]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix comments and make magic numbers into #defines in the fsdir
authordrh <drh@noemail.net>
Fri, 16 Nov 2018 13:06:30 +0000 (13:06 +0000)
committerdrh <drh@noemail.net>
Fri, 16 Nov 2018 13:06:30 +0000 (13:06 +0000)
implementation.

FossilOrigin-Name: c537c9c3630ca979bdccab977275bfc11cce33ea54adb71a4bd4f46c85f65c6f

ext/misc/fileio.c
manifest
manifest.uuid

index 12d20084f738e1698ce69647bc6a267376d8361a..47f474b6b5ae8c6fbc97e6e5d70a35e3c6685845 100644 (file)
@@ -106,7 +106,18 @@ SQLITE_EXTENSION_INIT1
 #include <errno.h>
 
 
+/*
+** Structure of the fsdir() table-valued function
+*/
+                 /*    0    1    2     3    4           5             */
 #define FSDIR_SCHEMA "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)"
+#define FSDIR_COLUMN_NAME     0     /* Name of the file */
+#define FSDIR_COLUMN_MODE     1     /* Access mode */
+#define FSDIR_COLUMN_MTIME    2     /* Last modification time */
+#define FSDIR_COLUMN_DATA     3     /* File content */
+#define FSDIR_COLUMN_PATH     4     /* Path to top of search */
+#define FSDIR_COLUMN_DIR      5     /* Path is relative to this directory */
+
 
 /*
 ** Set the result stored by context ctx to a blob containing the 
@@ -695,20 +706,20 @@ static int fsdirColumn(
 ){
   fsdir_cursor *pCur = (fsdir_cursor*)cur;
   switch( i ){
-    case 0: { /* name */
+    case FSDIR_COLUMN_NAME: {
       sqlite3_result_text(ctx, &pCur->zPath[pCur->nBase], -1, SQLITE_TRANSIENT);
       break;
     }
 
-    case 1: /* mode */
+    case FSDIR_COLUMN_MODE:
       sqlite3_result_int64(ctx, pCur->sStat.st_mode);
       break;
 
-    case 2: /* mtime */
+    case FSDIR_COLUMN_MTIME:
       sqlite3_result_int64(ctx, pCur->sStat.st_mtime);
       break;
 
-    case 3: { /* data */
+    case FSDIR_COLUMN_DATA: {
       mode_t m = pCur->sStat.st_mode;
       if( S_ISDIR(m) ){
         sqlite3_result_null(ctx);
@@ -738,6 +749,12 @@ static int fsdirColumn(
         readFileContents(ctx, pCur->zPath);
       }
     }
+    case FSDIR_COLUMN_PATH:
+    default: {
+      /* The FSDIR_COLUMN_PATH and FSDIR_COLUMN_DIR are input parameters.
+      ** always return their values as NULL */
+      break;
+    }
   }
   return SQLITE_OK;
 }
@@ -764,6 +781,9 @@ static int fsdirEof(sqlite3_vtab_cursor *cur){
 
 /*
 ** xFilter callback.
+**
+** idxNum==1   PATH parameter only
+** idxNum==2   Both PATH and DIR supplied
 */
 static int fsdirFilter(
   sqlite3_vtab_cursor *cur, 
@@ -816,20 +836,18 @@ static int fsdirFilter(
 ** In this implementation idxNum is used to represent the
 ** query plan.  idxStr is unused.
 **
-** The query plan is represented by bits in idxNum:
+** The query plan is represented by values of idxNum:
 **
-**  (1)  start = $value  -- constraint exists
-**  (2)  stop = $value   -- constraint exists
-**  (4)  step = $value   -- constraint exists
-**  (8)  output in descending order
+**  (1)  The path value is supplied by argv[0]
+**  (2)  Path is in argv[0] and dir is in argv[1]
 */
 static int fsdirBestIndex(
   sqlite3_vtab *tab,
   sqlite3_index_info *pIdxInfo
 ){
   int i;                 /* Loop over constraints */
-  int idx4 = -1;
-  int idx5 = -1;
+  int idx4 = -1;         /* Index in pIdxInfo->aConstraint of PATH= */
+  int idx5 = -1;         /* Index in pIdxInfo->aConstraint of DIR= */
   const struct sqlite3_index_constraint *pConstraint;
 
   (void)tab;
index f107779c8d3aa5f8d65b553a64c982aae8f08d87..d038e8fe2486ff6294854c5ec65c2f25f32cc896 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\swith\svirtual\stable\s"fsdir"\sand\ssome\sjoin\squeries.
-D 2018-11-16T08:36:15.097
+C Fix\scomments\sand\smake\smagic\snumbers\sinto\s#defines\sin\sthe\sfsdir\nimplementation.
+D 2018-11-16T13:06:30.577
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in b730006b54c990461d864c5387f2e6f13aadb0236804555fb010ed6865a5f058
@@ -282,7 +282,7 @@ F ext/misc/csv.c 88333dc9f7dcf6a8148406f10ae04261e24e3b4c721550ae33e9e71f1265c1f
 F ext/misc/dbdump.c 12389a10c410fadf1e68eeb382def92d5a7fa9ce7cce4fb86a736fa2bac1000a
 F ext/misc/eval.c 6ea9b22a5fa0dd973b67ca4e53555be177bc0b7b263aadf1024429457c82c0e3
 F ext/misc/explain.c c82dd86f1156d32b284e0523a4bf6a93a85ab2a812caed48963e0774f3327185
-F ext/misc/fileio.c df4ac09b20344c3124418e4933a66b2ab719619de23a9c9b28cd834023e6a354
+F ext/misc/fileio.c 45acde5c065cc13bc9e65d4c3d623fa47441daf6d4a996d0ac9e6c9907b1d550
 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c
 F ext/misc/json1.c b0fba11c4f4e7c80534b08e120a296a8b301ee7e4d1a33f6647f1c047c8ce8e2
@@ -1778,7 +1778,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 0406ecbbe75513e342040b71fdd342462222dbb3820486b5f745d7865805c00b
-R 82d5a7448671b4f8277fc5a4db39923a
-U dan
-Z f02ccb27fc5c195f57ddc85e56947a53
+P 7fffcee0fc3fe8d036f0d93ec17673992c3edcf2bb454dc90d80142435b37946
+R 2a2c80e2a75c50071a742aace6ac9b0f
+U drh
+Z 0d4f2c0f6de8a62406810148e0ad4826
index b6bd89059fcc282e5a04541a67ebebd668f5ba0b..fcb164c061579b888774c9c7a1cffdab98c43730 100644 (file)
@@ -1 +1 @@
-7fffcee0fc3fe8d036f0d93ec17673992c3edcf2bb454dc90d80142435b37946
\ No newline at end of file
+c537c9c3630ca979bdccab977275bfc11cce33ea54adb71a4bd4f46c85f65c6f
\ No newline at end of file