mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Merge the latest enhancements from trunk.
FossilOrigin-Name: 2695772c984c215649a16e1e3e18a8048a6a60dd
This commit is contained in:
38
manifest
38
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Change\sthe\snames\sof\sthe\sstream\sinterface\sAPIs\sto\sbe\sof\sthe\sform\n"_strm"\sinstead\sof\s"_str".\s\sIn\sother\swords,\sadded\san\s"m"\sto\sthe\send,\sto\ntry\sto\smake\sit\sclear\sthat\swe\sare\stalking\sabout\sa\s"stream"\sand\snot\sa\s"string.
|
C Merge\sthe\slatest\senhancements\sfrom\strunk.
|
||||||
D 2014-09-27T20:45:48.295
|
D 2014-10-01T01:52:42.892
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in dd5f245aa8c741bc65845747203c8ce2f3fb6c83
|
F Makefile.in dd5f245aa8c741bc65845747203c8ce2f3fb6c83
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -188,7 +188,7 @@ F src/auth.c d8abcde53426275dab6243b441256fcd8ccbebb2
|
|||||||
F src/backup.c a31809c65623cc41849b94d368917f8bb66e6a7e
|
F src/backup.c a31809c65623cc41849b94d368917f8bb66e6a7e
|
||||||
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
||||||
F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
|
F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
|
||||||
F src/btree.c 59f03e421dad3cb6e27cc7d2393d3a7459be4b5e
|
F src/btree.c ede8348a7d623257ee6c06ca4796ceaee13b8657
|
||||||
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
|
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
|
||||||
F src/btreeInt.h 1bd7957161a1346a914f1f09231610e777a8e58d
|
F src/btreeInt.h 1bd7957161a1346a914f1f09231610e777a8e58d
|
||||||
F src/build.c bde83dd5cf812e310a7e5ad2846790a14745bef4
|
F src/build.c bde83dd5cf812e310a7e5ad2846790a14745bef4
|
||||||
@@ -197,7 +197,7 @@ F src/complete.c 535183afb3c75628b78ce82612931ac7cdf26f14
|
|||||||
F src/ctime.c bb434068b5308a857b181c2d204a320ff0d6c638
|
F src/ctime.c bb434068b5308a857b181c2d204a320ff0d6c638
|
||||||
F src/date.c 57a7f9ba9f6b4d5268f5e411739066a611f99036
|
F src/date.c 57a7f9ba9f6b4d5268f5e411739066a611f99036
|
||||||
F src/delete.c de3d07d6602b90ae6e8bdebeb7b3265bb846377f
|
F src/delete.c de3d07d6602b90ae6e8bdebeb7b3265bb846377f
|
||||||
F src/expr.c f32119248996680aa73c5c37bfdd42820804dc17
|
F src/expr.c 46a8ca93361d09f2ec6d9b7d524751510569d737
|
||||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||||
F src/fkey.c da985ae673efef2c712caef825a5d2edb087ead7
|
F src/fkey.c da985ae673efef2c712caef825a5d2edb087ead7
|
||||||
F src/func.c ba47c1671ab3cfdafa6e9d6ee490939ea578adee
|
F src/func.c ba47c1671ab3cfdafa6e9d6ee490939ea578adee
|
||||||
@@ -210,7 +210,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
|||||||
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
|
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
|
||||||
F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
|
F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
|
||||||
F src/loadext.c de741e66e5ddc1598d904d7289239696e40ed994
|
F src/loadext.c de741e66e5ddc1598d904d7289239696e40ed994
|
||||||
F src/main.c 1010acfb69ccd62e34e3b83664537450225c74e2
|
F src/main.c c603e28922b78643c4e0747cac356cfb23d599b9
|
||||||
F src/malloc.c 5bb99ee1e08ad58e457063cf79ce521db0e24195
|
F src/malloc.c 5bb99ee1e08ad58e457063cf79ce521db0e24195
|
||||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||||
F src/mem1.c faf615aafd8be74a71494dfa027c113ea5c6615f
|
F src/mem1.c faf615aafd8be74a71494dfa027c113ea5c6615f
|
||||||
@@ -233,22 +233,22 @@ F src/os_win.c 0a4042ef35f322e86fa01f6c8884c5e645b911e7
|
|||||||
F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
|
F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
|
||||||
F src/pager.c caab007743821d96752597c9cfd7351654697b06
|
F src/pager.c caab007743821d96752597c9cfd7351654697b06
|
||||||
F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428
|
F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428
|
||||||
F src/parse.y b98772da2bb5415970085b707203f92569400aa8
|
F src/parse.y ce1494308578d2f10a68cd8debc9fc156dda1094
|
||||||
F src/pcache.c 4121a0571c18581ee9f82f086d5e2030051ebd6a
|
F src/pcache.c 4121a0571c18581ee9f82f086d5e2030051ebd6a
|
||||||
F src/pcache.h 9b559127b83f84ff76d735c8262f04853be0c59a
|
F src/pcache.h 9b559127b83f84ff76d735c8262f04853be0c59a
|
||||||
F src/pcache1.c dab8ab930d4a73b99768d881185994f34b80ecaa
|
F src/pcache1.c dab8ab930d4a73b99768d881185994f34b80ecaa
|
||||||
F src/pragma.c 3f3e959390a10c0131676f0e307acce372777e0f
|
F src/pragma.c 3f3e959390a10c0131676f0e307acce372777e0f
|
||||||
F src/prepare.c 6ef0cf2f9274982988ed6b7cab1be23147e94196
|
F src/prepare.c 6ef0cf2f9274982988ed6b7cab1be23147e94196
|
||||||
F src/printf.c 3a47f526b173813d9a7f4e7044007771ba68cde1
|
F src/printf.c 6b79bbd063dcbadca4cf617a4cde255bcc13ea64
|
||||||
F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece
|
F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece
|
||||||
F src/resolve.c a3466128b52a86c466e47ac1a19e2174f7b5cf89
|
F src/resolve.c a3466128b52a86c466e47ac1a19e2174f7b5cf89
|
||||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||||
F src/select.c a83ed8bc2a31c131e3addb6f0488b68334085e7b
|
F src/select.c f11533162b57ed5ed37f549add34cbcdf51f6712
|
||||||
F src/shell.c 85aae71dcc9bd6df28047b95ab631eb0ac91401f
|
F src/shell.c 801af09adf9bc64dea59b62880bfb72b42c5f5f2
|
||||||
F src/sqlite.h.in 1af072be5ed8902c8c12b5b105487d0efedd00b4
|
F src/sqlite.h.in 2d5eca136aeac3126da4fb3051bb000c6625047b
|
||||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||||
F src/sqliteInt.h 219f6e9323f7fdddaec9f442d9610cce356c3ad7
|
F src/sqliteInt.h c0e679f9be4081a88c734a357986fe6ffe2fcab7
|
||||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||||
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
||||||
F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
|
F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
|
||||||
@@ -307,18 +307,18 @@ F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
|
|||||||
F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
|
F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
|
||||||
F src/vdbe.c a96171a2d025cf3dfcea4f0d94232f4bfa192f34
|
F src/vdbe.c a96171a2d025cf3dfcea4f0d94232f4bfa192f34
|
||||||
F src/vdbe.h d61daeffed696e21630759de9e135ee298ad9573
|
F src/vdbe.h d61daeffed696e21630759de9e135ee298ad9573
|
||||||
F src/vdbeInt.h 7d15127815d68e683d6a31bb4f7a52baa9cd67e5
|
F src/vdbeInt.h 6d4bf3fd28699b5c81a68398e9d23720da58fcd8
|
||||||
F src/vdbeapi.c cdded67e36d2a20f6d1c7d56f008a646557d2bf0
|
F src/vdbeapi.c cdded67e36d2a20f6d1c7d56f008a646557d2bf0
|
||||||
F src/vdbeaux.c 07b0045d0f34d0ad70c1c42ff75246a7e64e4e87
|
F src/vdbeaux.c ea20bde8cad7b15198879255af849f105daa2fa0
|
||||||
F src/vdbeblob.c d65b01f439df63911ac3d7a9a85c15503965f2c3
|
F src/vdbeblob.c d65b01f439df63911ac3d7a9a85c15503965f2c3
|
||||||
F src/vdbemem.c 5096fe50a1bd12bc2294a8b27ca6e6d1b15ef607
|
F src/vdbemem.c 5096fe50a1bd12bc2294a8b27ca6e6d1b15ef607
|
||||||
F src/vdbesort.c 5c1bacf90578d22b630fbf6ed98ccf60d83435ef
|
F src/vdbesort.c 5c1bacf90578d22b630fbf6ed98ccf60d83435ef
|
||||||
F src/vdbetrace.c 4f29b04edb0cec3d5fcd9b566d9f0e75c8984362
|
F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
|
||||||
F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
|
F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
|
||||||
F src/wal.c 10e7de7ce90865a68153f001a61f1d985cd17983
|
F src/wal.c 10e7de7ce90865a68153f001a61f1d985cd17983
|
||||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||||
F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
|
F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
|
||||||
F src/where.c a14d3d8042adeb51f81731c1b47b3e481d1cc23a
|
F src/where.c 2f42fe0d19303e0f5ce29aff3afbd3e43cbd6efb
|
||||||
F src/whereInt.h 124d970450955a6982e174b07c320ae6d62a595c
|
F src/whereInt.h 124d970450955a6982e174b07c320ae6d62a595c
|
||||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
@@ -485,7 +485,7 @@ F test/enc3.test 90683ad0e6ea587b9d5542ca93568af9a9858c40
|
|||||||
F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
|
F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
|
||||||
F test/eqp.test 85873fa5816c48915c82c4e74cb5c35a5b48160f
|
F test/eqp.test 85873fa5816c48915c82c4e74cb5c35a5b48160f
|
||||||
F test/errmsg.test f31592a594b44ee121371d25ddd5d63497bb3401
|
F test/errmsg.test f31592a594b44ee121371d25ddd5d63497bb3401
|
||||||
F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3
|
F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c
|
||||||
F test/exclusive.test c7ebbc756eacf544c108b15eed64d7d4e5f86b75
|
F test/exclusive.test c7ebbc756eacf544c108b15eed64d7d4e5f86b75
|
||||||
F test/exclusive2.test 32798111aae78a5deec980eee383213f189df308
|
F test/exclusive2.test 32798111aae78a5deec980eee383213f189df308
|
||||||
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
|
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
|
||||||
@@ -1217,7 +1217,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 497367cb57345dd37793e5f369b34d12be56172e
|
P 1f44bfdc237ee6304f4aa56e5c5d1c0d74fcc944 5ce05757aac80b99c3b2141cd301809f8e28e661
|
||||||
R cc11bbbd763a56bfdd0667ee0dcdded3
|
R 7b6778125f5d37e90ebb0b670b3bd514
|
||||||
U drh
|
U drh
|
||||||
Z 9e5912d3733f34c1f4a27e9b30386e30
|
Z 7aa260299f51330d2234a568308a124e
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1f44bfdc237ee6304f4aa56e5c5d1c0d74fcc944
|
2695772c984c215649a16e1e3e18a8048a6a60dd
|
||||||
@@ -4985,8 +4985,7 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int *pRes){
|
|||||||
assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
|
assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
|
||||||
assert( pCur->info.nSize==0 );
|
assert( pCur->info.nSize==0 );
|
||||||
if( pCur->eState!=CURSOR_VALID ){
|
if( pCur->eState!=CURSOR_VALID ){
|
||||||
assert( pCur->eState>=CURSOR_REQUIRESEEK );
|
rc = restoreCursorPosition(pCur);
|
||||||
rc = btreeRestoreCursorPosition(pCur);
|
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|||||||
167
src/expr.c
167
src/expr.c
@@ -3236,90 +3236,86 @@ void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
|
|||||||
exprToRegister(pExpr, iMem);
|
exprToRegister(pExpr, iMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
#ifdef SQLITE_DEBUG
|
||||||
/*
|
/*
|
||||||
** Generate a human-readable explanation of an expression tree.
|
** Generate a human-readable explanation of an expression tree.
|
||||||
*/
|
*/
|
||||||
void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
|
||||||
int op; /* The opcode being coded */
|
|
||||||
const char *zBinOp = 0; /* Binary operator */
|
const char *zBinOp = 0; /* Binary operator */
|
||||||
const char *zUniOp = 0; /* Unary operator */
|
const char *zUniOp = 0; /* Unary operator */
|
||||||
|
pView = sqlite3TreeViewPush(pView, moreToFollow);
|
||||||
if( pExpr==0 ){
|
if( pExpr==0 ){
|
||||||
op = TK_NULL;
|
sqlite3TreeViewLine(pView, "nil");
|
||||||
}else{
|
sqlite3TreeViewPop(pView);
|
||||||
op = pExpr->op;
|
return;
|
||||||
}
|
}
|
||||||
switch( op ){
|
switch( pExpr->op ){
|
||||||
case TK_AGG_COLUMN: {
|
case TK_AGG_COLUMN: {
|
||||||
sqlite3ExplainPrintf(pOut, "AGG{%d:%d}",
|
sqlite3TreeViewLine(pView, "AGG{%d:%d}",
|
||||||
pExpr->iTable, pExpr->iColumn);
|
pExpr->iTable, pExpr->iColumn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_COLUMN: {
|
case TK_COLUMN: {
|
||||||
if( pExpr->iTable<0 ){
|
if( pExpr->iTable<0 ){
|
||||||
/* This only happens when coding check constraints */
|
/* This only happens when coding check constraints */
|
||||||
sqlite3ExplainPrintf(pOut, "COLUMN(%d)", pExpr->iColumn);
|
sqlite3TreeViewLine(pView, "COLUMN(%d)", pExpr->iColumn);
|
||||||
}else{
|
}else{
|
||||||
sqlite3ExplainPrintf(pOut, "{%d:%d}",
|
sqlite3TreeViewLine(pView, "{%d:%d}",
|
||||||
pExpr->iTable, pExpr->iColumn);
|
pExpr->iTable, pExpr->iColumn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_INTEGER: {
|
case TK_INTEGER: {
|
||||||
if( pExpr->flags & EP_IntValue ){
|
if( pExpr->flags & EP_IntValue ){
|
||||||
sqlite3ExplainPrintf(pOut, "%d", pExpr->u.iValue);
|
sqlite3TreeViewLine(pView, "%d", pExpr->u.iValue);
|
||||||
}else{
|
}else{
|
||||||
sqlite3ExplainPrintf(pOut, "%s", pExpr->u.zToken);
|
sqlite3TreeViewLine(pView, "%s", pExpr->u.zToken);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_FLOATING_POINT
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
case TK_FLOAT: {
|
case TK_FLOAT: {
|
||||||
sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
|
sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case TK_STRING: {
|
case TK_STRING: {
|
||||||
sqlite3ExplainPrintf(pOut,"%Q", pExpr->u.zToken);
|
sqlite3TreeViewLine(pView,"%Q", pExpr->u.zToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_NULL: {
|
case TK_NULL: {
|
||||||
sqlite3ExplainPrintf(pOut,"NULL");
|
sqlite3TreeViewLine(pView,"NULL");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
||||||
case TK_BLOB: {
|
case TK_BLOB: {
|
||||||
sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
|
sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case TK_VARIABLE: {
|
case TK_VARIABLE: {
|
||||||
sqlite3ExplainPrintf(pOut,"VARIABLE(%s,%d)",
|
sqlite3TreeViewLine(pView,"VARIABLE(%s,%d)",
|
||||||
pExpr->u.zToken, pExpr->iColumn);
|
pExpr->u.zToken, pExpr->iColumn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_REGISTER: {
|
case TK_REGISTER: {
|
||||||
sqlite3ExplainPrintf(pOut,"REGISTER(%d)", pExpr->iTable);
|
sqlite3TreeViewLine(pView,"REGISTER(%d)", pExpr->iTable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_AS: {
|
case TK_AS: {
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
sqlite3TreeViewLine(pView,"AS %Q", pExpr->u.zToken);
|
||||||
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TK_ID: {
|
||||||
|
sqlite3TreeViewLine(pView,"ID %Q", pExpr->u.zToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_CAST
|
#ifndef SQLITE_OMIT_CAST
|
||||||
case TK_CAST: {
|
case TK_CAST: {
|
||||||
/* Expressions of the form: CAST(pLeft AS token) */
|
/* Expressions of the form: CAST(pLeft AS token) */
|
||||||
const char *zAff = "unk";
|
sqlite3TreeViewLine(pView,"CAST %Q", pExpr->u.zToken);
|
||||||
switch( sqlite3AffinityType(pExpr->u.zToken, 0) ){
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
|
||||||
case SQLITE_AFF_TEXT: zAff = "TEXT"; break;
|
|
||||||
case SQLITE_AFF_NONE: zAff = "NONE"; break;
|
|
||||||
case SQLITE_AFF_NUMERIC: zAff = "NUMERIC"; break;
|
|
||||||
case SQLITE_AFF_INTEGER: zAff = "INTEGER"; break;
|
|
||||||
case SQLITE_AFF_REAL: zAff = "REAL"; break;
|
|
||||||
}
|
|
||||||
sqlite3ExplainPrintf(pOut, "CAST-%s(", zAff);
|
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
|
||||||
sqlite3ExplainPrintf(pOut, ")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_OMIT_CAST */
|
#endif /* SQLITE_OMIT_CAST */
|
||||||
@@ -3352,8 +3348,8 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
|||||||
case TK_NOTNULL: zUniOp = "NOTNULL"; break;
|
case TK_NOTNULL: zUniOp = "NOTNULL"; break;
|
||||||
|
|
||||||
case TK_COLLATE: {
|
case TK_COLLATE: {
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
sqlite3TreeViewLine(pView, "COLLATE %Q", pExpr->u.zToken);
|
||||||
sqlite3ExplainPrintf(pOut,".COLLATE(%s)",pExpr->u.zToken);
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3365,41 +3361,36 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
|||||||
}else{
|
}else{
|
||||||
pFarg = pExpr->x.pList;
|
pFarg = pExpr->x.pList;
|
||||||
}
|
}
|
||||||
if( op==TK_AGG_FUNCTION ){
|
if( pExpr->op==TK_AGG_FUNCTION ){
|
||||||
sqlite3ExplainPrintf(pOut, "AGG_FUNCTION%d:%s(",
|
sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q",
|
||||||
pExpr->op2, pExpr->u.zToken);
|
pExpr->op2, pExpr->u.zToken);
|
||||||
}else{
|
}else{
|
||||||
sqlite3ExplainPrintf(pOut, "FUNCTION:%s(", pExpr->u.zToken);
|
sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
|
||||||
}
|
}
|
||||||
if( pFarg ){
|
if( pFarg ){
|
||||||
sqlite3ExplainExprList(pOut, pFarg);
|
sqlite3TreeViewExprList(pView, pFarg, 0, 0);
|
||||||
}
|
}
|
||||||
sqlite3ExplainPrintf(pOut, ")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_SUBQUERY
|
#ifndef SQLITE_OMIT_SUBQUERY
|
||||||
case TK_EXISTS: {
|
case TK_EXISTS: {
|
||||||
sqlite3ExplainPrintf(pOut, "EXISTS(");
|
sqlite3TreeViewLine(pView, "EXISTS-expr");
|
||||||
sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
|
sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
|
||||||
sqlite3ExplainPrintf(pOut,")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_SELECT: {
|
case TK_SELECT: {
|
||||||
sqlite3ExplainPrintf(pOut, "(");
|
sqlite3TreeViewLine(pView, "SELECT-expr");
|
||||||
sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
|
sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
|
||||||
sqlite3ExplainPrintf(pOut, ")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_IN: {
|
case TK_IN: {
|
||||||
sqlite3ExplainPrintf(pOut, "IN(");
|
sqlite3TreeViewLine(pView, "IN");
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
|
||||||
sqlite3ExplainPrintf(pOut, ",");
|
|
||||||
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
||||||
sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
|
sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
|
||||||
}else{
|
}else{
|
||||||
sqlite3ExplainExprList(pOut, pExpr->x.pList);
|
sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
|
||||||
}
|
}
|
||||||
sqlite3ExplainPrintf(pOut, ")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_OMIT_SUBQUERY */
|
#endif /* SQLITE_OMIT_SUBQUERY */
|
||||||
@@ -3419,13 +3410,10 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
|||||||
Expr *pX = pExpr->pLeft;
|
Expr *pX = pExpr->pLeft;
|
||||||
Expr *pY = pExpr->x.pList->a[0].pExpr;
|
Expr *pY = pExpr->x.pList->a[0].pExpr;
|
||||||
Expr *pZ = pExpr->x.pList->a[1].pExpr;
|
Expr *pZ = pExpr->x.pList->a[1].pExpr;
|
||||||
sqlite3ExplainPrintf(pOut, "BETWEEN(");
|
sqlite3TreeViewLine(pView, "BETWEEN");
|
||||||
sqlite3ExplainExpr(pOut, pX);
|
sqlite3TreeViewExpr(pView, pX, 1);
|
||||||
sqlite3ExplainPrintf(pOut, ",");
|
sqlite3TreeViewExpr(pView, pY, 1);
|
||||||
sqlite3ExplainExpr(pOut, pY);
|
sqlite3TreeViewExpr(pView, pZ, 0);
|
||||||
sqlite3ExplainPrintf(pOut, ",");
|
|
||||||
sqlite3ExplainExpr(pOut, pZ);
|
|
||||||
sqlite3ExplainPrintf(pOut, ")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_TRIGGER: {
|
case TK_TRIGGER: {
|
||||||
@@ -3436,15 +3424,14 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
|||||||
** is set to the column of the pseudo-table to read, or to -1 to
|
** is set to the column of the pseudo-table to read, or to -1 to
|
||||||
** read the rowid field.
|
** read the rowid field.
|
||||||
*/
|
*/
|
||||||
sqlite3ExplainPrintf(pOut, "%s(%d)",
|
sqlite3TreeViewLine(pView, "%s(%d)",
|
||||||
pExpr->iTable ? "NEW" : "OLD", pExpr->iColumn);
|
pExpr->iTable ? "NEW" : "OLD", pExpr->iColumn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_CASE: {
|
case TK_CASE: {
|
||||||
sqlite3ExplainPrintf(pOut, "CASE(");
|
sqlite3TreeViewLine(pView, "CASE");
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
|
||||||
sqlite3ExplainPrintf(pOut, ",");
|
sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
|
||||||
sqlite3ExplainExprList(pOut, pExpr->x.pList);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_TRIGGER
|
#ifndef SQLITE_OMIT_TRIGGER
|
||||||
@@ -3456,55 +3443,57 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
|||||||
case OE_Fail: zType = "fail"; break;
|
case OE_Fail: zType = "fail"; break;
|
||||||
case OE_Ignore: zType = "ignore"; break;
|
case OE_Ignore: zType = "ignore"; break;
|
||||||
}
|
}
|
||||||
sqlite3ExplainPrintf(pOut, "RAISE-%s(%s)", zType, pExpr->u.zToken);
|
sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
default: {
|
||||||
|
sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( zBinOp ){
|
if( zBinOp ){
|
||||||
sqlite3ExplainPrintf(pOut,"%s(", zBinOp);
|
sqlite3TreeViewLine(pView, "%s", zBinOp);
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
|
||||||
sqlite3ExplainPrintf(pOut,",");
|
sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pRight);
|
|
||||||
sqlite3ExplainPrintf(pOut,")");
|
|
||||||
}else if( zUniOp ){
|
}else if( zUniOp ){
|
||||||
sqlite3ExplainPrintf(pOut,"%s(", zUniOp);
|
sqlite3TreeViewLine(pView, "%s", zUniOp);
|
||||||
sqlite3ExplainExpr(pOut, pExpr->pLeft);
|
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
|
||||||
sqlite3ExplainPrintf(pOut,")");
|
|
||||||
}
|
}
|
||||||
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
#endif /* defined(SQLITE_ENABLE_TREE_EXPLAIN) */
|
#endif /* SQLITE_DEBUG */
|
||||||
|
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
#ifdef SQLITE_DEBUG
|
||||||
/*
|
/*
|
||||||
** Generate a human-readable explanation of an expression list.
|
** Generate a human-readable explanation of an expression list.
|
||||||
*/
|
*/
|
||||||
void sqlite3ExplainExprList(Vdbe *pOut, ExprList *pList){
|
void sqlite3TreeViewExprList(
|
||||||
|
TreeView *pView,
|
||||||
|
const ExprList *pList,
|
||||||
|
u8 moreToFollow,
|
||||||
|
const char *zLabel
|
||||||
|
){
|
||||||
int i;
|
int i;
|
||||||
if( pList==0 || pList->nExpr==0 ){
|
pView = sqlite3TreeViewPush(pView, moreToFollow);
|
||||||
sqlite3ExplainPrintf(pOut, "(empty-list)");
|
if( zLabel==0 || zLabel[0]==0 ) zLabel = "LIST";
|
||||||
return;
|
if( pList==0 ){
|
||||||
}else if( pList->nExpr==1 ){
|
sqlite3TreeViewLine(pView, "%s (empty)", zLabel);
|
||||||
sqlite3ExplainExpr(pOut, pList->a[0].pExpr);
|
|
||||||
}else{
|
}else{
|
||||||
sqlite3ExplainPush(pOut);
|
sqlite3TreeViewLine(pView, "%s", zLabel);
|
||||||
for(i=0; i<pList->nExpr; i++){
|
for(i=0; i<pList->nExpr; i++){
|
||||||
sqlite3ExplainPrintf(pOut, "item[%d] = ", i);
|
sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
|
||||||
sqlite3ExplainPush(pOut);
|
#if 0
|
||||||
sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
|
if( pList->a[i].zName ){
|
||||||
sqlite3ExplainPop(pOut);
|
|
||||||
if( pList->a[i].zName ){
|
|
||||||
sqlite3ExplainPrintf(pOut, " AS %s", pList->a[i].zName);
|
sqlite3ExplainPrintf(pOut, " AS %s", pList->a[i].zName);
|
||||||
}
|
}
|
||||||
if( pList->a[i].bSpanIsTab ){
|
if( pList->a[i].bSpanIsTab ){
|
||||||
sqlite3ExplainPrintf(pOut, " (%s)", pList->a[i].zSpan);
|
sqlite3ExplainPrintf(pOut, " (%s)", pList->a[i].zSpan);
|
||||||
}
|
}
|
||||||
if( i<pList->nExpr-1 ){
|
#endif
|
||||||
sqlite3ExplainNL(pOut);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sqlite3ExplainPop(pOut);
|
|
||||||
}
|
}
|
||||||
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_DEBUG */
|
#endif /* SQLITE_DEBUG */
|
||||||
|
|
||||||
|
|||||||
16
src/main.c
16
src/main.c
@@ -3348,22 +3348,6 @@ int sqlite3_test_control(int op, ...){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
|
||||||
/* sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT,
|
|
||||||
** sqlite3_stmt*,const char**);
|
|
||||||
**
|
|
||||||
** If compiled with SQLITE_ENABLE_TREE_EXPLAIN, each sqlite3_stmt holds
|
|
||||||
** a string that describes the optimized parse tree. This test-control
|
|
||||||
** returns a pointer to that string.
|
|
||||||
*/
|
|
||||||
case SQLITE_TESTCTRL_EXPLAIN_STMT: {
|
|
||||||
sqlite3_stmt *pStmt = va_arg(ap, sqlite3_stmt*);
|
|
||||||
const char **pzRet = va_arg(ap, const char**);
|
|
||||||
*pzRet = sqlite3VdbeExplanation((Vdbe*)pStmt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int);
|
/* sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int);
|
||||||
**
|
**
|
||||||
** Set or clear a flag that indicates that the database file is always well-
|
** Set or clear a flag that indicates that the database file is always well-
|
||||||
|
|||||||
@@ -399,9 +399,6 @@ cmd ::= DROP VIEW ifexists(E) fullname(X). {
|
|||||||
cmd ::= select(X). {
|
cmd ::= select(X). {
|
||||||
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
|
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
|
||||||
sqlite3Select(pParse, X, &dest);
|
sqlite3Select(pParse, X, &dest);
|
||||||
sqlite3ExplainBegin(pParse->pVdbe);
|
|
||||||
sqlite3ExplainSelect(pParse->pVdbe, X);
|
|
||||||
sqlite3ExplainFinish(pParse->pVdbe);
|
|
||||||
sqlite3SelectDelete(pParse->db, X);
|
sqlite3SelectDelete(pParse->db, X);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
src/printf.c
63
src/printf.c
@@ -1056,6 +1056,69 @@ void sqlite3DebugPrintf(const char *zFormat, ...){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SQLITE_DEBUG
|
||||||
|
/*************************************************************************
|
||||||
|
** Routines for implementing the "TreeView" display of hierarchical
|
||||||
|
** data structures for debugging.
|
||||||
|
**
|
||||||
|
** The main entry points (coded elsewhere) are:
|
||||||
|
** sqlite3TreeViewExpr(0, pExpr, 0);
|
||||||
|
** sqlite3TreeViewExprList(0, pList, 0, 0);
|
||||||
|
** sqlite3TreeViewSelect(0, pSelect, 0);
|
||||||
|
** Insert calls to those routines while debugging in order to display
|
||||||
|
** a diagram of Expr, ExprList, and Select objects.
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
/* Add a new subitem to the tree. The moreToFollow flag indicates that this
|
||||||
|
** is not the last item in the tree. */
|
||||||
|
TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){
|
||||||
|
if( p==0 ){
|
||||||
|
p = sqlite3_malloc( sizeof(*p) );
|
||||||
|
if( p==0 ) return 0;
|
||||||
|
memset(p, 0, sizeof(*p));
|
||||||
|
}else{
|
||||||
|
p->iLevel++;
|
||||||
|
}
|
||||||
|
assert( moreToFollow==0 || moreToFollow==1 );
|
||||||
|
if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
/* Finished with one layer of the tree */
|
||||||
|
void sqlite3TreeViewPop(TreeView *p){
|
||||||
|
if( p==0 ) return;
|
||||||
|
p->iLevel--;
|
||||||
|
if( p->iLevel<0 ) sqlite3_free(p);
|
||||||
|
}
|
||||||
|
/* Generate a single line of output for the tree, with a prefix that contains
|
||||||
|
** all the appropriate tree lines */
|
||||||
|
void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
|
||||||
|
va_list ap;
|
||||||
|
int i;
|
||||||
|
StrAccum acc;
|
||||||
|
char zBuf[500];
|
||||||
|
sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
|
||||||
|
acc.useMalloc = 0;
|
||||||
|
if( p ){
|
||||||
|
for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
|
||||||
|
sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4);
|
||||||
|
}
|
||||||
|
sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
|
||||||
|
}
|
||||||
|
va_start(ap, zFormat);
|
||||||
|
sqlite3VXPrintf(&acc, 0, zFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
if( zBuf[acc.nChar-1]!='\n' ) sqlite3StrAccumAppend(&acc, "\n", 1);
|
||||||
|
sqlite3StrAccumFinish(&acc);
|
||||||
|
fprintf(stdout,"%s", zBuf);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
/* Shorthand for starting a new tree item that consists of a single label */
|
||||||
|
void sqlite3TreeViewItem(TreeView *p, const char *zLabel, u8 moreToFollow){
|
||||||
|
p = sqlite3TreeViewPush(p, moreToFollow);
|
||||||
|
sqlite3TreeViewLine(p, "%s", zLabel);
|
||||||
|
}
|
||||||
|
#endif /* SQLITE_DEBUG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** variable-argument wrapper around sqlite3VXPrintf().
|
** variable-argument wrapper around sqlite3VXPrintf().
|
||||||
*/
|
*/
|
||||||
|
|||||||
143
src/select.c
143
src/select.c
@@ -3642,6 +3642,13 @@ static int flattenSubquery(
|
|||||||
*/
|
*/
|
||||||
sqlite3SelectDelete(db, pSub1);
|
sqlite3SelectDelete(db, pSub1);
|
||||||
|
|
||||||
|
#if SELECTTRACE_ENABLED
|
||||||
|
if( sqlite3SelectTrace & 0x100 ){
|
||||||
|
sqlite3DebugPrintf("After flattening:\n");
|
||||||
|
sqlite3TreeViewSelect(0, p, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
|
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
|
||||||
@@ -4649,7 +4656,10 @@ int sqlite3Select(
|
|||||||
memset(&sAggInfo, 0, sizeof(sAggInfo));
|
memset(&sAggInfo, 0, sizeof(sAggInfo));
|
||||||
#if SELECTTRACE_ENABLED
|
#if SELECTTRACE_ENABLED
|
||||||
pParse->nSelectIndent++;
|
pParse->nSelectIndent++;
|
||||||
SELECTTRACE(1,pParse,p, ("begin processing\n"));
|
SELECTTRACE(1,pParse,p, ("begin processing:\n"));
|
||||||
|
if( sqlite3SelectTrace & 0x100 ){
|
||||||
|
sqlite3TreeViewSelect(0, p, 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );
|
assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );
|
||||||
@@ -5417,97 +5427,96 @@ select_end:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
#ifdef SQLITE_DEBUG
|
||||||
/*
|
/*
|
||||||
** Generate a human-readable description of a the Select object.
|
** Generate a human-readable description of a the Select object.
|
||||||
*/
|
*/
|
||||||
static void explainOneSelect(Vdbe *pVdbe, Select *p){
|
void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
|
||||||
sqlite3ExplainPrintf(pVdbe, "SELECT ");
|
int n = 0;
|
||||||
if( p->selFlags & (SF_Distinct|SF_Aggregate) ){
|
pView = sqlite3TreeViewPush(pView, moreToFollow);
|
||||||
if( p->selFlags & SF_Distinct ){
|
sqlite3TreeViewLine(pView, "SELECT%s%s",
|
||||||
sqlite3ExplainPrintf(pVdbe, "DISTINCT ");
|
((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
|
||||||
}
|
((p->selFlags & SF_Aggregate) ? " agg_flag" : "")
|
||||||
if( p->selFlags & SF_Aggregate ){
|
);
|
||||||
sqlite3ExplainPrintf(pVdbe, "agg_flag ");
|
if( p->pSrc && p->pSrc->nSrc ) n++;
|
||||||
}
|
if( p->pWhere ) n++;
|
||||||
sqlite3ExplainNL(pVdbe);
|
if( p->pGroupBy ) n++;
|
||||||
sqlite3ExplainPrintf(pVdbe, " ");
|
if( p->pHaving ) n++;
|
||||||
}
|
if( p->pOrderBy ) n++;
|
||||||
sqlite3ExplainExprList(pVdbe, p->pEList);
|
if( p->pLimit ) n++;
|
||||||
sqlite3ExplainNL(pVdbe);
|
if( p->pOffset ) n++;
|
||||||
|
if( p->pPrior ) n++;
|
||||||
|
sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
|
||||||
if( p->pSrc && p->pSrc->nSrc ){
|
if( p->pSrc && p->pSrc->nSrc ){
|
||||||
int i;
|
int i;
|
||||||
sqlite3ExplainPrintf(pVdbe, "FROM ");
|
pView = sqlite3TreeViewPush(pView, (n--)>0);
|
||||||
sqlite3ExplainPush(pVdbe);
|
sqlite3TreeViewLine(pView, "FROM");
|
||||||
for(i=0; i<p->pSrc->nSrc; i++){
|
for(i=0; i<p->pSrc->nSrc; i++){
|
||||||
struct SrcList_item *pItem = &p->pSrc->a[i];
|
struct SrcList_item *pItem = &p->pSrc->a[i];
|
||||||
sqlite3ExplainPrintf(pVdbe, "{%d,*} = ", pItem->iCursor);
|
StrAccum x;
|
||||||
if( pItem->pSelect ){
|
char zLine[100];
|
||||||
sqlite3ExplainSelect(pVdbe, pItem->pSelect);
|
sqlite3StrAccumInit(&x, zLine, sizeof(zLine), 0);
|
||||||
if( pItem->pTab ){
|
sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor);
|
||||||
sqlite3ExplainPrintf(pVdbe, " (tabname=%s)", pItem->pTab->zName);
|
if( pItem->zDatabase ){
|
||||||
}
|
sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName);
|
||||||
}else if( pItem->zName ){
|
}else if( pItem->zName ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "%s", pItem->zName);
|
sqlite3XPrintf(&x, 0, " %s", pItem->zName);
|
||||||
|
}
|
||||||
|
if( pItem->pTab ){
|
||||||
|
sqlite3XPrintf(&x, 0, " tabname=%Q", pItem->pTab->zName);
|
||||||
}
|
}
|
||||||
if( pItem->zAlias ){
|
if( pItem->zAlias ){
|
||||||
sqlite3ExplainPrintf(pVdbe, " (AS %s)", pItem->zAlias);
|
sqlite3XPrintf(&x, 0, " (AS %s)", pItem->zAlias);
|
||||||
}
|
}
|
||||||
if( pItem->jointype & JT_LEFT ){
|
if( pItem->jointype & JT_LEFT ){
|
||||||
sqlite3ExplainPrintf(pVdbe, " LEFT-JOIN");
|
sqlite3XPrintf(&x, 0, " LEFT-JOIN");
|
||||||
}
|
}
|
||||||
sqlite3ExplainNL(pVdbe);
|
sqlite3StrAccumFinish(&x);
|
||||||
|
sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1);
|
||||||
|
if( pItem->pSelect ){
|
||||||
|
sqlite3TreeViewSelect(pView, pItem->pSelect, 0);
|
||||||
|
}
|
||||||
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
sqlite3ExplainPop(pVdbe);
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
if( p->pWhere ){
|
if( p->pWhere ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "WHERE ");
|
sqlite3TreeViewItem(pView, "WHERE", (n--)>0);
|
||||||
sqlite3ExplainExpr(pVdbe, p->pWhere);
|
sqlite3TreeViewExpr(pView, p->pWhere, 0);
|
||||||
sqlite3ExplainNL(pVdbe);
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
if( p->pGroupBy ){
|
if( p->pGroupBy ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "GROUPBY ");
|
sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, "GROUPBY");
|
||||||
sqlite3ExplainExprList(pVdbe, p->pGroupBy);
|
|
||||||
sqlite3ExplainNL(pVdbe);
|
|
||||||
}
|
}
|
||||||
if( p->pHaving ){
|
if( p->pHaving ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "HAVING ");
|
sqlite3TreeViewItem(pView, "HAVING", (n--)>0);
|
||||||
sqlite3ExplainExpr(pVdbe, p->pHaving);
|
sqlite3TreeViewExpr(pView, p->pHaving, 0);
|
||||||
sqlite3ExplainNL(pVdbe);
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
if( p->pOrderBy ){
|
if( p->pOrderBy ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "ORDERBY ");
|
sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY");
|
||||||
sqlite3ExplainExprList(pVdbe, p->pOrderBy);
|
|
||||||
sqlite3ExplainNL(pVdbe);
|
|
||||||
}
|
}
|
||||||
if( p->pLimit ){
|
if( p->pLimit ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "LIMIT ");
|
sqlite3TreeViewItem(pView, "LIMIT", (n--)>0);
|
||||||
sqlite3ExplainExpr(pVdbe, p->pLimit);
|
sqlite3TreeViewExpr(pView, p->pLimit, 0);
|
||||||
sqlite3ExplainNL(pVdbe);
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
if( p->pOffset ){
|
if( p->pOffset ){
|
||||||
sqlite3ExplainPrintf(pVdbe, "OFFSET ");
|
sqlite3TreeViewItem(pView, "OFFSET", (n--)>0);
|
||||||
sqlite3ExplainExpr(pVdbe, p->pOffset);
|
sqlite3TreeViewExpr(pView, p->pOffset, 0);
|
||||||
sqlite3ExplainNL(pVdbe);
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
|
if( p->pPrior ){
|
||||||
|
const char *zOp = "UNION";
|
||||||
|
switch( p->op ){
|
||||||
|
case TK_ALL: zOp = "UNION ALL"; break;
|
||||||
|
case TK_INTERSECT: zOp = "INTERSECT"; break;
|
||||||
|
case TK_EXCEPT: zOp = "EXCEPT"; break;
|
||||||
|
}
|
||||||
|
sqlite3TreeViewItem(pView, zOp, (n--)>0);
|
||||||
|
sqlite3TreeViewSelect(pView, p->pPrior, 0);
|
||||||
|
sqlite3TreeViewPop(pView);
|
||||||
|
}
|
||||||
|
sqlite3TreeViewPop(pView);
|
||||||
}
|
}
|
||||||
void sqlite3ExplainSelect(Vdbe *pVdbe, Select *p){
|
#endif /* SQLITE_DEBUG */
|
||||||
if( p==0 ){
|
|
||||||
sqlite3ExplainPrintf(pVdbe, "(null-select)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sqlite3ExplainPush(pVdbe);
|
|
||||||
while( p ){
|
|
||||||
explainOneSelect(pVdbe, p);
|
|
||||||
p = p->pNext;
|
|
||||||
if( p==0 ) break;
|
|
||||||
sqlite3ExplainNL(pVdbe);
|
|
||||||
sqlite3ExplainPrintf(pVdbe, "%s\n", selectOpName(p->op));
|
|
||||||
}
|
|
||||||
sqlite3ExplainPrintf(pVdbe, "END");
|
|
||||||
sqlite3ExplainPop(pVdbe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of the structure debug printing code
|
|
||||||
*****************************************************************************/
|
|
||||||
#endif /* defined(SQLITE_ENABLE_TREE_EXPLAIN) */
|
|
||||||
|
|||||||
@@ -1370,15 +1370,6 @@ static int shell_exec(
|
|||||||
sqlite3_free(zEQP);
|
sqlite3_free(zEQP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output TESTCTRL_EXPLAIN text of requested */
|
|
||||||
if( pArg && pArg->mode==MODE_Explain ){
|
|
||||||
const char *zExplain = 0;
|
|
||||||
sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
|
|
||||||
if( zExplain && zExplain[0] ){
|
|
||||||
fprintf(pArg->out, "%s", zExplain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the shell is currently in ".explain" mode, gather the extra
|
/* If the shell is currently in ".explain" mode, gather the extra
|
||||||
** data required to add indents to the output.*/
|
** data required to add indents to the output.*/
|
||||||
if( pArg && pArg->mode==MODE_Explain ){
|
if( pArg && pArg->mode==MODE_Explain ){
|
||||||
|
|||||||
@@ -6205,7 +6205,7 @@ int sqlite3_test_control(int op, ...);
|
|||||||
#define SQLITE_TESTCTRL_ISKEYWORD 16
|
#define SQLITE_TESTCTRL_ISKEYWORD 16
|
||||||
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17
|
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17
|
||||||
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
|
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
|
||||||
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19
|
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
|
||||||
#define SQLITE_TESTCTRL_NEVER_CORRUPT 20
|
#define SQLITE_TESTCTRL_NEVER_CORRUPT 20
|
||||||
#define SQLITE_TESTCTRL_VDBE_COVERAGE 21
|
#define SQLITE_TESTCTRL_VDBE_COVERAGE 21
|
||||||
#define SQLITE_TESTCTRL_BYTEORDER 22
|
#define SQLITE_TESTCTRL_BYTEORDER 22
|
||||||
|
|||||||
@@ -469,6 +469,11 @@
|
|||||||
#define MIN(A,B) ((A)<(B)?(A):(B))
|
#define MIN(A,B) ((A)<(B)?(A):(B))
|
||||||
#define MAX(A,B) ((A)>(B)?(A):(B))
|
#define MAX(A,B) ((A)>(B)?(A):(B))
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Swap two objects of type TYPE.
|
||||||
|
*/
|
||||||
|
#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Check to see if this machine uses EBCDIC. (Yes, believe it or
|
** Check to see if this machine uses EBCDIC. (Yes, believe it or
|
||||||
** not, there are still machines out there that use EBCDIC.)
|
** not, there are still machines out there that use EBCDIC.)
|
||||||
@@ -856,6 +861,7 @@ typedef struct StrAccum StrAccum;
|
|||||||
typedef struct Table Table;
|
typedef struct Table Table;
|
||||||
typedef struct TableLock TableLock;
|
typedef struct TableLock TableLock;
|
||||||
typedef struct Token Token;
|
typedef struct Token Token;
|
||||||
|
typedef struct TreeView TreeView;
|
||||||
typedef struct Trigger Trigger;
|
typedef struct Trigger Trigger;
|
||||||
typedef struct TriggerPrg TriggerPrg;
|
typedef struct TriggerPrg TriggerPrg;
|
||||||
typedef struct TriggerStep TriggerStep;
|
typedef struct TriggerStep TriggerStep;
|
||||||
@@ -2233,7 +2239,7 @@ struct SrcList {
|
|||||||
#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
|
#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
|
||||||
#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
|
#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
|
||||||
#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
|
#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
|
||||||
#define WHERE_AND_ONLY 0x0080 /* Don't use indices for OR terms */
|
/* 0x0080 // not currently used */
|
||||||
#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
|
#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
|
||||||
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
|
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
|
||||||
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
|
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
|
||||||
@@ -2935,6 +2941,17 @@ struct With {
|
|||||||
} a[1];
|
} a[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SQLITE_DEBUG
|
||||||
|
/*
|
||||||
|
** An instance of the TreeView object is used for printing the content of
|
||||||
|
** data structures on sqlite3DebugPrintf() using a tree-like view.
|
||||||
|
*/
|
||||||
|
struct TreeView {
|
||||||
|
int iLevel; /* Which level of the tree we are on */
|
||||||
|
u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
|
||||||
|
};
|
||||||
|
#endif /* SQLITE_DEBUG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Assuming zIn points to the first byte of a UTF-8 character,
|
** Assuming zIn points to the first byte of a UTF-8 character,
|
||||||
** advance zIn to point to the first byte of the next UTF-8 character.
|
** advance zIn to point to the first byte of the next UTF-8 character.
|
||||||
@@ -3099,25 +3116,14 @@ char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
|
|||||||
void *sqlite3TestTextToPtr(const char*);
|
void *sqlite3TestTextToPtr(const char*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Output formatting for SQLITE_TESTCTRL_EXPLAIN */
|
#if defined(SQLITE_DEBUG)
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
TreeView *sqlite3TreeViewPush(TreeView*,u8);
|
||||||
void sqlite3ExplainBegin(Vdbe*);
|
void sqlite3TreeViewPop(TreeView*);
|
||||||
void sqlite3ExplainPrintf(Vdbe*, const char*, ...);
|
void sqlite3TreeViewLine(TreeView*, const char*, ...);
|
||||||
void sqlite3ExplainNL(Vdbe*);
|
void sqlite3TreeViewItem(TreeView*, const char*, u8);
|
||||||
void sqlite3ExplainPush(Vdbe*);
|
void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
|
||||||
void sqlite3ExplainPop(Vdbe*);
|
void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
|
||||||
void sqlite3ExplainFinish(Vdbe*);
|
void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
|
||||||
void sqlite3ExplainSelect(Vdbe*, Select*);
|
|
||||||
void sqlite3ExplainExpr(Vdbe*, Expr*);
|
|
||||||
void sqlite3ExplainExprList(Vdbe*, ExprList*);
|
|
||||||
const char *sqlite3VdbeExplanation(Vdbe*);
|
|
||||||
#else
|
|
||||||
# define sqlite3ExplainBegin(X)
|
|
||||||
# define sqlite3ExplainSelect(A,B)
|
|
||||||
# define sqlite3ExplainExpr(A,B)
|
|
||||||
# define sqlite3ExplainExprList(A,B)
|
|
||||||
# define sqlite3ExplainFinish(X)
|
|
||||||
# define sqlite3VdbeExplanation(X) 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -360,10 +360,6 @@ struct Vdbe {
|
|||||||
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
|
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
|
||||||
char *zSql; /* Text of the SQL statement that generated this */
|
char *zSql; /* Text of the SQL statement that generated this */
|
||||||
void *pFree; /* Free this when deleting the vdbe */
|
void *pFree; /* Free this when deleting the vdbe */
|
||||||
#ifdef SQLITE_ENABLE_TREE_EXPLAIN
|
|
||||||
Explain *pExplain; /* The explainer */
|
|
||||||
char *zExplain; /* Explanation of data structures */
|
|
||||||
#endif
|
|
||||||
VdbeFrame *pFrame; /* Parent frame */
|
VdbeFrame *pFrame; /* Parent frame */
|
||||||
VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
|
VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
|
||||||
int nFrame; /* Number of frames in pFrame list */
|
int nFrame; /* Number of frames in pFrame list */
|
||||||
|
|||||||
@@ -753,7 +753,8 @@ void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Remove the last opcode inserted
|
** If the last opcode is "op" and it is not a jump destination,
|
||||||
|
** then remove it. Return true if and only if an opcode was removed.
|
||||||
*/
|
*/
|
||||||
int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){
|
int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){
|
||||||
if( (p->nOp-1)>(p->pParse->iFixedOp) && p->aOp[p->nOp-1].opcode==op ){
|
if( (p->nOp-1)>(p->pParse->iFixedOp) && p->aOp[p->nOp-1].opcode==op ){
|
||||||
@@ -2678,10 +2679,6 @@ void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
|
|||||||
sqlite3DbFree(db, p->aColName);
|
sqlite3DbFree(db, p->aColName);
|
||||||
sqlite3DbFree(db, p->zSql);
|
sqlite3DbFree(db, p->zSql);
|
||||||
sqlite3DbFree(db, p->pFree);
|
sqlite3DbFree(db, p->pFree);
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
|
||||||
sqlite3DbFree(db, p->zExplain);
|
|
||||||
sqlite3DbFree(db, p->pExplain);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
115
src/vdbetrace.c
115
src/vdbetrace.c
@@ -183,118 +183,3 @@ char *sqlite3VdbeExpandSql(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* #ifndef SQLITE_OMIT_TRACE */
|
#endif /* #ifndef SQLITE_OMIT_TRACE */
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
** The following code implements the data-structure explaining logic
|
|
||||||
** for the Vdbe.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Allocate a new Explain object
|
|
||||||
*/
|
|
||||||
void sqlite3ExplainBegin(Vdbe *pVdbe){
|
|
||||||
if( pVdbe ){
|
|
||||||
Explain *p;
|
|
||||||
sqlite3BeginBenignMalloc();
|
|
||||||
p = (Explain *)sqlite3MallocZero( sizeof(Explain) );
|
|
||||||
if( p ){
|
|
||||||
p->pVdbe = pVdbe;
|
|
||||||
sqlite3_free(pVdbe->pExplain);
|
|
||||||
pVdbe->pExplain = p;
|
|
||||||
sqlite3StrAccumInit(&p->str, p->zBase, sizeof(p->zBase),
|
|
||||||
SQLITE_MAX_LENGTH);
|
|
||||||
p->str.useMalloc = 2;
|
|
||||||
}else{
|
|
||||||
sqlite3EndBenignMalloc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Return true if the Explain ends with a new-line.
|
|
||||||
*/
|
|
||||||
static int endsWithNL(Explain *p){
|
|
||||||
return p && p->str.zText && p->str.nChar
|
|
||||||
&& p->str.zText[p->str.nChar-1]=='\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Append text to the indentation
|
|
||||||
*/
|
|
||||||
void sqlite3ExplainPrintf(Vdbe *pVdbe, const char *zFormat, ...){
|
|
||||||
Explain *p;
|
|
||||||
if( pVdbe && (p = pVdbe->pExplain)!=0 ){
|
|
||||||
va_list ap;
|
|
||||||
if( p->nIndent && endsWithNL(p) ){
|
|
||||||
int n = p->nIndent;
|
|
||||||
if( n>ArraySize(p->aIndent) ) n = ArraySize(p->aIndent);
|
|
||||||
sqlite3AppendSpace(&p->str, p->aIndent[n-1]);
|
|
||||||
}
|
|
||||||
va_start(ap, zFormat);
|
|
||||||
sqlite3VXPrintf(&p->str, SQLITE_PRINTF_INTERNAL, zFormat, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Append a '\n' if there is not already one.
|
|
||||||
*/
|
|
||||||
void sqlite3ExplainNL(Vdbe *pVdbe){
|
|
||||||
Explain *p;
|
|
||||||
if( pVdbe && (p = pVdbe->pExplain)!=0 && !endsWithNL(p) ){
|
|
||||||
sqlite3StrAccumAppend(&p->str, "\n", 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Push a new indentation level. Subsequent lines will be indented
|
|
||||||
** so that they begin at the current cursor position.
|
|
||||||
*/
|
|
||||||
void sqlite3ExplainPush(Vdbe *pVdbe){
|
|
||||||
Explain *p;
|
|
||||||
if( pVdbe && (p = pVdbe->pExplain)!=0 ){
|
|
||||||
if( p->str.zText && p->nIndent<ArraySize(p->aIndent) ){
|
|
||||||
const char *z = p->str.zText;
|
|
||||||
int i = p->str.nChar-1;
|
|
||||||
int x;
|
|
||||||
while( i>=0 && z[i]!='\n' ){ i--; }
|
|
||||||
x = (p->str.nChar - 1) - i;
|
|
||||||
if( p->nIndent && x<p->aIndent[p->nIndent-1] ){
|
|
||||||
x = p->aIndent[p->nIndent-1];
|
|
||||||
}
|
|
||||||
p->aIndent[p->nIndent] = x;
|
|
||||||
}
|
|
||||||
p->nIndent++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Pop the indentation stack by one level.
|
|
||||||
*/
|
|
||||||
void sqlite3ExplainPop(Vdbe *p){
|
|
||||||
if( p && p->pExplain ) p->pExplain->nIndent--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Free the indentation structure
|
|
||||||
*/
|
|
||||||
void sqlite3ExplainFinish(Vdbe *pVdbe){
|
|
||||||
if( pVdbe && pVdbe->pExplain ){
|
|
||||||
sqlite3_free(pVdbe->zExplain);
|
|
||||||
sqlite3ExplainNL(pVdbe);
|
|
||||||
pVdbe->zExplain = sqlite3StrAccumFinish(&pVdbe->pExplain->str);
|
|
||||||
sqlite3_free(pVdbe->pExplain);
|
|
||||||
pVdbe->pExplain = 0;
|
|
||||||
sqlite3EndBenignMalloc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Return the explanation of a virtual machine.
|
|
||||||
*/
|
|
||||||
const char *sqlite3VdbeExplanation(Vdbe *pVdbe){
|
|
||||||
return (pVdbe && pVdbe->zExplain) ? pVdbe->zExplain : 0;
|
|
||||||
}
|
|
||||||
#endif /* defined(SQLITE_DEBUG) */
|
|
||||||
|
|||||||
87
src/where.c
87
src/where.c
@@ -364,11 +364,6 @@ static int allowedOp(int op){
|
|||||||
return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL;
|
return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Swap two objects of type TYPE.
|
|
||||||
*/
|
|
||||||
#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Commute a comparison operator. Expressions of the form "X op Y"
|
** Commute a comparison operator. Expressions of the form "X op Y"
|
||||||
** are converted into "Y op X".
|
** are converted into "Y op X".
|
||||||
@@ -3529,8 +3524,9 @@ static Bitmask codeOneLoopStart(
|
|||||||
** eliminating duplicates from other WHERE clauses, the action for each
|
** eliminating duplicates from other WHERE clauses, the action for each
|
||||||
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
|
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
|
||||||
*/
|
*/
|
||||||
wctrlFlags = WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
|
wctrlFlags = WHERE_OMIT_OPEN_CLOSE
|
||||||
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY;
|
| WHERE_FORCE_TABLE
|
||||||
|
| WHERE_ONETABLE_ONLY;
|
||||||
for(ii=0; ii<pOrWc->nTerm; ii++){
|
for(ii=0; ii<pOrWc->nTerm; ii++){
|
||||||
WhereTerm *pOrTerm = &pOrWc->a[ii];
|
WhereTerm *pOrTerm = &pOrWc->a[ii];
|
||||||
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
|
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
|
||||||
@@ -3542,6 +3538,7 @@ static Bitmask codeOneLoopStart(
|
|||||||
pOrExpr = pAndExpr;
|
pOrExpr = pAndExpr;
|
||||||
}
|
}
|
||||||
/* Loop through table entries that match term pOrTerm. */
|
/* Loop through table entries that match term pOrTerm. */
|
||||||
|
WHERETRACE(0xffff, ("Subplan for OR-clause:\n"));
|
||||||
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
|
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
|
||||||
wctrlFlags, iCovCur);
|
wctrlFlags, iCovCur);
|
||||||
assert( pSubWInfo || pParse->nErr || db->mallocFailed );
|
assert( pSubWInfo || pParse->nErr || db->mallocFailed );
|
||||||
@@ -3761,21 +3758,26 @@ static Bitmask codeOneLoopStart(
|
|||||||
return pLevel->notReady;
|
return pLevel->notReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WHERETRACE_ENABLED) && defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
#ifdef WHERETRACE_ENABLED
|
||||||
/*
|
/*
|
||||||
** Generate "Explanation" text for a WhereTerm.
|
** Print the content of a WhereTerm object
|
||||||
*/
|
*/
|
||||||
static void whereExplainTerm(Vdbe *v, WhereTerm *pTerm){
|
static void whereTermPrint(WhereTerm *pTerm, int iTerm){
|
||||||
char zType[4];
|
if( pTerm==0 ){
|
||||||
memcpy(zType, "...", 4);
|
sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
|
||||||
if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
|
}else{
|
||||||
if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
|
char zType[4];
|
||||||
if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
|
memcpy(zType, "...", 4);
|
||||||
sqlite3ExplainPrintf(v, "%s ", zType);
|
if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
|
||||||
sqlite3ExplainExpr(v, pTerm->pExpr);
|
if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
|
||||||
|
if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
|
||||||
|
sqlite3DebugPrintf("TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x\n",
|
||||||
|
iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb,
|
||||||
|
pTerm->eOperator);
|
||||||
|
sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* WHERETRACE_ENABLED && SQLITE_ENABLE_TREE_EXPLAIN */
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef WHERETRACE_ENABLED
|
#ifdef WHERETRACE_ENABLED
|
||||||
/*
|
/*
|
||||||
@@ -3819,27 +3821,12 @@ static void whereLoopPrint(WhereLoop *p, WhereClause *pWC){
|
|||||||
sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
|
sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
|
||||||
}
|
}
|
||||||
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
|
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
|
||||||
#ifdef SQLITE_ENABLE_TREE_EXPLAIN
|
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){
|
||||||
/* If the 0x100 bit of wheretracing is set, then show all of the constraint
|
|
||||||
** expressions in the WhereLoop.aLTerm[] array.
|
|
||||||
*/
|
|
||||||
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){ /* WHERETRACE 0x100 */
|
|
||||||
int i;
|
int i;
|
||||||
Vdbe *v = pWInfo->pParse->pVdbe;
|
|
||||||
sqlite3ExplainBegin(v);
|
|
||||||
for(i=0; i<p->nLTerm; i++){
|
for(i=0; i<p->nLTerm; i++){
|
||||||
WhereTerm *pTerm = p->aLTerm[i];
|
whereTermPrint(p->aLTerm[i], i);
|
||||||
if( pTerm==0 ) continue;
|
|
||||||
sqlite3ExplainPrintf(v, " (%d) #%-2d ", i+1, (int)(pTerm-pWC->a));
|
|
||||||
sqlite3ExplainPush(v);
|
|
||||||
whereExplainTerm(v, pTerm);
|
|
||||||
sqlite3ExplainPop(v);
|
|
||||||
sqlite3ExplainNL(v);
|
|
||||||
}
|
}
|
||||||
sqlite3ExplainFinish(v);
|
|
||||||
sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v));
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -5019,7 +5006,6 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
|
|||||||
struct SrcList_item *pItem;
|
struct SrcList_item *pItem;
|
||||||
|
|
||||||
pWC = pBuilder->pWC;
|
pWC = pBuilder->pWC;
|
||||||
if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK;
|
|
||||||
pWCEnd = pWC->a + pWC->nTerm;
|
pWCEnd = pWC->a + pWC->nTerm;
|
||||||
pNew = pBuilder->pNew;
|
pNew = pBuilder->pNew;
|
||||||
memset(&sSum, 0, sizeof(sSum));
|
memset(&sSum, 0, sizeof(sSum));
|
||||||
@@ -5040,6 +5026,7 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
|
|||||||
sSubBuild.pOrderBy = 0;
|
sSubBuild.pOrderBy = 0;
|
||||||
sSubBuild.pOrSet = &sCur;
|
sSubBuild.pOrSet = &sCur;
|
||||||
|
|
||||||
|
WHERETRACE(0x200, ("Begin processing OR-clause %p\n", pTerm));
|
||||||
for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){
|
for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){
|
||||||
if( (pOrTerm->eOperator & WO_AND)!=0 ){
|
if( (pOrTerm->eOperator & WO_AND)!=0 ){
|
||||||
sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;
|
sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;
|
||||||
@@ -5054,6 +5041,15 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sCur.n = 0;
|
sCur.n = 0;
|
||||||
|
#ifdef WHERETRACE_ENABLED
|
||||||
|
WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
|
||||||
|
(int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
|
||||||
|
if( sqlite3WhereTrace & 0x400 ){
|
||||||
|
for(i=0; i<sSubBuild.pWC->nTerm; i++){
|
||||||
|
whereTermPrint(&sSubBuild.pWC->a[i], i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
if( IsVirtual(pItem->pTab) ){
|
if( IsVirtual(pItem->pTab) ){
|
||||||
rc = whereLoopAddVirtual(&sSubBuild, mExtra);
|
rc = whereLoopAddVirtual(&sSubBuild, mExtra);
|
||||||
@@ -5062,6 +5058,9 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
|
|||||||
{
|
{
|
||||||
rc = whereLoopAddBtree(&sSubBuild, mExtra);
|
rc = whereLoopAddBtree(&sSubBuild, mExtra);
|
||||||
}
|
}
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
rc = whereLoopAddOr(&sSubBuild, mExtra);
|
||||||
|
}
|
||||||
assert( rc==SQLITE_OK || sCur.n==0 );
|
assert( rc==SQLITE_OK || sCur.n==0 );
|
||||||
if( sCur.n==0 ){
|
if( sCur.n==0 ){
|
||||||
sSum.n = 0;
|
sSum.n = 0;
|
||||||
@@ -5106,6 +5105,7 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
|
|||||||
pNew->prereq = sSum.a[i].prereq;
|
pNew->prereq = sSum.a[i].prereq;
|
||||||
rc = whereLoopInsert(pBuilder, pNew);
|
rc = whereLoopInsert(pBuilder, pNew);
|
||||||
}
|
}
|
||||||
|
WHERETRACE(0x200, ("End processing OR-clause %p\n", pTerm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@@ -6172,23 +6172,16 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
|
|
||||||
/* Construct the WhereLoop objects */
|
/* Construct the WhereLoop objects */
|
||||||
WHERETRACE(0xffff,("*** Optimizer Start ***\n"));
|
WHERETRACE(0xffff,("*** Optimizer Start ***\n"));
|
||||||
|
#if defined(WHERETRACE_ENABLED)
|
||||||
/* Display all terms of the WHERE clause */
|
/* Display all terms of the WHERE clause */
|
||||||
#if defined(WHERETRACE_ENABLED) && defined(SQLITE_ENABLE_TREE_EXPLAIN)
|
|
||||||
if( sqlite3WhereTrace & 0x100 ){
|
if( sqlite3WhereTrace & 0x100 ){
|
||||||
int i;
|
int i;
|
||||||
Vdbe *v = pParse->pVdbe;
|
|
||||||
sqlite3ExplainBegin(v);
|
|
||||||
for(i=0; i<sWLB.pWC->nTerm; i++){
|
for(i=0; i<sWLB.pWC->nTerm; i++){
|
||||||
sqlite3ExplainPrintf(v, "#%-2d ", i);
|
whereTermPrint(&sWLB.pWC->a[i], i);
|
||||||
sqlite3ExplainPush(v);
|
|
||||||
whereExplainTerm(v, &sWLB.pWC->a[i]);
|
|
||||||
sqlite3ExplainPop(v);
|
|
||||||
sqlite3ExplainNL(v);
|
|
||||||
}
|
}
|
||||||
sqlite3ExplainFinish(v);
|
|
||||||
sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
|
if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
|
||||||
rc = whereLoopAddAll(&sWLB);
|
rc = whereLoopAddAll(&sWLB);
|
||||||
if( rc ) goto whereBeginError;
|
if( rc ) goto whereBeginError;
|
||||||
|
|||||||
@@ -58,6 +58,18 @@ do_test eval-2.2 {
|
|||||||
SELECT * FROM t2
|
SELECT * FROM t2
|
||||||
}
|
}
|
||||||
} {}
|
} {}
|
||||||
|
do_test eval-2.3 {
|
||||||
|
execsql {
|
||||||
|
INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
|
||||||
|
SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2
|
||||||
|
ORDER BY rowid DESC;
|
||||||
|
}
|
||||||
|
} {4 {} {} 3 {} {} 2 {} {} 1 {} {}}
|
||||||
|
do_test eval-2.4 {
|
||||||
|
execsql {
|
||||||
|
SELECT * FROM t2
|
||||||
|
}
|
||||||
|
} {}
|
||||||
|
|
||||||
# Modify a row while it is being read.
|
# Modify a row while it is being read.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user