New assert() statements to validate the parameters to
sqlite3BtreeCursorHint(). Fix a problem with the construction of those parameters discovered by [forum:/forumpost/0b53708c95|forum post 0b53708c95]. FossilOrigin-Name: 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d
This commit is contained in:
parent
8346f8dacc
commit
ed36917835
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C Sync\sthe\svt02.c\stest\svirtual\stable\swith\sTH3,\sin\sorder\sto\spull\sin\sthe\sfix\nfor\slong\sdelays\swhen\sthere\sare\shuge\sOFFSET\svalues.
|
||||
D 2023-04-10T13:20:51.922
|
||||
C New\sassert()\sstatements\sto\svalidate\sthe\sparameters\sto\nsqlite3BtreeCursorHint().\s\sFix\sa\sproblem\swith\sthe\sconstruction\sof\sthose\nparameters\sdiscovered\sby\n[forum:/forumpost/0b53708c95|forum\spost\s0b53708c95].
|
||||
D 2023-04-10T18:44:00.864
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -564,7 +564,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
|
||||
F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7
|
||||
F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d
|
||||
F src/btmutex.c 6ffb0a22c19e2f9110be0964d0731d2ef1c67b5f7fabfbaeb7b9dabc4b7740ca
|
||||
F src/btree.c 895a4ab3a5aeb7db9ed894bb3fd1e2eee4422e95fa6ca3d3d0e803bc0080ec55
|
||||
F src/btree.c af379d801906f21dc18b534fc250a479f56045a450d8d5859ba2f57fd9eefcef
|
||||
F src/btree.h aa354b9bad4120af71e214666b35132712b8f2ec11869cb2315c52c81fad45cc
|
||||
F src/btreeInt.h a3268a60cbc91f578001f44ba40aae9c1b8aecbb0d2c095dd7fc54b0872ea4b8
|
||||
F src/build.c 8357d6ca9a8c9afc297c431df28bc2af407b47f3ef2311875276c944b30c4d54
|
||||
@ -630,7 +630,7 @@ F src/shell.c.in 80f7c4c1bdabc9dab416b59287458044c01df97035d626ea57ffeabbb289bdc
|
||||
F src/sqlite.h.in 4fff9c6cc5d4cbba9532a668112efb6dc469c425e1a2196664d7c07d508363ef
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h da473ce2b3d0ae407a6300c4a164589b9a6bfdbec9462688a8593ff16f3bb6e4
|
||||
F src/sqliteInt.h a605bcdaf9083655e848b54d55c053000ed4ab8325cca8696c41585ba8ac05fd
|
||||
F src/sqliteInt.h bf15f7db635d2e64a227bbf86845bc19755dbd932021a6461d6dd15b0da2cfd3
|
||||
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
|
||||
F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749
|
||||
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
|
||||
@ -696,10 +696,10 @@ F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
|
||||
F src/util.c 3ff7bc2b48dd425b1448304bb86273b05da1621f136d51dbb9789f8803559a1f
|
||||
F src/vacuum.c 84ce7f01f8a7a08748e107a441db83bcec13970190ddcb0c9ff522adbc1c23fd
|
||||
F src/vdbe.c a6c52ba65e8ceb574fe0eda62af84e6c50c176ffc5f310c613425f7ab2b1484b
|
||||
F src/vdbe.h 73b904a6b3bb27f308c6cc287a5751ebc7f1f89456be0ed068a12b92844c6e8c
|
||||
F src/vdbe.h 637ae853b7d42ae3951034cc63ab7c8af837861f79504cdb5399552fcd89a884
|
||||
F src/vdbeInt.h a4147a4ddf613cb1bcb555ace9e9e74a9c099d65facd88155f191b1fb4d74cfb
|
||||
F src/vdbeapi.c 1a95162e26d5eda3b7b46fbe4fcbc33eb7f801529d66fc2e14c52094a5523339
|
||||
F src/vdbeaux.c 0379f2529aa16ab82fefddb1163c3138d6552ede80962b599ae711bbf5777608
|
||||
F src/vdbeaux.c 128de68cade63c914e97d31c2fa71fd6186927ebfbedabc68019ce99256c3ddf
|
||||
F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd
|
||||
F src/vdbemem.c 1d9a0f37b0097fbb53f0d7ba081f7181b83cee2c6f46364706ea0c3896bd8ec0
|
||||
F src/vdbesort.c 43756031ca7430f7aec3ef904824a7883c4ede783e51f280d99b9b65c0796e35
|
||||
@ -712,7 +712,7 @@ F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
||||
F src/where.c ef9e644d1d76e86f68c941eb05d30a98fc0811eeef2a110906d81fedde81b6bf
|
||||
F src/whereInt.h e25203e5bfee149f5f1225ae0166cfb4f1e65490c998a024249e98bb0647377c
|
||||
F src/wherecode.c 41c17b089082558c1c5496e8a453b1f9a96485b6b355f318440fca2ee4754b2e
|
||||
F src/wherecode.c 277c38607de247353af79d54385d602d8fc2e535113253c006b749d9fff48c45
|
||||
F src/whereexpr.c 1dfda1695e4480c24248157df55bb4d66c732dc8d14ac16b4f076bb15de93d63
|
||||
F src/window.c 76a27cff9ea2ded0c2c3527187029259440fabcc4cc4c07b11d942c78494a614
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
@ -912,7 +912,7 @@ F test/createtab.test 85cdfdae5c3de331cd888d6c66e1aba575b47c2e3c3cc4a1d6f5414069
|
||||
F test/cse.test 00b3aea44b16828833c94fbe92475fd6977583fcb064ae0bc590986812b38d0c
|
||||
F test/csv01.test 2ab5514005fd308995c8910bc313e47f0368b94213b9d6c27f9a2da78796a091
|
||||
F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c4773
|
||||
F test/cursorhint.test 12e7d03262be8705798fe7b5719956bcda14989f10296a5e8fdc13466b7b75fc
|
||||
F test/cursorhint.test a44811a341281ebb73b939cb11bdcc2f374dc70e7e0f6cd7bfcb02e6fee67831
|
||||
F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f
|
||||
F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8
|
||||
F test/date.test 118e04db8c8b4efeb885542b4918c7b869a34c460a6bebbfe927dfd75706b80d
|
||||
@ -2052,8 +2052,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 9ff69e599817610d14948a3eebcc4d3c18245f78a1433c23ae659211cbbdb017
|
||||
R 7cdb734827060f13b761710e5ee55378
|
||||
P 49ba030080dd00b4fdf788fd3da057b333e705fa0fe37d653e2461bf96ca3785
|
||||
R 52234413a35145fce6946ef5d4a92056
|
||||
U drh
|
||||
Z 7d4200ee23a188536db0fc075de1e41b
|
||||
Z c6b409950782fc21232dcb9d111b6a54
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
49ba030080dd00b4fdf788fd3da057b333e705fa0fe37d653e2461bf96ca3785
|
||||
4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d
|
19
src/btree.c
19
src/btree.c
@ -946,8 +946,25 @@ int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){
|
||||
*/
|
||||
void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){
|
||||
/* Used only by system that substitute their own storage engine */
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( ALWAYS(eHintType==BTREE_HINT_RANGE) ){
|
||||
va_list ap;
|
||||
Expr *pExpr;
|
||||
Walker w;
|
||||
memset(&w, 0, sizeof(w));
|
||||
w.xExprCallback = sqlite3CursorRangeHintExprCheck;
|
||||
va_start(ap, eHintType);
|
||||
pExpr = va_arg(ap, Expr*);
|
||||
w.u.aMem = va_arg(ap, Mem*);
|
||||
va_end(ap);
|
||||
assert( pExpr!=0 );
|
||||
assert( w.u.aMem!=0 );
|
||||
sqlite3WalkExpr(&w, pExpr);
|
||||
}
|
||||
#endif /* SQLITE_DEBUG */
|
||||
}
|
||||
#endif
|
||||
#endif /* SQLITE_ENABLE_CURSOR_HINTS */
|
||||
|
||||
|
||||
/*
|
||||
** Provide flag hints to the cursor.
|
||||
|
@ -4186,6 +4186,7 @@ struct Walker {
|
||||
struct CoveringIndexCheck *pCovIdxCk; /* Check for covering index */
|
||||
SrcItem *pSrcItem; /* A single FROM clause item */
|
||||
DbFixer *pFix; /* See sqlite3FixSelect() */
|
||||
Mem *aMem; /* See sqlite3BtreeCursorHint() */
|
||||
} u;
|
||||
};
|
||||
|
||||
|
@ -403,4 +403,8 @@ void sqlite3VdbeScanStatusCounters(Vdbe*, int, int, int);
|
||||
void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
|
||||
#endif
|
||||
|
||||
#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
|
||||
int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr);
|
||||
#endif
|
||||
|
||||
#endif /* SQLITE_VDBE_H */
|
||||
|
@ -5275,6 +5275,20 @@ int sqlite3NotPureFunc(sqlite3_context *pCtx){
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
|
||||
/*
|
||||
** This Walker callback is used to help verify that calls to
|
||||
** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
|
||||
** byte-code register values correctly initialized.
|
||||
*/
|
||||
int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr){
|
||||
if( pExpr->op==TK_REGISTER ){
|
||||
assert( (pWalker->u.aMem[pExpr->iTable].flags & MEM_Undefined)==0 );
|
||||
}
|
||||
return WRC_Continue;
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_CURSOR_HINTS && SQLITE_DEBUG */
|
||||
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
/*
|
||||
** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
|
||||
|
@ -1011,11 +1011,12 @@ static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
|
||||
*/
|
||||
static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
|
||||
int rc = WRC_Continue;
|
||||
int reg;
|
||||
struct CCurHint *pHint = pWalker->u.pCCurHint;
|
||||
if( pExpr->op==TK_COLUMN ){
|
||||
if( pExpr->iTable!=pHint->iTabCur ){
|
||||
int reg = ++pWalker->pParse->nMem; /* Register for column value */
|
||||
sqlite3ExprCode(pWalker->pParse, pExpr, reg);
|
||||
reg = ++pWalker->pParse->nMem; /* Register for column value */
|
||||
reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
|
||||
pExpr->op = TK_REGISTER;
|
||||
pExpr->iTable = reg;
|
||||
}else if( pHint->pIdx!=0 ){
|
||||
@ -1023,15 +1024,12 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
|
||||
pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
|
||||
assert( pExpr->iColumn>=0 );
|
||||
}
|
||||
}else if( pExpr->op==TK_AGG_FUNCTION ){
|
||||
/* An aggregate function in the WHERE clause of a query means this must
|
||||
** be a correlated sub-query, and expression pExpr is an aggregate from
|
||||
** the parent context. Do not walk the function arguments in this case.
|
||||
**
|
||||
** todo: It should be possible to replace this node with a TK_REGISTER
|
||||
** expression, as the result of the expression must be stored in a
|
||||
** register at this point. The same holds for TK_AGG_COLUMN nodes. */
|
||||
}else if( pExpr->pAggInfo ){
|
||||
rc = WRC_Prune;
|
||||
reg = ++pWalker->pParse->nMem; /* Register for column value */
|
||||
reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
|
||||
pExpr->op = TK_REGISTER;
|
||||
pExpr->iTable = reg;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -180,4 +180,15 @@ do_execsql_test 5.1 {
|
||||
ORDER BY 1;
|
||||
}
|
||||
|
||||
# 2023-04-10 https://sqlite.org/forum/forumpost/0b53708c95
|
||||
#
|
||||
do_execsql_test 6.0 {
|
||||
CREATE TABLE t6(a TEXT UNIQUE, b TEXT);
|
||||
INSERT INTO t6(a,b) VALUES('uvw','xyz'),('abc','def');
|
||||
WITH v1(a) AS (SELECT a COLLATE NOCASE FROM t6)
|
||||
SELECT v1.a, count(*) FROM t6 LEFT JOIN v1 ON true
|
||||
GROUP BY 1
|
||||
HAVING (SELECT true FROM t6 AS aa LEFT JOIN t6 AS bb ON length(v1.a)>5);
|
||||
} {abc 2 uvw 2}
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user