From 4207a3fb9bfa73ab30077bb4f9dfe09fb871f164 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Feb 2013 14:04:28 +0000 Subject: [PATCH 01/45] Add recent API additions to the extension mechanism. FossilOrigin-Name: 7e10a62d0eb1cb2bdafb6752b78a9d368e9f21f5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite3ext.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index df59845dbb..2555acf5c8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\san\sindex\sto\sbe\sused\sfor\ssorting\seven\sif\sprior\sterms\sof\sthe\sindex\nare\sconstrained\sby\sIN\soperators. -D 2013-02-13T01:00:35.115 +C Add\srecent\sAPI\sadditions\sto\sthe\sextension\smechanism. +D 2013-02-13T14:04:28.390 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/select.c 7818b5c9b497499d8bd8c6d0e347a3cf67724867 F src/shell.c 266791241d7add796ccce2317977ae6c3c67d77f F src/sqlite.h.in 6296506a8fba279d8fa31f4abf01ab0cc92738a6 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 -F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 +F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75 F src/sqliteInt.h 758285f17a55bc37b6f042aa3a2464e74327f4a5 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P cdbca259da80df901837034d2616da434cb82216 71b6c26053fdf2a5a84116e005bad1f2ca873a66 -R 77755448a8b45c569e7779e037e5b44c +P 2cef8b68f0e1216cf68bb7dd45a5a9a330748070 +R cabc7a2fdbd232266103a87943ce9702 U drh -Z c2bdfa94c74d9c022b301306a5110614 +Z afea31491ba485b5cd581a2534ab702a diff --git a/manifest.uuid b/manifest.uuid index d635e5fced..6561e32438 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2cef8b68f0e1216cf68bb7dd45a5a9a330748070 \ No newline at end of file +7e10a62d0eb1cb2bdafb6752b78a9d368e9f21f5 \ No newline at end of file diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 5abcde2c8f..a465b8eccc 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -236,6 +236,20 @@ struct sqlite3_api_routines { int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); int (*vtab_config)(sqlite3*,int op,...); int (*vtab_on_conflict)(sqlite3*); + /* Version 3.7.16 and later */ + int (*close_v2)(sqlite3*); + const char *(*db_filename)(sqlite3*,const char*); + int (*db_readonly)(sqlite3*,const char*); + int (*db_release_memory)(sqlite3*); + const char *(*errstr)(int); + int (*stmt_busy)(sqlite3_stmt*); + int (*stmt_readonly)(sqlite3_stmt*); + int (*stricmp)(const char*,const char*); + int (*uri_boolean)(const char*,const char*,int); + sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64); + const char *(*uri_parameter)(const char*,const char*); + char *(*vsnprintf)(int,char*,const char*,va_list); + int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); }; /* @@ -439,6 +453,20 @@ struct sqlite3_api_routines { #define sqlite3_blob_reopen sqlite3_api->blob_reopen #define sqlite3_vtab_config sqlite3_api->vtab_config #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict +/* Version 3.7.16 and later */ +#define sqlite3_close_v2 sqlite3_api->close_v2 +#define sqlite3_db_filename sqlite3_api->db_filename +#define sqlite3_db_readonly sqlite3_api->db_readonly +#define sqlite3_db_release_memory sqlite3_api->db_release_memory +#define sqlite3_errstr sqlite3_api->errstr +#define sqlite3_stmt_busy sqlite3_api->stmt_busy +#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly +#define sqlite3_stricmp sqlite3_api->stricmp +#define sqlite3_uri_boolean sqlite3_api->uri_boolean +#define sqlite3_uri_int64 sqlite3_api->uri_int64 +#define sqlite3_uri_parameter sqlite3_api->uri_parameter +#define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf +#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 #endif /* SQLITE_CORE */ #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0; From 9ce59a947faa3a6c141602062d516d5abccde38f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 13 Feb 2013 22:54:03 +0000 Subject: [PATCH 02/45] On WinCE, fill in the winFile structure after winceCreateLock has succeeded. FossilOrigin-Name: ec13544ce336e8a02b34d574ced5912b06c82c0e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 30 +++++++++++++----------------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 2555acf5c8..682d1cdfa5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\srecent\sAPI\sadditions\sto\sthe\sextension\smechanism. -D 2013-02-13T14:04:28.390 +C On\sWinCE,\sfill\sin\sthe\swinFile\sstructure\safter\swinceCreateLock\shas\ssucceeded. +D 2013-02-13T22:54:03.955 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -161,7 +161,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c dfdc04b126f7b05dcb2e2cc5c1262f98acbb49d9 -F src/os_win.c e988c2de4266fbb3b8c58e4b5550a2e17f541327 +F src/os_win.c e27fafe8d04841bbe8d925003a4276b80fb59e73 F src/pager.c 4092c907222cfd451c74fe6bd2fd64b342f7190f F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 2cef8b68f0e1216cf68bb7dd45a5a9a330748070 -R cabc7a2fdbd232266103a87943ce9702 -U drh -Z afea31491ba485b5cd581a2534ab702a +P 7e10a62d0eb1cb2bdafb6752b78a9d368e9f21f5 +R 6de95ef06bdbb69d4dc56118d603276a +U mistachkin +Z cedfeda70156e3f731cd5d4242d033d6 diff --git a/manifest.uuid b/manifest.uuid index 6561e32438..5da994060e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e10a62d0eb1cb2bdafb6752b78a9d368e9f21f5 \ No newline at end of file +ec13544ce336e8a02b34d574ced5912b06c82c0e \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index bbc9c27b7a..59ff6833fa 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2076,6 +2076,7 @@ static int winClose(sqlite3_file *id){ assert( pFile->pShm==0 ); #endif OSTRACE(("CLOSE %d\n", pFile->h)); + assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE ); do{ rc = osCloseHandle(pFile->h); /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ @@ -3687,8 +3688,9 @@ static int winOpen( || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL ); - assert( id!=0 ); - UNUSED_PARAMETER(pVfs); + assert( pFile!=0 ); + memset(pFile, 0, sizeof(winFile)); + pFile->h = INVALID_HANDLE_VALUE; #if SQLITE_OS_WINRT if( !sqlite3_temp_directory ){ @@ -3697,8 +3699,6 @@ static int winOpen( } #endif - pFile->h = INVALID_HANDLE_VALUE; - /* If the second argument to this function is NULL, generate a ** temporary file name to use */ @@ -3841,19 +3841,6 @@ static int winOpen( } } - memset(pFile, 0, sizeof(*pFile)); - pFile->pMethod = &winIoMethod; - pFile->h = h; - pFile->lastErrno = NO_ERROR; - pFile->pVfs = pVfs; -#ifndef SQLITE_OMIT_WAL - pFile->pShm = 0; -#endif - pFile->zPath = zName; - if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ - pFile->ctrlFlags |= WINFILE_PSOW; - } - #if SQLITE_OS_WINCE if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK @@ -3870,6 +3857,15 @@ static int winOpen( sqlite3_free(zConverted); } + pFile->pMethod = &winIoMethod; + pFile->pVfs = pVfs; + pFile->h = h; + if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ + pFile->ctrlFlags |= WINFILE_PSOW; + } + pFile->lastErrno = NO_ERROR; + pFile->zPath = zName; + OpenCounter(+1); return rc; } From c95e01da22a96b2902b86aa684d21a9fc1dd30ea Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Feb 2013 16:16:05 +0000 Subject: [PATCH 03/45] Verify that the schema has not changed before running PRAGMA table_info, index_list, index_info, and foreign_key_list. FossilOrigin-Name: 82952d08f3e3aa80a7f51e80dbc89742cb4a09f0 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pragma.c | 4 ++++ test/pragma.test | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 682d1cdfa5..9264eb38e9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sWinCE,\sfill\sin\sthe\swinFile\sstructure\safter\swinceCreateLock\shas\ssucceeded. -D 2013-02-13T22:54:03.955 +C Verify\sthat\sthe\sschema\shas\snot\schanged\sbefore\srunning\sPRAGMA\stable_info,\nindex_list,\sindex_info,\sand\sforeign_key_list. +D 2013-02-14T16:16:05.951 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -168,7 +168,7 @@ F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9 -F src/pragma.c eb9d39e30f00e3ba51892749ddf9d7b86541c43e +F src/pragma.c bdb484d0283965c431d4153f28c30f836a1f16b1 F src/prepare.c 931ad0d852a0df48f79adcba6ce79ca5f475625c F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -656,7 +656,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/permutations.test 360b92859c0af814b3fe10b68746936389606501 -F test/pragma.test 5ce333cae37d86cfe9b3add840906e375e2272b0 +F test/pragma.test 60d29cd3d8098a2c20bf4c072810f99e3bf2757a F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 7e10a62d0eb1cb2bdafb6752b78a9d368e9f21f5 -R 6de95ef06bdbb69d4dc56118d603276a -U mistachkin -Z cedfeda70156e3f731cd5d4242d033d6 +P ec13544ce336e8a02b34d574ced5912b06c82c0e +R 2ef63d6ca4f42c051984cca4b5f3160e +U drh +Z accaf6a360627091cc9269e7b19cca54 diff --git a/manifest.uuid b/manifest.uuid index 5da994060e..95e3672938 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec13544ce336e8a02b34d574ced5912b06c82c0e \ No newline at end of file +82952d08f3e3aa80a7f51e80dbc89742cb4a09f0 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index babcbec629..9927c50f2a 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -958,6 +958,7 @@ void sqlite3Pragma( for(pPk=pTab->pIndex; pPk && pPk->autoIndex!=2; pPk=pPk->pNext){} sqlite3VdbeSetNumCols(v, 6); pParse->nMem = 6; + sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", SQLITE_STATIC); @@ -1003,6 +1004,7 @@ void sqlite3Pragma( pTab = pIdx->pTable; sqlite3VdbeSetNumCols(v, 3); pParse->nMem = 3; + sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC); @@ -1029,6 +1031,7 @@ void sqlite3Pragma( int i = 0; sqlite3VdbeSetNumCols(v, 3); pParse->nMem = 3; + sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC); @@ -1092,6 +1095,7 @@ void sqlite3Pragma( int i = 0; sqlite3VdbeSetNumCols(v, 8); pParse->nMem = 8; + sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "id", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC); diff --git a/test/pragma.test b/test/pragma.test index db6271c033..3eb624328e 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -1626,4 +1626,48 @@ do_test 22.4.3 { execsql { PRAGMA aux.integrity_check; } } {ok} +db close +forcedelete test.db test.db-wal test.db-journal +sqlite3 db test.db +sqlite3 db2 test.db +do_test 23.1 { + db eval { + CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d); + CREATE INDEX i1 ON t1(b,c); + CREATE INDEX i2 ON t1(c,d); + CREATE TABLE t2(x INTEGER REFERENCES t1); + } + db2 eval {SELECT name FROM sqlite_master} +} {t1 i1 i2 t2} +do_test 23.2 { + db eval { + DROP INDEX i2; + CREATE INDEX i2 ON t1(c,d,b); + } + db2 eval {PRAGMA index_info(i2)} +} {0 2 c 1 3 d 2 1 b} +do_test 23.3 { + db eval { + CREATE INDEX i3 ON t1(d,b,c); + } + db2 eval {PRAGMA index_list(t1)} +} {0 i3 0 1 i2 0 2 i1 0} +do_test 23.4 { + db eval { + ALTER TABLE t1 ADD COLUMN e; + } + db2 eval { + PRAGMA table_info(t1); + } +} {/4 e {} 0 {} 0/} +do_test 23.5 { + db eval { + DROP TABLE t2; + CREATE TABLE t2(x, y INTEGER REFERENCES t1); + } + db2 eval { + PRAGMA foreign_key_list(t2); + } +} {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE} + finish_test From 4600255a88d42f434d4372f1ca05aae3998df7f2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Feb 2013 04:21:01 +0000 Subject: [PATCH 04/45] Check for a NULL handle prior to manually calling winClose. FossilOrigin-Name: 843e1c543aabab8cd62f28742d5818887d36bcb7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9264eb38e9..003c2d122c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Verify\sthat\sthe\sschema\shas\snot\schanged\sbefore\srunning\sPRAGMA\stable_info,\nindex_list,\sindex_info,\sand\sforeign_key_list. -D 2013-02-14T16:16:05.951 +C Check\sfor\sa\sNULL\shandle\sprior\sto\smanually\scalling\swinClose. +D 2013-02-15T04:21:01.777 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -161,7 +161,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c dfdc04b126f7b05dcb2e2cc5c1262f98acbb49d9 -F src/os_win.c e27fafe8d04841bbe8d925003a4276b80fb59e73 +F src/os_win.c eabd00b813577d36bd66271cb08dd64ea0589dac F src/pager.c 4092c907222cfd451c74fe6bd2fd64b342f7190f F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P ec13544ce336e8a02b34d574ced5912b06c82c0e -R 2ef63d6ca4f42c051984cca4b5f3160e -U drh -Z accaf6a360627091cc9269e7b19cca54 +P 82952d08f3e3aa80a7f51e80dbc89742cb4a09f0 +R 1a81a87cce363420c7383bdc29f10671 +U mistachkin +Z 6e06285ee204b9b14328949d07dc3790 diff --git a/manifest.uuid b/manifest.uuid index 95e3672938..fd8b6d4e7a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -82952d08f3e3aa80a7f51e80dbc89742cb4a09f0 \ No newline at end of file +843e1c543aabab8cd62f28742d5818887d36bcb7 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 59ff6833fa..68aba744cb 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2993,7 +2993,7 @@ static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){ (int)osGetCurrentProcessId(), i, bRc ? "ok" : "failed")); } - if( p->hFile.h != INVALID_HANDLE_VALUE ){ + if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){ SimulateIOErrorBenign(1); winClose((sqlite3_file *)&p->hFile); SimulateIOErrorBenign(0); From c8ac0d16492631eb7ad59219f20564353800f20c Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 16 Feb 2013 02:41:01 +0000 Subject: [PATCH 05/45] Fix an unsafe VM register deallocation. FossilOrigin-Name: cfba2c8dadbf1fa6f1602a327933570820a3b134 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 9 ++------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 003c2d122c..e5a46828f7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Check\sfor\sa\sNULL\shandle\sprior\sto\smanually\scalling\swinClose. -D 2013-02-15T04:21:01.777 +C Fix\san\sunsafe\sVM\sregister\sdeallocation. +D 2013-02-16T02:41:01.780 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -174,7 +174,7 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 652ae6dc0f185b01b4536bb2fa7d878f13f0f1df F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 7818b5c9b497499d8bd8c6d0e347a3cf67724867 +F src/select.c e1c6f6abdf9f359f4e735cb8ae11d2f359bf52a9 F src/shell.c 266791241d7add796ccce2317977ae6c3c67d77f F src/sqlite.h.in 6296506a8fba279d8fa31f4abf01ab0cc92738a6 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 82952d08f3e3aa80a7f51e80dbc89742cb4a09f0 -R 1a81a87cce363420c7383bdc29f10671 -U mistachkin -Z 6e06285ee204b9b14328949d07dc3790 +P 843e1c543aabab8cd62f28742d5818887d36bcb7 +R cbf020f2dfe84836eeb7827fde2edff0 +U drh +Z a30ad478221935586b899d8baf64a9ed diff --git a/manifest.uuid b/manifest.uuid index fd8b6d4e7a..9d4a6ac1bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -843e1c543aabab8cd62f28742d5818887d36bcb7 \ No newline at end of file +cfba2c8dadbf1fa6f1602a327933570820a3b134 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 2e778a57d5..7e2bed434e 100644 --- a/src/select.c +++ b/src/select.c @@ -2366,7 +2366,8 @@ static int multiSelectOrderBy( }else{ int nExpr = p->pEList->nExpr; assert( nOrderBy>=nExpr || db->mallocFailed ); - regPrev = sqlite3GetTempRange(pParse, nExpr+1); + regPrev = pParse->nMem+1; + pParse->nMem += nExpr+1; sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev); pKeyDup = sqlite3DbMallocZero(db, sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) ); @@ -2548,12 +2549,6 @@ static int multiSelectOrderBy( sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE); sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); - /* Release temporary registers - */ - if( regPrev ){ - sqlite3ReleaseTempRange(pParse, regPrev, nOrderBy+1); - } - /* Jump to the this point in order to terminate the query. */ sqlite3VdbeResolveLabel(v, labelEnd); From 5cee8a7af51aaa2413a28f640f399353f98fdfda Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Feb 2013 11:51:27 +0000 Subject: [PATCH 06/45] Add the edit_cost_table= command to the spellfix1 virtual table, permitting the edit distance cost table to be changed at runtime. FossilOrigin-Name: 89d6368250f9ba2f49e930bbe5524f3da615ce70 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test_spellfix.c | 12 ++++++++++++ test/spellfix.test | 42 +++++++++++++++++++++++++++++++++++++++--- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index e5a46828f7..3f6cdd5a93 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sunsafe\sVM\sregister\sdeallocation. -D 2013-02-16T02:41:01.780 +C Add\sthe\sedit_cost_table=\scommand\sto\sthe\sspellfix1\svirtual\stable,\spermitting\nthe\sedit\sdistance\scost\stable\sto\sbe\schanged\sat\sruntime. +D 2013-02-19T11:51:27.137 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -222,7 +222,7 @@ F src/test_regexp.c 58e0349f155bc307dfa209df4b03add0a7749866 F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 860eb723100d4e3cff846ba5d25e02815b2a5cac +F src/test_spellfix.c 83abe9d8c364cdd5f93bc06eaf40a349ebbf6c5c F src/test_sqllog.c 8acb843ddb9928dea8962e31bb09f421a72ffccb F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd @@ -734,7 +734,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/spellfix.test 2953e9da0e46dab5f83059ef6bfdebca66e13418 +F test/spellfix.test 52ae2680b1247c52b9e2b2116de3fd26a78e6bd2 F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test be8d477306006ec696bc86757cfb34bec79447ce F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 843e1c543aabab8cd62f28742d5818887d36bcb7 -R cbf020f2dfe84836eeb7827fde2edff0 +P cfba2c8dadbf1fa6f1602a327933570820a3b134 +R 9b9c12c2a5a4863f535d3439db5387d0 U drh -Z a30ad478221935586b899d8baf64a9ed +Z 6e5d7f1f0806fdc66b4d3ab8e7314ebf diff --git a/manifest.uuid b/manifest.uuid index 9d4a6ac1bf..77fe1f277a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cfba2c8dadbf1fa6f1602a327933570820a3b134 \ No newline at end of file +89d6368250f9ba2f49e930bbe5524f3da615ce70 \ No newline at end of file diff --git a/src/test_spellfix.c b/src/test_spellfix.c index 543dccbf66..f294f48c61 100644 --- a/src/test_spellfix.c +++ b/src/test_spellfix.c @@ -2681,6 +2681,18 @@ static int spellfix1Update( p->pConfig3 = 0; return SQLITE_OK; } + if( memcmp(zCmd,"edit_cost_table=",16)==0 ){ + editDist3ConfigDelete(p->pConfig3); + p->pConfig3 = 0; + sqlite3_free(p->zCostTable); + p->zCostTable = spellfix1Dequote(zCmd+16); + if( p->zCostTable==0 ) return SQLITE_NOMEM; + if( p->zCostTable[0]==0 || sqlite3_stricmp(p->zCostTable,"null")==0 ){ + sqlite3_free(p->zCostTable); + p->zCostTable = 0; + } + return SQLITE_OK; + } pVTab->zErrMsg = sqlite3_mprintf("unknown value for %s.command: \"%w\"", p->zTableName, zCmd); return SQLITE_ERROR; diff --git a/test/spellfix.test b/test/spellfix.test index afef981d25..6fb32b6d37 100644 --- a/test/spellfix.test +++ b/test/spellfix.test @@ -136,16 +136,52 @@ do_test 3.2 { } } {} -breakpoint foreach {tn word res} { 1 kos* {kosher 3 kiosk 4 kudo 2 kiss 3 kissed 3} 2 kellj* {killjoy 5 kill 4 killed 4 killer 4 killers 4} 3 kellj {kill 4 kills 5 killjoy 7 keel 4 killed 6} } { - do_execsql_test 1.2.$tn { + do_execsql_test 3.2.$tn { SELECT word, matchlen FROM t3 WHERE word MATCH $word ORDER BY score, word LIMIT 5 } $res -} +} + +do_execsql_test 4.0 { + INSERT INTO t3(command) VALUES('edit_cost_table=NULL'); +} +foreach {tn word res} { + 1 kosher {kosher 0 kisser 51 kissers 76 kissed 126 kisses 126} + 2 kellj {keels 60 killjoy 68 kills 80 keel 120 kill 125} + 3 kashar {kosher 80 kisser 91 kissers 116 kissed 166 kisses 166} +} { + do_execsql_test 4.1.$tn { + SELECT word, distance FROM t3 WHERE word MATCH $word + ORDER BY score, word LIMIT 5 + } $res +} +do_execsql_test 5.0 { + CREATE TABLE costs2(iLang, cFrom, cTo, iCost); + INSERT INTO costs2 VALUES(0, 'a', 'o', 1); + INSERT INTO costs2 VALUES(0, 'e', 'o', 4); + INSERT INTO costs2 VALUES(0, 'i', 'o', 8); + INSERT INTO costs2 VALUES(0, 'u', 'o', 16); + INSERT INTO t3(command) VALUES('edit_cost_table="costs2"'); +} + +foreach {tn word res} { + 1 kasher {kosher 1} + 2 kesher {kosher 4} + 3 kisher {kosher 8} + 4 kosher {kosher 0} + 5 kusher {kosher 16} +} { + do_execsql_test 5.1.$tn { + SELECT word, distance FROM t3 WHERE word MATCH $word + ORDER BY score, word LIMIT 1 + } $res +} + + finish_test From 4bde37027ce42a76dccbf415e9b9b388bf3980f9 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Feb 2013 18:34:12 +0000 Subject: [PATCH 07/45] Truncate over-length source lines in sqliteInt.h to 80 characters or less. FossilOrigin-Name: d71abab08518f0be1eb73c7068566ab813652318 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 12 ++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 3f6cdd5a93..9c289d7fa8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sedit_cost_table=\scommand\sto\sthe\sspellfix1\svirtual\stable,\spermitting\nthe\sedit\sdistance\scost\stable\sto\sbe\schanged\sat\sruntime. -D 2013-02-19T11:51:27.137 +C Truncate\sover-length\ssource\slines\sin\ssqliteInt.h\sto\s80\scharacters\sor\sless. +D 2013-02-19T18:34:12.933 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/shell.c 266791241d7add796ccce2317977ae6c3c67d77f F src/sqlite.h.in 6296506a8fba279d8fa31f4abf01ab0cc92738a6 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75 -F src/sqliteInt.h 758285f17a55bc37b6f042aa3a2464e74327f4a5 +F src/sqliteInt.h 601c887f6d9c92e75551873c0a34711fff745bed F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P cfba2c8dadbf1fa6f1602a327933570820a3b134 -R 9b9c12c2a5a4863f535d3439db5387d0 +P 89d6368250f9ba2f49e930bbe5524f3da615ce70 +R ad93dc9e7473cd19fa3fc210214b9d33 U drh -Z 6e5d7f1f0806fdc66b4d3ab8e7314ebf +Z 704858c203a3733218f2f3535c035e6c diff --git a/manifest.uuid b/manifest.uuid index 77fe1f277a..ec25dd6c4e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -89d6368250f9ba2f49e930bbe5524f3da615ce70 \ No newline at end of file +d71abab08518f0be1eb73c7068566ab813652318 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 38dc44fcf3..a7c1f0e018 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -200,7 +200,8 @@ ** ** See also ticket #2741. */ -#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && SQLITE_THREADSAFE +#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) \ + && !defined(__APPLE__) && SQLITE_THREADSAFE # define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ #endif @@ -2837,7 +2838,7 @@ Table *sqlite3SrcListLookup(Parse*, SrcList*); int sqlite3IsReadOnly(Parse*, Table*, int); void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) -Expr *sqlite3LimitWhere(Parse *, SrcList *, Expr *, ExprList *, Expr *, Expr *, char *); +Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*); #endif void sqlite3DeleteFrom(Parse*, SrcList*, Expr*); void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); @@ -3018,8 +3019,11 @@ int sqlite3VarintLen(u64 v); ** x = putVarint32( A, B ); ** */ -#define getVarint32(A,B) (u8)((*(A)<(u8)0x80) ? ((B) = (u32)*(A)),1 : sqlite3GetVarint32((A), (u32 *)&(B))) -#define putVarint32(A,B) (u8)(((u32)(B)<(u32)0x80) ? (*(A) = (unsigned char)(B)),1 : sqlite3PutVarint32((A), (B))) +#define getVarint32(A,B) \ + (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B))) +#define putVarint32(A,B) \ + (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\ + sqlite3PutVarint32((A),(B))) #define getVarint sqlite3GetVarint #define putVarint sqlite3PutVarint From 5c5760aa811620d1141c44c6bd99498857362b5c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Feb 2013 18:34:45 +0000 Subject: [PATCH 08/45] Do not rollback the schema if a parsing error occurs while parsing the schema and writable_schema is set. FossilOrigin-Name: 680d3ab56b578bd4b0170559f9e35615ff43cf2c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9c289d7fa8..becd47e8c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Truncate\sover-length\ssource\slines\sin\ssqliteInt.h\sto\s80\scharacters\sor\sless. -D 2013-02-19T18:34:12.933 +C Do\snot\srollback\sthe\sschema\sif\sa\sparsing\serror\soccurs\swhile\sparsing\sthe\sschema\nand\swritable_schema\sis\sset. +D 2013-02-19T18:34:45.417 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 448564ee3795b13c373bbc5c8590df8fbfe1d64c +F src/main.c 8d204866d1abf5100503dcd54d3187b88f6846b7 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 89d6368250f9ba2f49e930bbe5524f3da615ce70 -R ad93dc9e7473cd19fa3fc210214b9d33 +P d71abab08518f0be1eb73c7068566ab813652318 +R bae530288ea7159e1aaf9a39decdf9bb U drh -Z 704858c203a3733218f2f3535c035e6c +Z a4669efab8929bd31e07170c5f4c2a01 diff --git a/manifest.uuid b/manifest.uuid index ec25dd6c4e..ad824b461b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d71abab08518f0be1eb73c7068566ab813652318 \ No newline at end of file +680d3ab56b578bd4b0170559f9e35615ff43cf2c \ No newline at end of file diff --git a/src/main.c b/src/main.c index b52d474443..77aaa6d83b 100644 --- a/src/main.c +++ b/src/main.c @@ -1002,7 +1002,7 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){ sqlite3VtabRollback(db); sqlite3EndBenignMalloc(); - if( db->flags&SQLITE_InternChanges ){ + if( (db->flags&SQLITE_InternChanges)!=0 && db->init.busy==0 ){ sqlite3ExpirePreparedStatements(db); sqlite3ResetAllSchemasOfConnection(db); } From 00e637f0f05095cb0920e77139ad90d413765e78 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Feb 2013 18:45:11 +0000 Subject: [PATCH 09/45] Enhance the pgidx of the showdb utility so that it provides better information even if the sqlite_master table is corrupt. FossilOrigin-Name: d14263a719101d9c70054f2fc37e7788f73aab28 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/showdb.c | 28 +++++++++++++++++----------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index becd47e8c0..df760a6298 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srollback\sthe\sschema\sif\sa\sparsing\serror\soccurs\swhile\sparsing\sthe\sschema\nand\swritable_schema\sis\sset. -D 2013-02-19T18:34:45.417 +C Enhance\sthe\spgidx\sof\sthe\sshowdb\sutility\sso\sthat\sit\sprovides\sbetter\sinformation\neven\sif\sthe\ssqlite_master\stable\sis\scorrupt. +D 2013-02-19T18:45:11.538 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1014,7 +1014,7 @@ F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c aca2644aa4de7c0cad5821e50bbd55397e0974b8 +F tool/showdb.c 8fa54c57cdbbe8ed42d47f19d1d54bf3debb32f4 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P d71abab08518f0be1eb73c7068566ab813652318 -R bae530288ea7159e1aaf9a39decdf9bb +P 680d3ab56b578bd4b0170559f9e35615ff43cf2c +R 60574b1dc9c1930236960e8450f1f431 U drh -Z a4669efab8929bd31e07170c5f4c2a01 +Z bb6a18ed85184e9966fde92c116bc017 diff --git a/manifest.uuid b/manifest.uuid index ad824b461b..53eaa88edb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -680d3ab56b578bd4b0170559f9e35615ff43cf2c \ No newline at end of file +d14263a719101d9c70054f2fc37e7788f73aab28 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index a100bba4f5..6096926f21 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -619,11 +619,12 @@ static void page_usage_freelist(int pgno){ ** Try to figure out how every page in the database file is being used. */ static void page_usage_report(const char *zDbName){ - int i; + int i, j; int rc; sqlite3 *db; sqlite3_stmt *pStmt; unsigned char *a; + char zQuery[200]; /* Avoid the pathological case */ if( mxPage<1 ){ @@ -650,18 +651,23 @@ static void page_usage_report(const char *zDbName){ page_usage_freelist(decodeInt32(a+32)); free(a); page_usage_btree(1, 0, 0, "sqlite_master"); - rc = sqlite3_prepare_v2(db, - "SELECT type, name, rootpage FROM SQLITE_MASTER WHERE rootpage", - -1, &pStmt, 0); - if( rc==SQLITE_OK ){ - while( sqlite3_step(pStmt)==SQLITE_ROW ){ - int pgno = sqlite3_column_int(pStmt, 2); - page_usage_btree(pgno, 0, 0, sqlite3_column_text(pStmt, 1)); + sqlite3_exec(db, "PRAGMA writable_schema=ON", 0, 0, 0); + for(j=0; j<2; j++){ + sqlite3_snprintf(sizeof(zQuery), zQuery, + "SELECT type, name, rootpage FROM SQLITE_MASTER WHERE rootpage" + " ORDER BY rowid %s", j?"DESC":""); + rc = sqlite3_prepare_v2(db, zQuery, -1, &pStmt, 0); + if( rc==SQLITE_OK ){ + while( sqlite3_step(pStmt)==SQLITE_ROW ){ + int pgno = sqlite3_column_int(pStmt, 2); + page_usage_btree(pgno, 0, 0, sqlite3_column_text(pStmt, 1)); + } + }else{ + printf("ERROR: cannot query database: %s\n", sqlite3_errmsg(db)); } - }else{ - printf("ERROR: cannot query database: %s\n", sqlite3_errmsg(db)); + rc = sqlite3_finalize(pStmt); + if( rc==SQLITE_OK ) break; } - sqlite3_finalize(pStmt); sqlite3_close(db); /* Print the report and free memory used */ From 103a70fa626686fe90dce7ae979fd9ade705ea12 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Feb 2013 20:25:16 +0000 Subject: [PATCH 10/45] Fix the showdb utility so that it displays the correct secondary usage of a page when reporting on an error of a page being used more than once. FossilOrigin-Name: 4507f0b3d409cd14bb2b9c29c92c76aa3ccb22b6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/showdb.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index df760a6298..dc27a853d4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\spgidx\sof\sthe\sshowdb\sutility\sso\sthat\sit\sprovides\sbetter\sinformation\neven\sif\sthe\ssqlite_master\stable\sis\scorrupt. -D 2013-02-19T18:45:11.538 +C Fix\sthe\sshowdb\sutility\sso\sthat\sit\sdisplays\sthe\scorrect\ssecondary\susage\sof\na\spage\swhen\sreporting\son\san\serror\sof\sa\spage\sbeing\sused\smore\sthan\sonce. +D 2013-02-19T20:25:16.107 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1014,7 +1014,7 @@ F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 8fa54c57cdbbe8ed42d47f19d1d54bf3debb32f4 +F tool/showdb.c 2292b901840eb0e3390af9e8115d54dfee7613a0 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 680d3ab56b578bd4b0170559f9e35615ff43cf2c -R 60574b1dc9c1930236960e8450f1f431 +P d14263a719101d9c70054f2fc37e7788f73aab28 +R c7d3b3e1fb8a10f0748991954af9d6f6 U drh -Z bb6a18ed85184e9966fde92c116bc017 +Z 8fc5bc0346e01701458f5c2865bfe0c3 diff --git a/manifest.uuid b/manifest.uuid index 53eaa88edb..7b37219e03 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d14263a719101d9c70054f2fc37e7788f73aab28 \ No newline at end of file +4507f0b3d409cd14bb2b9c29c92c76aa3ccb22b6 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index 6096926f21..a3358ba8bf 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -479,7 +479,7 @@ static void page_usage_msg(int pgno, const char *zFormat, ...){ if( zPageUse[pgno]!=0 ){ printf("ERROR: page %d used multiple times:\n", pgno); printf("ERROR: previous: %s\n", zPageUse[pgno]); - printf("ERROR: current: %s\n", zPageUse[pgno]); + printf("ERROR: current: %s\n", zMsg); sqlite3_free(zPageUse[pgno]); } zPageUse[pgno] = zMsg; From 344a97b4b0f32a2138b1b80410d01c82bb412dd1 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Feb 2013 22:26:51 +0000 Subject: [PATCH 11/45] Enhance the showdb tool with options to show PTRMAP usage and content. FossilOrigin-Name: 06bd91305ed6752315c5224be5f89e87cafa6687 --- manifest | 12 ++++----- manifest.uuid | 2 +- tool/showdb.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index dc27a853d4..eba974bac5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sshowdb\sutility\sso\sthat\sit\sdisplays\sthe\scorrect\ssecondary\susage\sof\na\spage\swhen\sreporting\son\san\serror\sof\sa\spage\sbeing\sused\smore\sthan\sonce. -D 2013-02-19T20:25:16.107 +C Enhance\sthe\sshowdb\stool\swith\soptions\sto\sshow\sPTRMAP\susage\sand\scontent. +D 2013-02-19T22:26:51.195 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1014,7 +1014,7 @@ F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 2292b901840eb0e3390af9e8115d54dfee7613a0 +F tool/showdb.c 16960a5ce59d8b1d70dc3bdc51e2c0fe7bb91359 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P d14263a719101d9c70054f2fc37e7788f73aab28 -R c7d3b3e1fb8a10f0748991954af9d6f6 +P 4507f0b3d409cd14bb2b9c29c92c76aa3ccb22b6 +R b76888af58f22e925445fcabab8c63d9 U drh -Z 8fc5bc0346e01701458f5c2865bfe0c3 +Z 14b66e62b1a3bf33a2d26df6fe5962d7 diff --git a/manifest.uuid b/manifest.uuid index 7b37219e03..326315ef7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4507f0b3d409cd14bb2b9c29c92c76aa3ccb22b6 \ No newline at end of file +06bd91305ed6752315c5224be5f89e87cafa6687 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index a3358ba8bf..4a31d9cd3e 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -615,6 +615,22 @@ static void page_usage_freelist(int pgno){ } } +/* +** Determine pages used as PTRMAP pages +*/ +static void page_usage_ptrmap(unsigned char *a){ + if( a[55] ){ + int usable = pagesize - a[20]; + int pgno = 2; + int perPage = usable/5; + while( pgno<=mxPage ){ + page_usage_msg(pgno, "PTRMAP page covering %d..%d", + pgno+1, pgno+perPage); + pgno += perPage + 1; + } + } +} + /* ** Try to figure out how every page in the database file is being used. */ @@ -649,6 +665,7 @@ static void page_usage_report(const char *zDbName){ /* Discover the usage of each page */ a = getContent(0, 100); page_usage_freelist(decodeInt32(a+32)); + page_usage_ptrmap(a); free(a); page_usage_btree(1, 0, 0, "sqlite_master"); sqlite3_exec(db, "PRAGMA writable_schema=ON", 0, 0, 0); @@ -679,6 +696,53 @@ static void page_usage_report(const char *zDbName){ zPageUse = 0; } +/* +** Try to figure out how every page in the database file is being used. +*/ +static void ptrmap_coverage_report(const char *zDbName){ + unsigned int pgno; + unsigned char *aHdr; + unsigned char *a; + int usable; + int perPage; + unsigned int i; + + /* Avoid the pathological case */ + if( mxPage<1 ){ + printf("empty database\n"); + return; + } + + /* Make sure PTRMAPs are used in this database */ + aHdr = getContent(0, 100); + if( aHdr[55]==0 ){ + printf("database does not use PTRMAP pages\n"); + return; + } + usable = pagesize - aHdr[20]; + perPage = usable/5; + free(aHdr); + printf("%5d: root of sqlite_master\n", 1); + for(pgno=2; pgno<=mxPage; pgno += perPage+1){ + printf("%5d: PTRMAP page covering %d..%d\n", pgno, + pgno+1, pgno+perPage); + a = getContent((pgno-1)*pagesize, usable); + for(i=0; i+5<=usable && pgno+1+i/5<=mxPage; i+=5){ + const char *zType = "???"; + unsigned int iFrom = decodeInt32(&a[i+1]); + switch( a[i] ){ + case 1: zType = "b-tree root page"; break; + case 2: zType = "freelist page"; break; + case 3: zType = "first page of overflow"; break; + case 4: zType = "later page of overflow"; break; + case 5: zType = "b-tree non-root page"; break; + } + printf("%5d: %s, parent=%u\n", pgno+1+i/5, zType, iFrom); + } + free(a); + } +} + /* ** Print a usage comment */ @@ -688,6 +752,7 @@ static void usage(const char *argv0){ "args:\n" " dbheader Show database header\n" " pgidx Index of how each page is used\n" + " ptrmap Show all PTRMAP page content\n" " NNN..MMM Show hex of pages NNN through MMM\n" " NNN..end Show hex of pages NNN through end of file\n" " NNNb Decode btree page NNN\n" @@ -737,6 +802,14 @@ int main(int argc, char **argv){ page_usage_report(argv[1]); continue; } + if( strcmp(argv[i], "ptrmap")==0 ){ + ptrmap_coverage_report(argv[1]); + continue; + } + if( strcmp(argv[i], "help")==0 ){ + usage(argv[0]); + continue; + } if( !isdigit(argv[i][0]) ){ fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]); continue; From d5d0f6432ce1cf89327a35d4fb7566176a58193d Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Feb 2013 00:54:21 +0000 Subject: [PATCH 12/45] On Minix, disable the ".timer" command in the shell in order to avoid calling getrusage(). FossilOrigin-Name: 9bd9bd9cab8c804c1a51d472199459176044a633 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index eba974bac5..b598aeddd6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sshowdb\stool\swith\soptions\sto\sshow\sPTRMAP\susage\sand\scontent. -D 2013-02-19T22:26:51.195 +C On\sMinix,\sdisable\sthe\s".timer"\scommand\sin\sthe\sshell\sin\sorder\sto\savoid\ncalling\sgetrusage(). +D 2013-02-20T00:54:21.855 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 652ae6dc0f185b01b4536bb2fa7d878f13f0f1df F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c e1c6f6abdf9f359f4e735cb8ae11d2f359bf52a9 -F src/shell.c 266791241d7add796ccce2317977ae6c3c67d77f +F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca F src/sqlite.h.in 6296506a8fba279d8fa31f4abf01ab0cc92738a6 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 4507f0b3d409cd14bb2b9c29c92c76aa3ccb22b6 -R b76888af58f22e925445fcabab8c63d9 +P 06bd91305ed6752315c5224be5f89e87cafa6687 +R 14c0fedf89f00b14b7845aeac312ffca U drh -Z 14b66e62b1a3bf33a2d26df6fe5962d7 +Z 673b617e6189db9a51be1e6b0160e6d4 diff --git a/manifest.uuid b/manifest.uuid index 326315ef7c..029dba568e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06bd91305ed6752315c5224be5f89e87cafa6687 \ No newline at end of file +9bd9bd9cab8c804c1a51d472199459176044a633 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 1428a45f0c..c6d7fa3d53 100644 --- a/src/shell.c +++ b/src/shell.c @@ -90,7 +90,8 @@ static int enableTimer = 0; #define IsDigit(X) isdigit((unsigned char)X) #define ToLower(X) (char)tolower((unsigned char)X) -#if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) +#if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \ + && !defined(__minux) #include #include From d495d8c9a3c5ac9bac58c68126c621d948c4992d Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 Feb 2013 19:34:25 +0000 Subject: [PATCH 13/45] Two new SQL functions: unicode() and char(). FossilOrigin-Name: 209b21085b9767f10f6ffb7c7cac756fcb74ded5 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/func.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/func.test | 6 +++++- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b598aeddd6..6d27274c2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sMinix,\sdisable\sthe\s".timer"\scommand\sin\sthe\sshell\sin\sorder\sto\savoid\ncalling\sgetrusage(). -D 2013-02-20T00:54:21.855 +C Two\snew\sSQL\sfunctions:\sunicode()\sand\schar(). +D 2013-02-22T19:34:25.685 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d F src/expr.c f6c20285bd36e87ec47f4d840e90a32755e2a90c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 -F src/func.c 8147799b048065a1590805be464d05b4913e652c +F src/func.c 18b120b9a34daf6d38d50969b6f3471c09b2934a F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -508,7 +508,7 @@ F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 F test/fts4unicode.test 25ccad45896f8e50f6a694cff738a35f798cdb40 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test 0d89043dab9a8853358d14c68e028ee0093bf066 +F test/func.test 0ea54895539c0586e86e2dcea59b05cc9e7dd6b2 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 @@ -1034,7 +1034,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 06bd91305ed6752315c5224be5f89e87cafa6687 -R 14c0fedf89f00b14b7845aeac312ffca +P 9bd9bd9cab8c804c1a51d472199459176044a633 +R 57460c96631f0b503379401f124964ab +T *branch * unicode-function +T *sym-unicode-function * +T -sym-trunk * U drh -Z 673b617e6189db9a51be1e6b0160e6d4 +Z ff410097880c23c389e99514cc7f5a15 diff --git a/manifest.uuid b/manifest.uuid index 029dba568e..a2ef64dc19 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9bd9bd9cab8c804c1a51d472199459176044a633 \ No newline at end of file +209b21085b9767f10f6ffb7c7cac756fcb74ded5 \ No newline at end of file diff --git a/src/func.c b/src/func.c index d4655ad7e9..98f2a2e96b 100644 --- a/src/func.c +++ b/src/func.c @@ -962,6 +962,56 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } } +/* +** The unicode() function. Return the integer unicode code-point value +** for the first character of the input string. +*/ +static void unicodeFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const unsigned char *z = sqlite3_value_text(argv[0]); + if( z && z[0] ) sqlite3_result_int(context, sqlite3Utf8Read(&z)); +} + +/* +** The char() function takes zero or more arguments, each of which is +** an integer. It constructs a string where each character of the string +** is the unicode character for the corresponding integer argument. +*/ +static void charFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + unsigned char *z, *zOut; + int i; + zOut = z = sqlite3_malloc( argc*4 ); + if( z==0 ){ + sqlite3_result_error_nomem(context); + return; + } + for(i=0; i0x10ffff ) x = 0xfffd; + c = (unsigned)(x & 0x1fffff); + if( c<=0xFFFF ){ + *zOut++ = (u8)(c&0x00FF); + *zOut++ = (u8)((c>>8)&0x00FF); + }else{ + if( c>=0xd800 && c<=0xdbff ) c = 0xfffd; + *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); + *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); + *zOut++ = (u8)(c&0x00FF); + *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); + } + } + sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free); +} + /* ** The hex() function. Interpret the argument as a blob. Return ** a hexadecimal rendering as text. @@ -1589,6 +1639,8 @@ void sqlite3RegisterGlobalFunctions(void){ FUNCTION(instr, 2, 0, 0, instrFunc ), FUNCTION(substr, 2, 0, 0, substrFunc ), FUNCTION(substr, 3, 0, 0, substrFunc ), + FUNCTION(unicode, 1, 0, 0, unicodeFunc ), + FUNCTION(char, -1, 0, 0, charFunc ), FUNCTION(abs, 1, 0, 0, absFunc ), #ifndef SQLITE_OMIT_FLOATING_POINT FUNCTION(round, 1, 0, 0, roundFunc ), diff --git a/test/func.test b/test/func.test index e44c44b280..3107e6df3f 100644 --- a/test/func.test +++ b/test/func.test @@ -1289,6 +1289,10 @@ do_test func-29.6 { if {$x<5} {set x 1} set x } {1} - + +do_execsql_test func-30.1 {SELECT unicode('$');} 36 +do_execsql_test func-30.2 {SELECT unicode('¢');} 162 +do_execsql_test func-30.3 {SELECT unicode('€');} 8364 +do_execsql_test func-30.4 {SELECT char(36,162,8364);} {$¢€} finish_test From 51f0b6d568df407b92ce9363b5dfb03f3b3be1f0 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 22 Feb 2013 20:16:34 +0000 Subject: [PATCH 14/45] Avoid moving pages more than once in an incremental vacuum operation. FossilOrigin-Name: c3939d249119b47bd57baa11a5ed7cc6014fc795 --- manifest | 17 +++--- manifest.uuid | 2 +- src/btree.c | 145 +++++++++++++++++++++++++++++++------------------- 3 files changed, 102 insertions(+), 62 deletions(-) diff --git a/manifest b/manifest index b598aeddd6..d14f19c439 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sMinix,\sdisable\sthe\s".timer"\scommand\sin\sthe\sshell\sin\sorder\sto\savoid\ncalling\sgetrusage(). -D 2013-02-20T00:54:21.855 +C Avoid\smoving\spages\smore\sthan\sonce\sin\san\sincremental\svacuum\soperation. +D 2013-02-22T20:16:34.273 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 32e35a3a4ea55b45c0e5f74eeb793aec71491517 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 7a80e4a67f32a2494c383a28a495bf3bd71cc230 +F src/btree.c 960274cb93c1d85e82bd106094e0890d89434ab8 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be @@ -1034,7 +1034,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 06bd91305ed6752315c5224be5f89e87cafa6687 -R 14c0fedf89f00b14b7845aeac312ffca -U drh -Z 673b617e6189db9a51be1e6b0160e6d4 +P 9bd9bd9cab8c804c1a51d472199459176044a633 +R d336ad839cab7fc86035cb53790f3fce +T *branch * incr-vacuum-opt +T *sym-incr-vacuum-opt * +T -sym-trunk * +U dan +Z cd58f1fbd68ec5de5d0f48d285a49284 diff --git a/manifest.uuid b/manifest.uuid index 029dba568e..6676236222 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9bd9bd9cab8c804c1a51d472199459176044a633 \ No newline at end of file +c3939d249119b47bd57baa11a5ed7cc6014fc795 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index bb64e643b0..de22559968 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2909,26 +2909,28 @@ static int relocatePage( /* Forward declaration required by incrVacuumStep(). */ static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); +#define BTALLOC_ANY 0 /* Allocate any page */ +#define BTALLOC_EXACT 1 /* Allocate exact page if possible */ +#define BTALLOC_LE 2 /* Allocate any page <= the parameter */ /* -** Perform a single step of an incremental-vacuum. If successful, -** return SQLITE_OK. If there is no work to do (and therefore no -** point in calling this function again), return SQLITE_DONE. +** Perform a single step of an incremental-vacuum. If successful, return +** SQLITE_OK. If there is no work to do (and therefore no point in +** calling this function again), return SQLITE_DONE. Or, if an error +** occurs, return some other error code. ** -** More specificly, this function attempts to re-organize the -** database so that the last page of the file currently in use -** is no longer in use. +** More specificly, this function attempts to re-organize the database so +** that the last page of the file currently in use is no longer in use. ** -** If the nFin parameter is non-zero, this function assumes -** that the caller will keep calling incrVacuumStep() until -** it returns SQLITE_DONE or an error, and that nFin is the -** number of pages the database file will contain after this -** process is complete. If nFin is zero, it is assumed that -** incrVacuumStep() will be called a finite amount of times -** which may or may not empty the freelist. A full autovacuum -** has nFin>0. A "PRAGMA incremental_vacuum" has nFin==0. +** Parameter nFin is the number of pages that this database would contain +** were this function called until it returns SQLITE_DONE. +** +** If the bCommit parameter is non-zero, this function assumes that the +** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE +** or an error. bCommit is passed true for an auto-vacuum-on-commmit +** operation, or false for an incremental vacuum. */ -static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){ +static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){ Pgno nFreeList; /* Number of pages still on the free-list */ int rc; @@ -2953,15 +2955,15 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){ } if( eType==PTRMAP_FREEPAGE ){ - if( nFin==0 ){ + if( bCommit==0 ){ /* Remove the page from the files free-list. This is not required - ** if nFin is non-zero. In that case, the free-list will be + ** if bCommit is non-zero. In that case, the free-list will be ** truncated to zero after this function returns, so it doesn't ** matter if it still contains some garbage entries. */ Pgno iFreePg; MemPage *pFreePg; - rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, 1); + rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, BTALLOC_EXACT); if( rc!=SQLITE_OK ){ return rc; } @@ -2971,28 +2973,34 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){ } else { Pgno iFreePg; /* Index of free page to move pLastPg to */ MemPage *pLastPg; + u8 eMode = BTALLOC_ANY; /* Mode parameter for allocateBtreePage() */ + Pgno iNear = 0; /* nearby parameter for allocateBtreePage() */ rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0); if( rc!=SQLITE_OK ){ return rc; } - /* If nFin is zero, this loop runs exactly once and page pLastPg + /* If bCommit is zero, this loop runs exactly once and page pLastPg ** is swapped with the first free page pulled off the free list. ** - ** On the other hand, if nFin is greater than zero, then keep + ** On the other hand, if bCommit is greater than zero, then keep ** looping until a free-page located within the first nFin pages ** of the file is found. */ + if( bCommit==0 ){ + eMode = BTALLOC_LE; + iNear = nFin; + } do { MemPage *pFreePg; - rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, 0, 0); + rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iNear, eMode); if( rc!=SQLITE_OK ){ releasePage(pLastPg); return rc; } releasePage(pFreePg); - }while( nFin!=0 && iFreePg>nFin ); + }while( bCommit && iFreePg>nFin ); assert( iFreePgpDbPage); @@ -3006,7 +3014,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){ } } - if( nFin==0 ){ + if( bCommit==0 ){ iLastPg--; while( iLastPg==PENDING_BYTE_PAGE(pBt)||PTRMAP_ISPAGE(pBt, iLastPg) ){ if( PTRMAP_ISPAGE(pBt, iLastPg) ){ @@ -3029,6 +3037,30 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){ return SQLITE_OK; } +/* +** The database opened by the first argument is an auto-vacuum database +** nOrig pages in size containing nFree free pages. Return the expected +** size of the database in pages following an auto-vacuum operation. +*/ +static Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){ + int nEntry; /* Number of entries on one ptrmap page */ + Pgno nPtrmap; /* Number of PtrMap pages to be freed */ + Pgno nFin; /* Return value */ + + nEntry = pBt->usableSize/5; + nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry; + nFin = nOrig - nFree - nPtrmap; + if( nOrig>PENDING_BYTE_PAGE(pBt) && nFinnOrig ) return SQLITE_CORRUPT_BKPT; + + return nFin; +} + /* ** A write-transaction must be opened before calling this function. ** It performs a single unit of work towards an incremental vacuum. @@ -3046,11 +3078,19 @@ int sqlite3BtreeIncrVacuum(Btree *p){ if( !pBt->autoVacuum ){ rc = SQLITE_DONE; }else{ - invalidateAllOverflowCache(pBt); - rc = incrVacuumStep(pBt, 0, btreePagecount(pBt)); - if( rc==SQLITE_OK ){ - rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); - put4byte(&pBt->pPage1->aData[28], pBt->nPage); + Pgno nOrig = btreePagecount(pBt); + Pgno nFree = get4byte(&pBt->pPage1->aData[36]); + Pgno nFin = finalDbSize(pBt, nOrig, nFree); + + if( nFinpPage1->pDbPage); + put4byte(&pBt->pPage1->aData[28], pBt->nPage); + } + }else{ + rc = SQLITE_DONE; } } sqlite3BtreeLeave(p); @@ -3077,9 +3117,7 @@ static int autoVacuumCommit(BtShared *pBt){ if( !pBt->incrVacuum ){ Pgno nFin; /* Number of pages in database after autovacuuming */ Pgno nFree; /* Number of pages on the freelist initially */ - Pgno nPtrmap; /* Number of PtrMap pages to be freed */ Pgno iFree; /* The next page to be freed */ - int nEntry; /* Number of entries on one ptrmap page */ Pgno nOrig; /* Database size before freeing */ nOrig = btreePagecount(pBt); @@ -3092,19 +3130,11 @@ static int autoVacuumCommit(BtShared *pBt){ } nFree = get4byte(&pBt->pPage1->aData[36]); - nEntry = pBt->usableSize/5; - nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry; - nFin = nOrig - nFree - nPtrmap; - if( nOrig>PENDING_BYTE_PAGE(pBt) && nFinnOrig ) return SQLITE_CORRUPT_BKPT; for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){ - rc = incrVacuumStep(pBt, nFin, iFree); + rc = incrVacuumStep(pBt, nFin, iFree, 1); } if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){ rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); @@ -4867,7 +4897,7 @@ static int allocateBtreePage( MemPage **ppPage, Pgno *pPgno, Pgno nearby, - u8 exact + u8 eMode ){ MemPage *pPage1; int rc; @@ -4895,16 +4925,19 @@ static int allocateBtreePage( ** the entire-list will be searched for that page. */ #ifndef SQLITE_OMIT_AUTOVACUUM - if( exact && nearby<=mxPage ){ - u8 eType; - assert( nearby>0 ); - assert( pBt->autoVacuum ); - rc = ptrmapGet(pBt, nearby, &eType, 0); - if( rc ) return rc; - if( eType==PTRMAP_FREEPAGE ){ - searchList = 1; + if( eMode==BTALLOC_EXACT ){ + if( nearby<=mxPage ){ + u8 eType; + assert( nearby>0 ); + assert( pBt->autoVacuum ); + rc = ptrmapGet(pBt, nearby, &eType, 0); + if( rc ) return rc; + if( eType==PTRMAP_FREEPAGE ){ + searchList = 1; + } } - *pPgno = nearby; + }else if( eMode==BTALLOC_LE ){ + searchList = 1; } #endif @@ -4959,11 +4992,13 @@ static int allocateBtreePage( rc = SQLITE_CORRUPT_BKPT; goto end_allocate_page; #ifndef SQLITE_OMIT_AUTOVACUUM - }else if( searchList && nearby==iTrunk ){ + }else if( searchList + && (nearby==iTrunk || (iTrunkpDbPage); @@ -5047,7 +5082,9 @@ static int allocateBtreePage( goto end_allocate_page; } testcase( iPage==mxPage ); - if( !searchList || iPage==nearby ){ + if( !searchList + || (iPage==nearby || (iPage Date: Fri, 22 Feb 2013 20:57:47 +0000 Subject: [PATCH 15/45] Fix a problem with the previous commit. FossilOrigin-Name: 720a3ceafc35b81936ed2eb1f07a7187d104f0a0 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/btree.c | 24 +++++++++++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index d14f19c439..ff7dff0ba5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\smoving\spages\smore\sthan\sonce\sin\san\sincremental\svacuum\soperation. -D 2013-02-22T20:16:34.273 +C Fix\sa\sproblem\swith\sthe\sprevious\scommit. +D 2013-02-22T20:57:47.269 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 32e35a3a4ea55b45c0e5f74eeb793aec71491517 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 960274cb93c1d85e82bd106094e0890d89434ab8 +F src/btree.c 76f063ffd70aba11b3f4701d216c157e1a81b51d F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be @@ -1034,10 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 9bd9bd9cab8c804c1a51d472199459176044a633 -R d336ad839cab7fc86035cb53790f3fce -T *branch * incr-vacuum-opt -T *sym-incr-vacuum-opt * -T -sym-trunk * +P c3939d249119b47bd57baa11a5ed7cc6014fc795 +R f58494bafc2bb0d7737cf9b62d925506 U dan -Z cd58f1fbd68ec5de5d0f48d285a49284 +Z 7eeaf98ba8f2d987bdc515914ba34037 diff --git a/manifest.uuid b/manifest.uuid index 6676236222..6accd36d88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c3939d249119b47bd57baa11a5ed7cc6014fc795 \ No newline at end of file +720a3ceafc35b81936ed2eb1f07a7187d104f0a0 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index de22559968..b3a907c5ab 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5061,14 +5061,24 @@ static int allocateBtreePage( unsigned char *aData = pTrunk->aData; if( nearby>0 ){ u32 i; - int dist; closest = 0; - dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby); - for(i=1; i Date: Sat, 23 Feb 2013 16:40:46 +0000 Subject: [PATCH 16/45] If a rollback mode transaction reduces the size of the database file, avoid actually truncating the file until after the transaction has been committed (but before the db has been unlocked). This means pages that are removed from the database by truncating the file need not be journalled. FossilOrigin-Name: b73847f17b7ae1298dfc52de6c4c4bc809bc77a3 --- manifest | 20 +++++++------- manifest.uuid | 2 +- src/backup.c | 17 ++++++++++-- src/btree.c | 59 +++++++++++++++++++++++------------------ src/btreeInt.h | 1 + src/pager.c | 67 ++++++++++++++++++----------------------------- test/tkt3762.test | 4 +-- 7 files changed, 89 insertions(+), 81 deletions(-) diff --git a/manifest b/manifest index ff7dff0ba5..a4147e0d00 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sthe\sprevious\scommit. -D 2013-02-22T20:57:47.269 +C If\sa\srollback\smode\stransaction\sreduces\sthe\ssize\sof\sthe\sdatabase\sfile,\savoid\sactually\struncating\sthe\sfile\suntil\safter\sthe\stransaction\shas\sbeen\scommitted\s(but\sbefore\sthe\sdb\shas\sbeen\sunlocked).\sThis\smeans\spages\sthat\sare\sremoved\sfrom\sthe\sdatabase\sby\struncating\sthe\sfile\sneed\snot\sbe\sjournalled. +D 2013-02-23T16:40:46.526 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -118,12 +118,12 @@ F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168 F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410 F src/attach.c ea5247f240e2c08afd608e9beb380814b86655e1 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 32e35a3a4ea55b45c0e5f74eeb793aec71491517 +F src/backup.c 0b8d2108a10ada00e642525921960b0c27451955 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 76f063ffd70aba11b3f4701d216c157e1a81b51d +F src/btree.c f021a7f59fd340577c2f9b7d6e951576af335cfb F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd -F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 +F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac @@ -162,7 +162,7 @@ F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c dfdc04b126f7b05dcb2e2cc5c1262f98acbb49d9 F src/os_win.c eabd00b813577d36bd66271cb08dd64ea0589dac -F src/pager.c 4092c907222cfd451c74fe6bd2fd64b342f7190f +F src/pager.c 0dbf5ff5d5d7d3a21fcab82e9e4d129b6fe6314f F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -871,7 +871,7 @@ F test/tkt3718.test 3b59dcb5c4e7754dacd91e7fd353a61492cc402a F test/tkt3731.test 0c5f4cbffe102d43c3b2188af91a9e36348f974b F test/tkt3757.test 10cd679a88675c880533083fc79ac04324525595 F test/tkt3761.test b95ea9c98f21cf91325f18a984887e62caceab33 -F test/tkt3762.test 2a9f3b03df44ec49ec0cfa8d5da6574c2a7853df +F test/tkt3762.test 4d439ff7abdc8d9323150269d182c37c2d514576 F test/tkt3773.test 7bca904d2a647a6a4a291bd86d7fd7c73855b789 F test/tkt3791.test a6624b9a80b216a26cf473607f42f3e51898c267 F test/tkt3793.test d90ffd75c52413908d15e1c44fc2ea9c80fcc449 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P c3939d249119b47bd57baa11a5ed7cc6014fc795 -R f58494bafc2bb0d7737cf9b62d925506 +P 720a3ceafc35b81936ed2eb1f07a7187d104f0a0 +R 2fcb8a3a4c948e70b98e89248d0d9b21 U dan -Z 7eeaf98ba8f2d987bdc515914ba34037 +Z 61c42a3e0f1600d37d1de1cf170b2233 diff --git a/manifest.uuid b/manifest.uuid index 6accd36d88..5875324cc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -720a3ceafc35b81936ed2eb1f07a7187d104f0a0 \ No newline at end of file +b73847f17b7ae1298dfc52de6c4c4bc809bc77a3 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index d3614b88c3..89e0f00e66 100644 --- a/src/backup.c +++ b/src/backup.c @@ -462,7 +462,6 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ nDestTruncate = nSrcPage * (pgszSrc/pgszDest); } assert( nDestTruncate>0 ); - sqlite3PagerTruncateImage(pDestPager, nDestTruncate); if( pgszSrc=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest )); - /* This call ensures that all data required to recreate the original + /* This block ensures that all data required to recreate the original ** database has been stored in the journal for pDestPager and the ** journal synced to disk. So at this point we may safely modify ** the database file in any way, knowing that if a power failure ** occurs, the original database will be reconstructed from the ** journal file. */ + sqlite3PagerPagecount(pDestPager, &nDstPage); + for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){ + if( iPg!=PENDING_BYTE_PAGE(p->pDest->pBt) ){ + DbPage *pPg; + rc = sqlite3PagerGet(pDestPager, iPg, &pPg); + if( rc==SQLITE_OK ){ + rc = sqlite3PagerWrite(pPg); + sqlite3PagerUnref(pPg); + } + } + } rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); /* Write the extra pages and truncate the database file as required */ @@ -519,6 +531,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ rc = sqlite3PagerSync(pDestPager); } }else{ + sqlite3PagerTruncateImage(pDestPager, nDestTruncate); rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0); } diff --git a/src/btree.c b/src/btree.c index b3a907c5ab..89f7acdb5e 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2595,6 +2595,7 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){ if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){ goto trans_begun; } + assert( pBt->bDoTruncate==0 ); /* Write transactions are not possible on a read-only database */ if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){ @@ -3003,10 +3004,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){ }while( bCommit && iFreePg>nFin ); assert( iFreePgpDbPage); - if( rc==SQLITE_OK ){ - rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, nFin!=0); - } + rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, nFin!=0); releasePage(pLastPg); if( rc!=SQLITE_OK ){ return rc; @@ -3015,23 +3013,10 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){ } if( bCommit==0 ){ - iLastPg--; - while( iLastPg==PENDING_BYTE_PAGE(pBt)||PTRMAP_ISPAGE(pBt, iLastPg) ){ - if( PTRMAP_ISPAGE(pBt, iLastPg) ){ - MemPage *pPg; - rc = btreeGetPage(pBt, iLastPg, &pPg, 0); - if( rc!=SQLITE_OK ){ - return rc; - } - rc = sqlite3PagerWrite(pPg->pDbPage); - releasePage(pPg); - if( rc!=SQLITE_OK ){ - return rc; - } - } + do { iLastPg--; - } - sqlite3PagerTruncateImage(pBt->pPager, iLastPg); + }while( iLastPg==PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg) ); + pBt->bDoTruncate = 1; pBt->nPage = iLastPg; } return SQLITE_OK; @@ -3141,7 +3126,7 @@ static int autoVacuumCommit(BtShared *pBt){ put4byte(&pBt->pPage1->aData[32], 0); put4byte(&pBt->pPage1->aData[36], 0); put4byte(&pBt->pPage1->aData[28], nFin); - sqlite3PagerTruncateImage(pBt->pPager, nFin); + pBt->bDoTruncate = 1; pBt->nPage = nFin; } if( rc!=SQLITE_OK ){ @@ -3196,6 +3181,9 @@ int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){ return rc; } } + if( pBt->bDoTruncate ){ + sqlite3PagerTruncateImage(pBt->pPager, pBt->nPage); + } #endif rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0); sqlite3BtreeLeave(p); @@ -3211,6 +3199,9 @@ static void btreeEndTransaction(Btree *p){ BtShared *pBt = p->pBt; assert( sqlite3BtreeHoldsMutex(p) ); +#ifndef SQLITE_OMIT_AUTOVACUUM + pBt->bDoTruncate = 0; +#endif btreeClearHasContent(pBt); if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){ /* If there are other active statements that belong to this database @@ -5121,8 +5112,26 @@ static int allocateBtreePage( pPrevTrunk = 0; }while( searchList ); }else{ - /* There are no pages on the freelist, so create a new page at the - ** end of the file */ + /* There are no pages on the freelist, so append a new page to the + ** database image. + ** + ** Normally, new pages allocated by this block can be requested from the + ** pager layer with the 'no-content' flag set. This prevents the pager + ** from trying to read the pages content from disk. However, if the + ** current transaction has already run one or more incremental-vacuum + ** steps, then the page we are about to allocate may contain content + ** that is required in the event of a rollback. In this case, do + ** not set the no-content flag. This causes the pager to load and journal + ** the current page content before overwriting it. + ** + ** Note that the pager will not actually attempt to load or journal + ** content for any page that really does lie past the end of the database + ** file on disk. So the effects of disabling the no-content optimization + ** here are confined to those pages that lie between the end of the + ** database image and the end of the database file. + */ + int bNoContent = (0==pBt->bDoTruncate); + rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); if( rc ) return rc; pBt->nPage++; @@ -5137,7 +5146,7 @@ static int allocateBtreePage( MemPage *pPg = 0; TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", pBt->nPage)); assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) ); - rc = btreeGetPage(pBt, pBt->nPage, &pPg, 1); + rc = btreeGetPage(pBt, pBt->nPage, &pPg, bNoContent); if( rc==SQLITE_OK ){ rc = sqlite3PagerWrite(pPg->pDbPage); releasePage(pPg); @@ -5151,7 +5160,7 @@ static int allocateBtreePage( *pPgno = pBt->nPage; assert( *pPgno!=PENDING_BYTE_PAGE(pBt) ); - rc = btreeGetPage(pBt, *pPgno, ppPage, 1); + rc = btreeGetPage(pBt, *pPgno, ppPage, bNoContent); if( rc ) return rc; rc = sqlite3PagerWrite((*ppPage)->pDbPage); if( rc!=SQLITE_OK ){ diff --git a/src/btreeInt.h b/src/btreeInt.h index b157decec7..ce3c5493f8 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -411,6 +411,7 @@ struct BtShared { #ifndef SQLITE_OMIT_AUTOVACUUM u8 autoVacuum; /* True if auto-vacuum is enabled */ u8 incrVacuum; /* True if incr-vacuum is enabled */ + u8 bDoTruncate; /* True to truncate db on commit */ #endif u8 inTransaction; /* Transaction state */ u8 max1bytePayload; /* Maximum first byte of cell for a 1-byte payload */ diff --git a/src/pager.c b/src/pager.c index 5879cf760a..863368f591 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1838,6 +1838,8 @@ static int pager_error(Pager *pPager, int rc){ return rc; } +static int pager_truncate(Pager *pPager, Pgno nPage); + /* ** This routine ends a transaction. A transaction is usually ended by ** either a COMMIT or a ROLLBACK operation. This routine may be called @@ -1891,7 +1893,7 @@ static int pager_error(Pager *pPager, int rc){ ** to the first error encountered (the journal finalization one) is ** returned. */ -static int pager_end_transaction(Pager *pPager, int hasMaster){ +static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ int rc = SQLITE_OK; /* Error code from journal finalization operation */ int rc2 = SQLITE_OK; /* Error code from db file unlock operation */ @@ -1977,7 +1979,17 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){ */ rc2 = sqlite3WalEndWriteTransaction(pPager->pWal); assert( rc2==SQLITE_OK ); + }else if( rc==SQLITE_OK && bCommit && pPager->dbFileSize>pPager->dbSize ){ + /* This branch is taken when committing a transaction in rollback-journal + ** mode if the database file on disk is larger than the database image. + ** At this point the journal has been finalized and the transaction + ** successfully committed, but the EXCLUSIVE lock is still held on the + ** file. So it is safe to truncate the database file to its minimum + ** required size. */ + assert( pPager->eLock==EXCLUSIVE_LOCK ); + rc = pager_truncate(pPager, pPager->dbSize); } + if( !pPager->exclusiveMode && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0)) ){ @@ -2016,7 +2028,7 @@ static void pagerUnlockAndRollback(Pager *pPager){ sqlite3EndBenignMalloc(); }else if( !pPager->exclusiveMode ){ assert( pPager->eState==PAGER_READER ); - pager_end_transaction(pPager, 0); + pager_end_transaction(pPager, 0, 0); } } pager_unlock(pPager); @@ -2791,7 +2803,7 @@ end_playback: rc = sqlite3PagerSync(pPager); } if( rc==SQLITE_OK ){ - rc = pager_end_transaction(pPager, zMaster[0]!='\0'); + rc = pager_end_transaction(pPager, zMaster[0]!='\0', 0); testcase( rc!=SQLITE_OK ); } if( rc==SQLITE_OK && zMaster[0] && res ){ @@ -5885,36 +5897,6 @@ int sqlite3PagerCommitPhaseOne( #endif if( rc!=SQLITE_OK ) goto commit_phase_one_exit; - /* If this transaction has made the database smaller, then all pages - ** being discarded by the truncation must be written to the journal - ** file. - ** - ** Before reading the pages with page numbers larger than the - ** current value of Pager.dbSize, set dbSize back to the value - ** that it took at the start of the transaction. Otherwise, the - ** calls to sqlite3PagerGet() return zeroed pages instead of - ** reading data from the database file. - */ - if( pPager->dbSizedbOrigSize - && pPager->journalMode!=PAGER_JOURNALMODE_OFF - ){ - Pgno i; /* Iterator variable */ - const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */ - const Pgno dbSize = pPager->dbSize; /* Database image size */ - pPager->dbSize = pPager->dbOrigSize; - for( i=dbSize+1; i<=pPager->dbOrigSize; i++ ){ - if( !sqlite3BitvecTest(pPager->pInJournal, i) && i!=iSkip ){ - PgHdr *pPage; /* Page to journal */ - rc = sqlite3PagerGet(pPager, i, &pPage); - if( rc!=SQLITE_OK ) goto commit_phase_one_exit; - rc = sqlite3PagerWrite(pPage); - sqlite3PagerUnref(pPage); - if( rc!=SQLITE_OK ) goto commit_phase_one_exit; - } - } - pPager->dbSize = dbSize; - } - /* Write the master journal name into the journal file. If a master ** journal file name has already been written to the journal file, ** or if zMaster is NULL (no master journal), then this call is a no-op. @@ -5942,11 +5924,14 @@ int sqlite3PagerCommitPhaseOne( goto commit_phase_one_exit; } sqlite3PcacheCleanAll(pPager->pPCache); - - /* If the file on disk is not the same size as the database image, - ** then use pager_truncate to grow or shrink the file here. - */ - if( pPager->dbSize!=pPager->dbFileSize ){ + + /* If the file on disk is smaller than the database image, use + ** pager_truncate to grow the file here. This can happen if the database + ** image was extended as part of the current transaction and then the + ** last page in the db image moved to the free-list. In this case the + ** last page is never written out to disk, leaving the database file + ** undersized. Fix this now if it is the case. */ + if( pPager->dbSize>pPager->dbFileSize ){ Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager)); assert( pPager->eState==PAGER_WRITER_DBMOD ); rc = pager_truncate(pPager, nNew); @@ -6019,7 +6004,7 @@ int sqlite3PagerCommitPhaseTwo(Pager *pPager){ } PAGERTRACE(("COMMIT %d\n", PAGERID(pPager))); - rc = pager_end_transaction(pPager, pPager->setMaster); + rc = pager_end_transaction(pPager, pPager->setMaster, 1); return pager_error(pPager, rc); } @@ -6064,11 +6049,11 @@ int sqlite3PagerRollback(Pager *pPager){ if( pagerUseWal(pPager) ){ int rc2; rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1); - rc2 = pager_end_transaction(pPager, pPager->setMaster); + rc2 = pager_end_transaction(pPager, pPager->setMaster, 0); if( rc==SQLITE_OK ) rc = rc2; }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){ int eState = pPager->eState; - rc = pager_end_transaction(pPager, 0); + rc = pager_end_transaction(pPager, 0, 0); if( !MEMDB && eState>PAGER_WRITER_LOCKED ){ /* This can happen using journal_mode=off. Move the pager to the error ** state to indicate that the contents of the cache may not be trusted. diff --git a/test/tkt3762.test b/test/tkt3762.test index c24041c96e..424b1e6487 100644 --- a/test/tkt3762.test +++ b/test/tkt3762.test @@ -10,8 +10,8 @@ #*********************************************************************** # # Ticket #3762: Make sure that an incremental vacuum that reduces the -# size of the database file such that a pointer-map page is elemented -# can be correctly rolled back. +# size of the database file such that if a pointer-map page is eliminated +# it can be correctly rolled back. # # That ticket #3762 has been fixed has already been verified by the # savepoint6.test test script. But this script is simplier and a From 87ade19eb91f1c71a21e89c6b8f8a680a034aa8e Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 23 Feb 2013 17:49:16 +0000 Subject: [PATCH 17/45] Fix off-by-one bug in [c3939d2491] uncovered by th3. FossilOrigin-Name: 66f9faa9a969d004486ee38d492fb3eda6cdebab --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a4147e0d00..d869216321 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\srollback\smode\stransaction\sreduces\sthe\ssize\sof\sthe\sdatabase\sfile,\savoid\sactually\struncating\sthe\sfile\suntil\safter\sthe\stransaction\shas\sbeen\scommitted\s(but\sbefore\sthe\sdb\shas\sbeen\sunlocked).\sThis\smeans\spages\sthat\sare\sremoved\sfrom\sthe\sdatabase\sby\struncating\sthe\sfile\sneed\snot\sbe\sjournalled. -D 2013-02-23T16:40:46.526 +C Fix\soff-by-one\sbug\sin\s[c3939d2491]\suncovered\sby\sth3. +D 2013-02-23T17:49:16.450 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 0b8d2108a10ada00e642525921960b0c27451955 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c f021a7f59fd340577c2f9b7d6e951576af335cfb +F src/btree.c bcd64dff70af19e3a166853b7b728887cd4cc975 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 720a3ceafc35b81936ed2eb1f07a7187d104f0a0 -R 2fcb8a3a4c948e70b98e89248d0d9b21 +P b73847f17b7ae1298dfc52de6c4c4bc809bc77a3 +R 34a70e559a11e4b7cf3c06168257f235 U dan -Z 61c42a3e0f1600d37d1de1cf170b2233 +Z 1b7c8c9ddd8f5c22095277131689ae60 diff --git a/manifest.uuid b/manifest.uuid index 5875324cc6..bda95df179 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b73847f17b7ae1298dfc52de6c4c4bc809bc77a3 \ No newline at end of file +66f9faa9a969d004486ee38d492fb3eda6cdebab \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 89f7acdb5e..b46b32ffca 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5056,7 +5056,7 @@ static int allocateBtreePage( if( eMode==BTALLOC_LE ){ for(i=0; i Date: Sat, 23 Feb 2013 18:58:11 +0000 Subject: [PATCH 18/45] Enhancements to test scripts. No code changes. FossilOrigin-Name: ccab94c10d54e585de918bbf82dec188287d93b2 --- manifest | 16 ++++---- manifest.uuid | 2 +- src/test_vfs.c | 32 ++++++++------- test/incrvacuum_ioerr.test | 4 +- test/tester.tcl | 83 +++++++++++++++++++++++--------------- 5 files changed, 78 insertions(+), 59 deletions(-) diff --git a/manifest b/manifest index d869216321..9a1539d2ca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\soff-by-one\sbug\sin\s[c3939d2491]\suncovered\sby\sth3. -D 2013-02-23T17:49:16.450 +C Enhancements\sto\stest\sscripts.\sNo\scode\schanges. +D 2013-02-23T18:58:11.423 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -229,7 +229,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4 -F src/test_vfs.c c6260ef238c1142c8f8bd402db02216afd182ae3 +F src/test_vfs.c fb16b2d9938cf0c1afc5a423b55b952fcc024275 F src/test_vfstrace.c 34b544e80ba7fb77be15395a609c669df2e660a2 F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 @@ -534,7 +534,7 @@ F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597 F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32 F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b -F test/incrvacuum_ioerr.test 22f208d01c528403240e05beecc41dc98ed01637 +F test/incrvacuum_ioerr.test 293f2714571255539c8c789da2f7de4ec3f7101e F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 @@ -752,7 +752,7 @@ F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d -F test/tester.tcl 0560b09498876da7714fff680c5d892b9228862f +F test/tester.tcl 2918ebca150b67ca25b1682f8ecd857af77fab05 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P b73847f17b7ae1298dfc52de6c4c4bc809bc77a3 -R 34a70e559a11e4b7cf3c06168257f235 +P 66f9faa9a969d004486ee38d492fb3eda6cdebab +R 87b39f8ba9e2866ed1adab1a9b990f83 U dan -Z 1b7c8c9ddd8f5c22095277131689ae60 +Z c23ef7906674057cc290bb43146b99c4 diff --git a/manifest.uuid b/manifest.uuid index bda95df179..265b085615 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -66f9faa9a969d004486ee38d492fb3eda6cdebab \ No newline at end of file +ccab94c10d54e585de918bbf82dec188287d93b2 \ No newline at end of file diff --git a/src/test_vfs.c b/src/test_vfs.c index 93c556b56e..933de99515 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -265,7 +265,8 @@ static void tvfsExecTcl( const char *zMethod, Tcl_Obj *arg1, Tcl_Obj *arg2, - Tcl_Obj *arg3 + Tcl_Obj *arg3, + Tcl_Obj *arg4 ){ int rc; /* Return code from Tcl_EvalObj() */ Tcl_Obj *pEval; @@ -282,6 +283,7 @@ static void tvfsExecTcl( if( arg1 ) Tcl_ListObjAppendElement(p->interp, pEval, arg1); if( arg2 ) Tcl_ListObjAppendElement(p->interp, pEval, arg2); if( arg3 ) Tcl_ListObjAppendElement(p->interp, pEval, arg3); + if( arg4 ) Tcl_ListObjAppendElement(p->interp, pEval, arg4); rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL); if( rc!=TCL_OK ){ @@ -302,7 +304,7 @@ static int tvfsClose(sqlite3_file *pFile){ if( p->pScript && p->mask&TESTVFS_CLOSE_MASK ){ tvfsExecTcl(p, "xClose", - Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0 + Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0 ); } @@ -333,7 +335,7 @@ static int tvfsRead( Testvfs *p = (Testvfs *)pFd->pVfs->pAppData; if( p->pScript && p->mask&TESTVFS_READ_MASK ){ tvfsExecTcl(p, "xRead", - Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0 + Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0 ); tvfsResultCode(p, &rc); } @@ -362,7 +364,7 @@ static int tvfsWrite( if( p->pScript && p->mask&TESTVFS_WRITE_MASK ){ tvfsExecTcl(p, "xWrite", Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, - Tcl_NewWideIntObj(iOfst) + Tcl_NewWideIntObj(iOfst), Tcl_NewIntObj(iAmt) ); tvfsResultCode(p, &rc); } @@ -390,7 +392,7 @@ static int tvfsTruncate(sqlite3_file *pFile, sqlite_int64 size){ if( p->pScript && p->mask&TESTVFS_TRUNCATE_MASK ){ tvfsExecTcl(p, "xTruncate", - Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0 + Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0 ); tvfsResultCode(p, &rc); } @@ -431,7 +433,7 @@ static int tvfsSync(sqlite3_file *pFile, int flags){ tvfsExecTcl(p, "xSync", Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, - Tcl_NewStringObj(zFlags, -1) + Tcl_NewStringObj(zFlags, -1), 0 ); tvfsResultCode(p, &rc); } @@ -578,7 +580,7 @@ static int tvfsOpen( z += strlen(z) + 1; } } - tvfsExecTcl(p, "xOpen", Tcl_NewStringObj(pFd->zFilename, -1), pArg, 0); + tvfsExecTcl(p, "xOpen", Tcl_NewStringObj(pFd->zFilename, -1), pArg, 0, 0); Tcl_DecrRefCount(pArg); if( tvfsResultCode(p, &rc) ){ if( rc!=SQLITE_OK ) return rc; @@ -635,7 +637,7 @@ static int tvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ if( p->pScript && p->mask&TESTVFS_DELETE_MASK ){ tvfsExecTcl(p, "xDelete", - Tcl_NewStringObj(zPath, -1), Tcl_NewIntObj(dirSync), 0 + Tcl_NewStringObj(zPath, -1), Tcl_NewIntObj(dirSync), 0, 0 ); tvfsResultCode(p, &rc); } @@ -663,7 +665,7 @@ static int tvfsAccess( if( flags==SQLITE_ACCESS_READWRITE ) zArg = "SQLITE_ACCESS_READWRITE"; if( flags==SQLITE_ACCESS_READ ) zArg = "SQLITE_ACCESS_READ"; tvfsExecTcl(p, "xAccess", - Tcl_NewStringObj(zPath, -1), Tcl_NewStringObj(zArg, -1), 0 + Tcl_NewStringObj(zPath, -1), Tcl_NewStringObj(zArg, -1), 0, 0 ); if( tvfsResultCode(p, &rc) ){ if( rc!=SQLITE_OK ) return rc; @@ -691,7 +693,7 @@ static int tvfsFullPathname( Testvfs *p = (Testvfs *)pVfs->pAppData; if( p->pScript && p->mask&TESTVFS_FULLPATHNAME_MASK ){ int rc; - tvfsExecTcl(p, "xFullPathname", Tcl_NewStringObj(zPath, -1), 0, 0); + tvfsExecTcl(p, "xFullPathname", Tcl_NewStringObj(zPath, -1), 0, 0, 0); if( tvfsResultCode(p, &rc) ){ if( rc!=SQLITE_OK ) return rc; } @@ -771,7 +773,7 @@ static int tvfsShmOpen(sqlite3_file *pFile){ */ Tcl_ResetResult(p->interp); if( p->pScript && p->mask&TESTVFS_SHMOPEN_MASK ){ - tvfsExecTcl(p, "xShmOpen", Tcl_NewStringObj(pFd->zFilename, -1), 0, 0); + tvfsExecTcl(p, "xShmOpen", Tcl_NewStringObj(pFd->zFilename, -1), 0, 0, 0); if( tvfsResultCode(p, &rc) ){ if( rc!=SQLITE_OK ) return rc; } @@ -841,7 +843,7 @@ static int tvfsShmMap( Tcl_ListObjAppendElement(p->interp, pArg, Tcl_NewIntObj(pgsz)); Tcl_ListObjAppendElement(p->interp, pArg, Tcl_NewIntObj(isWrite)); tvfsExecTcl(p, "xShmMap", - Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, pArg + Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, pArg, 0 ); tvfsResultCode(p, &rc); Tcl_DecrRefCount(pArg); @@ -891,7 +893,7 @@ static int tvfsShmLock( } tvfsExecTcl(p, "xShmLock", Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, - Tcl_NewStringObj(zLock, -1) + Tcl_NewStringObj(zLock, -1), 0 ); tvfsResultCode(p, &rc); } @@ -937,7 +939,7 @@ static void tvfsShmBarrier(sqlite3_file *pFile){ if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){ tvfsExecTcl(p, "xShmBarrier", - Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0 + Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0, 0 ); } } @@ -961,7 +963,7 @@ static int tvfsShmUnmap( if( p->pScript && p->mask&TESTVFS_SHMCLOSE_MASK ){ tvfsExecTcl(p, "xShmUnmap", - Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0 + Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0, 0 ); tvfsResultCode(p, &rc); } diff --git a/test/incrvacuum_ioerr.test b/test/incrvacuum_ioerr.test index 946925d7dc..aecb6f8747 100644 --- a/test/incrvacuum_ioerr.test +++ b/test/incrvacuum_ioerr.test @@ -139,8 +139,8 @@ ifcapable shared_cache { # Figure out how big the database is and how many free pages it # has before running incremental-vacuum. # - set nPage [expr {[file size test.db]/1024}] set nFree [execsql {pragma freelist_count} db1] + set nPage [execsql {pragma page_count} db1] # Now run incremental-vacuum to vacuum 5 pages from the db file. # The iTest'th I/O call is set to fail. @@ -158,7 +158,7 @@ ifcapable shared_cache { set ::sqlite_io_error_hardhit 0 set nFree2 [execsql {pragma freelist_count} db1] - set nPage2 [expr {[file size test.db]/1024}] + set nPage2 [execsql {pragma page_count} db1] do_test incrvacuum-ioerr-4.$iTest.2 { set shrink [expr {$nPage-$nPage2}] diff --git a/test/tester.tcl b/test/tester.tcl index a7e6c99580..f360840789 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -1118,6 +1118,25 @@ proc crashsql {args} { lappend r $msg } +proc run_ioerr_prep {} { + set ::sqlite_io_error_pending 0 + catch {db close} + catch {db2 close} + catch {forcedelete test.db} + catch {forcedelete test.db-journal} + catch {forcedelete test2.db} + catch {forcedelete test2.db-journal} + set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db] + sqlite3_extended_result_codes $::DB $::ioerropts(-erc) + if {[info exists ::ioerropts(-tclprep)]} { + eval $::ioerropts(-tclprep) + } + if {[info exists ::ioerropts(-sqlprep)]} { + execsql $::ioerropts(-sqlprep) + } + expr 0 +} + # Usage: do_ioerr_test # # This proc is used to implement test cases that check that IO errors @@ -1150,10 +1169,26 @@ proc do_ioerr_test {testname args} { # TEMPORARY: For 3.5.9, disable testing of extended result codes. There are # a couple of obscure IO errors that do not return them. set ::ioerropts(-erc) 0 + + # Create a single TCL script from the TCL and SQL specified + # as the body of the test. + set ::ioerrorbody {} + if {[info exists ::ioerropts(-tclbody)]} { + append ::ioerrorbody "$::ioerropts(-tclbody)\n" + } + if {[info exists ::ioerropts(-sqlbody)]} { + append ::ioerrorbody "db eval {$::ioerropts(-sqlbody)}" + } + + save_prng_state + if {$::ioerropts(-cksum)} { + run_ioerr_prep + eval $::ioerrorbody + set ::goodcksum [cksum] + } set ::go 1 #reset_prng_state - save_prng_state for {set n $::ioerropts(-start)} {$::go} {incr n} { set ::TN $n incr ::ioerropts(-count) -1 @@ -1170,27 +1205,12 @@ proc do_ioerr_test {testname args} { # Delete the files test.db and test2.db, then execute the TCL and # SQL (in that order) to prepare for the test case. do_test $testname.$n.1 { - set ::sqlite_io_error_pending 0 - catch {db close} - catch {db2 close} - catch {forcedelete test.db} - catch {forcedelete test.db-journal} - catch {forcedelete test2.db} - catch {forcedelete test2.db-journal} - set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db] - sqlite3_extended_result_codes $::DB $::ioerropts(-erc) - if {[info exists ::ioerropts(-tclprep)]} { - eval $::ioerropts(-tclprep) - } - if {[info exists ::ioerropts(-sqlprep)]} { - execsql $::ioerropts(-sqlprep) - } - expr 0 + run_ioerr_prep } {0} # Read the 'checksum' of the database. if {$::ioerropts(-cksum)} { - set checksum [cksum] + set ::checksum [cksum] } # Set the Nth IO error to fail. @@ -1198,20 +1218,10 @@ proc do_ioerr_test {testname args} { set ::sqlite_io_error_persist $::ioerropts(-persist) set ::sqlite_io_error_pending $n }] $n - - # Create a single TCL script from the TCL and SQL specified - # as the body of the test. - set ::ioerrorbody {} - if {[info exists ::ioerropts(-tclbody)]} { - append ::ioerrorbody "$::ioerropts(-tclbody)\n" - } - if {[info exists ::ioerropts(-sqlbody)]} { - append ::ioerrorbody "db eval {$::ioerropts(-sqlbody)}" - } - # Execute the TCL Script created in the above block. If - # there are at least N IO operations performed by SQLite as - # a result of the script, the Nth will fail. + # Execute the TCL script created for the body of this test. If + # at least N IO operations performed by SQLite as a result of + # the script, the Nth will fail. do_test $testname.$n.3 { set ::sqlite_io_error_hit 0 set ::sqlite_io_error_hardhit 0 @@ -1315,8 +1325,15 @@ proc do_ioerr_test {testname args} { catch {db close} catch {db2 close} set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db] - cksum - } $checksum + set nowcksum [cksum] + set res [expr {$nowcksum==$::checksum || $nowcksum==$::goodcksum}] + if {$res==0} { + puts "now=$nowcksum" + puts "the=$::checksum" + puts "fwd=$::goodcksum" + } + set res + } 1 } set ::sqlite_io_error_hardhit 0 From 22d27300476e8e14ef35e0935eae4333eb259e01 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 23 Feb 2013 19:11:47 +0000 Subject: [PATCH 19/45] Fix a cut-and-paste bug causing the library to fail to report database corruption in a few cases. FossilOrigin-Name: f921df59560d536f5b80eef8c995cbe3ff591bae --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9a1539d2ca..4bdfea20f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\stest\sscripts.\sNo\scode\schanges. -D 2013-02-23T18:58:11.423 +C Fix\sa\scut-and-paste\sbug\scausing\sthe\slibrary\sto\sfail\sto\sreport\sdatabase\scorruption\sin\sa\sfew\scases. +D 2013-02-23T19:11:47.930 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 0b8d2108a10ada00e642525921960b0c27451955 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c bcd64dff70af19e3a166853b7b728887cd4cc975 +F src/btree.c 02ab112a16517321d64660e84e0ccc06ef5f43c7 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 66f9faa9a969d004486ee38d492fb3eda6cdebab -R 87b39f8ba9e2866ed1adab1a9b990f83 +P ccab94c10d54e585de918bbf82dec188287d93b2 +R e25f1782ace53b239780abd0cb855692 U dan -Z c23ef7906674057cc290bb43146b99c4 +Z 0e49116a8cea889274c349c3b9506a7e diff --git a/manifest.uuid b/manifest.uuid index 265b085615..f96d46f468 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ccab94c10d54e585de918bbf82dec188287d93b2 \ No newline at end of file +f921df59560d536f5b80eef8c995cbe3ff591bae \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index b46b32ffca..5952aa3a55 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3041,7 +3041,6 @@ static Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){ while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){ nFin--; } - if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT; return nFin; } From e0b605917e23a5106f7000e9d3e3786cf700787a Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 23 Feb 2013 19:43:47 +0000 Subject: [PATCH 20/45] Fix a case in the incremental vacuum code where database corruption was going unreported. FossilOrigin-Name: 4cd30c72629a7f44b18026a70103aa0bb8a3b959 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4bdfea20f9..034f22ed52 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scut-and-paste\sbug\scausing\sthe\slibrary\sto\sfail\sto\sreport\sdatabase\scorruption\sin\sa\sfew\scases. -D 2013-02-23T19:11:47.930 +C Fix\sa\scase\sin\sthe\sincremental\svacuum\scode\swhere\sdatabase\scorruption\swas\sgoing\sunreported. +D 2013-02-23T19:43:47.508 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 0b8d2108a10ada00e642525921960b0c27451955 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 02ab112a16517321d64660e84e0ccc06ef5f43c7 +F src/btree.c b84e2ac3b4ed5a4eb1b186c9c37eef53b635bc7f F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P ccab94c10d54e585de918bbf82dec188287d93b2 -R e25f1782ace53b239780abd0cb855692 +P f921df59560d536f5b80eef8c995cbe3ff591bae +R 1c3862ad49b71ee257cac1e86a276cf3 U dan -Z 0e49116a8cea889274c349c3b9506a7e +Z 0b46646dde77425bfb67d915fec16418 diff --git a/manifest.uuid b/manifest.uuid index f96d46f468..78f73b491f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f921df59560d536f5b80eef8c995cbe3ff591bae \ No newline at end of file +4cd30c72629a7f44b18026a70103aa0bb8a3b959 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 5952aa3a55..6c6d0b953b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3066,7 +3066,7 @@ int sqlite3BtreeIncrVacuum(Btree *p){ Pgno nFree = get4byte(&pBt->pPage1->aData[36]); Pgno nFin = finalDbSize(pBt, nOrig, nFree); - if( nFin0 ){ invalidateAllOverflowCache(pBt); rc = incrVacuumStep(pBt, nFin, nOrig, 0); if( rc==SQLITE_OK ){ From 9138471141dc1bd40db0430d17a612bfb5759a95 Mon Sep 17 00:00:00 2001 From: dan Date: Sun, 24 Feb 2013 11:50:43 +0000 Subject: [PATCH 21/45] Fix a case where database corruption may cause an assert() to fail. FossilOrigin-Name: ba33bb059ed4f4547da2880dbc8bd827c06fae34 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 034f22ed52..04965dd758 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scase\sin\sthe\sincremental\svacuum\scode\swhere\sdatabase\scorruption\swas\sgoing\sunreported. -D 2013-02-23T19:43:47.508 +C Fix\sa\scase\swhere\sdatabase\scorruption\smay\scause\san\sassert()\sto\sfail. +D 2013-02-24T11:50:43.950 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 0b8d2108a10ada00e642525921960b0c27451955 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c b84e2ac3b4ed5a4eb1b186c9c37eef53b635bc7f +F src/btree.c cbad71970cfadfa342fc137ca5e319f98b2d0da1 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P f921df59560d536f5b80eef8c995cbe3ff591bae -R 1c3862ad49b71ee257cac1e86a276cf3 +P 4cd30c72629a7f44b18026a70103aa0bb8a3b959 +R 4b714cf37fc577e9e0a95ce1f9383dd9 U dan -Z 0b46646dde77425bfb67d915fec16418 +Z 57f0815a503efb202bba1a714e0db419 diff --git a/manifest.uuid b/manifest.uuid index 78f73b491f..801adee734 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4cd30c72629a7f44b18026a70103aa0bb8a3b959 \ No newline at end of file +ba33bb059ed4f4547da2880dbc8bd827c06fae34 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 6c6d0b953b..84bafb9e73 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3066,7 +3066,9 @@ int sqlite3BtreeIncrVacuum(Btree *p){ Pgno nFree = get4byte(&pBt->pPage1->aData[36]); Pgno nFin = finalDbSize(pBt, nOrig, nFree); - if( nFree>0 ){ + if( nOrig0 ){ invalidateAllOverflowCache(pBt); rc = incrVacuumStep(pBt, nFin, nOrig, 0); if( rc==SQLITE_OK ){ From 896f99e942225edaf1fc40a0d04beace6f1bb835 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 25 Feb 2013 07:12:40 +0000 Subject: [PATCH 22/45] Catch a dropped error code in backup.c. FossilOrigin-Name: ac8ca3ecee4d81bf522b330033e5d85638063670 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/backup.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 04965dd758..cf75f0f4f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scase\swhere\sdatabase\scorruption\smay\scause\san\sassert()\sto\sfail. -D 2013-02-24T11:50:43.950 +C Catch\sa\sdropped\serror\scode\sin\sbackup.c. +D 2013-02-25T07:12:40.512 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -118,7 +118,7 @@ F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168 F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410 F src/attach.c ea5247f240e2c08afd608e9beb380814b86655e1 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 0b8d2108a10ada00e642525921960b0c27451955 +F src/backup.c b2cac9f7993f3f9588827b824b1501d0c820fa68 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c cbad71970cfadfa342fc137ca5e319f98b2d0da1 @@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 4cd30c72629a7f44b18026a70103aa0bb8a3b959 -R 4b714cf37fc577e9e0a95ce1f9383dd9 +P ba33bb059ed4f4547da2880dbc8bd827c06fae34 +R 2d999113323b8a278783fe6edad2f381 U dan -Z 57f0815a503efb202bba1a714e0db419 +Z 36585c74ecb2f209e8dc6af8304c9567 diff --git a/manifest.uuid b/manifest.uuid index 801adee734..1e72101c48 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba33bb059ed4f4547da2880dbc8bd827c06fae34 \ No newline at end of file +ac8ca3ecee4d81bf522b330033e5d85638063670 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 89e0f00e66..71a8a1a3e7 100644 --- a/src/backup.c +++ b/src/backup.c @@ -504,7 +504,9 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ } } } - rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); + if( rc==SQLITE_OK ){ + rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); + } /* Write the extra pages and truncate the database file as required */ iEnd = MIN(PENDING_BYTE + pgszDest, iSize); From 295fc442b50042644870cfd41d99619512eb2172 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 25 Feb 2013 12:06:55 +0000 Subject: [PATCH 23/45] Add test file incrvacuum3.test. No code changes. FossilOrigin-Name: bf57534188e044fb341315bfc05b7927e66a04e0 --- manifest | 11 ++-- manifest.uuid | 2 +- test/incrvacuum3.test | 137 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 test/incrvacuum3.test diff --git a/manifest b/manifest index cf75f0f4f9..f11324d902 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Catch\sa\sdropped\serror\scode\sin\sbackup.c. -D 2013-02-25T07:12:40.512 +C Add\stest\sfile\sincrvacuum3.test.\sNo\scode\schanges. +D 2013-02-25T12:06:55.032 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -534,6 +534,7 @@ F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597 F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32 F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b +F test/incrvacuum3.test 1159ec2b3e7bafbde5718867bc7328ba58863313 F test/incrvacuum_ioerr.test 293f2714571255539c8c789da2f7de4ec3f7101e F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 @@ -1034,7 +1035,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P ba33bb059ed4f4547da2880dbc8bd827c06fae34 -R 2d999113323b8a278783fe6edad2f381 +P ac8ca3ecee4d81bf522b330033e5d85638063670 +R 4eb400824b32ad5749b8b0c556f7d2a9 U dan -Z 36585c74ecb2f209e8dc6af8304c9567 +Z 4b0cde4b14de44a514d78f31b4dd5809 diff --git a/manifest.uuid b/manifest.uuid index 1e72101c48..3341d99e0a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac8ca3ecee4d81bf522b330033e5d85638063670 \ No newline at end of file +bf57534188e044fb341315bfc05b7927e66a04e0 \ No newline at end of file diff --git a/test/incrvacuum3.test b/test/incrvacuum3.test new file mode 100644 index 0000000000..ed2d47139e --- /dev/null +++ b/test/incrvacuum3.test @@ -0,0 +1,137 @@ +# 2013 Feb 25 +# +# 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 the SQLite library, focusing +# on the incremental vacuum feature. +# +# The tests in this file were added at the same time as optimizations +# were made to: +# +# * Truncate the database after a rollback mode commit, and +# +# * Avoid moving pages to locations from which they may need to be moved +# a second time if an incremental-vacuum proccess is allowed to vacuum +# the entire database. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix incrvacuum3 + +# If this build of the library does not support auto-vacuum, omit this +# whole file. +ifcapable {!autovacuum || !pragma} { + finish_test + return +} + +proc check_on_disk {} { + + # Copy the files for database "test.db" to "test2.db". + forcedelete test2.db test2.db-journal test2.db-wal + forcecopy test.db test2.db + if {[file exists test.db-journal]} { + forcecopy test.db-journal test2.db-journal + } + if {[file exists test.db-wal]} { + forcecopy test.db-wal test2.db-wal + } + + # Open "test2.db" and check it is Ok. + sqlite3 dbcheck test2.db + set ret [dbcheck eval { PRAGMA integrity_check }] + dbcheck close + set ret +} + +# Run these tests once in rollback journal mode, and once in wal mode. +# +foreach {T jrnl_mode} { + 1 delete + 2 wal +} { + catch { db close } + forcedelete test.db test.db-journal test.db-wal + sqlite3 db test.db + db eval { + PRAGMA cache_size = 5; + PRAGMA page_size = 1024; + PRAGMA auto_vacuum = 2; + } + db eval "PRAGMA journal_mode = $jrnl_mode" + + foreach {tn sql} { + 1 { + CREATE TABLE t1(x UNIQUE); + INSERT INTO t1 VALUES(randomblob(400)); + INSERT INTO t1 VALUES(randomblob(400)); + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 4 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 8 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 16 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 32 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 + } + + 2 { + DELETE FROM t1 WHERE rowid%8; + } + + 3 { + BEGIN; + PRAGMA incremental_vacuum = 100; + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 + ROLLBACK; + } + + 4 { + BEGIN; + SAVEPOINT one; + PRAGMA incremental_vacuum = 100; + SAVEPOINT two; + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 + } + + 5 { ROLLBACK to two } + + 6 { ROLLBACK to one } + + 7 { + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 + PRAGMA incremental_vacuum = 1000; + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 + ROLLBACK; + } + + 8 { + BEGIN; + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 + PRAGMA incremental_vacuum = 1000; + INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 + COMMIT; + } + } { + do_execsql_test $T.1.$tn.1 $sql + do_execsql_test $T.1.$tn.2 {PRAGMA integrity_check} ok + do_test $T.1.$tn.3 { check_on_disk } ok + } + + do_execsql_test $T.1.x.1 { PRAGMA freelist_count } 0 + do_execsql_test $T.1.x.2 { SELECT count(*) FROM t1 } 128 +} + +finish_test + From 132d93838d5b8c3c49db5d88d928f791f6678b3f Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 25 Feb 2013 13:44:56 +0000 Subject: [PATCH 24/45] Fix an error in test script index5.test. FossilOrigin-Name: d87e5acf2802d2887e20f79a8bd4990b2cd47b91 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/index5.test | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c6c0e781f4..405ebb13c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\sincr-vacuum-opt\sbranch\swith\sthe\strunk. -D 2013-02-25T13:31:30.464 +C Fix\san\serror\sin\stest\sscript\sindex5.test. +D 2013-02-25T13:44:56.570 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -540,7 +540,7 @@ F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026 -F test/index5.test edc8c64ca78bee140c21ce3836820fadf47906bb +F test/index5.test 7af36009155f091526454b371482eaffa07e9fb8 F test/indexedby.test be501e381b82b2f8ab406309ba7aac46e221f4ad F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1035,7 +1035,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 9bd9bd9cab8c804c1a51d472199459176044a633 bf57534188e044fb341315bfc05b7927e66a04e0 -R 4eb400824b32ad5749b8b0c556f7d2a9 +P 26e235b7a4cd4d0dc9725774d70174c4d369cb98 +R 0cfcb8f301b9cfa0a465c09c870c162d U dan -Z 245da16ecbcaa5ac23033dda88925107 +Z 886833d22a3b2590790bb996461e3c36 diff --git a/manifest.uuid b/manifest.uuid index 31095e83e3..181b80da0f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -26e235b7a4cd4d0dc9725774d70174c4d369cb98 \ No newline at end of file +d87e5acf2802d2887e20f79a8bd4990b2cd47b91 \ No newline at end of file diff --git a/test/index5.test b/test/index5.test index c8e94b3985..d7c663a113 100644 --- a/test/index5.test +++ b/test/index5.test @@ -36,11 +36,10 @@ db close testvfs tvfs tvfs filter xWrite tvfs script write_cb -proc write_cb {xCall file handle iOfst} { +proc write_cb {xCall file handle iOfst args} { if {[file tail $file]=="test.db"} { lappend ::write_list [expr $iOfst/1024] } - puts "$xCall $file $args" } do_test 1.2 { From c6a67173bda67abd641c5ed15fc928ded471864c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Feb 2013 13:55:59 +0000 Subject: [PATCH 25/45] Strengthen the final test case in index5.test. Also provide additional diagnostic information out the output. FossilOrigin-Name: 47b6418242bb2cd718d1a73b0cb73a43ee74e503 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/index5.test | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 405ebb13c7..3a38438d67 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\serror\sin\stest\sscript\sindex5.test. -D 2013-02-25T13:44:56.570 +C Strengthen\sthe\sfinal\stest\scase\sin\sindex5.test.\s\sAlso\sprovide\sadditional\ndiagnostic\sinformation\sout\sthe\soutput. +D 2013-02-25T13:55:59.837 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -540,7 +540,7 @@ F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026 -F test/index5.test 7af36009155f091526454b371482eaffa07e9fb8 +F test/index5.test 5616266b2387003bf83c39df626c7292622d58de F test/indexedby.test be501e381b82b2f8ab406309ba7aac46e221f4ad F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1035,7 +1035,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 26e235b7a4cd4d0dc9725774d70174c4d369cb98 -R 0cfcb8f301b9cfa0a465c09c870c162d -U dan -Z 886833d22a3b2590790bb996461e3c36 +P d87e5acf2802d2887e20f79a8bd4990b2cd47b91 +R eab578b1b57353b6c3cb7f5f6faef55f +U drh +Z 0e128646425d74587780af38946ae84f diff --git a/manifest.uuid b/manifest.uuid index 181b80da0f..232a450f12 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d87e5acf2802d2887e20f79a8bd4990b2cd47b91 \ No newline at end of file +47b6418242bb2cd718d1a73b0cb73a43ee74e503 \ No newline at end of file diff --git a/test/index5.test b/test/index5.test index d7c663a113..72f536fc8f 100644 --- a/test/index5.test +++ b/test/index5.test @@ -64,11 +64,12 @@ do_test 1.3 { } set iPrev $iNext } + puts -nonewline \ + " (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)" - expr {$nForward > $nBackward} + expr {$nForward > 25*($nBackward + $nNoncont)} } {1} db close tvfs delete finish_test - From c9545442f95f3dd71e67e249bec93fe36ec774d4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 26 Feb 2013 05:42:30 +0000 Subject: [PATCH 26/45] Remove extra use of the sqlite3_value_int64() function. FossilOrigin-Name: 6d7973524a7d3bf3158fdac58975945da7f51740 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b7ed61fdcb..2add2e5ec7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sSQL\sfunctions\sunicode()\sand\schar(). -D 2013-02-25T14:39:47.361 +C Remove\sextra\suse\sof\sthe\ssqlite3_value_int64()\sfunction. +D 2013-02-26T05:42:30.002 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d F src/expr.c f6c20285bd36e87ec47f4d840e90a32755e2a90c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 -F src/func.c 18b120b9a34daf6d38d50969b6f3471c09b2934a +F src/func.c cac45cca7bbe29bbefef46116174e89e1284763b F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -1035,7 +1035,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 47b6418242bb2cd718d1a73b0cb73a43ee74e503 209b21085b9767f10f6ffb7c7cac756fcb74ded5 -R acbb3126cf444e9dd94bf56c3bd8260d -U drh -Z f91250c13344084844a40baa07a182ba +P be2493905281e12c7f4c146ab17c8872e52da350 +R a60abe17b21bf1359d9c1679d089205f +U mistachkin +Z 59402f1761566765a916d1a7046c0b39 diff --git a/manifest.uuid b/manifest.uuid index d8624e0281..9754acb583 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -be2493905281e12c7f4c146ab17c8872e52da350 \ No newline at end of file +6d7973524a7d3bf3158fdac58975945da7f51740 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 98f2a2e96b..43a338ed38 100644 --- a/src/func.c +++ b/src/func.c @@ -993,7 +993,7 @@ static void charFunc( return; } for(i=0; i0x10ffff ) x = 0xfffd; From 8d0b81d764bc4b27fa732d18c032081f2b0791d3 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 26 Feb 2013 05:44:33 +0000 Subject: [PATCH 27/45] Prevent Tcl file encoding issues in the tests for the unicode() and char() functions. FossilOrigin-Name: d2e7dfca5a92074a7984032deb6a4e3681389c72 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- test/func.test | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2add2e5ec7..36ed88708b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sextra\suse\sof\sthe\ssqlite3_value_int64()\sfunction. -D 2013-02-26T05:42:30.002 +C Prevent\sTcl\sfile\sencoding\sissues\sin\sthe\stests\sfor\sthe\sunicode()\sand\schar()\sfunctions. +D 2013-02-26T05:44:33.955 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -508,7 +508,7 @@ F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 F test/fts4unicode.test 25ccad45896f8e50f6a694cff738a35f798cdb40 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test dd81580d3e8f2afafdcc8dd67233f9b4fc69a79e +F test/func.test b058483c17952eff7797b837bbb61e27e6b05606 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 @@ -1035,7 +1035,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P be2493905281e12c7f4c146ab17c8872e52da350 -R a60abe17b21bf1359d9c1679d089205f +P 6d7973524a7d3bf3158fdac58975945da7f51740 +R 49ff1f2b0a98496405857ab66db0f4ad +T *branch * funcTestEncoding +T *sym-funcTestEncoding * +T -sym-trunk * U mistachkin -Z 59402f1761566765a916d1a7046c0b39 +Z 6ef7a794e2bcbed68706686e53ccd98f diff --git a/manifest.uuid b/manifest.uuid index 9754acb583..bcd57415cc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d7973524a7d3bf3158fdac58975945da7f51740 \ No newline at end of file +d2e7dfca5a92074a7984032deb6a4e3681389c72 \ No newline at end of file diff --git a/test/func.test b/test/func.test index e45f961a73..f09ff49805 100644 --- a/test/func.test +++ b/test/func.test @@ -1291,9 +1291,9 @@ do_test func-29.6 { } {1} do_execsql_test func-30.1 {SELECT unicode('$');} 36 -do_execsql_test func-30.2 {SELECT unicode('¢');} 162 -do_execsql_test func-30.3 {SELECT unicode('€');} 8364 -do_execsql_test func-30.4 {SELECT char(36,162,8364);} {$¢€} +do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162 +do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364 +do_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\u00A2\u20AC}] for {set i 1} {$i<0xd800} {incr i 13} { do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i From 9cf37e718c0f0e86b3ba0861d7aa18dcb8fbd9ff Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 26 Feb 2013 06:14:27 +0000 Subject: [PATCH 28/45] Change the way test script incrvacuum3.test copies database files in order to avoid trying to read the (locked) 512 byte 'pending-byte' region. FossilOrigin-Name: fa1842e462049b1366909fe36d6d81b634be3953 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/incrvacuum3.test | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2add2e5ec7..4aae897e11 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sextra\suse\sof\sthe\ssqlite3_value_int64()\sfunction. -D 2013-02-26T05:42:30.002 +C Change\sthe\sway\stest\sscript\sincrvacuum3.test\scopies\sdatabase\sfiles\sin\sorder\sto\savoid\strying\sto\sread\sthe\s(locked)\s512\sbyte\s'pending-byte'\sregion. +D 2013-02-26T06:14:27.544 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -534,7 +534,7 @@ F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597 F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32 F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b -F test/incrvacuum3.test 1159ec2b3e7bafbde5718867bc7328ba58863313 +F test/incrvacuum3.test 7198a60267beda6eb49bb65ab40db35873ec8d0d F test/incrvacuum_ioerr.test 293f2714571255539c8c789da2f7de4ec3f7101e F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 @@ -1035,7 +1035,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P be2493905281e12c7f4c146ab17c8872e52da350 -R a60abe17b21bf1359d9c1679d089205f -U mistachkin -Z 59402f1761566765a916d1a7046c0b39 +P 6d7973524a7d3bf3158fdac58975945da7f51740 +R 538583335e104793ae2aa040823d6e4d +U dan +Z 05d687700aaf72f6488f6d2b4316e01c diff --git a/manifest.uuid b/manifest.uuid index 9754acb583..e6aa0cf57e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d7973524a7d3bf3158fdac58975945da7f51740 \ No newline at end of file +fa1842e462049b1366909fe36d6d81b634be3953 \ No newline at end of file diff --git a/test/incrvacuum3.test b/test/incrvacuum3.test index ed2d47139e..12f6b23edf 100644 --- a/test/incrvacuum3.test +++ b/test/incrvacuum3.test @@ -34,9 +34,8 @@ ifcapable {!autovacuum || !pragma} { proc check_on_disk {} { - # Copy the files for database "test.db" to "test2.db". + # Copy the wal and journal files for database "test.db" to "test2.db". forcedelete test2.db test2.db-journal test2.db-wal - forcecopy test.db test2.db if {[file exists test.db-journal]} { forcecopy test.db-journal test2.db-journal } @@ -44,6 +43,23 @@ proc check_on_disk {} { forcecopy test.db-wal test2.db-wal } + # Now copy the database file itself. Do this using open/read/puts + # instead of the [file copy] command in order to avoid attempting + # to read the 512 bytes begining at offset $sqlite_pending_byte. + # + set sz [file size test.db] + set fd [open test.db] + set fd2 [open test2.db w] + fconfigure $fd -encoding binary -translation binary + fconfigure $fd2 -encoding binary -translation binary + if {$sz>$::sqlite_pending_byte} { + puts -nonewline $fd2 [read $fd $::sqlite_pending_byte] + seek $fd [expr $::sqlite_pending_byte+512] + seek $fd2 [expr $::sqlite_pending_byte+512] + } + puts -nonewline $fd2 [read $fd] + close $fd2 + # Open "test2.db" and check it is Ok. sqlite3 dbcheck test2.db set ret [dbcheck eval { PRAGMA integrity_check }] From dd1dd489d9d13289aa81dba943d011c6e17db640 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Feb 2013 12:57:42 +0000 Subject: [PATCH 29/45] When comparing names during name resolution, make sure the names match exactly and that one name isn't merely a prefix of the other. Fix for ticket [7a31705a7e6c95d51]. FossilOrigin-Name: c2d5a23b1ab39918e97c596cf75c42f86a5fe2b7 --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/resolve.c | 4 ++-- test/tkt-7a31705a7e6.test | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 test/tkt-7a31705a7e6.test diff --git a/manifest b/manifest index 4aae897e11..1f2fb128ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sway\stest\sscript\sincrvacuum3.test\scopies\sdatabase\sfiles\sin\sorder\sto\savoid\strying\sto\sread\sthe\s(locked)\s512\sbyte\s'pending-byte'\sregion. -D 2013-02-26T06:14:27.544 +C When\scomparing\snames\sduring\sname\sresolution,\smake\ssure\sthe\snames\smatch\nexactly\sand\sthat\sone\sname\sisn't\smerely\sa\sprefix\sof\sthe\sother.\nFix\sfor\sticket\s[7a31705a7e6c95d51]. +D 2013-02-26T12:57:42.514 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -172,7 +172,7 @@ F src/pragma.c bdb484d0283965c431d4153f28c30f836a1f16b1 F src/prepare.c 931ad0d852a0df48f79adcba6ce79ca5f475625c F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 -F src/resolve.c 652ae6dc0f185b01b4536bb2fa7d878f13f0f1df +F src/resolve.c 9079da7d59aed2bb14ec8315bc7f720dd85b5b65 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c e1c6f6abdf9f359f4e735cb8ae11d2f359bf52a9 F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca @@ -784,6 +784,7 @@ F test/tkt-5e10420e8d.test 904d1687b3c06d43e5b3555bbcf6802e7c0ffd84 F test/tkt-5ee23731f.test 9db6e1d7209dc0794948b260d6f82b2b1de83a9f F test/tkt-752e1646fc.test ea78d88d14fe9866bdd991c634483334639e13bf F test/tkt-78e04e52ea.test 703e0bfb23d543edf0426a97e3bbd0ca346508ec +F test/tkt-7a31705a7e6.test 5a7889fdb095ffbe1622413e0145de1637d421bd F test/tkt-7bbfb7d442.test dfa5c8097a8c353ae40705d6cddeb1f99c18b81a F test/tkt-80ba201079.test 105a721e6aad0ae3c5946d7615d1e4d03f6145b8 F test/tkt-80e031a00f.test 9a154173461a4dbe2de49cda73963e04842d52f7 @@ -1035,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 6d7973524a7d3bf3158fdac58975945da7f51740 -R 538583335e104793ae2aa040823d6e4d -U dan -Z 05d687700aaf72f6488f6d2b4316e01c +P fa1842e462049b1366909fe36d6d81b634be3953 +R f34c00396e68edbafc7e03b1d894fd28 +U drh +Z a7d367b0a7c33935bece18346d0a84c6 diff --git a/manifest.uuid b/manifest.uuid index e6aa0cf57e..d756f270b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa1842e462049b1366909fe36d6d81b634be3953 \ No newline at end of file +c2d5a23b1ab39918e97c596cf75c42f86a5fe2b7 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index f8cd9e5ab2..0380138678 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -165,12 +165,12 @@ int sqlite3MatchSpanName( ){ int n; for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} - if( zDb && sqlite3StrNICmp(zSpan, zDb, n)!=0 ){ + if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ return 0; } zSpan += n+1; for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} - if( zTab && sqlite3StrNICmp(zSpan, zTab, n)!=0 ){ + if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){ return 0; } zSpan += n+1; diff --git a/test/tkt-7a31705a7e6.test b/test/tkt-7a31705a7e6.test new file mode 100644 index 0000000000..64701220a8 --- /dev/null +++ b/test/tkt-7a31705a7e6.test @@ -0,0 +1,26 @@ +# 2013 February 26 +# +# 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. Specifically, +# it tests that ticket [7a31705a7e6c95d514e6f20a6900f436bbc9fed8] in the +# name resolver has been fixed. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_execsql_test tkt-7a31705a7e6-1.1 { + CREATE TABLE t1 (a INTEGER PRIMARY KEY); + CREATE TABLE t2 (a INTEGER PRIMARY KEY, b INTEGER); + CREATE TABLE t2x (b INTEGER PRIMARY KEY); + SELECT t1.a FROM ((t1 JOIN t2 ON t1.a=t2.a) AS x JOIN t2x ON x.b=t2x.b) as y; +} {} + From 016fff2b6eacbf1335e105f430bcd741d771d7f4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 26 Feb 2013 18:54:18 +0000 Subject: [PATCH 30/45] In the incrvacuum3 test, add missing call to the Tcl close command. FossilOrigin-Name: cd8067238439638bcfd3966d55d2a3990f36d702 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/incrvacuum3.test | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1f2fb128ab..ca40b04498 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scomparing\snames\sduring\sname\sresolution,\smake\ssure\sthe\snames\smatch\nexactly\sand\sthat\sone\sname\sisn't\smerely\sa\sprefix\sof\sthe\sother.\nFix\sfor\sticket\s[7a31705a7e6c95d51]. -D 2013-02-26T12:57:42.514 +C In\sthe\sincrvacuum3\stest,\sadd\smissing\scall\sto\sthe\sTcl\sclose\scommand. +D 2013-02-26T18:54:18.663 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -534,7 +534,7 @@ F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597 F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0 F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32 F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b -F test/incrvacuum3.test 7198a60267beda6eb49bb65ab40db35873ec8d0d +F test/incrvacuum3.test 2ffa9e4a23f072bd7902b9ae6471f8822a6522a7 F test/incrvacuum_ioerr.test 293f2714571255539c8c789da2f7de4ec3f7101e F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P fa1842e462049b1366909fe36d6d81b634be3953 -R f34c00396e68edbafc7e03b1d894fd28 -U drh -Z a7d367b0a7c33935bece18346d0a84c6 +P c2d5a23b1ab39918e97c596cf75c42f86a5fe2b7 +R 687a470b4afc6de785d4ede326493d08 +U mistachkin +Z 915aa22c53fd0f2da96b96267104ce14 diff --git a/manifest.uuid b/manifest.uuid index d756f270b9..2106d91ee2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2d5a23b1ab39918e97c596cf75c42f86a5fe2b7 \ No newline at end of file +cd8067238439638bcfd3966d55d2a3990f36d702 \ No newline at end of file diff --git a/test/incrvacuum3.test b/test/incrvacuum3.test index 12f6b23edf..f01dc100b8 100644 --- a/test/incrvacuum3.test +++ b/test/incrvacuum3.test @@ -59,6 +59,7 @@ proc check_on_disk {} { } puts -nonewline $fd2 [read $fd] close $fd2 + close $fd # Open "test2.db" and check it is Ok. sqlite3 dbcheck test2.db From 503a686e09ce03995eef5d9a95ef217532575be5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Mar 2013 01:07:17 +0000 Subject: [PATCH 31/45] Always use strncmp() rather than memcmp() when comparing strings where one or other string might be less than the length parameter, since optimized versions of memcmp() might read past the first difference and in so doing generate an access violation. FossilOrigin-Name: d73435587ba7459e2e2c32980d0e17abdeceb4bc --- manifest | 28 ++++++++++++++-------------- manifest.uuid | 2 +- src/analyze.c | 4 ++-- src/build.c | 2 +- src/expr.c | 2 +- src/os_unix.c | 2 +- src/test_quota.c | 2 +- src/test_regexp.c | 2 +- src/test_spellfix.c | 12 ++++++------ src/vdbeapi.c | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index ca40b04498..740d228bb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sincrvacuum3\stest,\sadd\smissing\scall\sto\sthe\sTcl\sclose\scommand. -D 2013-02-26T18:54:18.663 +C Always\suse\sstrncmp()\srather\sthan\smemcmp()\swhen\scomparing\sstrings\swhere\sone\nor\sother\sstring\smight\sbe\sless\sthan\sthe\slength\sparameter,\ssince\soptimized\nversions\sof\smemcmp()\smight\sread\spast\sthe\sfirst\sdifference\sand\sin\sso\sdoing\ngenerate\san\saccess\sviolation. +D 2013-03-01T01:07:17.783 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -115,7 +115,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168 -F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410 +F src/analyze.c d5f895810e8ff9737c9ec7b76abc3dcff5860335 F src/attach.c ea5247f240e2c08afd608e9beb380814b86655e1 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b2cac9f7993f3f9588827b824b1501d0c820fa68 @@ -124,13 +124,13 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c cbad71970cfadfa342fc137ca5e319f98b2d0da1 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 -F src/build.c 73ca65f32938e4e0d94e831b61b5749b211b79be +F src/build.c 375e5df716e03b9343c5e1211be3b24e6d6dff05 F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d -F src/expr.c f6c20285bd36e87ec47f4d840e90a32755e2a90c +F src/expr.c a23b4aac2a455b2e76b55bef5dcfbe62b665375c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 F src/func.c cac45cca7bbe29bbefef46116174e89e1284763b @@ -160,7 +160,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c dfdc04b126f7b05dcb2e2cc5c1262f98acbb49d9 +F src/os_unix.c 8964f621aaab1f2c9804fbbff4450d9811ef5548 F src/os_win.c eabd00b813577d36bd66271cb08dd64ea0589dac F src/pager.c 0dbf5ff5d5d7d3a21fcab82e9e4d129b6fe6314f F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 @@ -216,13 +216,13 @@ F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25 F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 -F src/test_quota.c 0e0e2e3bf6766b101ecccd8c042b66e44e9be8f5 +F src/test_quota.c 1ec82e02fd3643899e9a5de9684515e84641c91f F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb -F src/test_regexp.c 58e0349f155bc307dfa209df4b03add0a7749866 +F src/test_regexp.c 08748a68ddb3b29329dbdade5ede849a749f0c07 F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 83abe9d8c364cdd5f93bc06eaf40a349ebbf6c5c +F src/test_spellfix.c 56dfa6d583ac34f61af0834d7b58d674e7e18e13 F src/test_sqllog.c 8acb843ddb9928dea8962e31bb09f421a72ffccb F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd @@ -242,7 +242,7 @@ F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 F src/vdbe.c 292f8f7ced59c29c63fe17830cbe5f5a0230cdf0 F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d F src/vdbeInt.h 396bb03eec560f768d1b86092b00f46c25575d3b -F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c +F src/vdbeapi.c 9616986209cc77822aa9f7d91cf9e6880516d557 F src/vdbeaux.c 735a6905df302a7f3c715a82bd3af06dc7d74ef2 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P c2d5a23b1ab39918e97c596cf75c42f86a5fe2b7 -R 687a470b4afc6de785d4ede326493d08 -U mistachkin -Z 915aa22c53fd0f2da96b96267104ce14 +P cd8067238439638bcfd3966d55d2a3990f36d702 +R 5a3dd033106407aa4f07779dd0d49c1d +U drh +Z dd2b43e4a7c5d5f8a543e6614ead6c72 diff --git a/manifest.uuid b/manifest.uuid index 2106d91ee2..e255598aac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd8067238439638bcfd3966d55d2a3990f36d702 \ No newline at end of file +d73435587ba7459e2e2c32980d0e17abdeceb4bc \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 632fdc1ac1..9a3e9597db 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -473,7 +473,7 @@ static void analyzeOneTable( /* Do not gather statistics on views or virtual tables */ return; } - if( memcmp(pTab->zName, "sqlite_", 7)==0 ){ + if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){ /* Do not gather statistics on system tables */ return; } @@ -883,7 +883,7 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ if( pIndex==0 ) break; pIndex->aiRowEst[i] = v; if( *z==' ' ) z++; - if( memcmp(z, "unordered", 10)==0 ){ + if( strcmp(z, "unordered")==0 ){ pIndex->bUnordered = 1; break; } diff --git a/src/build.c b/src/build.c index 4ce65a43d7..5d063f0726 100644 --- a/src/build.c +++ b/src/build.c @@ -2594,7 +2594,7 @@ Index *sqlite3CreateIndex( assert( pTab!=0 ); assert( pParse->nErr==0 ); if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 - && memcmp(&pTab->zName[7],"altertab_",9)!=0 ){ + && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){ sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName); goto exit_create_index; } diff --git a/src/expr.c b/src/expr.c index 5de468e211..4f38ab0a46 100644 --- a/src/expr.c +++ b/src/expr.c @@ -638,7 +638,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ */ ynVar i; for(i=0; inzVar; i++){ - if( pParse->azVar[i] && memcmp(pParse->azVar[i],z,n+1)==0 ){ + if( pParse->azVar[i] && strcmp(pParse->azVar[i],z)==0 ){ pExpr->iColumn = x = (ynVar)i+1; break; } diff --git a/src/os_unix.c b/src/os_unix.c index dc13be186e..fca2f703df 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4752,7 +4752,7 @@ static int fillInUnixFile( "psow", SQLITE_POWERSAFE_OVERWRITE) ){ pNew->ctrlFlags |= UNIXFILE_PSOW; } - if( memcmp(pVfs->zName,"unix-excl",10)==0 ){ + if( strcmp(pVfs->zName,"unix-excl")==0 ){ pNew->ctrlFlags |= UNIXFILE_EXCL; } diff --git a/src/test_quota.c b/src/test_quota.c index 166a512f18..58169e17cc 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -1295,7 +1295,7 @@ int sqlite3_quota_remove(const char *zFilename){ if( pGroup ){ for(pFile=pGroup->pFiles; pFile && rc==SQLITE_OK; pFile=pNextFile){ pNextFile = pFile->pNext; - diff = memcmp(zFull, pFile->zFilename, nFull); + diff = strncmp(zFull, pFile->zFilename, nFull); if( diff==0 && ((c = pFile->zFilename[nFull])==0 || c=='/' || c=='\\') ){ if( pFile->nRef ){ pFile->deleteOnClose = 1; diff --git a/src/test_regexp.c b/src/test_regexp.c index 321417b882..2cebbea44a 100644 --- a/src/test_regexp.c +++ b/src/test_regexp.c @@ -194,7 +194,7 @@ int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){ if( pRe->nInit ){ unsigned char x = pRe->zInit[0]; while( in.i+pRe->nInit<=in.mx - && (zIn[in.i]!=x || memcmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0) + && (zIn[in.i]!=x || strncmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0) ){ in.i++; } diff --git a/src/test_spellfix.c b/src/test_spellfix.c index f294f48c61..16376244a3 100644 --- a/src/test_spellfix.c +++ b/src/test_spellfix.c @@ -744,22 +744,22 @@ static int utf8Len(unsigned char c, int N){ } /* -** Return TRUE (non-zero) of the To side of the given cost matches +** Return TRUE (non-zero) if the To side of the given cost matches ** the given string. */ static int matchTo(EditDist3Cost *p, const char *z, int n){ if( p->nTo>n ) return 0; - if( memcmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0; + if( strncmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0; return 1; } /* -** Return TRUE (non-zero) of the To side of the given cost matches +** Return TRUE (non-zero) if the From side of the given cost matches ** the given string. */ static int matchFrom(EditDist3Cost *p, const char *z, int n){ assert( p->nFrom<=n ); - if( memcmp(p->a, z, p->nFrom)!=0 ) return 0; + if( strncmp(p->a, z, p->nFrom)!=0 ) return 0; return 1; } @@ -1952,7 +1952,7 @@ static int spellfix1Init( ); } for(i=3; rc==SQLITE_OK && i Date: Fri, 1 Mar 2013 23:40:26 +0000 Subject: [PATCH 35/45] Complete the initialization of the loadable extension thunk table. Also fix other (harmless) compiler warnings. FossilOrigin-Name: 780d06c5e54590f677f993fa9c313989c2eab8c7 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/func.c | 1 + src/loadext.c | 13 +++++++++++++ src/test_regexp.c | 5 +++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index bf449307b2..7bd0348f28 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\scygwin\sinterface\sto\suse\sthe\snewer\s1.7\sAPIs\sinstead\sof\sthe\n1.5\sAPIs.\s\sAlso\sshorten\sover-length\ssource\scode\slines\sin\sos_win.c. -D 2013-03-01T23:24:04.416 +C Complete\sthe\sinitialization\sof\sthe\sloadable\sextension\sthunk\stable.\s\sAlso\nfix\sother\s(harmless)\scompiler\swarnings. +D 2013-03-01T23:40:26.913 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d F src/expr.c a23b4aac2a455b2e76b55bef5dcfbe62b665375c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 -F src/func.c b45b6a171511e3a8e50bf6f8503e54a76f608e02 +F src/func.c 91bc65eb68ef6cf29198aac92f11489fa85a8de4 F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -142,7 +142,7 @@ F src/insert.c f7cb141e8ce257cb6b15c497f09e4e23d6055599 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b -F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d +F src/loadext.c 1422eba4aa2b1fb5f7b3aef574752272477d21e2 F src/main.c 8d204866d1abf5100503dcd54d3187b88f6846b7 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -218,7 +218,7 @@ F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 F src/test_quota.c 1ec82e02fd3643899e9a5de9684515e84641c91f F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb -F src/test_regexp.c 08748a68ddb3b29329dbdade5ede849a749f0c07 +F src/test_regexp.c 5ff0eafd66c9a209417142fa319006f7028fbda8 F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P c9c2b82c86fff457a0b32d5be84ec66639065ae1 -R f939bbf001afa25b994d8ca6deefd57b +P 6b2838336a31e34c540210ccc9c934d4ba94757c +R db69dd670ef335759c7475908d848a42 U drh -Z d24cb65108217f32a1099dd98d4c4743 +Z d35d3652e81b05a9c2009fdff0b4ddbd diff --git a/manifest.uuid b/manifest.uuid index a06a7efc72..235d98e3ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b2838336a31e34c540210ccc9c934d4ba94757c \ No newline at end of file +780d06c5e54590f677f993fa9c313989c2eab8c7 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 09453b3c63..56cd6052b4 100644 --- a/src/func.c +++ b/src/func.c @@ -972,6 +972,7 @@ static void unicodeFunc( sqlite3_value **argv ){ const unsigned char *z = sqlite3_value_text(argv[0]); + (void)argc; if( z && z[0] ) sqlite3_result_int(context, sqlite3Utf8Read(&z)); } diff --git a/src/loadext.c b/src/loadext.c index 3fcf5008cf..76450f2e8b 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -378,6 +378,19 @@ static const sqlite3_api_routines sqlite3Apis = { sqlite3_blob_reopen, sqlite3_vtab_config, sqlite3_vtab_on_conflict, + sqlite3_close_v2, + sqlite3_db_filename, + sqlite3_db_readonly, + sqlite3_db_release_memory, + sqlite3_errstr, + sqlite3_stmt_busy, + sqlite3_stmt_readonly, + sqlite3_stricmp, + sqlite3_uri_boolean, + sqlite3_uri_int64, + sqlite3_uri_parameter, + sqlite3_vsnprintf, + sqlite3_wal_checkpoint_v2 }; /* diff --git a/src/test_regexp.c b/src/test_regexp.c index 2cebbea44a..a1969ada40 100644 --- a/src/test_regexp.c +++ b/src/test_regexp.c @@ -107,7 +107,7 @@ struct ReCompiled { char *aOp; /* Operators for the virtual machine */ int *aArg; /* Arguments to each operator */ unsigned (*xNextChar)(ReInput*); /* Next character function */ - char zInit[12]; /* Initial text to match */ + unsigned char zInit[12]; /* Initial text to match */ int nInit; /* Number of characters in zInit */ unsigned nState; /* Number of entries in aOp[] and aArg[] */ unsigned nAlloc; /* Slots allocated for aOp[] and aArg[] */ @@ -194,7 +194,8 @@ int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){ if( pRe->nInit ){ unsigned char x = pRe->zInit[0]; while( in.i+pRe->nInit<=in.mx - && (zIn[in.i]!=x || strncmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0) + && (zIn[in.i]!=x || + strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0) ){ in.i++; } From 82e647d7c3ee32d9a5312b6a704810b2b4213c17 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Mar 2013 03:25:55 +0000 Subject: [PATCH 36/45] Update comments on the free-page allocator to accurately reflect the latest implementation. Add new asserts to the free-page allocator. FossilOrigin-Name: 9a135e37b696b8544da8dbddf9d1041b8fa6f1c2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 26 +++++++++++++++----------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 7bd0348f28..9a9419e608 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Complete\sthe\sinitialization\sof\sthe\sloadable\sextension\sthunk\stable.\s\sAlso\nfix\sother\s(harmless)\scompiler\swarnings. -D 2013-03-01T23:40:26.913 +C Update\scomments\son\sthe\sfree-page\sallocator\sto\saccurately\sreflect\sthe\nlatest\simplementation.\s\sAdd\snew\sasserts\sto\sthe\sfree-page\sallocator. +D 2013-03-02T03:25:55.218 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b2cac9f7993f3f9588827b824b1501d0c820fa68 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c cbad71970cfadfa342fc137ca5e319f98b2d0da1 +F src/btree.c ea4cc870674e608cd9349798d6f7811feeb85643 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 375e5df716e03b9343c5e1211be3b24e6d6dff05 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 6b2838336a31e34c540210ccc9c934d4ba94757c -R db69dd670ef335759c7475908d848a42 +P 780d06c5e54590f677f993fa9c313989c2eab8c7 +R f5753609ff29532bc332844f7d251f42 U drh -Z d35d3652e81b05a9c2009fdff0b4ddbd +Z ee29f611b55f3013b3ce8fc0c9bc38da diff --git a/manifest.uuid b/manifest.uuid index 235d98e3ca..7697cb81fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -780d06c5e54590f677f993fa9c313989c2eab8c7 \ No newline at end of file +9a135e37b696b8544da8dbddf9d1041b8fa6f1c2 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 84bafb9e73..24211a5289 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4875,21 +4875,23 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){ ** an error. *ppPage and *pPgno are undefined in the event of an error. ** Do not invoke sqlite3PagerUnref() on *ppPage if an error is returned. ** -** If the "nearby" parameter is not 0, then a (feeble) effort is made to +** If the "nearby" parameter is not 0, then an effort is made to ** locate a page close to the page number "nearby". This can be used in an ** attempt to keep related pages close to each other in the database file, ** which in turn can make database access faster. ** -** If the "exact" parameter is not 0, and the page-number nearby exists -** anywhere on the free-list, then it is guarenteed to be returned. This -** is only used by auto-vacuum databases when allocating a new table. +** If the eMode parameter is BTALLOC_EXACT and the nearby page exists +** anywhere on the free-list, then it is guaranteed to be returned. If +** eMode is BTALLOC_LT then the page returned will be less than or equal +** to nearby if any such page exists. If eMode is BTALLOC_ANY then there +** are no restrictions on which page is returned. */ static int allocateBtreePage( - BtShared *pBt, - MemPage **ppPage, - Pgno *pPgno, - Pgno nearby, - u8 eMode + BtShared *pBt, /* The btree */ + MemPage **ppPage, /* Store pointer to the allocated page here */ + Pgno *pPgno, /* Store the page number here */ + Pgno nearby, /* Search for a page near this one */ + u8 eMode /* BTALLOC_EXACT, BTALLOC_LT, or BTALLOC_ANY */ ){ MemPage *pPage1; int rc; @@ -4900,6 +4902,7 @@ static int allocateBtreePage( Pgno mxPage; /* Total size of the database file */ assert( sqlite3_mutex_held(pBt->mutex) ); + assert( eMode==BTALLOC_ANY || (nearby>0 && pBt->autoVacuum) ); pPage1 = pBt->pPage1; mxPage = btreePagecount(pBt); n = get4byte(&pPage1->aData[36]); @@ -4912,7 +4915,7 @@ static int allocateBtreePage( Pgno iTrunk; u8 searchList = 0; /* If the free-list must be searched for 'nearby' */ - /* If the 'exact' parameter was true and a query of the pointer-map + /* If eMode==BTALLOC_EXACT and a query of the pointer-map ** shows that the page 'nearby' is somewhere on the free-list, then ** the entire-list will be searched for that page. */ @@ -4942,7 +4945,8 @@ static int allocateBtreePage( /* The code within this loop is run only once if the 'searchList' variable ** is not true. Otherwise, it runs once for each trunk-page on the - ** free-list until the page 'nearby' is located. + ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT) + ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT) */ do { pPrevTrunk = pTrunk; From 7015698b81bae7a3bad30f5edeb27fea8491c0cf Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Mar 2013 20:26:46 +0000 Subject: [PATCH 37/45] Add the test_fs.c test module to Makefile.in. Adjust the success criteria on index5-1.3 so that it works under auto_vacuum configurations. FossilOrigin-Name: b457c8870ac5ef58f2b7f8daed723c0cf0c07340 --- Makefile.in | 1 + manifest | 14 +++++++------- manifest.uuid | 2 +- test/index5.test | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 98a3edb091..652928b8cc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -357,6 +357,7 @@ TESTSRC = \ $(TOP)/src/test_config.c \ $(TOP)/src/test_demovfs.c \ $(TOP)/src/test_devsym.c \ + $(TOP)/src/test_fs.c \ $(TOP)/src/test_func.c \ $(TOP)/src/test_fuzzer.c \ $(TOP)/src/test_hexio.c \ diff --git a/manifest b/manifest index 9a9419e608..f5814d9922 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Update\scomments\son\sthe\sfree-page\sallocator\sto\saccurately\sreflect\sthe\nlatest\simplementation.\s\sAdd\snew\sasserts\sto\sthe\sfree-page\sallocator. -D 2013-03-02T03:25:55.218 +C Add\sthe\stest_fs.c\stest\smodule\sto\sMakefile.in.\s\sAdjust\sthe\ssuccess\scriteria\non\sindex5-1.3\sso\sthat\sit\sworks\sunder\sauto_vacuum\sconfigurations. +D 2013-03-03T20:26:46.744 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 +F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc 1bed3bca025ee90441bb0c9f95f36f42b70bd839 F Makefile.vxworks b18ad88e9a8c6a001f5cf4a389116a4f1a7ab45f @@ -540,7 +540,7 @@ F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026 -F test/index5.test 5616266b2387003bf83c39df626c7292622d58de +F test/index5.test fc07c14193c0430814e7a08b5da46888ee795c33 F test/indexedby.test be501e381b82b2f8ab406309ba7aac46e221f4ad F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 780d06c5e54590f677f993fa9c313989c2eab8c7 -R f5753609ff29532bc332844f7d251f42 +P 9a135e37b696b8544da8dbddf9d1041b8fa6f1c2 +R 9293e988d26790e7e84c28eec0d1e5f0 U drh -Z ee29f611b55f3013b3ce8fc0c9bc38da +Z ffeccda697146da2c5f1e0fb0eff3d20 diff --git a/manifest.uuid b/manifest.uuid index 7697cb81fe..d898a6fb98 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a135e37b696b8544da8dbddf9d1041b8fa6f1c2 \ No newline at end of file +b457c8870ac5ef58f2b7f8daed723c0cf0c07340 \ No newline at end of file diff --git a/test/index5.test b/test/index5.test index 72f536fc8f..7895391309 100644 --- a/test/index5.test +++ b/test/index5.test @@ -67,7 +67,7 @@ do_test 1.3 { puts -nonewline \ " (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)" - expr {$nForward > 25*($nBackward + $nNoncont)} + expr {$nForward > 2*($nBackward + $nNoncont)} } {1} db close tvfs delete From e0ac363c62d2e40e80e6f255ab70a66894b4aec4 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 4 Mar 2013 16:35:06 +0000 Subject: [PATCH 38/45] Remove an assert() statement that has been incorrect since the recent incremental-vacuum related changes in [26e235b7a4]. FossilOrigin-Name: 090a47127fde90616a92a324d26bf9ddd4053120 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f5814d9922..ab32e2fb4f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\stest_fs.c\stest\smodule\sto\sMakefile.in.\s\sAdjust\sthe\ssuccess\scriteria\non\sindex5-1.3\sso\sthat\sit\sworks\sunder\sauto_vacuum\sconfigurations. -D 2013-03-03T20:26:46.744 +C Remove\san\sassert()\sstatement\sthat\shas\sbeen\sincorrect\ssince\sthe\srecent\sincremental-vacuum\srelated\schanges\sin\s[26e235b7a4]. +D 2013-03-04T16:35:06.413 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +162,7 @@ F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 8964f621aaab1f2c9804fbbff4450d9811ef5548 F src/os_win.c f7da4dc0a2545c0a430080380809946ae4d676d6 -F src/pager.c 9e51c2a37a2f2c3ed4689c25204e2977b5450ac0 +F src/pager.c bbe1eca2d1c81dcf163836ca317a6a6ea84441d8 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 9a135e37b696b8544da8dbddf9d1041b8fa6f1c2 -R 9293e988d26790e7e84c28eec0d1e5f0 -U drh -Z ffeccda697146da2c5f1e0fb0eff3d20 +P b457c8870ac5ef58f2b7f8daed723c0cf0c07340 +R 7554fffb7ea77fca9105b89fb46d1a5e +U dan +Z 6be45ce5fd9d36a4a4ba22a061a3da5d diff --git a/manifest.uuid b/manifest.uuid index d898a6fb98..56bfca0fc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b457c8870ac5ef58f2b7f8daed723c0cf0c07340 \ No newline at end of file +090a47127fde90616a92a324d26bf9ddd4053120 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 7acb7fd43c..d4984586de 100644 --- a/src/pager.c +++ b/src/pager.c @@ -3755,12 +3755,26 @@ static void assertTruncateConstraint(Pager *pPager){ ** function does not actually modify the database file on disk. It ** just sets the internal state of the pager object so that the ** truncation will be done when the current transaction is committed. +** +** This function is only called right before committing a transaction. +** Once this function has been called, the transaction must either be +** rolled back or committed. It is not safe to call this function and +** then continue writing to the database. */ void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){ assert( pPager->dbSize>=nPage ); assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); pPager->dbSize = nPage; - assertTruncateConstraint(pPager); + + /* At one point the code here called assertTruncateConstraint() to + ** ensure that all pages being truncated away by this operation are, + ** if one or more savepoints are open, present in the savepoint + ** journal so that they can be restored if the savepoint is rolled + ** back. This is no longer necessary as this function is now only + ** called right before committing a transaction. So although the + ** Pager object may still have open savepoints (Pager.nSavepoint!=0), + ** they cannot be rolled back. So the assertTruncateConstraint() call + ** is no longer correct. */ } From 84fb4c22b940e9e9667cd6d91fd2f3b4731bd269 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 4 Mar 2013 17:41:32 +0000 Subject: [PATCH 39/45] Omit a test that uses the progress handler callback from view.test if OMIT_PROGRESS_HANDLER is defined. FossilOrigin-Name: f40552ada57622825d2974d392356aa34612d5ee --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/view.test | 14 ++++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index ab32e2fb4f..e6cfc37d43 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sassert()\sstatement\sthat\shas\sbeen\sincorrect\ssince\sthe\srecent\sincremental-vacuum\srelated\schanges\sin\s[26e235b7a4]. -D 2013-03-04T16:35:06.413 +C Omit\sa\stest\sthat\suses\sthe\sprogress\shandler\scallback\sfrom\sview.test\sif\sOMIT_PROGRESS_HANDLER\sis\sdefined. +D 2013-03-04T17:41:32.501 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -928,7 +928,7 @@ F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 7701bb609fe8bf6535514e8b849a309e8f00573b -F test/view.test 977eb3fa17b44f73fc2b636172dc9136311024ce +F test/view.test 4057630287bfa5955628fe90a13d4c225d1c7352 F test/vtab1.test 4403f987860ebddef1ce2de6db7216421035339d F test/vtab2.test 7bcffc050da5c68f4f312e49e443063e2d391c0d F test/vtab3.test baad99fd27217f5d6db10660522e0b7192446de1 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P b457c8870ac5ef58f2b7f8daed723c0cf0c07340 -R 7554fffb7ea77fca9105b89fb46d1a5e +P 090a47127fde90616a92a324d26bf9ddd4053120 +R 6934d41f0981fdd51befb5693c74c199 U dan -Z 6be45ce5fd9d36a4a4ba22a061a3da5d +Z 2cadb001785412dcf064c155dea5de1b diff --git a/manifest.uuid b/manifest.uuid index 56bfca0fc6..84a283820f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -090a47127fde90616a92a324d26bf9ddd4053120 \ No newline at end of file +f40552ada57622825d2974d392356aa34612d5ee \ No newline at end of file diff --git a/test/view.test b/test/view.test index 4abd3cf70b..779f77b6ae 100644 --- a/test/view.test +++ b/test/view.test @@ -602,11 +602,13 @@ do_test view-21.1 { CREATE VIEW vx AS SELECT * FROM v32768 UNION SELECT * FROM v32768; } } {1 {too many references to "v1": max 65535}} -do_test view-21.2 { - db progress 1000 {expr 1} - catchsql { - SELECT * FROM v32768; - } -} {1 interrupted} +ifcapable progress { + do_test view-21.2 { + db progress 1000 {expr 1} + catchsql { + SELECT * FROM v32768; + } + } {1 interrupted} +} finish_test From edf9a17b477e9e53cb330b4bfcccf2ec897bd311 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Mar 2013 01:46:26 +0000 Subject: [PATCH 40/45] Simplified error message on the showdb utility. FossilOrigin-Name: 8e0ced1af78d8c25a06423a8e7e337ac845155cc --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/showdb.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e6cfc37d43..29d706ef83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sa\stest\sthat\suses\sthe\sprogress\shandler\scallback\sfrom\sview.test\sif\sOMIT_PROGRESS_HANDLER\sis\sdefined. -D 2013-03-04T17:41:32.501 +C Simplified\serror\smessage\son\sthe\sshowdb\sutility. +D 2013-03-05T01:46:26.107 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1016,7 +1016,7 @@ F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 16960a5ce59d8b1d70dc3bdc51e2c0fe7bb91359 +F tool/showdb.c acd24ea035a3bd2ffe266f1ef8a161812c29b2f0 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 090a47127fde90616a92a324d26bf9ddd4053120 -R 6934d41f0981fdd51befb5693c74c199 -U dan -Z 2cadb001785412dcf064c155dea5de1b +P f40552ada57622825d2974d392356aa34612d5ee +R e74a37a3f1e9384492860c906eed95aa +U drh +Z b5a881064edd7a6340015d7ebf25b267 diff --git a/manifest.uuid b/manifest.uuid index 84a283820f..99c68ef8c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f40552ada57622825d2974d392356aa34612d5ee \ No newline at end of file +8e0ced1af78d8c25a06423a8e7e337ac845155cc \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index 4a31d9cd3e..dbd79e9586 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -471,7 +471,7 @@ static void page_usage_msg(int pgno, const char *zFormat, ...){ zMsg = sqlite3_vmprintf(zFormat, ap); va_end(ap); if( pgno<=0 || pgno>mxPage ){ - printf("ERROR: page %d out of bounds. Range=1..%d. Msg: %s\n", + printf("ERROR: page %d out of range 1..%d: %s\n", pgno, mxPage, zMsg); sqlite3_free(zMsg); return; From e1df4e31ec386c7c00dc913926e01b312a592203 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 Mar 2013 11:27:04 +0000 Subject: [PATCH 41/45] Fix a bug in the recent incremental-vacuum related changes. FossilOrigin-Name: 717863fca6d58828bf9321bc8b169e385ad4263f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 29d706ef83..871ea51352 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplified\serror\smessage\son\sthe\sshowdb\sutility. -D 2013-03-05T01:46:26.107 +C Fix\sa\sbug\sin\sthe\srecent\sincremental-vacuum\srelated\schanges. +D 2013-03-05T11:27:04.053 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b2cac9f7993f3f9588827b824b1501d0c820fa68 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c ea4cc870674e608cd9349798d6f7811feeb85643 +F src/btree.c c7ce6045f023ba6426d5cca63fab5e1e3d282309 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 F src/build.c 375e5df716e03b9343c5e1211be3b24e6d6dff05 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P f40552ada57622825d2974d392356aa34612d5ee -R e74a37a3f1e9384492860c906eed95aa -U drh -Z b5a881064edd7a6340015d7ebf25b267 +P 8e0ced1af78d8c25a06423a8e7e337ac845155cc +R d0fc02cfce5e41e4c1a5be120b4b33d4 +U dan +Z c4b64c03342d1e7d5813b1d9185813bd diff --git a/manifest.uuid b/manifest.uuid index 99c68ef8c9..95a5e3503e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e0ced1af78d8c25a06423a8e7e337ac845155cc \ No newline at end of file +717863fca6d58828bf9321bc8b169e385ad4263f \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 24211a5289..16b56f5bf0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3004,7 +3004,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){ }while( bCommit && iFreePg>nFin ); assert( iFreePg Date: Tue, 5 Mar 2013 15:09:25 +0000 Subject: [PATCH 42/45] Add extended error code SQLITE_READONLY_ROLLBACK. Returned if a read-only connection cannot read the database because doing so would require it to roll back a hot-journal. FossilOrigin-Name: 39247b14a52b0c0222fe5a848bf0aef0854058c4 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/pager.c | 5 +++++ src/sqlite.h.in | 1 + src/test1.c | 1 + test/misc7.test | 28 ++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 871ea51352..5d23e6a058 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sthe\srecent\sincremental-vacuum\srelated\schanges. -D 2013-03-05T11:27:04.053 +C Add\sextended\serror\scode\sSQLITE_READONLY_ROLLBACK.\sReturned\sif\sa\sread-only\sconnection\scannot\sread\sthe\sdatabase\sbecause\sdoing\sso\swould\srequire\sit\sto\sroll\sback\sa\shot-journal. +D 2013-03-05T15:09:25.827 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +162,7 @@ F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 8964f621aaab1f2c9804fbbff4450d9811ef5548 F src/os_win.c f7da4dc0a2545c0a430080380809946ae4d676d6 -F src/pager.c bbe1eca2d1c81dcf163836ca317a6a6ea84441d8 +F src/pager.c 582f8da52d0bd4b43d3bdaeba0ea7702c1f23702 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -176,7 +176,7 @@ F src/resolve.c 9079da7d59aed2bb14ec8315bc7f720dd85b5b65 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c e1c6f6abdf9f359f4e735cb8ae11d2f359bf52a9 F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca -F src/sqlite.h.in 6296506a8fba279d8fa31f4abf01ab0cc92738a6 +F src/sqlite.h.in 31045976254225e6bf046a96e87b40fa4c1d55e4 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75 F src/sqliteInt.h 601c887f6d9c92e75551873c0a34711fff745bed @@ -184,7 +184,7 @@ F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 3213f3101e3b85f047d6e389da5a53d76d3d7540 -F src/test1.c 50003e3beccad5569f757598fc7ce81b4f21aa7e +F src/test1.c ff3e68eedfbd858c9b89cf03e3db233cd29be1d0 F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa @@ -628,7 +628,7 @@ F test/misc3.test fe55130a43e444ee75e2156ff75dc96e964b5738 F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test f00dad9a004da659330013e6f21819d018b683d3 +F test/misc7.test dd82ec9250b89178b96cd28b2aca70639d21e5b3 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a @@ -1036,7 +1036,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 8e0ced1af78d8c25a06423a8e7e337ac845155cc -R d0fc02cfce5e41e4c1a5be120b4b33d4 +P 717863fca6d58828bf9321bc8b169e385ad4263f +R b78ae2bf1dec51f1a9a8371984f07596 +T *branch * experimental +T *sym-experimental * +T -sym-trunk * U dan -Z c4b64c03342d1e7d5813b1d9185813bd +Z 99ffc2717f24e39ecc7d3dce830bdc34 diff --git a/manifest.uuid b/manifest.uuid index 95a5e3503e..9944c340cc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -717863fca6d58828bf9321bc8b169e385ad4263f \ No newline at end of file +39247b14a52b0c0222fe5a848bf0aef0854058c4 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d4984586de..1d84fa2b7e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4827,6 +4827,11 @@ int sqlite3PagerSharedLock(Pager *pPager){ goto failed; } if( bHotJournal ){ + if( pPager->readOnly ){ + rc = SQLITE_READONLY_ROLLBACK; + goto failed; + } + /* Get an EXCLUSIVE lock on the database file. At this point it is ** important that a RESERVED lock is not obtained on the way to the ** EXCLUSIVE lock. If it were, another process might open the diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 77bb02a341..a32af16be6 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -478,6 +478,7 @@ int sqlite3_exec( #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) +#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) diff --git a/src/test1.c b/src/test1.c index 247fc872fa..0bace84420 100644 --- a/src/test1.c +++ b/src/test1.c @@ -178,6 +178,7 @@ const char *sqlite3TestErrorName(int rc){ case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break; case SQLITE_READONLY_RECOVERY: zName = "SQLITE_READONLY_RECOVERY"; break; case SQLITE_READONLY_CANTLOCK: zName = "SQLITE_READONLY_CANTLOCK"; break; + case SQLITE_READONLY_ROLLBACK: zName = "SQLITE_READONLY_ROLLBACK"; break; default: zName = "SQLITE_Unknown"; break; } return zName; diff --git a/test/misc7.test b/test/misc7.test index 4868c12ac0..72c1cd64ff 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -488,6 +488,34 @@ do_test misc7-21.1 { list $rc $msg } {1 {unable to open database file}} +# Try to do hot-journal rollback with a read-only connection. The +# error code should be SQLITE_READONLY_ROLLBACK. +# +do_test misc7-22.1 { + db close + forcedelete test.db copy.db-journal + sqlite3 db test.db + execsql { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); + } + db close + sqlite3 db test.db -readonly 1 + catchsql { + INSERT INTO t1 VALUES(5, 6); + } +} {1 {attempt to write a readonly database}} +do_test misc7-22.2 { execsql { SELECT * FROM t1 } } {1 2 3 4} +do_test misc7-22.3 { + set fd [open test.db-journal w] + puts $fd [string repeat abc 1000] + close $fd + catchsql { SELECT * FROM t1 } +} {1 {attempt to write a readonly database}} +do_test misc7-22.4 { + sqlite3_extended_errcode db +} SQLITE_READONLY_ROLLBACK db close forcedelete test.db From b83c21e600e57322278bb42cb1ac76dfd62cc7a1 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 Mar 2013 15:27:34 +0000 Subject: [PATCH 43/45] Do not attempt to set the permissions on an existing journal or wal file. Do this only immediately after creating a new file (or opening one zero bytes in size). FossilOrigin-Name: 1d8086902ee96347491bce5ec04dc92ccd42efa1 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/os_unix.c | 5 ++++- test/pager1.test | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 5d23e6a058..d0c6ed2126 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextended\serror\scode\sSQLITE_READONLY_ROLLBACK.\sReturned\sif\sa\sread-only\sconnection\scannot\sread\sthe\sdatabase\sbecause\sdoing\sso\swould\srequire\sit\sto\sroll\sback\sa\shot-journal. -D 2013-03-05T15:09:25.827 +C Do\snot\sattempt\sto\sset\sthe\spermissions\son\san\sexisting\sjournal\sor\swal\sfile.\sDo\sthis\sonly\simmediately\safter\screating\sa\snew\sfile\s(or\sopening\sone\szero\sbytes\sin\ssize). +D 2013-03-05T15:27:34.350 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c 8964f621aaab1f2c9804fbbff4450d9811ef5548 +F src/os_unix.c d8ab3f4bae870ebd8032a08be10501213487c6e1 F src/os_win.c f7da4dc0a2545c0a430080380809946ae4d676d6 F src/pager.c 582f8da52d0bd4b43d3bdaeba0ea7702c1f23702 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 @@ -646,7 +646,7 @@ F test/orderby1.test f33968647da5c546528fe4d2bf86c6a6a2e5a7ae F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04 F test/orderby3.test 8619d06a3debdcd80a27c0fdea5c40b468854b99 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test 8e14e7cfd2fbfe65eabead73af10ceeb2fc676aa +F test/pager1.test 31c04bec797dda1bde337810b52efa08d1f1f08e F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -1036,10 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 717863fca6d58828bf9321bc8b169e385ad4263f -R b78ae2bf1dec51f1a9a8371984f07596 -T *branch * experimental -T *sym-experimental * -T -sym-trunk * +P 39247b14a52b0c0222fe5a848bf0aef0854058c4 +R cdff7116ca1269af949fd381129331e4 U dan -Z 99ffc2717f24e39ecc7d3dce830bdc34 +Z 72d9794671122cfd955b2358dcd76229 diff --git a/manifest.uuid b/manifest.uuid index 9944c340cc..d22a7b5ed1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39247b14a52b0c0222fe5a848bf0aef0854058c4 \ No newline at end of file +1d8086902ee96347491bce5ec04dc92ccd42efa1 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index fca2f703df..ee13ae8ad7 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -552,7 +552,10 @@ static int robust_open(const char *z, int f, mode_t m){ if( fd>=0 ){ if( m!=0 ){ struct stat statbuf; - if( osFstat(fd, &statbuf)==0 && (statbuf.st_mode&0777)!=m ){ + if( osFstat(fd, &statbuf)==0 + && statbuf.st_size==0 + && statbuf.st_mode&0777!=m + ){ osFchmod(fd, m); } } diff --git a/test/pager1.test b/test/pager1.test index 6eafa11244..ae47b3d932 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -752,7 +752,7 @@ sqlite3 db test.db -readonly 1 do_catchsql_test pager1.4.5.6 { SELECT * FROM t1; SELECT * FROM t2; -} {1 {disk I/O error}} +} {1 {attempt to write a readonly database}} db close # Snapshot the file-system just before multi-file commit. Save the name From cfc176973ec6a138068a2f9c30e5662dd5d5ced0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Mar 2013 01:41:53 +0000 Subject: [PATCH 44/45] Fix an operator precedence problem on the [1d8086902e] check-in. FossilOrigin-Name: 4f5f3aebe81c3cbe539db3e33ec38fa3de47e90b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4b5b831042..c496616be0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sexperimental\sbranch\swith\strunk. -D 2013-03-05T16:54:45.725 +C Fix\san\soperator\sprecedence\sproblem\son\sthe\s[1d8086902e]\scheck-in. +D 2013-03-06T01:41:53.549 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c d8ab3f4bae870ebd8032a08be10501213487c6e1 +F src/os_unix.c f6387eef0cf8f6b808738f4f3aa47e6132af0940 F src/os_win.c f7da4dc0a2545c0a430080380809946ae4d676d6 F src/pager.c 582f8da52d0bd4b43d3bdaeba0ea7702c1f23702 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 @@ -1036,7 +1036,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 717863fca6d58828bf9321bc8b169e385ad4263f 1d8086902ee96347491bce5ec04dc92ccd42efa1 -R cdff7116ca1269af949fd381129331e4 -U dan -Z 096a27b1e7348ccd7fb11b376ce2d88a +P 4e6e07a60e543d5d1727cde27ab11e156202a1b8 +R 4624808bc8666139dd43b7c21e0d98ea +U drh +Z 778831793a4a16e588dea29c8ecebc95 diff --git a/manifest.uuid b/manifest.uuid index 7f87da50b6..1f727ac74b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e6e07a60e543d5d1727cde27ab11e156202a1b8 \ No newline at end of file +4f5f3aebe81c3cbe539db3e33ec38fa3de47e90b \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index ee13ae8ad7..8f094bdc19 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -554,7 +554,7 @@ static int robust_open(const char *z, int f, mode_t m){ struct stat statbuf; if( osFstat(fd, &statbuf)==0 && statbuf.st_size==0 - && statbuf.st_mode&0777!=m + && (statbuf.st_mode&0777)!=m ){ osFchmod(fd, m); } From 459f63e7edb1d04af7f70bb9c898929e0a188101 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Mar 2013 01:55:27 +0000 Subject: [PATCH 45/45] Fix a bug (ticket [fc7bd6358f59]) that caused incorrect query results in three way queries that involved comparing INTEGER and TEXT columns for equality. FossilOrigin-Name: 7097241c1220ada318f8eda938c3e3430b94a606 --- manifest | 13 +++---- manifest.uuid | 2 +- src/where.c | 14 +++++--- test/tkt-fc7bd6358f.test | 78 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 12 deletions(-) create mode 100644 test/tkt-fc7bd6358f.test diff --git a/manifest b/manifest index 4aae4dfca5..aacba4cf11 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_READONLY_ROLLBACK\sextended\serror\scode.\nDo\snot\stry\sto\sset\sthe\spermissions\son\sjournal\sor\swal\sfiles\sexcept\sif\sthe\nfilesize\sis\sinitially\szero\s(indicating\sthat\sit\sis\sa\snew\sfile.) -D 2013-03-06T01:48:20.423 +C Fix\sa\sbug\s(ticket\s[fc7bd6358f59])\sthat\scaused\sincorrect\squery\sresults\sin\nthree\sway\squeries\sthat\sinvolved\scomparing\sINTEGER\sand\sTEXT\scolumns\sfor\nequality. +D 2013-03-06T01:55:27.319 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -252,7 +252,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b -F src/where.c 43e05406f0e05960a62d4719ed77f551f8204d3f +F src/where.c 8b7690cae8700b385d8a53a39387cf8054d8cc47 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -809,6 +809,7 @@ F test/tkt-f7b4edec.test d998a08ff2b18b7f62edce8e3044317c45efe6c7 F test/tkt-f973c7ac31.test 1da0ed15ec2c7749fb5ce2828cd69d07153ad9f4 F test/tkt-fa7bf5ec.test 9102dfea58aa371d78969da735f9392c57e2e035 F test/tkt-fc62af4523.test 72825d3febdedcd5593a27989fc05accdbfc2bb4 +F test/tkt-fc7bd6358f.test 634bb4af7d661e82d6b61b80c86727bad698e08f F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00 F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368 F test/tkt1444.test a9d72f9e942708bd82dde6c707da61c489e213e9 @@ -1036,7 +1037,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 717863fca6d58828bf9321bc8b169e385ad4263f 4f5f3aebe81c3cbe539db3e33ec38fa3de47e90b -R 4624808bc8666139dd43b7c21e0d98ea +P ce4ac66a4b623a3cee1a63089dd5ba8341244f1e +R d68087991aff1a0f42c82b57cc68e943 U drh -Z 5a1f66c8d1d16d93a8aa4820fbcfcadc +Z 8c08911ad7848ca72da641a08c68b6f0 diff --git a/manifest.uuid b/manifest.uuid index 1a841a4e80..e12fd1d206 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ce4ac66a4b623a3cee1a63089dd5ba8341244f1e \ No newline at end of file +7097241c1220ada318f8eda938c3e3430b94a606 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 3db76b5339..aa81dabd47 100644 --- a/src/where.c +++ b/src/where.c @@ -643,9 +643,8 @@ static u16 operatorMask(int op){ ** then try for the one with no dependencies on - in other words where ** is a constant expression of some kind. Only return entries of ** the form "X Y" where Y is a column in another table if no terms of -** the form "X " exist. Other than this priority, if there -** are two or more terms that match, then the choice of which term to return -** is arbitrary. +** the form "X " exist. If no terms with a constant RHS +** exist, try to return a term that does not use WO_EQUIV. */ static WhereTerm *findTerm( WhereClause *pWC, /* The WHERE clause to be searched */ @@ -704,8 +703,12 @@ static WhereTerm *findTerm( continue; } } - pResult = pTerm; - if( pTerm->prereqRight==0 ) goto findTerm_success; + if( pTerm->prereqRight==0 ){ + pResult = pTerm; + goto findTerm_success; + }else if( pResult==0 ){ + pResult = pTerm; + } } if( (pTerm->eOperator & WO_EQUIV)!=0 && nEquivaddrNxt; sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); + sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); VdbeComment((v, "pk")); pLevel->op = OP_Noop; diff --git a/test/tkt-fc7bd6358f.test b/test/tkt-fc7bd6358f.test new file mode 100644 index 0000000000..a1b13c463c --- /dev/null +++ b/test/tkt-fc7bd6358f.test @@ -0,0 +1,78 @@ +# 2013 March 05 +# +# 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. Specifically, +# it tests that ticket [fc7bd6358f]: +# +# The following SQL yields an incorrect result (zero rows) in all +# versions of SQLite between 3.6.14 and 3.7.15.2: +# +# CREATE TABLE t(textid TEXT); +# INSERT INTO t VALUES('12'); +# INSERT INTO t VALUES('34'); +# CREATE TABLE i(intid INTEGER PRIMARY KEY); +# INSERT INTO i VALUES(12); +# INSERT INTO i VALUES(34); +# +# SELECT t1.textid AS a, i.intid AS b, t2.textid AS c +# FROM t t1, i, t t2 +# WHERE t1.textid = i.intid +# AND t1.textid = t2.textid; +# +# The correct result should be two rows, one with 12|12|12 and the other +# with 34|34|34. With this bug, no rows are returned. Bisecting shows that +# this bug was introduced with check-in [dd4d67a67454] on 2009-04-23. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_test tkt-fc7bd6358f.100 { + db eval { + CREATE TABLE t(textid TEXT); + INSERT INTO t VALUES('12'); + INSERT INTO t VALUES('34'); + CREATE TABLE i(intid INTEGER PRIMARY KEY); + INSERT INTO i VALUES(12); + INSERT INTO i VALUES(34); + } +} {} +unset -nocomplain from +unset -nocomplain where +unset -nocomplain a +unset -nocomplain b +foreach {a from} { + 1 {FROM t t1, i, t t2} + 2 {FROM i, t t1, t t2} + 3 {FROM t t1, t t2, i} +} { + foreach {b where} { + 1 {WHERE t1.textid=i.intid AND t1.textid=t2.textid} + 2 {WHERE i.intid=t1.textid AND t1.textid=t2.textid} + 3 {WHERE t1.textid=i.intid AND i.intid=t2.textid} + 4 {WHERE t1.textid=i.intid AND t2.textid=i.intid} + 5 {WHERE i.intid=t1.textid AND i.intid=t2.textid} + 6 {WHERE i.intid=t1.textid AND t2.textid=i.intid} + 7 {WHERE t1.textid=t2.textid AND i.intid=t2.textid} + 8 {WHERE t1.textid=t2.textid AND t2.textid=i.intid} + } { + do_test tkt-fc7bd6358f.110.$a.$b.1 { + db eval {PRAGMA automatic_index=ON} + db eval "SELECT t1.textid, i.intid, t2.textid $from $where" + } {12 12 12 34 34 34} + do_test tkt-fc7bd6358f.110.$a.$b.2 { + db eval {PRAGMA automatic_index=OFF} + db eval "SELECT t1.textid, i.intid, t2.textid $from $where" + } {12 12 12 34 34 34} + } +} + + +finish_test