Add interfaces sqlite3_prepare_v3() and sqlite3_prepare16_v3() with the

extra prepFlags argument. Add the SQLITE_PREPARE_PERSISTENT option as 
one bit in that argument.  Use the new option in FTS3, FTS5, and RTREE.

FossilOrigin-Name: 03977248e6fdaa9b35c15e5dd9bb89552f2f0a913cc31609b5af1e2347b67d38
This commit is contained in:
drh 2017-06-29 15:24:57 +00:00
commit 01e6d540a7
15 changed files with 210 additions and 94 deletions

View File

@ -1744,7 +1744,7 @@ static int fts3CursorSeekStmt(Fts3Cursor *pCsr){
}else{ }else{
zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
if( !zSql ) return SQLITE_NOMEM; if( !zSql ) return SQLITE_NOMEM;
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
sqlite3_free(zSql); sqlite3_free(zSql);
} }
if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1; if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
@ -3281,7 +3281,7 @@ static int fts3FilterMethod(
); );
} }
if( zSql ){ if( zSql ){
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
sqlite3_free(zSql); sqlite3_free(zSql);
}else{ }else{
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;

View File

@ -407,7 +407,8 @@ static int fts3SqlStmt(
if( !zSql ){ if( !zSql ){
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
}else{ }else{
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL); rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
&pStmt, NULL);
sqlite3_free(zSql); sqlite3_free(zSql);
assert( rc==SQLITE_OK || pStmt==0 ); assert( rc==SQLITE_OK || pStmt==0 );
p->aStmt[eStmt] = pStmt; p->aStmt[eStmt] = pStmt;

View File

@ -728,7 +728,8 @@ static int fts5IndexPrepareStmt(
){ ){
if( p->rc==SQLITE_OK ){ if( p->rc==SQLITE_OK ){
if( zSql ){ if( zSql ){
p->rc = sqlite3_prepare_v2(p->pConfig->db, zSql, -1, ppStmt, 0); p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
}else{ }else{
p->rc = SQLITE_NOMEM; p->rc = SQLITE_NOMEM;
} }
@ -777,7 +778,8 @@ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){
if( zSql==0 ){ if( zSql==0 ){
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
}else{ }else{
rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p->pDeleter, 0); rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
sqlite3_free(zSql); sqlite3_free(zSql);
} }
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){

View File

@ -883,7 +883,8 @@ static int fts5PrepareStatement(
if( zSql==0 ){ if( zSql==0 ){
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
}else{ }else{
rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0); rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
SQLITE_PREPARE_PERSISTENT, &pRet, 0);
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
*pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db)); *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
} }
@ -1019,7 +1020,8 @@ static int fts5FindRankFunction(Fts5Cursor *pCsr){
char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs); char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
if( zSql ){ if( zSql ){
sqlite3_stmt *pStmt = 0; sqlite3_stmt *pStmt = 0;
rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pStmt, 0); rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
sqlite3_free(zSql); sqlite3_free(zSql);
assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 ); assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){

View File

@ -136,7 +136,8 @@ static int fts5StorageGetStmt(
if( zSql==0 ){ if( zSql==0 ){
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
}else{ }else{
rc = sqlite3_prepare_v2(pC->db, zSql, -1, &p->aStmt[eStmt], 0); rc = sqlite3_prepare_v3(pC->db, zSql, -1,
SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
sqlite3_free(zSql); sqlite3_free(zSql);
if( rc!=SQLITE_OK && pzErrMsg ){ if( rc!=SQLITE_OK && pzErrMsg ){
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db)); *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));

View File

@ -3361,7 +3361,8 @@ static int rtreeSqlInit(
for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){ for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix); char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
if( zSql ){ if( zSql ){
rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0); rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
appStmt[i], 0);
}else{ }else{
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
} }

View File

@ -1,5 +1,5 @@
C Further\scorrections\sto\sthe\sWin32\sinterface\sfor\slsm1. C Add\sinterfaces\ssqlite3_prepare_v3()\sand\ssqlite3_prepare16_v3()\swith\sthe\s\nextra\sprepFlags\sargument.\sAdd\sthe\sSQLITE_PREPARE_PERSISTENT\soption\sas\s\none\sbit\sin\sthat\sargument.\s\sUse\sthe\snew\soption\sin\sFTS3,\sFTS5,\sand\sRTREE.
D 2017-06-29T15:13:48.585 D 2017-06-29T15:24:57.455
F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12 F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 4ebb1d257cac7fb1bcb4ba59278416d410ff1c4bf59447a9c37a415f3516056a F Makefile.msc 4ebb1d257cac7fb1bcb4ba59278416d410ff1c4bf59447a9c37a415f3516056a
@ -70,7 +70,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 88ea5c444fdf262b4eb7b5872b9a3192b8b8d0df8cc9735c5aed159ec5dae02a F ext/fts3/fts3.c 6c5543ce771db11d27793fb696564ef5e977116671353a0d5c22056aba73055e
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h eb2502000148e80913b965db3e59f29251266d0a F ext/fts3/fts3Int.h eb2502000148e80913b965db3e59f29251266d0a
F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1 F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1
@ -88,7 +88,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
F ext/fts3/fts3_unicode.c 525a3bd9a7564603c5c061b7de55403a565307758a94600e8a2f6b00d1c40d9d F ext/fts3/fts3_unicode.c 525a3bd9a7564603c5c061b7de55403a565307758a94600e8a2f6b00d1c40d9d
F ext/fts3/fts3_unicode2.c cc04fc672bfd42b1e650398cb0bf71f64f9aae032cfe75bbcfe75b9cf966029c F ext/fts3/fts3_unicode2.c cc04fc672bfd42b1e650398cb0bf71f64f9aae032cfe75bbcfe75b9cf966029c
F ext/fts3/fts3_write.c a51d48d646974ee2fb4b17fcd5da0416a5759a32dcacc2cce2ba00d5a767848e F ext/fts3/fts3_write.c a3f7bf869622d1d0aa66661ba71d88e6f9646d69a2c335f40a0addf25974db47
F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
F ext/fts3/tool/fts3cov.sh c331d006359456cf6f8f953e37f2b9c7d568f3863f00bb5f7eb87fea4ac01b73 F ext/fts3/tool/fts3cov.sh c331d006359456cf6f8f953e37f2b9c7d568f3863f00bb5f7eb87fea4ac01b73
@ -105,9 +105,9 @@ F ext/fts5/fts5_buffer.c 1dd1ec0446b3acfc2d7d407eb894762a461613e2695273f48e449bf
F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857
F ext/fts5/fts5_expr.c f2825f714d91bbe62ab5820aee9ad12e0c94205b2a01725eaa9072415ae9ff1c F ext/fts5/fts5_expr.c f2825f714d91bbe62ab5820aee9ad12e0c94205b2a01725eaa9072415ae9ff1c
F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301546dd55 F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301546dd55
F ext/fts5/fts5_index.c cdceac47287c66500214ee946ca871ac48027a82a0ca82177c1c6af19f181ca0 F ext/fts5/fts5_index.c 2ce9d50ec5508b8205615aad69e1c9b2c77f017f21d4479e1fb2079c01fdd017
F ext/fts5/fts5_main.c 1ba0e7806886c1bc16e20d0dde1c2b535d1aeb98cbbb937c4c3e064af5ac6f03 F ext/fts5/fts5_main.c f32b3b878c21df7bd4ea4c096c7d4b36f3fa40b216899ddf29d2eb9b47053069
F ext/fts5/fts5_storage.c 7750986004f3f0c94619a85ecb5dd6cbef53e5e3853488e8a906c269d4d11db6 F ext/fts5/fts5_storage.c fb5ef3c27073f67ade2e1bea08405f9e43f68f5f3676ed0ab7013bce5ba10be6
F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a
F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc
F ext/fts5/fts5_test_tok.c ffd657dd67e7fcdb31bf63fb60b6d867299a581d0f46e97086abacd66c2a9b26 F ext/fts5/fts5_test_tok.c ffd657dd67e7fcdb31bf63fb60b6d867299a581d0f46e97086abacd66c2a9b26
@ -317,7 +317,7 @@ F ext/rbu/sqlite3rbu.c d1438580a451eebda3bfd42ef69b677512f00125285e0e4e789b6131a
F ext/rbu/sqlite3rbu.h fc25e1fcd99b5c6d32b1b5b1c73122632e873ac89bd0be9bf646db362b7ce02c F ext/rbu/sqlite3rbu.h fc25e1fcd99b5c6d32b1b5b1c73122632e873ac89bd0be9bf646db362b7ce02c
F ext/rbu/test_rbu.c ec18cfc69a104309df23c359e3c80306c9a6bdd1d2c53c8b70ae158e9832dcd6 F ext/rbu/test_rbu.c ec18cfc69a104309df23c359e3c80306c9a6bdd1d2c53c8b70ae158e9832dcd6
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
F ext/rtree/rtree.c 8205d6e4466f766e57ce1b8aa38224ac9e1cec2d2bf4684cd1cc5a6ddf9b7014 F ext/rtree/rtree.c 9c55ff738ac3cd466f2eb23a91fb9bd6bf882ec30fed567066a0d95a6c757605
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
F ext/rtree/rtree1.test d5f0ba215b3bd1d05269ada86e74073b8445852aa0d33a63e10ec63a09c39473 F ext/rtree/rtree1.test d5f0ba215b3bd1d05269ada86e74073b8445852aa0d33a63e10ec63a09c39473
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
@ -443,21 +443,21 @@ F src/pcache.h 521bb9610d38ef17a3cc9b5ddafd4546c2ea67fa3d0e464823d73c2a28d50e11
F src/pcache1.c 1195a21fe28e223e024f900b2011e80df53793f0356a24caace4188b098540dc F src/pcache1.c 1195a21fe28e223e024f900b2011e80df53793f0356a24caace4188b098540dc
F src/pragma.c 2362670a9d28b71708aecb2b9b10b3f7be71f4c950961c07e81dc400e3ce6371 F src/pragma.c 2362670a9d28b71708aecb2b9b10b3f7be71f4c950961c07e81dc400e3ce6371
F src/pragma.h 99d3df4a3d2f12c5227ad403f767334910e6356325b6d155a9a99b4037093460 F src/pragma.h 99d3df4a3d2f12c5227ad403f767334910e6356325b6d155a9a99b4037093460
F src/prepare.c a80a740b306a5fb2f2594d68776aade4ce1920687932e7c4dc0320ebdadcbb5d F src/prepare.c 4b84ae7458febe1df3e04ae62ba56abc851f771340e460d14426e6802c5615f4
F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c d1e69759e7a79c156c692793f5d16f82f9a60ce5e82efd95e4374b2423034946 F src/resolve.c d1e69759e7a79c156c692793f5d16f82f9a60ce5e82efd95e4374b2423034946
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c 741937503c74d85e64828b63d5a4219d3cfce480a717efef635839606001b1ba F src/select.c 741937503c74d85e64828b63d5a4219d3cfce480a717efef635839606001b1ba
F src/shell.c 227b86f2bdd707d0a177a4805a5c0b0378ef8337ab1ad04f5d79dc479568735a F src/shell.c 227b86f2bdd707d0a177a4805a5c0b0378ef8337ab1ad04f5d79dc479568735a
F src/sqlite.h.in 40c70d4c9c39f69c4de6704428eaacc3e0ae939af49bdb7bc6b272efe2d61516 F src/sqlite.h.in fdfae933ad8648defe209a3c155759e5677c23840c84fc7f2a7673bcf39f8b9c
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
F src/sqliteInt.h 37f1a9a3266aa7b11126585314cd98cf11ba6f174b1244de2221270107ea754d F src/sqliteInt.h 37f1a9a3266aa7b11126585314cd98cf11ba6f174b1244de2221270107ea754d
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
F src/tclsqlite.c cbf6313f86400acdf7dbf55fcd218cd28d43110a1210967efbc4f250646f81c0 F src/tclsqlite.c 2c29b0b76e91edfd1b43bf135c32c8674710089197327682b6b7e6af88062c3d
F src/test1.c 1c0726cdf7389ed053a9b9aa0dc3c63f3b9bbc607a25decae6549682008510b3 F src/test1.c 1c0726cdf7389ed053a9b9aa0dc3c63f3b9bbc607a25decae6549682008510b3
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b
@ -516,10 +516,10 @@ F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23 F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23
F src/vacuum.c 874c0f2f15ab2908748297d587d22d485ea96d55aaec91d4775dddb2e24d2ecf F src/vacuum.c 874c0f2f15ab2908748297d587d22d485ea96d55aaec91d4775dddb2e24d2ecf
F src/vdbe.c adc8a378710ec2376101483cc8a5f499539ee9bbebfb2a784f3370704d5d44ad F src/vdbe.c adc8a378710ec2376101483cc8a5f499539ee9bbebfb2a784f3370704d5d44ad
F src/vdbe.h 70a409d171d4e51b962f0d53abf15c33c404c6aa4c9d62fb3a931b5a62ba9615 F src/vdbe.h dde459b1e8a02b8445ecfd5959f38cd5ebb6b0ad392d491d8b159ac8193d231a
F src/vdbeInt.h a2d03f8b4dd8fc2f80c93b408d54c7c28f696b7156ed6fe2691ae2b58828b72e F src/vdbeInt.h 8dd7548d86a98b77b6ed910d8014d0e9e0666356b56f3d16ab7063aad4f102f5
F src/vdbeapi.c c961d8d9e0f52e2df60a6ddbbccd7d99dc4d00103db7e53f77fcef44fbd23178 F src/vdbeapi.c 899d8f021c89ab348708b3a9b00b855f5ecc3c0f949a75359a61a3c621021281
F src/vdbeaux.c 09aaf89ef0fd9455ba5f814891e708f66705c9b3b5218fd89b087de59f2e5fb4 F src/vdbeaux.c 32ff5e8a7226c0bc6df0f214a5cc1a76fcc5d8863c491a800ef3d6f5236feae7
F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9
F src/vdbemem.c 8d78df62becfd2dce3c317f64b32a94ecaff8346d814bc8b0b877b38a1ad3718 F src/vdbemem.c 8d78df62becfd2dce3c317f64b32a94ecaff8346d814bc8b0b877b38a1ad3718
F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372 F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372
@ -1627,7 +1627,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P adfdb80105c46ac42b71132c80a91dbd5b1c9ff241fb4fbb5d04641a88898d90 P 4df6e2476ce93b9ca7a6959c8c2d6ef2c30395984b007d74166031dcf09d54b4 62b8269ba2ff71e2daaa86688698896badd6f6e34ab42fbf92dda7fcda73a230
R ef8d689596b1b0f39f6ae35de6ffda86 R cad4927ca13ab606926228f90825f496
U mistachkin T +closed 62b8269ba2ff71e2daaa86688698896badd6f6e34ab42fbf92dda7fcda73a230
Z c36edb8fe864971f5a22ea12e57f4f5d U drh
Z c711a468c88b761fff1a0b845cf3a6be

View File

@ -1 +1 @@
4df6e2476ce93b9ca7a6959c8c2d6ef2c30395984b007d74166031dcf09d54b4 03977248e6fdaa9b35c15e5dd9bb89552f2f0a913cc31609b5af1e2347b67d38

View File

@ -513,7 +513,7 @@ static int sqlite3Prepare(
sqlite3 *db, /* Database handle. */ sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */ const char *zSql, /* UTF-8 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */ int nBytes, /* Length of zSql in bytes. */
int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
Vdbe *pReprepare, /* VM being reprepared */ Vdbe *pReprepare, /* VM being reprepared */
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */ const char **pzTail /* OUT: End of parsed string */
@ -530,6 +530,14 @@ static int sqlite3Prepare(
/* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */ /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
assert( sqlite3_mutex_held(db->mutex) ); assert( sqlite3_mutex_held(db->mutex) );
/* For a long-term use prepared statement avoid the use of
** lookaside memory.
*/
if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
sParse.disableLookaside++;
db->lookaside.bDisable++;
}
/* Check to verify that it is possible to get a read lock on all /* Check to verify that it is possible to get a read lock on all
** database schemas. The inability to get a read lock indicates that ** database schemas. The inability to get a read lock indicates that
** some other database connection is holding a write-lock, which in ** some other database connection is holding a write-lock, which in
@ -629,8 +637,7 @@ static int sqlite3Prepare(
#endif #endif
if( db->init.busy==0 ){ if( db->init.busy==0 ){
Vdbe *pVdbe = sParse.pVdbe; sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag);
} }
if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){ if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
sqlite3VdbeFinalize(sParse.pVdbe); sqlite3VdbeFinalize(sParse.pVdbe);
@ -664,7 +671,7 @@ static int sqlite3LockAndPrepare(
sqlite3 *db, /* Database handle. */ sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */ const char *zSql, /* UTF-8 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */ int nBytes, /* Length of zSql in bytes. */
int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
Vdbe *pOld, /* VM being reprepared */ Vdbe *pOld, /* VM being reprepared */
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */ const char **pzTail /* OUT: End of parsed string */
@ -680,10 +687,10 @@ static int sqlite3LockAndPrepare(
} }
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
sqlite3BtreeEnterAll(db); sqlite3BtreeEnterAll(db);
rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail); rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
if( rc==SQLITE_SCHEMA ){ if( rc==SQLITE_SCHEMA ){
sqlite3_finalize(*ppStmt); sqlite3_finalize(*ppStmt);
rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail); rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
} }
sqlite3BtreeLeaveAll(db); sqlite3BtreeLeaveAll(db);
sqlite3_mutex_leave(db->mutex); sqlite3_mutex_leave(db->mutex);
@ -704,13 +711,15 @@ int sqlite3Reprepare(Vdbe *p){
sqlite3_stmt *pNew; sqlite3_stmt *pNew;
const char *zSql; const char *zSql;
sqlite3 *db; sqlite3 *db;
u8 prepFlags;
assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) ); assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
zSql = sqlite3_sql((sqlite3_stmt *)p); zSql = sqlite3_sql((sqlite3_stmt *)p);
assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */ assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
db = sqlite3VdbeDb(p); db = sqlite3VdbeDb(p);
assert( sqlite3_mutex_held(db->mutex) ); assert( sqlite3_mutex_held(db->mutex) );
rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0); prepFlags = sqlite3VdbePrepareFlags(p);
rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);
if( rc ){ if( rc ){
if( rc==SQLITE_NOMEM ){ if( rc==SQLITE_NOMEM ){
sqlite3OomFault(db); sqlite3OomFault(db);
@ -756,7 +765,23 @@ int sqlite3_prepare_v2(
const char **pzTail /* OUT: End of parsed string */ const char **pzTail /* OUT: End of parsed string */
){ ){
int rc; int rc;
rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail); rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
ppStmt,pzTail);
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
int sqlite3_prepare_v3(
sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
int rc;
rc = sqlite3LockAndPrepare(db,zSql,nBytes,
SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
0,ppStmt,pzTail);
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc; return rc;
} }
@ -770,7 +795,7 @@ static int sqlite3Prepare16(
sqlite3 *db, /* Database handle. */ sqlite3 *db, /* Database handle. */
const void *zSql, /* UTF-16 encoded SQL statement. */ const void *zSql, /* UTF-16 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */ int nBytes, /* Length of zSql in bytes. */
int saveSqlFlag, /* True to save SQL text into the sqlite3_stmt */ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const void **pzTail /* OUT: End of parsed string */ const void **pzTail /* OUT: End of parsed string */
){ ){
@ -798,7 +823,7 @@ static int sqlite3Prepare16(
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE); zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
if( zSql8 ){ if( zSql8 ){
rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8); rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);
} }
if( zTail8 && pzTail ){ if( zTail8 && pzTail ){
@ -844,7 +869,22 @@ int sqlite3_prepare16_v2(
const void **pzTail /* OUT: End of parsed string */ const void **pzTail /* OUT: End of parsed string */
){ ){
int rc; int rc;
rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail); rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
int sqlite3_prepare16_v3(
sqlite3 *db, /* Database handle. */
const void *zSql, /* UTF-16 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const void **pzTail /* OUT: End of parsed string */
){
int rc;
rc = sqlite3Prepare16(db,zSql,nBytes,
SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
ppStmt,pzTail);
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc; return rc;
} }

View File

@ -235,7 +235,7 @@ int sqlite3_threadsafe(void);
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
** and [sqlite3_close_v2()] are its destructors. There are many other ** and [sqlite3_close_v2()] are its destructors. There are many other
** interfaces (such as ** interfaces (such as
** [sqlite3_prepare_v2()], [sqlite3_create_function()], and ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
** [sqlite3_busy_timeout()] to name but three) that are methods on an ** [sqlite3_busy_timeout()] to name but three) that are methods on an
** sqlite3 object. ** sqlite3 object.
*/ */
@ -339,7 +339,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
** METHOD: sqlite3 ** METHOD: sqlite3
** **
** The sqlite3_exec() interface is a convenience wrapper around ** The sqlite3_exec() interface is a convenience wrapper around
** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
** that allows an application to run multiple statements of SQL ** that allows an application to run multiple statements of SQL
** without having to use a lot of C code. ** without having to use a lot of C code.
** **
@ -2691,7 +2691,8 @@ void sqlite3_randomness(int N, void *P);
** [database connection], supplied in the first argument. ** [database connection], supplied in the first argument.
** ^The authorizer callback is invoked as SQL statements are being compiled ** ^The authorizer callback is invoked as SQL statements are being compiled
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various ** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
** and [sqlite3_prepare16_v3()]. ^At various
** points during the compilation process, as logic is being created ** points during the compilation process, as logic is being created
** to perform various actions, the authorizer callback is invoked to ** to perform various actions, the authorizer callback is invoked to
** see if those actions are allowed. ^The authorizer callback should ** see if those actions are allowed. ^The authorizer callback should
@ -2700,12 +2701,12 @@ void sqlite3_randomness(int N, void *P);
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
** rejected with an error. ^If the authorizer callback returns ** rejected with an error. ^If the authorizer callback returns
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
** then the [sqlite3_prepare_v2()] or equivalent call that triggered ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
** the authorizer will fail with an error message. ** the authorizer will fail with an error message.
** **
** When the callback returns [SQLITE_OK], that means the operation ** When the callback returns [SQLITE_OK], that means the operation
** requested is ok. ^When the callback returns [SQLITE_DENY], the ** requested is ok. ^When the callback returns [SQLITE_DENY], the
** [sqlite3_prepare_v2()] or equivalent call that triggered the ** [sqlite3_prepare_v3()] or equivalent call that triggered the
** authorizer will fail with an error message explaining that ** authorizer will fail with an error message explaining that
** access is denied. ** access is denied.
** **
@ -2756,10 +2757,10 @@ void sqlite3_randomness(int N, void *P);
** **
** The authorizer callback must not do anything that will modify ** The authorizer callback must not do anything that will modify
** the database connection that invoked the authorizer callback. ** the database connection that invoked the authorizer callback.
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
** database connections for the meaning of "modify" in this paragraph. ** database connections for the meaning of "modify" in this paragraph.
** **
** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
** statement might be re-prepared during [sqlite3_step()] due to a ** statement might be re-prepared during [sqlite3_step()] due to a
** schema change. Hence, the application should ensure that the ** schema change. Hence, the application should ensure that the
** correct authorizer callback remains in place during the [sqlite3_step()]. ** correct authorizer callback remains in place during the [sqlite3_step()].
@ -2768,7 +2769,7 @@ void sqlite3_randomness(int N, void *P);
** [sqlite3_prepare()] or its variants. Authorization is not ** [sqlite3_prepare()] or its variants. Authorization is not
** performed during statement evaluation in [sqlite3_step()], unless ** performed during statement evaluation in [sqlite3_step()], unless
** as stated in the previous paragraph, sqlite3_step() invokes ** as stated in the previous paragraph, sqlite3_step() invokes
** sqlite3_prepare_v2() to reprepare a statement after a schema change. ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
*/ */
int sqlite3_set_authorizer( int sqlite3_set_authorizer(
sqlite3*, sqlite3*,
@ -3004,7 +3005,7 @@ int sqlite3_trace_v2(
** **
** The progress handler callback must not do anything that will modify ** The progress handler callback must not do anything that will modify
** the database connection that invoked the progress handler. ** the database connection that invoked the progress handler.
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
** database connections for the meaning of "modify" in this paragraph. ** database connections for the meaning of "modify" in this paragraph.
** **
*/ */
@ -3358,7 +3359,7 @@ const char *sqlite3_errstr(int);
** The life-cycle of a prepared statement object usually goes like this: ** The life-cycle of a prepared statement object usually goes like this:
** **
** <ol> ** <ol>
** <li> Create the prepared statement object using [sqlite3_prepare_v2()]. ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
** <li> Bind values to [parameters] using the sqlite3_bind_*() ** <li> Bind values to [parameters] using the sqlite3_bind_*()
** interfaces. ** interfaces.
** <li> Run the SQL by calling [sqlite3_step()] one or more times. ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
@ -3440,7 +3441,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** **
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
** <dd>The maximum number of instructions in a virtual machine program ** <dd>The maximum number of instructions in a virtual machine program
** used to implement an SQL statement. If [sqlite3_prepare_v2()] or ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
** the equivalent tries to allocate space for more than this many opcodes ** the equivalent tries to allocate space for more than this many opcodes
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^ ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
** **
@ -3480,6 +3481,24 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
#define SQLITE_LIMIT_TRIGGER_DEPTH 10 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
#define SQLITE_LIMIT_WORKER_THREADS 11 #define SQLITE_LIMIT_WORKER_THREADS 11
/*
** CAPI3REF: Prepare Flags
** KEYWORDS:
**
** These constants define various flags that can be passed into
** the [sqlite3_prepare_v3()] interface.
**
** <dl>
** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
** to optimize the resulting prepared statement to be retained for a
** relatively long amount of time.)^ ^Without this flag,
** [sqlite3_prepare_v3()] assumes that the prepared statement will be used
** just once or at most a few times and then destroyed using
** [sqlite3_finalize()] relatively soon.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT 0x01
/* /*
** CAPI3REF: Compiling An SQL Statement ** CAPI3REF: Compiling An SQL Statement
@ -3495,9 +3514,10 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** [sqlite3_open16()]. The database connection must not have been closed. ** [sqlite3_open16()]. The database connection must not have been closed.
** **
** The second argument, "zSql", is the statement to be compiled, encoded ** The second argument, "zSql", is the statement to be compiled, encoded
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() ** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() ** and sqlite3_prepare_v3()
** use UTF-16. ** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
** and sqlite3_prepare16_v3() use UTF-16.
** **
** ^If the nByte argument is negative, then zSql is read up to the ** ^If the nByte argument is negative, then zSql is read up to the
** first zero terminator. ^If nByte is positive, then it is the ** first zero terminator. ^If nByte is positive, then it is the
@ -3524,10 +3544,11 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
** otherwise an [error code] is returned. ** otherwise an [error code] is returned.
** **
** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are ** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
** recommended for all new programs. The two older interfaces are retained ** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
** for backwards compatibility, but their use is discouraged. ** The older interfaces are retained (sqlite3_prepare() and sqlite3_prepare16())
** ^In the "v2" interfaces, the prepared statement ** are retained for backwards compatibility, but their use is discouraged.
** ^In the "vX" interfaces, the prepared statement
** that is returned (the [sqlite3_stmt] object) contains a copy of the ** that is returned (the [sqlite3_stmt] object) contains a copy of the
** original SQL text. This causes the [sqlite3_step()] interface to ** original SQL text. This causes the [sqlite3_step()] interface to
** behave differently in three ways: ** behave differently in three ways:
@ -3560,6 +3581,12 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** or [GLOB] operator or if the parameter is compared to an indexed column ** or [GLOB] operator or if the parameter is compared to an indexed column
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
** </li> ** </li>
**
** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
** the extra prepFlags parameter, which is a bit array consisting of zero or
** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
** sqlite3_prepare_v2() interface works exactly the same as
** sqlite3_prepare_v3() with a zero prepFlags parameter.
** </ol> ** </ol>
*/ */
int sqlite3_prepare( int sqlite3_prepare(
@ -3576,6 +3603,14 @@ int sqlite3_prepare_v2(
sqlite3_stmt **ppStmt, /* OUT: Statement handle */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */ const char **pzTail /* OUT: Pointer to unused portion of zSql */
); );
int sqlite3_prepare_v3(
sqlite3 *db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
int sqlite3_prepare16( int sqlite3_prepare16(
sqlite3 *db, /* Database handle */ sqlite3 *db, /* Database handle */
const void *zSql, /* SQL statement, UTF-16 encoded */ const void *zSql, /* SQL statement, UTF-16 encoded */
@ -3590,6 +3625,14 @@ int sqlite3_prepare16_v2(
sqlite3_stmt **ppStmt, /* OUT: Statement handle */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const void **pzTail /* OUT: Pointer to unused portion of zSql */ const void **pzTail /* OUT: Pointer to unused portion of zSql */
); );
int sqlite3_prepare16_v3(
sqlite3 *db, /* Database handle */
const void *zSql, /* SQL statement, UTF-16 encoded */
int nByte, /* Maximum length of zSql in bytes. */
unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const void **pzTail /* OUT: Pointer to unused portion of zSql */
);
/* /*
** CAPI3REF: Retrieving Statement SQL ** CAPI3REF: Retrieving Statement SQL
@ -3597,7 +3640,8 @@ int sqlite3_prepare16_v2(
** **
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
** SQL text used to create [prepared statement] P if P was ** SQL text used to create [prepared statement] P if P was
** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
** string containing the SQL text of prepared statement P with ** string containing the SQL text of prepared statement P with
** [bound parameters] expanded. ** [bound parameters] expanded.
@ -3743,7 +3787,7 @@ typedef struct sqlite3_context sqlite3_context;
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
** METHOD: sqlite3_stmt ** METHOD: sqlite3_stmt
** **
** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
** literals may be replaced by a [parameter] that matches one of following ** literals may be replaced by a [parameter] that matches one of following
** templates: ** templates:
** **
@ -3762,7 +3806,7 @@ typedef struct sqlite3_context sqlite3_context;
** **
** ^The first argument to the sqlite3_bind_*() routines is always ** ^The first argument to the sqlite3_bind_*() routines is always
** a pointer to the [sqlite3_stmt] object returned from ** a pointer to the [sqlite3_stmt] object returned from
** [sqlite3_prepare_v2()] or its variants. ** [sqlite3_prepare_v3()] or its variants.
** **
** ^The second argument is the index of the SQL parameter to be set. ** ^The second argument is the index of the SQL parameter to be set.
** ^The leftmost SQL parameter has an index of 1. ^When the same named ** ^The leftmost SQL parameter has an index of 1. ^When the same named
@ -3899,8 +3943,8 @@ int sqlite3_bind_parameter_count(sqlite3_stmt*);
** ^If the value N is out of range or if the N-th parameter is ** ^If the value N is out of range or if the N-th parameter is
** nameless, then NULL is returned. ^The returned string is ** nameless, then NULL is returned. ^The returned string is
** always in UTF-8 encoding even if the named parameter was ** always in UTF-8 encoding even if the named parameter was
** originally specified as UTF-16 in [sqlite3_prepare16()] or ** originally specified as UTF-16 in [sqlite3_prepare16()],
** [sqlite3_prepare16_v2()]. ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
** **
** See also: [sqlite3_bind_blob|sqlite3_bind()], ** See also: [sqlite3_bind_blob|sqlite3_bind()],
** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_count()], and
@ -3917,7 +3961,8 @@ const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
** is returned if no matching parameter is found. ^The parameter ** is returned if no matching parameter is found. ^The parameter
** name must be given in UTF-8 even if the original statement ** name must be given in UTF-8 even if the original statement
** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
** [sqlite3_prepare16_v3()].
** **
** See also: [sqlite3_bind_blob|sqlite3_bind()], ** See also: [sqlite3_bind_blob|sqlite3_bind()],
** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_count()], and
@ -4071,16 +4116,18 @@ const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
** CAPI3REF: Evaluate An SQL Statement ** CAPI3REF: Evaluate An SQL Statement
** METHOD: sqlite3_stmt ** METHOD: sqlite3_stmt
** **
** After a [prepared statement] has been prepared using either ** After a [prepared statement] has been prepared using any of
** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy ** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
** or [sqlite3_prepare16_v3()] or one of the legacy
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
** must be called one or more times to evaluate the statement. ** must be called one or more times to evaluate the statement.
** **
** The details of the behavior of the sqlite3_step() interface depend ** The details of the behavior of the sqlite3_step() interface depend
** on whether the statement was prepared using the newer "v2" interface ** on whether the statement was prepared using the newer "vX" interfaces
** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy ** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the ** [sqlite3_prepare16_v2()] or the older legacy
** new "v2" interface is recommended for new applications but the legacy ** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
** new "vX" interface is recommended for new applications but the legacy
** interface will continue to be supported. ** interface will continue to be supported.
** **
** ^In the legacy interface, the return value will be either [SQLITE_BUSY], ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
@ -4141,10 +4188,11 @@ const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
** specific [error codes] that better describes the error. ** specific [error codes] that better describes the error.
** We admit that this is a goofy design. The problem has been fixed ** We admit that this is a goofy design. The problem has been fixed
** with the "v2" interface. If you prepare all of your SQL statements ** with the "v2" interface. If you prepare all of your SQL statements
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
** then the more specific [error codes] are returned directly ** then the more specific [error codes] are returned directly
** by sqlite3_step(). The use of the "v2" interface is recommended. ** by sqlite3_step(). The use of the "vX" interfaces is recommended.
*/ */
int sqlite3_step(sqlite3_stmt*); int sqlite3_step(sqlite3_stmt*);
@ -4209,7 +4257,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
** ^These routines return information about a single column of the current ** ^These routines return information about a single column of the current
** result row of a query. ^In every case the first argument is a pointer ** result row of a query. ^In every case the first argument is a pointer
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
** that was returned from [sqlite3_prepare_v2()] or one of its variants) ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
** and the second argument is the index of the column for which information ** and the second argument is the index of the column for which information
** should be returned. ^The leftmost column of the result set has the index 0. ** should be returned. ^The leftmost column of the result set has the index 0.
** ^The number of columns in the result can be determined using ** ^The number of columns in the result can be determined using
@ -5333,7 +5381,7 @@ int sqlite3_get_autocommit(sqlite3*);
** to which a [prepared statement] belongs. ^The [database connection] ** to which a [prepared statement] belongs. ^The [database connection]
** returned by sqlite3_db_handle is the same [database connection] ** returned by sqlite3_db_handle is the same [database connection]
** that was the first argument ** that was the first argument
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
** create the statement in the first place. ** create the statement in the first place.
*/ */
sqlite3 *sqlite3_db_handle(sqlite3_stmt*); sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
@ -5409,7 +5457,7 @@ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
** completion of the [sqlite3_step()] call that triggered the commit ** completion of the [sqlite3_step()] call that triggered the commit
** or rollback hook in the first place. ** or rollback hook in the first place.
** Note that running any other SQL statements, including SELECT statements, ** Note that running any other SQL statements, including SELECT statements,
** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
** the database connections for the meaning of "modify" in this paragraph. ** the database connections for the meaning of "modify" in this paragraph.
** **
** ^Registering a NULL function disables the callback. ** ^Registering a NULL function disables the callback.
@ -5469,7 +5517,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
** the database connection that invoked the update hook. Any actions ** the database connection that invoked the update hook. Any actions
** to modify the database connection must be deferred until after the ** to modify the database connection must be deferred until after the
** completion of the [sqlite3_step()] call that triggered the update hook. ** completion of the [sqlite3_step()] call that triggered the update hook.
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
** database connections for the meaning of "modify" in this paragraph. ** database connections for the meaning of "modify" in this paragraph.
** **
** ^The sqlite3_update_hook(D,C,P) function ** ^The sqlite3_update_hook(D,C,P) function

View File

@ -1215,12 +1215,18 @@ static int dbPrepare(
sqlite3_stmt **ppStmt, /* OUT: Prepared statement */ sqlite3_stmt **ppStmt, /* OUT: Prepared statement */
const char **pzOut /* OUT: Pointer to next SQL statement */ const char **pzOut /* OUT: Pointer to next SQL statement */
){ ){
unsigned int prepFlags = 0;
#ifdef SQLITE_TEST #ifdef SQLITE_TEST
if( pDb->bLegacyPrepare ){ if( pDb->bLegacyPrepare ){
return sqlite3_prepare(pDb->db, zSql, -1, ppStmt, pzOut); return sqlite3_prepare(pDb->db, zSql, -1, ppStmt, pzOut);
} }
#endif #endif
return sqlite3_prepare_v2(pDb->db, zSql, -1, ppStmt, pzOut); /* If the statement cache is large, use the SQLITE_PREPARE_PERSISTENT
** flags, which uses less lookaside memory. But if the cache is small,
** omit that flag to make full use of lookaside */
if( pDb->maxStmt>5 ) prepFlags = SQLITE_PREPARE_PERSISTENT;
return sqlite3_prepare_v3(pDb->db, zSql, -1, prepFlags, ppStmt, pzOut);
} }
/* /*

View File

@ -165,6 +165,12 @@ typedef struct VdbeOpList VdbeOpList;
*/ */
#include "opcodes.h" #include "opcodes.h"
/*
** Additional non-public SQLITE_PREPARE_* flags
*/
#define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
#define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
/* /*
** Prototypes for the VDBE interface. See comments on the implementation ** Prototypes for the VDBE interface. See comments on the implementation
** for a description of what each of these routines does. ** for a description of what each of these routines does.
@ -222,7 +228,8 @@ void sqlite3VdbeSetNumCols(Vdbe*,int);
int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
void sqlite3VdbeCountChanges(Vdbe*); void sqlite3VdbeCountChanges(Vdbe*);
sqlite3 *sqlite3VdbeDb(Vdbe*); sqlite3 *sqlite3VdbeDb(Vdbe*);
void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); u8 sqlite3VdbePrepareFlags(Vdbe*);
void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
void sqlite3VdbeSwap(Vdbe*,Vdbe*); void sqlite3VdbeSwap(Vdbe*,Vdbe*);
VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8); sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);

View File

@ -382,6 +382,7 @@ struct Vdbe {
u16 nResColumn; /* Number of columns in one row of the result set */ u16 nResColumn; /* Number of columns in one row of the result set */
u8 errorAction; /* Recovery action to do in case of an error */ u8 errorAction; /* Recovery action to do in case of an error */
u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 minWriteFileFormat; /* Minimum file format for writable database files */
u8 prepFlags; /* SQLITE_PREPARE_* flags */
bft expired:1; /* True if the VM needs to be recompiled */ bft expired:1; /* True if the VM needs to be recompiled */
bft doingRerun:1; /* True if rerunning after an auto-reprepare */ bft doingRerun:1; /* True if rerunning after an auto-reprepare */
bft explain:2; /* True if EXPLAIN present on SQL command */ bft explain:2; /* True if EXPLAIN present on SQL command */
@ -390,7 +391,6 @@ struct Vdbe {
bft usesStmtJournal:1; /* True if uses a statement journal */ bft usesStmtJournal:1; /* True if uses a statement journal */
bft readOnly:1; /* True for statements that do not write */ bft readOnly:1; /* True for statements that do not write */
bft bIsReader:1; /* True for statements that read */ bft bIsReader:1; /* True for statements that read */
bft isPrepareV2:1; /* True if prepared with prepare_v2() */
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
yDbMask lockMask; /* Subset of btreeMask that requires a lock */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */
u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */ u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */

View File

@ -154,7 +154,7 @@ int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
sqlite3VdbeMemRelease(&p->aVar[i]); sqlite3VdbeMemRelease(&p->aVar[i]);
p->aVar[i].flags = MEM_Null; p->aVar[i].flags = MEM_Null;
} }
assert( p->isPrepareV2 || p->expmask==0 ); assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
if( p->expmask ){ if( p->expmask ){
p->expired = 1; p->expired = 1;
} }
@ -633,8 +633,11 @@ end_of_step:
|| (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
); );
assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp ); assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
/* If this statement was prepared using sqlite3_prepare_v2(), and an && rc!=SQLITE_ROW
&& rc!=SQLITE_DONE
){
/* If this statement was prepared using saved SQL and an
** error has occurred, then return the error code in p->rc to the ** error has occurred, then return the error code in p->rc to the
** caller. Set the error code in the database handle to the same value. ** caller. Set the error code in the database handle to the same value.
*/ */
@ -1273,7 +1276,7 @@ static int vdbeUnbind(Vdbe *p, int i){
** as if there had been a schema change, on the first sqlite3_step() call ** as if there had been a schema change, on the first sqlite3_step() call
** following any change to the bindings of that parameter. ** following any change to the bindings of that parameter.
*/ */
assert( p->isPrepareV2 || p->expmask==0 ); assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){ if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
p->expired = 1; p->expired = 1;
} }
@ -1539,11 +1542,11 @@ int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
if( pFrom->nVar!=pTo->nVar ){ if( pFrom->nVar!=pTo->nVar ){
return SQLITE_ERROR; return SQLITE_ERROR;
} }
assert( pTo->isPrepareV2 || pTo->expmask==0 ); assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );
if( pTo->expmask ){ if( pTo->expmask ){
pTo->expired = 1; pTo->expired = 1;
} }
assert( pFrom->isPrepareV2 || pFrom->expmask==0 ); assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );
if( pFrom->expmask ){ if( pFrom->expmask ){
pFrom->expired = 1; pFrom->expired = 1;
} }

View File

@ -54,16 +54,14 @@ void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){
/* /*
** Remember the SQL string for a prepared statement. ** Remember the SQL string for a prepared statement.
*/ */
void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){
assert( isPrepareV2==1 || isPrepareV2==0 );
if( p==0 ) return; if( p==0 ) return;
if( !isPrepareV2 ) p->expmask = 0; p->prepFlags = prepFlags;
#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG) if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
if( !isPrepareV2 ) return; p->expmask = 0;
#endif }
assert( p->zSql==0 ); assert( p->zSql==0 );
p->zSql = sqlite3DbStrNDup(p->db, z, n); p->zSql = sqlite3DbStrNDup(p->db, z, n);
p->isPrepareV2 = (u8)isPrepareV2;
} }
/* /*
@ -85,11 +83,10 @@ void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
zTmp = pA->zSql; zTmp = pA->zSql;
pA->zSql = pB->zSql; pA->zSql = pB->zSql;
pB->zSql = zTmp; pB->zSql = zTmp;
pB->isPrepareV2 = pA->isPrepareV2;
pB->expmask = pA->expmask; pB->expmask = pA->expmask;
pB->prepFlags = pA->prepFlags;
memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter)); memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++; pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
} }
/* /*
@ -4533,6 +4530,13 @@ sqlite3 *sqlite3VdbeDb(Vdbe *v){
return v->db; return v->db;
} }
/*
** Return the SQLITE_PREPARE flags for a Vdbe.
*/
u8 sqlite3VdbePrepareFlags(Vdbe *v){
return v->prepFlags;
}
/* /*
** Return a pointer to an sqlite3_value structure containing the value bound ** Return a pointer to an sqlite3_value structure containing the value bound
** parameter iVar of VM v. Except, if the value is an SQL NULL, return ** parameter iVar of VM v. Except, if the value is an SQL NULL, return