Add the sqlite3VdbeLoadString() and sqlite3VdbeMultiLoad() routines to help
with code generation, especially on PRAGMAs. Rename sqlite3VdbeAddGoto() to just sqlite3VdbeGoto(). FossilOrigin-Name: 847387ec8e6fef283899578fb232b2c23b00ee5b
This commit is contained in:
parent
7cc023c7fa
commit
076e85f59c
40
manifest
40
manifest
@ -1,5 +1,5 @@
|
||||
C Factor\sout\sand\ssimplify\scode\sin\spragma.c\sfor\spragmas\sthat\sreturn\sa\ssingle\nrow\swith\sa\ssingle\scolumn\sthat\sis\san\sinteger\sor\stext\svalue.
|
||||
D 2015-09-03T04:28:25.375
|
||||
C Add\sthe\ssqlite3VdbeLoadString()\sand\ssqlite3VdbeMultiLoad()\sroutines\sto\shelp\nwith\scode\sgeneration,\sespecially\son\sPRAGMAs.\s\sRename\ssqlite3VdbeAddGoto()\nto\sjust\ssqlite3VdbeGoto().
|
||||
D 2015-09-03T13:46:12.406
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in f85066ce844a28b671aaeeff320921cd0ce36239
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -272,8 +272,8 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||
F src/alter.c 48e14b8aea28dc58baafe3cfcb8889c086b7744a
|
||||
F src/analyze.c eb4683b50a0c5eede2360a2f7c2ea03d0b33d822
|
||||
F src/alter.c 4911e1f18fc11b60edbc6410643e938762969a6a
|
||||
F src/analyze.c e4ad1495090d6b7bf58b927e1267fc211ad5e7da
|
||||
F src/attach.c e944d0052b577703b9b83aac1638452ff42a8395
|
||||
F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
|
||||
F src/backup.c 4d9134dc988a87838c06056c89c0e8c4700a0452
|
||||
@ -282,22 +282,22 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
|
||||
F src/btree.c 4084d9eed2817331f6e6a82230ba30e448cad497
|
||||
F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
|
||||
F src/btreeInt.h 8177c9ab90d772d6d2c6c517e05bed774b7c92c0
|
||||
F src/build.c 4e8b8bdeb238cc0ac1fecdd871ac172fc9ab995a
|
||||
F src/build.c 6c3a8a9b21402a6be98126f7d86b76527e68ca67
|
||||
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
|
||||
F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f
|
||||
F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b
|
||||
F src/date.c 8ec787fed4929d8ccdf6b1bc360fccc3e1d2ca58
|
||||
F src/dbstat.c f402e77e25089c6003d0c60b3233b9b3947d599a
|
||||
F src/delete.c e1efb66d52f4d05ad9231707373e3fed77209023
|
||||
F src/expr.c cf60b916ef4aee1a2c28e202566cc184dafdb998
|
||||
F src/delete.c 5b4835982c31f12b256dc4d814363a11e7ef34cf
|
||||
F src/expr.c af2c72f8938413c0c367554962b0d8761121f39d
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c a1d9d555c3fcf82cb0d4b0c03e5af28b9680a873
|
||||
F src/fkey.c 83e1baba999bed3144ea5a2143fc922edf51135f
|
||||
F src/func.c 824bea430d3a2b7dbc62806ad54da8fdb8ed9e3f
|
||||
F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9
|
||||
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
|
||||
F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
|
||||
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
|
||||
F src/insert.c fe5151937927dc1a5c5d7b6b473d5ab47338183e
|
||||
F src/insert.c bcff4a416177ed90faa8dba65f0266ddad2aeb76
|
||||
F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
||||
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
|
||||
F src/lempar.c 92bafa308607dd985ca389a788cd9e0a2b608712
|
||||
@ -330,14 +330,14 @@ F src/parse.y f599aa5e871a493330d567ced93de696f61f48f7
|
||||
F src/pcache.c cde06aa50962595e412d497e22fd2e07878ba1f0
|
||||
F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9
|
||||
F src/pcache1.c b31af9dbc83b9c68e87d681b8453a9605f28e734
|
||||
F src/pragma.c 0465869b5a6161f3184b8e31227ef1edfbabff46
|
||||
F src/pragma.c d71b813e67bf03f3116b9dd5164fbfd81ec673a2
|
||||
F src/pragma.h 631a91c8b0e6ca8f051a1d8a4a0da4150e04620a
|
||||
F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1
|
||||
F src/printf.c 0c4bcdd1c2e2521024f0a69cb5eb334f86b3652a
|
||||
F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
||||
F src/resolve.c f2ef256786a6435efddd64a632fea89c8be62215
|
||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||
F src/select.c da24e8406f819dfce006c6eeba2da7a561a45de1
|
||||
F src/select.c c17613385bc6b095c421b1f30548814f5fd8a9b2
|
||||
F src/shell.c bbe2bab590b7dd04dd8f9119d4473cb8c52906e3
|
||||
F src/sqlite.h.in 378bebc8fe6a88bade25e5f23b7e6123fdc64b00
|
||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||
@ -396,27 +396,27 @@ F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481
|
||||
F src/tokenize.c 57cb3720f53f84d811def2069c2b169b6be539a5
|
||||
F src/treeview.c 46036cbbceada0836833531b2d963edbca3d9cfa
|
||||
F src/trigger.c 322f23aad694e8f31d384dcfa386d52a48d3c52f
|
||||
F src/update.c bf0db5617e735c1527a30654dd083316297f50ea
|
||||
F src/update.c 795fba8ebadeb194285b0a73a07f7ad5ae4d0410
|
||||
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
|
||||
F src/util.c fc612367108b74573c5fd13a85d0a23027f438bd
|
||||
F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701
|
||||
F src/vdbe.c 6d85be995bd2308a5aa2a68c7b564c5d4cc1a6fb
|
||||
F src/vdbe.h 4297a88c5f29b79dda25f486ec26dd6a19dc6036
|
||||
F src/vdbe.h 4bc88bd0e06f8046ee6ab7487c0015e85ad949ad
|
||||
F src/vdbeInt.h 8b54e01ad0463590e7cffabce0bc36da9ee4f816
|
||||
F src/vdbeapi.c bda74ef4b5103d7b4a4be36f936d3cf2b56a7d6f
|
||||
F src/vdbeaux.c 9a10bda8923d5046ce0144dfca0f132a48f14544
|
||||
F src/vdbeaux.c fd00b489ab3f44f2dca1e4344faf289b7bfcf649
|
||||
F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90
|
||||
F src/vdbemem.c ae38a0d35ae71cf604381a887c170466ba518090
|
||||
F src/vdbesort.c f5009e7a35e3065635d8918b9a31f498a499976b
|
||||
F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0
|
||||
F src/vtab.c d31174e4c8f592febab3fa7f69e18320b4fd657a
|
||||
F src/vtab.c 2ecfe020c10e0a0c7b078203fdba2fae844744bc
|
||||
F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb
|
||||
F src/wal.c 8cd07f1f99e1a81346db1c9da879bef6c6f97cf6
|
||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||
F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba
|
||||
F src/where.c 8f3a40ccf5759aacccb65692e921ab9f01595205
|
||||
F src/where.c f0e08e4f1f66ba1a0f5b70c5161cb031ce1fb858
|
||||
F src/whereInt.h 901c17c1e3c82745ad9b85b4471543fa59c980e9
|
||||
F src/wherecode.c e215fc0223a0391178ad43c7a011047d2a63de55
|
||||
F src/wherecode.c c0d9b1c7c7c827998016809851d2ddc529de0fee
|
||||
F src/whereexpr.c 1a308d1ee5144890d21ea9cf70d49bc96a83432b
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
|
||||
@ -1380,7 +1380,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 0ea6e5c9fc6b1dd1174c09097be5bf291da4e6c7
|
||||
R ffdc67a15f3e87587ec67dbf739c11e1
|
||||
P d7f4bdf594e93c848f46901637861c8eed4c34df
|
||||
R 87d27a58ce6d4a6cd03f169f2370f2fe
|
||||
U drh
|
||||
Z 0c8a5640caa42ef8a565318b70a0d8e2
|
||||
Z bdbaccc5e83ea81c60c1b2c883af5b3e
|
||||
|
@ -1 +1 @@
|
||||
d7f4bdf594e93c848f46901637861c8eed4c34df
|
||||
847387ec8e6fef283899578fb232b2c23b00ee5b
|
@ -491,7 +491,7 @@ void sqlite3AlterRenameTable(
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( pVTab ){
|
||||
int i = ++pParse->nMem;
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0);
|
||||
sqlite3VdbeLoadString(v, i, zName);
|
||||
sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);
|
||||
sqlite3MayAbort(pParse);
|
||||
}
|
||||
|
@ -1014,7 +1014,7 @@ static void analyzeOneTable(
|
||||
iIdxCur = iTab++;
|
||||
pParse->nTab = MAX(pParse->nTab, iTab);
|
||||
sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0);
|
||||
sqlite3VdbeLoadString(v, regTabname, pTab->zName);
|
||||
|
||||
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
int nCol; /* Number of columns in pIdx. "N" */
|
||||
@ -1036,7 +1036,7 @@ static void analyzeOneTable(
|
||||
}
|
||||
|
||||
/* Populate the register containing the index name. */
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0);
|
||||
sqlite3VdbeLoadString(v, regIdxname, zIdxName);
|
||||
VdbeComment((v, "Analysis for %s.%s", pTab->zName, zIdxName));
|
||||
|
||||
/*
|
||||
@ -1150,7 +1150,7 @@ static void analyzeOneTable(
|
||||
VdbeCoverage(v);
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, nColTest, regChng);
|
||||
sqlite3VdbeAddGoto(v, endDistinctTest);
|
||||
sqlite3VdbeGoto(v, endDistinctTest);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -221,7 +221,7 @@ void sqlite3FinishCoding(Parse *pParse){
|
||||
}
|
||||
|
||||
/* Finally, jump back to the beginning of the executable code. */
|
||||
sqlite3VdbeAddGoto(v, 1);
|
||||
sqlite3VdbeGoto(v, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1963,7 +1963,7 @@ void sqlite3EndTable(
|
||||
sqlite3TableAffinity(v, p, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);
|
||||
sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);
|
||||
sqlite3VdbeAddGoto(v, addrInsLoop);
|
||||
sqlite3VdbeGoto(v, addrInsLoop);
|
||||
sqlite3VdbeJumpHere(v, addrInsLoop);
|
||||
sqlite3VdbeAddOp1(v, OP_Close, 1);
|
||||
}
|
||||
@ -2792,7 +2792,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
|
||||
assert( pKey!=0 || db->mallocFailed || pParse->nErr );
|
||||
if( IsUniqueIndex(pIndex) && pKey!=0 ){
|
||||
int j2 = sqlite3VdbeCurrentAddr(v) + 3;
|
||||
sqlite3VdbeAddGoto(v, j2);
|
||||
sqlite3VdbeGoto(v, j2);
|
||||
addr2 = sqlite3VdbeCurrentAddr(v);
|
||||
sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
|
||||
pIndex->nKeyCol); VdbeCoverage(v);
|
||||
|
@ -456,7 +456,7 @@ void sqlite3DeleteFrom(
|
||||
if( okOnePass ){
|
||||
/* Bypass the delete logic below if the WHERE loop found zero rows */
|
||||
addrBypass = sqlite3VdbeMakeLabel(v);
|
||||
sqlite3VdbeAddGoto(v, addrBypass);
|
||||
sqlite3VdbeGoto(v, addrBypass);
|
||||
sqlite3VdbeJumpHere(v, addrDelete);
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ void sqlite3DeleteFrom(
|
||||
sqlite3VdbeAddOp2(v, OP_Next, iEphCur, addrLoop+1); VdbeCoverage(v);
|
||||
sqlite3VdbeJumpHere(v, addrLoop);
|
||||
}else{
|
||||
sqlite3VdbeAddGoto(v, addrLoop);
|
||||
sqlite3VdbeGoto(v, addrLoop);
|
||||
sqlite3VdbeJumpHere(v, addrLoop);
|
||||
}
|
||||
|
||||
|
16
src/expr.c
16
src/expr.c
@ -2145,7 +2145,7 @@ static void sqlite3ExprCodeIN(
|
||||
}
|
||||
if( regCkNull ){
|
||||
sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, destIfFalse);
|
||||
sqlite3VdbeGoto(v, destIfFalse);
|
||||
}
|
||||
sqlite3VdbeResolveLabel(v, labelOk);
|
||||
sqlite3ReleaseTempReg(pParse, regCkNull);
|
||||
@ -2163,7 +2163,7 @@ static void sqlite3ExprCodeIN(
|
||||
int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, destIfNull);
|
||||
sqlite3VdbeGoto(v, destIfNull);
|
||||
sqlite3VdbeJumpHere(v, addr1);
|
||||
}
|
||||
}
|
||||
@ -2213,7 +2213,7 @@ static void sqlite3ExprCodeIN(
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp2(v, OP_IsNull, rRhsHasNull, destIfNull);
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, destIfFalse);
|
||||
sqlite3VdbeGoto(v, destIfFalse);
|
||||
sqlite3VdbeJumpHere(v, j1);
|
||||
}
|
||||
}
|
||||
@ -2639,7 +2639,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
#endif
|
||||
case TK_STRING: {
|
||||
assert( !ExprHasProperty(pExpr, EP_IntValue) );
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0);
|
||||
sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
|
||||
break;
|
||||
}
|
||||
case TK_NULL: {
|
||||
@ -3136,7 +3136,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
|
||||
testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
|
||||
sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
|
||||
sqlite3VdbeAddGoto(v, endLabel);
|
||||
sqlite3VdbeGoto(v, endLabel);
|
||||
sqlite3ExprCachePop(pParse);
|
||||
sqlite3VdbeResolveLabel(v, nextCase);
|
||||
}
|
||||
@ -3526,14 +3526,14 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
int destIfFalse = sqlite3VdbeMakeLabel(v);
|
||||
int destIfNull = jumpIfNull ? dest : destIfFalse;
|
||||
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
|
||||
sqlite3VdbeAddGoto(v, dest);
|
||||
sqlite3VdbeGoto(v, dest);
|
||||
sqlite3VdbeResolveLabel(v, destIfFalse);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
if( exprAlwaysTrue(pExpr) ){
|
||||
sqlite3VdbeAddGoto(v, dest);
|
||||
sqlite3VdbeGoto(v, dest);
|
||||
}else if( exprAlwaysFalse(pExpr) ){
|
||||
/* No-op */
|
||||
}else{
|
||||
@ -3689,7 +3689,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
#endif
|
||||
default: {
|
||||
if( exprAlwaysFalse(pExpr) ){
|
||||
sqlite3VdbeAddGoto(v, dest);
|
||||
sqlite3VdbeGoto(v, dest);
|
||||
}else if( exprAlwaysTrue(pExpr) ){
|
||||
/* no-op */
|
||||
}else{
|
||||
|
@ -374,7 +374,7 @@ static void fkLookupParent(
|
||||
|
||||
sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
|
||||
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, iOk);
|
||||
sqlite3VdbeGoto(v, iOk);
|
||||
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
|
||||
sqlite3VdbeJumpHere(v, iMustBeInt);
|
||||
sqlite3ReleaseTempReg(pParse, regTemp);
|
||||
@ -412,7 +412,7 @@ static void fkLookupParent(
|
||||
sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); VdbeCoverage(v);
|
||||
sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);
|
||||
}
|
||||
sqlite3VdbeAddGoto(v, iOk);
|
||||
sqlite3VdbeGoto(v, iOk);
|
||||
}
|
||||
|
||||
sqlite3VdbeAddOp4(v, OP_MakeRecord, regTemp, nCol, regRec,
|
||||
|
16
src/insert.c
16
src/insert.c
@ -259,14 +259,14 @@ void sqlite3AutoincrementBegin(Parse *pParse){
|
||||
sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);
|
||||
sqlite3VdbeAddOp3(v, OP_Null, 0, memId, memId+1);
|
||||
addr = sqlite3VdbeCurrentAddr(v);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, p->pTab->zName, 0);
|
||||
sqlite3VdbeLoadString(v, memId-1, p->pTab->zName);
|
||||
sqlite3VdbeAddOp2(v, OP_Rewind, 0, addr+9); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp3(v, OP_Column, 0, 0, memId);
|
||||
sqlite3VdbeAddOp3(v, OP_Ne, memId-1, addr+7, memId); VdbeCoverage(v);
|
||||
sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);
|
||||
sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId+1);
|
||||
sqlite3VdbeAddOp3(v, OP_Column, 0, 1, memId);
|
||||
sqlite3VdbeAddGoto(v, addr+9);
|
||||
sqlite3VdbeGoto(v, addr+9);
|
||||
sqlite3VdbeAddOp2(v, OP_Next, 0, addr+2); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, 0, memId);
|
||||
sqlite3VdbeAddOp0(v, OP_Close);
|
||||
@ -690,7 +690,7 @@ void sqlite3Insert(
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec);
|
||||
sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid);
|
||||
sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid);
|
||||
sqlite3VdbeAddGoto(v, addrL);
|
||||
sqlite3VdbeGoto(v, addrL);
|
||||
sqlite3VdbeJumpHere(v, addrL);
|
||||
sqlite3ReleaseTempReg(pParse, regRec);
|
||||
sqlite3ReleaseTempReg(pParse, regTempRowid);
|
||||
@ -991,7 +991,7 @@ void sqlite3Insert(
|
||||
sqlite3VdbeJumpHere(v, addrInsTop);
|
||||
sqlite3VdbeAddOp1(v, OP_Close, srcTab);
|
||||
}else if( pSelect ){
|
||||
sqlite3VdbeAddGoto(v, addrCont);
|
||||
sqlite3VdbeGoto(v, addrCont);
|
||||
sqlite3VdbeJumpHere(v, addrInsTop);
|
||||
}
|
||||
|
||||
@ -1238,7 +1238,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
int allOk = sqlite3VdbeMakeLabel(v);
|
||||
sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
|
||||
if( onError==OE_Ignore ){
|
||||
sqlite3VdbeAddGoto(v, ignoreDest);
|
||||
sqlite3VdbeGoto(v, ignoreDest);
|
||||
}else{
|
||||
char *zName = pCheck->a[i].zName;
|
||||
if( zName==0 ) zName = pTab->zName;
|
||||
@ -1346,7 +1346,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
}
|
||||
case OE_Ignore: {
|
||||
/*assert( seenReplace==0 );*/
|
||||
sqlite3VdbeAddGoto(v, ignoreDest);
|
||||
sqlite3VdbeGoto(v, ignoreDest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1499,7 +1499,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
break;
|
||||
}
|
||||
case OE_Ignore: {
|
||||
sqlite3VdbeAddGoto(v, ignoreDest);
|
||||
sqlite3VdbeGoto(v, ignoreDest);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -1520,7 +1520,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);
|
||||
}
|
||||
if( ipkTop ){
|
||||
sqlite3VdbeAddGoto(v, ipkTop+1);
|
||||
sqlite3VdbeGoto(v, ipkTop+1);
|
||||
sqlite3VdbeJumpHere(v, ipkBottom);
|
||||
}
|
||||
|
||||
|
152
src/pragma.c
152
src/pragma.c
@ -195,7 +195,7 @@ static void returnSingleText(
|
||||
const char *zValue /* Value to be returned */
|
||||
){
|
||||
if( zValue ){
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, (const char*)zValue, 0);
|
||||
sqlite3VdbeLoadString(v, 1, (const char*)zValue);
|
||||
setOneColumnName(v, zLabel);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
|
||||
}
|
||||
@ -1015,23 +1015,13 @@ void sqlite3Pragma(
|
||||
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
|
||||
pParse->nMem = 6;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
setAllColumnNames(v, 6, azCol);
|
||||
setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) );
|
||||
sqlite3ViewGetColumnNames(pParse, pTab);
|
||||
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
|
||||
if( IsHiddenColumn(pCol) ){
|
||||
nHidden++;
|
||||
continue;
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i-nHidden, 1);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
|
||||
pCol->zType ? pCol->zType : "", 0);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4);
|
||||
if( pCol->zDflt ){
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pCol->zDflt, 0);
|
||||
}else{
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, 5);
|
||||
}
|
||||
if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
|
||||
k = 0;
|
||||
}else if( pPk==0 ){
|
||||
@ -1039,7 +1029,13 @@ void sqlite3Pragma(
|
||||
}else{
|
||||
for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, k, 6);
|
||||
sqlite3VdbeMultiLoad(v, 1, "issisi",
|
||||
i-nHidden,
|
||||
pCol->zName,
|
||||
pCol->zType ? pCol->zType : "",
|
||||
pCol->notNull ? 1 : 0,
|
||||
pCol->zDflt,
|
||||
k);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
|
||||
}
|
||||
}
|
||||
@ -1053,22 +1049,20 @@ void sqlite3Pragma(
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
pParse->nMem = 4;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
setAllColumnNames(v, 4, azCol);
|
||||
setAllColumnNames(v, 4, azCol); assert( 4==ArraySize(azCol) );
|
||||
for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
|
||||
Table *pTab = sqliteHashData(i);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer,
|
||||
(int)sqlite3LogEstToInt(pTab->szTabRow), 3);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer,
|
||||
(int)sqlite3LogEstToInt(pTab->nRowLogEst), 4);
|
||||
sqlite3VdbeMultiLoad(v, 1, "ssii",
|
||||
pTab->zName,
|
||||
0,
|
||||
(int)sqlite3LogEstToInt(pTab->szTabRow),
|
||||
(int)sqlite3LogEstToInt(pTab->nRowLogEst));
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
|
||||
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer,
|
||||
(int)sqlite3LogEstToInt(pIdx->szIdxRow), 3);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer,
|
||||
(int)sqlite3LogEstToInt(pIdx->aiRowLogEst[0]), 4);
|
||||
sqlite3VdbeMultiLoad(v, 2, "sii",
|
||||
pIdx->zName,
|
||||
(int)sqlite3LogEstToInt(pIdx->szIdxRow),
|
||||
(int)sqlite3LogEstToInt(pIdx->aiRowLogEst[0]));
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
|
||||
}
|
||||
}
|
||||
@ -1096,20 +1090,17 @@ void sqlite3Pragma(
|
||||
}
|
||||
pTab = pIdx->pTable;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
assert( pParse->nMem<=ArraySize(azCol) );
|
||||
setAllColumnNames(v, pParse->nMem, azCol);
|
||||
for(i=0; i<mx; i++){
|
||||
i16 cnum = pIdx->aiColumn[i];
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);
|
||||
if( cnum<0 ){
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, 3);
|
||||
}else{
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
|
||||
}
|
||||
sqlite3VdbeMultiLoad(v, 1, "iis", i, cnum,
|
||||
cnum<0 ? 0 : pTab->aCol[cnum].zName);
|
||||
if( pPragma->iArg ){
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6);
|
||||
sqlite3VdbeMultiLoad(v, 4, "isi",
|
||||
pIdx->aSortOrder[i],
|
||||
pIdx->azColl[i],
|
||||
i<pIdx->nKeyCol);
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
|
||||
}
|
||||
@ -1129,14 +1120,15 @@ void sqlite3Pragma(
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
pParse->nMem = 5;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
setAllColumnNames(v, 5, azCol);
|
||||
setAllColumnNames(v, 5, azCol); assert( 5==ArraySize(azCol) );
|
||||
for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
|
||||
const char *azOrigin[] = { "c", "u", "pk" };
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, IsUniqueIndex(pIdx), 3);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, azOrigin[pIdx->idxType], 0);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->pPartIdxWhere!=0, 5);
|
||||
sqlite3VdbeMultiLoad(v, 1, "isisi",
|
||||
i,
|
||||
pIdx->zName,
|
||||
IsUniqueIndex(pIdx),
|
||||
azOrigin[pIdx->idxType],
|
||||
pIdx->pPartIdxWhere!=0);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
|
||||
}
|
||||
}
|
||||
@ -1147,14 +1139,14 @@ void sqlite3Pragma(
|
||||
static const char *azCol[] = { "seq", "name", "file" };
|
||||
int i;
|
||||
pParse->nMem = 3;
|
||||
setAllColumnNames(v, 3, azCol);
|
||||
setAllColumnNames(v, 3, azCol); assert( 3==ArraySize(azCol) );
|
||||
for(i=0; i<db->nDb; i++){
|
||||
if( db->aDb[i].pBt==0 ) continue;
|
||||
assert( db->aDb[i].zName!=0 );
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, db->aDb[i].zName, 0);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
|
||||
sqlite3BtreeGetFilename(db->aDb[i].pBt), 0);
|
||||
sqlite3VdbeMultiLoad(v, 1, "iss",
|
||||
i,
|
||||
db->aDb[i].zName,
|
||||
sqlite3BtreeGetFilename(db->aDb[i].pBt));
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
|
||||
}
|
||||
}
|
||||
@ -1165,11 +1157,10 @@ void sqlite3Pragma(
|
||||
int i = 0;
|
||||
HashElem *p;
|
||||
pParse->nMem = 2;
|
||||
setAllColumnNames(v, 2, azCol);
|
||||
setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) );
|
||||
for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){
|
||||
CollSeq *pColl = (CollSeq *)sqliteHashData(p);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i++, 1);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pColl->zName, 0);
|
||||
sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
|
||||
}
|
||||
}
|
||||
@ -1192,22 +1183,19 @@ void sqlite3Pragma(
|
||||
int i = 0;
|
||||
pParse->nMem = 8;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
setAllColumnNames(v, 8, azCol);
|
||||
setAllColumnNames(v, 8, azCol); assert( 8==ArraySize(azCol) );
|
||||
while(pFK){
|
||||
int j;
|
||||
for(j=0; j<pFK->nCol; j++){
|
||||
char *zCol = pFK->aCol[j].zCol;
|
||||
char *zOnDelete = (char *)actionName(pFK->aAction[0]);
|
||||
char *zOnUpdate = (char *)actionName(pFK->aAction[1]);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, j, 2);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
|
||||
pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
|
||||
sqlite3VdbeAddOp4(v, zCol ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, "NONE", 0);
|
||||
sqlite3VdbeMultiLoad(v, 1, "iissssss",
|
||||
i,
|
||||
j,
|
||||
pFK->zTo,
|
||||
pTab->aCol[pFK->aCol[j].iFrom].zName,
|
||||
pFK->aCol[j].zCol,
|
||||
actionName(pFK->aAction[1]), /* ON UPDATE */
|
||||
actionName(pFK->aAction[0]), /* ON DELETE */
|
||||
"NONE");
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8);
|
||||
}
|
||||
++i;
|
||||
@ -1243,7 +1231,7 @@ void sqlite3Pragma(
|
||||
regKey = ++pParse->nMem;
|
||||
regRow = ++pParse->nMem;
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
setAllColumnNames(v, 4, azCol);
|
||||
setAllColumnNames(v, 4, azCol); assert( 4==ArraySize(azCol) );
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash);
|
||||
while( k ){
|
||||
@ -1258,8 +1246,7 @@ void sqlite3Pragma(
|
||||
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
|
||||
if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
|
||||
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
|
||||
P4_TRANSIENT);
|
||||
sqlite3VdbeLoadString(v, regResult, pTab->zName);
|
||||
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
pParent = sqlite3FindTable(db, pFK->zTo, zDb);
|
||||
if( pParent==0 ) continue;
|
||||
@ -1304,7 +1291,7 @@ void sqlite3Pragma(
|
||||
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);
|
||||
}
|
||||
sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, addrOk);
|
||||
sqlite3VdbeGoto(v, addrOk);
|
||||
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
|
||||
}else{
|
||||
for(j=0; j<pFK->nCol; j++){
|
||||
@ -1320,9 +1307,7 @@ void sqlite3Pragma(
|
||||
}
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
|
||||
pFK->zTo, P4_TRANSIENT);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
|
||||
sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);
|
||||
sqlite3VdbeResolveLabel(v, addrOk);
|
||||
sqlite3DbFree(db, aiCols);
|
||||
@ -1520,13 +1505,11 @@ void sqlite3Pragma(
|
||||
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
|
||||
pIdx->nColumn); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, "row ", P4_STATIC);
|
||||
sqlite3VdbeLoadString(v, 3, "row ");
|
||||
sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
|
||||
" missing from index ", P4_STATIC);
|
||||
sqlite3VdbeLoadString(v, 4, " missing from index ");
|
||||
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
|
||||
jmp5 = sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
|
||||
pIdx->zName, P4_TRANSIENT);
|
||||
jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
|
||||
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);
|
||||
jmp4 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); VdbeCoverage(v);
|
||||
@ -1547,14 +1530,13 @@ void sqlite3Pragma(
|
||||
VdbeCoverage(v);
|
||||
}
|
||||
jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, uniqOk);
|
||||
sqlite3VdbeGoto(v, uniqOk);
|
||||
sqlite3VdbeJumpHere(v, jmp6);
|
||||
sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,
|
||||
pIdx->nKeyCol); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
|
||||
"non-unique entry in index ", P4_STATIC);
|
||||
sqlite3VdbeAddGoto(v, jmp5);
|
||||
sqlite3VdbeLoadString(v, 3, "non-unique entry in index ");
|
||||
sqlite3VdbeGoto(v, jmp5);
|
||||
sqlite3VdbeResolveLabel(v, uniqOk);
|
||||
}
|
||||
sqlite3VdbeJumpHere(v, jmp4);
|
||||
@ -1563,8 +1545,7 @@ void sqlite3Pragma(
|
||||
sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
|
||||
sqlite3VdbeJumpHere(v, loopTop-1);
|
||||
#ifndef SQLITE_OMIT_BTREECOUNT
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
|
||||
"wrong # of entries in index ", P4_STATIC);
|
||||
sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
|
||||
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
|
||||
if( pPk==pIdx ) continue;
|
||||
addr = sqlite3VdbeCurrentAddr(v);
|
||||
@ -1574,7 +1555,7 @@ void sqlite3Pragma(
|
||||
sqlite3VdbeAddOp3(v, OP_Eq, 8+j, addr+8, 3); VdbeCoverage(v);
|
||||
sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
|
||||
sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
|
||||
sqlite3VdbeLoadString(v, 3, pIdx->zName);
|
||||
sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
|
||||
}
|
||||
@ -1737,7 +1718,7 @@ void sqlite3Pragma(
|
||||
pParse->nMem = 1;
|
||||
setOneColumnName(v, "compile_option");
|
||||
while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0);
|
||||
sqlite3VdbeLoadString(v, 1, zOpt);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
|
||||
}
|
||||
}
|
||||
@ -1763,7 +1744,7 @@ void sqlite3Pragma(
|
||||
eMode = SQLITE_CHECKPOINT_TRUNCATE;
|
||||
}
|
||||
}
|
||||
setAllColumnNames(v, 3, azCol);
|
||||
setAllColumnNames(v, 3, azCol); assert( 3==ArraySize(azCol) );
|
||||
pParse->nMem = 3;
|
||||
sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
|
||||
@ -1869,14 +1850,13 @@ void sqlite3Pragma(
|
||||
};
|
||||
static const char *azCol[] = { "database", "status" };
|
||||
int i;
|
||||
setAllColumnNames(v, 2, azCol);
|
||||
setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) );
|
||||
pParse->nMem = 2;
|
||||
for(i=0; i<db->nDb; i++){
|
||||
Btree *pBt;
|
||||
const char *zState = "unknown";
|
||||
int j;
|
||||
if( db->aDb[i].zName==0 ) continue;
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC);
|
||||
pBt = db->aDb[i].pBt;
|
||||
if( pBt==0 || sqlite3BtreePager(pBt)==0 ){
|
||||
zState = "closed";
|
||||
@ -1884,7 +1864,7 @@ void sqlite3Pragma(
|
||||
SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
|
||||
zState = azLockName[j];
|
||||
}
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC);
|
||||
sqlite3VdbeMultiLoad(v, 1, "ss", db->aDb[i].zName, zState);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
|
||||
}
|
||||
break;
|
||||
|
22
src/select.c
22
src/select.c
@ -597,7 +597,7 @@ static void codeOffset(
|
||||
if( iOffset>0 ){
|
||||
int addr;
|
||||
addr = sqlite3VdbeAddOp3(v, OP_IfNeg, iOffset, 0, -1); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, iContinue);
|
||||
sqlite3VdbeGoto(v, iContinue);
|
||||
VdbeComment((v, "skip OFFSET records"));
|
||||
sqlite3VdbeJumpHere(v, addr);
|
||||
}
|
||||
@ -1206,7 +1206,7 @@ static void generateSortTail(
|
||||
|
||||
if( pSort->labelBkOut ){
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
|
||||
sqlite3VdbeAddGoto(v, addrBreak);
|
||||
sqlite3VdbeGoto(v, addrBreak);
|
||||
sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
|
||||
}
|
||||
iTab = pSort->iECursor;
|
||||
@ -1834,7 +1834,7 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);
|
||||
VdbeComment((v, "LIMIT counter"));
|
||||
if( n==0 ){
|
||||
sqlite3VdbeAddGoto(v, iBreak);
|
||||
sqlite3VdbeGoto(v, iBreak);
|
||||
}else if( n>=0 && p->nSelectRow>(u64)n ){
|
||||
p->nSelectRow = n;
|
||||
}
|
||||
@ -2082,7 +2082,7 @@ static void generateWithRecursiveQuery(
|
||||
}
|
||||
|
||||
/* Keep running the loop until the Queue is empty */
|
||||
sqlite3VdbeAddGoto(v, addrTop);
|
||||
sqlite3VdbeGoto(v, addrTop);
|
||||
sqlite3VdbeResolveLabel(v, addrBreak);
|
||||
|
||||
end_of_recursive_query:
|
||||
@ -2991,7 +2991,7 @@ static int multiSelectOrderBy(
|
||||
addrEofA = sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);
|
||||
addrEofA_noB = sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, labelEnd);
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, addrEofA);
|
||||
sqlite3VdbeGoto(v, addrEofA);
|
||||
p->nSelectRow += pPrior->nSelectRow;
|
||||
}
|
||||
|
||||
@ -3005,7 +3005,7 @@ static int multiSelectOrderBy(
|
||||
VdbeNoopComment((v, "eof-B subroutine"));
|
||||
addrEofB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);
|
||||
sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, labelEnd); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, addrEofB);
|
||||
sqlite3VdbeGoto(v, addrEofB);
|
||||
}
|
||||
|
||||
/* Generate code to handle the case of A<B
|
||||
@ -3013,7 +3013,7 @@ static int multiSelectOrderBy(
|
||||
VdbeNoopComment((v, "A-lt-B subroutine"));
|
||||
addrAltB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);
|
||||
sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, labelCmpr);
|
||||
sqlite3VdbeGoto(v, labelCmpr);
|
||||
|
||||
/* Generate code to handle the case of A==B
|
||||
*/
|
||||
@ -3026,7 +3026,7 @@ static int multiSelectOrderBy(
|
||||
VdbeNoopComment((v, "A-eq-B subroutine"));
|
||||
addrAeqB =
|
||||
sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, labelCmpr);
|
||||
sqlite3VdbeGoto(v, labelCmpr);
|
||||
}
|
||||
|
||||
/* Generate code to handle the case of A>B
|
||||
@ -3037,7 +3037,7 @@ static int multiSelectOrderBy(
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);
|
||||
sqlite3VdbeAddGoto(v, labelCmpr);
|
||||
sqlite3VdbeGoto(v, labelCmpr);
|
||||
|
||||
/* This code runs once to initialize everything.
|
||||
*/
|
||||
@ -5403,7 +5403,7 @@ int sqlite3Select(
|
||||
|
||||
/* Jump over the subroutines
|
||||
*/
|
||||
sqlite3VdbeAddGoto(v, addrEnd);
|
||||
sqlite3VdbeGoto(v, addrEnd);
|
||||
|
||||
/* Generate a subroutine that outputs a single row of the result
|
||||
** set. This subroutine first looks at the iUseFlag. If iUseFlag
|
||||
@ -5557,7 +5557,7 @@ int sqlite3Select(
|
||||
updateAccumulator(pParse, &sAggInfo);
|
||||
assert( pMinMax==0 || pMinMax->nExpr==1 );
|
||||
if( sqlite3WhereIsOrdered(pWInfo)>0 ){
|
||||
sqlite3VdbeAddGoto(v, sqlite3WhereBreakLabel(pWInfo));
|
||||
sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));
|
||||
VdbeComment((v, "%s() by index",
|
||||
(flag==WHERE_ORDERBY_MIN?"min":"max")));
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ void sqlite3Update(
|
||||
sqlite3VdbeResolveLabel(v, labelContinue);
|
||||
sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v);
|
||||
}else{
|
||||
sqlite3VdbeAddGoto(v, labelContinue);
|
||||
sqlite3VdbeGoto(v, labelContinue);
|
||||
}
|
||||
sqlite3VdbeResolveLabel(v, labelBreak);
|
||||
|
||||
|
@ -169,7 +169,9 @@ Vdbe *sqlite3VdbeCreate(Parse*);
|
||||
int sqlite3VdbeAddOp0(Vdbe*,int);
|
||||
int sqlite3VdbeAddOp1(Vdbe*,int,int);
|
||||
int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
|
||||
int sqlite3VdbeAddGoto(Vdbe*,int);
|
||||
int sqlite3VdbeGoto(Vdbe*,int);
|
||||
int sqlite3VdbeLoadString(Vdbe*,int,const char*);
|
||||
void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);
|
||||
int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
|
||||
int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
|
||||
int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
|
||||
|
@ -214,10 +214,45 @@ int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){
|
||||
int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){
|
||||
return sqlite3VdbeAddOp3(p, op, p1, p2, 0);
|
||||
}
|
||||
int sqlite3VdbeAddGoto(Vdbe *p, int iDest){
|
||||
|
||||
/* Generate code for an unconditional jump to instruction iDest
|
||||
*/
|
||||
int sqlite3VdbeGoto(Vdbe *p, int iDest){
|
||||
return sqlite3VdbeAddOp3(p, OP_Goto, 0, iDest, 0);
|
||||
}
|
||||
|
||||
/* Generate code to cause the string zStr to be loaded into
|
||||
** register iDest
|
||||
*/
|
||||
int sqlite3VdbeLoadString(Vdbe *p, int iDest, const char *zStr){
|
||||
return sqlite3VdbeAddOp4(p, OP_String8, 0, iDest, 0, zStr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** Generate code that initializes multiple registers to string or integer
|
||||
** constants. The registers begin with iDest and increase consecutively.
|
||||
** One register is initialized for each characgter in zTypes[]. For each
|
||||
** "s" character in zTypes[], the register is a string if the argument is
|
||||
** not NULL, or OP_Null if the value is a null pointer. For each "i" character
|
||||
** in zTypes[], the register is initialized to an integer.
|
||||
*/
|
||||
void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
|
||||
va_list ap;
|
||||
int i;
|
||||
char c;
|
||||
va_start(ap, zTypes);
|
||||
for(i=0; (c = zTypes[i])!=0; i++){
|
||||
if( c=='s' ){
|
||||
const char *z = va_arg(ap, const char*);
|
||||
int addr = sqlite3VdbeAddOp2(p, z==0 ? OP_Null : OP_String8, 0, iDest++);
|
||||
if( z ) sqlite3VdbeChangeP4(p, addr, z, 0);
|
||||
}else{
|
||||
assert( c=='i' );
|
||||
sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest++);
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
** Add an opcode that includes the p4 value as a pointer.
|
||||
|
@ -423,7 +423,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
||||
sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
|
||||
|
||||
iReg = ++pParse->nMem;
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, iReg, 0, pTab->zName, 0);
|
||||
sqlite3VdbeLoadString(v, iReg, pTab->zName);
|
||||
sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,7 @@ static void constructAutomaticIndex(
|
||||
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
|
||||
if( pTabItem->fg.viaCoroutine ){
|
||||
translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult);
|
||||
sqlite3VdbeAddGoto(v, addrTop);
|
||||
sqlite3VdbeGoto(v, addrTop);
|
||||
pTabItem->fg.viaCoroutine = 0;
|
||||
}else{
|
||||
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
|
||||
@ -4386,7 +4386,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
}
|
||||
sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
|
||||
if( pLevel->addrSkip ){
|
||||
sqlite3VdbeAddGoto(v, pLevel->addrSkip);
|
||||
sqlite3VdbeGoto(v, pLevel->addrSkip);
|
||||
VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
|
||||
sqlite3VdbeJumpHere(v, pLevel->addrSkip);
|
||||
sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
|
||||
@ -4414,7 +4414,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
if( pLevel->op==OP_Return ){
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
|
||||
}else{
|
||||
sqlite3VdbeAddGoto(v, pLevel->addrFirst);
|
||||
sqlite3VdbeGoto(v, pLevel->addrFirst);
|
||||
}
|
||||
sqlite3VdbeJumpHere(v, addr);
|
||||
}
|
||||
|
@ -1375,7 +1375,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
sqlite3ExprDelete(db, pAndExpr);
|
||||
}
|
||||
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
|
||||
sqlite3VdbeAddGoto(v, pLevel->addrBrk);
|
||||
sqlite3VdbeGoto(v, pLevel->addrBrk);
|
||||
sqlite3VdbeResolveLabel(v, iLoopBody);
|
||||
|
||||
if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
|
||||
|
Loading…
Reference in New Issue
Block a user