Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c53688a1b | |||
| e7b554d615 | |||
| f4e994b23a | |||
| 68116939eb | |||
| 4cef5b1c81 | |||
| ad1d9a8707 | |||
| a67b5cb6b3 | |||
| e1ff3f5e11 | |||
| 1439a1e80f | |||
| 3d775e7586 | |||
| 817be73bfc | |||
| 2b64313b8d | |||
| 9e1ab1a8a4 | |||
| ac56ab7e48 | |||
| 5f40cebf43 | |||
| 34d04d64f0 | |||
| f9a12a106b | |||
| 801f55d837 | |||
| 4e1f0efb4d | |||
| 87e1e56b5b | |||
| b005f9e620 | |||
| 49c5ab243b | |||
| ad879ffdb5 | |||
| 1e9b53f9bc |
@@ -2039,7 +2039,7 @@ static void fts5SegIterNext(
|
||||
else if( pLeaf->nn>pLeaf->szLeaf ){
|
||||
pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(
|
||||
&pLeaf->p[pLeaf->szLeaf], iOff
|
||||
);
|
||||
);
|
||||
pIter->iLeafOffset = iOff;
|
||||
pIter->iEndofDoclist = iOff;
|
||||
bNewTerm = 1;
|
||||
@@ -2073,6 +2073,7 @@ static void fts5SegIterNext(
|
||||
*/
|
||||
int nSz;
|
||||
assert( p->rc==SQLITE_OK );
|
||||
assert( pIter->iLeafOffset<=pIter->pLeaf->nn );
|
||||
fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);
|
||||
pIter->bDel = (nSz & 0x0001);
|
||||
pIter->nPos = nSz>>1;
|
||||
@@ -3067,7 +3068,7 @@ static void fts5ChunkIterate(
|
||||
break;
|
||||
}else{
|
||||
pgno++;
|
||||
pData = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno));
|
||||
pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno));
|
||||
if( pData==0 ) break;
|
||||
pChunk = &pData->p[4];
|
||||
nChunk = MIN(nRem, pData->szLeaf - 4);
|
||||
@@ -5829,7 +5830,7 @@ static void fts5IndexIntegrityCheckSegment(
|
||||
** ignore this b-tree entry. Otherwise, load it into memory. */
|
||||
if( iIdxLeaf<pSeg->pgnoFirst ) continue;
|
||||
iRow = FTS5_SEGMENT_ROWID(pSeg->iSegid, iIdxLeaf);
|
||||
pLeaf = fts5DataRead(p, iRow);
|
||||
pLeaf = fts5LeafRead(p, iRow);
|
||||
if( pLeaf==0 ) break;
|
||||
|
||||
/* Check that the leaf contains at least one term, and that it is equal
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
C Changes\sto\sthe\sprintf\simplementation\sfor\sbetter\sperformance.
|
||||
D 2017-01-04T00:26:28.506
|
||||
C Try\sto\smove\sOP_Concat\soperations\soutside\sthe\sinner\sloop.\s\sThis\sturns\sout\nto\smake\sthings\svery\sslightly\sslower,\sat\sleast\sin\sspeedtest1.c.
|
||||
D 2017-01-09T18:20:45.545
|
||||
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
|
||||
@@ -104,7 +104,7 @@ F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd
|
||||
F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857
|
||||
F ext/fts5/fts5_expr.c dc2cee9f56b1818b85df59304b8104a5dfb8ab60
|
||||
F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2
|
||||
F ext/fts5/fts5_index.c fdbe46da11e81c1817cd4cb2de25ffdb4dd83711
|
||||
F ext/fts5/fts5_index.c f67032a9a529ba52a545e6e3ab970764199c05d4
|
||||
F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2
|
||||
F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58
|
||||
F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a
|
||||
@@ -340,8 +340,8 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a
|
||||
F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e
|
||||
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
|
||||
F src/delete.c c8bc10d145c9666a34ae906250326fdaa8d58fa5
|
||||
F src/expr.c 449cbb8b9857ff8eb685b72555086818a178858c
|
||||
F src/delete.c a84f6229ccb9448460c287248024ceb70e10baab
|
||||
F src/expr.c e559c6c1a0a0709aa056ea919dae0430956b890e
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae
|
||||
F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b
|
||||
@@ -350,7 +350,7 @@ F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd
|
||||
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
|
||||
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 91ba5d0143e66479081536ebbaff1850ec9f57d9
|
||||
F src/insert.c 7761fd63136771d411f096f4d7a1af9c5057ddd4
|
||||
F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
|
||||
F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d
|
||||
F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0
|
||||
@@ -381,19 +381,19 @@ F src/parse.y 29153738a7322054359320eb00b5a4cd44389f20
|
||||
F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e
|
||||
F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490
|
||||
F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953
|
||||
F src/pragma.c 5a23557e490e7ac5afef097efc4b59dce5b482c2
|
||||
F src/pragma.h f9b221b2c8949ea941dbee49934299e4ed5af41c
|
||||
F src/pragma.c 0e7a7c6f1c6fd8ff50c0fff65b8bb80174bc49c5
|
||||
F src/pragma.h 61aa5389118594bebb28120a6720401aee34ce1a
|
||||
F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a
|
||||
F src/printf.c ff10a9b9902cd2afe5f655f3013c6307d969b1fd
|
||||
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c bb070cf5f23611c44ab7e4788803684e385fc3fb
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c dfb6cadc3dcfba1b1bdbfba62ebba2b4b673413e
|
||||
F src/select.c 533e55a4067278fef76eff951462383d4147880f
|
||||
F src/shell.c 6095531aa900decdaa765e0f3993fba7153c92c1
|
||||
F src/sqlite.h.in e8e2d108d82647f0a812fdb74accf91c1ec08ddc
|
||||
F src/sqlite.h.in e71655293c9bde26939496f3aac9d1821d2c07a2
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
|
||||
F src/sqliteInt.h f3450b70cfd99b434304225cf3b95de9cb4a9536
|
||||
F src/sqliteInt.h 9fdfb8789b27a621f3401468bc1705c32308f877
|
||||
F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
|
||||
F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
|
||||
F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
|
||||
@@ -437,7 +437,7 @@ F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d
|
||||
F src/test_rtree.c 671f3fae50ff116ef2e32a3bf1fe21b5615b4b7b
|
||||
F src/test_schema.c f575932cb6274d12147a77e13ea4b49d52408513
|
||||
F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe
|
||||
F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b
|
||||
F src/test_sqllog.c 11e6ce7575f489155c604ac4b439f2ac1d3d5aef
|
||||
F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e
|
||||
F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
|
||||
F src/test_tclvar.c df9fe1213c2634687a9ca0b0bec0d2119d359ae3
|
||||
@@ -455,13 +455,13 @@ F src/update.c 1da7c462110bffed442a42884cb0d528c1db46d8
|
||||
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
|
||||
F src/util.c a88b0466fddf445ce752226d4698ca3faada620a
|
||||
F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16
|
||||
F src/vdbe.c 88bd6c32b333580d2661ac3afe33369757fb1522
|
||||
F src/vdbe.h 50ee139f9c68fff91be1d717ed3a6abbd496919c
|
||||
F src/vdbe.c b7f39cec8b572df61cdbd26426e285f8fd759db3
|
||||
F src/vdbe.h b0866e4191f096f1c987a84b042c3599bdf5423b
|
||||
F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e
|
||||
F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24
|
||||
F src/vdbeaux.c 12919c5aa354296d6b9ba808bca3e9dda836858c
|
||||
F src/vdbeaux.c 35c9a9908174e5a26c96d15e1f98214814a39147
|
||||
F src/vdbeblob.c f4f98ea672b242f807c08c92c7faaa79e5091b65
|
||||
F src/vdbemem.c d3fd85b7b7ef3eb75de29c6d7e1d10d3ca78b4fd
|
||||
F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd
|
||||
F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face
|
||||
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
|
||||
F src/vtab.c c4bbe0f870f52036553f8098aee0703997f0577a
|
||||
@@ -692,7 +692,7 @@ F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
|
||||
F test/fkey5.test 5a373303f201ac03c22ba1ef17a733d3f56e611a
|
||||
F test/fkey6.test d078a1e323a740062bed38df32b8a736fd320dc0
|
||||
F test/fkey7.test 72e915890ee4a005daaf3002cb208e8fe973ac13
|
||||
F test/fkey8.test 7bd1dd0174a0e29a90c62c517b9e2a410a0b345d
|
||||
F test/fkey8.test e5372e32cdb4481f121ec3550703eeb7b4e0762c
|
||||
F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749
|
||||
F test/fordelete.test eb93a2f34137bb87bdab88fcab06c0bd92719aff
|
||||
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
|
||||
@@ -1010,6 +1010,7 @@ F test/permutations.test cd0b7bc04bf5e50d3a993d24c834d591f7d4f5fe
|
||||
F test/pragma.test 1e94755164a3a3264cd39836de4bebcb7809e5f8
|
||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||
F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
|
||||
F test/pragma4.test 6e85b6eab8e61ffc9c7db59d842276674e8e3264
|
||||
F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc
|
||||
F test/printf2.test 0b61566dd1c0f0b802f59dffa228c5dc5aa6b054
|
||||
F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb
|
||||
@@ -1073,7 +1074,7 @@ F test/select8.test 8c8f5ae43894c891efc5755ed905467d1d67ad5d
|
||||
F test/select9.test aebc2bb0c3bc44606125033cbcaac2c8d1f33a95
|
||||
F test/selectA.test 101e722370ac6e84978c2958b8931c78b10a1709
|
||||
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
|
||||
F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977
|
||||
F test/selectC.test e25243f8ca503e06f252eb0218976d07cfeceac3
|
||||
F test/selectD.test b0f02a04ef7737decb24e08be2c39b9664b43394
|
||||
F test/selectE.test a8730ca330fcf40ace158f134f4fe0eb00c7edbf
|
||||
F test/selectF.test 21c94e6438f76537b72532fa9fd4710cdd455fc3
|
||||
@@ -1336,6 +1337,7 @@ F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe
|
||||
F test/triggerC.test 302d8995f5ffe63bbc15053abb3ef7a39cf5a092
|
||||
F test/triggerD.test 8e7f3921a92a5797d472732108109e44575fa650
|
||||
F test/triggerE.test 15fa63f1097db1f83dd62d121616006978063d1f
|
||||
F test/triggerF.test 55b1eb13433997faac3a4948c1d8252f6c8c636b
|
||||
F test/tt3_checkpoint.c 9e75cf7c1c364f52e1c47fd0f14c4340a9db0fe1
|
||||
F test/tt3_index.c 39eec10a35f57672225be4d182862152896dee4a
|
||||
F test/tt3_lookaside1.c 0377e202c3c2a50d688cb65ba203afeda6fafeb9
|
||||
@@ -1479,7 +1481,7 @@ F tool/mkmsvcmin.tcl 2f12f7fa8858bbe61cf81820a2da96c79ed1ca8d
|
||||
F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
|
||||
F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
|
||||
F tool/mkpragmatab.tcl a30ee93515135466fc49ae881f75da07ebcafd19
|
||||
F tool/mkpragmatab.tcl ebb4bfcd2f8010e0a3934b6118db4b5f2f5edf5c
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb
|
||||
F tool/mksqlite3c.tcl 06b2e6a0f21cc0a5d70fbbd136b3e0a96470645e
|
||||
@@ -1541,10 +1543,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P d3ac32a6e7f1823450feb3d1089802542090d164
|
||||
R 1c116e0d91d0fafdc790fe63a7695a8d
|
||||
T *branch * printf-optimization
|
||||
T *sym-printf-optimization *
|
||||
P 6e106acd74da3baa5c308a76443d2f0a7c904e5e
|
||||
R 9f6dfb3523e9de7aca6ed8bcaf1ea804
|
||||
T *branch * failed-optimization
|
||||
T *sym-failed-optimization *
|
||||
T -sym-trunk *
|
||||
U drh
|
||||
Z 6815c125f61af9819176bed00aaf68bc
|
||||
Z 56c063ac5b216f23ecc2133640602b56
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
acdb8f6f10953ed4290aadc9e026edd57d1dd21a
|
||||
8a90f69139f7014ed53303814772f9f3efbc4f79
|
||||
+17
-14
@@ -519,12 +519,8 @@ void sqlite3DeleteFrom(
|
||||
#endif
|
||||
{
|
||||
int count = (pParse->nested==0); /* True to count changes */
|
||||
int iIdxNoSeek = -1;
|
||||
if( bComplex==0 && aiCurOnePass[1]!=iDataCur ){
|
||||
iIdxNoSeek = aiCurOnePass[1];
|
||||
}
|
||||
sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
|
||||
iKey, nKey, count, OE_Default, eOnePass, iIdxNoSeek);
|
||||
iKey, nKey, count, OE_Default, eOnePass, aiCurOnePass[1]);
|
||||
}
|
||||
|
||||
/* End of the loop over all rowids/primary-keys. */
|
||||
@@ -604,15 +600,17 @@ delete_from_cleanup:
|
||||
**
|
||||
** If eMode is ONEPASS_MULTI, then this call is being made as part
|
||||
** of a ONEPASS delete that affects multiple rows. In this case, if
|
||||
** iIdxNoSeek is a valid cursor number (>=0), then its position should
|
||||
** be preserved following the delete operation. Or, if iIdxNoSeek is not
|
||||
** a valid cursor number, the position of iDataCur should be preserved
|
||||
** instead.
|
||||
** iIdxNoSeek is a valid cursor number (>=0) and is not the same as
|
||||
** iDataCur, then its position should be preserved following the delete
|
||||
** operation. Or, if iIdxNoSeek is not a valid cursor number, the
|
||||
** position of iDataCur should be preserved instead.
|
||||
**
|
||||
** iIdxNoSeek:
|
||||
** If iIdxNoSeek is a valid cursor number (>=0), then it identifies an
|
||||
** index cursor (from within array of cursors starting at iIdxCur) that
|
||||
** already points to the index entry to be deleted.
|
||||
** If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur,
|
||||
** then it identifies an index cursor (from within array of cursors
|
||||
** starting at iIdxCur) that already points to the index entry to be deleted.
|
||||
** Except, this optimization is disabled if there are BEFORE triggers since
|
||||
** the trigger body might have moved the cursor.
|
||||
*/
|
||||
void sqlite3GenerateRowDelete(
|
||||
Parse *pParse, /* Parsing context */
|
||||
@@ -683,13 +681,18 @@ void sqlite3GenerateRowDelete(
|
||||
|
||||
/* If any BEFORE triggers were coded, then seek the cursor to the
|
||||
** row to be deleted again. It may be that the BEFORE triggers moved
|
||||
** the cursor or of already deleted the row that the cursor was
|
||||
** the cursor or already deleted the row that the cursor was
|
||||
** pointing to.
|
||||
**
|
||||
** Also disable the iIdxNoSeek optimization since the BEFORE trigger
|
||||
** may have moved that cursor.
|
||||
*/
|
||||
if( addrStart<sqlite3VdbeCurrentAddr(v) ){
|
||||
sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
|
||||
VdbeCoverageIf(v, opSeek==OP_NotExists);
|
||||
VdbeCoverageIf(v, opSeek==OP_NotFound);
|
||||
testcase( iIdxNoSeek>=0 );
|
||||
iIdxNoSeek = -1;
|
||||
}
|
||||
|
||||
/* Do FK processing. This call checks that any FK constraints that
|
||||
@@ -716,7 +719,7 @@ void sqlite3GenerateRowDelete(
|
||||
if( eMode!=ONEPASS_OFF ){
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE);
|
||||
}
|
||||
if( iIdxNoSeek>=0 ){
|
||||
if( iIdxNoSeek>=0 && iIdxNoSeek!=iDataCur ){
|
||||
sqlite3VdbeAddOp1(v, OP_Delete, iIdxNoSeek);
|
||||
}
|
||||
if( eMode==ONEPASS_MULTI ) p5 |= OPFLAG_SAVEPOSITION;
|
||||
|
||||
+35
-20
@@ -3514,6 +3514,12 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TK_CONCAT: {
|
||||
if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
|
||||
/* Try to run CONCAT operations at outside the inner loop */
|
||||
return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
|
||||
}
|
||||
}
|
||||
case TK_AND:
|
||||
case TK_OR:
|
||||
case TK_PLUS:
|
||||
@@ -3524,8 +3530,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
case TK_BITOR:
|
||||
case TK_SLASH:
|
||||
case TK_LSHIFT:
|
||||
case TK_RSHIFT:
|
||||
case TK_CONCAT: {
|
||||
case TK_RSHIFT: {
|
||||
assert( TK_AND==OP_And ); testcase( op==TK_AND );
|
||||
assert( TK_OR==OP_Or ); testcase( op==TK_OR );
|
||||
assert( TK_PLUS==OP_Add ); testcase( op==TK_PLUS );
|
||||
@@ -3612,6 +3617,11 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
u8 enc = ENC(db); /* The text encoding used by this database */
|
||||
CollSeq *pColl = 0; /* A collating sequence */
|
||||
|
||||
if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
|
||||
/* SQL functions can be expensive. So try to move constant functions
|
||||
** out of the inner loop, even if that means an extra OP_Copy. */
|
||||
return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
|
||||
}
|
||||
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
|
||||
if( ExprHasProperty(pExpr, EP_TokenOnly) ){
|
||||
pFarg = 0;
|
||||
@@ -3992,24 +4002,40 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
|
||||
/*
|
||||
** Factor out the code of the given expression to initialization time.
|
||||
**
|
||||
** If regDest>=0 then the result is always stored in that register and the
|
||||
** result is not reusable. If regDest<0 then this routine is free to
|
||||
** store the value whereever it wants. The register where the expression
|
||||
** is stored is returned. When regDest<0, two identical expressions will
|
||||
** code to the same register.
|
||||
*/
|
||||
void sqlite3ExprCodeAtInit(
|
||||
int sqlite3ExprCodeAtInit(
|
||||
Parse *pParse, /* Parsing context */
|
||||
Expr *pExpr, /* The expression to code when the VDBE initializes */
|
||||
int regDest, /* Store the value in this register */
|
||||
u8 reusable /* True if this expression is reusable */
|
||||
int regDest /* Store the value in this register */
|
||||
){
|
||||
ExprList *p;
|
||||
assert( ConstFactorOk(pParse) );
|
||||
p = pParse->pConstExpr;
|
||||
if( regDest<0 && p ){
|
||||
struct ExprList_item *pItem;
|
||||
int i;
|
||||
for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
|
||||
if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
|
||||
return pItem->u.iConstExprReg;
|
||||
}
|
||||
}
|
||||
}
|
||||
pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
|
||||
p = sqlite3ExprListAppend(pParse, p, pExpr);
|
||||
if( p ){
|
||||
struct ExprList_item *pItem = &p->a[p->nExpr-1];
|
||||
pItem->reusable = regDest<0;
|
||||
if( regDest<0 ) regDest = ++pParse->nMem;
|
||||
pItem->u.iConstExprReg = regDest;
|
||||
pItem->reusable = reusable;
|
||||
}
|
||||
pParse->pConstExpr = p;
|
||||
return regDest;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4032,19 +4058,8 @@ int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
|
||||
&& pExpr->op!=TK_REGISTER
|
||||
&& sqlite3ExprIsConstantNotJoin(pExpr)
|
||||
){
|
||||
ExprList *p = pParse->pConstExpr;
|
||||
int i;
|
||||
*pReg = 0;
|
||||
if( p ){
|
||||
struct ExprList_item *pItem;
|
||||
for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
|
||||
if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
|
||||
return pItem->u.iConstExprReg;
|
||||
}
|
||||
}
|
||||
}
|
||||
r2 = ++pParse->nMem;
|
||||
sqlite3ExprCodeAtInit(pParse, pExpr, r2, 1);
|
||||
r2 = sqlite3ExprCodeAtInit(pParse, pExpr, -1);
|
||||
}else{
|
||||
int r1 = sqlite3GetTempReg(pParse);
|
||||
r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
|
||||
@@ -4098,7 +4113,7 @@ void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){
|
||||
*/
|
||||
void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
|
||||
if( pParse->okConstFactor && sqlite3ExprIsConstant(pExpr) ){
|
||||
sqlite3ExprCodeAtInit(pParse, pExpr, target, 0);
|
||||
sqlite3ExprCodeAtInit(pParse, pExpr, target);
|
||||
}else{
|
||||
sqlite3ExprCode(pParse, pExpr, target);
|
||||
}
|
||||
@@ -4170,7 +4185,7 @@ int sqlite3ExprCodeExprList(
|
||||
sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);
|
||||
}
|
||||
}else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){
|
||||
sqlite3ExprCodeAtInit(pParse, pExpr, target+i, 0);
|
||||
sqlite3ExprCodeAtInit(pParse, pExpr, target+i);
|
||||
}else{
|
||||
int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
|
||||
if( inReg!=target+i ){
|
||||
|
||||
+18
-5
@@ -1549,12 +1549,25 @@ void sqlite3GenerateConstraintChecks(
|
||||
onError = OE_Abort;
|
||||
}
|
||||
|
||||
if( ix==0 && pPk==pIdx && onError==OE_Replace && pPk->pNext==0 ){
|
||||
/* Collision detection may be omitted if all of the following are true:
|
||||
** (1) The conflict resolution algorithm is REPLACE
|
||||
** (2) The table is a WITHOUT ROWID table
|
||||
** (3) There are no secondary indexes on the table
|
||||
** (4) No delete triggers need to be fired if there is a conflict
|
||||
** (5) No FK constraint counters need to be updated if a conflict occurs.
|
||||
*/
|
||||
if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
|
||||
&& pPk==pIdx /* Condition 2 */
|
||||
&& onError==OE_Replace /* Condition 1 */
|
||||
&& ( 0==(db->flags&SQLITE_RecTriggers) || /* Condition 4 */
|
||||
0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))
|
||||
&& ( 0==(db->flags&SQLITE_ForeignKeys) || /* Condition 5 */
|
||||
(0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))
|
||||
){
|
||||
sqlite3VdbeResolveLabel(v, addrUniqueOk);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Check to see if the new index entry will be unique */
|
||||
sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
|
||||
regIdx, pIdx->nKeyCol); VdbeCoverage(v);
|
||||
@@ -1638,7 +1651,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
}
|
||||
sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
|
||||
regR, nPkField, 0, OE_Replace,
|
||||
(pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), -1);
|
||||
(pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
|
||||
seenReplace = 1;
|
||||
break;
|
||||
}
|
||||
@@ -2125,7 +2138,7 @@ static int xferOptimization(
|
||||
addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
|
||||
assert( (pDest->tabFlags & TF_Autoincrement)==0 );
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData);
|
||||
sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);
|
||||
if( db->flags & SQLITE_Vacuum ){
|
||||
sqlite3VdbeAddOp3(v, OP_Last, iDest, 0, -1);
|
||||
insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|
|
||||
@@ -2157,7 +2170,7 @@ static int xferOptimization(
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);
|
||||
VdbeComment((v, "%s", pDestIdx->zName));
|
||||
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData);
|
||||
sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);
|
||||
if( db->flags & SQLITE_Vacuum ){
|
||||
/* This INSERT command is part of a VACUUM operation, which guarantees
|
||||
** that the destination table is empty. If all indexed columns use
|
||||
|
||||
+12
-1
@@ -408,7 +408,9 @@ void sqlite3Pragma(
|
||||
}
|
||||
|
||||
/* Register the result column names for pragmas that return results */
|
||||
if( (pPragma->mPragFlg & PragFlg_NoColumns)==0 ){
|
||||
if( (pPragma->mPragFlg & PragFlg_NoColumns)==0
|
||||
&& ((pPragma->mPragFlg & PragFlg_NoColumns1)==0 || zRight==0)
|
||||
){
|
||||
setPragmaResultColumnNames(v, pPragma);
|
||||
}
|
||||
|
||||
@@ -1953,6 +1955,15 @@ void sqlite3Pragma(
|
||||
|
||||
} /* End of the PRAGMA switch */
|
||||
|
||||
/* The following block is a no-op unless SQLITE_DEBUG is defined. Its only
|
||||
** purpose is to execute assert() statements to verify that if the
|
||||
** PragFlg_NoColumns1 flag is set and the caller specified an argument
|
||||
** to the PRAGMA, the implementation has not added any OP_ResultRow
|
||||
** instructions to the VM. */
|
||||
if( (pPragma->mPragFlg & PragFlg_NoColumns1) && zRight ){
|
||||
sqlite3VdbeVerifyNoResultRow(v);
|
||||
}
|
||||
|
||||
pragma_out:
|
||||
sqlite3DbFree(db, zLeft);
|
||||
sqlite3DbFree(db, zRight);
|
||||
|
||||
+47
-46
@@ -52,11 +52,12 @@
|
||||
/* Property flags associated with various pragma. */
|
||||
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
|
||||
#define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
|
||||
#define PragFlg_ReadOnly 0x04 /* Read-only HEADER_VALUE */
|
||||
#define PragFlg_Result0 0x08 /* Acts as query when no argument */
|
||||
#define PragFlg_Result1 0x10 /* Acts as query when has one argument */
|
||||
#define PragFlg_SchemaOpt 0x20 /* Schema restricts name search if present */
|
||||
#define PragFlg_SchemaReq 0x40 /* Schema required - "main" is default */
|
||||
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
|
||||
#define PragFlg_ReadOnly 0x08 /* Read-only HEADER_VALUE */
|
||||
#define PragFlg_Result0 0x10 /* Acts as query when no argument */
|
||||
#define PragFlg_Result1 0x20 /* Acts as query when has one argument */
|
||||
#define PragFlg_SchemaOpt 0x40 /* Schema restricts name search if present */
|
||||
#define PragFlg_SchemaReq 0x80 /* Schema required - "main" is default */
|
||||
|
||||
/* Names of columns for pragmas that return multi-column result
|
||||
** or that return single-column results where the name of the
|
||||
@@ -133,14 +134,14 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "application_id",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1|PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_APPLICATION_ID },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_AUTOVACUUM)
|
||||
{/* zName: */ "auto_vacuum",
|
||||
/* ePragTyp: */ PragTyp_AUTO_VACUUM,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -148,7 +149,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
|
||||
{/* zName: */ "automatic_index",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_AutoIndex },
|
||||
#endif
|
||||
@@ -161,31 +162,31 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "cache_size",
|
||||
/* ePragTyp: */ PragTyp_CACHE_SIZE,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "cache_spill",
|
||||
/* ePragTyp: */ PragTyp_CACHE_SPILL,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
{/* zName: */ "case_sensitive_like",
|
||||
/* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "cell_size_check",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_CellSizeCk },
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "checkpoint_fullfsync",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_CkptFullFSync },
|
||||
#endif
|
||||
@@ -206,21 +207,21 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "count_changes",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_CountRows },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
|
||||
{/* zName: */ "data_store_directory",
|
||||
/* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "data_version",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_ReadOnly,
|
||||
/* ePragFlg: */ PragFlg_ReadOnly|PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_DATA_VERSION },
|
||||
#endif
|
||||
@@ -234,7 +235,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
|
||||
{/* zName: */ "default_cache_size",
|
||||
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 1,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -242,7 +243,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
|
||||
{/* zName: */ "defer_foreign_keys",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_DeferFKs },
|
||||
#endif
|
||||
@@ -250,14 +251,14 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "empty_result_callbacks",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_NullCallback },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_UTF16)
|
||||
{/* zName: */ "encoding",
|
||||
/* ePragTyp: */ PragTyp_ENCODING,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -279,7 +280,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
|
||||
{/* zName: */ "foreign_keys",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ForeignKeys },
|
||||
#endif
|
||||
@@ -287,19 +288,19 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "freelist_count",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_ReadOnly,
|
||||
/* ePragFlg: */ PragFlg_ReadOnly|PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_FREE_PAGE_COUNT },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "full_column_names",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_FullColNames },
|
||||
{/* zName: */ "fullfsync",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_FullFSync },
|
||||
#endif
|
||||
@@ -319,7 +320,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_CHECK)
|
||||
{/* zName: */ "ignore_check_constraints",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_IgnoreChecks },
|
||||
#endif
|
||||
@@ -377,14 +378,14 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "legacy_file_format",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_LegacyFileFmt },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
|
||||
{/* zName: */ "lock_proxy_file",
|
||||
/* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -418,7 +419,7 @@ static const PragmaName aPragmaName[] = {
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "page_size",
|
||||
/* ePragTyp: */ PragTyp_PAGE_SIZE,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -432,7 +433,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "query_only",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_QueryOnly },
|
||||
#endif
|
||||
@@ -446,12 +447,12 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "read_uncommitted",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ReadUncommitted },
|
||||
{/* zName: */ "recursive_triggers",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_RecTriggers },
|
||||
#endif
|
||||
@@ -465,14 +466,14 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "reverse_unordered_selects",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ReverseOrder },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "schema_version",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1|PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_SCHEMA_VERSION },
|
||||
#endif
|
||||
@@ -486,13 +487,13 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "short_column_names",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_ShortColNames },
|
||||
#endif
|
||||
{/* zName: */ "shrink_memory",
|
||||
/* ePragTyp: */ PragTyp_SHRINK_MEMORY,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "soft_heap_limit",
|
||||
@@ -504,7 +505,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if defined(SQLITE_DEBUG)
|
||||
{/* zName: */ "sql_trace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_SqlTrace },
|
||||
#endif
|
||||
@@ -519,7 +520,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "synchronous",
|
||||
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -533,12 +534,12 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "temp_store",
|
||||
/* ePragTyp: */ PragTyp_TEMP_STORE,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "temp_store_directory",
|
||||
/* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
|
||||
/* ePragFlg: */ 0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
@@ -550,7 +551,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
{/* zName: */ "user_version",
|
||||
/* ePragTyp: */ PragTyp_HEADER_VALUE,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ePragFlg: */ PragFlg_NoColumns1|PragFlg_Result0,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ BTREE_USER_VERSION },
|
||||
#endif
|
||||
@@ -558,27 +559,27 @@ static const PragmaName aPragmaName[] = {
|
||||
#if defined(SQLITE_DEBUG)
|
||||
{/* zName: */ "vdbe_addoptrace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeAddopTrace },
|
||||
{/* zName: */ "vdbe_debug",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
|
||||
{/* zName: */ "vdbe_eqp",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeEQP },
|
||||
{/* zName: */ "vdbe_listing",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeListing },
|
||||
{/* zName: */ "vdbe_trace",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_VdbeTrace },
|
||||
#endif
|
||||
@@ -598,7 +599,7 @@ static const PragmaName aPragmaName[] = {
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
{/* zName: */ "writable_schema",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
|
||||
#endif
|
||||
|
||||
+3
-2
@@ -657,6 +657,7 @@ static void codeDistinct(
|
||||
sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
|
||||
sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
|
||||
sqlite3ReleaseTempReg(pParse, r1);
|
||||
}
|
||||
|
||||
@@ -742,8 +743,7 @@ static void selectInnerLoop(
|
||||
}else{
|
||||
ecelFlags = 0;
|
||||
}
|
||||
assert( eDest!=SRT_Table || pSort==0 );
|
||||
if( pSort && hasDistinct==0 && eDest!=SRT_EphemTab ){
|
||||
if( pSort && hasDistinct==0 && eDest!=SRT_EphemTab && eDest!=SRT_Table ){
|
||||
/* For each expression in pEList that is a copy of an expression in
|
||||
** the ORDER BY clause (pSort->pOrderBy), set the associated
|
||||
** iOrderByCol value to one more than the index of the ORDER BY
|
||||
@@ -1285,6 +1285,7 @@ static void generateSortTail(
|
||||
VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));
|
||||
}
|
||||
switch( eDest ){
|
||||
case SRT_Table:
|
||||
case SRT_EphemTab: {
|
||||
sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
|
||||
sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
|
||||
|
||||
+11
-3
@@ -259,7 +259,11 @@ typedef struct sqlite3 sqlite3;
|
||||
*/
|
||||
#ifdef SQLITE_INT64_TYPE
|
||||
typedef SQLITE_INT64_TYPE sqlite_int64;
|
||||
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
|
||||
# ifdef SQLITE_UINT64_TYPE
|
||||
typedef SQLITE_UINT64_TYPE sqlite_uint64;
|
||||
# else
|
||||
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
|
||||
# endif
|
||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef __int64 sqlite_int64;
|
||||
typedef unsigned __int64 sqlite_uint64;
|
||||
@@ -3896,8 +3900,12 @@ int sqlite3_clear_bindings(sqlite3_stmt*);
|
||||
** METHOD: sqlite3_stmt
|
||||
**
|
||||
** ^Return the number of columns in the result set returned by the
|
||||
** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
|
||||
** statement that does not return data (for example an [UPDATE]).
|
||||
** [prepared statement]. ^If this routine returns 0, that means the
|
||||
** [prepared statement] returns no data (for example an [UPDATE]).
|
||||
** ^However, just because this routine returns a positive number does not
|
||||
** mean that one or more rows of data will be returned. ^A SELECT statement
|
||||
** will always have a positive sqlite3_column_count() but depending on the
|
||||
** WHERE clause constraints and the table content, it might return no rows.
|
||||
**
|
||||
** See also: [sqlite3_data_count()]
|
||||
*/
|
||||
|
||||
+1
-1
@@ -3716,7 +3716,7 @@ void sqlite3ExprCacheAffinityChange(Parse*, int, int);
|
||||
void sqlite3ExprCode(Parse*, Expr*, int);
|
||||
void sqlite3ExprCodeCopy(Parse*, Expr*, int);
|
||||
void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
|
||||
void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
|
||||
int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
|
||||
int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
|
||||
int sqlite3ExprCodeTarget(Parse*, Expr*, int);
|
||||
void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
|
||||
|
||||
+3
-3
@@ -313,7 +313,7 @@ static void sqllogCopydb(struct SLConn *p, const char *zSearch, int bLog){
|
||||
|
||||
/* Generate a file-name to use for the copy of this database */
|
||||
iDb = sqllogglobal.iNextDb++;
|
||||
zInit = sqlite3_mprintf("%s_%d.db", sqllogglobal.zPrefix, iDb);
|
||||
zInit = sqlite3_mprintf("%s_%02d.db", sqllogglobal.zPrefix, iDb);
|
||||
|
||||
/* Create the backup */
|
||||
assert( sqllogglobal.bRec==0 );
|
||||
@@ -376,7 +376,7 @@ static void sqllogOpenlog(struct SLConn *p){
|
||||
char *zVar = getenv(ENVIRONMENT_VARIABLE1_NAME);
|
||||
if( zVar==0 || strlen(zVar)+10>=(sizeof(sqllogglobal.zPrefix)) ) return;
|
||||
sqlite3_snprintf(sizeof(sqllogglobal.zPrefix), sqllogglobal.zPrefix,
|
||||
"%s/sqllog_%d", zVar, getProcessId());
|
||||
"%s/sqllog_%05d", zVar, getProcessId());
|
||||
sqlite3_snprintf(sizeof(sqllogglobal.zIdx), sqllogglobal.zIdx,
|
||||
"%s.idx", sqllogglobal.zPrefix);
|
||||
if( getenv(ENVIRONMENT_VARIABLE2_NAME) ){
|
||||
@@ -387,7 +387,7 @@ static void sqllogOpenlog(struct SLConn *p){
|
||||
}
|
||||
|
||||
/* Open the log file */
|
||||
zLog = sqlite3_mprintf("%s_%d.sql", sqllogglobal.zPrefix, p->iLog);
|
||||
zLog = sqlite3_mprintf("%s_%05d.sql", sqllogglobal.zPrefix, p->iLog);
|
||||
p->fd = fopen(zLog, "w");
|
||||
sqlite3_free(zLog);
|
||||
if( p->fd==0 ){
|
||||
|
||||
+17
-10
@@ -4632,7 +4632,7 @@ case OP_SorterData: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: RowData P1 P2 * * *
|
||||
/* Opcode: RowData P1 P2 P3 * *
|
||||
** Synopsis: r[P2]=data
|
||||
**
|
||||
** Write into register P2 the complete row content for the row at
|
||||
@@ -4646,14 +4646,26 @@ case OP_SorterData: {
|
||||
**
|
||||
** If the P1 cursor must be pointing to a valid row (not a NULL row)
|
||||
** of a real table, not a pseudo-table.
|
||||
**
|
||||
** If P3!=0 then this opcode is allowed to make an ephermeral pointer
|
||||
** into the database page. That means that the content of the output
|
||||
** register will be invalidated as soon as the cursor moves - including
|
||||
** moves caused by other cursors that "save" the the current cursors
|
||||
** position in order that they can write to the same table. If P3==0
|
||||
** then a copy of the data is made into memory. P3!=0 is faster, but
|
||||
** P3==0 is safer.
|
||||
**
|
||||
** If P3!=0 then the content of the P2 register is unsuitable for use
|
||||
** in OP_Result and any OP_Result will invalidate the P2 register content.
|
||||
** The P2 register content is invalided by opcodes like OP_Function or
|
||||
** by any use of another cursor pointing to the same table.
|
||||
*/
|
||||
case OP_RowData: {
|
||||
VdbeCursor *pC;
|
||||
BtCursor *pCrsr;
|
||||
u32 n;
|
||||
|
||||
pOut = &aMem[pOp->p2];
|
||||
memAboutToChange(p, pOut);
|
||||
pOut = out2Prerelease(p, pOp);
|
||||
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||
pC = p->apCsr[pOp->p1];
|
||||
@@ -4684,14 +4696,9 @@ case OP_RowData: {
|
||||
goto too_big;
|
||||
}
|
||||
testcase( n==0 );
|
||||
if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){
|
||||
goto no_mem;
|
||||
}
|
||||
pOut->n = n;
|
||||
MemSetTypeFlag(pOut, MEM_Blob);
|
||||
rc = sqlite3BtreePayload(pCrsr, 0, n, pOut->z);
|
||||
rc = sqlite3VdbeMemFromBtree(pCrsr, 0, n, pOut);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */
|
||||
if( !pOp->p3 ) Deephemeralize(pOut);
|
||||
UPDATE_MAX_BLOBSIZE(pOut);
|
||||
REGISTER_TRACE(pOp->p2, pOut);
|
||||
break;
|
||||
|
||||
@@ -183,8 +183,10 @@ int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
|
||||
void sqlite3VdbeEndCoroutine(Vdbe*,int);
|
||||
#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
|
||||
void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
|
||||
void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
|
||||
#else
|
||||
# define sqlite3VdbeVerifyNoMallocRequired(A,B)
|
||||
# define sqlite3VdbeVerifyNoResultRow(A)
|
||||
#endif
|
||||
VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
|
||||
void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
|
||||
|
||||
@@ -648,6 +648,22 @@ void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Verify that the VM passed as the only argument does not contain
|
||||
** an OP_ResultRow opcode. Fail an assert() if it does. This is used
|
||||
** by code in pragma.c to ensure that the implementation of certain
|
||||
** pragmas comports with the flags specified in the mkpragmatab.tcl
|
||||
** script.
|
||||
*/
|
||||
#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
|
||||
void sqlite3VdbeVerifyNoResultRow(Vdbe *p){
|
||||
int i;
|
||||
for(i=0; i<p->nOp; i++){
|
||||
assert( p->aOp[i].opcode!=OP_ResultRow );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** This function returns a pointer to the array of opcodes associated with
|
||||
** the Vdbe passed as the first argument. It is the callers responsibility
|
||||
|
||||
@@ -1010,6 +1010,7 @@ static SQLITE_NOINLINE const void *valueToText(sqlite3_value* pVal, u8 enc){
|
||||
assert( (pVal->flags & MEM_RowSet)==0 );
|
||||
assert( (pVal->flags & (MEM_Null))==0 );
|
||||
if( pVal->flags & (MEM_Blob|MEM_Str) ){
|
||||
if( ExpandBlob(pVal) ) return 0;
|
||||
pVal->flags |= MEM_Str;
|
||||
if( pVal->enc != (enc & ~SQLITE_UTF16_ALIGNED) ){
|
||||
sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);
|
||||
|
||||
@@ -101,5 +101,67 @@ foreach {tn use_stmt sql schema} {
|
||||
} $use_stmt
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following tests check that foreign key constaint counters are
|
||||
# correctly updated for any implicit DELETE operations that occur
|
||||
# when a REPLACE command is executed against a WITHOUT ROWID table
|
||||
# that has no triggers or auxiliary indexes.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 2.1.0 {
|
||||
PRAGMA foreign_keys = on;
|
||||
CREATE TABLE p1(a PRIMARY KEY, b) WITHOUT ROWID;
|
||||
CREATE TABLE c1(x REFERENCES p1 DEFERRABLE INITIALLY DEFERRED);
|
||||
|
||||
INSERT INTO p1 VALUES(1, 'one');
|
||||
INSERT INTO p1 VALUES(2, 'two');
|
||||
INSERT INTO c1 VALUES(1);
|
||||
INSERT INTO c1 VALUES(2);
|
||||
}
|
||||
|
||||
do_catchsql_test 2.1.2 {
|
||||
BEGIN;
|
||||
DELETE FROM p1 WHERE a=1;
|
||||
INSERT OR REPLACE INTO p1 VALUES(2, 'two');
|
||||
COMMIT;
|
||||
} {1 {FOREIGN KEY constraint failed}}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 2.2.0 {
|
||||
PRAGMA foreign_keys = on;
|
||||
CREATE TABLE p2(a PRIMARY KEY, b);
|
||||
CREATE TABLE c2(
|
||||
x PRIMARY KEY,
|
||||
y REFERENCES p2 DEFERRABLE INITIALLY DEFERRED
|
||||
) WITHOUT ROWID;
|
||||
}
|
||||
|
||||
do_catchsql_test 2.2.1 {
|
||||
BEGIN;
|
||||
INSERT INTO c2 VALUES(13, 13);
|
||||
INSERT OR REPLACE INTO c2 VALUES(13, 13);
|
||||
DELETE FROM c2;
|
||||
COMMIT;
|
||||
} {0 {}}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 2.3.0 {
|
||||
PRAGMA foreign_keys = on;
|
||||
CREATE TABLE p3(a PRIMARY KEY, b) WITHOUT ROWID;
|
||||
CREATE TABLE c3(x REFERENCES p3);
|
||||
|
||||
INSERT INTO p3 VALUES(1, 'one');
|
||||
INSERT INTO p3 VALUES(2, 'two');
|
||||
INSERT INTO c3 VALUES(1);
|
||||
INSERT INTO c3 VALUES(2);
|
||||
|
||||
CREATE TRIGGER p3d AFTER DELETE ON p3 WHEN old.a=1 BEGIN
|
||||
INSERT OR REPLACE INTO p3 VALUES(2, 'three');
|
||||
END;
|
||||
}
|
||||
|
||||
do_catchsql_test 2.3.1 {
|
||||
DELETE FROM p3 WHERE a=1
|
||||
} {1 {FOREIGN KEY constraint failed}}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# 2017 Jan 4
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix pragma4
|
||||
|
||||
proc do_pragma_ncol_test {tn sql nCol} {
|
||||
set ::stmt 0
|
||||
set ::stmt [sqlite3_prepare_v2 db $sql -1 dummy]
|
||||
uplevel [list do_test $tn { sqlite3_column_count $::stmt } $nCol]
|
||||
sqlite3_finalize $::stmt
|
||||
}
|
||||
|
||||
# If there is no RHS argument, the following PRAGMA statements operate as
|
||||
# queries, returning a single row containing a single column.
|
||||
#
|
||||
# Or, if there is RHS argument, they return zero rows of zero columns.
|
||||
#
|
||||
foreach {tn sql} {
|
||||
1 "PRAGMA application_id = 10"
|
||||
2 "PRAGMA automatic_index = 1"
|
||||
3 "PRAGMA auto_vacuum = 1"
|
||||
4 "PRAGMA cache_size = -100"
|
||||
5 "PRAGMA cache_spill = 1"
|
||||
6 "PRAGMA cell_size_check = 1"
|
||||
7 "PRAGMA checkpoint_fullfsync = 1"
|
||||
8 "PRAGMA count_changes = 1"
|
||||
9 "PRAGMA default_cache_size = 100"
|
||||
10 "PRAGMA defer_foreign_keys = 1"
|
||||
11 "PRAGMA empty_result_callbacks = 1"
|
||||
12 "PRAGMA encoding = 'utf-8'"
|
||||
13 "PRAGMA foreign_keys = 1"
|
||||
14 "PRAGMA full_column_names = 1"
|
||||
15 "PRAGMA fullfsync = 1"
|
||||
16 "PRAGMA ignore_check_constraints = 1"
|
||||
17 "PRAGMA legacy_file_format = 1"
|
||||
18 "PRAGMA page_size = 511"
|
||||
19 "PRAGMA page_size = 512"
|
||||
20 "PRAGMA query_only = false"
|
||||
21 "PRAGMA read_uncommitted = true"
|
||||
22 "PRAGMA recursive_triggers = false"
|
||||
23 "PRAGMA reverse_unordered_selects = false"
|
||||
24 "PRAGMA schema_version = 211"
|
||||
25 "PRAGMA short_column_names = 1"
|
||||
26 "PRAGMA synchronous = full"
|
||||
29 "PRAGMA temp_store = memory"
|
||||
30 "PRAGMA user_version = 405"
|
||||
31 "PRAGMA writable_schema = 1"
|
||||
} {
|
||||
reset_db
|
||||
|
||||
# Without RHS:
|
||||
do_pragma_ncol_test 1.$tn.1 [lindex [split $sql =] 0] 1
|
||||
|
||||
# With RHS:
|
||||
do_pragma_ncol_test 1.$tn.2 $sql 0
|
||||
}
|
||||
|
||||
# These pragmas should never return any values.
|
||||
#
|
||||
foreach {tn sql} {
|
||||
1 "PRAGMA shrink_memory"
|
||||
2 "PRAGMA shrink_memory = 10"
|
||||
3 "PRAGMA case_sensitive_like = 0"
|
||||
4 "PRAGMA case_sensitive_like = 1"
|
||||
5 "PRAGMA case_sensitive_like"
|
||||
} {
|
||||
|
||||
do_pragma_ncol_test 1.$tn.1 $sql 0
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix selectC
|
||||
|
||||
# Ticket #
|
||||
do_test selectC-1.1 {
|
||||
@@ -233,4 +234,37 @@ do_execsql_test selectC-4.3 {
|
||||
select a, udf() from (select distinct a, b from t_distinct_bug)
|
||||
} {1 1 1 2 1 3}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that the problem in ticket #190c2507 has been fixed.
|
||||
#
|
||||
do_execsql_test 5.0 {
|
||||
CREATE TABLE x1(a);
|
||||
CREATE TABLE x2(b);
|
||||
CREATE TABLE x3(c);
|
||||
CREATE VIEW vvv AS SELECT b FROM x2 ORDER BY 1;
|
||||
|
||||
INSERT INTO x1 VALUES('a'), ('b');
|
||||
INSERT INTO x2 VALUES(22), (23), (25), (24), (21);
|
||||
INSERT INTO x3 VALUES(302), (303), (301);
|
||||
}
|
||||
|
||||
do_execsql_test 5.1 {
|
||||
CREATE TABLE x4 AS SELECT b FROM vvv UNION ALL SELECT c from x3;
|
||||
SELECT * FROM x4;
|
||||
} {21 22 23 24 25 302 303 301}
|
||||
|
||||
do_execsql_test 5.2 {
|
||||
SELECT * FROM x1, x4
|
||||
} {
|
||||
a 21 a 22 a 23 a 24 a 25 a 302 a 303 a 301
|
||||
b 21 b 22 b 23 b 24 b 25 b 302 b 303 b 301
|
||||
}
|
||||
|
||||
do_execsql_test 5.3 {
|
||||
SELECT * FROM x1, (SELECT b FROM vvv UNION ALL SELECT c from x3);
|
||||
} {
|
||||
a 21 a 22 a 23 a 24 a 25 a 302 a 303 a 301
|
||||
b 21 b 22 b 23 b 24 b 25 b 302 b 303 b 301
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# 2017 January 4
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice', here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix triggerF
|
||||
ifcapable {!trigger} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
foreach {tn sql log} {
|
||||
1 { } { }
|
||||
|
||||
2 {
|
||||
CREATE TRIGGER trd AFTER DELETE ON t1 BEGIN
|
||||
INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
|
||||
END;
|
||||
} {1one2 2two1 3three1}
|
||||
|
||||
3 {
|
||||
CREATE TRIGGER trd BEFORE DELETE ON t1 BEGIN
|
||||
INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
|
||||
END;
|
||||
} {1one3 2two2 3three2}
|
||||
|
||||
4 {
|
||||
CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
|
||||
INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
|
||||
END;
|
||||
CREATE TRIGGER tr2 BEFORE DELETE ON t1 BEGIN
|
||||
INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
|
||||
END;
|
||||
} {1one3 1one2 2two2 2two1 3three2 3three1}
|
||||
|
||||
} {
|
||||
reset_db
|
||||
do_execsql_test 1.$tn.0 {
|
||||
PRAGMA recursive_triggers = on;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
|
||||
CREATE TABLE log(t);
|
||||
}
|
||||
|
||||
execsql $sql
|
||||
|
||||
do_execsql_test 1.$tn.1 {
|
||||
INSERT INTO t1 VALUES(1, 'one');
|
||||
INSERT INTO t1 VALUES(2, 'two');
|
||||
INSERT INTO t1 VALUES(3, 'three');
|
||||
|
||||
DELETE FROM t1 WHERE a=1;
|
||||
INSERT OR REPLACE INTO t1 VALUES(2, 'three');
|
||||
UPDATE OR REPLACE t1 SET a=3 WHERE a=2;
|
||||
}
|
||||
|
||||
do_execsql_test 1.$tn.2 {
|
||||
SELECT * FROM log ORDER BY rowid;
|
||||
} $log
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+20
-14
@@ -18,6 +18,7 @@ set flagMeaning(Result1) {Acts as query when has one argument}
|
||||
set flagMeaning(SchemaReq) {Schema required - "main" is default}
|
||||
set flagMeaning(SchemaOpt) {Schema restricts name search if present}
|
||||
set flagMeaning(NoColumns) {OP_ResultRow called with zero columns}
|
||||
set flagMeaning(NoColumns1) {zero columns if RHS argument is present}
|
||||
|
||||
set pragma_def {
|
||||
NAME: full_column_names
|
||||
@@ -56,7 +57,7 @@ set pragma_def {
|
||||
IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
|
||||
NAME: cache_spill
|
||||
FLAG: Result0 SchemaReq
|
||||
FLAG: Result0 SchemaReq NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
|
||||
NAME: reverse_unordered_selects
|
||||
@@ -149,12 +150,12 @@ set pragma_def {
|
||||
ARG: SQLITE_CellSizeCk
|
||||
|
||||
NAME: default_cache_size
|
||||
FLAG: NeedSchema Result0 SchemaReq
|
||||
FLAG: NeedSchema Result0 SchemaReq NoColumns1
|
||||
COLS: cache_size
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
|
||||
|
||||
NAME: page_size
|
||||
FLAG: Result0 SchemaReq
|
||||
FLAG: Result0 SchemaReq NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: secure_delete
|
||||
@@ -183,14 +184,14 @@ set pragma_def {
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: cache_size
|
||||
FLAG: NeedSchema Result0 SchemaReq
|
||||
FLAG: NeedSchema Result0 SchemaReq NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: mmap_size
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: auto_vacuum
|
||||
FLAG: NeedSchema Result0 SchemaReq
|
||||
FLAG: NeedSchema Result0 SchemaReq NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_AUTOVACUUM)
|
||||
|
||||
NAME: incremental_vacuum
|
||||
@@ -198,20 +199,23 @@ set pragma_def {
|
||||
IF: !defined(SQLITE_OMIT_AUTOVACUUM)
|
||||
|
||||
NAME: temp_store
|
||||
FLAG: Result0
|
||||
FLAG: Result0 NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: temp_store_directory
|
||||
FLAG: NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: data_store_directory
|
||||
FLAG: NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
|
||||
|
||||
NAME: lock_proxy_file
|
||||
FLAG: NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
|
||||
|
||||
NAME: synchronous
|
||||
FLAG: NeedSchema Result0 SchemaReq
|
||||
FLAG: NeedSchema Result0 SchemaReq NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
|
||||
NAME: table_info
|
||||
@@ -267,6 +271,7 @@ set pragma_def {
|
||||
IF: defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
|
||||
|
||||
NAME: case_sensitive_like
|
||||
FLAG: NoColumns
|
||||
|
||||
NAME: integrity_check
|
||||
FLAG: NeedSchema
|
||||
@@ -278,34 +283,37 @@ set pragma_def {
|
||||
IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK)
|
||||
|
||||
NAME: encoding
|
||||
FLAG: Result0
|
||||
FLAG: Result0 NoColumns1
|
||||
IF: !defined(SQLITE_OMIT_UTF16)
|
||||
|
||||
NAME: schema_version
|
||||
TYPE: HEADER_VALUE
|
||||
ARG: BTREE_SCHEMA_VERSION
|
||||
FLAG: NoColumns1 Result0
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
|
||||
NAME: user_version
|
||||
TYPE: HEADER_VALUE
|
||||
ARG: BTREE_USER_VERSION
|
||||
FLAG: NoColumns1 Result0
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
|
||||
NAME: data_version
|
||||
TYPE: HEADER_VALUE
|
||||
ARG: BTREE_DATA_VERSION
|
||||
FLAG: ReadOnly
|
||||
FLAG: ReadOnly Result0
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
|
||||
NAME: freelist_count
|
||||
TYPE: HEADER_VALUE
|
||||
ARG: BTREE_FREE_PAGE_COUNT
|
||||
FLAG: ReadOnly
|
||||
FLAG: ReadOnly Result0
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
|
||||
NAME: application_id
|
||||
TYPE: HEADER_VALUE
|
||||
ARG: BTREE_APPLICATION_ID
|
||||
FLAG: NoColumns1 Result0
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
|
||||
|
||||
NAME: compile_options
|
||||
@@ -321,6 +329,7 @@ set pragma_def {
|
||||
IF: !defined(SQLITE_OMIT_WAL)
|
||||
|
||||
NAME: shrink_memory
|
||||
FLAG: NoColumns
|
||||
|
||||
NAME: busy_timeout
|
||||
FLAG: Result0
|
||||
@@ -408,10 +417,7 @@ foreach line [split $pragma_def \n] {
|
||||
} elseif {$id=="TYPE"} {
|
||||
set type $val
|
||||
if {$type=="FLAG"} {
|
||||
lappend flags Result0 NoColumns
|
||||
}
|
||||
if {$type=="HEADER_VALUE"} {
|
||||
lappend flags Result0
|
||||
lappend flags Result0 NoColumns1
|
||||
}
|
||||
} elseif {$id=="ARG"} {
|
||||
set arg $val
|
||||
|
||||
Reference in New Issue
Block a user