Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Merge the latest 3.38.0 alpha of SQLite that includes support for the use of Bloom filters, in order to test SQLite. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
88a93432050c52b518e69846af497e52 |
| User & Date: | drh 2021-12-09 20:12:28.270 |
Context
|
2021-12-10
| ||
| 04:13 | dbstat command: account for tags named wiki-X which are not wiki pages, fix ordering of event/forumpost queries which caused event (tech-note) count to get overwritten by forumpost count. check-in: 28a60efcf9 user: stephan tags: trunk | |
|
2021-12-09
| ||
| 20:12 | Merge the latest 3.38.0 alpha of SQLite that includes support for the use of Bloom filters, in order to test SQLite. check-in: 88a9343205 user: drh tags: trunk | |
|
2021-12-06
| ||
| 07:24 | Disable the short option of `-U|--username USERNAME' for the `winsrv' command, as it conflicts with the global `-U|--user USER' option, and could never be used, anyway. check-in: 10e7100107 user: florian tags: trunk | |
Changes
Changes to src/shell.c.
| ︙ | ︙ | |||
8673 8674 8675 8676 8677 8678 8679 | ** xStep() callback for the zipfile() aggregate. This can be called in ** any of the following ways: ** ** SELECT zipfile(name,data) ... ** SELECT zipfile(name,mode,mtime,data) ... ** SELECT zipfile(name,mode,mtime,data,method) ... */ | | | 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 |
** xStep() callback for the zipfile() aggregate. This can be called in
** any of the following ways:
**
** SELECT zipfile(name,data) ...
** SELECT zipfile(name,mode,mtime,data) ...
** SELECT zipfile(name,mode,mtime,data,method) ...
*/
static void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
ZipfileCtx *p; /* Aggregate function context */
ZipfileEntry e; /* New entry to add to zip archive */
sqlite3_value *pName = 0;
sqlite3_value *pMode = 0;
sqlite3_value *pMtime = 0;
sqlite3_value *pData = 0;
|
| ︙ | ︙ | |||
8848 8849 8850 8851 8852 8853 8854 | } sqlite3_free(zErr); } /* ** xFinalize() callback for zipfile aggregate function. */ | | | 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 |
}
sqlite3_free(zErr);
}
/*
** xFinalize() callback for zipfile aggregate function.
*/
static void zipfileFinal(sqlite3_context *pCtx){
ZipfileCtx *p;
ZipfileEOCD eocd;
sqlite3_int64 nZip;
u8 *aZip;
p = (ZipfileCtx*)sqlite3_aggregate_context(pCtx, sizeof(ZipfileCtx));
if( p==0 ) return;
|
| ︙ | ︙ | |||
10408 10409 10410 10411 10412 10413 10414 | /* ** This function is called after candidate indexes have been created. It ** runs all the queries to see which indexes they prefer, and populates ** IdxStatement.zIdx and IdxStatement.zEQP with the results. */ | | | 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 |
/*
** This function is called after candidate indexes have been created. It
** runs all the queries to see which indexes they prefer, and populates
** IdxStatement.zIdx and IdxStatement.zEQP with the results.
*/
static int idxFindIndexes(
sqlite3expert *p,
char **pzErr /* OUT: Error message (sqlite3_malloc) */
){
IdxStatement *pStmt;
sqlite3 *dbm = p->dbm;
int rc = SQLITE_OK;
|
| ︙ | ︙ | |||
12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 |
#define MODE_Ascii 10 /* Use ASCII unit and record separators (0x1F/0x1E) */
#define MODE_Pretty 11 /* Pretty-print schemas */
#define MODE_EQP 12 /* Converts EXPLAIN QUERY PLAN output into a graph */
#define MODE_Json 13 /* Output JSON */
#define MODE_Markdown 14 /* Markdown formatting */
#define MODE_Table 15 /* MySQL-style table formatting */
#define MODE_Box 16 /* Unicode box-drawing characters */
static const char *modeDescr[] = {
"line",
"column",
"list",
"semi",
"html",
"insert",
"quote",
"tcl",
"csv",
"explain",
"ascii",
"prettyprint",
"eqp",
"json",
"markdown",
"table",
| > > | > > | 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 |
#define MODE_Ascii 10 /* Use ASCII unit and record separators (0x1F/0x1E) */
#define MODE_Pretty 11 /* Pretty-print schemas */
#define MODE_EQP 12 /* Converts EXPLAIN QUERY PLAN output into a graph */
#define MODE_Json 13 /* Output JSON */
#define MODE_Markdown 14 /* Markdown formatting */
#define MODE_Table 15 /* MySQL-style table formatting */
#define MODE_Box 16 /* Unicode box-drawing characters */
#define MODE_Count 17 /* Output only a count of the rows of output */
#define MODE_Off 18 /* No query output shown */
static const char *modeDescr[] = {
"line",
"column",
"list",
"semi",
"html",
"insert",
"quote",
"tcl",
"csv",
"explain",
"ascii",
"prettyprint",
"eqp",
"json",
"markdown",
"table",
"box",
"count",
"off"
};
/*
** These are the column/row/line separators used by the various
** import/export modes.
*/
#define SEP_Column "|"
|
| ︙ | ︙ | |||
13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 |
int *aiType /* Column types. Might be NULL */
){
int i;
ShellState *p = (ShellState*)pArg;
if( azArg==0 ) return 0;
switch( p->cMode ){
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
int len = strlen30(azCol[i] ? azCol[i] : "");
if( len>w ) w = len;
}
| > > > > | 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 |
int *aiType /* Column types. Might be NULL */
){
int i;
ShellState *p = (ShellState*)pArg;
if( azArg==0 ) return 0;
switch( p->cMode ){
case MODE_Count:
case MODE_Off: {
break;
}
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
int len = strlen30(azCol[i] ? azCol[i] : "");
if( len>w ) w = len;
}
|
| ︙ | ︙ | |||
13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 |
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n",
iCur);
}
if( pArg->pStmt ){
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
bReset);
raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
raw_printf(pArg->out, "Reprepare operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_RUN, bReset);
raw_printf(pArg->out, "Number of times run: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_MEMUSED, bReset);
| > > > > > > > | 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 |
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n",
iCur);
}
if( pArg->pStmt ){
int iHit, iMiss;
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
bReset);
raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
iHit = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_HIT, bReset);
iMiss = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_MISS, bReset);
if( iHit || iMiss ){
raw_printf(pArg->out, "Bloom filter bypass taken: %d/%d\n",
iHit, iHit+iMiss);
}
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
raw_printf(pArg->out, "Reprepare operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_RUN, bReset);
raw_printf(pArg->out, "Number of times run: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_MEMUSED, bReset);
|
| ︙ | ︙ | |||
14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 |
** Run a prepared statement
*/
static void exec_prepared_stmt(
ShellState *pArg, /* Pointer to ShellState */
sqlite3_stmt *pStmt /* Statment to run */
){
int rc;
if( pArg->cMode==MODE_Column
|| pArg->cMode==MODE_Table
|| pArg->cMode==MODE_Box
|| pArg->cMode==MODE_Markdown
){
exec_prepared_stmt_columnar(pArg, pStmt);
| > | 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 |
** Run a prepared statement
*/
static void exec_prepared_stmt(
ShellState *pArg, /* Pointer to ShellState */
sqlite3_stmt *pStmt /* Statment to run */
){
int rc;
sqlite3_uint64 nRow = 0;
if( pArg->cMode==MODE_Column
|| pArg->cMode==MODE_Table
|| pArg->cMode==MODE_Box
|| pArg->cMode==MODE_Markdown
){
exec_prepared_stmt_columnar(pArg, pStmt);
|
| ︙ | ︙ | |||
14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 |
int i, x;
assert(sizeof(int) <= sizeof(char *));
/* save off ptrs to column names */
for(i=0; i<nCol; i++){
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
}
do{
/* extract the data and data types */
for(i=0; i<nCol; i++){
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
azVals[i] = "";
}else{
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
| > | 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 |
int i, x;
assert(sizeof(int) <= sizeof(char *));
/* save off ptrs to column names */
for(i=0; i<nCol; i++){
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
}
do{
nRow++;
/* extract the data and data types */
for(i=0; i<nCol; i++){
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
azVals[i] = "";
}else{
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
|
| ︙ | ︙ | |||
14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 |
rc = sqlite3_step(pStmt);
}
}
} while( SQLITE_ROW == rc );
sqlite3_free(pData);
if( pArg->cMode==MODE_Json ){
fputs("]\n", pArg->out);
}
}
}
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
| > > | 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 |
rc = sqlite3_step(pStmt);
}
}
} while( SQLITE_ROW == rc );
sqlite3_free(pData);
if( pArg->cMode==MODE_Json ){
fputs("]\n", pArg->out);
}else if( pArg->cMode==MODE_Count ){
printf("%llu row%s\n", nRow, nRow!=1 ? "s" : "");
}
}
}
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
|
| ︙ | ︙ | |||
19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 |
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
}else if( c2=='m' && strncmp(azArg[1],"markdown",n2)==0 ){
p->mode = MODE_Markdown;
}else if( c2=='t' && strncmp(azArg[1],"table",n2)==0 ){
p->mode = MODE_Table;
}else if( c2=='b' && strncmp(azArg[1],"box",n2)==0 ){
p->mode = MODE_Box;
}else if( c2=='j' && strncmp(azArg[1],"json",n2)==0 ){
p->mode = MODE_Json;
}else if( nArg==1 ){
raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
}else{
raw_printf(stderr, "Error: mode should be one of: "
"ascii box column csv html insert json line list markdown "
| > > > > | 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 |
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
}else if( c2=='m' && strncmp(azArg[1],"markdown",n2)==0 ){
p->mode = MODE_Markdown;
}else if( c2=='t' && strncmp(azArg[1],"table",n2)==0 ){
p->mode = MODE_Table;
}else if( c2=='b' && strncmp(azArg[1],"box",n2)==0 ){
p->mode = MODE_Box;
}else if( c2=='c' && strncmp(azArg[1],"count",n2)==0 ){
p->mode = MODE_Count;
}else if( c2=='o' && strncmp(azArg[1],"off",n2)==0 ){
p->mode = MODE_Off;
}else if( c2=='j' && strncmp(azArg[1],"json",n2)==0 ){
p->mode = MODE_Json;
}else if( nArg==1 ){
raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
}else{
raw_printf(stderr, "Error: mode should be one of: "
"ascii box column csv html insert json line list markdown "
|
| ︙ | ︙ | |||
19995 19996 19997 19998 19999 20000 20001 |
}else
#endif /* SQLITE_DEBUG */
if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */
| < < < < < < < | | < | | | | | > > > > > > > > > > > > | 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 |
}else
#endif /* SQLITE_DEBUG */
if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */
int openMode = SHELL_OPEN_UNSPEC;
/* Check for command-line arguments */
for(iName=1; iName<nArg; iName++){
const char *z = azArg[iName];
if( optionMatch(z,"new") ){
newFlag = 1;
#ifdef SQLITE_HAVE_ZLIB
}else if( optionMatch(z, "zip") ){
openMode = SHELL_OPEN_ZIPFILE;
#endif
}else if( optionMatch(z, "append") ){
openMode = SHELL_OPEN_APPENDVFS;
}else if( optionMatch(z, "readonly") ){
openMode = SHELL_OPEN_READONLY;
}else if( optionMatch(z, "nofollow") ){
p->openFlags |= SQLITE_OPEN_NOFOLLOW;
#ifndef SQLITE_OMIT_DESERIALIZE
}else if( optionMatch(z, "deserialize") ){
openMode = SHELL_OPEN_DESERIALIZE;
}else if( optionMatch(z, "hexdb") ){
openMode = SHELL_OPEN_HEXDB;
}else if( optionMatch(z, "maxsize") && iName+1<nArg ){
p->szMax = integerValue(azArg[++iName]);
#endif /* SQLITE_OMIT_DESERIALIZE */
}else if( z[0]=='-' ){
utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1;
goto meta_command_exit;
}else if( zNewFilename ){
utf8_printf(stderr, "extra argument: \"%s\"\n", z);
rc = 1;
goto meta_command_exit;
}else{
zNewFilename = sqlite3_mprintf("%s", z);
}
}
/* Close the existing database */
session_close_all(p, -1);
close_db(p->db);
p->db = 0;
p->pAuxDb->zDbFilename = 0;
sqlite3_free(p->pAuxDb->zFreeOnClose);
p->pAuxDb->zFreeOnClose = 0;
p->openMode = openMode;
p->openFlags = 0;
p->szMax = 0;
/* If a filename is specified, try to open it first */
if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
if( newFlag && !p->bSafeMode ) shellDeleteFile(zNewFilename);
if( p->bSafeMode
&& p->openMode!=SHELL_OPEN_HEXDB
&& zNewFilename
&& strcmp(zNewFilename,":memory:")!=0
|
| ︙ | ︙ | |||
21258 21259 21260 21261 21262 21263 21264 21265 21266 |
}else
#ifndef SQLITE_UNTESTABLE
if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 ){
static const struct {
const char *zCtrlName; /* Name of a test-control option */
int ctrlCode; /* Integer code for that option */
const char *zUsage; /* Usage notes */
} aCtrl[] = {
| > | | | | | | | | | | | | | | | | | | | | | 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 |
}else
#ifndef SQLITE_UNTESTABLE
if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 ){
static const struct {
const char *zCtrlName; /* Name of a test-control option */
int ctrlCode; /* Integer code for that option */
int unSafe; /* Not valid for --safe mode */
const char *zUsage; /* Usage notes */
} aCtrl[] = {
{ "always", SQLITE_TESTCTRL_ALWAYS, 1, "BOOLEAN" },
{ "assert", SQLITE_TESTCTRL_ASSERT, 1, "BOOLEAN" },
/*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,1, "" },*/
/*{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "" },*/
{ "byteorder", SQLITE_TESTCTRL_BYTEORDER, 0, "" },
{ "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN" },
/*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"" },*/
{ "imposter", SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"},
{ "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS,0,"" },
{ "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,0,"BOOLEAN" },
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT,1, "BOOLEAN" },
{ "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS,0,"DISABLE-MASK" },
#ifdef YYCOVERAGE
{ "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE,0,"" },
#endif
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE,0, "OFFSET " },
{ "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE,0, "" },
{ "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" },
{ "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" },
{ "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" },
{ "sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" },
{ "tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" },
};
int testctrl = -1;
int iCtrl = -1;
int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
int isOk = 0;
int i, n2;
const char *zCmd = 0;
|
| ︙ | ︙ | |||
21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 |
goto meta_command_exit;
}
}
}
if( testctrl<0 ){
utf8_printf(stderr,"Error: unknown test-control: %s\n"
"Use \".testctrl --help\" for help\n", zCmd);
}else{
switch(testctrl){
/* sqlite3_test_control(int, db, int) */
case SQLITE_TESTCTRL_OPTIMIZATIONS:
if( nArg==3 ){
unsigned int opt = (unsigned int)strtol(azArg[2], 0, 0);
| > > > > > | 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 |
goto meta_command_exit;
}
}
}
if( testctrl<0 ){
utf8_printf(stderr,"Error: unknown test-control: %s\n"
"Use \".testctrl --help\" for help\n", zCmd);
}else if( aCtrl[iCtrl].unSafe && p->bSafeMode ){
utf8_printf(stderr,
"line %d: \".testctrl %s\" may not be used in safe mode\n",
p->lineno, aCtrl[iCtrl].zCtrlName);
exit(1);
}else{
switch(testctrl){
/* sqlite3_test_control(int, db, int) */
case SQLITE_TESTCTRL_OPTIMIZATIONS:
if( nArg==3 ){
unsigned int opt = (unsigned int)strtol(azArg[2], 0, 0);
|
| ︙ | ︙ |
Changes to src/sqlite3.c.
1 2 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite | | | 1 2 3 4 5 6 7 8 9 10 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.38.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% or more are commonly seen when SQLite is compiled as a single ** translation unit. ** ** This file is all you need to compile SQLite. To use SQLite in other |
| ︙ | ︙ | |||
448 449 450 451 452 453 454 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.38.0" #define SQLITE_VERSION_NUMBER 3038000 #define SQLITE_SOURCE_ID "2021-12-09 20:06:18 633bfeeea2bccdd44126acf3f61ecca163c9d933bdc787a2c18a697dc9406882" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
8246 8247 8248 8249 8250 8251 8252 | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 #define SQLITE_TESTCTRL_SEEK_COUNT 30 #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 | > | | 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 #define SQLITE_TESTCTRL_SEEK_COUNT 30 #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 #define SQLITE_TESTCTRL_LOGEST 33 #define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */ /* ** CAPI3REF: SQL Keyword Checking ** ** These routines provide access to the set of SQL language keywords ** recognized by SQLite. Applications can uses these routines to determine ** whether or not a specific identifier needs to be escaped (for example, |
| ︙ | ︙ | |||
8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 | ** ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> ** <dd>^This is the number of times that the prepared statement has ** been run. A single "run" for the purposes of this counter is one ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. ** The counter is incremented on the first [sqlite3_step()] call of each ** cycle. ** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 #define SQLITE_STMTSTATUS_REPREPARE 5 #define SQLITE_STMTSTATUS_RUN 6 #define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of | > > > > > > > > > > > > | 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 | ** ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> ** <dd>^This is the number of times that the prepared statement has ** been run. A single "run" for the purposes of this counter is one ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. ** The counter is incremented on the first [sqlite3_step()] call of each ** cycle. ** ** [[SQLITE_STMTSTATUS_FILTER_MISS]] ** [[SQLITE_STMTSTATUS_FILTER HIT]] ** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br> ** SQLITE_STMTSTATUS_FILTER_MISS</dt> ** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join ** step was bypassed because a Bloom filter returned not-found. The ** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of ** times that the Bloom filter returned a find, and thus the join step ** had to be processed as normal. ** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 #define SQLITE_STMTSTATUS_REPREPARE 5 #define SQLITE_STMTSTATUS_RUN 6 #define SQLITE_STMTSTATUS_FILTER_MISS 7 #define SQLITE_STMTSTATUS_FILTER_HIT 8 #define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of |
| ︙ | ︙ | |||
13550 13551 13552 13553 13554 13555 13556 | #define TK_DATABASE 38 #define TK_DESC 39 #define TK_DETACH 40 #define TK_EACH 41 #define TK_FAIL 42 #define TK_OR 43 #define TK_AND 44 | < | | | > | 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 | #define TK_DATABASE 38 #define TK_DESC 39 #define TK_DETACH 40 #define TK_EACH 41 #define TK_FAIL 42 #define TK_OR 43 #define TK_AND 44 #define TK_MATCH 45 #define TK_LIKE_KW 46 #define TK_BETWEEN 47 #define TK_IS 48 #define TK_IN 49 #define TK_ISNULL 50 #define TK_NOTNULL 51 #define TK_NE 52 #define TK_EQ 53 #define TK_GT 54 #define TK_LE 55 |
| ︙ | ︙ | |||
13794 13795 13796 13797 13798 13799 13800 | /* ** The default initial allocation for the pagecache when using separate ** pagecaches for each database connection. A positive number is the ** number of pages. A negative number N translations means that a buffer ** of -1024*N bytes is allocated and used for as many pages as it will hold. ** | | | 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 | /* ** The default initial allocation for the pagecache when using separate ** pagecaches for each database connection. A positive number is the ** number of pages. A negative number N translations means that a buffer ** of -1024*N bytes is allocated and used for as many pages as it will hold. ** ** The default value of "20" was chosen to minimize the run-time of the ** speedtest1 test program with options: --shrink-memory --reprepare */ #ifndef SQLITE_DEFAULT_PCACHE_INITSZ # define SQLITE_DEFAULT_PCACHE_INITSZ 20 #endif /* |
| ︙ | ︙ | |||
15249 15250 15251 15252 15253 15254 15255 | #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ #define OP_ElseEq 58 /* jump, same as TK_ESCAPE */ #define OP_IfNotZero 59 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ #define OP_DecrJumpZero 60 /* jump, synopsis: if (--r[P1])==0 goto P2 */ #define OP_IncrVacuum 61 /* jump */ #define OP_VNext 62 /* jump */ | > | | | | | | | | | | | | | | | | | | < < > > | | | | | | | | | | | | | | | | < | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | > | | 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 |
#define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
#define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
#define OP_ElseEq 58 /* jump, same as TK_ESCAPE */
#define OP_IfNotZero 59 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
#define OP_DecrJumpZero 60 /* jump, synopsis: if (--r[P1])==0 goto P2 */
#define OP_IncrVacuum 61 /* jump */
#define OP_VNext 62 /* jump */
#define OP_Filter 63 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
#define OP_Init 64 /* jump, synopsis: Start at P2 */
#define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */
#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
#define OP_Return 67
#define OP_EndCoroutine 68
#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
#define OP_Halt 70
#define OP_Integer 71 /* synopsis: r[P2]=P1 */
#define OP_Int64 72 /* synopsis: r[P2]=P4 */
#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
#define OP_Null 74 /* synopsis: r[P2..P3]=NULL */
#define OP_SoftNull 75 /* synopsis: r[P1]=NULL */
#define OP_Blob 76 /* synopsis: r[P2]=P4 (len=P1) */
#define OP_Variable 77 /* synopsis: r[P2]=parameter(P1,P4) */
#define OP_Move 78 /* synopsis: r[P2@P3]=r[P1@P3] */
#define OP_Copy 79 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
#define OP_SCopy 80 /* synopsis: r[P2]=r[P1] */
#define OP_IntCopy 81 /* synopsis: r[P2]=r[P1] */
#define OP_FkCheck 82
#define OP_ResultRow 83 /* synopsis: output=r[P1@P2] */
#define OP_CollSeq 84
#define OP_AddImm 85 /* synopsis: r[P1]=r[P1]+P2 */
#define OP_RealAffinity 86
#define OP_Cast 87 /* synopsis: affinity(r[P1]) */
#define OP_Permutation 88
#define OP_Compare 89 /* synopsis: r[P1@P3] <-> r[P2@P3] */
#define OP_IsTrue 90 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
#define OP_ZeroOrNull 91 /* synopsis: r[P2] = 0 OR NULL */
#define OP_Offset 92 /* synopsis: r[P3] = sqlite_offset(P1) */
#define OP_Column 93 /* synopsis: r[P3]=PX */
#define OP_TypeCheck 94 /* synopsis: typecheck(r[P1@P2]) */
#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
#define OP_Count 97 /* synopsis: r[P2]=count() */
#define OP_ReadCookie 98
#define OP_SetCookie 99
#define OP_ReopenIdx 100 /* synopsis: root=P2 iDb=P3 */
#define OP_OpenRead 101 /* synopsis: root=P2 iDb=P3 */
#define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
#define OP_ShiftRight 105 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
#define OP_Add 106 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
#define OP_Subtract 107 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply 108 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_OpenWrite 112 /* synopsis: root=P2 iDb=P3 */
#define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
#define OP_OpenDup 114
#define OP_OpenAutoindex 115 /* synopsis: nColumn=P2 */
#define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */
#define OP_OpenEphemeral 117 /* synopsis: nColumn=P2 */
#define OP_SorterOpen 118
#define OP_SequenceTest 119 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
#define OP_OpenPseudo 120 /* synopsis: P3 columns in r[P2] */
#define OP_Close 121
#define OP_ColumnsUsed 122
#define OP_SeekScan 123 /* synopsis: Scan-ahead up to P1 rows */
#define OP_SeekHit 124 /* synopsis: set P2<=seekHit<=P3 */
#define OP_Sequence 125 /* synopsis: r[P2]=cursor[P1].ctr++ */
#define OP_NewRowid 126 /* synopsis: r[P2]=rowid */
#define OP_Insert 127 /* synopsis: intkey=r[P3] data=r[P2] */
#define OP_RowCell 128
#define OP_Delete 129
#define OP_ResetCount 130
#define OP_SorterCompare 131 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
#define OP_SorterData 132 /* synopsis: r[P2]=data */
#define OP_RowData 133 /* synopsis: r[P2]=data */
#define OP_Rowid 134 /* synopsis: r[P2]=rowid */
#define OP_NullRow 135
#define OP_SeekEnd 136
#define OP_IdxInsert 137 /* synopsis: key=r[P2] */
#define OP_SorterInsert 138 /* synopsis: key=r[P2] */
#define OP_IdxDelete 139 /* synopsis: key=r[P2@P3] */
#define OP_DeferredSeek 140 /* synopsis: Move P3 to P1.rowid if needed */
#define OP_IdxRowid 141 /* synopsis: r[P2]=rowid */
#define OP_FinishSeek 142
#define OP_Destroy 143
#define OP_Clear 144
#define OP_ResetSorter 145
#define OP_CreateBtree 146 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
#define OP_SqlExec 147
#define OP_ParseSchema 148
#define OP_LoadAnalysis 149
#define OP_DropTable 150
#define OP_DropIndex 151
#define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
#define OP_DropTrigger 153
#define OP_IntegrityCk 154
#define OP_RowSetAdd 155 /* synopsis: rowset(P1)=r[P2] */
#define OP_Param 156
#define OP_FkCounter 157 /* synopsis: fkctr[P1]+=P2 */
#define OP_MemMax 158 /* synopsis: r[P1]=max(r[P1],r[P2]) */
#define OP_OffsetLimit 159 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
#define OP_AggInverse 160 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
#define OP_AggStep 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
#define OP_AggStep1 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
#define OP_AggValue 163 /* synopsis: r[P3]=value N=P2 */
#define OP_AggFinal 164 /* synopsis: accum=r[P1] N=P2 */
#define OP_Expire 165
#define OP_CursorLock 166
#define OP_CursorUnlock 167
#define OP_TableLock 168 /* synopsis: iDb=P1 root=P2 write=P3 */
#define OP_VBegin 169
#define OP_VCreate 170
#define OP_VDestroy 171
#define OP_VOpen 172
#define OP_VColumn 173 /* synopsis: r[P3]=vcolumn(P2) */
#define OP_VRename 174
#define OP_Pagecount 175
#define OP_MaxPgcnt 176
#define OP_FilterAdd 177 /* synopsis: filter(P1) += key(P3@P4) */
#define OP_Trace 178
#define OP_CursorHint 179
#define OP_ReleaseReg 180 /* synopsis: release r[P1@P2] mask P3 */
#define OP_Noop 181
#define OP_Explain 182
#define OP_Abortable 183
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
** are encoded into bitvectors as follows:
*/
#define OPFLG_JUMP 0x01 /* jump: P2 holds jmp target */
#define OPFLG_IN1 0x02 /* in1: P1 is an input */
#define OPFLG_IN2 0x04 /* in2: P2 is an input */
#define OPFLG_IN3 0x08 /* in3: P3 is an input */
#define OPFLG_OUT2 0x10 /* out2: P2 is an output */
#define OPFLG_OUT3 0x20 /* out3: P3 is an output */
#define OPFLG_INITIALIZER {\
/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
/* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
/* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x03, 0x01, 0x09,\
/* 24 */ 0x09, 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09,\
/* 32 */ 0x09, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
/* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
/* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,\
/* 88 */ 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00,\
/* 96 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
/* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
/* 136 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,\
/* 144 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 152 */ 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a,\
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
/* 176 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
}
/* The resolve3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
** JUMP opcode the better, so the mkopcodeh.tcl script that
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
#define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */
/************** End of opcodes.h *********************************************/
/************** Continuing where we left off in vdbe.h ***********************/
/*
** Additional non-public SQLITE_PREPARE_* flags
*/
|
| ︙ | ︙ | |||
16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 | #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */ #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ #define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */ /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* ** Macros for testing whether or not optimizations are enabled or disabled. */ #define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0) #define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0) | > > | 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 | #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */ #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ #define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */ /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ #define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */ #define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* ** Macros for testing whether or not optimizations are enabled or disabled. */ #define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0) #define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0) |
| ︙ | ︙ | |||
19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 |
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
Upsert*);
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
| > | 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 |
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe*,int,const char*);
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
Upsert*);
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
|
| ︙ | ︙ | |||
19717 19718 19719 19720 19721 19722 19723 | #ifndef SQLITE_OMIT_UTF16 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); #endif SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**); SQLITE_PRIVATE LogEst sqlite3LogEst(u64); SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst); | < < < < < < | 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 | #ifndef SQLITE_OMIT_UTF16 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); #endif SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**); SQLITE_PRIVATE LogEst sqlite3LogEst(u64); SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst); SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double); SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst); SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int); SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int); SQLITE_PRIVATE int sqlite3VListNameToNum(VList*,const char*,int); /* ** Routines to read and write variable-length integers. These used to ** be defined locally, but now we use the varint routines in the util.c |
| ︙ | ︙ | |||
22104 22105 22106 22107 22108 22109 22110 | bft changeCntOn:1; /* True to update the change-counter */ bft runOnlyOnce:1; /* Automatically expire on reset */ bft usesStmtJournal:1; /* True if uses a statement journal */ bft readOnly:1; /* True for statements that do not write */ bft bIsReader:1; /* True for statements that read */ yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ | | | 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 | bft changeCntOn:1; /* True to update the change-counter */ bft runOnlyOnce:1; /* Automatically expire on reset */ bft usesStmtJournal:1; /* True if uses a statement journal */ bft readOnly:1; /* True for statements that do not write */ bft bIsReader:1; /* True for statements that read */ yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ u32 aCounter[9]; /* Counters used by sqlite3_stmt_status() */ char *zSql; /* Text of the SQL statement that generated this */ #ifdef SQLITE_ENABLE_NORMALIZE char *zNormSql; /* Normalization of the associated SQL statement */ DblquoteStr *pDblStr; /* List of double-quoted string literals */ #endif void *pFree; /* Free this when deleting the vdbe */ VdbeFrame *pFrame; /* Parent frame */ |
| ︙ | ︙ | |||
22212 22213 22214 22215 22216 22217 22218 | #ifdef SQLITE_DEBUG SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); #endif SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double); | | | 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 | #ifdef SQLITE_DEBUG SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); #endif SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double); SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*); SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*); SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull); SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8); |
| ︙ | ︙ | |||
23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 | #endif sqlite3_mutex_enter(mutex); pX = localtime(t); #ifndef SQLITE_UNTESTABLE if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0; #endif if( pX ) *pTm = *pX; sqlite3_mutex_leave(mutex); rc = pX==0; #else #ifndef SQLITE_UNTESTABLE if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; #endif #if HAVE_LOCALTIME_R rc = localtime_r(t, pTm)==0; | > > | 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 | #endif sqlite3_mutex_enter(mutex); pX = localtime(t); #ifndef SQLITE_UNTESTABLE if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0; #endif if( pX ) *pTm = *pX; #if SQLITE_THREADSAFE>0 sqlite3_mutex_leave(mutex); #endif rc = pX==0; #else #ifndef SQLITE_UNTESTABLE if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; #endif #if HAVE_LOCALTIME_R rc = localtime_r(t, pTm)==0; |
| ︙ | ︙ | |||
23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 |
const char *z, /* The text of the modifier */
int n, /* Length of zMod in bytes */
DateTime *p /* The date/time value to be modified */
){
int rc = 1;
double r;
switch(sqlite3UpperToLower[(u8)z[0]] ){
#ifndef SQLITE_OMIT_LOCALTIME
case 'l': {
/* localtime
**
** Assuming the current time value is UTC (a.k.a. GMT), shift it to
** show local time.
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 |
const char *z, /* The text of the modifier */
int n, /* Length of zMod in bytes */
DateTime *p /* The date/time value to be modified */
){
int rc = 1;
double r;
switch(sqlite3UpperToLower[(u8)z[0]] ){
case 'a': {
/*
** auto
**
** If rawS is available, then interpret as a julian day number, or
** a unix timestamp, depending on its magnitude.
*/
if( sqlite3_stricmp(z, "auto")==0 ){
if( !p->rawS || p->validJD ){
rc = 0;
p->rawS = 0;
}else if( p->s>=-210866760000 && p->s<=253402300799 ){
r = p->s*1000.0 + 210866760000000.0;
clearYMD_HMS_TZ(p);
p->iJD = (sqlite3_int64)(r + 0.5);
p->validJD = 1;
p->rawS = 0;
rc = 0;
}
}
break;
}
case 'j': {
/*
** julianday
**
** Always interpret the prior number as a julian-day value. If this
** is not the first modifier, or if the prior argument is not a numeric
** value in the allowed range of julian day numbers understood by
** SQLite (0..5373484.5) then the result will be NULL.
*/
if( sqlite3_stricmp(z, "julianday")==0 ){
if( p->validJD && p->rawS ){
rc = 0;
p->rawS = 0;
}
}
break;
}
#ifndef SQLITE_OMIT_LOCALTIME
case 'l': {
/* localtime
**
** Assuming the current time value is UTC (a.k.a. GMT), shift it to
** show local time.
*/
|
| ︙ | ︙ | |||
23612 23613 23614 23615 23616 23617 23618 23619 23620 23621 23622 23623 23624 23625 |
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
computeJD(&x);
sqlite3_result_double(context, x.iJD/86400000.0);
}
}
/*
** datetime( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD HH:MM:SS
*/
static void datetimeFunc(
| > > > > > > > > > > > > > > > > > > | 23666 23667 23668 23669 23670 23671 23672 23673 23674 23675 23676 23677 23678 23679 23680 23681 23682 23683 23684 23685 23686 23687 23688 23689 23690 23691 23692 23693 23694 23695 23696 23697 |
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
computeJD(&x);
sqlite3_result_double(context, x.iJD/86400000.0);
}
}
/*
** unixepoch( TIMESTRING, MOD, MOD, ...)
**
** Return the number of seconds (including fractional seconds) since
** the unix epoch of 1970-01-01 00:00:00 GMT.
*/
static void unixepochFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
computeJD(&x);
sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
}
}
/*
** datetime( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD HH:MM:SS
*/
static void datetimeFunc(
|
| ︙ | ︙ | |||
23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 |
** functions. This should be the only routine in this file with
** external linkage.
*/
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
PURE_DATE(julianday, -1, 0, 0, juliandayFunc ),
PURE_DATE(date, -1, 0, 0, dateFunc ),
PURE_DATE(time, -1, 0, 0, timeFunc ),
PURE_DATE(datetime, -1, 0, 0, datetimeFunc ),
PURE_DATE(strftime, -1, 0, 0, strftimeFunc ),
DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
DFUNCTION(current_date, 0, 0, 0, cdateFunc ),
| > | 23961 23962 23963 23964 23965 23966 23967 23968 23969 23970 23971 23972 23973 23974 23975 |
** functions. This should be the only routine in this file with
** external linkage.
*/
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
PURE_DATE(julianday, -1, 0, 0, juliandayFunc ),
PURE_DATE(unixepoch, -1, 0, 0, unixepochFunc ),
PURE_DATE(date, -1, 0, 0, dateFunc ),
PURE_DATE(time, -1, 0, 0, timeFunc ),
PURE_DATE(datetime, -1, 0, 0, datetimeFunc ),
PURE_DATE(strftime, -1, 0, 0, strftimeFunc ),
DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
DFUNCTION(current_date, 0, 0, 0, cdateFunc ),
|
| ︙ | ︙ | |||
33606 33607 33608 33609 33610 33611 33612 |
while( x>255 ){ y += 40; x >>= 4; } /*OPTIMIZATION-IF-TRUE*/
while( x>15 ){ y += 10; x >>= 1; }
#endif
}
return a[x&7] + y - 10;
}
| < < < < < < < < < < < < < < < < | 33679 33680 33681 33682 33683 33684 33685 33686 33687 33688 33689 33690 33691 33692 33693 33694 33695 33696 33697 33698 33699 33700 33701 33702 33703 33704 33705 33706 33707 33708 33709 33710 33711 33712 33713 33714 33715 33716 33717 33718 33719 |
while( x>255 ){ y += 40; x >>= 4; } /*OPTIMIZATION-IF-TRUE*/
while( x>15 ){ y += 10; x >>= 1; }
#endif
}
return a[x&7] + y - 10;
}
/*
** Convert a double into a LogEst
** In other words, compute an approximation for 10*log2(x).
*/
SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){
u64 a;
LogEst e;
assert( sizeof(x)==8 && sizeof(a)==8 );
if( x<=1 ) return 0;
if( x<=2000000000 ) return sqlite3LogEst((u64)x);
memcpy(&a, &x, 8);
e = (a>>52) - 1022;
return e*10;
}
/*
** Convert a LogEst into an integer.
*/
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
u64 n;
n = x%10;
x /= 10;
if( n>=5 ) n -= 2;
else if( n>=1 ) n -= 1;
if( x>60 ) return (u64)LARGEST_INT64;
return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
}
/*
** Add a new name/number pair to a VList. This might require that the
** VList object be reallocated, so return the new VList. If an OOM
** error occurs, the original VList returned and the
** db->mallocFailed flag is set.
**
|
| ︙ | ︙ | |||
34102 34103 34104 34105 34106 34107 34108 |
/* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
/* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
/* 58 */ "ElseEq" OpHelp(""),
/* 59 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
/* 60 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 61 */ "IncrVacuum" OpHelp(""),
/* 62 */ "VNext" OpHelp(""),
| > | | | | | | | | | | | | | | | | | | < < > > | | | | | | | | | | | | | | | | | | < | > | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | 34159 34160 34161 34162 34163 34164 34165 34166 34167 34168 34169 34170 34171 34172 34173 34174 34175 34176 34177 34178 34179 34180 34181 34182 34183 34184 34185 34186 34187 34188 34189 34190 34191 34192 34193 34194 34195 34196 34197 34198 34199 34200 34201 34202 34203 34204 34205 34206 34207 34208 34209 34210 34211 34212 34213 34214 34215 34216 34217 34218 34219 34220 34221 34222 34223 34224 34225 34226 34227 34228 34229 34230 34231 34232 34233 34234 34235 34236 34237 34238 34239 34240 34241 34242 34243 34244 34245 34246 34247 34248 34249 34250 34251 34252 34253 34254 34255 34256 34257 34258 34259 34260 34261 34262 34263 34264 34265 34266 34267 34268 34269 34270 34271 34272 34273 34274 34275 34276 34277 34278 34279 34280 34281 34282 34283 34284 34285 34286 34287 34288 34289 34290 34291 34292 34293 |
/* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
/* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
/* 58 */ "ElseEq" OpHelp(""),
/* 59 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
/* 60 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 61 */ "IncrVacuum" OpHelp(""),
/* 62 */ "VNext" OpHelp(""),
/* 63 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
/* 64 */ "Init" OpHelp("Start at P2"),
/* 65 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
/* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
/* 67 */ "Return" OpHelp(""),
/* 68 */ "EndCoroutine" OpHelp(""),
/* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
/* 70 */ "Halt" OpHelp(""),
/* 71 */ "Integer" OpHelp("r[P2]=P1"),
/* 72 */ "Int64" OpHelp("r[P2]=P4"),
/* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
/* 74 */ "Null" OpHelp("r[P2..P3]=NULL"),
/* 75 */ "SoftNull" OpHelp("r[P1]=NULL"),
/* 76 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
/* 77 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
/* 78 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
/* 79 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
/* 80 */ "SCopy" OpHelp("r[P2]=r[P1]"),
/* 81 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
/* 82 */ "FkCheck" OpHelp(""),
/* 83 */ "ResultRow" OpHelp("output=r[P1@P2]"),
/* 84 */ "CollSeq" OpHelp(""),
/* 85 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
/* 86 */ "RealAffinity" OpHelp(""),
/* 87 */ "Cast" OpHelp("affinity(r[P1])"),
/* 88 */ "Permutation" OpHelp(""),
/* 89 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
/* 90 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
/* 91 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
/* 92 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
/* 93 */ "Column" OpHelp("r[P3]=PX"),
/* 94 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
/* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
/* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
/* 97 */ "Count" OpHelp("r[P2]=count()"),
/* 98 */ "ReadCookie" OpHelp(""),
/* 99 */ "SetCookie" OpHelp(""),
/* 100 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
/* 101 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
/* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
/* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
/* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
/* 105 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
/* 106 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
/* 107 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
/* 108 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
/* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
/* 112 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
/* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
/* 114 */ "OpenDup" OpHelp(""),
/* 115 */ "OpenAutoindex" OpHelp("nColumn=P2"),
/* 116 */ "String8" OpHelp("r[P2]='P4'"),
/* 117 */ "OpenEphemeral" OpHelp("nColumn=P2"),
/* 118 */ "SorterOpen" OpHelp(""),
/* 119 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
/* 120 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
/* 121 */ "Close" OpHelp(""),
/* 122 */ "ColumnsUsed" OpHelp(""),
/* 123 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
/* 124 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
/* 125 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
/* 126 */ "NewRowid" OpHelp("r[P2]=rowid"),
/* 127 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
/* 128 */ "RowCell" OpHelp(""),
/* 129 */ "Delete" OpHelp(""),
/* 130 */ "ResetCount" OpHelp(""),
/* 131 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
/* 132 */ "SorterData" OpHelp("r[P2]=data"),
/* 133 */ "RowData" OpHelp("r[P2]=data"),
/* 134 */ "Rowid" OpHelp("r[P2]=rowid"),
/* 135 */ "NullRow" OpHelp(""),
/* 136 */ "SeekEnd" OpHelp(""),
/* 137 */ "IdxInsert" OpHelp("key=r[P2]"),
/* 138 */ "SorterInsert" OpHelp("key=r[P2]"),
/* 139 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
/* 140 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
/* 141 */ "IdxRowid" OpHelp("r[P2]=rowid"),
/* 142 */ "FinishSeek" OpHelp(""),
/* 143 */ "Destroy" OpHelp(""),
/* 144 */ "Clear" OpHelp(""),
/* 145 */ "ResetSorter" OpHelp(""),
/* 146 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
/* 147 */ "SqlExec" OpHelp(""),
/* 148 */ "ParseSchema" OpHelp(""),
/* 149 */ "LoadAnalysis" OpHelp(""),
/* 150 */ "DropTable" OpHelp(""),
/* 151 */ "DropIndex" OpHelp(""),
/* 152 */ "Real" OpHelp("r[P2]=P4"),
/* 153 */ "DropTrigger" OpHelp(""),
/* 154 */ "IntegrityCk" OpHelp(""),
/* 155 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
/* 156 */ "Param" OpHelp(""),
/* 157 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
/* 158 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
/* 159 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
/* 160 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
/* 161 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
/* 162 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
/* 163 */ "AggValue" OpHelp("r[P3]=value N=P2"),
/* 164 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
/* 165 */ "Expire" OpHelp(""),
/* 166 */ "CursorLock" OpHelp(""),
/* 167 */ "CursorUnlock" OpHelp(""),
/* 168 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
/* 169 */ "VBegin" OpHelp(""),
/* 170 */ "VCreate" OpHelp(""),
/* 171 */ "VDestroy" OpHelp(""),
/* 172 */ "VOpen" OpHelp(""),
/* 173 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
/* 174 */ "VRename" OpHelp(""),
/* 175 */ "Pagecount" OpHelp(""),
/* 176 */ "MaxPgcnt" OpHelp(""),
/* 177 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
/* 178 */ "Trace" OpHelp(""),
/* 179 */ "CursorHint" OpHelp(""),
/* 180 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
/* 181 */ "Noop" OpHelp(""),
/* 182 */ "Explain" OpHelp(""),
/* 183 */ "Abortable" OpHelp(""),
};
return azName[i];
}
#endif
/************** End of opcodes.c *********************************************/
/************** Begin file os_unix.c *****************************************/
|
| ︙ | ︙ | |||
68261 68262 68263 68264 68265 68266 68267 | } /* ** Make sure pBt->pTmpSpace points to an allocation of ** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child ** pointer. */ | | > | > > > | > > > > > | > | | | | | | | | | | | | | | | < | | < < > | 68320 68321 68322 68323 68324 68325 68326 68327 68328 68329 68330 68331 68332 68333 68334 68335 68336 68337 68338 68339 68340 68341 68342 68343 68344 68345 68346 68347 68348 68349 68350 68351 68352 68353 68354 68355 68356 68357 68358 68359 68360 68361 68362 68363 68364 68365 |
}
/*
** Make sure pBt->pTmpSpace points to an allocation of
** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child
** pointer.
*/
static SQLITE_NOINLINE int allocateTempSpace(BtShared *pBt){
assert( pBt!=0 );
assert( pBt->pTmpSpace==0 );
/* This routine is called only by btreeCursor() when allocating the
** first write cursor for the BtShared object */
assert( pBt->pCursor!=0 && (pBt->pCursor->curFlags & BTCF_WriteFlag)!=0 );
pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
if( pBt->pTmpSpace==0 ){
BtCursor *pCur = pBt->pCursor;
pBt->pCursor = pCur->pNext; /* Unlink the cursor */
memset(pCur, 0, sizeof(*pCur));
return SQLITE_NOMEM_BKPT;
}
/* One of the uses of pBt->pTmpSpace is to format cells before
** inserting them into a leaf page (function fillInCell()). If
** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
** by the various routines that manipulate binary cells. Which
** can mean that fillInCell() only initializes the first 2 or 3
** bytes of pTmpSpace, but that the first 4 bytes are copied from
** it into a database page. This is not actually a problem, but it
** does cause a valgrind error when the 1 or 2 bytes of unitialized
** data is passed to system call write(). So to avoid this error,
** zero the first 4 bytes of temp space here.
**
** Also: Provide four bytes of initialized space before the
** beginning of pTmpSpace as an area available to prepend the
** left-child pointer to the beginning of a cell.
*/
memset(pBt->pTmpSpace, 0, 8);
pBt->pTmpSpace += 4;
return SQLITE_OK;
}
/*
** Free the pBt->pTmpSpace allocation
*/
static void freeTempSpace(BtShared *pBt){
if( pBt->pTmpSpace ){
|
| ︙ | ︙ | |||
70025 70026 70027 70028 70029 70030 70031 | /* Assert that the caller has opened the required transaction. */ assert( p->inTrans>TRANS_NONE ); assert( wrFlag==0 || p->inTrans==TRANS_WRITE ); assert( pBt->pPage1 && pBt->pPage1->aData ); assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 ); | < < < < | < | > > > | > > > > | 70092 70093 70094 70095 70096 70097 70098 70099 70100 70101 70102 70103 70104 70105 70106 70107 70108 70109 70110 70111 70112 70113 70114 70115 70116 70117 70118 70119 70120 70121 70122 70123 70124 70125 70126 70127 70128 70129 70130 70131 70132 70133 70134 70135 70136 70137 70138 70139 70140 |
/* Assert that the caller has opened the required transaction. */
assert( p->inTrans>TRANS_NONE );
assert( wrFlag==0 || p->inTrans==TRANS_WRITE );
assert( pBt->pPage1 && pBt->pPage1->aData );
assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );
if( iTable<=1 ){
if( iTable<1 ){
return SQLITE_CORRUPT_BKPT;
}else if( btreePagecount(pBt)==0 ){
assert( wrFlag==0 );
iTable = 0;
}
}
/* Now that no other errors can occur, finish filling in the BtCursor
** variables and link the cursor into the BtShared list. */
pCur->pgnoRoot = iTable;
pCur->iPage = -1;
pCur->pKeyInfo = pKeyInfo;
pCur->pBtree = p;
pCur->pBt = pBt;
pCur->curFlags = 0;
/* If there are two or more cursors on the same btree, then all such
** cursors *must* have the BTCF_Multiple flag set. */
for(pX=pBt->pCursor; pX; pX=pX->pNext){
if( pX->pgnoRoot==iTable ){
pX->curFlags |= BTCF_Multiple;
pCur->curFlags = BTCF_Multiple;
}
}
pCur->eState = CURSOR_INVALID;
pCur->pNext = pBt->pCursor;
pBt->pCursor = pCur;
if( wrFlag ){
pCur->curFlags |= BTCF_WriteFlag;
pCur->curPagerFlags = 0;
if( pBt->pTmpSpace==0 ) return allocateTempSpace(pBt);
}else{
pCur->curPagerFlags = PAGER_GET_READONLY;
}
return SQLITE_OK;
}
static int btreeCursorWithLock(
Btree *p, /* The btree */
Pgno iTable, /* Root page of table to open */
int wrFlag, /* 1 to write. 0 read-only */
struct KeyInfo *pKeyInfo, /* First arg to comparison function */
|
| ︙ | ︙ | |||
77810 77811 77812 77813 77814 77815 77816 | ** a floating-point then the value returned is the integer part. ** If pMem is a string or blob, then we make an attempt to convert ** it into an integer and return that. If pMem represents an ** an SQL-NULL value, return 0. ** ** If pMem represents a string value, its encoding might be changed. */ | | | | 77879 77880 77881 77882 77883 77884 77885 77886 77887 77888 77889 77890 77891 77892 77893 77894 77895 77896 77897 77898 |
** a floating-point then the value returned is the integer part.
** If pMem is a string or blob, then we make an attempt to convert
** it into an integer and return that. If pMem represents an
** an SQL-NULL value, return 0.
**
** If pMem represents a string value, its encoding might be changed.
*/
static SQLITE_NOINLINE i64 memIntValue(const Mem *pMem){
i64 value = 0;
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
return value;
}
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem *pMem){
int flags;
assert( pMem!=0 );
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
flags = pMem->flags;
if( flags & (MEM_Int|MEM_IntReal) ){
testcase( flags & MEM_IntReal );
|
| ︙ | ︙ | |||
87364 87365 87366 87367 87368 87369 87370 87371 87372 87373 87374 87375 87376 87377 |
if( VdbeMemDynamic(pOut) ){ /*OPTIMIZATION-IF-FALSE*/
return out2PrereleaseWithClear(pOut);
}else{
pOut->flags = MEM_Int;
return pOut;
}
}
/*
** Return the symbolic name for the data type of a pMem
*/
static const char *vdbeMemTypeName(Mem *pMem){
static const char *azTypes[] = {
/* SQLITE_INTEGER */ "INT",
| > > > > > > > > > > > > > > > > > > > > > > > > > | 87433 87434 87435 87436 87437 87438 87439 87440 87441 87442 87443 87444 87445 87446 87447 87448 87449 87450 87451 87452 87453 87454 87455 87456 87457 87458 87459 87460 87461 87462 87463 87464 87465 87466 87467 87468 87469 87470 87471 |
if( VdbeMemDynamic(pOut) ){ /*OPTIMIZATION-IF-FALSE*/
return out2PrereleaseWithClear(pOut);
}else{
pOut->flags = MEM_Int;
return pOut;
}
}
/*
** Compute a bloom filter hash using pOp->p4.i registers from aMem[] beginning
** with pOp->p3. Return the hash.
*/
static u64 filterHash(const Mem *aMem, const Op *pOp){
int i, mx;
u64 h = 0;
i = pOp->p3;
assert( pOp->p4type==P4_INT32 );
mx = i + pOp->p4.i;
for(i=pOp->p3, mx=i+pOp->p4.i; i<mx; i++){
const Mem *p = &aMem[i];
if( p->flags & (MEM_Int|MEM_IntReal) ){
h += p->u.i;
}else if( p->flags & MEM_Real ){
h += sqlite3VdbeIntValue(p);
}else if( p->flags & (MEM_Str|MEM_Blob) ){
h += p->n;
if( p->flags & MEM_Zero ) h += p->u.nZero;
}
}
return h;
}
/*
** Return the symbolic name for the data type of a pMem
*/
static const char *vdbeMemTypeName(Mem *pMem){
static const char *azTypes[] = {
/* SQLITE_INTEGER */ "INT",
|
| ︙ | ︙ | |||
88019 88020 88021 88022 88023 88024 88025 | break; } /* Opcode: Blob P1 P2 * P4 * ** Synopsis: r[P2]=P4 (len=P1) ** ** P4 points to a blob of data P1 bytes long. Store this | | > > > > > | > | 88113 88114 88115 88116 88117 88118 88119 88120 88121 88122 88123 88124 88125 88126 88127 88128 88129 88130 88131 88132 88133 88134 88135 88136 88137 88138 |
break;
}
/* Opcode: Blob P1 P2 * P4 *
** Synopsis: r[P2]=P4 (len=P1)
**
** P4 points to a blob of data P1 bytes long. Store this
** blob in register P2. If P4 is a NULL pointer, then construct
** a zero-filled blob that is P1 bytes long in P2.
*/
case OP_Blob: { /* out2 */
assert( pOp->p1 <= SQLITE_MAX_LENGTH );
pOut = out2Prerelease(p, pOp);
if( pOp->p4.z==0 ){
sqlite3VdbeMemSetZeroBlob(pOut, pOp->p1);
if( sqlite3VdbeMemExpandBlob(pOut) ) goto no_mem;
}else{
sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
}
pOut->enc = encoding;
UPDATE_MAX_BLOBSIZE(pOut);
break;
}
/* Opcode: Variable P1 P2 * P4 *
** Synopsis: r[P2]=parameter(P1,P4)
|
| ︙ | ︙ | |||
88173 88174 88175 88176 88177 88178 88179 | pIn1 = &aMem[pOp->p1]; assert( (pIn1->flags & MEM_Int)!=0 ); pOut = &aMem[pOp->p2]; sqlite3VdbeMemSetInt64(pOut, pIn1->u.i); break; } | | < < | | > > | | | | < < | | 88273 88274 88275 88276 88277 88278 88279 88280 88281 88282 88283 88284 88285 88286 88287 88288 88289 88290 88291 88292 88293 88294 88295 88296 88297 88298 88299 88300 88301 88302 |
pIn1 = &aMem[pOp->p1];
assert( (pIn1->flags & MEM_Int)!=0 );
pOut = &aMem[pOp->p2];
sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);
break;
}
/* Opcode: FkCheck * * * * *
**
** Halt with an SQLITE_CONSTRAINT error if there are any unresolved
** foreign key constraint violations. If there are no foreign key
** constraint violations, this is a no-op.
**
** FK constraint violations are also checked when the prepared statement
** exits. This opcode is used to raise foreign key constraint errors prior
** to returning results such as a row change count or the result of a
** RETURNING clause.
*/
case OP_FkCheck: {
if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){
goto abort_due_to_error;
}
break;
}
/* Opcode: ResultRow P1 P2 * * *
** Synopsis: output=r[P1@P2]
**
** The registers P1 through P1+P2-1 contain a single row of
** results. This opcode causes the sqlite3_step() call to terminate
|
| ︙ | ︙ | |||
90037 90038 90039 90040 90041 90042 90043 | assert( nByte==(int)(zPayload - (u8*)pOut->z) ); assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); REGISTER_TRACE(pOp->p3, pOut); break; } | | | 90135 90136 90137 90138 90139 90140 90141 90142 90143 90144 90145 90146 90147 90148 90149 | assert( nByte==(int)(zPayload - (u8*)pOut->z) ); assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); REGISTER_TRACE(pOp->p3, pOut); break; } /* Opcode: Count P1 P2 P3 * * ** Synopsis: r[P2]=count() ** ** Store the number of entries (an integer value) in the table or index ** opened by cursor P1 in register P2. ** ** If P3==0, then an exact count is obtained, which involves visiting ** every btree page of the table. But if P3 is non-zero, an estimate |
| ︙ | ︙ | |||
94822 94823 94824 94825 94826 94827 94828 94829 94830 94831 94832 94833 94834 94835 |
if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;
}
REGISTER_TRACE(pOp->p3, pOut);
UPDATE_MAX_BLOBSIZE(pOut);
break;
}
/* Opcode: Trace P1 P2 * P4 *
**
** Write P4 on the statement trace output if statement tracing is
** enabled.
**
** Operand P1 must be 0x7fffffff and P2 must positive.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 94920 94921 94922 94923 94924 94925 94926 94927 94928 94929 94930 94931 94932 94933 94934 94935 94936 94937 94938 94939 94940 94941 94942 94943 94944 94945 94946 94947 94948 94949 94950 94951 94952 94953 94954 94955 94956 94957 94958 94959 94960 94961 94962 94963 94964 94965 94966 94967 94968 94969 94970 94971 94972 94973 94974 94975 94976 94977 94978 94979 94980 94981 94982 94983 94984 94985 94986 94987 94988 94989 94990 94991 94992 94993 94994 94995 94996 94997 94998 94999 95000 95001 95002 95003 95004 |
if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;
}
REGISTER_TRACE(pOp->p3, pOut);
UPDATE_MAX_BLOBSIZE(pOut);
break;
}
/* Opcode: FilterAdd P1 * P3 P4 *
** Synopsis: filter(P1) += key(P3@P4)
**
** Compute a hash on the P4 registers starting with r[P3] and
** add that hash to the bloom filter contained in r[P1].
*/
case OP_FilterAdd: {
u64 h;
assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
pIn1 = &aMem[pOp->p1];
assert( pIn1->flags & MEM_Blob );
assert( pIn1->n>0 );
h = filterHash(aMem, pOp);
#ifdef SQLITE_DEBUG
if( db->flags&SQLITE_VdbeTrace ){
int ii;
for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
registerTrace(ii, &aMem[ii]);
}
printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
}
#endif
h %= pIn1->n;
pIn1->z[h/8] |= 1<<(h&7);
break;
}
/* Opcode: Filter P1 P2 P3 P4 *
** Synopsis: if key(P3@P4) not in filter(P1) goto P2
**
** Compute a hash on the key contained in the P4 registers starting
** with r[P3]. Check to see if that hash is found in the
** bloom filter hosted by register P1. If it is not present then
** maybe jump to P2. Otherwise fall through.
**
** False negatives are harmless. It is always safe to fall through,
** even if the value is in the bloom filter. A false negative causes
** more CPU cycles to be used, but it should still yield the correct
** answer. However, an incorrect answer may well arise from a
** false positive - if the jump is taken when it should fall through.
*/
case OP_Filter: { /* jump */
u64 h;
assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
pIn1 = &aMem[pOp->p1];
assert( (pIn1->flags & MEM_Blob)!=0 );
assert( pIn1->n >= 1 );
h = filterHash(aMem, pOp);
#ifdef SQLITE_DEBUG
if( db->flags&SQLITE_VdbeTrace ){
int ii;
for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
registerTrace(ii, &aMem[ii]);
}
printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
}
#endif
h %= pIn1->n;
if( (pIn1->z[h/8] & (1<<(h&7)))==0 ){
VdbeBranchTaken(1, 2);
p->aCounter[SQLITE_STMTSTATUS_FILTER_HIT]++;
goto jump_to_p2;
}else{
p->aCounter[SQLITE_STMTSTATUS_FILTER_MISS]++;
VdbeBranchTaken(0, 2);
}
break;
}
/* Opcode: Trace P1 P2 * P4 *
**
** Write P4 on the statement trace output if statement tracing is
** enabled.
**
** Operand P1 must be 0x7fffffff and P2 must positive.
|
| ︙ | ︙ | |||
104081 104082 104083 104084 104085 104086 104087 |
case TK_BLOB:
return 0;
case TK_COLUMN:
assert( ExprUseYTab(p) );
return ExprHasProperty(p, EP_CanBeNull) ||
p->y.pTab==0 || /* Reference to column of index on expression */
(p->iColumn>=0
| | | 104250 104251 104252 104253 104254 104255 104256 104257 104258 104259 104260 104261 104262 104263 104264 |
case TK_BLOB:
return 0;
case TK_COLUMN:
assert( ExprUseYTab(p) );
return ExprHasProperty(p, EP_CanBeNull) ||
p->y.pTab==0 || /* Reference to column of index on expression */
(p->iColumn>=0
&& p->y.pTab->aCol!=0 /* Possible due to prior error */
&& p->y.pTab->aCol[p->iColumn].notNull==0);
default:
return 1;
}
}
/*
|
| ︙ | ︙ | |||
107512 107513 107514 107515 107516 107517 107518 |
/* Structure used to pass information throught the Walker in order to
** implement sqlite3ReferencesSrcList().
*/
struct RefSrcList {
sqlite3 *db; /* Database connection used for sqlite3DbRealloc() */
SrcList *pRef; /* Looking for references to these tables */
| | > | | 107681 107682 107683 107684 107685 107686 107687 107688 107689 107690 107691 107692 107693 107694 107695 107696 107697 107698 107699 107700 107701 107702 107703 107704 107705 107706 107707 107708 107709 107710 107711 |
/* Structure used to pass information throught the Walker in order to
** implement sqlite3ReferencesSrcList().
*/
struct RefSrcList {
sqlite3 *db; /* Database connection used for sqlite3DbRealloc() */
SrcList *pRef; /* Looking for references to these tables */
i64 nExclude; /* Number of tables to exclude from the search */
int *aiExclude; /* Cursor IDs for tables to exclude from the search */
};
/*
** Walker SELECT callbacks for sqlite3ReferencesSrcList().
**
** When entering a new subquery on the pExpr argument, add all FROM clause
** entries for that subquery to the exclude list.
**
** When leaving the subquery, remove those entries from the exclude list.
*/
static int selectRefEnter(Walker *pWalker, Select *pSelect){
struct RefSrcList *p = pWalker->u.pRefSrcList;
SrcList *pSrc = pSelect->pSrc;
i64 i, j;
int *piNew;
if( pSrc->nSrc==0 ) return WRC_Continue;
j = p->nExclude;
p->nExclude += pSrc->nSrc;
piNew = sqlite3DbRealloc(p->db, p->aiExclude, p->nExclude*sizeof(int));
if( piNew==0 ){
p->nExclude = 0;
return WRC_Abort;
|
| ︙ | ︙ | |||
113190 113191 113192 113193 113194 113195 113196 113197 113198 113199 113200 113201 113202 113203 |
int addrRewind;
int i;
int reg;
if( pReturning->nRetCol==0 ){
assert( CORRUPT_DB );
}else{
addrRewind =
sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
VdbeCoverage(v);
reg = pReturning->iRetReg;
for(i=0; i<pReturning->nRetCol; i++){
sqlite3VdbeAddOp3(v, OP_Column, pReturning->iRetCur, i, reg+i);
}
| > | 113360 113361 113362 113363 113364 113365 113366 113367 113368 113369 113370 113371 113372 113373 113374 |
int addrRewind;
int i;
int reg;
if( pReturning->nRetCol==0 ){
assert( CORRUPT_DB );
}else{
sqlite3VdbeAddOp0(v, OP_FkCheck);
addrRewind =
sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
VdbeCoverage(v);
reg = pReturning->iRetReg;
for(i=0; i<pReturning->nRetCol; i++){
sqlite3VdbeAddOp3(v, OP_Column, pReturning->iRetCur, i, reg+i);
}
|
| ︙ | ︙ | |||
113759 113760 113761 113762 113763 113764 113765 |
** Set the collating sequence name for a column.
*/
SQLITE_PRIVATE void sqlite3ColumnSetColl(
sqlite3 *db,
Column *pCol,
const char *zColl
){
| | | | 113930 113931 113932 113933 113934 113935 113936 113937 113938 113939 113940 113941 113942 113943 113944 113945 |
** Set the collating sequence name for a column.
*/
SQLITE_PRIVATE void sqlite3ColumnSetColl(
sqlite3 *db,
Column *pCol,
const char *zColl
){
i64 nColl;
i64 n;
char *zNew;
assert( zColl!=0 );
n = sqlite3Strlen30(pCol->zCnName) + 1;
if( pCol->colFlags & COLFLAG_HASTYPE ){
n += sqlite3Strlen30(pCol->zCnName+n) + 1;
}
nColl = sqlite3Strlen30(zColl) + 1;
|
| ︙ | ︙ | |||
114565 114566 114567 114568 114569 114570 114571 |
affinity = sqlite3StdTypeAffinity[i];
if( affinity<=SQLITE_AFF_TEXT ) szEst = 5;
break;
}
}
}
| | | | 114736 114737 114738 114739 114740 114741 114742 114743 114744 114745 114746 114747 114748 114749 114750 114751 114752 114753 114754 114755 114756 114757 114758 114759 114760 114761 114762 114763 114764 |
affinity = sqlite3StdTypeAffinity[i];
if( affinity<=SQLITE_AFF_TEXT ) szEst = 5;
break;
}
}
}
z = sqlite3DbMallocRaw(db, (i64)sName.n + 1 + (i64)sType.n + (sType.n>0) );
if( z==0 ) return;
if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName);
memcpy(z, sName.z, sName.n);
z[sName.n] = 0;
sqlite3Dequote(z);
hName = sqlite3StrIHash(z);
for(i=0; i<p->nCol; i++){
if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zCnName)==0 ){
sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
sqlite3DbFree(db, z);
return;
}
}
aNew = sqlite3DbRealloc(db,p->aCol,((i64)p->nCol+1)*sizeof(p->aCol[0]));
if( aNew==0 ){
sqlite3DbFree(db, z);
return;
}
p->aCol = aNew;
pCol = &p->aCol[p->nCol];
memset(pCol, 0, sizeof(p->aCol[0]));
|
| ︙ | ︙ | |||
116592 116593 116594 116595 116596 116597 116598 |
int flags /* Conflict resolution algorithms. */
){
sqlite3 *db = pParse->db;
#ifndef SQLITE_OMIT_FOREIGN_KEY
FKey *pFKey = 0;
FKey *pNextTo;
Table *p = pParse->pNewTable;
| | | 116763 116764 116765 116766 116767 116768 116769 116770 116771 116772 116773 116774 116775 116776 116777 |
int flags /* Conflict resolution algorithms. */
){
sqlite3 *db = pParse->db;
#ifndef SQLITE_OMIT_FOREIGN_KEY
FKey *pFKey = 0;
FKey *pNextTo;
Table *p = pParse->pNewTable;
i64 nByte;
int i;
int nCol;
char *z;
assert( pTo!=0 );
if( p==0 || IN_DECLARE_VTAB ) goto fk_end;
if( pFromCol==0 ){
|
| ︙ | ︙ | |||
117422 117423 117424 117425 117426 117427 117428 |
/* zStmt = sqlite3MPrintf(""); */
zStmt = 0;
}
/* Add an entry in sqlite_schema for this index
*/
sqlite3NestedParse(pParse,
| | | | | | | | | 117593 117594 117595 117596 117597 117598 117599 117600 117601 117602 117603 117604 117605 117606 117607 117608 117609 117610 117611 117612 117613 |
/* zStmt = sqlite3MPrintf(""); */
zStmt = 0;
}
/* Add an entry in sqlite_schema for this index
*/
sqlite3NestedParse(pParse,
"INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
db->aDb[iDb].zDbSName,
pIndex->zName,
pTab->zName,
iMem,
zStmt
);
sqlite3DbFree(db, zStmt);
/* Fill the index with data and reparse the schema. Code an OP_Expire
** to invalidate all pre-compiled statements.
*/
if( pTblName ){
sqlite3RefillIndex(pParse, pIndex, iMem);
|
| ︙ | ︙ | |||
117976 117977 117978 117979 117980 117981 117982 |
pItem->zAlias = sqlite3NameFromToken(db, pAlias);
}
pItem->pSelect = pSubquery;
pItem->pOn = pOn;
pItem->pUsing = pUsing;
return p;
| | | 118147 118148 118149 118150 118151 118152 118153 118154 118155 118156 118157 118158 118159 118160 118161 |
pItem->zAlias = sqlite3NameFromToken(db, pAlias);
}
pItem->pSelect = pSubquery;
pItem->pOn = pOn;
pItem->pUsing = pUsing;
return p;
append_from_error:
assert( p==0 );
sqlite3ExprDelete(db, pOn);
sqlite3IdListDelete(db, pUsing);
sqlite3SelectDelete(db, pSubquery);
return 0;
}
|
| ︙ | ︙ | |||
119232 119233 119234 119235 119236 119237 119238 119239 119240 119241 119242 119243 119244 119245 |
pTab->nTabRef++;
if( pItem->fg.isIndexedBy && sqlite3IndexedByLookup(pParse, pItem) ){
pTab = 0;
}
}
return pTab;
}
/* Return true if table pTab is read-only.
**
** A table is read-only if any of the following are true:
**
** 1) It is a virtual table and no implementation of the xUpdate method
** has been provided
| > > > > > > > > > > | 119403 119404 119405 119406 119407 119408 119409 119410 119411 119412 119413 119414 119415 119416 119417 119418 119419 119420 119421 119422 119423 119424 119425 119426 |
pTab->nTabRef++;
if( pItem->fg.isIndexedBy && sqlite3IndexedByLookup(pParse, pItem) ){
pTab = 0;
}
}
return pTab;
}
/* Generate byte-code that will report the number of rows modified
** by a DELETE, INSERT, or UPDATE statement.
*/
SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe *v, int regCounter, const char *zColName){
sqlite3VdbeAddOp0(v, OP_FkCheck);
sqlite3VdbeAddOp2(v, OP_ResultRow, regCounter, 1);
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zColName, SQLITE_STATIC);
}
/* Return true if table pTab is read-only.
**
** A table is read-only if any of the following are true:
**
** 1) It is a virtual table and no implementation of the xUpdate method
** has been provided
|
| ︙ | ︙ | |||
119808 119809 119810 119811 119812 119813 119814 |
}
/* Return the number of rows that were deleted. If this routine is
** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function.
*/
if( memCnt ){
| < < | | 119989 119990 119991 119992 119993 119994 119995 119996 119997 119998 119999 120000 120001 120002 120003 |
}
/* Return the number of rows that were deleted. If this routine is
** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function.
*/
if( memCnt ){
sqlite3CodeChangeCount(v, memCnt, "rows deleted");
}
delete_from_cleanup:
sqlite3AuthContextPop(&sContext);
sqlite3SrcListDelete(db, pTabList);
sqlite3ExprDelete(db, pWhere);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
|
| ︙ | ︙ | |||
125368 125369 125370 125371 125372 125373 125374 |
/*
** Return the number of rows inserted. If this routine is
** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function.
*/
if( regRowCount ){
| | < < | 125547 125548 125549 125550 125551 125552 125553 125554 125555 125556 125557 125558 125559 125560 125561 |
/*
** Return the number of rows inserted. If this routine is
** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function.
*/
if( regRowCount ){
sqlite3CodeChangeCount(v, regRowCount, "rows inserted");
}
insert_cleanup:
sqlite3SrcListDelete(db, pTabList);
sqlite3ExprListDelete(db, pList);
sqlite3UpsertDelete(db, pUpsert);
sqlite3SelectDelete(db, pSelect);
|
| ︙ | ︙ | |||
133000 133001 133002 133003 133004 133005 133006 133007 133008 133009 133010 133011 133012 133013 |
sqlite3BtreeEnterAll(db);
do{
/* Make multiple attempts to compile the SQL, until it either succeeds
** or encounters a permanent error. A schema problem after one schema
** reset is considered a permanent error. */
rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 );
}while( rc==SQLITE_ERROR_RETRY
|| (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
sqlite3BtreeLeaveAll(db);
rc = sqlite3ApiExit(db, rc);
assert( (rc&db->errMask)==rc );
db->busyHandler.nBusy = 0;
sqlite3_mutex_leave(db->mutex);
| > | 133177 133178 133179 133180 133181 133182 133183 133184 133185 133186 133187 133188 133189 133190 133191 |
sqlite3BtreeEnterAll(db);
do{
/* Make multiple attempts to compile the SQL, until it either succeeds
** or encounters a permanent error. A schema problem after one schema
** reset is considered a permanent error. */
rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 );
if( rc==SQLITE_OK || db->mallocFailed ) break;
}while( rc==SQLITE_ERROR_RETRY
|| (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
sqlite3BtreeLeaveAll(db);
rc = sqlite3ApiExit(db, rc);
assert( (rc&db->errMask)==rc );
db->busyHandler.nBusy = 0;
sqlite3_mutex_leave(db->mutex);
|
| ︙ | ︙ | |||
135416 135417 135418 135419 135420 135421 135422 |
assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );
if( db->mallocFailed ) return;
memset(&sNC, 0, sizeof(sNC));
sNC.pSrcList = pSelect->pSrc;
a = pSelect->pEList->a;
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
const char *zType;
| | | 135594 135595 135596 135597 135598 135599 135600 135601 135602 135603 135604 135605 135606 135607 135608 |
assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );
if( db->mallocFailed ) return;
memset(&sNC, 0, sizeof(sNC));
sNC.pSrcList = pSelect->pSrc;
a = pSelect->pEList->a;
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
const char *zType;
i64 n, m;
pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT);
p = a[i].pExpr;
zType = columnType(&sNC, p, 0, 0, 0);
/* pCol->szEst = ... // Column size est for SELECT tables never used */
pCol->affinity = sqlite3ExprAffinity(p);
if( zType ){
m = sqlite3Strlen30(zType);
|
| ︙ | ︙ | |||
137402 137403 137404 137405 137406 137407 137408 |
}
/* Restriction (23) */
if( (p->selFlags & SF_Recursive) ) return 0;
if( pSrc->nSrc>1 ){
if( pParse->nSelect>500 ) return 0;
| | | 137580 137581 137582 137583 137584 137585 137586 137587 137588 137589 137590 137591 137592 137593 137594 |
}
/* Restriction (23) */
if( (p->selFlags & SF_Recursive) ) return 0;
if( pSrc->nSrc>1 ){
if( pParse->nSelect>500 ) return 0;
aCsrMap = sqlite3DbMallocZero(db, ((i64)pParse->nTab+1)*sizeof(int));
if( aCsrMap ) aCsrMap[0] = pParse->nTab;
}
}
/***** If we reach this point, flattening is permitted. *****/
SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
pSub->selId, pSub, iFrom));
|
| ︙ | ︙ | |||
138173 138174 138175 138176 138177 138178 138179 | ** ** SELECT count(*) FROM <tbl> ** ** where table is a database table, not a sub-select or view. If the query ** does match this pattern, then a pointer to the Table object representing ** <tbl> is returned. Otherwise, NULL is returned. ** | | | | | | | 138351 138352 138353 138354 138355 138356 138357 138358 138359 138360 138361 138362 138363 138364 138365 138366 138367 138368 138369 |
**
** SELECT count(*) FROM <tbl>
**
** where table is a database table, not a sub-select or view. If the query
** does match this pattern, then a pointer to the Table object representing
** <tbl> is returned. Otherwise, NULL is returned.
**
** This routine checks to see if it is safe to use the count optimization.
** A correct answer is still obtained (though perhaps more slowly) if
** this routine returns NULL when it could have returned a table pointer.
** But returning the pointer when NULL should have been returned can
** result in incorrect answers and/or crashes. So, when in doubt, return NULL.
*/
static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
Table *pTab;
Expr *pExpr;
assert( !p->pGroupBy );
|
| ︙ | ︙ | |||
143491 143492 143493 143494 143495 143496 143497 |
}
/*
** Return the number of rows that were changed, if we are tracking
** that information.
*/
if( regRowCount ){
| | < < | 143669 143670 143671 143672 143673 143674 143675 143676 143677 143678 143679 143680 143681 143682 143683 |
}
/*
** Return the number of rows that were changed, if we are tracking
** that information.
*/
if( regRowCount ){
sqlite3CodeChangeCount(v, regRowCount, "rows updated");
}
update_cleanup:
sqlite3AuthContextPop(&sContext);
sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */
sqlite3SrcListDelete(db, pTabList);
sqlite3ExprListDelete(db, pChanges);
|
| ︙ | ︙ | |||
145867 145868 145869 145870 145871 145872 145873 145874 145875 145876 145877 145878 145879 145880 |
int addrBody; /* Beginning of the body of this loop */
int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
int addrBignull; /* Jump here for next part of big-null scan */
#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
int addrLikeRep; /* LIKE range processing address */
#endif
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to end the loop */
union { /* Information that depends on pWLoop->wsFlags */
struct {
int nIn; /* Number of entries in aInLoop[] */
struct InLoop {
| > | 146043 146044 146045 146046 146047 146048 146049 146050 146051 146052 146053 146054 146055 146056 146057 |
int addrBody; /* Beginning of the body of this loop */
int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
int addrBignull; /* Jump here for next part of big-null scan */
#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
int addrLikeRep; /* LIKE range processing address */
#endif
int regFilter; /* Bloom filter */
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to end the loop */
union { /* Information that depends on pWLoop->wsFlags */
struct {
int nIn; /* Number of entries in aInLoop[] */
struct InLoop {
|
| ︙ | ︙ | |||
146095 146096 146097 146098 146099 146100 146101 146102 146103 |
** terms in the WHERE clause that are useful to the query planner.
*/
struct WhereScan {
WhereClause *pOrigWC; /* Original, innermost WhereClause */
WhereClause *pWC; /* WhereClause currently being scanned */
const char *zCollName; /* Required collating sequence, if not NULL */
Expr *pIdxExpr; /* Search for this index expression */
char idxaff; /* Must match this affinity, if zCollName!=NULL */
unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
| > > > < < < | 146272 146273 146274 146275 146276 146277 146278 146279 146280 146281 146282 146283 146284 146285 146286 146287 146288 146289 146290 |
** terms in the WHERE clause that are useful to the query planner.
*/
struct WhereScan {
WhereClause *pOrigWC; /* Original, innermost WhereClause */
WhereClause *pWC; /* WhereClause currently being scanned */
const char *zCollName; /* Required collating sequence, if not NULL */
Expr *pIdxExpr; /* Search for this index expression */
int k; /* Resume scanning at this->pWC->a[this->k] */
u32 opMask; /* Acceptable operators */
char idxaff; /* Must match this affinity, if zCollName!=NULL */
unsigned char iEquiv; /* Current slot in aiCur[] and aiColumn[] */
unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
int aiCur[11]; /* Cursors in the equivalence class */
i16 aiColumn[11]; /* Corresponding column number in the eq-class */
};
/*
** An instance of the following structure holds all information about a
** WHERE clause. Mostly this is a container for one or more WhereTerms.
|
| ︙ | ︙ | |||
146123 146124 146125 146126 146127 146128 146129 146130 146131 146132 146133 146134 146135 146136 |
struct WhereClause {
WhereInfo *pWInfo; /* WHERE clause processing context */
WhereClause *pOuter; /* Outer conjunction */
u8 op; /* Split operator. TK_AND or TK_OR */
u8 hasOr; /* True if any a[].eOperator is WO_OR */
int nTerm; /* Number of terms */
int nSlot; /* Number of entries in a[] */
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
#if defined(SQLITE_SMALL_STACK)
WhereTerm aStatic[1]; /* Initial static space for a[] */
#else
WhereTerm aStatic[8]; /* Initial static space for a[] */
#endif
};
| > | 146300 146301 146302 146303 146304 146305 146306 146307 146308 146309 146310 146311 146312 146313 146314 |
struct WhereClause {
WhereInfo *pWInfo; /* WHERE clause processing context */
WhereClause *pOuter; /* Outer conjunction */
u8 op; /* Split operator. TK_AND or TK_OR */
u8 hasOr; /* True if any a[].eOperator is WO_OR */
int nTerm; /* Number of terms */
int nSlot; /* Number of entries in a[] */
int nBase; /* Number of terms through the last non-Virtual */
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
#if defined(SQLITE_SMALL_STACK)
WhereTerm aStatic[1]; /* Initial static space for a[] */
#else
WhereTerm aStatic[8]; /* Initial static space for a[] */
#endif
};
|
| ︙ | ︙ | |||
146180 146181 146182 146183 146184 146185 146186 |
*/
struct WhereMaskSet {
int bVarSelect; /* Used by sqlite3WhereExprUsage() */
int n; /* Number of assigned cursor values */
int ix[BMS]; /* Cursor assigned to each bit */
};
| < < < < < | 146358 146359 146360 146361 146362 146363 146364 146365 146366 146367 146368 146369 146370 146371 |
*/
struct WhereMaskSet {
int bVarSelect; /* Used by sqlite3WhereExprUsage() */
int n; /* Number of assigned cursor values */
int ix[BMS]; /* Cursor assigned to each bit */
};
/*
** This object is a convenience wrapper holding all information needed
** to construct WhereLoop objects for a particular query.
*/
struct WhereLoopBuilder {
WhereInfo *pWInfo; /* Information about this WHERE */
WhereClause *pWC; /* WHERE clause terms */
|
| ︙ | ︙ | |||
146313 146314 146315 146316 146317 146318 146319 146320 146321 146322 146323 146324 146325 146326 146327 146328 | #ifndef SQLITE_OMIT_EXPLAIN SQLITE_PRIVATE int sqlite3WhereExplainOneScan( Parse *pParse, /* Parse context */ SrcList *pTabList, /* Table list this loop refers to */ WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */ u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ ); #else # define sqlite3WhereExplainOneScan(u,v,w,x) 0 #endif /* SQLITE_OMIT_EXPLAIN */ #ifdef SQLITE_ENABLE_STMT_SCANSTATUS SQLITE_PRIVATE void sqlite3WhereAddScanStatus( Vdbe *v, /* Vdbe to add scanstatus entry to */ SrcList *pSrclist, /* FROM clause pLvl reads data from */ WhereLevel *pLvl, /* Level to add scanstatus() entry for */ int addrExplain /* Address of OP_Explain (or 0) */ | > > > > > > | 146486 146487 146488 146489 146490 146491 146492 146493 146494 146495 146496 146497 146498 146499 146500 146501 146502 146503 146504 146505 146506 146507 | #ifndef SQLITE_OMIT_EXPLAIN SQLITE_PRIVATE int sqlite3WhereExplainOneScan( Parse *pParse, /* Parse context */ SrcList *pTabList, /* Table list this loop refers to */ WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */ u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ ); SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter( const Parse *pParse, /* Parse context */ const WhereInfo *pWInfo, /* WHERE clause */ const WhereLevel *pLevel /* Bloom filter on this level */ ); #else # define sqlite3WhereExplainOneScan(u,v,w,x) 0 # define sqlite3WhereExplainBloomFilter(u,v,w) 0 #endif /* SQLITE_OMIT_EXPLAIN */ #ifdef SQLITE_ENABLE_STMT_SCANSTATUS SQLITE_PRIVATE void sqlite3WhereAddScanStatus( Vdbe *v, /* Vdbe to add scanstatus entry to */ SrcList *pSrclist, /* FROM clause pLvl reads data from */ WhereLevel *pLvl, /* Level to add scanstatus() entry for */ int addrExplain /* Address of OP_Explain (or 0) */ |
| ︙ | ︙ | |||
146407 146408 146409 146410 146411 146412 146413 146414 146415 146416 146417 146418 146419 146420 | #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */ #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/ #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */ #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */ #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ #endif /* !defined(SQLITE_WHEREINT_H) */ /************** End of whereInt.h ********************************************/ /************** Continuing where we left off in wherecode.c ******************/ #ifndef SQLITE_OMIT_EXPLAIN | > > | 146586 146587 146588 146589 146590 146591 146592 146593 146594 146595 146596 146597 146598 146599 146600 146601 | #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */ #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/ #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */ #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */ #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ #endif /* !defined(SQLITE_WHEREINT_H) */ /************** End of whereInt.h ********************************************/ /************** Continuing where we left off in wherecode.c ******************/ #ifndef SQLITE_OMIT_EXPLAIN |
| ︙ | ︙ | |||
146569 146570 146571 146572 146573 146574 146575 |
}
if( zFmt ){
sqlite3_str_append(&str, " USING ", 7);
sqlite3_str_appendf(&str, zFmt, pIdx->zName);
explainIndexRange(&str, pLoop);
}
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
| > > > > > > | > > | > | | | | < | 146750 146751 146752 146753 146754 146755 146756 146757 146758 146759 146760 146761 146762 146763 146764 146765 146766 146767 146768 146769 146770 146771 146772 146773 146774 146775 146776 146777 146778 146779 146780 146781 146782 146783 146784 |
}
if( zFmt ){
sqlite3_str_append(&str, " USING ", 7);
sqlite3_str_appendf(&str, zFmt, pIdx->zName);
explainIndexRange(&str, pLoop);
}
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
char cRangeOp;
#if 0 /* Better output, but breaks many tests */
const Table *pTab = pItem->pTab;
const char *zRowid = pTab->iPKey>=0 ? pTab->aCol[pTab->iPKey].zCnName:
"rowid";
#else
const char *zRowid = "rowid";
#endif
sqlite3_str_appendf(&str, " USING INTEGER PRIMARY KEY (%s", zRowid);
if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
cRangeOp = '=';
}else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){
sqlite3_str_appendf(&str, ">? AND %s", zRowid);
cRangeOp = '<';
}else if( flags&WHERE_BTM_LIMIT ){
cRangeOp = '>';
}else{
assert( flags&WHERE_TOP_LIMIT);
cRangeOp = '<';
}
sqlite3_str_appendf(&str, "%c?)", cRangeOp);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
sqlite3_str_appendf(&str, " VIRTUAL TABLE INDEX %d:%s",
pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);
}
#endif
|
| ︙ | ︙ | |||
146604 146605 146606 146607 146608 146609 146610 146611 146612 146613 146614 146615 146616 146617 |
zMsg = sqlite3StrAccumFinish(&str);
sqlite3ExplainBreakpoint("",zMsg);
ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
}
return ret;
}
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
/*
** Configure the VM passed as the first argument with an
** sqlite3_stmt_scanstatus() entry corresponding to the scan used to
** implement level pLvl. Argument pSrclist is a pointer to the FROM
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 146793 146794 146795 146796 146797 146798 146799 146800 146801 146802 146803 146804 146805 146806 146807 146808 146809 146810 146811 146812 146813 146814 146815 146816 146817 146818 146819 146820 146821 146822 146823 146824 146825 146826 146827 146828 146829 146830 146831 146832 146833 146834 146835 146836 146837 146838 146839 146840 146841 146842 146843 146844 146845 146846 146847 146848 146849 146850 146851 146852 146853 146854 146855 146856 |
zMsg = sqlite3StrAccumFinish(&str);
sqlite3ExplainBreakpoint("",zMsg);
ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
}
return ret;
}
/*
** Add a single OP_Explain opcode that describes a Bloom filter.
**
** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or
** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not
** required and this routine is a no-op.
**
** If an OP_Explain opcode is added to the VM, its address is returned.
** Otherwise, if no OP_Explain is coded, zero is returned.
*/
SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter(
const Parse *pParse, /* Parse context */
const WhereInfo *pWInfo, /* WHERE clause */
const WhereLevel *pLevel /* Bloom filter on this level */
){
int ret = 0;
SrcItem *pItem = &pWInfo->pTabList->a[pLevel->iFrom];
Vdbe *v = pParse->pVdbe; /* VM being constructed */
sqlite3 *db = pParse->db; /* Database handle */
char *zMsg; /* Text to add to EQP output */
int i; /* Loop counter */
WhereLoop *pLoop; /* The where loop */
StrAccum str; /* EQP output string */
char zBuf[100]; /* Initial space for EQP output string */
sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
str.printfFlags = SQLITE_PRINTF_INTERNAL;
sqlite3_str_appendf(&str, "BLOOM FILTER ON %S (", pItem);
pLoop = pLevel->pWLoop;
if( pLoop->wsFlags & WHERE_IPK ){
const Table *pTab = pItem->pTab;
if( pTab->iPKey>=0 ){
sqlite3_str_appendf(&str, "%s=?", pTab->aCol[pTab->iPKey].zCnName);
}else{
sqlite3_str_appendf(&str, "rowid=?");
}
}else{
for(i=pLoop->nSkip; i<pLoop->u.btree.nEq; i++){
const char *z = explainIndexColumnName(pLoop->u.btree.pIndex, i);
if( i>pLoop->nSkip ) sqlite3_str_append(&str, " AND ", 5);
sqlite3_str_appendf(&str, "%s=?", z);
}
}
sqlite3_str_append(&str, ")", 1);
zMsg = sqlite3StrAccumFinish(&str);
ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
return ret;
}
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
/*
** Configure the VM passed as the first argument with an
** sqlite3_stmt_scanstatus() entry corresponding to the scan used to
** implement level pLvl. Argument pSrclist is a pointer to the FROM
|
| ︙ | ︙ | |||
147363 147364 147365 147366 147367 147368 147369 | sHint.iTabCur = iCur; sHint.iIdxCur = pLevel->iIdxCur; sHint.pIdx = pLoop->u.btree.pIndex; memset(&sWalker, 0, sizeof(sWalker)); sWalker.pParse = pParse; sWalker.u.pCCurHint = &sHint; pWC = &pWInfo->sWC; | | | 147602 147603 147604 147605 147606 147607 147608 147609 147610 147611 147612 147613 147614 147615 147616 |
sHint.iTabCur = iCur;
sHint.iIdxCur = pLevel->iIdxCur;
sHint.pIdx = pLoop->u.btree.pIndex;
memset(&sWalker, 0, sizeof(sWalker));
sWalker.pParse = pParse;
sWalker.u.pCCurHint = &sHint;
pWC = &pWInfo->sWC;
for(i=0; i<pWC->nBase; i++){
pTerm = &pWC->a[i];
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( pTerm->prereqAll & pLevel->notReady ) continue;
/* Any terms specified as part of the ON(...) clause for any LEFT
** JOIN for which the current table is not the rhs are omitted
** from the cursor-hint.
|
| ︙ | ︙ | |||
147693 147694 147695 147696 147697 147698 147699 147700 147701 147702 147703 147704 147705 147706 |
if( pTerm->wtFlags & TERM_CODED ) continue;
pExpr = pTerm->pExpr;
if( sqlite3ExprCompare(0, pExpr, pTruth, iTabCur)==0 ){
pTerm->wtFlags |= TERM_CODED;
}
}
}
/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
** implementation described by pWInfo.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
Parse *pParse, /* Parsing context */
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 147932 147933 147934 147935 147936 147937 147938 147939 147940 147941 147942 147943 147944 147945 147946 147947 147948 147949 147950 147951 147952 147953 147954 147955 147956 147957 147958 147959 147960 147961 147962 147963 147964 147965 147966 147967 147968 147969 147970 147971 147972 147973 147974 147975 147976 147977 147978 147979 147980 147981 147982 147983 147984 147985 147986 147987 147988 147989 147990 147991 147992 147993 147994 147995 147996 147997 147998 147999 148000 148001 148002 |
if( pTerm->wtFlags & TERM_CODED ) continue;
pExpr = pTerm->pExpr;
if( sqlite3ExprCompare(0, pExpr, pTruth, iTabCur)==0 ){
pTerm->wtFlags |= TERM_CODED;
}
}
}
/*
** This routine is called right after An OP_Filter has been generated and
** before the corresponding index search has been performed. This routine
** checks to see if there are additional Bloom filters in inner loops that
** can be checked prior to doing the index lookup. If there are available
** inner-loop Bloom filters, then evaluate those filters now, before the
** index lookup. The idea is that a Bloom filter check is way faster than
** an index lookup, and the Bloom filter might return false, meaning that
** the index lookup can be skipped.
**
** We know that an inner loop uses a Bloom filter because it has the
** WhereLevel.regFilter set. If an inner-loop Bloom filter is checked,
** then clear the WhereLevel.regFilter value to prevent the Bloom filter
** from being checked a second time when the inner loop is evaluated.
*/
static SQLITE_NOINLINE void filterPullDown(
Parse *pParse, /* Parsing context */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
int addrNxt, /* Jump here to bypass inner loops */
Bitmask notReady /* Loops that are not ready */
){
while( ++iLevel < pWInfo->nLevel ){
WhereLevel *pLevel = &pWInfo->a[iLevel];
WhereLoop *pLoop = pLevel->pWLoop;
if( pLevel->regFilter==0 ) continue;
/* ,--- Because constructBloomFilter() has will not have set
** vvvvv--' pLevel->regFilter if this were true. */
if( NEVER(pLoop->prereq & notReady) ) continue;
if( pLoop->wsFlags & WHERE_IPK ){
WhereTerm *pTerm = pLoop->aLTerm[0];
int regRowid;
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
testcase( pTerm->wtFlags & TERM_VIRTUAL );
regRowid = sqlite3GetTempReg(pParse);
regRowid = codeEqualityTerm(pParse, pTerm, pLevel, 0, 0, regRowid);
sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
addrNxt, regRowid, 1);
VdbeCoverage(pParse->pVdbe);
}else{
u16 nEq = pLoop->u.btree.nEq;
int r1;
char *zStartAff;
assert( pLoop->wsFlags & WHERE_INDEXED );
r1 = codeAllEqualityTerms(pParse,pLevel,0,0,&zStartAff);
codeApplyAffinity(pParse, r1, nEq, zStartAff);
sqlite3DbFree(pParse->db, zStartAff);
sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
addrNxt, r1, nEq);
VdbeCoverage(pParse->pVdbe);
}
pLevel->regFilter = 0;
}
}
/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
** implementation described by pWInfo.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
Parse *pParse, /* Parsing context */
|
| ︙ | ︙ | |||
147904 147905 147906 147907 147908 147909 147910 147911 147912 147913 147914 147915 147916 147917 |
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
testcase( pTerm->wtFlags & TERM_VIRTUAL );
iReleaseReg = ++pParse->nMem;
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
addrNxt = pLevel->addrNxt;
sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
VdbeCoverage(v);
pLevel->op = OP_Noop;
}else if( (pLoop->wsFlags & WHERE_IPK)!=0
&& (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0
){
/* Case 3: We have an inequality comparison against the ROWID field.
| > > > > > > | 148200 148201 148202 148203 148204 148205 148206 148207 148208 148209 148210 148211 148212 148213 148214 148215 148216 148217 148218 148219 |
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
testcase( pTerm->wtFlags & TERM_VIRTUAL );
iReleaseReg = ++pParse->nMem;
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
addrNxt = pLevel->addrNxt;
if( pLevel->regFilter ){
sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
iRowidReg, 1);
VdbeCoverage(v);
filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
}
sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
VdbeCoverage(v);
pLevel->op = OP_Noop;
}else if( (pLoop->wsFlags & WHERE_IPK)!=0
&& (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0
){
/* Case 3: We have an inequality comparison against the ROWID field.
|
| ︙ | ︙ | |||
148229 148230 148231 148232 148233 148234 148235 148236 148237 148238 148239 148240 148241 148242 |
** above has already left the cursor sitting on the correct row,
** so no further seeking is needed */
}else{
if( regBignull ){
sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
VdbeComment((v, "NULL-scan pass ctr"));
}
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 && op==OP_SeekGE ){
assert( regBignull==0 );
/* TUNING: The OP_SeekScan opcode seeks to reduce the number
** of expensive seek operations by replacing a single seek with
| > > > > > > | 148531 148532 148533 148534 148535 148536 148537 148538 148539 148540 148541 148542 148543 148544 148545 148546 148547 148548 148549 148550 |
** above has already left the cursor sitting on the correct row,
** so no further seeking is needed */
}else{
if( regBignull ){
sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
VdbeComment((v, "NULL-scan pass ctr"));
}
if( pLevel->regFilter ){
sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
regBase, nEq);
VdbeCoverage(v);
filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
}
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 && op==OP_SeekGE ){
assert( regBignull==0 );
/* TUNING: The OP_SeekScan opcode seeks to reduce the number
** of expensive seek operations by replacing a single seek with
|
| ︙ | ︙ | |||
148860 148861 148862 148863 148864 148865 148866 | ** of the "==" operator. ** ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123" ** and we are coding the t1 loop and the t2 loop has not yet coded, ** then we cannot use the "t1.a=t2.b" constraint, but we can code ** the implied "t1.a=123" constraint. */ | | | 149168 149169 149170 149171 149172 149173 149174 149175 149176 149177 149178 149179 149180 149181 149182 |
** of the "==" operator.
**
** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123"
** and we are coding the t1 loop and the t2 loop has not yet coded,
** then we cannot use the "t1.a=t2.b" constraint, but we can code
** the implied "t1.a=123" constraint.
*/
for(pTerm=pWC->a, j=pWC->nBase; j>0; j--, pTerm++){
Expr *pE, sEAlt;
WhereTerm *pAlt;
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue;
if( (pTerm->eOperator & WO_EQUIV)==0 ) continue;
if( pTerm->leftCursor!=iCur ) continue;
if( pTabItem->fg.jointype & JT_LEFT ) continue;
|
| ︙ | ︙ | |||
148905 148906 148907 148908 148909 148910 148911 |
/* For a LEFT OUTER JOIN, generate code that will record the fact that
** at least one row of the right table has matched the left table.
*/
if( pLevel->iLeftJoin ){
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
VdbeComment((v, "record LEFT JOIN hit"));
| | | 149213 149214 149215 149216 149217 149218 149219 149220 149221 149222 149223 149224 149225 149226 149227 |
/* For a LEFT OUTER JOIN, generate code that will record the fact that
** at least one row of the right table has matched the left table.
*/
if( pLevel->iLeftJoin ){
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
VdbeComment((v, "record LEFT JOIN hit"));
for(pTerm=pWC->a, j=0; j<pWC->nBase; j++, pTerm++){
testcase( pTerm->wtFlags & TERM_VIRTUAL );
testcase( pTerm->wtFlags & TERM_CODED );
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
assert( pWInfo->untestedTerms );
continue;
}
|
| ︙ | ︙ | |||
149016 149017 149018 149019 149020 149021 149022 149023 149024 149025 149026 149027 149028 149029 |
memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);
if( pOld!=pWC->aStatic ){
sqlite3DbFree(db, pOld);
}
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
}
pTerm = &pWC->a[idx = pWC->nTerm++];
if( p && ExprHasProperty(p, EP_Unlikely) ){
pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
pTerm->truthProb = 1;
}
pTerm->pExpr = sqlite3ExprSkipCollateAndLikely(p);
pTerm->wtFlags = wtFlags;
| > | 149324 149325 149326 149327 149328 149329 149330 149331 149332 149333 149334 149335 149336 149337 149338 |
memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);
if( pOld!=pWC->aStatic ){
sqlite3DbFree(db, pOld);
}
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
}
pTerm = &pWC->a[idx = pWC->nTerm++];
if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm;
if( p && ExprHasProperty(p, EP_Unlikely) ){
pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
pTerm->truthProb = 1;
}
pTerm->pExpr = sqlite3ExprSkipCollateAndLikely(p);
pTerm->wtFlags = wtFlags;
|
| ︙ | ︙ | |||
150007 150008 150009 150010 150011 150012 150013 150014 150015 150016 150017 150018 150019 150020 150021 150022 150023 150024 150025 150026 150027 |
sqlite3 *db = pParse->db; /* Database connection */
unsigned char eOp2 = 0; /* op2 value for LIKE/REGEXP/GLOB */
int nLeft; /* Number of elements on left side vector */
if( db->mallocFailed ){
return;
}
pTerm = &pWC->a[idxTerm];
pMaskSet = &pWInfo->sMaskSet;
pExpr = pTerm->pExpr;
assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
op = pExpr->op;
if( op==TK_IN ){
assert( pExpr->pRight==0 );
if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
if( ExprUseXSelect(pExpr) ){
pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);
}else{
pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
}
| > > > < | > > > > > > > | > | > > | > > > > > | | 150316 150317 150318 150319 150320 150321 150322 150323 150324 150325 150326 150327 150328 150329 150330 150331 150332 150333 150334 150335 150336 150337 150338 150339 150340 150341 150342 150343 150344 150345 150346 150347 150348 150349 150350 150351 150352 150353 150354 150355 150356 150357 150358 150359 150360 150361 150362 150363 150364 150365 150366 150367 150368 |
sqlite3 *db = pParse->db; /* Database connection */
unsigned char eOp2 = 0; /* op2 value for LIKE/REGEXP/GLOB */
int nLeft; /* Number of elements on left side vector */
if( db->mallocFailed ){
return;
}
assert( pWC->nTerm > idxTerm );
pTerm = &pWC->a[idxTerm];
pMaskSet = &pWInfo->sMaskSet;
pExpr = pTerm->pExpr;
assert( pExpr!=0 ); /* Because malloc() has not failed */
assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
pMaskSet->bVarSelect = 0;
prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
op = pExpr->op;
if( op==TK_IN ){
assert( pExpr->pRight==0 );
if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
if( ExprUseXSelect(pExpr) ){
pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);
}else{
pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
}
prereqAll = prereqLeft | pTerm->prereqRight;
}else{
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
if( pExpr->pLeft==0
|| ExprHasProperty(pExpr, EP_xIsSelect|EP_IfNullRow)
|| pExpr->x.pList!=0
){
prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
}else{
prereqAll = prereqLeft | pTerm->prereqRight;
}
}
if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
#ifdef SQLITE_DEBUG
if( prereqAll!=sqlite3WhereExprUsageNN(pMaskSet, pExpr) ){
printf("\n*** Incorrect prereqAll computed for:\n");
sqlite3TreeViewExpr(0,pExpr,0);
abort();
}
#endif
if( ExprHasProperty(pExpr, EP_FromJoin) ){
Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
prereqAll |= x;
extraRight = x-1; /* ON clause terms may not be used with an index
** on left table of a LEFT JOIN. Ticket #3015 */
if( (prereqAll>>1)>=x ){
sqlite3ErrorMsg(pParse, "ON clause references tables to its right");
|
| ︙ | ︙ | |||
150452 150453 150454 150455 150456 150457 150458 150459 150460 150461 150462 150463 150464 150465 150466 150467 150468 |
WhereClause *pWC, /* The WhereClause to be initialized */
WhereInfo *pWInfo /* The WHERE processing context */
){
pWC->pWInfo = pWInfo;
pWC->hasOr = 0;
pWC->pOuter = 0;
pWC->nTerm = 0;
pWC->nSlot = ArraySize(pWC->aStatic);
pWC->a = pWC->aStatic;
}
/*
** Deallocate a WhereClause structure. The WhereClause structure
** itself is not freed. This routine is the inverse of
** sqlite3WhereClauseInit().
*/
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){
| > < < > | > > > > > > > > > > | | | > | > | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > < < < < < < > > > > > > > > > | 150778 150779 150780 150781 150782 150783 150784 150785 150786 150787 150788 150789 150790 150791 150792 150793 150794 150795 150796 150797 150798 150799 150800 150801 150802 150803 150804 150805 150806 150807 150808 150809 150810 150811 150812 150813 150814 150815 150816 150817 150818 150819 150820 150821 150822 150823 150824 150825 150826 150827 150828 150829 150830 150831 150832 150833 150834 150835 150836 150837 150838 150839 150840 150841 150842 150843 150844 150845 150846 150847 150848 150849 150850 150851 150852 150853 150854 150855 150856 150857 150858 150859 150860 150861 150862 150863 150864 150865 150866 150867 150868 150869 150870 150871 150872 150873 150874 150875 150876 150877 150878 150879 150880 150881 150882 150883 150884 150885 150886 150887 150888 150889 150890 150891 150892 150893 150894 150895 150896 150897 150898 150899 150900 150901 150902 |
WhereClause *pWC, /* The WhereClause to be initialized */
WhereInfo *pWInfo /* The WHERE processing context */
){
pWC->pWInfo = pWInfo;
pWC->hasOr = 0;
pWC->pOuter = 0;
pWC->nTerm = 0;
pWC->nBase = 0;
pWC->nSlot = ArraySize(pWC->aStatic);
pWC->a = pWC->aStatic;
}
/*
** Deallocate a WhereClause structure. The WhereClause structure
** itself is not freed. This routine is the inverse of
** sqlite3WhereClauseInit().
*/
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){
sqlite3 *db = pWC->pWInfo->pParse->db;
assert( pWC->nTerm>=pWC->nBase );
if( pWC->nTerm>0 ){
WhereTerm *a = pWC->a;
WhereTerm *aLast = &pWC->a[pWC->nTerm-1];
#ifdef SQLITE_DEBUG
int i;
/* Verify that every term past pWC->nBase is virtual */
for(i=pWC->nBase; i<pWC->nTerm; i++){
assert( (pWC->a[i].wtFlags & TERM_VIRTUAL)!=0 );
}
#endif
while(1){
if( a->wtFlags & TERM_DYNAMIC ){
sqlite3ExprDelete(db, a->pExpr);
}
if( a->wtFlags & (TERM_ORINFO|TERM_ANDINFO) ){
if( a->wtFlags & TERM_ORINFO ){
assert( (a->wtFlags & TERM_ANDINFO)==0 );
whereOrInfoDelete(db, a->u.pOrInfo);
}else{
assert( (a->wtFlags & TERM_ANDINFO)!=0 );
whereAndInfoDelete(db, a->u.pAndInfo);
}
}
if( a==aLast ) break;
a++;
}
}
if( pWC->a!=pWC->aStatic ){
sqlite3DbFree(db, pWC->a);
}
}
/*
** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression
** tree.
**
** sqlite3WhereExprUsage(MaskSet, Expr) ->
**
** Return a Bitmask of all tables referenced by Expr. Expr can be
** be NULL, in which case 0 is returned.
**
** sqlite3WhereExprUsageNN(MaskSet, Expr) ->
**
** Same as sqlite3WhereExprUsage() except that Expr must not be
** NULL. The "NN" suffix on the name stands for "Not Null".
**
** sqlite3WhereExprListUsage(MaskSet, ExprList) ->
**
** Return a Bitmask of all tables referenced by every expression
** in the expression list ExprList. ExprList can be NULL, in which
** case 0 is returned.
**
** sqlite3WhereExprUsageFull(MaskSet, ExprList) ->
**
** Internal use only. Called only by sqlite3WhereExprUsageNN() for
** complex expressions that require pushing register values onto
** the stack. Many calls to sqlite3WhereExprUsageNN() do not need
** the more complex analysis done by this routine. Hence, the
** computations done by this routine are broken out into a separate
** "no-inline" function to avoid the stack push overhead in the
** common case where it is not needed.
*/
static SQLITE_NOINLINE Bitmask sqlite3WhereExprUsageFull(
WhereMaskSet *pMaskSet,
Expr *p
){
Bitmask mask;
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
if( p->pRight ){
mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight);
assert( p->x.pList==0 );
}else if( ExprUseXSelect(p) ){
if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
}else if( p->x.pList ){
mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
}
#ifndef SQLITE_OMIT_WINDOWFUNC
if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && ExprUseYWin(p) ){
assert( p->y.pWin!=0 );
mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition);
mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy);
mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter);
}
#endif
return mask;
}
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
return sqlite3WhereGetMask(pMaskSet, p->iTable);
}else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
assert( p->op!=TK_IF_NULL_ROW );
return 0;
}
return sqlite3WhereExprUsageFull(pMaskSet, p);
}
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
}
SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){
int i;
Bitmask mask = 0;
|
| ︙ | ︙ | |||
150832 150833 150834 150835 150836 150837 150838 |
/*
** Return the bitmask for the given cursor number. Return 0 if
** iCursor is not in the set.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){
int i;
assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );
| > > > > > | | 151207 151208 151209 151210 151211 151212 151213 151214 151215 151216 151217 151218 151219 151220 151221 151222 151223 151224 151225 151226 |
/*
** Return the bitmask for the given cursor number. Return 0 if
** iCursor is not in the set.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){
int i;
assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );
assert( pMaskSet->n>0 || pMaskSet->ix[0]<0 );
assert( iCursor>=-1 );
if( pMaskSet->ix[0]==iCursor ){
return 1;
}
for(i=1; i<pMaskSet->n; i++){
if( pMaskSet->ix[i]==iCursor ){
return MASKBIT(i);
}
}
return 0;
}
|
| ︙ | ︙ | |||
151017 151018 151019 151020 151021 151022 151023 |
pScan->k = 0;
pScan->aiCur[0] = iCur;
pScan->nEquiv = 1;
pScan->iEquiv = 1;
if( pIdx ){
int j = iColumn;
iColumn = pIdx->aiColumn[j];
| > > > > > | < < < < < | 151397 151398 151399 151400 151401 151402 151403 151404 151405 151406 151407 151408 151409 151410 151411 151412 151413 151414 151415 151416 151417 151418 151419 151420 |
pScan->k = 0;
pScan->aiCur[0] = iCur;
pScan->nEquiv = 1;
pScan->iEquiv = 1;
if( pIdx ){
int j = iColumn;
iColumn = pIdx->aiColumn[j];
if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
pScan->zCollName = pIdx->azColl[j];
}else if( iColumn==XN_EXPR ){
pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
pScan->zCollName = pIdx->azColl[j];
pScan->aiColumn[0] = XN_EXPR;
return whereScanInitIndexExpr(pScan);
}
}else if( iColumn==XN_EXPR ){
return 0;
}
pScan->aiColumn[0] = iColumn;
return whereScanNext(pScan);
}
|
| ︙ | ︙ | |||
151310 151311 151312 151313 151314 151315 151316 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX /* ** Return TRUE if the WHERE clause term pTerm is of a form where it ** could be used with an index to access pSrc, assuming an appropriate ** index existed. */ static int termCanDriveIndex( | | | | | 151690 151691 151692 151693 151694 151695 151696 151697 151698 151699 151700 151701 151702 151703 151704 151705 151706 |
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
/*
** Return TRUE if the WHERE clause term pTerm is of a form where it
** could be used with an index to access pSrc, assuming an appropriate
** index existed.
*/
static int termCanDriveIndex(
const WhereTerm *pTerm, /* WHERE clause term to check */
const SrcItem *pSrc, /* Table we are trying to access */
const Bitmask notReady /* Tables in outer loops of the join */
){
char aff;
if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0;
if( (pSrc->fg.jointype & JT_LEFT)
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
&& (pTerm->eOperator & WO_IS)
|
| ︙ | ︙ | |||
151343 151344 151345 151346 151347 151348 151349 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX /* ** Generate code to construct the Index object for an automatic index ** and to set up the WhereLevel object pLevel so that the code generator ** makes use of the automatic index. */ | | | | | | 151723 151724 151725 151726 151727 151728 151729 151730 151731 151732 151733 151734 151735 151736 151737 151738 151739 151740 151741 |
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
/*
** Generate code to construct the Index object for an automatic index
** and to set up the WhereLevel object pLevel so that the code generator
** makes use of the automatic index.
*/
static SQLITE_NOINLINE void constructAutomaticIndex(
Parse *pParse, /* The parsing context */
const WhereClause *pWC, /* The WHERE clause */
const SrcItem *pSrc, /* The FROM clause term to get the next index */
const Bitmask notReady, /* Mask of cursors that are not available */
WhereLevel *pLevel /* Write new index here */
){
int nKeyCol; /* Number of columns in the constructed index */
WhereTerm *pTerm; /* A single term of the WHERE clause */
WhereTerm *pWCEnd; /* End of pWC->a[] */
Index *pIdx; /* Object describing the transient index */
Vdbe *v; /* Prepared statement under construction */
|
| ︙ | ︙ | |||
151389 151390 151391 151392 151393 151394 151395 |
nKeyCol = 0;
pTable = pSrc->pTab;
pWCEnd = &pWC->a[pWC->nTerm];
pLoop = pLevel->pWLoop;
idxCols = 0;
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
| | < | < > | | | > | 151769 151770 151771 151772 151773 151774 151775 151776 151777 151778 151779 151780 151781 151782 151783 151784 151785 151786 151787 151788 151789 |
nKeyCol = 0;
pTable = pSrc->pTab;
pWCEnd = &pWC->a[pWC->nTerm];
pLoop = pLevel->pWLoop;
idxCols = 0;
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
/* Make the automatic index a partial index if there are terms in the
** WHERE clause (or the ON clause of a LEFT join) that constrain which
** rows of the target table (pSrc) that can be used. */
if( (pTerm->wtFlags & TERM_VIRTUAL)==0
&& ((pSrc->fg.jointype&JT_LEFT)==0 || ExprHasProperty(pExpr,EP_FromJoin))
&& sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor)
){
pPartial = sqlite3ExprAnd(pParse, pPartial,
sqlite3ExprDup(pParse->db, pExpr, 0));
}
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
int iCol;
Bitmask cMask;
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
| ︙ | ︙ | |||
151502 151503 151504 151505 151506 151507 151508 151509 151510 151511 151512 151513 151514 151515 |
/* Create the automatic index */
assert( pLevel->iIdxCur>=0 );
pLevel->iIdxCur = pParse->nTab++;
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
VdbeComment((v, "for %s", pTable->zName));
/* Fill the automatic index with content */
pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
if( pTabItem->fg.viaCoroutine ){
int regYield = pTabItem->regReturn;
addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
| > > > > | 151882 151883 151884 151885 151886 151887 151888 151889 151890 151891 151892 151893 151894 151895 151896 151897 151898 151899 |
/* Create the automatic index */
assert( pLevel->iIdxCur>=0 );
pLevel->iIdxCur = pParse->nTab++;
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
VdbeComment((v, "for %s", pTable->zName));
if( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){
pLevel->regFilter = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Blob, 10000, pLevel->regFilter);
}
/* Fill the automatic index with content */
pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
if( pTabItem->fg.viaCoroutine ){
int regYield = pTabItem->regReturn;
addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
|
| ︙ | ︙ | |||
151524 151525 151526 151527 151528 151529 151530 151531 151532 151533 151534 151535 151536 151537 |
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
pLoop->wsFlags |= WHERE_PARTIALIDX;
}
regRecord = sqlite3GetTempReg(pParse);
regBase = sqlite3GenerateIndexKey(
pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
);
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
if( pTabItem->fg.viaCoroutine ){
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
testcase( pParse->db->mallocFailed );
assert( pLevel->iIdxCur>0 );
| > > > > | 151908 151909 151910 151911 151912 151913 151914 151915 151916 151917 151918 151919 151920 151921 151922 151923 151924 151925 |
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
pLoop->wsFlags |= WHERE_PARTIALIDX;
}
regRecord = sqlite3GetTempReg(pParse);
regBase = sqlite3GenerateIndexKey(
pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
);
if( pLevel->regFilter ){
sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0,
regBase, pLoop->u.btree.nEq);
}
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
if( pTabItem->fg.viaCoroutine ){
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
testcase( pParse->db->mallocFailed );
assert( pLevel->iIdxCur>0 );
|
| ︙ | ︙ | |||
151549 151550 151551 151552 151553 151554 151555 151556 151557 151558 151559 151560 151561 151562 | /* Jump here when skipping the initialization */ sqlite3VdbeJumpHere(v, addrInit); end_auto_index_create: sqlite3ExprDelete(pParse->db, pPartial); } #endif /* SQLITE_OMIT_AUTOMATIC_INDEX */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* ** Allocate and populate an sqlite3_index_info structure. It is the ** responsibility of the caller to eventually release the structure ** by passing the pointer returned by this function to sqlite3_free(). */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 151937 151938 151939 151940 151941 151942 151943 151944 151945 151946 151947 151948 151949 151950 151951 151952 151953 151954 151955 151956 151957 151958 151959 151960 151961 151962 151963 151964 151965 151966 151967 151968 151969 151970 151971 151972 151973 151974 151975 151976 151977 151978 151979 151980 151981 151982 151983 151984 151985 151986 151987 151988 151989 151990 151991 151992 151993 151994 151995 151996 151997 151998 151999 152000 152001 152002 152003 152004 152005 152006 152007 152008 152009 152010 152011 152012 152013 152014 152015 152016 152017 152018 152019 152020 152021 152022 152023 152024 152025 152026 152027 152028 152029 152030 152031 152032 152033 152034 152035 152036 152037 152038 152039 152040 152041 152042 152043 152044 152045 152046 152047 152048 152049 152050 152051 152052 152053 152054 152055 152056 152057 152058 152059 152060 152061 152062 152063 152064 152065 152066 152067 |
/* Jump here when skipping the initialization */
sqlite3VdbeJumpHere(v, addrInit);
end_auto_index_create:
sqlite3ExprDelete(pParse->db, pPartial);
}
#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
/*
** Generate bytecode that will initialize a Bloom filter that is appropriate
** for pLevel.
**
** If there are inner loops within pLevel that have the WHERE_BLOOMFILTER
** flag set, initialize a Bloomfilter for them as well. Except don't do
** this recursive initialization if the SQLITE_BloomPulldown optimization has
** been turned off.
**
** When the Bloom filter is initialized, the WHERE_BLOOMFILTER flag is cleared
** from the loop, but the regFilter value is set to a register that implements
** the Bloom filter. When regFilter is positive, the
** sqlite3WhereCodeOneLoopStart() will generate code to test the Bloom filter
** and skip the subsequence B-Tree seek if the Bloom filter indicates that
** no matching rows exist.
**
** This routine may only be called if it has previously been determined that
** the loop would benefit from a Bloom filter, and the WHERE_BLOOMFILTER bit
** is set.
*/
static SQLITE_NOINLINE void constructBloomFilter(
WhereInfo *pWInfo, /* The WHERE clause */
int iLevel, /* Index in pWInfo->a[] that is pLevel */
WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */
Bitmask notReady /* Loops that are not ready */
){
int addrOnce; /* Address of opening OP_Once */
int addrTop; /* Address of OP_Rewind */
int addrCont; /* Jump here to skip a row */
const WhereTerm *pTerm; /* For looping over WHERE clause terms */
const WhereTerm *pWCEnd; /* Last WHERE clause term */
Parse *pParse = pWInfo->pParse; /* Parsing context */
Vdbe *v = pParse->pVdbe; /* VDBE under construction */
WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */
int iCur; /* Cursor for table getting the filter */
assert( pLoop!=0 );
assert( v!=0 );
assert( pLoop->wsFlags & WHERE_BLOOMFILTER );
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
do{
const SrcItem *pItem;
const Table *pTab;
u64 sz;
sqlite3WhereExplainBloomFilter(pParse, pWInfo, pLevel);
addrCont = sqlite3VdbeMakeLabel(pParse);
iCur = pLevel->iTabCur;
pLevel->regFilter = ++pParse->nMem;
/* The Bloom filter is a Blob held in a register. Initialize it
** to zero-filled blob of at least 80K bits, but maybe more if the
** estimated size of the table is larger. We could actually
** measure the size of the table at run-time using OP_Count with
** P3==1 and use that value to initialize the blob. But that makes
** testing complicated. By basing the blob size on the value in the
** sqlite_stat1 table, testing is much easier.
*/
pItem = &pWInfo->pTabList->a[pLevel->iFrom];
assert( pItem!=0 );
pTab = pItem->pTab;
assert( pTab!=0 );
sz = sqlite3LogEstToInt(pTab->nRowLogEst);
if( sz<10000 ){
sz = 10000;
}else if( sz>10000000 ){
sz = 10000000;
}
sqlite3VdbeAddOp2(v, OP_Blob, (int)sz, pLevel->regFilter);
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm];
for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
if( (pTerm->wtFlags & TERM_VIRTUAL)==0
&& sqlite3ExprIsTableConstant(pExpr, iCur)
){
sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
}
}
if( pLoop->wsFlags & WHERE_IPK ){
int r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Rowid, iCur, r1);
sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, 1);
sqlite3ReleaseTempReg(pParse, r1);
}else{
Index *pIdx = pLoop->u.btree.pIndex;
int n = pLoop->u.btree.nEq;
int r1 = sqlite3GetTempRange(pParse, n);
int jj;
for(jj=0; jj<n; jj++){
int iCol = pIdx->aiColumn[jj];
assert( pIdx->pTable==pItem->pTab );
sqlite3ExprCodeGetColumnOfTable(v, pIdx->pTable, iCur, iCol,r1+jj);
}
sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, n);
sqlite3ReleaseTempRange(pParse, r1, n);
}
sqlite3VdbeResolveLabel(v, addrCont);
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
VdbeCoverage(v);
sqlite3VdbeJumpHere(v, addrTop);
pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
while( iLevel < pWInfo->nLevel ){
iLevel++;
pLevel = &pWInfo->a[iLevel];
pLoop = pLevel->pWLoop;
if( pLoop==0 ) continue;
if( pLoop->prereq & notReady ) continue;
if( pLoop->wsFlags & WHERE_BLOOMFILTER ) break;
}
}while( iLevel < pWInfo->nLevel );
sqlite3VdbeJumpHere(v, addrOnce);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Allocate and populate an sqlite3_index_info structure. It is the
** responsibility of the caller to eventually release the structure
** by passing the pointer returned by this function to sqlite3_free().
*/
|
| ︙ | ︙ | |||
152492 152493 152494 152495 152496 152497 152498 |
}else{
z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask);
}
sqlite3DebugPrintf(" %-19s", z);
sqlite3_free(z);
}
if( p->wsFlags & WHERE_SKIPSCAN ){
| | | | 152997 152998 152999 153000 153001 153002 153003 153004 153005 153006 153007 153008 153009 153010 153011 153012 153013 |
}else{
z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask);
}
sqlite3DebugPrintf(" %-19s", z);
sqlite3_free(z);
}
if( p->wsFlags & WHERE_SKIPSCAN ){
sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
}else{
sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
}
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){
int i;
for(i=0; i<p->nLTerm; i++){
sqlite3WhereTermPrint(p->aLTerm[i], i);
}
|
| ︙ | ︙ | |||
152954 152955 152956 152957 152958 152959 152960 |
){
WhereTerm *pTerm, *pX;
Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
int i, j;
LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
| | | | > > > > > > > | 153459 153460 153461 153462 153463 153464 153465 153466 153467 153468 153469 153470 153471 153472 153473 153474 153475 153476 153477 153478 153479 153480 153481 153482 153483 153484 153485 153486 153487 153488 153489 153490 153491 |
){
WhereTerm *pTerm, *pX;
Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
int i, j;
LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
for(i=pWC->nBase, pTerm=pWC->a; i>0; i--, pTerm++){
assert( pTerm!=0 );
if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) continue;
for(j=pLoop->nLTerm-1; j>=0; j--){
pX = pLoop->aLTerm[j];
if( pX==0 ) continue;
if( pX==pTerm ) break;
if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
}
if( j<0 ){
if( pLoop->maskSelf==pTerm->prereqAll ){
/* If there are extra terms in the WHERE clause not used by an index
** that depend only on the table being scanned, and that will tend to
** cause many rows to be omitted, then mark that table as
** "self-culling". */
pLoop->wsFlags |= WHERE_SELFCULL;
}
if( pTerm->truthProb<=0 ){
/* If a truth probability is specified using the likelihood() hints,
** then use the probability provided by the application. */
pLoop->nOut += pTerm->truthProb;
}else{
/* In the absence of explicit truth probabilities, use heuristics to
** guess a reasonable truth probability. */
|
| ︙ | ︙ | |||
152993 152994 152995 152996 152997 152998 152999 |
pTerm->wtFlags |= TERM_HEURTRUTH;
iReduce = k;
}
}
}
}
}
| | > > | 153505 153506 153507 153508 153509 153510 153511 153512 153513 153514 153515 153516 153517 153518 153519 153520 153521 |
pTerm->wtFlags |= TERM_HEURTRUTH;
iReduce = k;
}
}
}
}
}
if( pLoop->nOut > nRow-iReduce ){
pLoop->nOut = nRow - iReduce;
}
}
/*
** Term pTerm is a vector range comparison operation. The first comparison
** in the vector can be optimized using column nEq of the index. This
** function returns the total number of vector elements that can be used
** as part of the range comparison.
|
| ︙ | ︙ | |||
154229 154230 154231 154232 154233 154234 154235 154236 154237 154238 154239 154240 154241 154242 |
if( (pOrTerm->eOperator & WO_AND)!=0 ){
sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;
}else if( pOrTerm->leftCursor==iCur ){
tempWC.pWInfo = pWC->pWInfo;
tempWC.pOuter = pWC;
tempWC.op = TK_AND;
tempWC.nTerm = 1;
tempWC.a = pOrTerm;
sSubBuild.pWC = &tempWC;
}else{
continue;
}
sCur.n = 0;
#ifdef WHERETRACE_ENABLED
| > | 154743 154744 154745 154746 154747 154748 154749 154750 154751 154752 154753 154754 154755 154756 154757 |
if( (pOrTerm->eOperator & WO_AND)!=0 ){
sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;
}else if( pOrTerm->leftCursor==iCur ){
tempWC.pWInfo = pWC->pWInfo;
tempWC.pOuter = pWC;
tempWC.op = TK_AND;
tempWC.nTerm = 1;
tempWC.nBase = 1;
tempWC.a = pOrTerm;
sSubBuild.pWC = &tempWC;
}else{
continue;
}
sCur.n = 0;
#ifdef WHERETRACE_ENABLED
|
| ︙ | ︙ | |||
155335 155336 155337 155338 155339 155340 155341 155342 155343 155344 155345 155346 155347 155348 |
}
}
}
# define WHERETRACE_ALL_LOOPS(W,C) showAllWhereLoops(W,C)
#else
# define WHERETRACE_ALL_LOOPS(W,C)
#endif
/*
** Generate the beginning of the loop used for WHERE clause processing.
** The return value is a pointer to an opaque structure that contains
** information needed to terminate the loop. Later, the calling routine
** should invoke sqlite3WhereEnd() with the return value of this function
** in order to complete the WHERE clause processing.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 155850 155851 155852 155853 155854 155855 155856 155857 155858 155859 155860 155861 155862 155863 155864 155865 155866 155867 155868 155869 155870 155871 155872 155873 155874 155875 155876 155877 155878 155879 155880 155881 155882 155883 155884 155885 155886 155887 155888 155889 155890 155891 155892 155893 155894 155895 155896 155897 155898 155899 155900 155901 155902 155903 155904 155905 155906 155907 155908 155909 155910 155911 155912 155913 155914 155915 155916 155917 155918 155919 155920 155921 155922 155923 155924 155925 155926 155927 155928 155929 155930 155931 155932 155933 155934 155935 155936 155937 155938 155939 155940 155941 155942 155943 155944 155945 155946 155947 155948 155949 155950 155951 155952 155953 155954 155955 155956 155957 155958 155959 155960 155961 155962 155963 155964 155965 155966 155967 155968 155969 155970 155971 155972 155973 155974 155975 155976 155977 155978 155979 155980 155981 155982 155983 155984 155985 155986 155987 155988 155989 155990 155991 155992 155993 155994 155995 155996 155997 155998 155999 156000 156001 156002 156003 156004 156005 156006 156007 |
}
}
}
# define WHERETRACE_ALL_LOOPS(W,C) showAllWhereLoops(W,C)
#else
# define WHERETRACE_ALL_LOOPS(W,C)
#endif
/* Attempt to omit tables from a join that do not affect the result.
** For a table to not affect the result, the following must be true:
**
** 1) The query must not be an aggregate.
** 2) The table must be the RHS of a LEFT JOIN.
** 3) Either the query must be DISTINCT, or else the ON or USING clause
** must contain a constraint that limits the scan of the table to
** at most a single row.
** 4) The table must not be referenced by any part of the query apart
** from its own USING or ON clause.
**
** For example, given:
**
** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
**
** then table t2 can be omitted from the following:
**
** SELECT v1, v3 FROM t1
** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
**
** or from:
**
** SELECT DISTINCT v1, v3 FROM t1
** LEFT JOIN t2
** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
*/
static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
WhereInfo *pWInfo,
Bitmask notReady
){
int i;
Bitmask tabUsed;
/* Preconditions checked by the caller */
assert( pWInfo->nLevel>=2 );
assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_OmitNoopJoin) );
/* These two preconditions checked by the caller combine to guarantee
** condition (1) of the header comment */
assert( pWInfo->pResultSet!=0 );
assert( 0==(pWInfo->wctrlFlags & WHERE_AGG_DISTINCT) );
tabUsed = sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pResultSet);
if( pWInfo->pOrderBy ){
tabUsed |= sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pOrderBy);
}
for(i=pWInfo->nLevel-1; i>=1; i--){
WhereTerm *pTerm, *pEnd;
SrcItem *pItem;
WhereLoop *pLoop;
pLoop = pWInfo->a[i].pWLoop;
pItem = &pWInfo->pTabList->a[pLoop->iTab];
if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
&& (pLoop->wsFlags & WHERE_ONEROW)==0
){
continue;
}
if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
pEnd = pWInfo->sWC.a + pWInfo->sWC.nTerm;
for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
|| pTerm->pExpr->iRightJoinTable!=pItem->iCursor
){
break;
}
}
}
if( pTerm<pEnd ) continue;
WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
notReady &= ~pLoop->maskSelf;
for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
pTerm->wtFlags |= TERM_CODED;
}
}
if( i!=pWInfo->nLevel-1 ){
int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
}
pWInfo->nLevel--;
assert( pWInfo->nLevel>0 );
}
return notReady;
}
/*
** Check to see if there are any SEARCH loops that might benefit from
** using a Bloom filter. Consider a Bloom filter if:
**
** (1) The SEARCH happens more than N times where N is the number
** of rows in the table that is being considered for the Bloom
** filter.
** (2) Some searches are expected to find zero rows. (This is determined
** by the WHERE_SELFCULL flag on the term.)
** (3) Bloom-filter processing is not disabled. (Checked by the
** caller.)
** (4) The size of the table being searched is known by ANALYZE.
**
** This block of code merely checks to see if a Bloom filter would be
** appropriate, and if so sets the WHERE_BLOOMFILTER flag on the
** WhereLoop. The implementation of the Bloom filter comes further
** down where the code for each WhereLoop is generated.
*/
static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
const WhereInfo *pWInfo
){
int i;
LogEst nSearch;
assert( pWInfo->nLevel>=2 );
assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
nSearch = pWInfo->a[0].pWLoop->nOut;
for(i=1; i<pWInfo->nLevel; i++){
WhereLoop *pLoop = pWInfo->a[i].pWLoop;
const int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
if( (pLoop->wsFlags & reqFlags)==reqFlags
/* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
&& ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
){
SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
Table *pTab = pItem->pTab;
pTab->tabFlags |= TF_StatsUsed;
if( nSearch > pTab->nRowLogEst
&& (pTab->tabFlags & TF_HasStat1)!=0
){
testcase( pItem->fg.jointype & JT_LEFT );
pLoop->wsFlags |= WHERE_BLOOMFILTER;
pLoop->wsFlags &= ~WHERE_IDX_ONLY;
WHERETRACE(0xffff, (
"-> use Bloom-filter on loop %c because there are ~%.1e "
"lookups into %s which has only ~%.1e rows\n",
pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
(double)sqlite3LogEstToInt(pTab->nRowLogEst)));
}
}
nSearch += pLoop->nOut;
}
}
/*
** Generate the beginning of the loop used for WHERE clause processing.
** The return value is a pointer to an opaque structure that contains
** information needed to terminate the loop. Later, the calling routine
** should invoke sqlite3WhereEnd() with the return value of this function
** in order to complete the WHERE clause processing.
|
| ︙ | ︙ | |||
155466 155467 155468 155469 155470 155471 155472 | memset(&sWLB, 0, sizeof(sWLB)); /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0; sWLB.pOrderBy = pOrderBy; | < < < < < < | 156125 156126 156127 156128 156129 156130 156131 156132 156133 156134 156135 156136 156137 156138 |
memset(&sWLB, 0, sizeof(sWLB));
/* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );
if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;
sWLB.pOrderBy = pOrderBy;
/* The number of tables in the FROM clause is limited by the number of
** bits in a Bitmask
*/
testcase( pTabList->nSrc==BMS );
if( pTabList->nSrc>BMS ){
sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
return 0;
|
| ︙ | ︙ | |||
155518 155519 155520 155521 155522 155523 155524 155525 155526 155527 155528 155529 155530 155531 155532 155533 155534 155535 155536 |
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
memset(&pWInfo->nOBSat, 0,
offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));
memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));
assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */
pMaskSet = &pWInfo->sMaskSet;
sWLB.pWInfo = pWInfo;
sWLB.pWC = &pWInfo->sWC;
sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);
assert( EIGHT_BYTE_ALIGNMENT(sWLB.pNew) );
whereLoopInit(sWLB.pNew);
#ifdef SQLITE_DEBUG
sWLB.pNew->cId = '*';
#endif
/* Split the WHERE clause into separate subexpressions where each
** subexpression is separated by an AND operator.
*/
| > > > > < | > > | 156171 156172 156173 156174 156175 156176 156177 156178 156179 156180 156181 156182 156183 156184 156185 156186 156187 156188 156189 156190 156191 156192 156193 156194 156195 156196 156197 156198 156199 156200 156201 156202 156203 156204 156205 156206 156207 156208 156209 156210 |
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
memset(&pWInfo->nOBSat, 0,
offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));
memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));
assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */
pMaskSet = &pWInfo->sMaskSet;
pMaskSet->n = 0;
pMaskSet->ix[0] = -99; /* Initialize ix[0] to a value that can never be
** a valid cursor number, to avoid an initial
** test for pMaskSet->n==0 in sqlite3WhereGetMask() */
sWLB.pWInfo = pWInfo;
sWLB.pWC = &pWInfo->sWC;
sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);
assert( EIGHT_BYTE_ALIGNMENT(sWLB.pNew) );
whereLoopInit(sWLB.pNew);
#ifdef SQLITE_DEBUG
sWLB.pNew->cId = '*';
#endif
/* Split the WHERE clause into separate subexpressions where each
** subexpression is separated by an AND operator.
*/
sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
/* Special case: No FROM clause
*/
if( nTabList==0 ){
if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
if( (wctrlFlags & WHERE_WANT_DISTINCT)!=0
&& OptimizationEnabled(db, SQLITE_DistinctOpt)
){
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}
ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
}else{
/* Assign a bit from the bitmask to every term in the FROM clause.
**
** The N-th term of the FROM clause is assigned a bitmask of 1<<N.
|
| ︙ | ︙ | |||
155589 155590 155591 155592 155593 155594 155595 | ** Do not do this if the expression contains non-deterministic functions ** that are not within a sub-select. This is not strictly required, but ** preserves SQLite's legacy behaviour in the following two cases: ** ** FROM ... WHERE random()>0; -- eval random() once per row ** FROM ... WHERE (SELECT random())>0; -- eval random() once overall */ | | > > > > > | | 156247 156248 156249 156250 156251 156252 156253 156254 156255 156256 156257 156258 156259 156260 156261 156262 156263 156264 156265 156266 156267 156268 156269 156270 156271 156272 156273 156274 156275 156276 |
** Do not do this if the expression contains non-deterministic functions
** that are not within a sub-select. This is not strictly required, but
** preserves SQLite's legacy behaviour in the following two cases:
**
** FROM ... WHERE random()>0; -- eval random() once per row
** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
*/
for(ii=0; ii<sWLB.pWC->nBase; ii++){
WhereTerm *pT = &sWLB.pWC->a[ii];
if( pT->wtFlags & TERM_VIRTUAL ) continue;
if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);
pT->wtFlags |= TERM_CODED;
}
}
if( wctrlFlags & WHERE_WANT_DISTINCT ){
if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
/* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
wctrlFlags &= ~WHERE_WANT_DISTINCT;
pWInfo->wctrlFlags &= ~WHERE_WANT_DISTINCT;
}else if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
/* The DISTINCT marking is pointless. Ignore it. */
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}else if( pOrderBy==0 ){
/* Try to ORDER BY the result set to make distinct processing easier */
pWInfo->wctrlFlags |= WHERE_DISTINCTBY;
pWInfo->pOrderBy = pResultSet;
}
|
| ︙ | ︙ | |||
155700 155701 155702 155703 155704 155705 155706 |
sqlite3DebugPrintf("\n");
for(ii=0; ii<pWInfo->nLevel; ii++){
sqlite3WhereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);
}
}
#endif
| | | | | | | | | < < < < < < < < < < < < < < < < < < < | | | < | < < < < < < < < < < | > > > | < < < < < > | < < < < < < < < < < < < < < < < | < | | | 156363 156364 156365 156366 156367 156368 156369 156370 156371 156372 156373 156374 156375 156376 156377 156378 156379 156380 156381 156382 156383 156384 156385 156386 156387 156388 156389 156390 156391 156392 156393 156394 156395 156396 156397 156398 156399 156400 156401 156402 156403 156404 156405 156406 |
sqlite3DebugPrintf("\n");
for(ii=0; ii<pWInfo->nLevel; ii++){
sqlite3WhereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);
}
}
#endif
/* Attempt to omit tables from a join that do not affect the result.
** See the comment on whereOmitNoopJoin() for further information.
**
** This query optimization is factored out into a separate "no-inline"
** procedure to keep the sqlite3WhereBegin() procedure from becoming
** too large. If sqlite3WhereBegin() becomes too large, that prevents
** some C-compiler optimizers from in-lining the
** sqlite3WhereCodeOneLoopStart() procedure, and it is important to
** in-line sqlite3WhereCodeOneLoopStart() for performance reasons.
*/
notReady = ~(Bitmask)0;
if( pWInfo->nLevel>=2
&& pResultSet!=0 /* these two combine to guarantee */
&& 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
){
notReady = whereOmitNoopJoin(pWInfo, notReady);
nTabList = pWInfo->nLevel;
assert( nTabList>0 );
}
/* Check to see if there are any SEARCH loops that might benefit from
** using a Bloom filter.
*/
if( pWInfo->nLevel>=2
&& OptimizationEnabled(db, SQLITE_BloomFilter)
){
whereCheckIfBloomFilterIsUseful(pWInfo);
}
#if defined(WHERETRACE_ENABLED)
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n");
sqlite3WhereClausePrint(sWLB.pWC);
}
WHERETRACE(0xffff,("*** Optimizer Finished ***\n"));
#endif
|
| ︙ | ︙ | |||
155966 155967 155968 155969 155970 155971 155972 155973 |
*/
for(ii=0; ii<nTabList; ii++){
int addrExplain;
int wsFlags;
if( pParse->nErr ) goto whereBeginError;
pLevel = &pWInfo->a[ii];
wsFlags = pLevel->pWLoop->wsFlags;
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
| > > < | | > > > > < | 156581 156582 156583 156584 156585 156586 156587 156588 156589 156590 156591 156592 156593 156594 156595 156596 156597 156598 156599 156600 156601 156602 156603 156604 156605 |
*/
for(ii=0; ii<nTabList; ii++){
int addrExplain;
int wsFlags;
if( pParse->nErr ) goto whereBeginError;
pLevel = &pWInfo->a[ii];
wsFlags = pLevel->pWLoop->wsFlags;
if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){
if( (wsFlags & WHERE_AUTO_INDEX)!=0 ){
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
constructAutomaticIndex(pParse, &pWInfo->sWC,
&pTabList->a[pLevel->iFrom], notReady, pLevel);
#endif
}else{
constructBloomFilter(pWInfo, ii, pLevel, notReady);
}
if( db->mallocFailed ) goto whereBeginError;
}
addrExplain = sqlite3WhereExplainOneScan(
pParse, pTabList, pLevel, wctrlFlags
);
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
notReady = sqlite3WhereCodeOneLoopStart(pParse,v,pWInfo,ii,pLevel,notReady);
pWInfo->iContinue = pLevel->addrCont;
if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
|
| ︙ | ︙ | |||
159699 159700 159701 159702 159703 159704 159705 | #define TK_DATABASE 38 #define TK_DESC 39 #define TK_DETACH 40 #define TK_EACH 41 #define TK_FAIL 42 #define TK_OR 43 #define TK_AND 44 | < | | | > | 160318 160319 160320 160321 160322 160323 160324 160325 160326 160327 160328 160329 160330 160331 160332 160333 160334 160335 | #define TK_DATABASE 38 #define TK_DESC 39 #define TK_DETACH 40 #define TK_EACH 41 #define TK_FAIL 42 #define TK_OR 43 #define TK_AND 44 #define TK_MATCH 45 #define TK_LIKE_KW 46 #define TK_BETWEEN 47 #define TK_IS 48 #define TK_IN 49 #define TK_ISNULL 50 #define TK_NOTNULL 51 #define TK_NE 52 #define TK_EQ 53 #define TK_GT 54 #define TK_LE 55 |
| ︙ | ︙ | |||
160014 160015 160016 160017 160018 160019 160020 | ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 160633 160634 160635 160636 160637 160638 160639 160640 160641 160642 160643 160644 160645 160646 160647 160648 160649 160650 160651 160652 160653 160654 160655 160656 160657 160658 160659 160660 160661 160662 160663 160664 160665 160666 160667 160668 160669 160670 160671 160672 160673 160674 160675 160676 160677 160678 160679 160680 160681 160682 160683 160684 160685 160686 160687 160688 160689 160690 160691 160692 160693 160694 160695 160696 160697 160698 160699 160700 160701 160702 160703 160704 160705 160706 160707 160708 160709 160710 160711 160712 160713 160714 160715 160716 160717 160718 160719 160720 160721 160722 160723 160724 160725 160726 160727 160728 160729 160730 160731 160732 160733 160734 160735 160736 160737 160738 160739 160740 160741 160742 160743 160744 160745 160746 160747 160748 160749 160750 160751 160752 160753 160754 160755 160756 160757 160758 160759 160760 160761 160762 160763 160764 160765 160766 160767 160768 160769 160770 160771 160772 160773 160774 160775 160776 160777 160778 160779 160780 160781 160782 160783 160784 160785 160786 160787 160788 160789 160790 160791 160792 160793 160794 160795 160796 160797 160798 160799 160800 160801 160802 160803 160804 160805 160806 160807 160808 160809 160810 160811 160812 160813 160814 160815 160816 160817 160818 160819 160820 160821 160822 160823 160824 160825 160826 160827 160828 160829 160830 160831 160832 160833 160834 160835 160836 160837 160838 160839 160840 160841 160842 160843 160844 160845 160846 160847 160848 160849 160850 160851 160852 160853 160854 160855 160856 160857 160858 160859 160860 160861 160862 160863 160864 160865 160866 160867 160868 160869 160870 160871 160872 160873 160874 160875 160876 160877 160878 160879 160880 160881 160882 160883 160884 160885 160886 160887 160888 160889 160890 160891 160892 160893 160894 160895 160896 160897 160898 160899 160900 160901 160902 160903 160904 160905 160906 160907 160908 160909 160910 160911 160912 160913 160914 160915 160916 160917 160918 160919 160920 160921 160922 160923 160924 160925 160926 160927 160928 160929 160930 160931 160932 160933 160934 160935 160936 160937 160938 160939 160940 160941 160942 160943 160944 160945 160946 160947 160948 160949 160950 160951 160952 160953 160954 160955 160956 160957 160958 160959 160960 160961 160962 160963 160964 160965 160966 160967 160968 160969 160970 160971 160972 160973 160974 160975 160976 160977 160978 160979 160980 160981 160982 160983 160984 160985 160986 160987 160988 160989 160990 160991 160992 160993 160994 160995 160996 160997 160998 160999 161000 161001 161002 161003 161004 161005 161006 161007 161008 161009 161010 161011 161012 161013 161014 161015 161016 161017 161018 161019 161020 161021 161022 161023 161024 161025 161026 161027 161028 161029 161030 161031 161032 161033 161034 161035 161036 161037 161038 161039 161040 161041 161042 161043 161044 161045 161046 161047 161048 161049 161050 161051 161052 161053 161054 161055 161056 161057 161058 161059 161060 161061 161062 161063 161064 161065 161066 161067 161068 161069 161070 161071 161072 161073 161074 161075 161076 161077 161078 161079 161080 161081 161082 161083 161084 161085 161086 161087 161088 161089 161090 161091 161092 161093 161094 161095 161096 161097 161098 161099 161100 161101 161102 161103 161104 161105 161106 161107 161108 161109 161110 161111 161112 161113 161114 161115 161116 161117 161118 161119 161120 161121 161122 161123 161124 161125 161126 161127 161128 161129 161130 161131 161132 161133 161134 161135 161136 161137 161138 161139 161140 161141 161142 161143 161144 161145 161146 161147 161148 161149 161150 161151 161152 161153 161154 161155 161156 161157 161158 161159 161160 161161 161162 161163 161164 161165 161166 161167 161168 161169 161170 161171 161172 161173 161174 161175 161176 161177 161178 161179 161180 161181 161182 161183 |
** yy_shift_ofst[] For each state, the offset into yy_action for
** shifting terminals.
** yy_reduce_ofst[] For each state, the offset into yy_action for
** shifting non-terminals after a reduce.
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (2022)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 564, 115, 112, 220, 169, 199, 115, 112, 220, 564,
/* 10 */ 375, 1266, 564, 376, 564, 270, 1309, 1309, 406, 407,
/* 20 */ 1084, 199, 1513, 41, 41, 515, 489, 521, 558, 558,
/* 30 */ 558, 965, 41, 41, 395, 41, 41, 51, 51, 966,
/* 40 */ 296, 1269, 296, 122, 123, 1207, 1207, 1041, 113, 1044,
/* 50 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 564, 407,
/* 60 */ 275, 275, 275, 275, 1268, 115, 112, 220, 115, 112,
/* 70 */ 220, 1512, 846, 561, 516, 561, 115, 112, 220, 250,
/* 80 */ 217, 71, 71, 122, 123, 1207, 1207, 1041, 113, 1044,
/* 90 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 440, 440,
/* 100 */ 440, 1149, 119, 119, 119, 119, 118, 118, 117, 117,
/* 110 */ 117, 116, 442, 1183, 1149, 116, 442, 1149, 546, 513,
/* 120 */ 1548, 1554, 374, 213, 6, 169, 1154, 522, 1154, 407,
/* 130 */ 1556, 461, 373, 1554, 535, 99, 463, 332, 121, 121,
/* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117,
/* 150 */ 117, 116, 442, 122, 123, 1207, 1207, 1041, 113, 1044,
/* 160 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 1257, 1183,
/* 170 */ 1184, 1185, 243, 1064, 564, 502, 499, 498, 567, 124,
/* 180 */ 567, 1128, 1627, 344, 1627, 497, 119, 119, 119, 119,
/* 190 */ 118, 118, 117, 117, 117, 116, 442, 70, 70, 407,
/* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 442,
/* 210 */ 474, 1469, 119, 119, 119, 119, 118, 118, 117, 117,
/* 220 */ 117, 116, 442, 122, 123, 1207, 1207, 1041, 113, 1044,
/* 230 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 407, 208,
/* 240 */ 539, 1548, 1424, 81, 339, 6, 342, 80, 119, 119,
/* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 381,
/* 260 */ 1126, 442, 122, 123, 1207, 1207, 1041, 113, 1044, 1034,
/* 270 */ 1034, 120, 120, 121, 121, 121, 121, 262, 463, 332,
/* 280 */ 359, 1567, 119, 119, 119, 119, 118, 118, 117, 117,
/* 290 */ 117, 116, 442, 1231, 1, 1, 571, 2, 1235, 1573,
/* 300 */ 571, 2, 1235, 307, 1149, 141, 417, 307, 407, 141,
/* 310 */ 1183, 98, 1317, 489, 866, 531, 1317, 1149, 215, 512,
/* 320 */ 1149, 119, 119, 119, 119, 118, 118, 117, 117, 117,
/* 330 */ 116, 442, 122, 123, 1207, 1207, 1041, 113, 1044, 1034,
/* 340 */ 1034, 120, 120, 121, 121, 121, 121, 275, 275, 1001,
/* 350 */ 1257, 275, 275, 1128, 1628, 1021, 1628, 137, 415, 1600,
/* 360 */ 561, 272, 1255, 950, 561, 1423, 1183, 1184, 1185, 1594,
/* 370 */ 866, 1012, 530, 315, 231, 1011, 317, 1276, 231, 119,
/* 380 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442,
/* 390 */ 1570, 119, 119, 119, 119, 118, 118, 117, 117, 117,
/* 400 */ 116, 442, 330, 359, 1567, 564, 446, 1011, 1011, 1013,
/* 410 */ 446, 877, 564, 306, 555, 407, 447, 1021, 563, 346,
/* 420 */ 184, 118, 118, 117, 117, 117, 116, 442, 71, 71,
/* 430 */ 439, 438, 1126, 1012, 472, 71, 71, 1011, 205, 122,
/* 440 */ 123, 1207, 1207, 1041, 113, 1044, 1034, 1034, 120, 120,
/* 450 */ 121, 121, 121, 121, 1304, 219, 1283, 1183, 407, 570,
/* 460 */ 1183, 1235, 503, 1477, 1304, 546, 307, 489, 141, 1011,
/* 470 */ 1011, 1013, 546, 140, 545, 1317, 1214, 382, 1214, 378,
/* 480 */ 950, 514, 122, 123, 1207, 1207, 1041, 113, 1044, 1034,
/* 490 */ 1034, 120, 120, 121, 121, 121, 121, 472, 119, 119,
/* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 283,
/* 510 */ 275, 275, 1476, 1183, 1184, 1185, 1183, 1184, 1185, 417,
/* 520 */ 1183, 243, 541, 561, 502, 499, 498, 1001, 407, 478,
/* 530 */ 1183, 472, 870, 143, 497, 1549, 185, 231, 9, 6,
/* 540 */ 253, 119, 119, 119, 119, 118, 118, 117, 117, 117,
/* 550 */ 116, 442, 122, 123, 1207, 1207, 1041, 113, 1044, 1034,
/* 560 */ 1034, 120, 120, 121, 121, 121, 121, 407, 372, 446,
/* 570 */ 363, 863, 288, 1183, 397, 1204, 1183, 1184, 1185, 931,
/* 580 */ 330, 458, 318, 526, 564, 541, 1183, 1184, 1185, 284,
/* 590 */ 1183, 122, 123, 1207, 1207, 1041, 113, 1044, 1034, 1034,
/* 600 */ 120, 120, 121, 121, 121, 121, 291, 71, 71, 275,
/* 610 */ 275, 119, 119, 119, 119, 118, 118, 117, 117, 117,
/* 620 */ 116, 442, 561, 1031, 1031, 1042, 1183, 1045, 287, 1183,
/* 630 */ 1184, 1185, 1204, 137, 218, 542, 1541, 407, 363, 470,
/* 640 */ 431, 1167, 32, 363, 527, 350, 1183, 1184, 1185, 380,
/* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
/* 660 */ 442, 122, 123, 1207, 1207, 1041, 113, 1044, 1034, 1034,
/* 670 */ 120, 120, 121, 121, 121, 121, 407, 392, 1227, 1183,
/* 680 */ 1022, 1540, 1183, 1184, 1185, 1523, 149, 1307, 1307, 306,
/* 690 */ 555, 151, 1546, 361, 5, 564, 6, 3, 1035, 1542,
/* 700 */ 122, 123, 1207, 1207, 1041, 113, 1044, 1034, 1034, 120,
/* 710 */ 120, 121, 121, 121, 121, 411, 505, 83, 71, 71,
/* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
/* 730 */ 442, 1183, 426, 428, 1183, 1183, 1184, 1185, 191, 261,
/* 740 */ 278, 358, 508, 353, 507, 248, 407, 455, 137, 1539,
/* 750 */ 1006, 349, 363, 472, 1539, 302, 1228, 405, 281, 119,
/* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442,
/* 770 */ 122, 123, 1207, 1207, 1041, 113, 1044, 1034, 1034, 120,
/* 780 */ 120, 121, 121, 121, 121, 407, 452, 1183, 1184, 1185,
/* 790 */ 1183, 1184, 1185, 275, 275, 269, 269, 489, 483, 1525,
/* 800 */ 148, 363, 480, 564, 306, 555, 561, 489, 561, 122,
/* 810 */ 123, 1207, 1207, 1041, 113, 1044, 1034, 1034, 120, 120,
/* 820 */ 121, 121, 121, 121, 564, 886, 13, 13, 293, 119,
/* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442,
/* 840 */ 1183, 420, 1316, 564, 98, 417, 199, 13, 13, 150,
/* 850 */ 306, 555, 1312, 322, 386, 407, 506, 478, 562, 400,
/* 860 */ 920, 920, 425, 1539, 887, 292, 71, 71, 119, 119,
/* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 122,
/* 880 */ 123, 1207, 1207, 1041, 113, 1044, 1034, 1034, 120, 120,
/* 890 */ 121, 121, 121, 121, 564, 1149, 1183, 1184, 1185, 407,
/* 900 */ 275, 275, 451, 303, 1089, 1089, 486, 448, 1149, 276,
/* 910 */ 276, 1149, 1539, 561, 319, 286, 321, 71, 71, 429,
/* 920 */ 451, 450, 561, 952, 101, 1207, 1207, 1041, 113, 1044,
/* 930 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 119, 119,
/* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 1105,
/* 950 */ 1183, 1547, 564, 12, 437, 6, 329, 564, 834, 835,
/* 960 */ 836, 1629, 393, 547, 1106, 246, 245, 244, 1545, 1258,
/* 970 */ 413, 1521, 6, 1086, 310, 71, 71, 1086, 564, 1107,
/* 980 */ 13, 13, 119, 119, 119, 119, 118, 118, 117, 117,
/* 990 */ 117, 116, 442, 451, 104, 427, 537, 320, 275, 275,
/* 1000 */ 906, 13, 13, 520, 1482, 1105, 1183, 1184, 1185, 484,
/* 1010 */ 907, 561, 546, 564, 407, 536, 295, 478, 253, 200,
/* 1020 */ 1106, 548, 1482, 1484, 1160, 1409, 16, 16, 126, 557,
/* 1030 */ 413, 479, 311, 951, 407, 1107, 71, 71, 122, 123,
/* 1040 */ 1207, 1207, 1041, 113, 1044, 1034, 1034, 120, 120, 121,
/* 1050 */ 121, 121, 121, 1204, 407, 544, 552, 314, 122, 123,
/* 1060 */ 1207, 1207, 1041, 113, 1044, 1034, 1034, 120, 120, 121,
/* 1070 */ 121, 121, 121, 441, 144, 1160, 468, 146, 122, 111,
/* 1080 */ 1207, 1207, 1041, 113, 1044, 1034, 1034, 120, 120, 121,
/* 1090 */ 121, 121, 121, 247, 12, 1482, 422, 119, 119, 119,
/* 1100 */ 119, 118, 118, 117, 117, 117, 116, 442, 1183, 564,
/* 1110 */ 1204, 207, 404, 403, 858, 950, 294, 119, 119, 119,
/* 1120 */ 119, 118, 118, 117, 117, 117, 116, 442, 564, 30,
/* 1130 */ 564, 1409, 55, 55, 1599, 564, 895, 119, 119, 119,
/* 1140 */ 119, 118, 118, 117, 117, 117, 116, 442, 510, 1409,
/* 1150 */ 1409, 56, 56, 15, 15, 439, 438, 407, 13, 13,
/* 1160 */ 31, 1187, 412, 1211, 1183, 1184, 1185, 196, 1213, 306,
/* 1170 */ 555, 858, 462, 193, 926, 564, 1212, 489, 361, 925,
/* 1180 */ 1183, 564, 123, 1207, 1207, 1041, 113, 1044, 1034, 1034,
/* 1190 */ 120, 120, 121, 121, 121, 121, 1544, 1149, 43, 43,
/* 1200 */ 6, 1214, 423, 1214, 13, 13, 564, 219, 538, 494,
/* 1210 */ 1149, 108, 556, 1149, 4, 392, 1127, 434, 1187, 194,
/* 1220 */ 424, 485, 337, 1315, 414, 171, 1253, 1321, 559, 57,
/* 1230 */ 57, 564, 950, 564, 224, 247, 1183, 1184, 1185, 561,
/* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
/* 1250 */ 442, 443, 564, 517, 13, 13, 44, 44, 275, 275,
/* 1260 */ 1409, 275, 275, 553, 1353, 529, 213, 549, 456, 543,
/* 1270 */ 465, 561, 564, 137, 561, 58, 58, 469, 405, 1222,
/* 1280 */ 405, 274, 217, 108, 556, 110, 4, 405, 275, 275,
/* 1290 */ 564, 1352, 1021, 564, 1228, 59, 59, 523, 106, 106,
/* 1300 */ 559, 561, 275, 275, 412, 107, 457, 443, 566, 565,
/* 1310 */ 564, 8, 1011, 60, 60, 561, 61, 61, 564, 965,
/* 1320 */ 349, 926, 305, 443, 84, 204, 925, 966, 564, 306,
/* 1330 */ 555, 435, 405, 62, 62, 553, 476, 105, 564, 103,
/* 1340 */ 464, 45, 45, 1203, 1011, 1011, 1013, 1014, 27, 533,
/* 1350 */ 564, 46, 46, 453, 532, 1572, 1171, 445, 1528, 564,
/* 1360 */ 279, 47, 47, 327, 1021, 390, 390, 389, 264, 387,
/* 1370 */ 106, 106, 843, 49, 49, 108, 556, 107, 4, 443,
/* 1380 */ 566, 565, 50, 50, 1011, 225, 564, 313, 564, 96,
/* 1390 */ 564, 228, 559, 524, 147, 312, 38, 1123, 564, 394,
/* 1400 */ 466, 328, 280, 98, 544, 564, 17, 564, 323, 63,
/* 1410 */ 63, 64, 64, 65, 65, 443, 1011, 1011, 1013, 1014,
/* 1420 */ 27, 14, 14, 289, 564, 227, 564, 553, 66, 66,
/* 1430 */ 128, 128, 477, 162, 564, 309, 135, 564, 1003, 277,
/* 1440 */ 252, 533, 564, 1501, 564, 418, 534, 67, 67, 52,
/* 1450 */ 52, 564, 1287, 226, 564, 1500, 1021, 68, 68, 208,
/* 1460 */ 69, 69, 106, 106, 1286, 53, 53, 157, 157, 107,
/* 1470 */ 873, 443, 566, 565, 158, 158, 1011, 76, 76, 564,
/* 1480 */ 357, 564, 108, 556, 471, 4, 252, 408, 885, 884,
/* 1490 */ 356, 564, 306, 555, 564, 473, 564, 252, 481, 559,
/* 1500 */ 564, 334, 54, 54, 72, 72, 564, 230, 1011, 1011,
/* 1510 */ 1013, 1014, 27, 564, 129, 129, 449, 73, 73, 130,
/* 1520 */ 130, 564, 443, 131, 131, 519, 564, 873, 564, 127,
/* 1530 */ 127, 333, 1071, 98, 553, 1349, 156, 156, 564, 495,
/* 1540 */ 347, 249, 98, 338, 155, 155, 892, 893, 533, 136,
/* 1550 */ 136, 134, 134, 532, 341, 1171, 445, 1587, 564, 279,
/* 1560 */ 343, 132, 132, 1021, 390, 390, 389, 264, 387, 106,
/* 1570 */ 106, 843, 564, 1067, 564, 249, 107, 564, 443, 566,
/* 1580 */ 565, 133, 133, 1011, 225, 1015, 313, 108, 556, 1071,
/* 1590 */ 4, 345, 968, 969, 312, 75, 75, 77, 77, 1300,
/* 1600 */ 74, 74, 564, 1132, 559, 564, 108, 556, 959, 4,
/* 1610 */ 252, 923, 1083, 110, 1083, 1011, 1011, 1013, 1014, 27,
/* 1620 */ 1082, 1285, 1082, 559, 227, 42, 42, 443, 48, 48,
/* 1630 */ 1284, 856, 162, 145, 924, 135, 110, 352, 362, 553,
/* 1640 */ 1340, 1361, 1015, 1408, 1336, 301, 443, 1561, 1347, 550,
/* 1650 */ 1414, 551, 226, 202, 1265, 1333, 1256, 1244, 553, 1243,
/* 1660 */ 490, 1245, 1580, 267, 11, 391, 210, 223, 1021, 1390,
/* 1670 */ 1395, 282, 365, 367, 106, 106, 930, 369, 454, 285,
/* 1680 */ 1383, 107, 325, 443, 566, 565, 408, 1021, 1011, 326,
/* 1690 */ 475, 306, 555, 106, 106, 100, 556, 500, 4, 1400,
/* 1700 */ 107, 1399, 443, 566, 565, 398, 1283, 1011, 214, 355,
/* 1710 */ 1473, 290, 559, 1472, 1583, 449, 554, 371, 331, 197,
/* 1720 */ 1011, 1011, 1013, 1014, 27, 198, 209, 385, 1222, 173,
/* 1730 */ 221, 256, 1520, 1518, 1219, 443, 79, 416, 206, 1011,
/* 1740 */ 1011, 1013, 1014, 27, 83, 279, 182, 553, 82, 167,
/* 1750 */ 390, 390, 389, 264, 387, 35, 1396, 843, 1478, 459,
/* 1760 */ 175, 177, 460, 493, 178, 179, 180, 233, 96, 396,
/* 1770 */ 225, 1402, 313, 1401, 36, 1404, 1021, 467, 186, 482,
/* 1780 */ 312, 399, 106, 106, 237, 1467, 89, 1489, 488, 107,
/* 1790 */ 239, 443, 566, 565, 268, 336, 1011, 190, 491, 340,
/* 1800 */ 240, 401, 1246, 241, 509, 1294, 430, 1303, 91, 877,
/* 1810 */ 227, 215, 1566, 1302, 1301, 1273, 1598, 432, 162, 518,
/* 1820 */ 1272, 135, 1597, 354, 402, 433, 1271, 1596, 1011, 1011,
/* 1830 */ 1013, 1014, 27, 1293, 299, 360, 300, 525, 226, 95,
/* 1840 */ 254, 255, 1344, 364, 436, 125, 544, 1552, 10, 1453,
/* 1850 */ 379, 1551, 102, 304, 97, 528, 34, 568, 1177, 263,
/* 1860 */ 265, 266, 569, 1241, 1236, 172, 409, 410, 159, 383,
/* 1870 */ 377, 366, 408, 1345, 1343, 368, 370, 306, 555, 1342,
/* 1880 */ 1326, 1325, 1368, 201, 384, 1367, 1505, 1506, 160, 1504,
/* 1890 */ 1503, 142, 161, 211, 212, 78, 830, 444, 203, 308,
/* 1900 */ 297, 449, 222, 1081, 139, 1079, 316, 174, 163, 1203,
/* 1910 */ 229, 176, 232, 909, 324, 1095, 164, 181, 165, 419,
/* 1920 */ 421, 183, 85, 86, 87, 88, 166, 1098, 235, 234,
/* 1930 */ 1094, 152, 18, 236, 335, 1087, 252, 1216, 487, 238,
/* 1940 */ 37, 187, 188, 845, 492, 356, 242, 348, 496, 189,
/* 1950 */ 90, 93, 19, 20, 168, 875, 501, 351, 92, 504,
/* 1960 */ 888, 153, 511, 1133, 1165, 154, 298, 1047, 94, 1134,
/* 1970 */ 39, 958, 216, 271, 273, 192, 953, 110, 1151, 251,
/* 1980 */ 1155, 21, 1159, 22, 1158, 1139, 1153, 33, 23, 24,
/* 1990 */ 540, 25, 195, 98, 26, 1062, 1048, 1046, 1050, 1104,
/* 2000 */ 7, 1103, 257, 258, 1051, 28, 40, 560, 1016, 857,
/* 2010 */ 109, 29, 919, 138, 259, 260, 170, 1589, 388, 1588,
/* 2020 */ 1173, 1172,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 192, 273, 274, 275, 192, 192, 273, 274, 275, 192,
/* 10 */ 218, 215, 192, 218, 192, 212, 234, 235, 205, 19,
/* 20 */ 11, 192, 294, 215, 216, 203, 192, 203, 209, 210,
/* 30 */ 211, 31, 215, 216, 205, 215, 216, 215, 216, 39,
/* 40 */ 227, 215, 229, 43, 44, 45, 46, 47, 48, 49,
/* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 19,
/* 60 */ 238, 239, 238, 239, 215, 273, 274, 275, 273, 274,
/* 70 */ 275, 237, 21, 251, 252, 251, 273, 274, 275, 255,
/* 80 */ 256, 215, 216, 43, 44, 45, 46, 47, 48, 49,
/* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 209, 210,
/* 100 */ 211, 76, 102, 103, 104, 105, 106, 107, 108, 109,
/* 110 */ 110, 111, 112, 59, 89, 111, 112, 92, 252, 307,
/* 120 */ 308, 313, 314, 25, 312, 192, 86, 261, 88, 19,
/* 130 */ 313, 80, 315, 313, 314, 25, 127, 128, 54, 55,
/* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109,
/* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
/* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 115,
/* 170 */ 116, 117, 118, 122, 192, 121, 122, 123, 202, 69,
/* 180 */ 204, 22, 23, 16, 25, 131, 102, 103, 104, 105,
/* 190 */ 106, 107, 108, 109, 110, 111, 112, 215, 216, 19,
/* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112,
/* 210 */ 192, 160, 102, 103, 104, 105, 106, 107, 108, 109,
/* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
/* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 141,
/* 240 */ 307, 308, 272, 24, 77, 312, 79, 67, 102, 103,
/* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 277,
/* 260 */ 101, 112, 43, 44, 45, 46, 47, 48, 49, 50,
/* 270 */ 51, 52, 53, 54, 55, 56, 57, 26, 127, 128,
/* 280 */ 310, 311, 102, 103, 104, 105, 106, 107, 108, 109,
/* 290 */ 110, 111, 112, 184, 185, 186, 187, 188, 189, 186,
/* 300 */ 187, 188, 189, 194, 76, 196, 192, 194, 19, 196,
/* 310 */ 59, 25, 203, 192, 59, 87, 203, 89, 164, 165,
/* 320 */ 92, 102, 103, 104, 105, 106, 107, 108, 109, 110,
/* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
/* 340 */ 51, 52, 53, 54, 55, 56, 57, 238, 239, 73,
/* 350 */ 192, 238, 239, 22, 23, 100, 25, 81, 237, 229,
/* 360 */ 251, 23, 204, 25, 251, 272, 115, 116, 117, 214,
/* 370 */ 115, 116, 144, 192, 265, 120, 262, 222, 265, 102,
/* 380 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
/* 390 */ 192, 102, 103, 104, 105, 106, 107, 108, 109, 110,
/* 400 */ 111, 112, 126, 310, 311, 192, 297, 152, 153, 154,
/* 410 */ 297, 125, 192, 137, 138, 19, 295, 100, 192, 23,
/* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 215, 216,
/* 430 */ 106, 107, 101, 116, 192, 215, 216, 120, 149, 43,
/* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
/* 450 */ 54, 55, 56, 57, 222, 117, 224, 59, 19, 187,
/* 460 */ 59, 189, 23, 282, 232, 252, 194, 192, 196, 152,
/* 470 */ 153, 154, 252, 72, 261, 203, 152, 248, 154, 250,
/* 480 */ 142, 261, 43, 44, 45, 46, 47, 48, 49, 50,
/* 490 */ 51, 52, 53, 54, 55, 56, 57, 192, 102, 103,
/* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 267,
/* 510 */ 238, 239, 237, 115, 116, 117, 115, 116, 117, 192,
/* 520 */ 59, 118, 192, 251, 121, 122, 123, 73, 19, 192,
/* 530 */ 59, 192, 23, 72, 131, 308, 22, 265, 22, 312,
/* 540 */ 24, 102, 103, 104, 105, 106, 107, 108, 109, 110,
/* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
/* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 192, 297,
/* 570 */ 192, 23, 267, 59, 203, 59, 115, 116, 117, 108,
/* 580 */ 126, 127, 128, 192, 192, 192, 115, 116, 117, 262,
/* 590 */ 59, 43, 44, 45, 46, 47, 48, 49, 50, 51,
/* 600 */ 52, 53, 54, 55, 56, 57, 267, 215, 216, 238,
/* 610 */ 239, 102, 103, 104, 105, 106, 107, 108, 109, 110,
/* 620 */ 111, 112, 251, 45, 46, 47, 59, 49, 291, 115,
/* 630 */ 116, 117, 116, 81, 192, 305, 306, 19, 192, 268,
/* 640 */ 19, 23, 22, 192, 252, 24, 115, 116, 117, 192,
/* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
/* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51,
/* 670 */ 52, 53, 54, 55, 56, 57, 19, 22, 23, 59,
/* 680 */ 23, 303, 115, 116, 117, 192, 240, 234, 235, 137,
/* 690 */ 138, 240, 308, 192, 22, 192, 312, 22, 120, 306,
/* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
/* 710 */ 53, 54, 55, 56, 57, 197, 95, 150, 215, 216,
/* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
/* 730 */ 112, 59, 231, 112, 59, 115, 116, 117, 25, 118,
/* 740 */ 119, 120, 121, 122, 123, 124, 19, 243, 81, 303,
/* 750 */ 23, 130, 192, 192, 303, 252, 101, 253, 203, 102,
/* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
/* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
/* 780 */ 53, 54, 55, 56, 57, 19, 119, 115, 116, 117,
/* 790 */ 115, 116, 117, 238, 239, 238, 239, 192, 280, 192,
/* 800 */ 240, 192, 284, 192, 137, 138, 251, 192, 251, 43,
/* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
/* 820 */ 54, 55, 56, 57, 192, 35, 215, 216, 267, 102,
/* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
/* 840 */ 59, 230, 237, 192, 25, 192, 192, 215, 216, 240,
/* 850 */ 137, 138, 237, 16, 200, 19, 66, 192, 133, 205,
/* 860 */ 135, 136, 230, 303, 74, 203, 215, 216, 102, 103,
/* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43,
/* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
/* 890 */ 54, 55, 56, 57, 192, 76, 115, 116, 117, 19,
/* 900 */ 238, 239, 192, 252, 126, 127, 128, 192, 89, 238,
/* 910 */ 239, 92, 303, 251, 77, 262, 79, 215, 216, 129,
/* 920 */ 210, 211, 251, 142, 158, 45, 46, 47, 48, 49,
/* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103,
/* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 12,
/* 950 */ 59, 308, 192, 212, 252, 312, 291, 192, 7, 8,
/* 960 */ 9, 300, 301, 203, 27, 126, 127, 128, 308, 207,
/* 970 */ 208, 192, 312, 29, 192, 215, 216, 33, 192, 42,
/* 980 */ 215, 216, 102, 103, 104, 105, 106, 107, 108, 109,
/* 990 */ 110, 111, 112, 283, 158, 230, 66, 160, 238, 239,
/* 1000 */ 63, 215, 216, 192, 192, 12, 115, 116, 117, 65,
/* 1010 */ 73, 251, 252, 192, 19, 85, 230, 192, 24, 24,
/* 1020 */ 27, 261, 210, 211, 94, 192, 215, 216, 22, 207,
/* 1030 */ 208, 290, 192, 142, 19, 42, 215, 216, 43, 44,
/* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
/* 1050 */ 55, 56, 57, 59, 19, 144, 63, 192, 43, 44,
/* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
/* 1070 */ 55, 56, 57, 252, 163, 145, 114, 22, 43, 44,
/* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
/* 1090 */ 55, 56, 57, 45, 212, 283, 263, 102, 103, 104,
/* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192,
/* 1110 */ 116, 149, 106, 107, 59, 25, 291, 102, 103, 104,
/* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 192, 22,
/* 1130 */ 192, 192, 215, 216, 23, 192, 25, 102, 103, 104,
/* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 108, 192,
/* 1150 */ 192, 215, 216, 215, 216, 106, 107, 19, 215, 216,
/* 1160 */ 53, 59, 114, 114, 115, 116, 117, 285, 119, 137,
/* 1170 */ 138, 116, 290, 230, 134, 192, 127, 192, 192, 139,
/* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51,
/* 1190 */ 52, 53, 54, 55, 56, 57, 308, 76, 215, 216,
/* 1200 */ 312, 152, 263, 154, 215, 216, 192, 117, 87, 19,
/* 1210 */ 89, 19, 20, 92, 22, 22, 23, 231, 116, 230,
/* 1220 */ 263, 263, 237, 203, 298, 299, 203, 239, 36, 215,
/* 1230 */ 216, 192, 142, 192, 15, 45, 115, 116, 117, 251,
/* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
/* 1250 */ 112, 59, 192, 203, 215, 216, 215, 216, 238, 239,
/* 1260 */ 192, 238, 239, 71, 192, 144, 25, 203, 243, 230,
/* 1270 */ 243, 251, 192, 81, 251, 215, 216, 243, 253, 60,
/* 1280 */ 253, 255, 256, 19, 20, 25, 22, 253, 238, 239,
/* 1290 */ 192, 192, 100, 192, 101, 215, 216, 19, 106, 107,
/* 1300 */ 36, 251, 238, 239, 114, 113, 192, 115, 116, 117,
/* 1310 */ 192, 47, 120, 215, 216, 251, 215, 216, 192, 31,
/* 1320 */ 130, 134, 243, 59, 148, 149, 139, 39, 192, 137,
/* 1330 */ 138, 263, 253, 215, 216, 71, 19, 157, 192, 159,
/* 1340 */ 128, 215, 216, 25, 152, 153, 154, 155, 156, 85,
/* 1350 */ 192, 215, 216, 268, 90, 0, 1, 2, 192, 192,
/* 1360 */ 5, 215, 216, 151, 100, 10, 11, 12, 13, 14,
/* 1370 */ 106, 107, 17, 215, 216, 19, 20, 113, 22, 115,
/* 1380 */ 116, 117, 215, 216, 120, 30, 192, 32, 192, 148,
/* 1390 */ 192, 24, 36, 115, 22, 40, 24, 23, 192, 25,
/* 1400 */ 128, 23, 99, 25, 144, 192, 22, 192, 192, 215,
/* 1410 */ 216, 215, 216, 215, 216, 59, 152, 153, 154, 155,
/* 1420 */ 156, 215, 216, 151, 192, 70, 192, 71, 215, 216,
/* 1430 */ 215, 216, 115, 78, 192, 132, 81, 192, 23, 22,
/* 1440 */ 25, 85, 192, 192, 192, 61, 90, 215, 216, 215,
/* 1450 */ 216, 192, 225, 98, 192, 192, 100, 215, 216, 141,
/* 1460 */ 215, 216, 106, 107, 225, 215, 216, 215, 216, 113,
/* 1470 */ 59, 115, 116, 117, 215, 216, 120, 215, 216, 192,
/* 1480 */ 120, 192, 19, 20, 23, 22, 25, 132, 119, 120,
/* 1490 */ 130, 192, 137, 138, 192, 23, 192, 25, 192, 36,
/* 1500 */ 192, 192, 215, 216, 215, 216, 192, 140, 152, 153,
/* 1510 */ 154, 155, 156, 192, 215, 216, 161, 215, 216, 215,
/* 1520 */ 216, 192, 59, 215, 216, 19, 192, 116, 192, 215,
/* 1530 */ 216, 23, 59, 25, 71, 192, 215, 216, 192, 23,
/* 1540 */ 23, 25, 25, 192, 215, 216, 7, 8, 85, 215,
/* 1550 */ 216, 215, 216, 90, 192, 1, 2, 140, 192, 5,
/* 1560 */ 192, 215, 216, 100, 10, 11, 12, 13, 14, 106,
/* 1570 */ 107, 17, 192, 23, 192, 25, 113, 192, 115, 116,
/* 1580 */ 117, 215, 216, 120, 30, 59, 32, 19, 20, 116,
/* 1590 */ 22, 192, 83, 84, 40, 215, 216, 215, 216, 192,
/* 1600 */ 215, 216, 192, 97, 36, 192, 19, 20, 23, 22,
/* 1610 */ 25, 23, 152, 25, 154, 152, 153, 154, 155, 156,
/* 1620 */ 152, 225, 154, 36, 70, 215, 216, 59, 215, 216,
/* 1630 */ 192, 23, 78, 25, 23, 81, 25, 192, 192, 71,
/* 1640 */ 257, 192, 116, 192, 192, 254, 59, 317, 192, 192,
/* 1650 */ 192, 235, 98, 241, 192, 254, 192, 192, 71, 192,
/* 1660 */ 287, 192, 192, 286, 242, 190, 213, 296, 100, 266,
/* 1670 */ 270, 244, 254, 254, 106, 107, 108, 254, 258, 258,
/* 1680 */ 266, 113, 292, 115, 116, 117, 132, 100, 120, 245,
/* 1690 */ 292, 137, 138, 106, 107, 19, 20, 219, 22, 270,
/* 1700 */ 113, 270, 115, 116, 117, 270, 224, 120, 228, 218,
/* 1710 */ 218, 245, 36, 218, 195, 161, 279, 258, 244, 248,
/* 1720 */ 152, 153, 154, 155, 156, 248, 242, 244, 60, 296,
/* 1730 */ 296, 140, 199, 199, 38, 59, 293, 199, 149, 152,
/* 1740 */ 153, 154, 155, 156, 150, 5, 22, 71, 293, 43,
/* 1750 */ 10, 11, 12, 13, 14, 269, 271, 17, 282, 18,
/* 1760 */ 233, 236, 199, 18, 236, 236, 236, 198, 148, 245,
/* 1770 */ 30, 271, 32, 271, 269, 233, 100, 245, 233, 199,
/* 1780 */ 40, 245, 106, 107, 198, 245, 157, 289, 62, 113,
/* 1790 */ 198, 115, 116, 117, 199, 288, 120, 22, 220, 199,
/* 1800 */ 198, 220, 199, 198, 114, 226, 64, 217, 22, 125,
/* 1810 */ 70, 164, 311, 217, 217, 217, 223, 24, 78, 304,
/* 1820 */ 219, 81, 223, 217, 220, 112, 217, 217, 152, 153,
/* 1830 */ 154, 155, 156, 226, 281, 220, 281, 143, 98, 114,
/* 1840 */ 199, 91, 260, 259, 82, 147, 144, 316, 22, 276,
/* 1850 */ 199, 316, 157, 278, 146, 145, 25, 201, 13, 193,
/* 1860 */ 193, 6, 191, 191, 191, 299, 302, 302, 206, 246,
/* 1870 */ 248, 259, 132, 260, 260, 259, 259, 137, 138, 260,
/* 1880 */ 249, 249, 264, 247, 245, 264, 212, 212, 206, 212,
/* 1890 */ 212, 221, 206, 213, 213, 212, 4, 3, 22, 162,
/* 1900 */ 221, 161, 15, 23, 16, 23, 138, 150, 129, 25,
/* 1910 */ 24, 141, 143, 20, 16, 1, 129, 141, 129, 61,
/* 1920 */ 37, 150, 53, 53, 53, 53, 129, 115, 140, 34,
/* 1930 */ 1, 5, 22, 114, 160, 68, 25, 75, 41, 140,
/* 1940 */ 24, 68, 114, 20, 19, 130, 124, 23, 67, 22,
/* 1950 */ 22, 148, 22, 22, 37, 59, 67, 24, 22, 96,
/* 1960 */ 28, 23, 22, 97, 23, 23, 67, 23, 25, 23,
/* 1970 */ 22, 115, 140, 23, 23, 22, 142, 25, 88, 34,
/* 1980 */ 75, 34, 75, 34, 93, 23, 86, 22, 34, 34,
/* 1990 */ 24, 34, 25, 25, 34, 23, 23, 23, 23, 23,
/* 2000 */ 44, 23, 25, 22, 11, 22, 22, 25, 23, 23,
/* 2010 */ 22, 22, 134, 23, 140, 140, 25, 140, 15, 140,
/* 2020 */ 1, 1, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2030 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2040 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2050 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2060 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2070 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2080 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2090 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2100 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2110 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2120 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2130 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2140 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2150 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2160 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2170 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2180 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2190 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
/* 2200 */ 318, 318, 318, 318, 318, 318,
};
#define YY_SHIFT_COUNT (571)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (2020)
static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 1554, 1355, 1740, 1192, 1192, 552, 1264, 1356, 1463, 1587,
/* 10 */ 1587, 1587, 276, 0, 0, 180, 1015, 1587, 1587, 1587,
/* 20 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587,
/* 30 */ 1049, 1049, 1121, 1121, 54, 667, 552, 552, 552, 552,
/* 40 */ 552, 40, 110, 219, 289, 396, 439, 509, 548, 618,
/* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015,
/* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
/* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1568, 1587,
/* 80 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587,
/* 90 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587,
/* 100 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587,
/* 110 */ 1587, 1587, 1587, 1676, 1587, 1587, 1587, 1587, 1587, 1587,
/* 120 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 146, 84, 84,
/* 130 */ 84, 84, 84, 277, 315, 401, 97, 461, 251, 531,
/* 140 */ 531, 51, 1190, 531, 531, 324, 324, 531, 713, 713,
/* 150 */ 713, 713, 151, 154, 154, 4, 149, 2022, 2022, 621,
/* 160 */ 621, 621, 567, 398, 398, 398, 398, 937, 937, 228,
/* 170 */ 251, 159, 331, 531, 531, 531, 531, 531, 531, 531,
/* 180 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 531,
/* 190 */ 531, 531, 531, 819, 819, 531, 9, 25, 25, 1102,
/* 200 */ 1102, 911, 1032, 2022, 2022, 2022, 2022, 2022, 2022, 2022,
/* 210 */ 255, 317, 317, 514, 403, 620, 471, 672, 781, 891,
/* 220 */ 675, 531, 531, 531, 531, 531, 531, 531, 531, 531,
/* 230 */ 531, 454, 531, 531, 531, 531, 531, 531, 531, 531,
/* 240 */ 531, 531, 531, 531, 790, 790, 790, 531, 531, 531,
/* 250 */ 338, 531, 531, 531, 516, 930, 531, 531, 993, 531,
/* 260 */ 531, 531, 531, 531, 531, 531, 531, 778, 944, 725,
/* 270 */ 994, 994, 994, 994, 1090, 725, 725, 1040, 1006, 951,
/* 280 */ 1219, 962, 1176, 98, 1278, 1176, 1278, 1317, 1241, 962,
/* 290 */ 962, 1241, 962, 98, 1317, 286, 1111, 1048, 1288, 1288,
/* 300 */ 1288, 1278, 1260, 1260, 1180, 1318, 1187, 1372, 1668, 1668,
/* 310 */ 1591, 1591, 1696, 1696, 1591, 1594, 1589, 1724, 1706, 1741,
/* 320 */ 1741, 1741, 1741, 1591, 1745, 1620, 1589, 1589, 1620, 1724,
/* 330 */ 1706, 1620, 1706, 1620, 1591, 1745, 1629, 1726, 1591, 1745,
/* 340 */ 1775, 1591, 1745, 1591, 1745, 1775, 1690, 1690, 1690, 1742,
/* 350 */ 1786, 1786, 1775, 1690, 1684, 1690, 1742, 1690, 1690, 1647,
/* 360 */ 1793, 1713, 1713, 1775, 1694, 1725, 1694, 1725, 1694, 1725,
/* 370 */ 1694, 1725, 1591, 1750, 1750, 1762, 1762, 1698, 1702, 1826,
/* 380 */ 1591, 1695, 1698, 1708, 1710, 1620, 1831, 1845, 1845, 1855,
/* 390 */ 1855, 1855, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022,
/* 400 */ 2022, 2022, 2022, 2022, 2022, 2022, 2022, 578, 837, 655,
/* 410 */ 1193, 167, 839, 1055, 1374, 1303, 1107, 1367, 1212, 1272,
/* 420 */ 1378, 1384, 1415, 1461, 1472, 1508, 1516, 1517, 1411, 1369,
/* 430 */ 1539, 1360, 1506, 1473, 1550, 1585, 1509, 1588, 1460, 1468,
/* 440 */ 1608, 1611, 1526, 1417, 1892, 1894, 1876, 1737, 1887, 1888,
/* 450 */ 1880, 1882, 1768, 1757, 1779, 1884, 1884, 1886, 1770, 1893,
/* 460 */ 1769, 1898, 1914, 1776, 1787, 1884, 1789, 1858, 1883, 1884,
/* 470 */ 1771, 1869, 1870, 1871, 1872, 1797, 1812, 1895, 1788, 1929,
/* 480 */ 1926, 1910, 1819, 1774, 1867, 1911, 1873, 1862, 1897, 1799,
/* 490 */ 1828, 1916, 1923, 1925, 1815, 1822, 1927, 1881, 1928, 1930,
/* 500 */ 1924, 1931, 1889, 1896, 1933, 1863, 1932, 1936, 1899, 1917,
/* 510 */ 1938, 1803, 1940, 1941, 1942, 1944, 1943, 1946, 1948, 1866,
/* 520 */ 1832, 1950, 1951, 1856, 1945, 1953, 1834, 1952, 1947, 1949,
/* 530 */ 1954, 1955, 1890, 1905, 1900, 1956, 1907, 1891, 1957, 1962,
/* 540 */ 1965, 1966, 1967, 1968, 1960, 1972, 1952, 1973, 1974, 1975,
/* 550 */ 1976, 1977, 1978, 1981, 1993, 1983, 1984, 1985, 1986, 1988,
/* 560 */ 1989, 1982, 1878, 1874, 1875, 1877, 1879, 1991, 1990, 2003,
/* 570 */ 2019, 2020,
};
#define YY_REDUCE_COUNT (406)
#define YY_REDUCE_MIN (-272)
#define YY_REDUCE_MAX (1686)
static const short yy_reduce_ofst[] = {
/* 0 */ 109, 113, 272, 760, -178, -176, -192, -183, -180, -134,
/* 10 */ 213, 220, 371, -208, -205, -272, -197, 611, 632, 765,
/* 20 */ 786, 392, 943, 989, 503, 651, 1039, -18, 702, 821,
/* 30 */ 710, 812, -188, -67, -187, 555, 662, 1020, 1023, 1050,
/* 40 */ 1064, -267, -267, -267, -267, -267, -267, -267, -267, -267,
/* 50 */ -267, -267, -267, -267, -267, -267, -267, -267, -267, -267,
/* 60 */ -267, -267, -267, -267, -267, -267, -267, -267, -267, -267,
/* 70 */ -267, -267, -267, -267, -267, -267, -267, -267, 811, 917,
/* 80 */ 936, 938, 983, 1014, 1041, 1060, 1080, 1098, 1101, 1118,
/* 90 */ 1126, 1136, 1146, 1158, 1167, 1194, 1196, 1198, 1206, 1213,
/* 100 */ 1215, 1232, 1234, 1242, 1245, 1250, 1252, 1259, 1262, 1287,
/* 110 */ 1289, 1299, 1302, 1304, 1308, 1314, 1321, 1329, 1334, 1336,
/* 120 */ 1346, 1366, 1380, 1382, 1385, 1410, 1413, -267, -267, -267,
/* 130 */ -267, -267, -267, -267, -267, 446, -267, 451, -24, 121,
/* 140 */ 560, 518, 232, 609, 330, -181, -111, 654, 557, 671,
/* 150 */ 557, 671, 882, -30, 93, -267, -267, -267, -267, 155,
/* 160 */ 155, 155, 181, 242, 305, 339, 561, -218, 453, 227,
/* 170 */ 158, 661, 661, -171, 114, 327, 653, -166, 275, 605,
/* 180 */ 615, 337, 833, 665, 939, 957, 825, 958, 985, 501,
/* 190 */ 986, 378, 1068, 384, 643, 393, 741, 660, 888, 762,
/* 200 */ 822, 229, 988, 926, 504, 1025, 1027, 1034, 1026, 1079,
/* 210 */ -204, -174, -151, 18, 130, 198, 226, 376, 391, 442,
/* 220 */ 457, 493, 607, 715, 779, 782, 840, 865, 1072, 1099,
/* 230 */ 1114, 1085, 1166, 1216, 1251, 1263, 1306, 1309, 1343, 1351,
/* 240 */ 1362, 1368, 1399, 1407, 1227, 1239, 1396, 1438, 1445, 1446,
/* 250 */ 1383, 1449, 1451, 1452, 1391, 1330, 1456, 1457, 1416, 1458,
/* 260 */ 226, 1462, 1464, 1465, 1467, 1469, 1470, 1373, 1377, 1412,
/* 270 */ 1401, 1418, 1419, 1423, 1383, 1412, 1412, 1422, 1453, 1475,
/* 280 */ 1371, 1400, 1403, 1427, 1420, 1414, 1421, 1390, 1444, 1429,
/* 290 */ 1431, 1466, 1435, 1474, 1398, 1478, 1480, 1482, 1491, 1492,
/* 300 */ 1495, 1459, 1471, 1477, 1437, 1483, 1484, 1519, 1433, 1434,
/* 310 */ 1533, 1534, 1443, 1455, 1538, 1476, 1485, 1486, 1527, 1525,
/* 320 */ 1528, 1529, 1530, 1563, 1569, 1524, 1500, 1502, 1532, 1505,
/* 330 */ 1542, 1536, 1545, 1540, 1580, 1586, 1498, 1507, 1595, 1592,
/* 340 */ 1578, 1600, 1602, 1603, 1605, 1581, 1590, 1596, 1597, 1579,
/* 350 */ 1593, 1599, 1604, 1598, 1601, 1606, 1607, 1609, 1610, 1501,
/* 360 */ 1515, 1553, 1555, 1615, 1582, 1584, 1613, 1612, 1614, 1616,
/* 370 */ 1619, 1617, 1641, 1531, 1535, 1618, 1621, 1631, 1622, 1573,
/* 380 */ 1651, 1575, 1632, 1636, 1623, 1639, 1656, 1666, 1667, 1671,
/* 390 */ 1672, 1673, 1564, 1565, 1566, 1662, 1674, 1675, 1677, 1678,
/* 400 */ 1682, 1670, 1679, 1680, 1681, 1683, 1686,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 1633, 1633, 1633, 1462, 1230, 1341, 1230, 1230, 1230, 1462,
/* 10 */ 1462, 1462, 1230, 1371, 1371, 1515, 1263, 1230, 1230, 1230,
/* 20 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1461, 1230, 1230,
/* 30 */ 1230, 1230, 1550, 1550, 1230, 1230, 1230, 1230, 1230, 1230,
/* 40 */ 1230, 1230, 1380, 1230, 1387, 1230, 1230, 1230, 1230, 1230,
|
| ︙ | ︙ | |||
160678 160679 160680 160681 160682 160683 160684 |
59, /* DATABASE => ID */
59, /* DESC => ID */
59, /* DETACH => ID */
59, /* EACH => ID */
59, /* FAIL => ID */
0, /* OR => nothing */
0, /* AND => nothing */
| < > | 161294 161295 161296 161297 161298 161299 161300 161301 161302 161303 161304 161305 161306 161307 161308 161309 161310 161311 |
59, /* DATABASE => ID */
59, /* DESC => ID */
59, /* DETACH => ID */
59, /* EACH => ID */
59, /* FAIL => ID */
0, /* OR => nothing */
0, /* AND => nothing */
59, /* MATCH => ID */
59, /* LIKE_KW => ID */
0, /* BETWEEN => nothing */
0, /* IS => nothing */
0, /* IN => nothing */
0, /* ISNULL => nothing */
0, /* NOTNULL => nothing */
0, /* NE => nothing */
0, /* EQ => nothing */
0, /* GT => nothing */
0, /* LE => nothing */
|
| ︙ | ︙ | |||
160950 160951 160952 160953 160954 160955 160956 | /* 38 */ "DATABASE", /* 39 */ "DESC", /* 40 */ "DETACH", /* 41 */ "EACH", /* 42 */ "FAIL", /* 43 */ "OR", /* 44 */ "AND", | | | | | | 161566 161567 161568 161569 161570 161571 161572 161573 161574 161575 161576 161577 161578 161579 161580 161581 161582 161583 | /* 38 */ "DATABASE", /* 39 */ "DESC", /* 40 */ "DETACH", /* 41 */ "EACH", /* 42 */ "FAIL", /* 43 */ "OR", /* 44 */ "AND", /* 45 */ "MATCH", /* 46 */ "LIKE_KW", /* 47 */ "BETWEEN", /* 48 */ "IS", /* 49 */ "IN", /* 50 */ "ISNULL", /* 51 */ "NOTNULL", /* 52 */ "NE", /* 53 */ "EQ", /* 54 */ "GT", /* 55 */ "LE", |
| ︙ | ︙ | |||
169406 169407 169408 169409 169410 169411 169412 169413 169414 169415 169416 169417 169418 169419 |
if( limitId<0 || limitId>=SQLITE_N_LIMIT ){
return -1;
}
oldLimit = db->aLimit[limitId];
if( newLimit>=0 ){ /* IMP: R-52476-28732 */
if( newLimit>aHardLimit[limitId] ){
newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */
}
db->aLimit[limitId] = newLimit;
}
return oldLimit; /* IMP: R-53341-35419 */
}
/*
| > > | 170022 170023 170024 170025 170026 170027 170028 170029 170030 170031 170032 170033 170034 170035 170036 170037 |
if( limitId<0 || limitId>=SQLITE_N_LIMIT ){
return -1;
}
oldLimit = db->aLimit[limitId];
if( newLimit>=0 ){ /* IMP: R-52476-28732 */
if( newLimit>aHardLimit[limitId] ){
newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */
}else if( newLimit<1 && limitId==SQLITE_LIMIT_LENGTH ){
newLimit = 1;
}
db->aLimit[limitId] = newLimit;
}
return oldLimit; /* IMP: R-53341-35419 */
}
/*
|
| ︙ | ︙ | |||
170809 170810 170811 170812 170813 170814 170815 170816 |
**
** If onOff==0 and tnum>0 then reset the schema for all databases, causing
** the schema to be reparsed the next time it is needed. This has the
** effect of erasing all imposter tables.
*/
case SQLITE_TESTCTRL_IMPOSTER: {
sqlite3 *db = va_arg(ap, sqlite3*);
sqlite3_mutex_enter(db->mutex);
| > | > > | | | | > | 171427 171428 171429 171430 171431 171432 171433 171434 171435 171436 171437 171438 171439 171440 171441 171442 171443 171444 171445 171446 171447 171448 171449 171450 |
**
** If onOff==0 and tnum>0 then reset the schema for all databases, causing
** the schema to be reparsed the next time it is needed. This has the
** effect of erasing all imposter tables.
*/
case SQLITE_TESTCTRL_IMPOSTER: {
sqlite3 *db = va_arg(ap, sqlite3*);
int iDb;
sqlite3_mutex_enter(db->mutex);
iDb = sqlite3FindDbName(db, va_arg(ap,const char*));
if( iDb>=0 ){
db->init.iDb = iDb;
db->init.busy = db->init.imposterTable = va_arg(ap,int);
db->init.newTnum = va_arg(ap,int);
if( db->init.busy==0 && db->init.newTnum>0 ){
sqlite3ResetAllSchemasOfConnection(db);
}
}
sqlite3_mutex_leave(db->mutex);
break;
}
#if defined(YYCOVERAGE)
/* sqlite3_test_control(SQLITE_TESTCTRL_PARSER_COVERAGE, FILE *out)
|
| ︙ | ︙ | |||
170889 170890 170891 170892 170893 170894 170895 170896 170897 170898 170899 170900 170901 170902 |
case 0: *ptr = sqlite3SelectTrace; break;
case 1: sqlite3SelectTrace = *ptr; break;
case 2: *ptr = sqlite3WhereTrace; break;
case 3: sqlite3WhereTrace = *ptr; break;
}
break;
}
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
/* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
**
** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
** of the id-th tuning parameter to *piValue. If "id" is between -1
** and -SQLITE_NTUNE, then write the current value of the (-id)-th
| > > > > > > > > > > > > > > > > > > > > | 171511 171512 171513 171514 171515 171516 171517 171518 171519 171520 171521 171522 171523 171524 171525 171526 171527 171528 171529 171530 171531 171532 171533 171534 171535 171536 171537 171538 171539 171540 171541 171542 171543 171544 |
case 0: *ptr = sqlite3SelectTrace; break;
case 1: sqlite3SelectTrace = *ptr; break;
case 2: *ptr = sqlite3WhereTrace; break;
case 3: sqlite3WhereTrace = *ptr; break;
}
break;
}
/* sqlite3_test_control(SQLITE_TESTCTRL_LOGEST,
** double fIn, // Input value
** int *pLogEst, // sqlite3LogEstFromDouble(fIn)
** u64 *pInt, // sqlite3LogEstToInt(*pLogEst)
** int *pLogEst2 // sqlite3LogEst(*pInt)
** );
**
** Test access for the LogEst conversion routines.
*/
case SQLITE_TESTCTRL_LOGEST: {
double rIn = va_arg(ap, double);
LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
u64 iInt = sqlite3LogEstToInt(rLogEst);
va_arg(ap, int*)[0] = rLogEst;
va_arg(ap, u64*)[0] = iInt;
va_arg(ap, int*)[0] = sqlite3LogEst(iInt);
break;
}
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
/* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
**
** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
** of the id-th tuning parameter to *piValue. If "id" is between -1
** and -SQLITE_NTUNE, then write the current value of the (-id)-th
|
| ︙ | ︙ | |||
203300 203301 203302 203303 203304 203305 203306 | ** ** except that the "?" placeholders are replaced with literal values. ** ** If the expression cannot be created, NULL is returned. In this case, ** the caller has to use an OFFSET clause to extract only the required ** rows from the sourct table, just as it does for an RBU update operation. */ | | | 203942 203943 203944 203945 203946 203947 203948 203949 203950 203951 203952 203953 203954 203955 203956 |
**
** except that the "?" placeholders are replaced with literal values.
**
** If the expression cannot be created, NULL is returned. In this case,
** the caller has to use an OFFSET clause to extract only the required
** rows from the sourct table, just as it does for an RBU update operation.
*/
static char *rbuVacuumIndexStart(
sqlite3rbu *p, /* RBU handle */
RbuObjIter *pIter /* RBU iterator object */
){
char *zOrder = 0;
char *zLhs = 0;
char *zSelect = 0;
char *zVector = 0;
|
| ︙ | ︙ | |||
223725 223726 223727 223728 223729 223730 223731 |
**
** This function is a no-op if (*pRc) is not SQLITE_OK when it is called. If
** an error occurs, (*pRc) is set to an SQLite error code before returning.
*/
static void fts5StructureMakeWritable(int *pRc, Fts5Structure **pp){
Fts5Structure *p = *pp;
if( *pRc==SQLITE_OK && p->nRef>1 ){
| | | 224367 224368 224369 224370 224371 224372 224373 224374 224375 224376 224377 224378 224379 224380 224381 |
**
** This function is a no-op if (*pRc) is not SQLITE_OK when it is called. If
** an error occurs, (*pRc) is set to an SQLite error code before returning.
*/
static void fts5StructureMakeWritable(int *pRc, Fts5Structure **pp){
Fts5Structure *p = *pp;
if( *pRc==SQLITE_OK && p->nRef>1 ){
i64 nByte = sizeof(Fts5Structure)+(p->nLevel-1)*sizeof(Fts5StructureLevel);
Fts5Structure *pNew;
pNew = (Fts5Structure*)sqlite3Fts5MallocZero(pRc, nByte);
if( pNew ){
int i;
memcpy(pNew, p, nByte);
for(i=0; i<p->nLevel; i++) pNew->aLevel[i].aSeg = 0;
for(i=0; i<p->nLevel; i++){
|
| ︙ | ︙ | |||
224754 224755 224756 224757 224758 224759 224760 |
pIter->pLeaf = pNew;
pIter->iLeafOffset = pIter->iTermLeafOffset;
}
}else{
int iRowidOff;
iRowidOff = fts5LeafFirstRowidOff(pNew);
if( iRowidOff ){
| > > > | | > | 225396 225397 225398 225399 225400 225401 225402 225403 225404 225405 225406 225407 225408 225409 225410 225411 225412 225413 225414 225415 |
pIter->pLeaf = pNew;
pIter->iLeafOffset = pIter->iTermLeafOffset;
}
}else{
int iRowidOff;
iRowidOff = fts5LeafFirstRowidOff(pNew);
if( iRowidOff ){
if( iRowidOff>=pNew->szLeaf ){
p->rc = FTS5_CORRUPT;
}else{
pIter->pLeaf = pNew;
pIter->iLeafOffset = iRowidOff;
}
}
}
if( pIter->pLeaf ){
u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset];
pIter->iLeafOffset += fts5GetVarint(a, (u64*)&pIter->iRowid);
break;
|
| ︙ | ︙ | |||
232484 232485 232486 232487 232488 232489 232490 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
| | | 233130 233131 233132 233133 233134 233135 233136 233137 233138 233139 233140 233141 233142 233143 233144 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2021-12-09 20:06:18 633bfeeea2bccdd44126acf3f61ecca163c9d933bdc787a2c18a697dc9406882", -1, SQLITE_TRANSIENT);
}
/*
** Return true if zName is the extension on one of the shadow tables used
** by this module.
*/
static int fts5ShadowName(const char *zName){
|
| ︙ | ︙ | |||
236701 236702 236703 236704 236705 236706 236707 |
}
}else{
rc = sqlite3Fts5FlushToDisk(pFts5);
}
}
if( rc==SQLITE_OK ){
| | | 237347 237348 237349 237350 237351 237352 237353 237354 237355 237356 237357 237358 237359 237360 237361 |
}
}else{
rc = sqlite3Fts5FlushToDisk(pFts5);
}
}
if( rc==SQLITE_OK ){
i64 nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor);
pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);
}
if( pCsr ){
pCsr->pFts5 = pFts5;
pCsr->pStmt = pStmt;
pCsr->aCnt = (i64*)&pCsr[1];
|
| ︙ | ︙ |
Changes to src/sqlite3.h.
| ︙ | ︙ | |||
142 143 144 145 146 147 148 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.38.0" #define SQLITE_VERSION_NUMBER 3038000 #define SQLITE_SOURCE_ID "2021-12-09 20:06:18 633bfeeea2bccdd44126acf3f61ecca163c9d933bdc787a2c18a697dc9406882" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
7940 7941 7942 7943 7944 7945 7946 | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 #define SQLITE_TESTCTRL_SEEK_COUNT 30 #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 | > | | 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 #define SQLITE_TESTCTRL_SEEK_COUNT 30 #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 #define SQLITE_TESTCTRL_LOGEST 33 #define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */ /* ** CAPI3REF: SQL Keyword Checking ** ** These routines provide access to the set of SQL language keywords ** recognized by SQLite. Applications can uses these routines to determine ** whether or not a specific identifier needs to be escaped (for example, |
| ︙ | ︙ | |||
8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 | ** ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> ** <dd>^This is the number of times that the prepared statement has ** been run. A single "run" for the purposes of this counter is one ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. ** The counter is incremented on the first [sqlite3_step()] call of each ** cycle. ** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 #define SQLITE_STMTSTATUS_REPREPARE 5 #define SQLITE_STMTSTATUS_RUN 6 #define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of | > > > > > > > > > > > > | 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 | ** ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> ** <dd>^This is the number of times that the prepared statement has ** been run. A single "run" for the purposes of this counter is one ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. ** The counter is incremented on the first [sqlite3_step()] call of each ** cycle. ** ** [[SQLITE_STMTSTATUS_FILTER_MISS]] ** [[SQLITE_STMTSTATUS_FILTER HIT]] ** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br> ** SQLITE_STMTSTATUS_FILTER_MISS</dt> ** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join ** step was bypassed because a Bloom filter returned not-found. The ** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of ** times that the Bloom filter returned a find, and thus the join step ** had to be processed as normal. ** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 #define SQLITE_STMTSTATUS_REPREPARE 5 #define SQLITE_STMTSTATUS_RUN 6 #define SQLITE_STMTSTATUS_FILTER_MISS 7 #define SQLITE_STMTSTATUS_FILTER_HIT 8 #define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of |
| ︙ | ︙ |