1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Sync the latest trunk changes into the winRT branch.

FossilOrigin-Name: be4ab188cffbe97ae4f1f0520591bb7f0df185de
This commit is contained in:
drh
2012-05-04 23:11:21 +00:00
15 changed files with 2206 additions and 234 deletions

View File

@ -1,5 +1,5 @@
C Merge\sthe\slatest\strunk\schanges\sinto\sthe\sWinRT\sbranch\s(fixes\sfor\stickets\s[2a5629202f]\sand\s[385a5b56b9]). C Sync\sthe\slatest\strunk\schanges\sinto\sthe\swinRT\sbranch.
D 2012-04-21T00:31:21.773 D 2012-05-04T23:11:21.989
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -161,7 +161,7 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47 F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47
F src/os_win.c c3487c9c506c1253bb4c65abc3caf988b9addb6c F src/os_win.c c3487c9c506c1253bb4c65abc3caf988b9addb6c
F src/pager.c 85988507fa20acc60defb834722eddf4633e4aeb F src/pager.c bb5635dde0b152797836d1c72275284724bb563c
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
F src/parse.y eb054bb40a5bf90d3422a01ed0e5df229461727a F src/parse.y eb054bb40a5bf90d3422a01ed0e5df229461727a
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
@ -171,10 +171,10 @@ F src/pragma.c 149d8400ff783741d41389176832241cbff8f856
F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e
F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 969ec2bc52db1b068054ecf5ddc74f244102a71d F src/resolve.c 748e75299faff345f34f0e5bd02a2bac8aa69fcd
F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1
F src/select.c d7b9018b7dd2e821183d69477ab55c39b8272335 F src/select.c d7b9018b7dd2e821183d69477ab55c39b8272335
F src/shell.c 11185a9a4574f363bd4268a2780d37480ae00040 F src/shell.c 04399b2f9942bd02ed5ffee3b84bcdb39c52a1e6
F src/sqlite.h.in 21eb2ff783710a8cf2b435890dc1ffc750058169 F src/sqlite.h.in 21eb2ff783710a8cf2b435890dc1ffc750058169
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
F src/sqliteInt.h c5e917c4f1453f3972b1fd0c81105dfe4f09cc32 F src/sqliteInt.h c5e917c4f1453f3972b1fd0c81105dfe4f09cc32
@ -218,6 +218,7 @@ F src/test_quota.h ee5da2ae7f84d1c8e0e0e2ab33f01d69f10259b5
F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f
F src/test_spellfix.c 495535f3eb57acdc384572da570e869bb1834bf4
F src/test_stat.c d7035cfcc0ff1f93c000b621f36524318e004e11 F src/test_stat.c d7035cfcc0ff1f93c000b621f36524318e004e11
F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
@ -242,7 +243,7 @@ F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb
F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74
F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9
F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843 F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843
F src/vtab.c ab90fb600a3f5e4b7c48d22a4cdb2d6b23239847 F src/vtab.c ae657b1c22cff43863458e768a44f915c07bc0e4
F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146
F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
@ -535,7 +536,7 @@ F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6
F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4
F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1 F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1
F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f
F test/io.test b278aa8fa609ed0dcc825df31b2d9f526c5a52bd F test/io.test 36d251507d72e92b965fb2f0801c2f0b56335bcf
F test/ioerr.test 40bb2cfcab63fb6aa7424cd97812a84bc16b5fb8 F test/ioerr.test 40bb2cfcab63fb6aa7424cd97812a84bc16b5fb8
F test/ioerr2.test 9d71166f8466eda510f1af6137bdabaa82b5408d F test/ioerr2.test 9d71166f8466eda510f1af6137bdabaa82b5408d
F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd
@ -675,7 +676,7 @@ F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535
F test/select6.test cc25a8650cf9a4d4f74e586c45a75f9836516b18 F test/select6.test cc25a8650cf9a4d4f74e586c45a75f9836516b18
F test/select7.test dad6f00f0d49728a879d6eb6451d4752db0b0abe F test/select7.test dad6f00f0d49728a879d6eb6451d4752db0b0abe
F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d
F test/select9.test 74c0fb2c6eecb0219cbed0cbe3df136f8fbf9343 F test/select9.test c0ca3cd87a8ebb04de2cb1402c77df55d911a0ea
F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532 F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25 F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977 F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977
@ -688,6 +689,11 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9
F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e
F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de
F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf
F test/shell1.test 7dcd612b0018ddad783647d984fffa76791ffd3d w tool/shell1.test
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a w tool/shell2.test
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59 w tool/shell3.test
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 w tool/shell4.test
F test/shell5.test fa2188bbb13fe2d183fd04a5f7b512650c35ef5d w tool/shell5.test
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868 F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868
F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329
@ -719,7 +725,7 @@ F test/tclsqlite.test 1597d353308531527583481d14d9da52ea8ed0af
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2
F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d
F test/tester.tcl d06382066250b1c68b199d3656d090db5f9a9a16 F test/tester.tcl e1e5d5bc3453338ec7fded894614e059a5ce2c6a
F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91 F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@ -971,11 +977,6 @@ F tool/omittest.tcl 72a49b8a9a8b0bf213a438180307a0df836d4380
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
F tool/shell1.test 20dfe7099cf2afe37aecd69afb7678d14f7a0abf
F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3
F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836
F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce
F tool/shell5.test 0e987fb8d40638bb5c90163cb58cbe3e07dbed56
F tool/showdb.c 2e28d8e499b016485672e9a7ac65dacc0d28ff69 F tool/showdb.c 2e28d8e499b016485672e9a7ac65dacc0d28ff69
F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02
F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9
@ -994,7 +995,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 294a5cca5087b510c2483792631bbf98a415e254 7b8548b1872cc1225355ba8311e93dd08d6526e2 P 25478dcff59690a5f59c3b96600374184057eae9 bfa61e781cb442be641486e7e55a1518e888d830
R dd7224aee3a3a8ff8a26727b1243ba57 R ce5ef0f680ccee96865eacdf6d030fb3
U mistachkin U drh
Z 89bcb246fbfedd2e196bdf30f9fdc4fa Z e6cad85cf7d7f8dd84e66fcbcd8c3674

View File

@ -1 +1 @@
25478dcff59690a5f59c3b96600374184057eae9 be4ab188cffbe97ae4f1f0520591bb7f0df185de

View File

@ -3003,7 +3003,7 @@ static int pagerWalFrames(
PgHdr *p; PgHdr *p;
PgHdr **ppNext = &pList; PgHdr **ppNext = &pList;
nList = 0; nList = 0;
for(p=pList; (*ppNext = p); p=p->pDirty){ for(p=pList; (*ppNext = p)!=0; p=p->pDirty){
if( p->pgno<=nTruncate ){ if( p->pgno<=nTruncate ){
ppNext = &p->pDirty; ppNext = &p->pDirty;
nList++; nList++;

View File

@ -883,7 +883,7 @@ static int resolveOrderGroupBy(
ExprList *pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */ ExprList *pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */
const char *zType /* Either "ORDER" or "GROUP", as appropriate */ const char *zType /* Either "ORDER" or "GROUP", as appropriate */
){ ){
int i; /* Loop counter */ int i, j; /* Loop counters */
int iCol; /* Column number */ int iCol; /* Column number */
struct ExprList_item *pItem; /* A term of the ORDER BY clause */ struct ExprList_item *pItem; /* A term of the ORDER BY clause */
Parse *pParse; /* Parsing context */ Parse *pParse; /* Parsing context */
@ -920,6 +920,11 @@ static int resolveOrderGroupBy(
if( sqlite3ResolveExprNames(pNC, pE) ){ if( sqlite3ResolveExprNames(pNC, pE) ){
return 1; return 1;
} }
for(j=0; j<pSelect->pEList->nExpr; j++){
if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
pItem->iOrderByCol = j+1;
}
}
} }
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType); return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
} }

View File

@ -499,7 +499,7 @@ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
int i; int i;
char *zBlob = (char *)pBlob; char *zBlob = (char *)pBlob;
fprintf(out,"X'"); fprintf(out,"X'");
for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]); } for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]&0xff); }
fprintf(out,"'"); fprintf(out,"'");
} }
@ -2248,46 +2248,71 @@ static int do_meta_command(char *zLine, struct callback_data *p){
}else }else
if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){ if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){
sqlite3_stmt *pStmt;
char **azResult; char **azResult;
int nRow; int nRow, nAlloc;
char *zErrMsg; char *zSql = 0;
int ii;
open_db(p); open_db(p);
if( nArg==1 ){ rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
rc = sqlite3_get_table(p->db, if( rc ) return rc;
zSql = sqlite3_mprintf(
"SELECT name FROM sqlite_master" "SELECT name FROM sqlite_master"
"WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' "
"UNION ALL "
"SELECT name FROM sqlite_temp_master "
" WHERE type IN ('table','view')" " WHERE type IN ('table','view')"
"ORDER BY 1", " AND name NOT LIKE 'sqlite_%%'"
&azResult, &nRow, 0, &zErrMsg " AND name LIKE ?1");
); while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
if( zDbName==0 || strcmp(zDbName,"main")==0 ) continue;
if( strcmp(zDbName,"temp")==0 ){
zSql = sqlite3_mprintf(
"%z UNION ALL "
"SELECT 'temp.' || name FROM sqlite_temp_master"
" WHERE type IN ('table','view')"
" AND name NOT LIKE 'sqlite_%%'"
" AND name LIKE ?1", zSql);
}else{ }else{
zShellStatic = azArg[1]; zSql = sqlite3_mprintf(
rc = sqlite3_get_table(p->db, "%z UNION ALL "
"SELECT name FROM sqlite_master " "SELECT '%q.' || name FROM \"%w\".sqlite_master"
"WHERE type IN ('table','view') AND name LIKE shellstatic() " " WHERE type IN ('table','view')"
"UNION ALL " " AND name NOT LIKE 'sqlite_%%'"
"SELECT name FROM sqlite_temp_master " " AND name LIKE ?1", zSql, zDbName, zDbName);
"WHERE type IN ('table','view') AND name LIKE shellstatic() "
"ORDER BY 1",
&azResult, &nRow, 0, &zErrMsg
);
zShellStatic = 0;
} }
if( zErrMsg ){ }
fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_finalize(pStmt);
sqlite3_free(zErrMsg); zSql = sqlite3_mprintf("%z ORDER BY 1", zSql);
rc = 1; rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
}else if( rc != SQLITE_OK ){ sqlite3_free(zSql);
fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n"); if( rc ) return rc;
rc = 1; nRow = nAlloc = 0;
azResult = 0;
if( nArg>1 ){
sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT);
}else{ }else{
sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
}
while( sqlite3_step(pStmt)==SQLITE_ROW ){
if( nRow>=nAlloc ){
char **azNew;
int n = nAlloc*2 + 10;
azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n);
if( azNew==0 ){
fprintf(stderr, "Error: out of memory\n");
break;
}
nAlloc = n;
azResult = azNew;
}
azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
if( azResult[nRow] ) nRow++;
}
sqlite3_finalize(pStmt);
if( nRow>0 ){
int len, maxlen = 0; int len, maxlen = 0;
int i, j; int i, j;
int nPrintCol, nPrintRow; int nPrintCol, nPrintRow;
for(i=1; i<=nRow; i++){ for(i=0; i<nRow; i++){
if( azResult[i]==0 ) continue;
len = strlen30(azResult[i]); len = strlen30(azResult[i]);
if( len>maxlen ) maxlen = len; if( len>maxlen ) maxlen = len;
} }
@ -2295,14 +2320,15 @@ static int do_meta_command(char *zLine, struct callback_data *p){
if( nPrintCol<1 ) nPrintCol = 1; if( nPrintCol<1 ) nPrintCol = 1;
nPrintRow = (nRow + nPrintCol - 1)/nPrintCol; nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
for(i=0; i<nPrintRow; i++){ for(i=0; i<nPrintRow; i++){
for(j=i+1; j<=nRow; j+=nPrintRow){ for(j=i; j<nRow; j+=nPrintRow){
char *zSp = j<=nPrintRow ? "" : " "; char *zSp = j<nPrintRow ? "" : " ";
printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : ""); printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : "");
} }
printf("\n"); printf("\n");
} }
} }
sqlite3_free_table(azResult); for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);
sqlite3_free(azResult);
}else }else
if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){ if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){
@ -2437,6 +2463,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
}else }else
if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){ if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){
open_db(p);
output_file_close(p->traceOut); output_file_close(p->traceOut);
p->traceOut = output_file_open(azArg[1]); p->traceOut = output_file_open(azArg[1]);
#ifndef SQLITE_OMIT_TRACE #ifndef SQLITE_OMIT_TRACE
@ -2572,7 +2599,9 @@ static int process_input(struct callback_data *p, FILE *in){
free(zLine); free(zLine);
zLine = one_input_line(zSql, in); zLine = one_input_line(zSql, in);
if( zLine==0 ){ if( zLine==0 ){
break; /* We have reached EOF */ /* End of input */
if( stdin_is_interactive ) printf("\n");
break;
} }
if( seenInterrupt ){ if( seenInterrupt ){
if( in!=0 ) break; if( in!=0 ) break;

1951
src/test_spellfix.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -447,7 +447,7 @@ static int vtabCallConstructor(
int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**), int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
char **pzErr char **pzErr
){ ){
VtabCtx sCtx; VtabCtx sCtx, *pPriorCtx;
VTable *pVTable; VTable *pVTable;
int rc; int rc;
const char *const*azArg = (const char *const*)pTab->azModuleArg; const char *const*azArg = (const char *const*)pTab->azModuleArg;
@ -472,9 +472,10 @@ static int vtabCallConstructor(
assert( xConstruct ); assert( xConstruct );
sCtx.pTab = pTab; sCtx.pTab = pTab;
sCtx.pVTable = pVTable; sCtx.pVTable = pVTable;
pPriorCtx = db->pVtabCtx;
db->pVtabCtx = &sCtx; db->pVtabCtx = &sCtx;
rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr); rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
db->pVtabCtx = 0; db->pVtabCtx = pPriorCtx;
if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
if( SQLITE_OK!=rc ){ if( SQLITE_OK!=rc ){

View File

@ -146,11 +146,15 @@ do_test io-2.2 {
# written because page 1 - the change-counter page - is written using # written because page 1 - the change-counter page - is written using
# an out-of-band method that bypasses the write counter. # an out-of-band method that bypasses the write counter.
# #
# UPDATE: As of [05f98d4eec] (adding SQLITE_DBSTATUS_CACHE_WRITE), the
# second write is also counted. So this now reports two writes and a
# single fsync.
#
sqlite3_simulate_device -char atomic sqlite3_simulate_device -char atomic
do_test io-2.3 { do_test io-2.3 {
execsql { INSERT INTO abc VALUES(3, 4) } execsql { INSERT INTO abc VALUES(3, 4) }
list [nWrite db] [nSync] list [nWrite db] [nSync]
} {1 1} } {2 1}
# Test that the journal file is not created and the change-counter is # Test that the journal file is not created and the change-counter is
# updated when the atomic-write optimization is used. # updated when the atomic-write optimization is used.

View File

@ -415,5 +415,40 @@ do_test select9-4.X {
} }
} {} } {}
# Testing to make sure that queries involving a view of a compound select
# are planned efficiently. This detects a problem reported on the mailing
# list on 2012-04-26. See
#
# http://www.mail-archive.com/sqlite-users%40sqlite.org/msg69746.html
#
# For additional information.
#
do_test select9-5.1 {
db eval {
CREATE TABLE t51(x, y);
CREATE TABLE t52(x, y);
CREATE VIEW v5 as
SELECT x, y FROM t51
UNION ALL
SELECT x, y FROM t52;
CREATE INDEX t51x ON t51(x);
CREATE INDEX t52x ON t52(x);
EXPLAIN QUERY PLAN
SELECT * FROM v5 WHERE x='12345' ORDER BY y;
}
} {~/SCAN TABLE/} ;# Uses indices with "*"
do_test select9-5.2 {
db eval {
EXPLAIN QUERY PLAN
SELECT x, y FROM v5 WHERE x='12345' ORDER BY y;
}
} {~/SCAN TABLE/} ;# Uses indices with "x, y"
do_test select9-5.3 {
db eval {
EXPLAIN QUERY PLAN
SELECT x, y FROM v5 WHERE +x='12345' ORDER BY y;
}
} {/SCAN TABLE/} ;# Full table scan if the "+x" prevents index usage.
finish_test finish_test

View File

@ -11,7 +11,6 @@
# #
# The focus of this file is testing the CLI shell tool. # The focus of this file is testing the CLI shell tool.
# #
# $Id: shell1.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
# #
# Test plan: # Test plan:
@ -20,44 +19,19 @@
# shell1-2.*: Basic "dot" command token parsing. # shell1-2.*: Basic "dot" command token parsing.
# shell1-3.*: Basic test that "dot" command can be called. # shell1-3.*: Basic test that "dot" command can be called.
# #
set testdir [file dirname $argv0]
package require sqlite3 source $testdir/tester.tcl
if {$tcl_platform(platform)=="windows"} {
set CLI "./sqlite3" set CLI "sqlite3.exe"
proc do_test {name cmd expected} {
puts -nonewline "$name ..."
set res [uplevel $cmd]
if {$res eq $expected} {
puts Ok
} else { } else {
puts Error set CLI "./sqlite3"
puts " Got: $res"
puts " Expected: $expected"
exit
} }
if {![file executable $CLI]} {
finish_test
return
} }
db close
proc execsql {sql} { forcedelete test.db test.db-journal test.db-wal
uplevel [list db eval $sql]
}
proc catchsql {sql} {
set rc [catch {uplevel [list db eval $sql]} msg]
list $rc $msg
}
proc catchcmd {db {cmd ""}} {
global CLI
set out [open cmds.txt w]
puts $out $cmd
close $out
set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg
}
file delete -force test.db test.db.journal
sqlite3 db test.db sqlite3 db test.db
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -717,4 +691,33 @@ do_test shell1-3-28.1 {
".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');" ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
} "0 {(123) hello\n456}" } "0 {(123) hello\n456}"
puts "CLI tests completed successfully" # Test the output of the ".dump" command
#
do_test shell1-4.1 {
db eval {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(null), (1), (2.25), ('hello'), (x'807f');
}
catchcmd test.db {.dump}
} {0 {PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE t1(x);
INSERT INTO "t1" VALUES(NULL);
INSERT INTO "t1" VALUES(1);
INSERT INTO "t1" VALUES(2.25);
INSERT INTO "t1" VALUES('hello');
INSERT INTO "t1" VALUES(X'807F');
COMMIT;}}
# Test the output of ".mode insert"
#
do_test shell1-4.2 {
catchcmd test.db ".mode insert t1\nselect * from t1;"
} {0 {INSERT INTO t1 VALUES(NULL);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2.25);
INSERT INTO t1 VALUES('hello');
INSERT INTO t1 VALUES(X'807f');}}
finish_test

View File

@ -18,44 +18,19 @@
# #
# shell2-1.*: Misc. test of various tickets and reported errors. # shell2-1.*: Misc. test of various tickets and reported errors.
# #
set testdir [file dirname $argv0]
package require sqlite3 source $testdir/tester.tcl
if {$tcl_platform(platform)=="windows"} {
set CLI "./sqlite3" set CLI "sqlite3.exe"
proc do_test {name cmd expected} {
puts -nonewline "$name ..."
set res [uplevel $cmd]
if {$res eq $expected} {
puts Ok
} else { } else {
puts Error set CLI "./sqlite3"
puts " Got: $res"
puts " Expected: $expected"
exit
} }
if {![file executable $CLI]} {
finish_test
return
} }
db close
proc execsql {sql} { forcedelete test.db test.db-journal test.db-wal
uplevel [list db eval $sql]
}
proc catchsql {sql} {
set rc [catch {uplevel [list db eval $sql]} msg]
list $rc $msg
}
proc catchcmd {db {cmd ""}} {
global CLI
set out [open cmds.txt w]
puts $out $cmd
close $out
set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg
}
file delete -force test.db test.db.journal
sqlite3 db test.db sqlite3 db test.db
@ -219,4 +194,4 @@ b
1 1
2}} 2}}
puts "CLI tests completed successfully" finish_test

View File

@ -19,47 +19,21 @@
# shell3-1.*: Basic tests for running SQL statments from command line. # shell3-1.*: Basic tests for running SQL statments from command line.
# shell3-2.*: Basic tests for running SQL file from command line. # shell3-2.*: Basic tests for running SQL file from command line.
# #
set testdir [file dirname $argv0]
package require sqlite3 source $testdir/tester.tcl
if {$tcl_platform(platform)=="windows"} {
set CLI "./sqlite3" set CLI "sqlite3.exe"
proc do_test {name cmd expected} {
puts -nonewline "$name ..."
set res [uplevel $cmd]
if {$res eq $expected} {
puts Ok
} else { } else {
puts Error set CLI "./sqlite3"
puts " Got: $res"
puts " Expected: $expected"
exit
} }
if {![file executable $CLI]} {
finish_test
return
} }
db close
proc execsql {sql} { forcedelete test.db test.db-journal test.db-wal
uplevel [list db eval $sql]
}
proc catchsql {sql} {
set rc [catch {uplevel [list db eval $sql]} msg]
list $rc $msg
}
proc catchcmd {db {cmd ""}} {
global CLI
set out [open cmds.txt w]
puts $out $cmd
close $out
set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg
}
file delete -force test.db test.db.journal
sqlite3 db test.db sqlite3 db test.db
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# shell3-1.*: Basic tests for running SQL statments from command line. # shell3-1.*: Basic tests for running SQL statments from command line.
# #
@ -120,5 +94,4 @@ do_test shell3-2.7 {
catchcmd "foo.db" "CREATE TABLE" catchcmd "foo.db" "CREATE TABLE"
} {1 {Error: incomplete SQL: CREATE TABLE}} } {1 {Error: incomplete SQL: CREATE TABLE}}
finish_test
puts "CLI tests completed successfully"

View File

@ -19,33 +19,20 @@
# #
# shell4-1.*: Basic tests specific to the "stats" command. # shell4-1.*: Basic tests specific to the "stats" command.
# #
set testdir [file dirname $argv0]
set CLI "./sqlite3" source $testdir/tester.tcl
if {$tcl_platform(platform)=="windows"} {
proc do_test {name cmd expected} { set CLI "sqlite3.exe"
puts -nonewline "$name ..."
set res [uplevel $cmd]
if {$res eq $expected} {
puts Ok
} else { } else {
puts Error set CLI "./sqlite3"
puts " Got: $res"
puts " Expected: $expected"
exit
} }
if {![file executable $CLI]} {
finish_test
return
} }
db close
proc catchcmd {db {cmd ""}} { forcedelete test.db test.db-journal test.db-wal
global CLI sqlite3 db test.db
set out [open cmds.txt w]
puts $out $cmd
close $out
set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg
}
file delete -force test.db test.db.journal
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Test cases shell4-1.*: Tests specific to the "stats" command. # Test cases shell4-1.*: Tests specific to the "stats" command.
@ -126,4 +113,4 @@ SELECT 1;
[regexp {Autoindex Inserts} $res] [regexp {Autoindex Inserts} $res]
} {1 1 1} } {1 1 1}
puts "CLI tests completed successfully" finish_test

View File

@ -19,33 +19,20 @@
# #
# shell5-1.*: Basic tests specific to the ".import" command. # shell5-1.*: Basic tests specific to the ".import" command.
# #
set testdir [file dirname $argv0]
set CLI "./sqlite3" source $testdir/tester.tcl
if {$tcl_platform(platform)=="windows"} {
proc do_test {name cmd expected} { set CLI "sqlite3.exe"
puts -nonewline "$name ..."
set res [uplevel $cmd]
if {$res eq $expected} {
puts Ok
} else { } else {
puts Error set CLI "./sqlite3"
puts " Got: $res"
puts " Expected: $expected"
exit
} }
if {![file executable $CLI]} {
finish_test
return
} }
db close
proc catchcmd {db {cmd ""}} { forcedelete test.db test.db-journal test.db-wal
global CLI sqlite3 db test.db
set out [open cmds.txt w]
puts $out $cmd
close $out
set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg
}
file delete -force test.db test.db.journal
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Test cases shell5-1.*: Basic handling of the .import and .separator commands. # Test cases shell5-1.*: Basic handling of the .import and .separator commands.
@ -239,5 +226,4 @@ do_test shell5-1.7.1 {
SELECT COUNT(*) FROM t3;}] SELECT COUNT(*) FROM t3;}]
} [list 0 $rows] } [list 0 $rows]
finish_test
puts "CLI tests completed successfully"

View File

@ -504,7 +504,6 @@ proc incr_ntest {} {
# Invoke the do_test procedure to run a single test # Invoke the do_test procedure to run a single test
# #
proc do_test {name cmd expected} { proc do_test {name cmd expected} {
global argv cmdlinearg global argv cmdlinearg
fix_testname name fix_testname name
@ -535,12 +534,25 @@ proc do_test {name cmd expected} {
if {[catch {uplevel #0 "$cmd;\n"} result]} { if {[catch {uplevel #0 "$cmd;\n"} result]} {
puts "\nError: $result" puts "\nError: $result"
fail_test $name fail_test $name
} elseif {[string compare $result $expected]} { } else {
if {[regexp {^~?/.*/$} $expected]} {
if {[string index $expected 0]=="~"} {
set re [string range $expected 2 end-1]
set ok [expr {![regexp $re $result]}]
} else {
set re [string range $expected 1 end-1]
set ok [regexp $re $result]
}
} else {
set ok [expr {[string compare $result $expected]==0}]
}
if {!$ok} {
puts "\nExpected: \[$expected\]\n Got: \[$result\]" puts "\nExpected: \[$expected\]\n Got: \[$result\]"
fail_test $name fail_test $name
} else { } else {
puts " Ok" puts " Ok"
} }
}
} else { } else {
puts " Omitted" puts " Omitted"
omit_test $name "pattern mismatch" 0 omit_test $name "pattern mismatch" 0
@ -548,6 +560,16 @@ proc do_test {name cmd expected} {
flush stdout flush stdout
} }
proc catchcmd {db {cmd ""}} {
global CLI
set out [open cmds.txt w]
puts $out $cmd
close $out
set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg
}
proc filepath_normalize {p} { proc filepath_normalize {p} {
# test cases should be written to assume "unix"-like file paths # test cases should be written to assume "unix"-like file paths
if {$::tcl_platform(platform)!="unix"} { if {$::tcl_platform(platform)!="unix"} {