mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Update the generate_series() table-valued function to make use of the new
SQLITE_CONSTRAINT return from xBestIndex. FossilOrigin-Name: 4372ad644dda5a1fa46b6b6070092320c835439b41f598cbc041e9deef786988
This commit is contained in:
@ -313,44 +313,44 @@ static int seriesBestIndex(
|
|||||||
sqlite3_vtab *tab,
|
sqlite3_vtab *tab,
|
||||||
sqlite3_index_info *pIdxInfo
|
sqlite3_index_info *pIdxInfo
|
||||||
){
|
){
|
||||||
int i; /* Loop over constraints */
|
int i, j; /* Loop over constraints */
|
||||||
int idxNum = 0; /* The query plan bitmask */
|
int idxNum = 0; /* The query plan bitmask */
|
||||||
int startIdx = -1; /* Index of the start= constraint, or -1 if none */
|
int unusableMask = 0; /* Mask of unusable constraints */
|
||||||
int stopIdx = -1; /* Index of the stop= constraint, or -1 if none */
|
|
||||||
int stepIdx = -1; /* Index of the step= constraint, or -1 if none */
|
|
||||||
int nArg = 0; /* Number of arguments that seriesFilter() expects */
|
int nArg = 0; /* Number of arguments that seriesFilter() expects */
|
||||||
|
int aIdx[3]; /* Constraints on start, stop, and step */
|
||||||
const struct sqlite3_index_constraint *pConstraint;
|
const struct sqlite3_index_constraint *pConstraint;
|
||||||
|
|
||||||
|
/* This implementation assumes that the start, stop, and step columns
|
||||||
|
** are the last three columns in the virtual table. */
|
||||||
|
assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 );
|
||||||
|
assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 );
|
||||||
|
aIdx[0] = aIdx[1] = aIdx[2] = -1;
|
||||||
pConstraint = pIdxInfo->aConstraint;
|
pConstraint = pIdxInfo->aConstraint;
|
||||||
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
|
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
|
||||||
if( pConstraint->usable==0 ) continue;
|
int iCol; /* 0 for start, 1 for stop, 2 for step */
|
||||||
if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
|
int iMask; /* bitmask for those column */
|
||||||
switch( pConstraint->iColumn ){
|
if( pConstraint->iColumn<SERIES_COLUMN_START ) continue;
|
||||||
case SERIES_COLUMN_START:
|
iCol = pConstraint->iColumn - SERIES_COLUMN_START;
|
||||||
startIdx = i;
|
iMask = 1 << iCol;
|
||||||
idxNum |= 1;
|
if( pConstraint->usable==0 ){
|
||||||
break;
|
unusableMask |= iMask;
|
||||||
case SERIES_COLUMN_STOP:
|
continue;
|
||||||
stopIdx = i;
|
}else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
|
||||||
idxNum |= 2;
|
idxNum |= iMask;
|
||||||
break;
|
aIdx[iCol] = i;
|
||||||
case SERIES_COLUMN_STEP:
|
|
||||||
stepIdx = i;
|
|
||||||
idxNum |= 4;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( startIdx>=0 ){
|
for(i=0; i<3; i++){
|
||||||
pIdxInfo->aConstraintUsage[startIdx].argvIndex = ++nArg;
|
if( (j = aIdx[i])>=0 ){
|
||||||
pIdxInfo->aConstraintUsage[startIdx].omit= !SQLITE_SERIES_CONSTRAINT_VERIFY;
|
pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg;
|
||||||
|
pIdxInfo->aConstraintUsage[j].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( stopIdx>=0 ){
|
if( (unusableMask & ~idxNum)!=0 ){
|
||||||
pIdxInfo->aConstraintUsage[stopIdx].argvIndex = ++nArg;
|
/* The start, stop, and step columns are inputs. Therefore if there
|
||||||
pIdxInfo->aConstraintUsage[stopIdx].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
|
** are unusable constraints on any of start, stop, or step then
|
||||||
}
|
** this plan is unusable */
|
||||||
if( stepIdx>=0 ){
|
return SQLITE_CONSTRAINT;
|
||||||
pIdxInfo->aConstraintUsage[stepIdx].argvIndex = ++nArg;
|
|
||||||
pIdxInfo->aConstraintUsage[stepIdx].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
|
|
||||||
}
|
}
|
||||||
if( (idxNum & 3)==3 ){
|
if( (idxNum & 3)==3 ){
|
||||||
/* Both start= and stop= boundaries are available. This is the
|
/* Both start= and stop= boundaries are available. This is the
|
||||||
@ -365,7 +365,6 @@ static int seriesBestIndex(
|
|||||||
/* If either boundary is missing, we have to generate a huge span
|
/* If either boundary is missing, we have to generate a huge span
|
||||||
** of numbers. Make this case very expensive so that the query
|
** of numbers. Make this case very expensive so that the query
|
||||||
** planner will work hard to avoid it. */
|
** planner will work hard to avoid it. */
|
||||||
pIdxInfo->estimatedCost = (double)2147483647;
|
|
||||||
pIdxInfo->estimatedRows = 2147483647;
|
pIdxInfo->estimatedRows = 2147483647;
|
||||||
}
|
}
|
||||||
pIdxInfo->idxNum = idxNum;
|
pIdxInfo->idxNum = idxNum;
|
||||||
|
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
|||||||
C In\sorder\sto\savoid\sexporting\sa\ssymbol,\suse\sa\smacro\sinstead\sof\sa\sfunction\sto\nreplace\ssqlite3_complete()\sin\sthe\sshell\scode\swhen\sSQLITE_OMIT_COMPLETE\sis\ndefined.
|
C Update\sthe\sgenerate_series()\stable-valued\sfunction\sto\smake\suse\sof\sthe\snew\nSQLITE_CONSTRAINT\sreturn\sfrom\sxBestIndex.
|
||||||
D 2018-11-16T14:36:42.078
|
D 2018-11-16T15:08:31.923
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F Makefile.in b730006b54c990461d864c5387f2e6f13aadb0236804555fb010ed6865a5f058
|
F Makefile.in b730006b54c990461d864c5387f2e6f13aadb0236804555fb010ed6865a5f058
|
||||||
@ -296,7 +296,7 @@ F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
|
|||||||
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
|
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
|
||||||
F ext/misc/rot13.c 540a169cb0d74f15522a8930b0cccdcb37a4fd071d219a5a083a319fc6e8db77
|
F ext/misc/rot13.c 540a169cb0d74f15522a8930b0cccdcb37a4fd071d219a5a083a319fc6e8db77
|
||||||
F ext/misc/scrub.c db9fff56fed322ca587d73727c6021b11ae79ce3f31b389e1d82891d144f22ad
|
F ext/misc/scrub.c db9fff56fed322ca587d73727c6021b11ae79ce3f31b389e1d82891d144f22ad
|
||||||
F ext/misc/series.c c7197db304f7009b08d6459a9de02e7f51ad0e1a3fdacbc1ebf5252a9a346959
|
F ext/misc/series.c 2141a38d14b9b3256f372cdfe3bec8e611115815f3c7f7afb131cf1d68d78d91
|
||||||
F ext/misc/sha1.c df0a667211baa2c0612d8486acbf6331b9f8633fd4d605c17c7cccd26d59c6bd
|
F ext/misc/sha1.c df0a667211baa2c0612d8486acbf6331b9f8633fd4d605c17c7cccd26d59c6bd
|
||||||
F ext/misc/shathree.c 22ba7ca84a433d6466a7d05dcc876910b435a715da8cc462517db9351412b8c8
|
F ext/misc/shathree.c 22ba7ca84a433d6466a7d05dcc876910b435a715da8cc462517db9351412b8c8
|
||||||
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
||||||
@ -591,7 +591,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
|||||||
F src/wal.c 3f4f653daf234fe713edbcbca3fec2350417d159d28801feabc702a22c4e213f
|
F src/wal.c 3f4f653daf234fe713edbcbca3fec2350417d159d28801feabc702a22c4e213f
|
||||||
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
|
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
|
||||||
F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
|
F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
|
||||||
F src/where.c 23f955de6db320fa5afcbe569687e649e5c9be1380c742fe7c5e9939e18cbcbe
|
F src/where.c 053e5004a608195cf0345441a46274d318966b34b9c7c0033e6e1d8bc0833307
|
||||||
F src/whereInt.h f125f29fca80890768e0b2caa14f95db74b2dacd3a122a168f97aa7b64d6968f
|
F src/whereInt.h f125f29fca80890768e0b2caa14f95db74b2dacd3a122a168f97aa7b64d6968f
|
||||||
F src/wherecode.c c45f03aefc2266b990df0fc4d7acc4e27f56f881f4fc0fc355b7cbc4d7189da5
|
F src/wherecode.c c45f03aefc2266b990df0fc4d7acc4e27f56f881f4fc0fc355b7cbc4d7189da5
|
||||||
F src/whereexpr.c 491f0894ad9903750cdecb7894437a0cabdffdd88f574d2b1c9ac85d14fe4b9c
|
F src/whereexpr.c 491f0894ad9903750cdecb7894437a0cabdffdd88f574d2b1c9ac85d14fe4b9c
|
||||||
@ -1778,7 +1778,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 684013cef6bfcfd920a4aec645df9f5d41ace8b34e75fca61759c1b4f82cc89e
|
P d584a0cb512815945ef06ee3b5ebadbf2a543b008487f6d098e1e8ab79f61d2d
|
||||||
R 8193ecf2adbc9160819a0d27025d0547
|
R a216ab0261496ebce0502a9a5ca8d671
|
||||||
U dan
|
U drh
|
||||||
Z 06b4c40afe20fcd6ade0db726d80955d
|
Z 184170d79003d8b9b10ccf4765c179a2
|
||||||
|
@ -1 +1 @@
|
|||||||
d584a0cb512815945ef06ee3b5ebadbf2a543b008487f6d098e1e8ab79f61d2d
|
4372ad644dda5a1fa46b6b6070092320c835439b41f598cbc041e9deef786988
|
@ -3140,6 +3140,7 @@ static int whereLoopAddVirtualOne(
|
|||||||
** that the particular combination of parameters provided is unusable.
|
** that the particular combination of parameters provided is unusable.
|
||||||
** Make no entries in the loop table.
|
** Make no entries in the loop table.
|
||||||
*/
|
*/
|
||||||
|
WHERETRACE(0xffff, (" ^^^^--- non-viable plan rejected!\n"));
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
Reference in New Issue
Block a user