char *zFilename; /* Name of the CSV file */
long iStart; /* Offset to start of data in zFilename */
int nCol; /* Number of columns in the CSV file */
+ unsigned int tstFlags; /* Bit values used for testing */
} CsvTable;
+/* Allowed values for tstFlags */
+#define CSVTEST_FIDX 0x0001 /* Pretend that constrained searchs cost less*/
+
/* A cursor for the CSV virtual table */
typedef struct CsvCursor {
sqlite3_vtab_cursor base; /* Base class. Must be first */
** schema=SCHEMA Optional
** header=YES|NO First row of CSV defines the names of
** columns if "yes". Default "no".
+** testflags=N Bitmask of test flags. Optional
**
** If header=no and not columns are listed, then the columns are named
** "c0", "c1", "c2", and so forth.
int i;
char *zFilename = 0;
char *zSchema = 0;
+ int tstFlags = 0;
CsvReader sRdr;
memset(&sRdr, 0, sizeof(sRdr));
goto csvtab_connect_error;
}
}else
+ if( (zValue = csv_parameter("testflags",9,z))!=0 ){
+ tstFlags = (unsigned int)atoi(zValue);
+ }else
{
csv_errmsg(&sRdr, "unrecognized parameter '%s'", z);
goto csvtab_connect_error;
pNew->nCol++;
}while( sRdr.cTerm==',' );
pNew->zFilename = zFilename;
+ pNew->tstFlags = tstFlags;
zFilename = 0;
pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0;
csv_reader_reset(&sRdr);
*pzErr = sqlite3_mprintf("%s", sRdr.zErr);
}
csv_reader_reset(&sRdr);
+ if( rc==SQLITE_OK ) rc = SQLITE_ERROR;
return rc;
}
}
/*
-** Only a forwards full table scan is supported. xBestIndex is a no-op.
+** Only a forwards full table scan is supported. xBestIndex is mostly
+** a no-op. If CSVTEST_FIDX is set, then the presence of equality
+** constraints lowers the estimated cost, which is fiction, but is useful
+** for testing certain kinds of virtual table behavior.
*/
static int csvtabBestIndex(
sqlite3_vtab *tab,
sqlite3_index_info *pIdxInfo
){
+ CsvTable *pTab = (CsvTable*)tab;
+ int i;
+ pIdxInfo->estimatedCost = 1000000;
+ if( (pTab->tstFlags & CSVTEST_FIDX)==0 ){
+ return SQLITE_OK;
+ }
+ for(i=0; i<pIdxInfo->nConstraint; i++){
+ if( pIdxInfo->aConstraint[i].usable==0 ) continue;
+ if( pIdxInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ ){
+ pIdxInfo->estimatedCost = 10;
+ break;
+ }
+ }
return SQLITE_OK;
}
-C Add\sthe\s"csv"\svirtual\stable\sfor\sreading\sCSV\sfiles,\sas\san\sextension\sin\nthe\sext/misc/\ssubfolder.
-D 2016-05-31T16:22:48.849
+C Add\sthe\stestflags\sparameter\sto\sthe\scsv\sextension.
+D 2016-05-31T18:08:35.263
F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234
F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704
F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83
-F ext/misc/csv.c 386ea82a7eeac9850000b43913a20453bc816a70
+F ext/misc/csv.c d9b1dac6e43891174560abdd7d1d68bac20a2277
F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 64ca1a835a89fd211078d2cd8f9b649e89be528d
-R b775d969691f2ff7971a8ef71faf9f8c
+P 00d3570c8bb96469c984903e20de589e998d4636
+R 7c1772dc60b41e0b51f7bd702d450189
U drh
-Z 58655b63021cdf0ee9fb657659454c01
+Z ed250383d88d82f9f9e7a2529e3cc23c