From c216eee7ce2211ffd363b3885b34f161f3bc237f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 Dec 2010 16:39:25 +0000 Subject: [PATCH 01/82] Fix a bug in the demo "superlock" code preventing locks from being released in some circumstances. FossilOrigin-Name: 65c393793ff5fdb935d5acfe5bdc3bca052f7314 --- manifest | 26 ++++++----------- manifest.uuid | 2 +- src/test_superlock.c | 68 +++++++++++++++++++++++++++++--------------- test/superlock.test | 9 ++++++ 4 files changed, 63 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index 14f5ca8663..10f8555a8c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Version\s3.7.4\srelease\scandidate\s3 -D 2010-12-07T14:59:22 +C Fix\sa\sbug\sin\sthe\sdemo\s"superlock"\scode\spreventing\slocks\sfrom\sbeing\sreleased\sin\ssome\scircumstances. +D 2010-12-07T16:39:26 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -220,7 +217,7 @@ F src/test_rtree.c 30c981837445a4e187ee850a49c4760d9642f7c3 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c -F src/test_superlock.c c0c0b1f73254a0c4ad5aca69e627fe32f571f7f9 +F src/test_superlock.c aa91c01e42c8e1eef663b74bd1b9a762306f06b5 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 F src/test_vfs.c e10fcca756cafa89438311b31522ac1f95bf784b @@ -657,7 +654,7 @@ F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 F test/subquery.test b524f57c9574b2c0347045b4510ef795d4686796 F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a -F test/superlock.test 070e7fd9ccf91755b6f8e03ede27995a73220672 +F test/superlock.test 8468e057d8a5531ff99e504e77fcc585a0291bf2 F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3 F test/table.test 04ba066432430657712d167ebf28080fe878d305 F test/tableapi.test 7262a8cbaa9965d429f1cbd2747edc185fa56516 @@ -897,14 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b0634d2f909fb192d20315e59fa31fcd8f316541 -R c899dedfcbfad993e519fd17027aa5c1 -U drh -Z e558719848264f114302cf252022d7ad ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFM/kvQoxKgR168RlERAihjAJ483qru/mKHGZtSh1P4zl69jepBKwCfe11S -MaOtcUGzrbyHLk/lC2rzkPk= -=bBvs ------END PGP SIGNATURE----- +P 11c74c0dae0e302f248ec4af6dc8a9376203b034 +R b4c637d07289308a3222d68447f4c6c3 +U dan +Z 63bd98324f51b062689452a6abdd2cdc diff --git a/manifest.uuid b/manifest.uuid index 281813f1d5..63640be6f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11c74c0dae0e302f248ec4af6dc8a9376203b034 \ No newline at end of file +65c393793ff5fdb935d5acfe5bdc3bca052f7314 \ No newline at end of file diff --git a/src/test_superlock.c b/src/test_superlock.c index 8a49188658..464da55076 100644 --- a/src/test_superlock.c +++ b/src/test_superlock.c @@ -33,6 +33,17 @@ struct SuperlockBusy { }; typedef struct SuperlockBusy SuperlockBusy; +/* +** An instance of the following structure is allocated for each active +** superlock. The opaque handle returned by sqlite3demo_superlock() is +** actually a pointer to an instance of this structure. +*/ +struct Superlock { + sqlite3 *db; /* Database handle used to lock db */ + int bWal; /* True if db is a WAL database */ +}; +typedef struct Superlock Superlock; + /* ** The pCtx pointer passed to this function is actually a pointer to a ** SuperlockBusy structure. Invoke the busy-handler function encapsulated @@ -53,18 +64,18 @@ static int superlockBusyHandler(void *pCtx, int UNUSED){ ** If an error occurs, return an SQLite error code. The value of *pbWal ** is undefined in this case. */ -static int superlockIsWal(sqlite3 *db, int *pbWal){ +static int superlockIsWal(Superlock *pLock){ int rc; /* Return Code */ sqlite3_stmt *pStmt; /* Compiled PRAGMA journal_mode statement */ - rc = sqlite3_prepare(db, "PRAGMA main.journal_mode", -1, &pStmt, 0); + rc = sqlite3_prepare(pLock->db, "PRAGMA main.journal_mode", -1, &pStmt, 0); if( rc!=SQLITE_OK ) return rc; - *pbWal = 0; + pLock->bWal = 0; if( SQLITE_ROW==sqlite3_step(pStmt) ){ const char *zMode = (const char *)sqlite3_column_text(pStmt, 0); if( zMode && strlen(zMode)==3 && sqlite3_strnicmp("wal", zMode, 3)==0 ){ - *pbWal = 1; + pLock->bWal = 1; } } @@ -132,6 +143,23 @@ static int superlockWalLock( return rc; } +/* +** Release a superlock held on a database file. The argument passed to +** this function must have been obtained from a successful call to +** sqlite3demo_superlock(). +*/ +void sqlite3demo_superunlock(void *pLock){ + Superlock *p = (Superlock *)pLock; + if( p->bWal ){ + int flags = SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE; + sqlite3_file *fd = 0; + sqlite3_file_control(p->db, "main", SQLITE_FCNTL_FILE_POINTER, (void *)&fd); + fd->pMethods->xShmLock(fd, 2, SQLITE_SHM_NLOCK-2, flags); + } + sqlite3_close(p->db); + sqlite3_free(p); +} + /* ** Obtain a superlock on the database file identified by zPath, using the ** locking primitives provided by VFS zVfs. If successful, SQLITE_OK is @@ -154,13 +182,17 @@ int sqlite3demo_superlock( void *pBusyArg, /* Context arg for busy handler */ void **ppLock /* OUT: Context to pass to superunlock() */ ){ - sqlite3 *db = 0; /* Database handle open on zPath */ SuperlockBusy busy = {0, 0, 0}; /* Busy handler wrapper object */ int rc; /* Return code */ + Superlock *pLock; + + pLock = sqlite3_malloc(sizeof(Superlock)); + if( !pLock ) return SQLITE_NOMEM; + memset(pLock, 0, sizeof(Superlock)); /* Open a database handle on the file to superlock. */ rc = sqlite3_open_v2( - zPath, &db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs + zPath, &pLock->db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs ); /* Install a busy-handler and execute a BEGIN EXCLUSIVE. If this is not @@ -179,8 +211,8 @@ int sqlite3demo_superlock( if( rc==SQLITE_OK ){ busy.xBusy = xBusy; busy.pBusyArg = pBusyArg; - sqlite3_busy_handler(db, superlockBusyHandler, (void *)&busy); - rc = sqlite3_exec(db, "BEGIN EXCLUSIVE", 0, 0, 0); + sqlite3_busy_handler(pLock->db, superlockBusyHandler, (void *)&busy); + rc = sqlite3_exec(pLock->db, "BEGIN EXCLUSIVE", 0, 0, 0); } /* If the BEGIN EXCLUSIVE was executed successfully and this is a WAL @@ -193,34 +225,24 @@ int sqlite3demo_superlock( ** new WAL locks may conflict with the old. */ if( rc==SQLITE_OK ){ - int bWal; /* True for a WAL database, false otherwise */ - if( SQLITE_OK==(rc = superlockIsWal(db, &bWal)) && bWal ){ - rc = sqlite3_exec(db, "COMMIT", 0, 0, 0); + if( SQLITE_OK==(rc = superlockIsWal(pLock)) && pLock->bWal ){ + rc = sqlite3_exec(pLock->db, "COMMIT", 0, 0, 0); if( rc==SQLITE_OK ){ - rc = superlockWalLock(db, &busy); + rc = superlockWalLock(pLock->db, &busy); } } } if( rc!=SQLITE_OK ){ - sqlite3_close(db); + sqlite3demo_superunlock(pLock); *ppLock = 0; }else{ - *ppLock = (void *)db; + *ppLock = pLock; } return rc; } -/* -** Release a superlock held on a database file. The argument passed to -** this function must have been obtained from a successful call to -** sqlite3demo_superlock(). -*/ -void sqlite3demo_superunlock(void *pLock){ - sqlite3_close((sqlite3 *)pLock); -} - /* ** End of example code. Everything below here is the test harness. ************************************************************************** diff --git a/test/superlock.test b/test/superlock.test index c022d35c78..41a55144a6 100644 --- a/test/superlock.test +++ b/test/superlock.test @@ -143,6 +143,15 @@ do_multiclient_test tn { list [catch {sqlite3demo_superlock unlock test.db} msg] $msg } {0 unlock} unlock + + + do_test 5.$tn.13 { sql1 { SELECT * FROM t1 } } {1 2 3 4 5 6} + do_test 5.$tn.14 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6} + do_test 5.$tn.15 { sqlite3demo_superlock unlock test.db } {unlock} + do_test 5.$tn.16 { unlock } {} + do_test 5.$tn.17 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6} + do_test 5.$tn.18 { sql1 { SELECT * FROM t1 } } {1 2 3 4 5 6} + do_test 5.$tn.19 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6} } proc read_content {file} { From 2c2e8eb1a8632c692ab538e5246528513c5ce416 Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 7 Dec 2010 17:12:21 +0000 Subject: [PATCH 02/82] Work around restriction in Windows file locking. FossilOrigin-Name: fe441df9ba447d97571e919099846efa3ec87427 --- configure | 0 install-sh | 0 manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test_superlock.c | 8 ++++++-- 5 files changed, 16 insertions(+), 12 deletions(-) mode change 100755 => 100644 configure mode change 100755 => 100644 install-sh diff --git a/configure b/configure old mode 100755 new mode 100644 diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 10f8555a8c..3a63518a4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sthe\sdemo\s"superlock"\scode\spreventing\slocks\sfrom\sbeing\sreleased\sin\ssome\scircumstances. -D 2010-12-07T16:39:26 +C Work\saround\srestriction\sin\sWindows\sfile\slocking. +D 2010-12-07T17:12:21 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -22,7 +22,7 @@ F art/src_logo.gif 9341ef09f0e53cd44c0c9b6fc3c16f7f3d6c2ad9 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 868fdb48c028421a203470e15c69ada15b9ba673 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure daed6cfdb4c1449a4335b3eeddc0d836e33fb54e x +F configure daed6cfdb4c1449a4335b3eeddc0d836e33fb54e F configure.ac 699040cc9abb7465dca5a2972bc89d227fd8f734 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 @@ -97,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -217,7 +217,7 @@ F src/test_rtree.c 30c981837445a4e187ee850a49c4760d9642f7c3 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c -F src/test_superlock.c aa91c01e42c8e1eef663b74bd1b9a762306f06b5 +F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 F src/test_vfs.c e10fcca756cafa89438311b31522ac1f95bf784b @@ -894,7 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 11c74c0dae0e302f248ec4af6dc8a9376203b034 -R b4c637d07289308a3222d68447f4c6c3 -U dan -Z 63bd98324f51b062689452a6abdd2cdc +P 65c393793ff5fdb935d5acfe5bdc3bca052f7314 +R 6bbeb99b0a61f7ea1af21c5b74072ff6 +U shaneh +Z 46b092e6924aa6236cd81b6ddc388e65 diff --git a/manifest.uuid b/manifest.uuid index 63640be6f9..edaec7f5ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65c393793ff5fdb935d5acfe5bdc3bca052f7314 \ No newline at end of file +fe441df9ba447d97571e919099846efa3ec87427 \ No newline at end of file diff --git a/src/test_superlock.c b/src/test_superlock.c index 464da55076..936fcad0c5 100644 --- a/src/test_superlock.c +++ b/src/test_superlock.c @@ -151,10 +151,14 @@ static int superlockWalLock( void sqlite3demo_superunlock(void *pLock){ Superlock *p = (Superlock *)pLock; if( p->bWal ){ + int rc; /* Return code */ int flags = SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE; sqlite3_file *fd = 0; - sqlite3_file_control(p->db, "main", SQLITE_FCNTL_FILE_POINTER, (void *)&fd); - fd->pMethods->xShmLock(fd, 2, SQLITE_SHM_NLOCK-2, flags); + rc = sqlite3_file_control(p->db, "main", SQLITE_FCNTL_FILE_POINTER, (void *)&fd); + if( rc==SQLITE_OK ){ + fd->pMethods->xShmLock(fd, 2, 1, flags); + fd->pMethods->xShmLock(fd, 3, SQLITE_SHM_NLOCK-3, flags); + } } sqlite3_close(p->db); sqlite3_free(p); From 5480617fb14c2f5151c716b3a89feec1d38c1b85 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 7 Dec 2010 20:14:08 +0000 Subject: [PATCH 03/82] Version 3.7.4 release candidate 4 FossilOrigin-Name: a586a4deeb25330037a49df295b36aaf624d0f45 --- configure | 0 install-sh | 0 manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) mode change 100644 => 100755 configure mode change 100644 => 100755 install-sh diff --git a/configure b/configure old mode 100644 new mode 100755 diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 3a63518a4c..6f9e049703 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Work\saround\srestriction\sin\sWindows\sfile\slocking. -D 2010-12-07T17:12:21 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Version\s3.7.4\srelease\scandidate\s4 +D 2010-12-07T20:14:09 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -22,7 +25,7 @@ F art/src_logo.gif 9341ef09f0e53cd44c0c9b6fc3c16f7f3d6c2ad9 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 868fdb48c028421a203470e15c69ada15b9ba673 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure daed6cfdb4c1449a4335b3eeddc0d836e33fb54e +F configure daed6cfdb4c1449a4335b3eeddc0d836e33fb54e x F configure.ac 699040cc9abb7465dca5a2972bc89d227fd8f734 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 @@ -97,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -894,7 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 65c393793ff5fdb935d5acfe5bdc3bca052f7314 +P fe441df9ba447d97571e919099846efa3ec87427 R 6bbeb99b0a61f7ea1af21c5b74072ff6 -U shaneh -Z 46b092e6924aa6236cd81b6ddc388e65 +U drh +Z 584aed3667b20c0c4d105810047e9fd4 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFM/pWUoxKgR168RlERAuOQAJ9BLHxhysfzWC+psYkAVcf2xDsyTgCeIRqp +FF5a9ESJ6yucR80Re9sEWmU= +=ZPd3 +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index edaec7f5ef..420ef50389 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe441df9ba447d97571e919099846efa3ec87427 \ No newline at end of file +a586a4deeb25330037a49df295b36aaf624d0f45 \ No newline at end of file From 91412b244678dd680314e44d11237fb744f3fef0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 7 Dec 2010 23:24:00 +0000 Subject: [PATCH 04/82] Improved documentation for SQLITE_FCNTL_FILE_POINTER. FossilOrigin-Name: 43935548ae79d4d1a71549820a77368cda77104a --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 5 +++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6f9e049703..1ed5edf090 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Version\s3.7.4\srelease\scandidate\s4 -D 2010-12-07T20:14:09 +C Improved\sdocumentation\sfor\sSQLITE_FCNTL_FILE_POINTER. +D 2010-12-07T23:24:00 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056 -F src/sqlite.h.in b7e8a4e4749cfae9c99e1fbe3f9f87763cbbf7a2 +F src/sqlite.h.in d0cd88c447f25ead403bca04ebd8fe93e035f820 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P fe441df9ba447d97571e919099846efa3ec87427 -R 6bbeb99b0a61f7ea1af21c5b74072ff6 +P a586a4deeb25330037a49df295b36aaf624d0f45 +R 3ba386f2c8b25a73fb57f972152ce3ef U drh -Z 584aed3667b20c0c4d105810047e9fd4 +Z 390cd6512179f591600a20e0c1174f61 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM/pWUoxKgR168RlERAuOQAJ9BLHxhysfzWC+psYkAVcf2xDsyTgCeIRqp -FF5a9ESJ6yucR80Re9sEWmU= -=ZPd3 +iD8DBQFM/sIUoxKgR168RlERAjAdAJ9Bc1SGQwJEVJ0ZfAySqiDTMFxl5QCeLRfO +Kwt1ARzpSbUsTRztqDWiNdo= +=QYvM -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 420ef50389..fc57e9a4d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a586a4deeb25330037a49df295b36aaf624d0f45 \ No newline at end of file +43935548ae79d4d1a71549820a77368cda77104a \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 240a3bab22..7c259c8671 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -710,6 +710,11 @@ struct sqlite3_io_methods { ** for the nominated database. Allocating database file space in large ** chunks (say 1MB at a time), may reduce file-system fragmentation and ** improve performance on some systems. +** +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with a particular database +** connection. See the [sqlite3_file_control()] documentation for +** additional information. */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_GET_LOCKPROXYFILE 2 From 81d7fd13e46fda12f82ac52d838458ef88957063 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 8 Dec 2010 00:02:26 +0000 Subject: [PATCH 05/82] Changes to the shell which should, in theory, allow it to work with libeditline as an alternative to libreadline. FossilOrigin-Name: e474fd9e7f89644a7840e33e9df03dbaa4dd28bd --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/shell.c | 6 +++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 1ed5edf090..f8e150b6ed 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Improved\sdocumentation\sfor\sSQLITE_FCNTL_FILE_POINTER. -D 2010-12-07T23:24:00 +C Changes\sto\sthe\sshell\swhich\sshould,\sin\stheory,\sallow\sit\sto\swork\swith\nlibeditline\sas\san\salternative\sto\slibreadline. +D 2010-12-08T00:02:26 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 -F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056 +F src/shell.c 7b429fc7441594abcc5b97b4756a5f0a0a098e1b F src/sqlite.h.in d0cd88c447f25ead403bca04ebd8fe93e035f820 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a586a4deeb25330037a49df295b36aaf624d0f45 -R 3ba386f2c8b25a73fb57f972152ce3ef +P 43935548ae79d4d1a71549820a77368cda77104a +R fd202792c0017998f8a242e921dc5a93 U drh -Z 390cd6512179f591600a20e0c1174f61 +Z 6ca1c6e52bb72fad878f40ab29ea43f7 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM/sIUoxKgR168RlERAjAdAJ9Bc1SGQwJEVJ0ZfAySqiDTMFxl5QCeLRfO -Kwt1ARzpSbUsTRztqDWiNdo= -=QYvM +iD8DBQFM/ssWoxKgR168RlERArYWAJ9xDo6ujSZYl3PfXvHcS3k6gSuHwACdHVf9 +uErtwsOokR+Gj4AK0f8GS0M= +=EZ4n -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index fc57e9a4d3..afc682821d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -43935548ae79d4d1a71549820a77368cda77104a \ No newline at end of file +e474fd9e7f89644a7840e33e9df03dbaa4dd28bd \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index c5aa40cf29..f75c4b92b8 100644 --- a/src/shell.c +++ b/src/shell.c @@ -38,10 +38,14 @@ # include #endif +#ifdef HAVE_EDITLINE +# include +#endif #if defined(HAVE_READLINE) && HAVE_READLINE==1 # include # include -#else +#endif +#if !defined(HAVE_EDITLINE) && (!defined(HAVE_READLINE) || HAVE_READLINE!=1) # define readline(p) local_getline(p,stdin) # define add_history(X) # define read_history(X) From e14cd93f2e1cf021a9c553c6968e7d6d6b73d40c Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 8 Dec 2010 03:28:17 +0000 Subject: [PATCH 06/82] The command-line shell ignore errors in sqlite3_close() when shutting down. FossilOrigin-Name: 925332c3d79f6252895ff1a367f795630619247e --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/shell.c | 6 +----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index f8e150b6ed..36254014d3 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Changes\sto\sthe\sshell\swhich\sshould,\sin\stheory,\sallow\sit\sto\swork\swith\nlibeditline\sas\san\salternative\sto\slibreadline. -D 2010-12-08T00:02:26 +C The\scommand-line\sshell\signore\serrors\sin\ssqlite3_close()\swhen\sshutting\sdown. +D 2010-12-08T03:28:17 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 -F src/shell.c 7b429fc7441594abcc5b97b4756a5f0a0a098e1b +F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 F src/sqlite.h.in d0cd88c447f25ead403bca04ebd8fe93e035f820 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 43935548ae79d4d1a71549820a77368cda77104a -R fd202792c0017998f8a242e921dc5a93 +P e474fd9e7f89644a7840e33e9df03dbaa4dd28bd +R 7edcb2582417e56eb98f0dae455ae31e U drh -Z 6ca1c6e52bb72fad878f40ab29ea43f7 +Z b15026da9128033b9dc0a7b0dce2ca83 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM/ssWoxKgR168RlERArYWAJ9xDo6ujSZYl3PfXvHcS3k6gSuHwACdHVf9 -uErtwsOokR+Gj4AK0f8GS0M= -=EZ4n +iD8DBQFM/vtUoxKgR168RlERAi0wAJ4nUq0PfKIRivnR/wjbLVQFsF5neACfb8+m +fqFov7rgIDAItG1ZstpEvGo= +=CHf6 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index afc682821d..2287c208e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e474fd9e7f89644a7840e33e9df03dbaa4dd28bd \ No newline at end of file +925332c3d79f6252895ff1a367f795630619247e \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index f75c4b92b8..3fd0db3682 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2727,11 +2727,7 @@ int main(int argc, char **argv){ } set_table_name(&data, 0); if( data.db ){ - if( sqlite3_close(data.db)!=SQLITE_OK ){ - fprintf(stderr,"Error: cannot close database \"%s\"\n", - sqlite3_errmsg(db)); - rc++; - } + sqlite3_close(data.db); } return rc; } From 10fc727d35d4bc6b8a670e324d86f7377f38e34a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 8 Dec 2010 18:30:19 +0000 Subject: [PATCH 07/82] Update the sqlite3_stmt_readonly() interface so that its output is well-defined for all prepared statements, and so that it gives the correct result for VACUUM. FossilOrigin-Name: 9c19b7ae3542fd1fac692b4471f1839b22685c76 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/sqlite.h.in | 33 +++++++++++++++++++++++++-------- src/vdbeaux.c | 2 +- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 36254014d3..2497116d8c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C The\scommand-line\sshell\signore\serrors\sin\ssqlite3_close()\swhen\sshutting\sdown. -D 2010-12-08T03:28:17 +C Update\sthe\ssqlite3_stmt_readonly()\sinterface\sso\sthat\sits\soutput\sis\s\nwell-defined\sfor\sall\sprepared\sstatements,\sand\sso\sthat\sit\sgives\sthe\s\ncorrect\sresult\sfor\sVACUUM. +D 2010-12-08T18:30:20 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 -F src/sqlite.h.in d0cd88c447f25ead403bca04ebd8fe93e035f820 +F src/sqlite.h.in 2bd41c95c0a38a048511025b646b6fe3621f0753 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -235,7 +235,7 @@ F src/vdbe.c 5d310eaf1a4d8383602126fa82e01291ab7d3cf3 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 1f2137b905969f4de0648256aeb73abdf88f9213 F src/vdbeapi.c fb0036185b3c56e15916a5ee96309cd4acf6818f -F src/vdbeaux.c b810a66902ee40c71cdb9c64f43760da516c91df +F src/vdbeaux.c 33448d23b857654dd69ed2103611f5c733606f68 F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e474fd9e7f89644a7840e33e9df03dbaa4dd28bd -R 7edcb2582417e56eb98f0dae455ae31e +P 925332c3d79f6252895ff1a367f795630619247e +R 21967790fc1d3a87411c7dc79f0363d8 U drh -Z b15026da9128033b9dc0a7b0dce2ca83 +Z 43b494b0390c277287ad8dcfa52377ca -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM/vtUoxKgR168RlERAi0wAJ4nUq0PfKIRivnR/wjbLVQFsF5neACfb8+m -fqFov7rgIDAItG1ZstpEvGo= -=CHf6 +iD8DBQFM/87BoxKgR168RlERAq7yAJ91YZzLtFsuVU7N+/YXYPca9gc1nQCggog3 +BbPOFe1Sz6rNVdsQrKMw7s8= +=vXgA -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 2287c208e6..c8a9082ca9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -925332c3d79f6252895ff1a367f795630619247e \ No newline at end of file +9c19b7ae3542fd1fac692b4471f1839b22685c76 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 7c259c8671..f2bd71b1ff 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2650,14 +2650,31 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If An SQL Statement Writes The Database ** -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if -** the [prepared statement] X is [SELECT] statement and false (zero) if -** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], -** [ALTER], or [REINDEX] statement. -** If X is a NULL pointer or any other kind of statement, including but -** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], -** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is -** undefined. +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if +** and only if the [prepared statement] X is makes no direct changes to +** the content of the database file. +** +** Note that [application-defined SQL functions] or +** [virtual tables] might change the database indirectly as a side effect. +** ^(For example, if an application defines a function "eval()" that +** calls [sqlite3_exec()], then the following SQL statement would +** change the database file through side-effects: +** +**
+**    SELECT eval('DELETE FROM t1') FROM t2;
+** 
+** +** But because the [SELECT] statement does not change the database file +** directly, sqlite3_stmt_readonly() would still return true.)^ +** +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, +** since the statements themselves do not actually modify the database but +** rather they control the timing of when other statements modify the +** database. ^The [ATTACH] and [DETACH] statements also cause +** sqlite3_stmt_readonly() to return true since, while those statements +** change the configuration of a database connection, they do not make +** changes to the content of the database files on disk. */ int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a9ac9b032d..de69e544e5 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -408,7 +408,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ pOp->opflags = sqlite3OpcodeProperty[opcode]; if( opcode==OP_Function || opcode==OP_AggStep ){ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; - }else if( opcode==OP_Transaction && pOp->p2!=0 ){ + }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){ p->readOnly = 0; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( opcode==OP_VUpdate ){ From 7f322e791c48c6dbfd7046641307b860b006be75 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 9 Dec 2010 18:55:09 +0000 Subject: [PATCH 08/82] Mention the SQLITE_DEFAULT_WAL_AUTOCHECKPOINT compile-time option in the documentation for the sqlite3_wal_autocheckpoint() interface. FossilOrigin-Name: 5a52dd59ff577b071b4ed9316dc3bc753a18c8da --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 2497116d8c..2bfa063aad 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Update\sthe\ssqlite3_stmt_readonly()\sinterface\sso\sthat\sits\soutput\sis\s\nwell-defined\sfor\sall\sprepared\sstatements,\sand\sso\sthat\sit\sgives\sthe\s\ncorrect\sresult\sfor\sVACUUM. -D 2010-12-08T18:30:20 +C Mention\sthe\sSQLITE_DEFAULT_WAL_AUTOCHECKPOINT\scompile-time\soption\sin\sthe\ndocumentation\sfor\sthe\ssqlite3_wal_autocheckpoint()\sinterface. +D 2010-12-09T18:55:10 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 -F src/sqlite.h.in 2bd41c95c0a38a048511025b646b6fe3621f0753 +F src/sqlite.h.in eac5fdf313cd314b23093d70bf09b070e8f67919 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 925332c3d79f6252895ff1a367f795630619247e -R 21967790fc1d3a87411c7dc79f0363d8 +P 9c19b7ae3542fd1fac692b4471f1839b22685c76 +R 9fc220aeb3ca470dbed46dad4b9aed8d U drh -Z 43b494b0390c277287ad8dcfa52377ca +Z 1132cb60f4e8c33d250be651797c62dc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM/87BoxKgR168RlERAq7yAJ91YZzLtFsuVU7N+/YXYPca9gc1nQCggog3 -BbPOFe1Sz6rNVdsQrKMw7s8= -=vXgA +iD8DBQFNASYRoxKgR168RlERAkTOAJ43Vd+nEvp2oWH+XAz9YxMSE5KCZwCfZw+1 +GacVWoNSt5pj2hAFO+nz9+A= +=Kbdc -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index c8a9082ca9..8401774de4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c19b7ae3542fd1fac692b4471f1839b22685c76 \ No newline at end of file +5a52dd59ff577b071b4ed9316dc3bc753a18c8da \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index f2bd71b1ff..26c5591b05 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6180,7 +6180,8 @@ void *sqlite3_wal_hook( ** from SQL. ** ** ^Every new [database connection] defaults to having the auto-checkpoint -** enabled with a threshold of 1000 pages. The use of this interface +** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] +** pages. The use of this interface ** is only necessary if the default setting is found to be suboptimal ** for a particular application. */ From a4bfd7fde821eca44a6a217a9bc82700084586ec Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 9 Dec 2010 19:15:17 +0000 Subject: [PATCH 09/82] Add support for the SQLITE_DEFAULT_FOREIGN_KEYS compile-time option. FossilOrigin-Name: c959945ab7129b67eb2364befb9bf5cc88a8b0bf --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/main.c | 3 +++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2bfa063aad..e8e5f88473 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Mention\sthe\sSQLITE_DEFAULT_WAL_AUTOCHECKPOINT\scompile-time\soption\sin\sthe\ndocumentation\sfor\sthe\ssqlite3_wal_autocheckpoint()\sinterface. -D 2010-12-09T18:55:10 +C Add\ssupport\sfor\sthe\sSQLITE_DEFAULT_FOREIGN_KEYS\scompile-time\soption. +D 2010-12-09T19:15:17 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e -F src/main.c 721e5530b14b91a1fb6aead279af8b8729fa9a20 +F src/main.c b82ea116fc9e2e059e77b9a1aba76267681f7149 F src/malloc.c 3d7284cd9346ab6e3945535761e68c23c6cf40ef F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9c19b7ae3542fd1fac692b4471f1839b22685c76 -R 9fc220aeb3ca470dbed46dad4b9aed8d +P 5a52dd59ff577b071b4ed9316dc3bc753a18c8da +R f77079846f4aaed873cf9f6ceda77529 U drh -Z 1132cb60f4e8c33d250be651797c62dc +Z 52a27da9ef768b0e16942ded7463031d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNASYRoxKgR168RlERAkTOAJ43Vd+nEvp2oWH+XAz9YxMSE5KCZwCfZw+1 -GacVWoNSt5pj2hAFO+nz9+A= -=Kbdc +iD8DBQFNASrIoxKgR168RlERAqlaAJ9aEPuysxoQS1x9hi1oYTyTN055FACfbx1X +aPAgBUJmi1Z0CWWDapob82w= +=QBYv -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 8401774de4..727165bc7a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a52dd59ff577b071b4ed9316dc3bc753a18c8da \ No newline at end of file +c959945ab7129b67eb2364befb9bf5cc88a8b0bf \ No newline at end of file diff --git a/src/main.c b/src/main.c index f9e1a1c138..4b93a2ba54 100644 --- a/src/main.c +++ b/src/main.c @@ -1821,6 +1821,9 @@ static int openDatabase( #endif #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS | SQLITE_RecTriggers +#endif +#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS + | SQLITE_ForeignKeys #endif ; sqlite3HashInit(&db->aCollSeq); From d3842765aeb04b2cd1edf6fd72bdf432c80bb435 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 10 Dec 2010 17:06:48 +0000 Subject: [PATCH 10/82] Fix a performance regression in matchinfo(). FossilOrigin-Name: fa37d8eb7cd8049689068af2a80fe2cbb4a603f1 --- ext/fts3/fts3.c | 9 ++++++++- ext/fts3/fts3_snippet.c | 23 ++--------------------- manifest | 26 ++++++++------------------ manifest.uuid | 2 +- 4 files changed, 19 insertions(+), 41 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 8d517219a2..072e12e2fe 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3106,9 +3106,16 @@ char *sqlite3Fts3FindPositions( assert( pExpr->isLoaded ); if( pExpr->aDoclist ){ char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; - char *pCsr = pExpr->pCurrent; + char *pCsr; + if( pExpr->pCurrent==0 ){ + pExpr->pCurrent = pExpr->aDoclist; + pExpr->iCurrent = 0; + pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent); + } + pCsr = pExpr->pCurrent; assert( pCsr ); + while( pCsriCurrentaDoclist ){ - pExpr->pCurrent = pExpr->aDoclist; - pExpr->iCurrent = 0; - pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent, &pExpr->iCurrent); - } - return SQLITE_OK; -} - /* ** Load the doclists for each phrase in the query associated with FTS3 cursor ** pCsr. @@ -280,10 +264,7 @@ static int fts3ExprLoadDoclists( int rc; /* Return Code */ LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ sCtx.pCsr = pCsr; - rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb1, (void *)&sCtx); - if( rc==SQLITE_OK ){ - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb2, 0); - } + rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); if( pnPhrase ) *pnPhrase = sCtx.nPhrase; if( pnToken ) *pnToken = sCtx.nToken; return rc; diff --git a/manifest b/manifest index e8e5f88473..0a63041a09 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Add\ssupport\sfor\sthe\sSQLITE_DEFAULT_FOREIGN_KEYS\scompile-time\soption. -D 2010-12-09T19:15:17 +C Fix\sa\sperformance\sregression\sin\smatchinfo(). +D 2010-12-10T17:06:48 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -64,7 +61,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 44f998657ec849362484bb389c5728e821fc8c59 +F ext/fts3/fts3.c 28ada7d1c700e57b072b2c95d70565b05925fa46 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h a6c69c1c5e2c8c19172ddff42d262c087dcd7337 F ext/fts3/fts3_expr.c 5f49e0deaf723724b08100bb3ff40aab02ad0c93 @@ -72,7 +69,7 @@ F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295 F ext/fts3/fts3_porter.c d61cfd81fb0fd8fbcb25adcaee0ba671aefaa5c2 -F ext/fts3/fts3_snippet.c 6c87b55965124920d6461d79ea44b22cc3f307aa +F ext/fts3/fts3_snippet.c 3a26a835732619b62f3af1b73f96d017f8651f9f F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d @@ -897,14 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 5a52dd59ff577b071b4ed9316dc3bc753a18c8da -R f77079846f4aaed873cf9f6ceda77529 -U drh -Z 52a27da9ef768b0e16942ded7463031d ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNASrIoxKgR168RlERAqlaAJ9aEPuysxoQS1x9hi1oYTyTN055FACfbx1X -aPAgBUJmi1Z0CWWDapob82w= -=QBYv ------END PGP SIGNATURE----- +P c959945ab7129b67eb2364befb9bf5cc88a8b0bf +R ecceeedfad0e31364c78a099c74496b6 +U dan +Z 880171407a74a3cc3ca171dd325c20ce diff --git a/manifest.uuid b/manifest.uuid index 727165bc7a..632e91e631 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c959945ab7129b67eb2364befb9bf5cc88a8b0bf \ No newline at end of file +fa37d8eb7cd8049689068af2a80fe2cbb4a603f1 \ No newline at end of file From 901e994b8b7ed694ffe6d3858c79a195ee7b4791 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Dec 2010 18:54:37 +0000 Subject: [PATCH 11/82] When registering the built-in LIKE and GLOB functions, make sure that they are tagged with SQLITE_UTF8 so that if other application-defined LIKE and GLOB implementations are provided for UTF16, then the appropriate function will be selected. FossilOrigin-Name: e1660764f20fed3fe92156d2b7f06075ff6ac145 --- manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- src/func.c | 6 +++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0a63041a09..5968a5fa22 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\sperformance\sregression\sin\smatchinfo(). -D 2010-12-10T17:06:48 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C When\sregistering\sthe\sbuilt-in\sLIKE\sand\sGLOB\sfunctions,\smake\ssure\sthat\sthey\nare\stagged\swith\sSQLITE_UTF8\sso\sthat\sif\sother\sapplication-defined\sLIKE\sand\nGLOB\simplementations\sare\sprovided\sfor\sUTF16,\sthen\sthe\sappropriate\sfunction\nwill\sbe\sselected. +D 2010-12-15T18:54:37 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +134,7 @@ F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd F src/expr.c 1810f3056b11de99cc10e24629edf00e5fbd3a75 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 17950a28f28b23e8ad3feaac5fc88c324d2f600a -F src/func.c 2b7cf54d2569c2eba42fe81165d1932b546681a3 +F src/func.c cb41f614edc43b00bfeb030f9768e80eaff47edd F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -894,7 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c959945ab7129b67eb2364befb9bf5cc88a8b0bf -R ecceeedfad0e31364c78a099c74496b6 -U dan -Z 880171407a74a3cc3ca171dd325c20ce +P fa37d8eb7cd8049689068af2a80fe2cbb4a603f1 +R 54ccdc3adac00c10353f3a4344e22182 +U drh +Z d38e8f6227d017dae680c87b22026116 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNCQ7woxKgR168RlERAhlXAJ0VoVIcQCG2JtRw00vlkdOF11cy9wCfVw49 +kGM8knNFe0ZkghKGrCrLrig= +=6CjA +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 632e91e631..475677dcd5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa37d8eb7cd8049689068af2a80fe2cbb4a603f1 \ No newline at end of file +e1660764f20fed3fe92156d2b7f06075ff6ac145 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 8b7086f600..19c6d22510 100644 --- a/src/func.c +++ b/src/func.c @@ -1450,9 +1450,9 @@ void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){ }else{ pInfo = (struct compareInfo*)&likeInfoNorm; } - sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); - sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); - sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, + sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); + sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); + sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); setLikeOptFlag(db, "like", From d9c9b78e6c98e7fdcc128e8d790d5ce82d9e3bfa Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Dec 2010 21:02:06 +0000 Subject: [PATCH 12/82] Enhanced comments in wal.c and declare some procedure parameters "const". No changes to the generated code. FossilOrigin-Name: d0e4375b8a784d4e4ae66caababac919edd61883 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/wal.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 5968a5fa22..b15c5901aa 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C When\sregistering\sthe\sbuilt-in\sLIKE\sand\sGLOB\sfunctions,\smake\ssure\sthat\sthey\nare\stagged\swith\sSQLITE_UTF8\sso\sthat\sif\sother\sapplication-defined\sLIKE\sand\nGLOB\simplementations\sare\sprovided\sfor\sUTF16,\sthen\sthe\sappropriate\sfunction\nwill\sbe\sselected. -D 2010-12-15T18:54:37 +C Enhanced\scomments\sin\swal.c\sand\sdeclare\ssome\sprocedure\sparameters\s"const".\nNo\schanges\sto\sthe\sgenerated\scode. +D 2010-12-15T21:02:06 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -240,7 +240,7 @@ F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 -F src/wal.c f26b8d297bd11cb792e609917f9d4c6718ac8e0e +F src/wal.c 1c846e56cb271675304c0152cea91f4c2ecf5111 F src/wal.h c1aac6593a0b02b15dc625987e619edeab39292e F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c fa22d45b2577c77146f2e894d58011d472d64103 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P fa37d8eb7cd8049689068af2a80fe2cbb4a603f1 -R 54ccdc3adac00c10353f3a4344e22182 +P e1660764f20fed3fe92156d2b7f06075ff6ac145 +R 1109917c271937e015845cf31d3c184d U drh -Z d38e8f6227d017dae680c87b22026116 +Z 64f2fa76dd6cb11cf7eb68fbbec80d5e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNCQ7woxKgR168RlERAhlXAJ0VoVIcQCG2JtRw00vlkdOF11cy9wCfVw49 -kGM8knNFe0ZkghKGrCrLrig= -=6CjA +iD8DBQFNCSzRoxKgR168RlERAuCpAJ9yUwv8k5HtKXw8KEgKm4OKZcQUiwCfRCV0 +zLsoQIm1ng13QYFi6EqUsyY= +=j104 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 475677dcd5..72d8e84c22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1660764f20fed3fe92156d2b7f06075ff6ac145 \ No newline at end of file +d0e4375b8a784d4e4ae66caababac919edd61883 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 3b217908b7..913644c4ae 100644 --- a/src/wal.c +++ b/src/wal.c @@ -458,14 +458,14 @@ typedef u16 ht_slot; */ struct WalIterator { int iPrior; /* Last result returned from the iterator */ - int nSegment; /* Size of the aSegment[] array */ + int nSegment; /* Number of entries in aSegment[] */ struct WalSegment { int iNext; /* Next slot in aIndex[] not yet returned */ ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ u32 *aPgno; /* Array of page numbers. */ - int nEntry; /* Max size of aPgno[] and aIndex[] arrays */ + int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */ int iZero; /* Frame number associated with aPgno[0] */ - } aSegment[1]; /* One for every 32KB page in the WAL */ + } aSegment[1]; /* One for every 32KB page in the wal-index */ }; /* @@ -1329,9 +1329,29 @@ static int walIteratorNext( /* ** This function merges two sorted lists into a single sorted list. +** +** aLeft[] and aRight[] are arrays of indices. The sort key is +** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following +** is guaranteed for all J Date: Thu, 16 Dec 2010 02:06:29 +0000 Subject: [PATCH 13/82] Make wal_checkpoint a no-op if a prior checkpoint has already copied all WAL content into the database. This prevents a concurrent write to the database from resetting the wal-index out from under the WalIterator of the checkpoint as it is initializing. FossilOrigin-Name: cf86affcb7d3089496e9849cbf43a211097e4f64 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/wal.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index b15c5901aa..5130ec956c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Enhanced\scomments\sin\swal.c\sand\sdeclare\ssome\sprocedure\sparameters\s"const".\nNo\schanges\sto\sthe\sgenerated\scode. -D 2010-12-15T21:02:06 +C Make\swal_checkpoint\sa\sno-op\sif\sa\sprior\scheckpoint\shas\salready\scopied\sall\s\nWAL\scontent\sinto\sthe\sdatabase.\s\sThis\sprevents\sa\sconcurrent\swrite\sto\sthe\ndatabase\sfrom\sresetting\sthe\swal-index\sout\sfrom\sunder\sthe\sWalIterator\sof\nthe\scheckpoint\sas\sit\sis\sinitializing. +D 2010-12-16T02:06:30 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -240,7 +240,7 @@ F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 -F src/wal.c 1c846e56cb271675304c0152cea91f4c2ecf5111 +F src/wal.c dbca424f71678f663a286ab2a98f947af1d412a7 F src/wal.h c1aac6593a0b02b15dc625987e619edeab39292e F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c fa22d45b2577c77146f2e894d58011d472d64103 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e1660764f20fed3fe92156d2b7f06075ff6ac145 -R 1109917c271937e015845cf31d3c184d +P d0e4375b8a784d4e4ae66caababac919edd61883 +R 80db019f1fe0898e29ee135039b02e42 U drh -Z 64f2fa76dd6cb11cf7eb68fbbec80d5e +Z b7c01cb05c8175ac2d3c285f2b41993d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNCSzRoxKgR168RlERAuCpAJ9yUwv8k5HtKXw8KEgKm4OKZcQUiwCfRCV0 -zLsoQIm1ng13QYFi6EqUsyY= -=j104 +iD8DBQFNCXQpoxKgR168RlERAvhYAJ9VEC5cEqFcvoO8pUyjLqrkEx8osgCePOvl +dryfAhOPr5nP5lktpU/6FWo= +=UvbB -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 72d8e84c22..e14e633729 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0e4375b8a784d4e4ae66caababac919edd61883 \ No newline at end of file +cf86affcb7d3089496e9849cbf43a211097e4f64 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 913644c4ae..ff327bf6bb 100644 --- a/src/wal.c +++ b/src/wal.c @@ -1608,7 +1608,8 @@ static int walCheckpoint( szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); testcase( szPage<=32768 ); testcase( szPage>=65536 ); - if( pWal->hdr.mxFrame==0 ) return SQLITE_OK; + pInfo = walCkptInfo(pWal); + if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK; /* Allocate the iterator */ rc = walIteratorInit(pWal, &pIter); @@ -1630,7 +1631,6 @@ static int walCheckpoint( */ mxSafeFrame = pWal->hdr.mxFrame; mxPage = pWal->hdr.nPage; - pInfo = walCkptInfo(pWal); for(i=1; iaReadMark[i]; if( mxSafeFrame>=y ){ From 4278d53efa42707c253fee9420c53e760307f17b Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Dec 2010 19:52:52 +0000 Subject: [PATCH 14/82] Fix an assertion fault that can only occur if SQLITE_ENABLE_STAT2 is defined and the constant folding optimization is disabled using sqlite3_test_control(). Problem introduced by [ad8bc68197f2b4] but we missed it prior to the 3.7.4 release due to taking shortcuts and skipping tests in the release checklist. FossilOrigin-Name: 70a3d81742fcd481f83ccc8f7ff6af58bc29c4fa --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/where.c | 7 +++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 5130ec956c..9650e8ccdb 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Make\swal_checkpoint\sa\sno-op\sif\sa\sprior\scheckpoint\shas\salready\scopied\sall\s\nWAL\scontent\sinto\sthe\sdatabase.\s\sThis\sprevents\sa\sconcurrent\swrite\sto\sthe\ndatabase\sfrom\sresetting\sthe\swal-index\sout\sfrom\sunder\sthe\sWalIterator\sof\nthe\scheckpoint\sas\sit\sis\sinitializing. -D 2010-12-16T02:06:30 +C Fix\san\sassertion\sfault\sthat\scan\sonly\soccur\sif\sSQLITE_ENABLE_STAT2\sis\sdefined\nand\sthe\sconstant\sfolding\soptimization\sis\sdisabled\susing\ssqlite3_test_control().\nProblem\sintroduced\sby\s[ad8bc68197f2b4]\sbut\swe\smissed\sit\sprior\sto\sthe\s3.7.4\nrelease\sdue\sto\staking\sshortcuts\sand\sskipping\stests\sin\sthe\srelease\schecklist. +D 2010-12-16T19:52:53 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -243,7 +243,7 @@ F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 F src/wal.c dbca424f71678f663a286ab2a98f947af1d412a7 F src/wal.h c1aac6593a0b02b15dc625987e619edeab39292e F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c fa22d45b2577c77146f2e894d58011d472d64103 +F src/where.c af069e6b53234118014dabfece96a9515b69d76b F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d0e4375b8a784d4e4ae66caababac919edd61883 -R 80db019f1fe0898e29ee135039b02e42 +P cf86affcb7d3089496e9849cbf43a211097e4f64 +R 3de2e9f1840abc5aa813c8670b73846d U drh -Z b7c01cb05c8175ac2d3c285f2b41993d +Z 1060a236dbc52565455341e304a20640 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNCXQpoxKgR168RlERAvhYAJ9VEC5cEqFcvoO8pUyjLqrkEx8osgCePOvl -dryfAhOPr5nP5lktpU/6FWo= -=UvbB +iD8DBQFNCm4ZoxKgR168RlERAiUbAJ4qrpq7mstZk9+svbST+q1EKzcnqACfZcXk +mdsfy827moHN92mPMgDc9TQ= +=f2T1 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e14e633729..51060b8537 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf86affcb7d3089496e9849cbf43a211097e4f64 \ No newline at end of file +70a3d81742fcd481f83ccc8f7ff6af58bc29c4fa \ No newline at end of file diff --git a/src/where.c b/src/where.c index b8d1d6b276..4a5026f5f4 100644 --- a/src/where.c +++ b/src/where.c @@ -2315,10 +2315,9 @@ static int valueFromExpr( u8 aff, sqlite3_value **pp ){ - /* The evalConstExpr() function will have already converted any TK_VARIABLE - ** expression involved in an comparison into a TK_REGISTER. */ - assert( pExpr->op!=TK_VARIABLE ); - if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){ + if( pExpr->op==TK_VARIABLE + || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) + ){ int iVar = pExpr->iColumn; sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); From 230bd63011f6e6adbaa7b4940ed565efc2218c0e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Dec 2010 20:35:09 +0000 Subject: [PATCH 15/82] Improvements to the documentation for sqlite3_backup. No code changes. FossilOrigin-Name: f83609f4703b5e74a91bca071a4ac2843189f463 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 13 +++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 9650e8ccdb..57ea46afae 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\san\sassertion\sfault\sthat\scan\sonly\soccur\sif\sSQLITE_ENABLE_STAT2\sis\sdefined\nand\sthe\sconstant\sfolding\soptimization\sis\sdisabled\susing\ssqlite3_test_control().\nProblem\sintroduced\sby\s[ad8bc68197f2b4]\sbut\swe\smissed\sit\sprior\sto\sthe\s3.7.4\nrelease\sdue\sto\staking\sshortcuts\sand\sskipping\stests\sin\sthe\srelease\schecklist. -D 2010-12-16T19:52:53 +C Improvements\sto\sthe\sdocumentation\sfor\ssqlite3_backup.\s\sNo\scode\schanges. +D 2010-12-16T20:35:09 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 -F src/sqlite.h.in eac5fdf313cd314b23093d70bf09b070e8f67919 +F src/sqlite.h.in 10703eabbc046241562e351db01867bfd6ee9511 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P cf86affcb7d3089496e9849cbf43a211097e4f64 -R 3de2e9f1840abc5aa813c8670b73846d +P 70a3d81742fcd481f83ccc8f7ff6af58bc29c4fa +R 9519e6fa67e1334e4afcff3dd84c9457 U drh -Z 1060a236dbc52565455341e304a20640 +Z 293fd4f88c8d8f9ba51254632b1b2210 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNCm4ZoxKgR168RlERAiUbAJ4qrpq7mstZk9+svbST+q1EKzcnqACfZcXk -mdsfy827moHN92mPMgDc9TQ= -=f2T1 +iD8DBQFNCngBoxKgR168RlERAsAFAJ4iiuLm7vklx4CB6wSiyiEwn4CjxgCeOsUX +lnxUFl9L9846F0vUhGk6SN0= +=SOu3 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 51060b8537..7c38729052 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -70a3d81742fcd481f83ccc8f7ff6af58bc29c4fa \ No newline at end of file +f83609f4703b5e74a91bca071a4ac2843189f463 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 26c5591b05..18372c1692 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5783,11 +5783,12 @@ typedef struct sqlite3_backup sqlite3_backup; ** ** See Also: [Using the SQLite Online Backup API] ** -** ^Exclusive access is required to the destination database for the -** duration of the operation. ^However the source database is only -** read-locked while it is actually being read; it is not locked -** continuously for the entire backup operation. ^Thus, the backup may be -** performed on a live source database without preventing other users from +** ^SQLite holds a write transaction open on the destination database file +** for the duration of the backup operation. +** ^The source database is read-locked only while it is being read; +** it is not locked continuously for the entire backup operation. +** ^Thus, the backup may be performed on a live source database without +** preventing other database connections from ** reading or writing to the source database while the backup is underway. ** ** ^(To perform a backup operation: @@ -5835,7 +5836,7 @@ typedef struct sqlite3_backup sqlite3_backup; ** the source and destination databases specified by [sqlite3_backup] object B. ** ^If N is negative, all remaining source pages are copied. ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there -** are still more pages to be copied, then the function resturns [SQLITE_OK]. +** are still more pages to be copied, then the function returns [SQLITE_OK]. ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages ** from source to destination, then it returns [SQLITE_DONE]. ** ^If an error occurs while running sqlite3_backup_step(B,N), From cd2f58b3741d744b68803ec79a923e4df8bb2d04 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Dec 2010 00:59:59 +0000 Subject: [PATCH 16/82] Fix minor typos in the sqlite3_backup documentation. FossilOrigin-Name: df430be59d0766a34a94ab85fec9aa3c3baeb740 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 57ea46afae..1b7eff98ab 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Improvements\sto\sthe\sdocumentation\sfor\ssqlite3_backup.\s\sNo\scode\schanges. -D 2010-12-16T20:35:09 +C Fix\sminor\stypos\sin\sthe\ssqlite3_backup\sdocumentation. +D 2010-12-17T01:00:00 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 -F src/sqlite.h.in 10703eabbc046241562e351db01867bfd6ee9511 +F src/sqlite.h.in 83fed95ea6acbac51c48eba5bd93933f3795ee91 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 70a3d81742fcd481f83ccc8f7ff6af58bc29c4fa -R 9519e6fa67e1334e4afcff3dd84c9457 +P f83609f4703b5e74a91bca071a4ac2843189f463 +R 4fe65842543b054691673679e78a0692 U drh -Z 293fd4f88c8d8f9ba51254632b1b2210 +Z 4e539ffc5f953aea785c9c0d27788fb5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNCngBoxKgR168RlERAsAFAJ4iiuLm7vklx4CB6wSiyiEwn4CjxgCeOsUX -lnxUFl9L9846F0vUhGk6SN0= -=SOu3 +iD8DBQFNCrYToxKgR168RlERAvmlAJ43BlcnUUZrpZ/M23vbx+daRFmY/wCfaT9g +E7S6EnO/SOTNHOaDSvM60FI= +=7L0d -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 7c38729052..26559b48d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f83609f4703b5e74a91bca071a4ac2843189f463 \ No newline at end of file +df430be59d0766a34a94ab85fec9aa3c3baeb740 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 18372c1692..84999d4b1a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5815,11 +5815,11 @@ typedef struct sqlite3_backup sqlite3_backup; ** sqlite3_backup_init(D,N,S,M) identify the [database connection] ** and database name of the source database, respectively. ** ^The source and destination [database connections] (parameters S and D) -** must be different or else sqlite3_backup_init(D,N,S,M) will file with +** must be different or else sqlite3_backup_init(D,N,S,M) will fail with ** an error. ** ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is -** returned and an error code and error message are store3d in the +** returned and an error code and error message are stored in the ** destination [database connection] D. ** ^The error code and message for the failed call to sqlite3_backup_init() ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or @@ -5850,7 +5850,7 @@ typedef struct sqlite3_backup sqlite3_backup; **
  • the destination database was opened read-only, or **
  • the destination database is using write-ahead-log journaling ** and the destination and source page sizes differ, or -**
  • The destination database is an in-memory database and the +**
  • the destination database is an in-memory database and the ** destination and source page sizes differ. ** )^ ** From 9c88d68988afd24e1ee607deef5531115a2c95f7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Dec 2010 14:03:01 +0000 Subject: [PATCH 17/82] Add the "-heap" option to the command-line shell - to allocate a fixed heap for use with SQLITE_ENABLE_MEMSYS5. FossilOrigin-Name: 74fff692345fed4b247e2b34c1e63b4d50cddfd4 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/shell.c | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1b7eff98ab..8023d4f93e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sminor\stypos\sin\sthe\ssqlite3_backup\sdocumentation. -D 2010-12-17T01:00:00 +C Add\sthe\s"-heap"\soption\sto\sthe\scommand-line\sshell\s-\sto\sallocate\sa\sfixed\sheap\nfor\suse\swith\sSQLITE_ENABLE_MEMSYS5. +D 2010-12-17T14:03:02 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 -F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 +F src/shell.c 9afa9bdd62142e254b4581a77b43080d3ffd4ef4 F src/sqlite.h.in 83fed95ea6acbac51c48eba5bd93933f3795ee91 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f83609f4703b5e74a91bca071a4ac2843189f463 -R 4fe65842543b054691673679e78a0692 +P df430be59d0766a34a94ab85fec9aa3c3baeb740 +R 393588dace853776e15dcf6aab702ada U drh -Z 4e539ffc5f953aea785c9c0d27788fb5 +Z 6ec40d9633f2b97ac37609013c97cbd2 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNCrYToxKgR168RlERAvmlAJ43BlcnUUZrpZ/M23vbx+daRFmY/wCfaT9g -E7S6EnO/SOTNHOaDSvM60FI= -=7L0d +iD8DBQFNC22aoxKgR168RlERAm4mAJ9G1zGhPNOGmUpwiD7fc9SFGpgP5ACeMlV3 +fsznZTHZc81uTNgquU68if8= +=DrJ4 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 26559b48d7..0a6617ada8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df430be59d0766a34a94ab85fec9aa3c3baeb740 \ No newline at end of file +74fff692345fed4b247e2b34c1e63b4d50cddfd4 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 3fd0db3682..0609e42318 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2542,6 +2542,7 @@ int main(int argc, char **argv){ /* Do an initial pass through the command-line argument to locate ** the name of the database file, the name of the initialization file, + ** the size of the alternative malloc heap, ** and the first command to execute. */ for(i=1; i0x7fff0000 ) szHeap = 0x7fff0000; +#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) + sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); +#endif } } if( i Date: Mon, 20 Dec 2010 15:51:58 +0000 Subject: [PATCH 18/82] Add additional DBSTATUS options for measuring the hit and miss rates against the lookaside memory pool - information useful in tuning the lookaside size. Currently experimental pending analysis of performance impact. FossilOrigin-Name: 34613f1dc54c638531ca2f5907b71fbe8841233e --- manifest | 28 ++++++++++++++++------------ manifest.uuid | 2 +- src/malloc.c | 20 +++++++++++++------- src/sqlite.h.in | 35 ++++++++++++++++++++++++++++++----- src/sqliteInt.h | 1 + src/status.c | 16 ++++++++++++++++ 6 files changed, 77 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 8023d4f93e..c423fa11b3 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sthe\s"-heap"\soption\sto\sthe\scommand-line\sshell\s-\sto\sallocate\sa\sfixed\sheap\nfor\suse\swith\sSQLITE_ENABLE_MEMSYS5. -D 2010-12-17T14:03:02 +C Add\sadditional\sDBSTATUS\soptions\sfor\smeasuring\sthe\shit\sand\smiss\srates\sagainst\nthe\slookaside\smemory\spool\s-\sinformation\suseful\sin\stuning\sthe\slookaside\ssize.\nCurrently\sexperimental\spending\sanalysis\sof\sperformance\simpact. +D 2010-12-20T15:51:59 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e F src/main.c b82ea116fc9e2e059e77b9a1aba76267681f7149 -F src/malloc.c 3d7284cd9346ab6e3945535761e68c23c6cf40ef +F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf @@ -179,11 +179,11 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 9afa9bdd62142e254b4581a77b43080d3ffd4ef4 -F src/sqlite.h.in 83fed95ea6acbac51c48eba5bd93933f3795ee91 +F src/sqlite.h.in 2f1fd40e8ba7c0a51eb755e0b6af236ce692325b F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 +F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 -F src/status.c 496913d4e8441195f6f2a75b1c95993a45b9b30b +F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 77c5c4b8ac7b2d94ee480e1ad626fbd921d948e4 F src/test1.c 397809a3069c171a507a49b6f6edfc4255b0afbc @@ -897,14 +897,18 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P df430be59d0766a34a94ab85fec9aa3c3baeb740 -R 393588dace853776e15dcf6aab702ada +P 74fff692345fed4b247e2b34c1e63b4d50cddfd4 +R 5082873d15f794ab949991323071e42f +T *bgcolor * #c0ffc0 +T *branch * experimental +T *sym-experimental * +T -sym-trunk * U drh -Z 6ec40d9633f2b97ac37609013c97cbd2 +Z d0e19bf0b71d36c4c32d327aba382999 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNC22aoxKgR168RlERAm4mAJ9G1zGhPNOGmUpwiD7fc9SFGpgP5ACeMlV3 -fsznZTHZc81uTNgquU68if8= -=DrJ4 +iD8DBQFND3uioxKgR168RlERAirTAJ0bHLsmerXov5fiom51y80kBrhKkACfXfos +ossaFA/wslQt5YU5JPaXj1I= +=Q2Je -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0a6617ada8..dfd9a9a2d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74fff692345fed4b247e2b34c1e63b4d50cddfd4 \ No newline at end of file +34613f1dc54c638531ca2f5907b71fbe8841233e \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 2c78979498..a3a9e0fe2c 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -616,14 +616,20 @@ void *sqlite3DbMallocRaw(sqlite3 *db, int n){ if( db->mallocFailed ){ return 0; } - if( db->lookaside.bEnabled && n<=db->lookaside.sz - && (pBuf = db->lookaside.pFree)!=0 ){ - db->lookaside.pFree = pBuf->pNext; - db->lookaside.nOut++; - if( db->lookaside.nOut>db->lookaside.mxOut ){ - db->lookaside.mxOut = db->lookaside.nOut; + if( db->lookaside.bEnabled ){ + if( n>db->lookaside.sz ){ + db->lookaside.anStat[1]++; + }else if( (pBuf = db->lookaside.pFree)==0 ){ + db->lookaside.anStat[2]++; + }else{ + db->lookaside.pFree = pBuf->pNext; + db->lookaside.nOut++; + db->lookaside.anStat[0]++; + if( db->lookaside.nOut>db->lookaside.mxOut ){ + db->lookaside.mxOut = db->lookaside.nOut; + } + return (void*)pBuf; } - return (void*)pBuf; } } #else diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 84999d4b1a..226c5f97f5 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5509,6 +5509,28 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); **
    This parameter returns the number of lookaside memory slots currently ** checked out.
    )^ ** +** ^(
    SQLITE_DBSTATUS_LOOKASIDE_HIT
    +**
    This parameter returns the number malloc attempts that were +** satisfied using lookaside memory. Only the high-water value is meaningful; +** the current value is always zero. +** checked out.
    )^ +** +** ^(
    SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
    +**
    This parameter returns the number malloc attempts that might have +** been satisfied using lookaside memory but failed due to the amount of +** memory requested being larger than the lookaside slot size. +** Only the high-water value is meaningful; +** the current value is always zero. +** checked out.
    )^ +** +** ^(
    SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
    +**
    This parameter returns the number malloc attempts that might have +** been satisfied using lookaside memory but failed due to all lookaside +** memory already being in use. +** Only the high-water value is meaningful; +** the current value is always zero. +** checked out.
    )^ +** ** ^(
    SQLITE_DBSTATUS_CACHE_USED
    **
    This parameter returns the approximate number of of bytes of heap ** memory used by all pager caches associated with the database connection.)^ @@ -5531,11 +5553,14 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); **
    ** */ -#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 -#define SQLITE_DBSTATUS_CACHE_USED 1 -#define SQLITE_DBSTATUS_SCHEMA_USED 2 -#define SQLITE_DBSTATUS_STMT_USED 3 -#define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 +#define SQLITE_DBSTATUS_CACHE_USED 1 +#define SQLITE_DBSTATUS_SCHEMA_USED 2 +#define SQLITE_DBSTATUS_STMT_USED 3 +#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 +#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4f0e08ea76..5233e99f09 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -737,6 +737,7 @@ struct Lookaside { u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ int nOut; /* Number of buffers currently checked out */ int mxOut; /* Highwater mark for nOut */ + int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ LookasideSlot *pFree; /* List of available buffers */ void *pStart; /* First byte of available memory space */ void *pEnd; /* First byte past end of available space */ diff --git a/src/status.c b/src/status.c index 7f05f1c68e..96759fda7e 100644 --- a/src/status.c +++ b/src/status.c @@ -116,6 +116,22 @@ int sqlite3_db_status( break; } + case SQLITE_DBSTATUS_LOOKASIDE_HIT: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT ); + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); + assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 ); + assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 ); + *pCurrent = 0; + *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; + if( resetFlag ){ + db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; + } + break; + } + /* ** Return an approximation for the amount of memory currently used ** by all pagers associated with the given database connection. The From 08bd9f83ceb589a81eebe21d27e52eb1b593f438 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 20 Dec 2010 17:00:27 +0000 Subject: [PATCH 19/82] Clarify the documentation of the SQLITE_STATUS_MALLOC_COUNT parameter to sqlite3_status(). FossilOrigin-Name: 3b41bcc3e36a9ef0146bc2f6ae86377bd1700afd --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8023d4f93e..195351767b 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sthe\s"-heap"\soption\sto\sthe\scommand-line\sshell\s-\sto\sallocate\sa\sfixed\sheap\nfor\suse\swith\sSQLITE_ENABLE_MEMSYS5. -D 2010-12-17T14:03:02 +C Clarify\sthe\sdocumentation\sof\sthe\sSQLITE_STATUS_MALLOC_COUNT\sparameter\sto\nsqlite3_status(). +D 2010-12-20T17:00:28 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 9afa9bdd62142e254b4581a77b43080d3ffd4ef4 -F src/sqlite.h.in 83fed95ea6acbac51c48eba5bd93933f3795ee91 +F src/sqlite.h.in 2d24126d553904fa0d9207e2424109ae2369a707 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P df430be59d0766a34a94ab85fec9aa3c3baeb740 -R 393588dace853776e15dcf6aab702ada +P 74fff692345fed4b247e2b34c1e63b4d50cddfd4 +R 05696043bb691972743f116032eb7cc7 U drh -Z 6ec40d9633f2b97ac37609013c97cbd2 +Z 0d94f4cb1ba5a4f17daf853cca6b2b1d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNC22aoxKgR168RlERAm4mAJ9G1zGhPNOGmUpwiD7fc9SFGpgP5ACeMlV3 -fsznZTHZc81uTNgquU68if8= -=DrJ4 +iD8DBQFND4uvoxKgR168RlERAmboAJ9ECncAj8L2uNPORTjmNgH2KLgLGQCfTHpL +w2fdORwbJsTAnpJEGct6W7Q= +=6J0C -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0a6617ada8..b5e82032ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74fff692345fed4b247e2b34c1e63b4d50cddfd4 \ No newline at end of file +3b41bcc3e36a9ef0146bc2f6ae86377bd1700afd \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 84999d4b1a..13dd1fa963 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5403,7 +5403,8 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); ** The value written into the *pCurrent parameter is undefined.)^ ** ** ^(
    SQLITE_STATUS_MALLOC_COUNT
    -**
    This parameter records the number of separate memory allocations.
    )^ +**
    This parameter records the number of separate memory allocations +** currently checked out.
    )^ ** ** ^(
    SQLITE_STATUS_PAGECACHE_USED
    **
    This parameter returns the number of pages used out of the From 29ecd8a0779769dab9e1034e50b6527669a60aaf Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Dec 2010 00:16:40 +0000 Subject: [PATCH 20/82] Rearrange a variable declaration in the proxy locking code to avoid a harmless compiler warning on recent MacOS versions. FossilOrigin-Name: 39bbd35599e735b32f7ed18143073165b805dd98 --- manifest | 22 ++++++---------------- manifest.uuid | 2 +- src/os_unix.c | 15 ++++++++------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 195351767b..17705b4a17 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Clarify\sthe\sdocumentation\sof\sthe\sSQLITE_STATUS_MALLOC_COUNT\sparameter\sto\nsqlite3_status(). -D 2010-12-20T17:00:28 +C Rearrange\sa\svariable\sdeclaration\sin\sthe\sproxy\slocking\scode\sto\savoid\sa\sharmless\ncompiler\swarning\son\srecent\sMacOS\sversions. +D 2010-12-21T00:16:40 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +160,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e -F src/os_unix.c 0240c5b547b4cf585c8cac351a95c3e85ce00772 +F src/os_unix.c c43a55b46a6be81a4f29a52eb88245e5d7f342fa F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad F src/pager.c c0aca5c733c15a16fe158c3215d857841a4e5381 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 @@ -897,14 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 74fff692345fed4b247e2b34c1e63b4d50cddfd4 -R 05696043bb691972743f116032eb7cc7 +P 3b41bcc3e36a9ef0146bc2f6ae86377bd1700afd +R 1a70a1f19194c16e9b9725927017bb71 U drh -Z 0d94f4cb1ba5a4f17daf853cca6b2b1d ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFND4uvoxKgR168RlERAmboAJ9ECncAj8L2uNPORTjmNgH2KLgLGQCfTHpL -w2fdORwbJsTAnpJEGct6W7Q= -=6J0C ------END PGP SIGNATURE----- +Z 9866ee9011213cea3ec50de8e4d375c6 diff --git a/manifest.uuid b/manifest.uuid index b5e82032ac..4ebd5e84ba 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b41bcc3e36a9ef0146bc2f6ae86377bd1700afd \ No newline at end of file +39bbd35599e735b32f7ed18143073165b805dd98 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 72ac4c8048..ba699632d7 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5403,18 +5403,19 @@ extern int gethostuuid(uuid_t id, const struct timespec *wait); ** bytes of writable memory. */ static int proxyGetHostID(unsigned char *pHostID, int *pError){ - struct timespec timeout = {1, 0}; /* 1 sec timeout */ - assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); memset(pHostID, 0, PROXY_HOSTIDLEN); #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 - if( gethostuuid(pHostID, &timeout) ){ - int err = errno; - if( pError ){ - *pError = err; + { + static const struct timespec timeout = {1, 0}; /* 1 sec timeout */ + if( gethostuuid(pHostID, &timeout) ){ + int err = errno; + if( pError ){ + *pError = err; + } + return SQLITE_IOERR; } - return SQLITE_IOERR; } #endif #ifdef SQLITE_TEST From 697e965299afe8e07b2a5d95354922dc9252cccd Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Dec 2010 00:20:53 +0000 Subject: [PATCH 21/82] Remove the obsolete compile-time option SQLITE_THREAD_OVERRIDE_LOCK from the autoconf makefile. Needed only for LinuxThreads, which we no longer support. FossilOrigin-Name: 09f6c053ff9239c22ecf527ae579446c6e21e550 --- Makefile.in | 4 ---- configure | 58 +++++++++++++-------------------------------------- configure.ac | 18 ---------------- manifest | 26 ++++++++++++++++------- manifest.uuid | 2 +- 5 files changed, 33 insertions(+), 75 deletions(-) diff --git a/Makefile.in b/Makefile.in index d5e29a1bc5..0e2837cd9f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,10 +59,6 @@ LIBREADLINE = @TARGET_READLINE_LIBS@ # TCC += -DSQLITE_THREADSAFE=@SQLITE_THREADSAFE@ -# Do threads override each others locks by default (1), or do we test (-1) -# -TCC += -DSQLITE_THREAD_OVERRIDE_LOCK=@THREADSOVERRIDELOCKS@ - # Any target libraries which libsqlite must be linked against # TLIBS = @LIBS@ diff --git a/configure b/configure index a3de9e603d..3d617d0dd8 100755 --- a/configure +++ b/configure @@ -869,7 +869,6 @@ VERSION_NUMBER BUILD_CC SQLITE_THREADSAFE XTHREADCONNECT -THREADSOVERRIDELOCKS ALLOWRELEASE TEMP_STORE BUILD_EXEEXT @@ -912,7 +911,6 @@ enable_largefile with_hints enable_threadsafe enable_cross_thread_connections -enable_threads_override_locks enable_releasemode enable_tempstore enable_tcl @@ -1569,8 +1567,6 @@ Optional Features: --enable-threadsafe Support threadsafe operation --enable-cross-thread-connections Allow connection sharing across threads - --enable-threads-override-locks - Threads can override each others locks --enable-releasemode Support libtool link to release mode --enable-tempstore Use an in-ram database for temporary tables (never,no,yes,always) @@ -3738,13 +3734,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3741: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3737: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3744: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3740: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3747: output\"" >&5) + (eval echo "\"\$as_me:3743: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -4966,7 +4962,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4969 "configure"' > conftest.$ac_ext + echo '#line 4965 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6835,11 +6831,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6838: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6834: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6842: \$? = $ac_status" >&5 + echo "$as_me:6838: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7174,11 +7170,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7177: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7173: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7181: \$? = $ac_status" >&5 + echo "$as_me:7177: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7279,11 +7275,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7282: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7278: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7286: \$? = $ac_status" >&5 + echo "$as_me:7282: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7334,11 +7330,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7337: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7333: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7341: \$? = $ac_status" >&5 + echo "$as_me:7337: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10147,7 +10143,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10150 "configure" +#line 10146 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10243,7 +10239,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10246 "configure" +#line 10242 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12580,32 +12576,6 @@ $as_echo "yes" >&6; } fi -########## -# Do we want to set threadsOverrideEachOthersLocks variable to be 1 (true) by -# default. Normally, a test at runtime is performed to determine the -# appropriate value of this variable. Use this option only if you're sure that -# threads can safely override each others locks in all runtime situations. -# -# Check whether --enable-threads-override-locks was given. -if test "${enable_threads_override_locks+set}" = set; then - enableval=$enable_threads_override_locks; -else - enable_threads_override_locks=no -fi - -{ $as_echo "$as_me:$LINENO: checking whether threads can override each others locks" >&5 -$as_echo_n "checking whether threads can override each others locks... " >&6; } -if test "$enable_threads_override_locks" = "no"; then - THREADSOVERRIDELOCKS='-1' - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -else - THREADSOVERRIDELOCKS='1' - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } -fi - - ########## # Do we want to support release # diff --git a/configure.ac b/configure.ac index ea8c23f511..464ed1ef11 100644 --- a/configure.ac +++ b/configure.ac @@ -268,24 +268,6 @@ else fi AC_SUBST(XTHREADCONNECT) -########## -# Do we want to set threadsOverrideEachOthersLocks variable to be 1 (true) by -# default. Normally, a test at runtime is performed to determine the -# appropriate value of this variable. Use this option only if you're sure that -# threads can safely override each others locks in all runtime situations. -# -AC_ARG_ENABLE(threads-override-locks, -AC_HELP_STRING([--enable-threads-override-locks],[Threads can override each others locks]),,enable_threads_override_locks=no) -AC_MSG_CHECKING([whether threads can override each others locks]) -if test "$enable_threads_override_locks" = "no"; then - THREADSOVERRIDELOCKS='-1' - AC_MSG_RESULT([no]) -else - THREADSOVERRIDELOCKS='1' - AC_MSG_RESULT([yes]) -fi -AC_SUBST(THREADSOVERRIDELOCKS) - ########## # Do we want to support release # diff --git a/manifest b/manifest index 17705b4a17..3df97295bb 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,10 @@ -C Rearrange\sa\svariable\sdeclaration\sin\sthe\sproxy\slocking\scode\sto\savoid\sa\sharmless\ncompiler\swarning\son\srecent\sMacOS\sversions. -D 2010-12-21T00:16:40 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Remove\sthe\sobsolete\scompile-time\soption\sSQLITE_THREAD_OVERRIDE_LOCK\nfrom\sthe\sautoconf\smakefile.\s\sNeeded\sonly\sfor\sLinuxThreads,\swhich\swe\sno\nlonger\ssupport. +D 2010-12-21T00:20:54 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 +F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 @@ -22,8 +25,8 @@ F art/src_logo.gif 9341ef09f0e53cd44c0c9b6fc3c16f7f3d6c2ad9 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 868fdb48c028421a203470e15c69ada15b9ba673 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure daed6cfdb4c1449a4335b3eeddc0d836e33fb54e x -F configure.ac 699040cc9abb7465dca5a2972bc89d227fd8f734 +F configure 4d325bb1fd4064fc4b8a2102e47e3c8966bbe2cf x +F configure.ac 87a3c71bbe9c925381c154413eea7f3cdc397244 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 F doc/pager-invariants.txt 870107036470d7c419e93768676fae2f8749cf9e @@ -894,7 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3b41bcc3e36a9ef0146bc2f6ae86377bd1700afd -R 1a70a1f19194c16e9b9725927017bb71 +P 39bbd35599e735b32f7ed18143073165b805dd98 +R 80b3317d427aed8936aa381a5ad6ed6c U drh -Z 9866ee9011213cea3ec50de8e4d375c6 +Z 50f3f1b11bd7b6b561a6a28e34c75c73 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFND/LpoxKgR168RlERAjN/AJ9GW7kKHV8mhDRU/MIZoIFYemwlJQCfS21P +RmgCdBRtWA88sFD1ddbbF+c= +=PAHS +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4ebd5e84ba..beb1ad79d5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39bbd35599e735b32f7ed18143073165b805dd98 \ No newline at end of file +09f6c053ff9239c22ecf527ae579446c6e21e550 \ No newline at end of file From 2a58e9cc32dad4e437ba880a951aa06bb69691e5 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Dec 2010 21:28:38 +0000 Subject: [PATCH 22/82] Add test cases for the new lookaside hit and miss status outputs. Add the output of lookaside hit and miss to the command-line shell statistics. FossilOrigin-Name: b0888047bb6d9ac55e29b9224df2ff650728bb78 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/shell.c | 8 +++++++- src/test_malloc.c | 13 +++++++++---- test/lookaside.test | 32 ++++++++++++++++++++++---------- 5 files changed, 50 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 79050bc92a..ef6736f82b 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Merge\sinto\sthe\strunk\sthe\sexperimental\senhancements\sto\ssqlite3_db_status()\s\nfor\smeasuring\slookaside\smemory\sallocator\sperformance. -D 2010-12-21T20:36:46 +C Add\stest\scases\sfor\sthe\snew\slookaside\shit\sand\smiss\sstatus\soutputs.\s\sAdd\nthe\soutput\sof\slookaside\shit\sand\smiss\sto\sthe\scommand-line\sshell\sstatistics. +D 2010-12-21T21:28:38 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 -F src/shell.c 9afa9bdd62142e254b4581a77b43080d3ffd4ef4 +F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 F src/sqlite.h.in 54dd12d0dd8b6a4afd7b3d5a03d36ec64a67b641 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c @@ -209,7 +209,7 @@ F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99 F src/test_intarray.h 489edb9068bb926583445cb02589344961054207 F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e -F src/test_malloc.c 09a88f0c111201dc4f8c20470aa1b5f611d59200 +F src/test_malloc.c fd6188b1501c0010fb4241ddc9f0d5ac402c688d F src/test_multiplex.c 5990431a852aa21c9a67da748f23d2cf1e21f8fc F src/test_mutex.c ce06b59aca168cd8c520b77159a24352a7469bd3 F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec @@ -528,7 +528,7 @@ F test/lock5.test b2abb5e711bc59b0eae00f6c97a36ec9f458fada F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 64006c84c1c616657e237c7ad6532b765611cf64 F test/lock_common.tcl d279887a0ab16cdb6d935c1203e64113c5a000e9 -F test/lookaside.test 382e7bc2fab23d902c8eafb1b9ed7ababfff75a6 +F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2 F test/main.test 9d7bbfcc1b52c88ba7b2ba6554068ecf9939f252 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 F test/malloc.test 927e6c8668a1d48c23aa6189bda02aff5a1b83de @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 09f6c053ff9239c22ecf527ae579446c6e21e550 34613f1dc54c638531ca2f5907b71fbe8841233e -R 70bb859101c53c246dfc4f574be27803 +P 8c3b06c299554759b67437e09ee7ef6420dacafc +R 3d2dc28d218eda07e432c06d2acaf490 U drh -Z a58574a5d2655de53c943a82d61ee0c4 +Z 978ce4a1633e46da2aa79d83b4cbd5d5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNEQ/hoxKgR168RlERAlduAKCC7Lj51Ln8aN6aJlGCTwPg8olPygCghFCt -2eqZ3E29sKKFSCheCCAI7u0= -=jBul +iD8DBQFNERwJoxKgR168RlERAicZAJwKgYzQDbPRBPAlwwf+g1uwhrnDewCePClG +nEAmUkNjgcw8rSbTLPArTDg= +=3YUL -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e97834e992..886c84aa99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c3b06c299554759b67437e09ee7ef6420dacafc \ No newline at end of file +b0888047bb6d9ac55e29b9224df2ff650728bb78 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 0609e42318..33dc1ac38a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -984,7 +984,7 @@ static int display_stats( fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Number of Allocations: %d (max %d)\n", iCur, iHiwtr); + fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr); /* ** Not currently used by the CLI. ** iHiwtr = iCur = -1; @@ -1023,6 +1023,12 @@ static int display_stats( iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr); + sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); + fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); + sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); + fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); + sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); + fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); diff --git a/src/test_malloc.c b/src/test_malloc.c index 08642c9fec..c63ded7035 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -1290,10 +1290,13 @@ static int test_db_status( const char *zName; int op; } aOp[] = { - { "SQLITE_DBSTATUS_LOOKASIDE_USED", SQLITE_DBSTATUS_LOOKASIDE_USED }, - { "SQLITE_DBSTATUS_CACHE_USED", SQLITE_DBSTATUS_CACHE_USED }, - { "SQLITE_DBSTATUS_SCHEMA_USED", SQLITE_DBSTATUS_SCHEMA_USED }, - { "SQLITE_DBSTATUS_STMT_USED", SQLITE_DBSTATUS_STMT_USED } + { "LOOKASIDE_USED", SQLITE_DBSTATUS_LOOKASIDE_USED }, + { "CACHE_USED", SQLITE_DBSTATUS_CACHE_USED }, + { "SCHEMA_USED", SQLITE_DBSTATUS_SCHEMA_USED }, + { "STMT_USED", SQLITE_DBSTATUS_STMT_USED }, + { "LOOKASIDE_HIT", SQLITE_DBSTATUS_LOOKASIDE_HIT }, + { "LOOKASIDE_MISS_SIZE", SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE }, + { "LOOKASIDE_MISS_FULL", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL } }; Tcl_Obj *pResult; if( objc!=4 ){ @@ -1302,6 +1305,8 @@ static int test_db_status( } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; zOpName = Tcl_GetString(objv[2]); + if( memcmp(zOpName, "SQLITE_", 7)==0 ) zOpName += 7; + if( memcmp(zOpName, "DBSTATUS_", 9)==0 ) zOpName += 9; for(i=0; i0 && $q>0 && $r>0} } {0} do_test lookaside-1.5 { - foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break + foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break expr {$x==0 && $y<$z && $z==18} } {0} do_test lookaside-1.6 { - foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break + foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break expr {$x==0 && $y==$z && $y<18} } {1} do_test lookaside-1.7 { db cache flush - foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break + foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break expr {$x==0 && $y==0 && $z<18} } {1} do_test lookaside-1.8 { db cache flush - foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break + foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break expr {$x==0 && $y==0 && $z<18} } {1} do_test lookaside-1.9 { db cache flush - sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0 + sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0 } {0 0 0} do_test lookaside-2.1 { @@ -83,7 +95,7 @@ do_test lookaside-2.1 { } {0} do_test lookaside-2.2 { db eval {CREATE TABLE t2(x);} - foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break + foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break expr {$x==0 && $y<$z && $z>10 && $z<100} } {1} do_test lookaside-2.3 { From b469f46083520476d9b328f17086e97c5590cd8c Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 22 Dec 2010 21:48:50 +0000 Subject: [PATCH 23/82] Do not include <sys/mmap.h> if SQLITE_OMIT_WAL is defined. FossilOrigin-Name: b82e85ece94c8e25c1dc3251f5444a295fbf8c89 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/os_unix.c | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ef6736f82b..5894989f76 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\stest\scases\sfor\sthe\snew\slookaside\shit\sand\smiss\sstatus\soutputs.\s\sAdd\nthe\soutput\sof\slookaside\shit\sand\smiss\sto\sthe\scommand-line\sshell\sstatistics. -D 2010-12-21T21:28:38 +C Do\snot\sinclude\s<sys/mmap.h>\sif\sSQLITE_OMIT_WAL\sis\sdefined. +D 2010-12-22T21:48:51 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e -F src/os_unix.c c43a55b46a6be81a4f29a52eb88245e5d7f342fa +F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad F src/pager.c c0aca5c733c15a16fe158c3215d857841a4e5381 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8c3b06c299554759b67437e09ee7ef6420dacafc -R 3d2dc28d218eda07e432c06d2acaf490 +P b0888047bb6d9ac55e29b9224df2ff650728bb78 +R 0a946df43b3c238f90360fc25b951e41 U drh -Z 978ce4a1633e46da2aa79d83b4cbd5d5 +Z 3ea172d138576a025bf2ce93fc7e3eec -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNERwJoxKgR168RlERAicZAJwKgYzQDbPRBPAlwwf+g1uwhrnDewCePClG -nEAmUkNjgcw8rSbTLPArTDg= -=3YUL +iD8DBQFNEnJJoxKgR168RlERAn0IAJ4p+41yKye5mYGJ8Gy2zjNRxLR9cACff/OG +IVGOq0B0rEJQ0tWbOl8FLrM= +=3XEk -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 886c84aa99..609190bea3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0888047bb6d9ac55e29b9224df2ff650728bb78 \ No newline at end of file +b82e85ece94c8e25c1dc3251f5444a295fbf8c89 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index ba699632d7..edc716c987 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -119,7 +119,9 @@ #include #include #include +#ifndef SQLITE_OMIT_WAL #include +#endif #if SQLITE_ENABLE_LOCKING_STYLE # include From b9a93d70b822b9a75d184c9b930d6356d1287ec0 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 Dec 2010 15:49:27 +0000 Subject: [PATCH 24/82] Reduce the number of calls to sqlite3_realloc() made by fts3 when querying for position information of a term prefix. FossilOrigin-Name: 7088d9450f403f12f67eed558e368573101245d6 --- ext/fts3/fts3_write.c | 2 +- install-sh | 0 manifest | 30 ++++++++++-------------------- manifest.uuid | 2 +- test/progress.test | 0 tool/mkopts.tcl | 0 6 files changed, 12 insertions(+), 22 deletions(-) mode change 100755 => 100644 install-sh mode change 100644 => 100755 test/progress.test mode change 100644 => 100755 tool/mkopts.tcl diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 9b3d9ba7a0..3120a80c58 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -2240,7 +2240,7 @@ int sqlite3Fts3SegReaderIterate( nByte = sqlite3Fts3VarintLen(iDocid-iPrev) + (isRequirePos?nList+1:0); if( nDoclist+nByte>nAlloc ){ char *aNew; - nAlloc = nDoclist+nByte*2; + nAlloc = (nDoclist+nByte)*2; aNew = sqlite3_realloc(aBuffer, nAlloc); if( !aNew ){ rc = SQLITE_NOMEM; diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 5894989f76..b66e26ff09 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Do\snot\sinclude\s<sys/mmap.h>\sif\sSQLITE_OMIT_WAL\sis\sdefined. -D 2010-12-22T21:48:51 +C Reduce\sthe\snumber\sof\scalls\sto\ssqlite3_realloc()\smade\sby\sfts3\swhen\squerying\sfor\sposition\sinformation\sof\sa\sterm\sprefix. +D 2010-12-24T15:49:28 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -76,7 +73,7 @@ F ext/fts3/fts3_snippet.c 3a26a835732619b62f3af1b73f96d017f8651f9f F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d -F ext/fts3/fts3_write.c 13012755d59e5d4f09a41fd3b5ad17de7dafe3e7 +F ext/fts3/fts3_write.c 1fd0988538fb3b40009a99068148e63cec7426aa F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -100,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -591,7 +588,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -872,7 +869,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl 03b6ca938c833814923674d8a160e91fcedb4571 @@ -897,14 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b0888047bb6d9ac55e29b9224df2ff650728bb78 -R 0a946df43b3c238f90360fc25b951e41 -U drh -Z 3ea172d138576a025bf2ce93fc7e3eec ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNEnJJoxKgR168RlERAn0IAJ4p+41yKye5mYGJ8Gy2zjNRxLR9cACff/OG -IVGOq0B0rEJQ0tWbOl8FLrM= -=3XEk ------END PGP SIGNATURE----- +P b82e85ece94c8e25c1dc3251f5444a295fbf8c89 +R ce7cb30b15477376bb0e944cbe48b806 +U dan +Z 4a4d34a31e9e8331938c1d98dd8bbb1f diff --git a/manifest.uuid b/manifest.uuid index 609190bea3..a9a0998e75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b82e85ece94c8e25c1dc3251f5444a295fbf8c89 \ No newline at end of file +7088d9450f403f12f67eed558e368573101245d6 \ No newline at end of file diff --git a/test/progress.test b/test/progress.test old mode 100644 new mode 100755 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100644 new mode 100755 From 72903821e35bdb2cee10f7db503f0441396453ce Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 29 Dec 2010 10:49:46 +0000 Subject: [PATCH 25/82] Fix some off-by-one errors in the comments for API functions create_function() and value_blob(). No changes to code or tests. FossilOrigin-Name: 7ded90baeb75db5af83345cd2c31211cbee1e91b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b66e26ff09..5f47b63c48 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\snumber\sof\scalls\sto\ssqlite3_realloc()\smade\sby\sfts3\swhen\squerying\sfor\sposition\sinformation\sof\sa\sterm\sprefix. -D 2010-12-24T15:49:28 +C Fix\ssome\soff-by-one\serrors\sin\sthe\scomments\sfor\sAPI\sfunctions\screate_function()\sand\svalue_blob().\sNo\schanges\sto\scode\sor\stests. +D 2010-12-29T10:49:47 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in 54dd12d0dd8b6a4afd7b3d5a03d36ec64a67b641 +F src/sqlite.h.in b1cee73c93ce5e00bc112a9092f31fb22f5bbdde F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -894,7 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b82e85ece94c8e25c1dc3251f5444a295fbf8c89 -R ce7cb30b15477376bb0e944cbe48b806 +P 7088d9450f403f12f67eed558e368573101245d6 +R 41d13c42705e4dca92c02cfd9c746865 U dan -Z 4a4d34a31e9e8331938c1d98dd8bbb1f +Z 37366d27149e755f493600c08e0d3d27 diff --git a/manifest.uuid b/manifest.uuid index a9a0998e75..d27be57b0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7088d9450f403f12f67eed558e368573101245d6 \ No newline at end of file +7ded90baeb75db5af83345cd2c31211cbee1e91b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 0a6fe2ac2c..77b0aad639 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3411,7 +3411,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt); ** ^(The fifth parameter is an arbitrary pointer. The implementation of the ** function can gain access to this pointer using [sqlite3_user_data()].)^ ** -** ^The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are +** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are ** pointers to C-language functions that implement the SQL function or ** aggregate. ^A scalar SQL function requires an implementation of the xFunc ** callback only; NULL pointers must be passed as the xStep and xFinal @@ -3420,7 +3420,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt); ** SQL function or aggregate, pass NULL poiners for all three function ** callbacks. ** -** ^(If the tenth parameter to sqlite3_create_function_v2() is not NULL, +** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, ** then it is destructor for the application data pointer. ** The destructor is invoked when the function is deleted, either by being ** overloaded or when the database connection closes.)^ @@ -3524,7 +3524,7 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void ** The xFunc (for scalar functions) or xStep (for aggregates) parameters ** to [sqlite3_create_function()] and [sqlite3_create_function16()] ** define callbacks that implement the SQL functions and aggregates. -** The 4th parameter to these callbacks is an array of pointers to +** The 3rd parameter to these callbacks is an array of pointers to ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for ** each parameter to the SQL function. These routines are used to ** extract values from the [sqlite3_value] objects. From b29010cd4f4676ad6b3a6b90681bd8d4113299ee Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 29 Dec 2010 18:24:38 +0000 Subject: [PATCH 26/82] Have testfixture invoke C routine Zipvfs_Init() when creating a new interpreter if SQLITE_ENABLE_ZIPVFS is defined. FossilOrigin-Name: 430635dacfa818e8266a88214aaf60c77862de1c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 5f47b63c48..287040a5de 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\soff-by-one\serrors\sin\sthe\scomments\sfor\sAPI\sfunctions\screate_function()\sand\svalue_blob().\sNo\schanges\sto\scode\sor\stests. -D 2010-12-29T10:49:47 +C Have\stestfixture\sinvoke\sC\sroutine\sZipvfs_Init()\swhen\screating\sa\snew\sinterpreter\sif\sSQLITE_ENABLE_ZIPVFS\sis\sdefined. +D 2010-12-29T18:24:39 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e -F src/tclsqlite.c 77c5c4b8ac7b2d94ee480e1ad626fbd921d948e4 +F src/tclsqlite.c 549859dc2c143f3deb6a92636a2d27973652c164 F src/test1.c 397809a3069c171a507a49b6f6edfc4255b0afbc F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc @@ -894,7 +894,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7088d9450f403f12f67eed558e368573101245d6 -R 41d13c42705e4dca92c02cfd9c746865 +P 7ded90baeb75db5af83345cd2c31211cbee1e91b +R d42c36fbd6ce68590e6e0dd8ec4c5c18 U dan -Z 37366d27149e755f493600c08e0d3d27 +Z 8593c64ef1af55c2ba01b9032057e1e5 diff --git a/manifest.uuid b/manifest.uuid index d27be57b0e..23c1ab40b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7ded90baeb75db5af83345cd2c31211cbee1e91b \ No newline at end of file +430635dacfa818e8266a88214aaf60c77862de1c \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 9a6307d8e4..99939c1f26 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3582,6 +3582,11 @@ static void init_all(Tcl_Interp *interp){ extern int Sqlitemultiplex_Init(Tcl_Interp*); extern int SqliteSuperlock_Init(Tcl_Interp*); +#ifdef SQLITE_ENABLE_ZIPVFS + extern int Zipvfs_Init(Tcl_Interp*); + Zipvfs_Init(interp); +#endif + Sqliteconfig_Init(interp); Sqlitetest1_Init(interp); Sqlitetest2_Init(interp); From 8e93b10a4e20d2d4f7683bbc350f39e7ca534e7e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 4 Jan 2011 17:57:53 +0000 Subject: [PATCH 27/82] The ANALYZE command now counts at all rows of an index, even those containing NULL values. A valid sqlite_stat1 entry is created even if the index contains nothing but NULLs. FossilOrigin-Name: 824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3 --- manifest | 25 +++++++++++---- manifest.uuid | 2 +- src/analyze.c | 14 +++++--- test/analyze4.test | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 test/analyze4.test diff --git a/manifest b/manifest index 287040a5de..05d30be4a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Have\stestfixture\sinvoke\sC\sroutine\sZipvfs_Init()\swhen\screating\sa\snew\sinterpreter\sif\sSQLITE_ENABLE_ZIPVFS\sis\sdefined. -D 2010-12-29T18:24:39 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C The\sANALYZE\scommand\snow\scounts\sat\sall\srows\sof\san\sindex,\seven\sthose\scontaining\nNULL\svalues.\s\sA\svalid\ssqlite_stat1\sentry\sis\screated\seven\sif\sthe\sindex\scontains\nnothing\sbut\sNULLs. +D 2011-01-04T17:57:54 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -113,7 +116,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 -F src/analyze.c 1ea594a912a14138e20a05db09d9065e46f29a2a +F src/analyze.c 62ccd3a44e5c303bfa27987c596bfd1136741d81 F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c d5b0137bc20327af08c14772227cc35134839c30 @@ -252,6 +255,7 @@ F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/analyze.test c1eb87067fc16ece7c07e823d6395fd831b270c5 F test/analyze2.test 3bde8f0879d9c1f2df3af21fcf42e706d8ee1e43 F test/analyze3.test 820ddfb7591b49607fbaf77240c7955ac3cabb04 +F test/analyze4.test ce844952931beea75dcd3bd416f3d10444fbcfde F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3 F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e @@ -894,7 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7ded90baeb75db5af83345cd2c31211cbee1e91b -R d42c36fbd6ce68590e6e0dd8ec4c5c18 -U dan -Z 8593c64ef1af55c2ba01b9032057e1e5 +P 430635dacfa818e8266a88214aaf60c77862de1c +R ec45ba633f0c4f96e6a484b9eb344d5c +U drh +Z cde307ce45c85e17f986af467042bf4f +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNI1+moxKgR168RlERAjnJAJ4o8v4Qvkj2Lt5p/tc7Gw/iz0iScACeJQd8 +a939JIEB/46ZOm5/OzfvI/M= +=dmuf +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 23c1ab40b8..ec7d8b96b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -430635dacfa818e8266a88214aaf60c77862de1c \ No newline at end of file +824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 159e323612..96fd4e4703 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -234,8 +234,8 @@ static void analyzeOneTable( for(i=0; imallocFailed ){ /* If a malloc failure has occurred, then the result of the expression @@ -280,7 +282,11 @@ static void analyzeOneTable( } sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); for(i=0; i Date: Tue, 4 Jan 2011 19:01:26 +0000 Subject: [PATCH 28/82] Fix the ANALYZE command so that it takes collating sequences into account when gathering index statistics. FossilOrigin-Name: a5867cfc4c9b9155fa345247dec29e38fffa8002 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/analyze.c | 8 ++++++-- test/analyze4.test | 31 +++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 05d30be4a9..30ce694c15 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C The\sANALYZE\scommand\snow\scounts\sat\sall\srows\sof\san\sindex,\seven\sthose\scontaining\nNULL\svalues.\s\sA\svalid\ssqlite_stat1\sentry\sis\screated\seven\sif\sthe\sindex\scontains\nnothing\sbut\sNULLs. -D 2011-01-04T17:57:54 +C Fix\sthe\sANALYZE\scommand\sso\sthat\sit\stakes\scollating\ssequences\sinto\saccount\nwhen\sgathering\sindex\sstatistics. +D 2011-01-04T19:01:27 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -116,7 +116,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 -F src/analyze.c 62ccd3a44e5c303bfa27987c596bfd1136741d81 +F src/analyze.c a2257126f629615fee6381526d928487b44d628f F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c d5b0137bc20327af08c14772227cc35134839c30 @@ -255,7 +255,7 @@ F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/analyze.test c1eb87067fc16ece7c07e823d6395fd831b270c5 F test/analyze2.test 3bde8f0879d9c1f2df3af21fcf42e706d8ee1e43 F test/analyze3.test 820ddfb7591b49607fbaf77240c7955ac3cabb04 -F test/analyze4.test ce844952931beea75dcd3bd416f3d10444fbcfde +F test/analyze4.test 757b37875cf9bb528d46f74497bc789c88365045 F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3 F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 430635dacfa818e8266a88214aaf60c77862de1c -R ec45ba633f0c4f96e6a484b9eb344d5c +P 824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3 +R d21b60403fa8454869264e5a7d85a460 U drh -Z cde307ce45c85e17f986af467042bf4f +Z 85dcf9c1c5d1988281920e678e21e010 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNI1+moxKgR168RlERAjnJAJ4o8v4Qvkj2Lt5p/tc7Gw/iz0iScACeJQd8 -a939JIEB/46ZOm5/OzfvI/M= -=dmuf +iD8DBQFNI26OoxKgR168RlERAjyZAJ0cxp7jjQMaSBHHPEQ/Ng2xxCrQ6QCeJqqw +pD4g20IkcXJp5ot9VEJNDSI= +=6TbT -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index ec7d8b96b4..e1fc8b066b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3 \ No newline at end of file +a5867cfc4c9b9155fa345247dec29e38fffa8002 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 96fd4e4703..51fd92500c 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -233,6 +233,7 @@ static void analyzeOneTable( sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); for(i=0; iazColl!=0 ); + assert( pIdx->azColl[i]!=0 ); + pColl = sqlite3LocateCollSeq(pParse, pIdx->azColl[i]); + sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1, + (char*)pColl, P4_COLLSEQ); sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); } if( db->mallocFailed ){ diff --git a/test/analyze4.test b/test/analyze4.test index 3919bad760..1fed564b8f 100644 --- a/test/analyze4.test +++ b/test/analyze4.test @@ -14,6 +14,8 @@ # a NULL value count as distinct rows for the purposes of analyze # statistics. # +# Also include test cases for collating sequences on indices. +# set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -77,4 +79,33 @@ do_test analyze4-1.3 { } } {t1a {128 1} t1b {128 128} t1bcd {128 128 4 2} t1cbd {128 4 4 2} t1cdb {128 4 2 2}} +# Verify that collating sequences are taken into account when computing +# ANALYZE statistics. +# +do_test analyze4-2.0 { + db eval { + CREATE TABLE t2( + x INTEGER PRIMARY KEY, + a TEXT COLLATE nocase, + b TEXT COLLATE rtrim, + c TEXT COLLATE binary + ); + CREATE INDEX t2a ON t2(a); + CREATE INDEX t2b ON t2(b); + CREATE INDEX t2c ON t2(c); + CREATE INDEX t2c2 ON t2(c COLLATE nocase); + CREATE INDEX t2c3 ON t2(c COLLATE rtrim); + INSERT INTO t2 VALUES(1, 'abc', 'abc', 'abc'); + INSERT INTO t2 VALUES(2, 'abC', 'abC', 'abC'); + INSERT INTO t2 VALUES(3, 'abc ', 'abc ', 'abc '); + INSERT INTO t2 VALUES(4, 'abC ', 'abC ', 'abC '); + INSERT INTO t2 VALUES(5, 'aBc', 'aBc', 'aBc'); + INSERT INTO t2 VALUES(6, 'aBC', 'aBC', 'aBC'); + INSERT INTO t2 VALUES(7, 'aBc ', 'aBc ', 'aBc '); + INSERT INTO t2 VALUES(8, 'aBC ', 'aBC ', 'aBC '); + ANALYZE; + SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t2' ORDER BY idx; + } +} {t2a {8 4} t2b {8 2} t2c {8 1} t2c2 {8 4} t2c3 {8 2}} + finish_test From 65a0ce16aa2eb4153816ef19836b8ae18906fe3f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 4 Jan 2011 20:06:33 +0000 Subject: [PATCH 29/82] Fix a null-pointer dereference that can occur on an OOM error while running ANALYZE with SQLITE_ENABLE_STAT2. FossilOrigin-Name: 73128d4ef5d7703bf7af0553c307b55dc1b783f6 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/analyze.c | 7 +++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 30ce694c15..494390ee4d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sthe\sANALYZE\scommand\sso\sthat\sit\stakes\scollating\ssequences\sinto\saccount\nwhen\sgathering\sindex\sstatistics. -D 2011-01-04T19:01:27 +C Fix\sa\snull-pointer\sdereference\sthat\scan\soccur\son\san\sOOM\serror\swhile\srunning\nANALYZE\swith\sSQLITE_ENABLE_STAT2. +D 2011-01-04T20:06:33 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -116,7 +116,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 -F src/analyze.c a2257126f629615fee6381526d928487b44d628f +F src/analyze.c 3af3fdb5edea9e69496b078935a3e6a2a1118b30 F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c d5b0137bc20327af08c14772227cc35134839c30 @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3 -R d21b60403fa8454869264e5a7d85a460 +P a5867cfc4c9b9155fa345247dec29e38fffa8002 +R 33920abd29ec7da3a05c7b6407d444e4 U drh -Z 85dcf9c1c5d1988281920e678e21e010 +Z fee44c23be46975276d6ff90647b1cd8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNI26OoxKgR168RlERAjyZAJ0cxp7jjQMaSBHHPEQ/Ng2xxCrQ6QCeJqqw -pD4g20IkcXJp5ot9VEJNDSI= -=6TbT +iD8DBQFNI348oxKgR168RlERArxzAJ48mvtLODhvrcwzodfd2cfkKQoKAgCfTW4G +KYtbHKKaTCI2uRFS5jBRYsE= +=uWmE -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e1fc8b066b..23399c4ad7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a5867cfc4c9b9155fa345247dec29e38fffa8002 \ No newline at end of file +73128d4ef5d7703bf7af0553c307b55dc1b783f6 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 51fd92500c..3693aad833 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -636,8 +636,11 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ if( rc==SQLITE_OK ){ while( sqlite3_step(pStmt)==SQLITE_ROW ){ - char *zIndex = (char *)sqlite3_column_text(pStmt, 0); - Index *pIdx = sqlite3FindIndex(db, zIndex, sInfo.zDatabase); + char *zIndex; /* Index name */ + Index *pIdx; /* Pointer to the index object */ + + zIndex = (char *)sqlite3_column_text(pStmt, 0); + pIdx = zIndex ? sqlite3FindIndex(db, zIndex, sInfo.zDatabase) : 0; if( pIdx ){ int iSample = sqlite3_column_int(pStmt, 1); if( iSample=0 ){ From db26d4c9e1ea6ca98b6cead8a4b3509f7b2c8a49 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 5 Jan 2011 12:20:09 +0000 Subject: [PATCH 30/82] Add the sqlite3_vsnprintf() interface. FossilOrigin-Name: fc67adea414320e0c0b24054f76070cfaeebb401 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/printf.c | 25 ++++++++++++++++--------- src/sqlite.h.in | 3 +++ 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 494390ee4d..c7260b994d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\snull-pointer\sdereference\sthat\scan\soccur\son\san\sOOM\serror\swhile\srunning\nANALYZE\swith\sSQLITE_ENABLE_STAT2. -D 2011-01-04T20:06:33 +C Add\sthe\ssqlite3_vsnprintf()\sinterface. +D 2011-01-05T12:20:09 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,13 +173,13 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c e9578a3beac26f229ee558a4e16c863f2498185f F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc -F src/printf.c 8ae5082dd38a1b5456030c3755ec3a392cd51506 +F src/printf.c 37e8bfd4c5a04eae4960adbe776b0f1fc4cad674 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in b1cee73c93ce5e00bc112a9092f31fb22f5bbdde +F src/sqlite.h.in 8ee5a78674f9b78a59a0313197a46892204e3407 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a5867cfc4c9b9155fa345247dec29e38fffa8002 -R 33920abd29ec7da3a05c7b6407d444e4 +P 73128d4ef5d7703bf7af0553c307b55dc1b783f6 +R 22f3c024ddce8fb34edcc7b2ba2f47cc U drh -Z fee44c23be46975276d6ff90647b1cd8 +Z 7a7101ec3b07503edbe1e87dcccedd8b -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNI348oxKgR168RlERArxzAJ48mvtLODhvrcwzodfd2cfkKQoKAgCfTW4G -KYtbHKKaTCI2uRFS5jBRYsE= -=uWmE +iD8DBQFNJGH9oxKgR168RlERApc5AJ0YgtPklZ+P441lEcNlotS284XXhwCdF7KS +vpLjG17hnHrqRDNqDYunPRg= +=hyLY -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 23399c4ad7..adfaf67b0f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73128d4ef5d7703bf7af0553c307b55dc1b783f6 \ No newline at end of file +fc67adea414320e0c0b24054f76070cfaeebb401 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index da2fdf610d..755355de0c 100644 --- a/src/printf.c +++ b/src/printf.c @@ -934,21 +934,28 @@ char *sqlite3_mprintf(const char *zFormat, ...){ ** current locale settings. This is important for SQLite because we ** are not able to use a "," as the decimal point in place of "." as ** specified by some locales. +** +** Oops: The first two arguments of sqlite3_snprintf() are backwards +** from the snprintf() standard. Unfortunately, it is too late to change +** this without breaking compatibility, so we just have to live with the +** mistake. +** +** sqlite3_vsnprintf() is the varargs version. */ +char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){ + StrAccum acc; + if( n<=0 ) return zBuf; + sqlite3StrAccumInit(&acc, zBuf, n, 0); + acc.useMalloc = 0; + sqlite3VXPrintf(&acc, 0, zFormat, ap); + return sqlite3StrAccumFinish(&acc); +} char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ char *z; va_list ap; - StrAccum acc; - - if( n<=0 ){ - return zBuf; - } - sqlite3StrAccumInit(&acc, zBuf, n, 0); - acc.useMalloc = 0; va_start(ap,zFormat); - sqlite3VXPrintf(&acc, 0, zFormat, ap); + z = sqlite3_vsnprintf(n, zBuf, zFormat, ap); va_end(ap); - z = sqlite3StrAccumFinish(&acc); return z; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 77b0aad639..5aaeb4a10f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1861,6 +1861,8 @@ void sqlite3_free_table(char **result); ** the zero terminator. So the longest string that can be completely ** written will be n-1 characters. ** +** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). +** ** These routines all implement some additional formatting ** options that are useful for constructing SQL statements. ** All of the usual printf() formatting options apply. In addition, there @@ -1924,6 +1926,7 @@ void sqlite3_free_table(char **result); char *sqlite3_mprintf(const char*,...); char *sqlite3_vmprintf(const char*, va_list); char *sqlite3_snprintf(int,char*,const char*, ...); +char *sqlite3_vsnprintf(int,char*,const char*, va_list); /* ** CAPI3REF: Memory Allocation Subsystem From 8a3d62224c8463d70044f439cc3bcddc04440c62 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 5 Jan 2011 13:43:23 +0000 Subject: [PATCH 31/82] Increment the version number to 3.7.5. FossilOrigin-Name: 9ec3896e2fda5b04e609300463dc5b6e79d6cff1 --- VERSION | 2 +- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- tool/shell1.test | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index 0833a98f14..aaf18d2948 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.7.4 +3.7.5 diff --git a/manifest b/manifest index c7260b994d..f59101160b 100644 --- a/manifest +++ b/manifest @@ -1,14 +1,14 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sthe\ssqlite3_vsnprintf()\sinterface. -D 2011-01-05T12:20:09 +C Increment\sthe\sversion\snumber\sto\s3.7.5. +D 2011-01-05T13:43:24 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 -F VERSION 3466c92381170cedd7c04fc6ac2760b53a61cde9 +F VERSION de8d3477dbf0d6cc226ccc6e046273627eb55fc5 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 17dc593f791f874d2c23a0f9360850ded0286531 F art/2005osaward.gif 0d1851b2a7c1c9d0ccce545f3e14bca42d7fd248 @@ -881,7 +881,7 @@ F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a -F tool/shell1.test 6c66ada564076681d38cba7eb00468e72a4764f4 +F tool/shell1.test c31b0814a9c543db51ca0cc63edb5e77ea532303 F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3 F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836 F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 73128d4ef5d7703bf7af0553c307b55dc1b783f6 -R 22f3c024ddce8fb34edcc7b2ba2f47cc +P fc67adea414320e0c0b24054f76070cfaeebb401 +R b51bcff3419da43413c66f28a4b457e3 U drh -Z 7a7101ec3b07503edbe1e87dcccedd8b +Z 2557ea75f46cff086921c5cb180d1215 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJGH9oxKgR168RlERApc5AJ0YgtPklZ+P441lEcNlotS284XXhwCdF7KS -vpLjG17hnHrqRDNqDYunPRg= -=hyLY +iD8DBQFNJHWAoxKgR168RlERAoy1AJ9uLWl2o3iLADUipTYKkyjr8TgZUACeN166 +VPCKM2cZ5hq8bpokjQkRLp4= +=u7CG -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index adfaf67b0f..858417fa43 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc67adea414320e0c0b24054f76070cfaeebb401 \ No newline at end of file +9ec3896e2fda5b04e609300463dc5b6e79d6cff1 \ No newline at end of file diff --git a/tool/shell1.test b/tool/shell1.test index 37c78d18e7..e33013d67d 100644 --- a/tool/shell1.test +++ b/tool/shell1.test @@ -200,7 +200,7 @@ do_test shell1-1.15.3 { # -version show SQLite version do_test shell1-1.16.1 { catchcmd "-version test.db" "" -} {0 3.7.3} +} {0 3.7.5} #---------------------------------------------------------------------------- # Test cases shell1-2.*: Basic "dot" command token parsing. From 100335be779cdd5b86b9c83ed3572b894a78d42f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 5 Jan 2011 21:20:52 +0000 Subject: [PATCH 32/82] Enhancements to the "showdb" debugging tool. Add the ability to display the content of a cell. FossilOrigin-Name: e9023a4e1edd552a81dcb2dcd5a996edfa167709 --- manifest | 18 ++++----- manifest.uuid | 2 +- tool/showdb.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 104 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index f59101160b..17245878b6 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Increment\sthe\sversion\snumber\sto\s3.7.5. -D 2011-01-05T13:43:24 +C Enhancements\sto\sthe\s"showdb"\sdebugging\stool.\s\sAdd\sthe\sability\sto\sdisplay\nthe\scontent\sof\sa\scell. +D 2011-01-05T21:20:52 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -886,7 +886,7 @@ F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3 F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836 F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce F tool/shell5.test 62bfaf9267296da1b91e4b1c03e44e7b393f6a94 -F tool/showdb.c c7a978cf525ef0f8bc2fd29cd52108dd1dfa605a +F tool/showdb.c 1496ea81d21072633fd559e3f39262d2392dc069 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P fc67adea414320e0c0b24054f76070cfaeebb401 -R b51bcff3419da43413c66f28a4b457e3 +P 9ec3896e2fda5b04e609300463dc5b6e79d6cff1 +R e186367957c82f3f2e1fafed8df69dbf U drh -Z 2557ea75f46cff086921c5cb180d1215 +Z cd277adeb367840ebc217b239c3df117 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJHWAoxKgR168RlERAoy1AJ9uLWl2o3iLADUipTYKkyjr8TgZUACeN166 -VPCKM2cZ5hq8bpokjQkRLp4= -=u7CG +iD8DBQFNJOC3oxKgR168RlERAqoaAJ0WxGOj5UtyDg8CWCSQ3WoqPL2v+ACggqUJ +bS9FcHu8epTJHsJhYAEdEvE= +=TSIi -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 858417fa43..4b46b0b4ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ec3896e2fda5b04e609300463dc5b6e79d6cff1 \ No newline at end of file +e9023a4e1edd552a81dcb2dcd5a996edfa167709 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index f313b1aff9..b54d2e1525 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -180,39 +180,110 @@ static void print_db_header(void){ print_decode_line(aData, 96, 4, "SQLite version number"); } +/* +** Describe cell content. +*/ +static int describeContent( + unsigned char *a, + char *zDesc +){ + int nDesc = 0; + int n, i, j; + i64 x, v; + const unsigned char *pData; + char sep = ' '; + + n = decodeVarint(a, &x); + pData = &a[x]; + a += n; + i = x - n; + while( i>0 ){ + n = decodeVarint(a, &x); + a += n; + i -= n; + zDesc[0] = sep; + sep = ','; + nDesc++; + zDesc++; + if( x==0 ){ + sprintf(zDesc, "null"); + }else if( x>=1 && x<=6 ){ + v = (signed char)pData[0]; + pData++; + switch( x ){ + case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 4: v = (v<<8) + pData[0]; pData++; + case 3: v = (v<<8) + pData[0]; pData++; + case 2: v = (v<<8) + pData[0]; pData++; + } + sprintf(zDesc, "%lld", v); + }else if( x==7 ){ + sprintf(zDesc, "real"); + pData += 8; + }else if( x==8 ){ + sprintf(zDesc, "0"); + }else if( x==9 ){ + sprintf(zDesc, "1"); + }else if( x>=12 ){ + int size = (x-12)/2; + if( x&1 ){ + sprintf(zDesc, "blob(%d)", size); + }else{ + sprintf(zDesc, "text(%d)", size); + } + pData += size; + } + j = strlen(zDesc); + zDesc += j; + nDesc += j; + } + return nDesc; +} + + /* ** Create a description for a single cell. */ -static int describeCell(unsigned char cType, unsigned char *a, char **pzDesc){ +static int describeCell( + unsigned char cType, /* Page type */ + unsigned char *a, /* Cell content */ + int showCellContent, /* Show cell content if true */ + char **pzDesc /* Store description here */ +){ int i; int nDesc = 0; int n = 0; int leftChild; i64 nPayload; i64 rowid; - static char zDesc[100]; + int nLocal; + static char zDesc[1000]; i = 0; if( cType<=5 ){ leftChild = ((a[0]*256 + a[1])*256 + a[2])*256 + a[3]; a += 4; n += 4; - sprintf(zDesc, "left-child: %d ", leftChild); + sprintf(zDesc, "lx: %d ", leftChild); nDesc = strlen(zDesc); } if( cType!=5 ){ i = decodeVarint(a, &nPayload); a += i; n += i; - sprintf(&zDesc[nDesc], "sz: %lld ", nPayload); + sprintf(&zDesc[nDesc], "n: %lld ", nPayload); nDesc += strlen(&zDesc[nDesc]); } if( cType==5 || cType==13 ){ i = decodeVarint(a, &rowid); a += i; n += i; - sprintf(&zDesc[nDesc], "rowid: %lld ", rowid); + sprintf(&zDesc[nDesc], "r: %lld ", rowid); nDesc += strlen(&zDesc[nDesc]); } + if( showCellContent && cType!=5 ){ + nDesc += describeContent(a, &zDesc[nDesc]); + } *pzDesc = zDesc; return n; } @@ -220,17 +291,29 @@ static int describeCell(unsigned char cType, unsigned char *a, char **pzDesc){ /* ** Decode a btree page */ -static void decode_btree_page(unsigned char *a, int pgno, int hdrSize){ +static void decode_btree_page( + unsigned char *a, /* Page content */ + int pgno, /* Page number */ + int hdrSize, /* Size of the page header. 0 or 100 */ + char *zArgs /* Flags to control formatting */ +){ const char *zType = "unknown"; int nCell; int i; int iCellPtr; + int showCellContent = 0; switch( a[0] ){ case 2: zType = "index interior node"; break; case 5: zType = "table interior node"; break; case 10: zType = "index leaf"; break; case 13: zType = "table leaf"; break; } + while( zArgs[0] ){ + switch( zArgs[0] ){ + case 'c': showCellContent = 1; break; + } + zArgs++; + } printf("Decode of btree page %d:\n", pgno); print_decode_line(a, 0, 1, zType); print_decode_line(a, 1, 2, "Offset to first freeblock"); @@ -238,6 +321,9 @@ static void decode_btree_page(unsigned char *a, int pgno, int hdrSize){ nCell = a[3]*256 + a[4]; print_decode_line(a, 5, 2, "Offset to cell content area"); print_decode_line(a, 7, 1, "Fragmented byte count"); + if( nCell>0 ){ + printf(" key: lx=left-child n=payload-size r=rowid\n"); + } if( a[0]==2 || a[0]==5 ){ print_decode_line(a, 8, 4, "Right child"); iCellPtr = 12; @@ -248,7 +334,7 @@ static void decode_btree_page(unsigned char *a, int pgno, int hdrSize){ int cofst = iCellPtr + i*2; char *zDesc; cofst = a[cofst]*256 + a[cofst+1]; - describeCell(a[0], &a[cofst-hdrSize], &zDesc); + describeCell(a[0], &a[cofst-hdrSize], showCellContent, &zDesc); printf(" %03x: cell[%d] %s\n", cofst, i, zDesc); } } @@ -361,7 +447,7 @@ int main(int argc, char **argv){ nByte = pagesize; } a = getContent(ofst, nByte); - decode_btree_page(a, iStart, hdrSize); + decode_btree_page(a, iStart, hdrSize, &zLeft[1]); free(a); continue; }else if( zLeft && zLeft[0]=='t' ){ From b2c062df719730b1a0f140d12df443ecf880919b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 5 Jan 2011 21:46:52 +0000 Subject: [PATCH 33/82] Fix a bug in the showdb utility: the serial types for BLOB and TEXT where reversed. FossilOrigin-Name: 65a13faf1e3cd18f3459cd410f65d334cfa7c376 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- tool/showdb.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 17245878b6..fe4cfc2a84 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Enhancements\sto\sthe\s"showdb"\sdebugging\stool.\s\sAdd\sthe\sability\sto\sdisplay\nthe\scontent\sof\sa\scell. -D 2011-01-05T21:20:52 +C Fix\sa\sbug\sin\sthe\sshowdb\sutility:\sthe\sserial\stypes\sfor\sBLOB\sand\sTEXT\swhere\nreversed. +D 2011-01-05T21:46:53 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -886,7 +886,7 @@ F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3 F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836 F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce F tool/shell5.test 62bfaf9267296da1b91e4b1c03e44e7b393f6a94 -F tool/showdb.c 1496ea81d21072633fd559e3f39262d2392dc069 +F tool/showdb.c 2f4d20922d1047530f3c6843a8d5973dbc7d8216 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9ec3896e2fda5b04e609300463dc5b6e79d6cff1 -R e186367957c82f3f2e1fafed8df69dbf +P e9023a4e1edd552a81dcb2dcd5a996edfa167709 +R 8dba7658a57757c37f21c1db4903dcb5 U drh -Z cd277adeb367840ebc217b239c3df117 +Z df7dfd891fb3ff873623731883eb9291 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJOC3oxKgR168RlERAqoaAJ0WxGOj5UtyDg8CWCSQ3WoqPL2v+ACggqUJ -bS9FcHu8epTJHsJhYAEdEvE= -=TSIi +iD8DBQFNJObRoxKgR168RlERAlvgAJwJBI65HjFeJ29eAiEYGnhONZD3qgCff9Rz +zfYRaCzJT4SENwO7E6/i8Qk= +=/6Az -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4b46b0b4ac..c7ca973cd9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e9023a4e1edd552a81dcb2dcd5a996edfa167709 \ No newline at end of file +65a13faf1e3cd18f3459cd410f65d334cfa7c376 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index b54d2e1525..cdffa82d35 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -227,7 +227,7 @@ static int describeContent( sprintf(zDesc, "1"); }else if( x>=12 ){ int size = (x-12)/2; - if( x&1 ){ + if( (x&1)==0 ){ sprintf(zDesc, "blob(%d)", size); }else{ sprintf(zDesc, "text(%d)", size); From 5240aebdd8bfab6989f835db83b66c42a95ecdea Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Jan 2011 01:26:38 +0000 Subject: [PATCH 34/82] Enhance the showdb tool to show a btree page layout. Add limit checks so that overflow content does not overflow the buffer. FossilOrigin-Name: 57ffa07e26a26d2f4527c8e6d7a9c1f48f380bf7 --- manifest | 18 +++++----- manifest.uuid | 2 +- tool/showdb.c | 94 ++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 91 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index fe4cfc2a84..6f28a148f5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\sbug\sin\sthe\sshowdb\sutility:\sthe\sserial\stypes\sfor\sBLOB\sand\sTEXT\swhere\nreversed. -D 2011-01-05T21:46:53 +C Enhance\sthe\sshowdb\stool\sto\sshow\sa\sbtree\spage\slayout.\s\sAdd\slimit\schecks\sso\sthat\noverflow\scontent\sdoes\snot\soverflow\sthe\sbuffer. +D 2011-01-06T01:26:38 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -886,7 +886,7 @@ F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3 F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836 F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce F tool/shell5.test 62bfaf9267296da1b91e4b1c03e44e7b393f6a94 -F tool/showdb.c 2f4d20922d1047530f3c6843a8d5973dbc7d8216 +F tool/showdb.c 65c209d59aa1e5d6c43e8d5f3a1a5d1521b83bd1 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e9023a4e1edd552a81dcb2dcd5a996edfa167709 -R 8dba7658a57757c37f21c1db4903dcb5 +P 65a13faf1e3cd18f3459cd410f65d334cfa7c376 +R 80317cc5c88d48103f5881daa67068e5 U drh -Z df7dfd891fb3ff873623731883eb9291 +Z 959c94bb95cb816dc6454b5126d5e277 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJObRoxKgR168RlERAlvgAJwJBI65HjFeJ29eAiEYGnhONZD3qgCff9Rz -zfYRaCzJT4SENwO7E6/i8Qk= -=/6Az +iD8DBQFNJRpRoxKgR168RlERAneLAJ0Ubz3gvmcO85uJHJOXqW1k9GkMcwCdE1AW +B34z8WqDcDzvAiuG+61UwD4= +=HyMh -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index c7ca973cd9..a922e669e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65a13faf1e3cd18f3459cd410f65d334cfa7c376 \ No newline at end of file +57ffa07e26a26d2f4527c8e6d7a9c1f48f380bf7 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index cdffa82d35..8ccef76ced 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -57,7 +57,7 @@ static void out_of_memory(void){ */ static unsigned char *getContent(int ofst, int nByte){ unsigned char *aData; - aData = malloc(nByte); + aData = malloc(nByte+32); if( aData==0 ) out_of_memory(); lseek(db, ofst, SEEK_SET); read(db, aData, nByte); @@ -184,29 +184,33 @@ static void print_db_header(void){ ** Describe cell content. */ static int describeContent( - unsigned char *a, - char *zDesc + unsigned char *a, /* Cell content */ + int nLocal, /* Bytes in a[] */ + char *zDesc /* Write description here */ ){ int nDesc = 0; int n, i, j; i64 x, v; const unsigned char *pData; + const unsigned char *pLimit; char sep = ' '; + pLimit = &a[nLocal]; n = decodeVarint(a, &x); pData = &a[x]; a += n; i = x - n; - while( i>0 ){ + while( i>0 && pData<=pLimit ){ n = decodeVarint(a, &x); a += n; i -= n; + nLocal -= n; zDesc[0] = sep; sep = ','; nDesc++; zDesc++; if( x==0 ){ - sprintf(zDesc, "null"); + sprintf(zDesc, "*"); /* NULL is a "*" */ }else if( x>=1 && x<=6 ){ v = (signed char)pData[0]; pData++; @@ -230,7 +234,7 @@ static int describeContent( if( (x&1)==0 ){ sprintf(zDesc, "blob(%d)", size); }else{ - sprintf(zDesc, "text(%d)", size); + sprintf(zDesc, "txt(%d)", size); } pData += size; } @@ -240,10 +244,42 @@ static int describeContent( } return nDesc; } + +/* +** Compute the local payload size given the total payload size and +** the page size. +*/ +static int localPayload(i64 nPayload, char cType){ + int maxLocal; + int minLocal; + int surplus; + int nLocal; + if( cType==13 ){ + /* Table leaf */ + maxLocal = pagesize-35; + minLocal = (pagesize-12)*32/255-23; + }else{ + maxLocal = (pagesize-12)*64/255-23; + minLocal = (pagesize-12)*32/255-23; + } + if( nPayload>maxLocal ){ + surplus = minLocal + (nPayload-minLocal)%(pagesize-4); + if( surplus<=maxLocal ){ + nLocal = surplus; + }else{ + nLocal = minLocal; + } + }else{ + nLocal = nPayload; + } + return nLocal; +} /* ** Create a description for a single cell. +** +** The return value is the local cell size. */ static int describeCell( unsigned char cType, /* Page type */ @@ -273,6 +309,9 @@ static int describeCell( n += i; sprintf(&zDesc[nDesc], "n: %lld ", nPayload); nDesc += strlen(&zDesc[nDesc]); + nLocal = localPayload(nPayload, cType); + }else{ + nPayload = nLocal = 0; } if( cType==5 || cType==13 ){ i = decodeVarint(a, &rowid); @@ -282,10 +321,10 @@ static int describeCell( nDesc += strlen(&zDesc[nDesc]); } if( showCellContent && cType!=5 ){ - nDesc += describeContent(a, &zDesc[nDesc]); + nDesc += describeContent(a, nLocal, &zDesc[nDesc-1]); } *pzDesc = zDesc; - return n; + return nLocal+n; } /* @@ -299,9 +338,11 @@ static void decode_btree_page( ){ const char *zType = "unknown"; int nCell; - int i; + int i, j; int iCellPtr; int showCellContent = 0; + int showMap = 0; + char *zMap = 0; switch( a[0] ){ case 2: zType = "index interior node"; break; case 5: zType = "table interior node"; break; @@ -311,6 +352,7 @@ static void decode_btree_page( while( zArgs[0] ){ switch( zArgs[0] ){ case 'c': showCellContent = 1; break; + case 'm': showMap = 1; break; } zArgs++; } @@ -321,22 +363,46 @@ static void decode_btree_page( nCell = a[3]*256 + a[4]; print_decode_line(a, 5, 2, "Offset to cell content area"); print_decode_line(a, 7, 1, "Fragmented byte count"); - if( nCell>0 ){ - printf(" key: lx=left-child n=payload-size r=rowid\n"); - } if( a[0]==2 || a[0]==5 ){ print_decode_line(a, 8, 4, "Right child"); iCellPtr = 12; }else{ iCellPtr = 8; } + if( nCell>0 ){ + printf(" key: lx=left-child n=payload-size r=rowid\n"); + } + if( showMap ){ + zMap = malloc(pagesize); + memset(zMap, '.', pagesize); + memset(zMap, '1', hdrSize); + memset(&zMap[hdrSize], 'H', iCellPtr); + memset(&zMap[hdrSize+iCellPtr], 'P', 2*nCell); + } for(i=0; i Date: Thu, 6 Jan 2011 15:51:18 +0000 Subject: [PATCH 35/82] Enhance the showdb tool to show overflow page pointers at the end of overflow cells. FossilOrigin-Name: cda5eab18f48d3836dfd3e1f8c76e5f83b43485f --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- tool/showdb.c | 9 +++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6f28a148f5..a5d974f259 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Enhance\sthe\sshowdb\stool\sto\sshow\sa\sbtree\spage\slayout.\s\sAdd\slimit\schecks\sso\sthat\noverflow\scontent\sdoes\snot\soverflow\sthe\sbuffer. -D 2011-01-06T01:26:38 +C Enhance\sthe\sshowdb\stool\sto\sshow\soverflow\spage\spointers\sat\sthe\send\sof\noverflow\scells. +D 2011-01-06T15:51:19 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -886,7 +886,7 @@ F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3 F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836 F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce F tool/shell5.test 62bfaf9267296da1b91e4b1c03e44e7b393f6a94 -F tool/showdb.c 65c209d59aa1e5d6c43e8d5f3a1a5d1521b83bd1 +F tool/showdb.c 471c0f8fa472e71bb7654500096a5bdb4ea1fb2a F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 65a13faf1e3cd18f3459cd410f65d334cfa7c376 -R 80317cc5c88d48103f5881daa67068e5 +P 57ffa07e26a26d2f4527c8e6d7a9c1f48f380bf7 +R d89e08a20775097580ea6af4c734a279 U drh -Z 959c94bb95cb816dc6454b5126d5e277 +Z 423cd0f908ca695200442e25ae6188b4 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJRpRoxKgR168RlERAneLAJ0Ubz3gvmcO85uJHJOXqW1k9GkMcwCdE1AW -B34z8WqDcDzvAiuG+61UwD4= -=HyMh +iD8DBQFNJeT6oxKgR168RlERAqIMAJ0R7uEoG6ZDNI1Fi1NrZqeT9QSTlACfX5On +3pJ6qRdQvw3bEFgCv0on13s= +=XUQa -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index a922e669e8..6b26b0ccf7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -57ffa07e26a26d2f4527c8e6d7a9c1f48f380bf7 \ No newline at end of file +cda5eab18f48d3836dfd3e1f8c76e5f83b43485f \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index 8ccef76ced..c954153cf2 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -59,6 +59,7 @@ static unsigned char *getContent(int ofst, int nByte){ unsigned char *aData; aData = malloc(nByte+32); if( aData==0 ) out_of_memory(); + memset(aData, 0, nByte+32); lseek(db, ofst, SEEK_SET); read(db, aData, nByte); return aData; @@ -320,6 +321,14 @@ static int describeCell( sprintf(&zDesc[nDesc], "r: %lld ", rowid); nDesc += strlen(&zDesc[nDesc]); } + if( nLocal Date: Fri, 7 Jan 2011 02:50:40 +0000 Subject: [PATCH 36/82] Reorder the fields in private structures in an effort to reduce alignment gaps and thus make the structures smaller, and to put frequently accessed fields first. Also update some obsolete comments. Valgrind shows a very slight performance improvement. FossilOrigin-Name: 378a1d13af4a6f4cb2bfa65944b3b0d444b9f21c --- manifest | 22 ++++++------ manifest.uuid | 2 +- src/btreeInt.h | 16 ++++----- src/vdbeInt.h | 90 ++++++++++++++++++-------------------------------- src/vdbeapi.c | 2 +- 5 files changed, 54 insertions(+), 78 deletions(-) diff --git a/manifest b/manifest index a5d974f259..904f168e94 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Enhance\sthe\sshowdb\stool\sto\sshow\soverflow\spage\spointers\sat\sthe\send\sof\noverflow\scells. -D 2011-01-06T15:51:19 +C Reorder\sthe\sfields\sin\sprivate\sstructures\sin\san\seffort\sto\sreduce\salignment\ngaps\sand\sthus\smake\sthe\sstructures\ssmaller,\sand\sto\sput\sfrequently\saccessed\nfields\sfirst.\s\sAlso\supdate\ssome\sobsolete\scomments.\s\sValgrind\sshows\sa\svery\nslight\sperformance\simprovement. +D 2011-01-07T02:50:40 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c b70bf1dc563ec532851715ce51aa1ea0c0c592b9 F src/btree.h 10f9296bf4edf034f5adce921b7b4383a56a1c90 -F src/btreeInt.h c424f2f131cc61ddf130f9bd736b3df12c8a51f0 +F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 F src/build.c 00a327120d81ace6267e714ae8010c997d55de5d F src/callback.c a1d1b1c9c85415dff013af033e2fed9c8382d33b F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac @@ -233,8 +233,8 @@ F src/util.c ab1c92426494f499f42b9e307537b03e923d75c1 F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f F src/vdbe.c 5d310eaf1a4d8383602126fa82e01291ab7d3cf3 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 -F src/vdbeInt.h 1f2137b905969f4de0648256aeb73abdf88f9213 -F src/vdbeapi.c fb0036185b3c56e15916a5ee96309cd4acf6818f +F src/vdbeInt.h 6e6f28e9bccc6c703dca1372fd661c57b5c15fb0 +F src/vdbeapi.c 0f898cc77099f0b0b4d6a045e905c3501f9c8b27 F src/vdbeaux.c 33448d23b857654dd69ed2103611f5c733606f68 F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 57ffa07e26a26d2f4527c8e6d7a9c1f48f380bf7 -R d89e08a20775097580ea6af4c734a279 +P cda5eab18f48d3836dfd3e1f8c76e5f83b43485f +R b6bb91d8008f3bd40fbfcc333ed6ae8d U drh -Z 423cd0f908ca695200442e25ae6188b4 +Z b9332de9f4f0b427c676c0d723aec735 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJeT6oxKgR168RlERAqIMAJ0R7uEoG6ZDNI1Fi1NrZqeT9QSTlACfX5On -3pJ6qRdQvw3bEFgCv0on13s= -=XUQa +iD8DBQFNJn+EoxKgR168RlERArozAJ488YVf31pNpQTakJkJq0sV2ZJnxQCfW6sh +hZ8upDwsMRzRPHR7Truah5Q= +=G69s -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 6b26b0ccf7..0814d081fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cda5eab18f48d3836dfd3e1f8c76e5f83b43485f \ No newline at end of file +378a1d13af4a6f4cb2bfa65944b3b0d444b9f21c \ No newline at end of file diff --git a/src/btreeInt.h b/src/btreeInt.h index 59597faecb..0e71195b0a 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -414,12 +414,12 @@ struct BtShared { u8 autoVacuum; /* True if auto-vacuum is enabled */ u8 incrVacuum; /* True if incr-vacuum is enabled */ #endif + u8 inTransaction; /* Transaction state */ + u8 doNotUseWAL; /* If true, do not open write-ahead-log file */ u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */ u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */ u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */ u16 minLeaf; /* Minimum local payload in a LEAFDATA table */ - u8 inTransaction; /* Transaction state */ - u8 doNotUseWAL; /* If true, do not open write-ahead-log file */ u32 pageSize; /* Total number of bytes on a page */ u32 usableSize; /* Number of usable bytes on each page */ int nTransaction; /* Number of open transactions (read + write) */ @@ -446,8 +446,8 @@ struct BtShared { */ typedef struct CellInfo CellInfo; struct CellInfo { - u8 *pCell; /* Pointer to the start of cell content */ i64 nKey; /* The key for INTKEY tables, or number of bytes in key */ + u8 *pCell; /* Pointer to the start of cell content */ u32 nData; /* Number of bytes of data */ u32 nPayload; /* Total amount of payload */ u16 nHeader; /* Size of the cell content header in bytes */ @@ -489,20 +489,20 @@ struct BtCursor { Pgno pgnoRoot; /* The root page of this tree */ sqlite3_int64 cachedRowid; /* Next rowid cache. 0 means not valid */ CellInfo info; /* A parse of the cell we are pointing at */ + i64 nKey; /* Size of pKey, or last integer key */ + void *pKey; /* Saved key that was cursor's last known position */ + int skipNext; /* Prev() is noop if negative. Next() is noop if positive */ u8 wrFlag; /* True if writable */ u8 atLast; /* Cursor pointing to the last entry */ u8 validNKey; /* True if info.nKey is valid */ u8 eState; /* One of the CURSOR_XXX constants (see below) */ - void *pKey; /* Saved key that was cursor's last known position */ - i64 nKey; /* Size of pKey, or last integer key */ - int skipNext; /* Prev() is noop if negative. Next() is noop if positive */ #ifndef SQLITE_OMIT_INCRBLOB - u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */ Pgno *aOverflow; /* Cache of overflow page locations */ + u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */ #endif i16 iPage; /* Index of current page in apPage */ - MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ u16 aiIdx[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ + MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ }; /* diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 765852aaef..b42729d236 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -39,16 +39,14 @@ typedef unsigned char Bool; ** ** Every cursor that the virtual machine has open is represented by an ** instance of the following structure. -** -** If the VdbeCursor.isTriggerRow flag is set it means that this cursor is -** really a single row that represents the NEW or OLD pseudo-table of -** a row trigger. The data for the row is stored in VdbeCursor.pData and -** the rowid is in VdbeCursor.iKey. */ struct VdbeCursor { BtCursor *pCursor; /* The cursor structure of the backend */ + Btree *pBt; /* Separate file holding temporary table */ + KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */ int iDb; /* Index of cursor database in db->aDb[] (or -1) */ - i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ + int pseudoTableReg; /* Register holding pseudotable content. */ + int nField; /* Number of fields in the header */ Bool zeroed; /* True if zeroed out and ready for reuse */ Bool rowidIsValid; /* True if lastRowid is valid */ Bool atFirst; /* True if pointing to first entry */ @@ -58,14 +56,11 @@ struct VdbeCursor { Bool isTable; /* True if a table requiring integer keys */ Bool isIndex; /* True if an index containing keys only - no data */ Bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ - i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ - Btree *pBt; /* Separate file holding temporary table */ - int pseudoTableReg; /* Register holding pseudotable content. */ - KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */ - int nField; /* Number of fields in the header */ - i64 seqCount; /* Sequence counter */ sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */ const sqlite3_module *pModule; /* Module for cursor pVtabCursor */ + i64 seqCount; /* Sequence counter */ + i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ + i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or ** OP_IsUnique opcode on this cursor. */ @@ -137,25 +132,19 @@ struct VdbeFrame { /* ** Internally, the vdbe manipulates nearly all SQL values as Mem ** structures. Each Mem struct may cache multiple representations (string, -** integer etc.) of the same value. A value (and therefore Mem structure) -** has the following properties: -** -** Each value has a manifest type. The manifest type of the value stored -** in a Mem struct is returned by the MemType(Mem*) macro. The type is -** one of SQLITE_NULL, SQLITE_INTEGER, SQLITE_REAL, SQLITE_TEXT or -** SQLITE_BLOB. +** integer etc.) of the same value. */ struct Mem { + sqlite3 *db; /* The associated database connection */ + char *z; /* String or BLOB value */ + double r; /* Real value */ union { - i64 i; /* Integer value. */ + i64 i; /* Integer value used when MEM_Int is set in flags */ int nZero; /* Used when bit MEM_Zero is set in flags */ FuncDef *pDef; /* Used only when flags==MEM_Agg */ RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ } u; - double r; /* Real value */ - sqlite3 *db; /* The associated database connection */ - char *z; /* String or BLOB value */ int n; /* Number of characters in string value, excluding '\0' */ u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ u8 type; /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */ @@ -179,9 +168,6 @@ struct Mem { ** database (see below for exceptions). If the MEM_Term flag is also ** set, then the string is nul terminated. The MEM_Int and MEM_Real ** flags may coexist with the MEM_Str flag. -** -** Multiple of these values can appear in Mem.flags. But only one -** at a time can appear in Mem.type. */ #define MEM_Null 0x0001 /* Value is NULL */ #define MEM_Str 0x0002 /* Value is a string */ @@ -264,23 +250,11 @@ struct sqlite3_context { CollSeq *pColl; /* Collating sequence */ }; -/* -** A Set structure is used for quick testing to see if a value -** is part of a small set. Sets are used to implement code like -** this: -** x.y IN ('hi','hoo','hum') -*/ -typedef struct Set Set; -struct Set { - Hash hash; /* A set is just a hash table */ - HashElem *prev; /* Previously accessed hash elemen */ -}; - /* ** An instance of the virtual machine. This structure contains the complete ** state of the virtual machine. ** -** The "sqlite3_stmt" structure pointer that is returned by sqlite3_compile() +** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() ** is really a pointer to an instance of this structure. ** ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of @@ -293,31 +267,31 @@ struct Set { */ struct Vdbe { sqlite3 *db; /* The database connection that owns this statement */ - Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ - int nOp; /* Number of instructions in the program */ - int nOpAlloc; /* Number of slots allocated for aOp[] */ Op *aOp; /* Space to hold the virtual machine's program */ - int nLabel; /* Number of labels used */ - int nLabelAlloc; /* Number of slots allocated in aLabel[] */ - int *aLabel; /* Space to hold the labels */ + Mem *aMem; /* The memory locations */ Mem **apArg; /* Arguments to currently executing user function */ Mem *aColName; /* Column names to return */ Mem *pResultSet; /* Pointer to an array of results */ + int nMem; /* Number of memory locations currently allocated */ + int nOp; /* Number of instructions in the program */ + int nOpAlloc; /* Number of slots allocated for aOp[] */ + int nLabel; /* Number of labels used */ + int nLabelAlloc; /* Number of slots allocated in aLabel[] */ + int *aLabel; /* Space to hold the labels */ u16 nResColumn; /* Number of columns in one row of the result set */ u16 nCursor; /* Number of slots in apCsr[] */ + u32 magic; /* Magic number for sanity checking */ + char *zErrMsg; /* Error message written here */ + Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ VdbeCursor **apCsr; /* One element of this array for each open cursor */ - u8 errorAction; /* Recovery action to do in case of an error */ - u8 okVar; /* True if azVar[] has been initialized */ - ynVar nVar; /* Number of entries in aVar[] */ Mem *aVar; /* Values for the OP_Variable opcode. */ char **azVar; /* Name of variables */ - u32 magic; /* Magic number for sanity checking */ - int nMem; /* Number of memory locations currently allocated */ - Mem *aMem; /* The memory locations */ + ynVar nVar; /* Number of entries in aVar[] */ u32 cacheCtr; /* VdbeCursor row cache generation counter */ int pc; /* The program counter */ int rc; /* Value to return */ - char *zErrMsg; /* Error message written here */ + u8 errorAction; /* Recovery action to do in case of an error */ + u8 okVar; /* True if azVar[] has been initialized */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ @@ -329,14 +303,16 @@ struct Vdbe { u8 isPrepareV2; /* True if prepared with prepare_v2() */ int nChange; /* Number of db changes made since last reset */ int btreeMask; /* Bitmask of db->aDb[] entries referenced */ - i64 startTime; /* Time when query started - used for profiling */ - BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ + int iStatement; /* Statement number (or 0 if has not opened stmt) */ int aCounter[3]; /* Counters used by sqlite3_stmt_status() */ - char *zSql; /* Text of the SQL statement that generated this */ - void *pFree; /* Free this when deleting the vdbe */ + BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ +#ifndef SQLITE_OMIT_TRACE + i64 startTime; /* Time when query started - used for profiling */ +#endif i64 nFkConstraint; /* Number of imm. FK constraints this VM */ i64 nStmtDefCons; /* Number of def. constraints when stmt started */ - int iStatement; /* Statement number (or 0 if has not opened stmt) */ + char *zSql; /* Text of the SQL statement that generated this */ + void *pFree; /* Free this when deleting the vdbe */ #ifdef SQLITE_DEBUG FILE *trace; /* Write an execution trace here, if not NULL */ #endif diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 93689ebcee..f08c296d1d 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -685,7 +685,7 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){ #if defined(SQLITE_DEBUG) && defined(__GNUC__) __attribute__((aligned(8))) #endif - = {{0}, (double)0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 }; + = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, 0, 0 }; if( pVm && ALWAYS(pVm->db) ){ sqlite3_mutex_enter(pVm->db->mutex); From 444d26065e66674269c958c73a3c01291a054610 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 10 Jan 2011 21:01:10 +0000 Subject: [PATCH 37/82] Update pager requirements to accound for the ZIPVFS extension. FossilOrigin-Name: d94e59b514c16c5f7ea506e0af1c6e2ffecc13be --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 904f168e94..aeb632010c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Reorder\sthe\sfields\sin\sprivate\sstructures\sin\san\seffort\sto\sreduce\salignment\ngaps\sand\sthus\smake\sthe\sstructures\ssmaller,\sand\sto\sput\sfrequently\saccessed\nfields\sfirst.\s\sAlso\supdate\ssome\sobsolete\scomments.\s\sValgrind\sshows\sa\svery\nslight\sperformance\simprovement. -D 2011-01-07T02:50:40 +C Update\spager\srequirements\sto\saccound\sfor\sthe\sZIPVFS\sextension. +D 2011-01-10T21:01:10.514 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in 8ee5a78674f9b78a59a0313197a46892204e3407 +F src/sqlite.h.in f48408b86c0713bc074b16c83543868688b0e18d F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P cda5eab18f48d3836dfd3e1f8c76e5f83b43485f -R b6bb91d8008f3bd40fbfcc333ed6ae8d +P 378a1d13af4a6f4cb2bfa65944b3b0d444b9f21c +R 9ba476b75f53d677656fa985b1b64795 U drh -Z b9332de9f4f0b427c676c0d723aec735 +Z b1419bbb0387a7a1916f12cb7cb5d1cc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNJn+EoxKgR168RlERArozAJ488YVf31pNpQTakJkJq0sV2ZJnxQCfW6sh -hZ8upDwsMRzRPHR7Truah5Q= -=G69s +iD8DBQFNK3OZoxKgR168RlERAkacAKCMhl6ZxRLBUNTVdjwpBabO5xt6DACdFjqx +fy4uPWEx1WyrV/pu6K1mVzM= +=JPWF -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0814d081fb..e125cf8057 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -378a1d13af4a6f4cb2bfa65944b3b0d444b9f21c \ No newline at end of file +d94e59b514c16c5f7ea506e0af1c6e2ffecc13be \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5aaeb4a10f..0f05a09a33 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5692,11 +5692,13 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** first parameter, szPage, is the size in bytes of the pages that must ** be allocated by the cache. ^szPage will not be a power of two. ^szPage ** will the page size of the database file that is to be cached plus an -** increment (here called "R") of about 100 or 200. SQLite will use the +** increment (here called "R") of less than 250. SQLite will use the ** extra R bytes on each page to store metadata about the underlying ** database page on disk. The value of R depends ** on the SQLite version, the target platform, and how SQLite was compiled. -** ^R is constant for a particular build of SQLite. ^The second argument to +** ^(R is constant for a particular build of SQLite. Except, there are two +** distinct values of R when SQLite is compiled with the proprietary +** ZIPVFS extension.)^ ^The second argument to ** xCreate(), bPurgeable, is true if the cache being created will ** be used to cache database pages of a file stored on disk, or ** false if it is used for an in-memory database. The cache implementation From bbd91944dd7fca17d19afe43ee9e5e982bf58b3a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 11 Jan 2011 12:46:05 +0000 Subject: [PATCH 38/82] Fix the sqlite3.h generator script so that it generates the correct SQLITE_SOURCE_ID string with the latest versions of Fossil that include fractional seconds on the date/time stamp. FossilOrigin-Name: 3513bf6ee090d9be97f60e12a4b39f4361ee17b7 --- install-sh | 0 manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- test/progress.test | 0 tool/mkopts.tcl | 0 tool/mksqlite3h.tcl | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index aeb632010c..310c1dfb95 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Update\spager\srequirements\sto\saccound\sfor\sthe\sZIPVFS\sextension. -D 2011-01-10T21:01:10.514 +C Fix\sthe\ssqlite3.h\sgenerator\sscript\sso\sthat\sit\sgenerates\sthe\scorrect\nSQLITE_SOURCE_ID\sstring\swith\sthe\slatest\sversions\sof\sFossil\sthat\s\ninclude\sfractional\sseconds\son\sthe\sdate/time\sstamp. +D 2011-01-11T12:46:05.980 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -100,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -592,7 +592,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -873,10 +873,10 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 -F tool/mksqlite3h.tcl 03b6ca938c833814923674d8a160e91fcedb4571 +F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 378a1d13af4a6f4cb2bfa65944b3b0d444b9f21c -R 9ba476b75f53d677656fa985b1b64795 +P d94e59b514c16c5f7ea506e0af1c6e2ffecc13be +R f02123c924a142fca1a394313d3028b5 U drh -Z b1419bbb0387a7a1916f12cb7cb5d1cc +Z 6f6ef4dbc6a35c4d5adf4fad0076b217 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNK3OZoxKgR168RlERAkacAKCMhl6ZxRLBUNTVdjwpBabO5xt6DACdFjqx -fy4uPWEx1WyrV/pu6K1mVzM= -=JPWF +iD8DBQFNLFERoxKgR168RlERAifbAJsFaxIQF3cfejQ8x4UPtTJT8QRE3ACfSRFj +QVjUad79/TL7jK/KM05BlxQ= +=ebHi -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e125cf8057..28ec38acbe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d94e59b514c16c5f7ea506e0af1c6e2ffecc13be \ No newline at end of file +3513bf6ee090d9be97f60e12a4b39f4361ee17b7 \ No newline at end of file diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index 88dc8df807..554069c323 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -53,7 +53,7 @@ set in [open $TOP/manifest] set zDate {} while {![eof $in]} { set line [gets $in] - if {[regexp {^D (2.*[0-9])} $line all date]} { + if {[regexp {^D (2[-0-9T:]+)} $line all date]} { set zDate [string map {T { }} $date] break } From 9f4beedb6fcff907e90a5a2ba4d8c3fe3f9af27d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 11 Jan 2011 16:09:55 +0000 Subject: [PATCH 39/82] If a rollback is attempted in journal_mode=off mode, force SQLite to discard the contents of the pager cache before processing any subsequent queries. FossilOrigin-Name: ece7efce2733b4fdd71db385abebbde464ac8f30 --- install-sh | 0 manifest | 30 ++++++++++-------------------- manifest.uuid | 2 +- src/pager.c | 10 ++++++++++ test/progress.test | 0 tool/mkopts.tcl | 0 6 files changed, 21 insertions(+), 21 deletions(-) mode change 100755 => 100644 install-sh mode change 100644 => 100755 test/progress.test mode change 100644 => 100755 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 310c1dfb95..17ae3d5687 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Fix\sthe\ssqlite3.h\sgenerator\sscript\sso\sthat\sit\sgenerates\sthe\scorrect\nSQLITE_SOURCE_ID\sstring\swith\sthe\slatest\sversions\sof\sFossil\sthat\s\ninclude\sfractional\sseconds\son\sthe\sdate/time\sstamp. -D 2011-01-11T12:46:05.980 +C If\sa\srollback\sis\sattempted\sin\sjournal_mode=off\smode,\sforce\sSQLite\sto\sdiscard\sthe\scontents\sof\sthe\spager\scache\sbefore\sprocessing\sany\ssubsequent\squeries. +D 2011-01-11T16:09:55 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -100,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -165,7 +162,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c c0aca5c733c15a16fe158c3215d857841a4e5381 +F src/pager.c a3d1b55d4572c229170ddb1589232ae7251f8d28 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -592,7 +589,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -873,7 +870,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -898,14 +895,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d94e59b514c16c5f7ea506e0af1c6e2ffecc13be -R f02123c924a142fca1a394313d3028b5 -U drh -Z 6f6ef4dbc6a35c4d5adf4fad0076b217 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNLFERoxKgR168RlERAifbAJsFaxIQF3cfejQ8x4UPtTJT8QRE3ACfSRFj -QVjUad79/TL7jK/KM05BlxQ= -=ebHi ------END PGP SIGNATURE----- +P 3513bf6ee090d9be97f60e12a4b39f4361ee17b7 +R dfc530d225d0c020fd7d8a2cd613ee21 +U dan +Z 8c19b076e4fa90af7411920026738949 diff --git a/manifest.uuid b/manifest.uuid index 28ec38acbe..226828c844 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3513bf6ee090d9be97f60e12a4b39f4361ee17b7 \ No newline at end of file +ece7efce2733b4fdd71db385abebbde464ac8f30 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 5fcee322bc..a4773e230f 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5926,7 +5926,17 @@ int sqlite3PagerRollback(Pager *pPager){ rc2 = pager_end_transaction(pPager, pPager->setMaster); 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); + 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. + ** Any active readers will get SQLITE_ABORT. + */ + pPager->errCode = SQLITE_ABORT; + pPager->eState = PAGER_ERROR; + return rc; + } }else{ rc = pager_playback(pPager, 0); } diff --git a/test/progress.test b/test/progress.test old mode 100644 new mode 100755 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100644 new mode 100755 From ca94d8bf828378c7d84151282769e88ba90830d9 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 11 Jan 2011 17:38:03 +0000 Subject: [PATCH 40/82] Change the page size of the destination database in a backup, if it is changeable, prior to starting the backup. FossilOrigin-Name: a5e4e0caad788318bc973e2550488a3b83128b8b --- install-sh | 0 manifest | 30 ++++++++++++++++++++---------- manifest.uuid | 2 +- src/backup.c | 19 +++++++++++++++---- test/progress.test | 0 tool/mkopts.tcl | 0 6 files changed, 36 insertions(+), 15 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 17ae3d5687..d8de733992 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C If\sa\srollback\sis\sattempted\sin\sjournal_mode=off\smode,\sforce\sSQLite\sto\sdiscard\sthe\scontents\sof\sthe\spager\scache\sbefore\sprocessing\sany\ssubsequent\squeries. -D 2011-01-11T16:09:55 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Change\sthe\spage\ssize\sof\sthe\sdestination\sdatabase\sin\sa\sbackup,\sif\sit\sis\nchangeable,\sprior\sto\sstarting\sthe\sbackup. +D 2011-01-11T17:38:03.635 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -97,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -116,7 +119,7 @@ F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 F src/analyze.c 3af3fdb5edea9e69496b078935a3e6a2a1118b30 F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c d5b0137bc20327af08c14772227cc35134839c30 +F src/backup.c ce552d975069f65ab1fc798950ff3582d8e76d58 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c b70bf1dc563ec532851715ce51aa1ea0c0c592b9 @@ -589,7 +592,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -870,7 +873,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -895,7 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3513bf6ee090d9be97f60e12a4b39f4361ee17b7 -R dfc530d225d0c020fd7d8a2cd613ee21 -U dan -Z 8c19b076e4fa90af7411920026738949 +P ece7efce2733b4fdd71db385abebbde464ac8f30 +R 29f54f2120ae55006ec20805de522720 +U drh +Z 2c38d84c8992f6e0694f158dc2a7fcb7 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNLJV+oxKgR168RlERAi/rAJ4/03yY93qaERvdXQ29IRVWFKS4bACbB68f +I9vtcTSZhseoWr42H7VDbvY= +=uS6P +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 226828c844..4e3a718601 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ece7efce2733b4fdd71db385abebbde464ac8f30 \ No newline at end of file +a5e4e0caad788318bc973e2550488a3b83128b8b \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index db8baeac5e..a37065080a 100644 --- a/src/backup.c +++ b/src/backup.c @@ -117,6 +117,16 @@ static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){ return pDb->aDb[i].pBt; } +/* +** Attempt to set the page size of the destination to match the page size +** of the source. +*/ +static int setDestPgsz(sqlite3_backup *p){ + int rc; + rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0); + return rc; +} + /* ** Create an sqlite3_backup process to copy the contents of zSrcDb from ** connection handle pSrcDb to zDestDb in pDestDb. If successful, return @@ -170,10 +180,11 @@ sqlite3_backup *sqlite3_backup_init( p->iNext = 1; p->isAttached = 0; - if( 0==p->pSrc || 0==p->pDest ){ - /* One (or both) of the named databases did not exist. An error has - ** already been written into the pDestDb handle. All that is left - ** to do here is free the sqlite3_backup structure. + if( 0==p->pSrc || 0==p->pDest || setDestPgsz(p)==SQLITE_NOMEM ){ + /* One (or both) of the named databases did not exist or an OOM + ** error was hit. The error has already been written into the + ** pDestDb handle. All that is left to do here is free the + ** sqlite3_backup structure. */ sqlite3_free(p); p = 0; diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 From 354bfe0363535e5788e1ed45285b73ba96c39429 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 11 Jan 2011 17:39:37 +0000 Subject: [PATCH 41/82] Add the SQLITE_FCNTL_SYNC file-control. FossilOrigin-Name: b3f2f465c310a2cfef8731a0dae3453593b68de9 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/pager.c | 11 +++++++---- src/sqlite.h.in | 7 +++++++ test/jrnlmode3.test | 11 +++++------ test/pager1.test | 4 ++-- test/pager2.test | 2 +- test/savepoint.test | 2 +- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 17ae3d5687..710a412372 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\srollback\sis\sattempted\sin\sjournal_mode=off\smode,\sforce\sSQLite\sto\sdiscard\sthe\scontents\sof\sthe\spager\scache\sbefore\sprocessing\sany\ssubsequent\squeries. -D 2011-01-11T16:09:55 +C Add\sthe\sSQLITE_FCNTL_SYNC\sfile-control. +D 2011-01-11T17:39:38 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +162,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c a3d1b55d4572c229170ddb1589232ae7251f8d28 +F src/pager.c ceceb5e20d8772cd6a1e3d6eb030fbcb1c052f61 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -176,7 +176,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in f48408b86c0713bc074b16c83543868688b0e18d +F src/sqlite.h.in 584410ebff31c8d1ca7cac5ddc9f0fa00e9b21c8 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -509,7 +509,7 @@ F test/journal2.test 50a3604768494d4a337f194f0a9480e7c57dcb72 F test/journal3.test ff175219be1b02d2f7e54297ad7e491b7533edb6 F test/jrnlmode.test e3fe6c4a2c3213d285650dc8e33aab7eaaa5ce53 F test/jrnlmode2.test a19e28de1a6ec898067e46a122f1b71c9323bf00 -F test/jrnlmode3.test cfcdb12b90e640a23b92785a002d96c0624c8710 +F test/jrnlmode3.test c6522b276ba315fd1416198de6fc1da9e72409fb F test/keyword1.test a2400977a2e4fde43bf33754c2929fda34dbca05 F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 @@ -576,8 +576,8 @@ F test/notify3.test d60923e186e0900f4812a845fcdfd8eea096e33a F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec -F test/pager1.test e066fb2e2dc1ac1cd9ef2b44a28ae3cc79a9150f -F test/pager2.test 0fbb6b6dc40ce1fecfe758c555a748ad2e9beaa3 +F test/pager1.test 7006a8b5dd3df1fe0d51d7da014333d7dc099778 +F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 9de4d3e0c59970b4c6cb8dac511fa242f335d8a7 F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401 @@ -604,7 +604,7 @@ F test/rollback.test 1a83118ea6db4e7d8c10eaa63871b5e90502ffdc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287 F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798 -F test/savepoint.test d3dd00e0137fc4b4659bde378a4d8f2cd07238a3 +F test/savepoint.test a1bef7ace82cc7922975fa96b06176e9bd5114cf F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7 F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0 @@ -895,7 +895,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3513bf6ee090d9be97f60e12a4b39f4361ee17b7 -R dfc530d225d0c020fd7d8a2cd613ee21 +P ece7efce2733b4fdd71db385abebbde464ac8f30 +R 8f29fed661ee1ba7528f6d53e5a1b035 U dan -Z 8c19b076e4fa90af7411920026738949 +Z 8ca27a923058f8ea50b31a1627ccbb6c diff --git a/manifest.uuid b/manifest.uuid index 226828c844..9f79240f99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ece7efce2733b4fdd71db385abebbde464ac8f30 \ No newline at end of file +b3f2f465c310a2cfef8731a0dae3453593b68de9 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index a4773e230f..d65c460afa 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2749,10 +2749,10 @@ end_playback: rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1); testcase( rc!=SQLITE_OK ); } - if( rc==SQLITE_OK && !pPager->noSync + if( rc==SQLITE_OK && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) ){ - rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); + rc = sqlite3PagerSync(pPager); } if( rc==SQLITE_OK ){ rc = pager_end_transaction(pPager, zMaster[0]!='\0'); @@ -5596,6 +5596,9 @@ int sqlite3PagerSync(Pager *pPager){ }else{ rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); } + if( isOpen(pPager->fd) ){ + sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, (void *)&rc); + } return rc; } @@ -5813,8 +5816,8 @@ int sqlite3PagerCommitPhaseOne( } /* Finally, sync the database file. */ - if( !pPager->noSync && !noSync ){ - rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); + if( !noSync ){ + rc = sqlite3PagerSync(pPager); } IOTRACE(("DBSYNC %p\n", pPager)) } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 0f05a09a33..0774493ed3 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -715,6 +715,12 @@ struct sqlite3_io_methods { ** to the [sqlite3_file] object associated with a particular database ** connection. See the [sqlite3_file_control()] documentation for ** additional information. +** +** The [SQLITE_FCNTL_SYNC] opcode is used internally. SQLite calls +** the file-control method with this opcode immediately after the database +** file is synced, or if the database is running in synchronous=off mode +** immediately after it would have been synced otherwise. This makes it +** easier to write special VFS modules that depend on the xSync call. */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_GET_LOCKPROXYFILE 2 @@ -723,6 +729,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_SIZE_HINT 5 #define SQLITE_FCNTL_CHUNK_SIZE 6 #define SQLITE_FCNTL_FILE_POINTER 7 +#define SQLITE_FCNTL_SYNC 8 /* diff --git a/test/jrnlmode3.test b/test/jrnlmode3.test index 7a6f4c3adc..6ae1346e32 100644 --- a/test/jrnlmode3.test +++ b/test/jrnlmode3.test @@ -45,7 +45,7 @@ do_test jrnlmode3-1.2 { ROLLBACK; SELECT * FROM t1; } -} {1 2} +} {1} db close file delete -force test.db test.db-journal @@ -67,7 +67,7 @@ do_test jrnlmode3-2.2 { ROLLBACK; SELECT * FROM t1; } -} {1 2} +} {1} # Test cases to verify that we can move from any journal_mode # to any other, as long as we are not in a transaction. Verify @@ -112,15 +112,14 @@ foreach fromjmode $all_journal_modes { db eval "PRAGMA journal_mode=$tojmode" } $fromjmode - # Rollback the transaction. Verify that the rollback occurred - # if journal_mode!=OFF. + # Rollback the transaction. # do_test jrnlmode3-3.$cnt.4 { db eval { ROLLBACK; SELECT * FROM t1; } - } [expr {$fromjmode=="off"?$cnt:""}] + } {} # Now change the journal mode again. This time the new mode # should take. @@ -143,7 +142,7 @@ foreach fromjmode $all_journal_modes { db eval { SELECT * FROM t1; } - } [expr {$tojmode=="off"?"1":""}] + } {} } } diff --git a/test/pager1.test b/test/pager1.test index cf34033b0c..481ef4a064 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -1614,7 +1614,7 @@ do_catchsql_test pager1-14.1.2 { } {0 {}} do_execsql_test pager1-14.1.3 { SELECT * FROM t1; -} {1 2 3 4} +} {1 2} do_catchsql_test pager1-14.1.4 { BEGIN; INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1; @@ -1623,7 +1623,7 @@ do_catchsql_test pager1-14.1.4 { do_execsql_test pager1-14.1.5 { COMMIT; SELECT * FROM t1; -} {1 2 3 4 2 2 4 4} +} {1 2 2 2} #------------------------------------------------------------------------- # Test opening and closing the pager sub-system with different values diff --git a/test/pager2.test b/test/pager2.test index 06389f5d9f..fa5f7b9611 100644 --- a/test/pager2.test +++ b/test/pager2.test @@ -133,7 +133,7 @@ do_test pager2-2.1 { ROLLBACK; SELECT * FROM t1; } -} {off 1 2} +} {off} do_test pager2-2.2 { faultsim_delete_and_reopen execsql { diff --git a/test/savepoint.test b/test/savepoint.test index 3ff0f92430..042c555894 100644 --- a/test/savepoint.test +++ b/test/savepoint.test @@ -905,7 +905,7 @@ if {[wal_is_wal_mode]==0} { ROLLBACK; SELECT * FROM t1; } - } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} + } {1 2 3 4 5 6 7 8 9 10 11 12} } db close From efd95a7acac244b323d52740a9043b9ccfb2756e Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 12 Jan 2011 17:56:26 +0000 Subject: [PATCH 42/82] Do not raise an SQLITE_CORRUPT error in Recoverymode if the database size in the header is larger than the physical file size. This facilitates recovery of a database in which the database size field has been corrupted. FossilOrigin-Name: 114640d920e16c85de90b19d53c485135875de5b --- install-sh | 0 manifest | 30 ++++++++++++++++++++---------- manifest.uuid | 2 +- src/btree.c | 2 +- test/progress.test | 0 tool/mkopts.tcl | 0 6 files changed, 22 insertions(+), 12 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index a59d5d3555..fdd13e45cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Merge\saccidentally\screated\sfork. -D 2011-01-11T17:40:31 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Do\snot\sraise\san\sSQLITE_CORRUPT\serror\sin\sRecoverymode\s\nif\sthe\sdatabase\ssize\sin\sthe\sheader\sis\slarger\sthan\sthe\sphysical\sfile\nsize.\s\sThis\sfacilitates\srecovery\sof\sa\sdatabase\sin\swhich\sthe\sdatabase\ssize\nfield\shas\sbeen\scorrupted. +D 2011-01-12T17:56:26.948 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -97,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -119,7 +122,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c ce552d975069f65ab1fc798950ff3582d8e76d58 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c b70bf1dc563ec532851715ce51aa1ea0c0c592b9 +F src/btree.c a27c3b41082889fc258278ba501ff2594dda2a41 F src/btree.h 10f9296bf4edf034f5adce921b7b4383a56a1c90 F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 F src/build.c 00a327120d81ace6267e714ae8010c997d55de5d @@ -589,7 +592,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -870,7 +873,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -895,7 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b3f2f465c310a2cfef8731a0dae3453593b68de9 a5e4e0caad788318bc973e2550488a3b83128b8b -R 6faced81a82ecb4ba54df893c5e6a297 -U dan -Z f0f3daac9da086373a27e5813015c53d +P b7d080b8e850bd262f53f29ba4687a62cf76d4ef +R 3df20cbf1e57e735d0696445d60d0fe8 +U drh +Z 2ae16dc41b5332856d6b8afad9a17eaa +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNLetOoxKgR168RlERAtbpAJsHFAuvo+hb/a4kPy6JuXOle+B9JQCeJDIz +fRWuQnWOMCXleg04aoLM6ng= +=2nsc +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index a739e42b91..92653444db 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b7d080b8e850bd262f53f29ba4687a62cf76d4ef \ No newline at end of file +114640d920e16c85de90b19d53c485135875de5b \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index fcc8deb922..bec19e315f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2386,7 +2386,7 @@ static int lockBtree(BtShared *pBt){ pageSize-usableSize); return rc; } - if( nPageHeader>nPageFile ){ + if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPageHeader>nPageFile ){ rc = SQLITE_CORRUPT_BKPT; goto page1_init_failed; } diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 From 86596e552e670ec105eac41349d9613818605105 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 13 Jan 2011 10:58:26 +0000 Subject: [PATCH 43/82] Fix a segfault that can occur in matchinfo if an fts4 table contains mostly zero-length documents. Specifically, if the table contains more rows than it does bytes of text. FossilOrigin-Name: fe9047668eaaf76e7aa1ef1f32dec7c7c4226e45 --- ext/fts3/fts3_snippet.c | 1 + ext/fts3/fts3_write.c | 5 +++-- install-sh | 0 manifest | 34 ++++++++++++---------------------- manifest.uuid | 2 +- test/fts3matchinfo.test | 26 ++++++++++++++++++++++++++ test/progress.test | 0 tool/mkopts.tcl | 0 8 files changed, 43 insertions(+), 25 deletions(-) mode change 100755 => 100644 install-sh mode change 100644 => 100755 test/progress.test mode change 100644 => 100755 tool/mkopts.tcl diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 9fac359840..acf1786819 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -956,6 +956,7 @@ static int fts3MatchinfoSelectDoctotal( if( rc!=SQLITE_OK ) return rc; } pStmt = *ppStmt; + assert( sqlite3_data_count(pStmt)==1 ); a = sqlite3_column_blob(pStmt, 0); a += sqlite3Fts3GetVarint(a, &nDoc); diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 3120a80c58..106f7b37bb 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -1104,7 +1104,7 @@ int sqlite3Fts3SegReaderCost( sqlite3_stmt *pStmt; rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0); if( rc ) return rc; - if( sqlite3_step(pStmt)==SQLITE_ROW ){ + if( sqlite3_data_count(pStmt) || sqlite3_step(pStmt)==SQLITE_ROW ){ sqlite3_int64 nDoc = 0; sqlite3_int64 nByte = 0; const char *a = sqlite3_column_blob(pStmt, 0); @@ -1116,7 +1116,8 @@ int sqlite3Fts3SegReaderCost( } } - pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz - 1) / pgsz); + pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz) / pgsz); + assert( pCsr->nRowAvg>0 ); } rc = sqlite3_reset(pStmt); if( rc!=SQLITE_OK || pCsr->nRowAvg==0 ) return rc; diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index fdd13e45cd..f6a6ce4aa7 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Do\snot\sraise\san\sSQLITE_CORRUPT\serror\sin\sRecoverymode\s\nif\sthe\sdatabase\ssize\sin\sthe\sheader\sis\slarger\sthan\sthe\sphysical\sfile\nsize.\s\sThis\sfacilitates\srecovery\sof\sa\sdatabase\sin\swhich\sthe\sdatabase\ssize\nfield\shas\sbeen\scorrupted. -D 2011-01-12T17:56:26.948 +C Fix\sa\ssegfault\sthat\scan\soccur\sin\smatchinfo\sif\san\sfts4\stable\scontains\smostly\szero-length\sdocuments.\sSpecifically,\sif\sthe\stable\scontains\smore\srows\sthan\sit\sdoes\sbytes\sof\stext. +D 2011-01-13T10:58:27 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -72,11 +69,11 @@ F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295 F ext/fts3/fts3_porter.c d61cfd81fb0fd8fbcb25adcaee0ba671aefaa5c2 -F ext/fts3/fts3_snippet.c 3a26a835732619b62f3af1b73f96d017f8651f9f +F ext/fts3/fts3_snippet.c 196c5e6cde57bfc1907c2d60e9c29590e4f93fb6 F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d -F ext/fts3/fts3_write.c 1fd0988538fb3b40009a99068148e63cec7426aa +F ext/fts3/fts3_write.c 9f3545ae27c13553a6f433fa0ec260fe8bf0cf2f F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -100,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -453,7 +450,7 @@ F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 F test/fts3malloc.test 9c8cc3f885bb4dfc66d0460c52f68f45e4710d1b -F test/fts3matchinfo.test ae910aa666285e14743a80799214bfb3f1aab8f2 +F test/fts3matchinfo.test 32e31467963698cc7fa311e9a61f99d7d06cf72b F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 F test/fts3query.test ef79d31fdb355d094baec1c1b24b60439a1fb8a2 F test/fts3rnd.test 2b1a579be557ab8ac54a51b39caa4aa8043cc4ad @@ -592,7 +589,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -873,7 +870,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -898,14 +895,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b7d080b8e850bd262f53f29ba4687a62cf76d4ef -R 3df20cbf1e57e735d0696445d60d0fe8 -U drh -Z 2ae16dc41b5332856d6b8afad9a17eaa ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNLetOoxKgR168RlERAtbpAJsHFAuvo+hb/a4kPy6JuXOle+B9JQCeJDIz -fRWuQnWOMCXleg04aoLM6ng= -=2nsc ------END PGP SIGNATURE----- +P 114640d920e16c85de90b19d53c485135875de5b +R f5eb10b21437fad711a6b9be4e7a8db9 +U dan +Z a737930e0e8a10b4bde0b31ffbd88e53 diff --git a/manifest.uuid b/manifest.uuid index 92653444db..2d44df5bca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -114640d920e16c85de90b19d53c485135875de5b \ No newline at end of file +fe9047668eaaf76e7aa1ef1f32dec7c7c4226e45 \ No newline at end of file diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test index be9682aa7e..bfa704080f 100644 --- a/test/fts3matchinfo.test +++ b/test/fts3matchinfo.test @@ -337,6 +337,32 @@ do_execsql_test 7.4 { FROM t10 WHERE t10 MATCH 'record' } {blob 20 blob 20} +#------------------------------------------------------------------------- +# Test a special case - matchinfo('nxa') with many zero length documents. +# Special because "x" internally uses a statement used by both "n" and "a". +# This was causing a problem at one point in the obscure case where the +# total number of bytes of data stored in an fts3 table was greater than +# the number of rows. i.e. when the following query returns true: +# +# SELECT sum(length(content)) < count(*) FROM fts4table; +# +do_execsql_test 8.1 { + CREATE VIRTUAL TABLE t11 USING fts4; + INSERT INTO t11(t11) VALUES('nodesize=24'); + INSERT INTO t11 VALUES('quitealongstringoftext'); + INSERT INTO t11 VALUES('anotherquitealongstringoftext'); + INSERT INTO t11 VALUES('athirdlongstringoftext'); + INSERT INTO t11 VALUES('andonemoreforgoodluck'); +} +do_test 8.2 { + for {set i 0} {$i < 200} {incr i} { + execsql { INSERT INTO t11 VALUES('') } + } + execsql { INSERT INTO t11(t11) VALUES('optimize') } +} {} +do_execsql_test 8.3 { + SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' +} {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}} finish_test diff --git a/test/progress.test b/test/progress.test old mode 100644 new mode 100755 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100644 new mode 100755 From a8ab60c6488b775adf2d5ea7d12ed35cac7e257e Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 13 Jan 2011 11:20:04 +0000 Subject: [PATCH 44/82] Fix a couple of crashes in fts3 that can occur if the database contents are inconsistent. FossilOrigin-Name: 811e12cddfb3246c6cf3d5085bd9b72b12e05550 --- ext/fts3/fts3_write.c | 33 ++++++++++++++++++--------------- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts3matchinfo.test | 16 ++++++++++++++++ 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 106f7b37bb..61def9993a 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -1102,25 +1102,28 @@ int sqlite3Fts3SegReaderCost( ** to right. */ sqlite3_stmt *pStmt; - rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0); + sqlite3_int64 nDoc = 0; + sqlite3_int64 nByte = 0; + const char *a; + rc = sqlite3Fts3SelectDoctotal(p, &pStmt); if( rc ) return rc; - if( sqlite3_data_count(pStmt) || sqlite3_step(pStmt)==SQLITE_ROW ){ - sqlite3_int64 nDoc = 0; - sqlite3_int64 nByte = 0; - const char *a = sqlite3_column_blob(pStmt, 0); - if( a ){ - const char *pEnd = &a[sqlite3_column_bytes(pStmt, 0)]; - a += sqlite3Fts3GetVarint(a, &nDoc); - while( anRowAvg = (int)(((nByte / nDoc) + pgsz) / pgsz); - assert( pCsr->nRowAvg>0 ); } + if( nDoc==0 || nByte==0 ){ + sqlite3_reset(pStmt); + return SQLITE_CORRUPT; + } + + pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz) / pgsz); + assert( pCsr->nRowAvg>0 ); rc = sqlite3_reset(pStmt); - if( rc!=SQLITE_OK || pCsr->nRowAvg==0 ) return rc; + if( rc!=SQLITE_OK ) return rc; } /* Assume that a blob flows over onto overflow pages if it is larger diff --git a/manifest b/manifest index f6a6ce4aa7..4753dfeee5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\ssegfault\sthat\scan\soccur\sin\smatchinfo\sif\san\sfts4\stable\scontains\smostly\szero-length\sdocuments.\sSpecifically,\sif\sthe\stable\scontains\smore\srows\sthan\sit\sdoes\sbytes\sof\stext. -D 2011-01-13T10:58:27 +C Fix\sa\scouple\sof\scrashes\sin\sfts3\sthat\scan\soccur\sif\sthe\sdatabase\scontents\sare\sinconsistent. +D 2011-01-13T11:20:04 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -73,7 +73,7 @@ F ext/fts3/fts3_snippet.c 196c5e6cde57bfc1907c2d60e9c29590e4f93fb6 F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d -F ext/fts3/fts3_write.c 9f3545ae27c13553a6f433fa0ec260fe8bf0cf2f +F ext/fts3/fts3_write.c 3eea26b9ca4219e1711b0db74fd5a9d448a6afbb F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -450,7 +450,7 @@ F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 F test/fts3malloc.test 9c8cc3f885bb4dfc66d0460c52f68f45e4710d1b -F test/fts3matchinfo.test 32e31467963698cc7fa311e9a61f99d7d06cf72b +F test/fts3matchinfo.test cc0b009edbbf575283d5fdb53271179e0d8019ba F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 F test/fts3query.test ef79d31fdb355d094baec1c1b24b60439a1fb8a2 F test/fts3rnd.test 2b1a579be557ab8ac54a51b39caa4aa8043cc4ad @@ -895,7 +895,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 114640d920e16c85de90b19d53c485135875de5b -R f5eb10b21437fad711a6b9be4e7a8db9 +P fe9047668eaaf76e7aa1ef1f32dec7c7c4226e45 +R 92da6ba399b108dc3885073a225af042 U dan -Z a737930e0e8a10b4bde0b31ffbd88e53 +Z 1a6f8ebc8ef3ebfc6cb5f32bb01c2e00 diff --git a/manifest.uuid b/manifest.uuid index 2d44df5bca..6f0b1a326a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe9047668eaaf76e7aa1ef1f32dec7c7c4226e45 \ No newline at end of file +811e12cddfb3246c6cf3d5085bd9b72b12e05550 \ No newline at end of file diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test index bfa704080f..8f194e72cb 100644 --- a/test/fts3matchinfo.test +++ b/test/fts3matchinfo.test @@ -364,5 +364,21 @@ do_execsql_test 8.3 { SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' } {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}} +# Corruption related tests. +do_execsql_test 8.4.1.1 { UPDATE t11_stat SET value = X'0000'; } +do_catchsql_test 8.5.1.2 { + SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' +} {1 {database disk image is malformed}} + +do_execsql_test 8.4.2.1 { UPDATE t11_stat SET value = X'00'; } +do_catchsql_test 8.5.2.2 { + SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' +} {1 {database disk image is malformed}} + +do_execsql_test 8.4.3.1 { UPDATE t11_stat SET value = NULL; } +do_catchsql_test 8.5.3.2 { + SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' +} {1 {database disk image is malformed}} + finish_test From 5b3696e8a6606e5c8ae232ecd9d5db717b55c80d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Jan 2011 16:10:58 +0000 Subject: [PATCH 45/82] Fix a typo on the sqlite3_open_v2() documentation. FossilOrigin-Name: b0add45abc9929c5b8d1124879bc3e8acf2ab7c7 --- install-sh | 0 manifest | 30 ++++++++++++++++++++---------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- test/progress.test | 0 tool/mkopts.tcl | 0 6 files changed, 22 insertions(+), 12 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 4753dfeee5..4327fa23df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\scouple\sof\scrashes\sin\sfts3\sthat\scan\soccur\sif\sthe\sdatabase\scontents\sare\sinconsistent. -D 2011-01-13T11:20:04 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\sa\stypo\son\sthe\ssqlite3_open_v2()\sdocumentation. +D 2011-01-13T16:10:58.039 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -97,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -176,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in 584410ebff31c8d1ca7cac5ddc9f0fa00e9b21c8 +F src/sqlite.h.in 90674938b3da90bc8c652d3cc8919bb5e59fca3a F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -589,7 +592,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -870,7 +873,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -895,7 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P fe9047668eaaf76e7aa1ef1f32dec7c7c4226e45 -R 92da6ba399b108dc3885073a225af042 -U dan -Z 1a6f8ebc8ef3ebfc6cb5f32bb01c2e00 +P 811e12cddfb3246c6cf3d5085bd9b72b12e05550 +R 4db09cc2d3d25cf2af107cc1bd614955 +U drh +Z f696e8356dbd05649a93c3ef6bad0b51 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNLyQVoxKgR168RlERAtTYAJ4vasQs4AbrNNxcwuyEckmjClcwJwCfcTEV +E1HYpfcH5ZGZGtGR544ndQ4= +=qmdL +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 6f0b1a326a..00d7cbc329 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -811e12cddfb3246c6cf3d5085bd9b72b12e05550 \ No newline at end of file +b0add45abc9929c5b8d1124879bc3e8acf2ab7c7 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 0774493ed3..79a1e0810c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2311,7 +2311,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** case the database must already exist, otherwise an error is returned.
    )^ ** ** ^(
    [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
    -**
    The database is opened for reading and writing, and is creates it if +**
    The database is opened for reading and writing, and is created if ** it does not already exist. This is the behavior that is always used for ** sqlite3_open() and sqlite3_open16().
    )^ ** diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 From 47e909bb15b6b7026439555e3df7454f63ffd6f3 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 14 Jan 2011 11:51:28 +0000 Subject: [PATCH 46/82] Fix a bug in test code (test_vfs.c). FossilOrigin-Name: 772a3845f8ef5cd3131992c45f6ce607977820f3 --- install-sh | 0 manifest | 30 ++++++++++-------------------- manifest.uuid | 2 +- src/test_vfs.c | 1 + test/progress.test | 0 tool/mkopts.tcl | 0 6 files changed, 12 insertions(+), 21 deletions(-) mode change 100755 => 100644 install-sh mode change 100644 => 100755 test/progress.test mode change 100644 => 100755 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 4327fa23df..8a3f1a33f1 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Fix\sa\stypo\son\sthe\ssqlite3_open_v2()\sdocumentation. -D 2011-01-13T16:10:58.039 +C Fix\sa\sbug\sin\stest\scode\s(test_vfs.c). +D 2011-01-14T11:51:28 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -100,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -223,7 +220,7 @@ F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 -F src/test_vfs.c e10fcca756cafa89438311b31522ac1f95bf784b +F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 F src/trigger.c b8bedb9c0084ceb51a40f54fcca2ce048c8de852 @@ -592,7 +589,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -873,7 +870,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -898,14 +895,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 811e12cddfb3246c6cf3d5085bd9b72b12e05550 -R 4db09cc2d3d25cf2af107cc1bd614955 -U drh -Z f696e8356dbd05649a93c3ef6bad0b51 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNLyQVoxKgR168RlERAtTYAJ4vasQs4AbrNNxcwuyEckmjClcwJwCfcTEV -E1HYpfcH5ZGZGtGR544ndQ4= -=qmdL ------END PGP SIGNATURE----- +P b0add45abc9929c5b8d1124879bc3e8acf2ab7c7 +R b67b9c989bcea8b245d245dba2997a91 +U dan +Z 95ee84a38eb35f38451c4014903841ae diff --git a/manifest.uuid b/manifest.uuid index 00d7cbc329..6744ad0de4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0add45abc9929c5b8d1124879bc3e8acf2ab7c7 \ No newline at end of file +772a3845f8ef5cd3131992c45f6ce607977820f3 \ No newline at end of file diff --git a/src/test_vfs.c b/src/test_vfs.c index ebe4a576a4..64b3cb574b 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -540,6 +540,7 @@ static int tvfsOpen( pFd->zFilename = zName; pFd->pVfs = pVfs; pFd->pReal = (sqlite3_file *)&pFd[1]; + memset(pTestfile, 0, sizeof(TestvfsFile)); pTestfile->pFd = pFd; /* Evaluate the Tcl script: diff --git a/test/progress.test b/test/progress.test old mode 100644 new mode 100755 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100644 new mode 100755 From 94e7bd55bd94ad33a6eb7bfab6016800d64af3d7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 14 Jan 2011 15:17:55 +0000 Subject: [PATCH 47/82] Fix comments, including some documentation comments, in the page cache logic. No code changes. FossilOrigin-Name: c80e9c1a0dc0e501b209874e147e1cb1348cb4a4 --- install-sh | 0 manifest | 32 +++++++++++++++++++++----------- manifest.uuid | 2 +- src/pcache1.c | 6 +----- src/sqlite.h.in | 2 +- test/progress.test | 0 tool/mkopts.tcl | 0 7 files changed, 24 insertions(+), 18 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 8a3f1a33f1..8c4edfea74 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\sbug\sin\stest\scode\s(test_vfs.c). -D 2011-01-14T11:51:28 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\scomments,\sincluding\ssome\sdocumentation\scomments,\sin\sthe\spage\scache\nlogic.\s\sNo\scode\schanges. +D 2011-01-14T15:17:55.081 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -97,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -167,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c e9578a3beac26f229ee558a4e16c863f2498185f +F src/pcache1.c 306389ff1a9677fc93533c3100b728c43cc007c0 F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc F src/printf.c 37e8bfd4c5a04eae4960adbe776b0f1fc4cad674 @@ -176,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in 90674938b3da90bc8c652d3cc8919bb5e59fca3a +F src/sqlite.h.in e93b13af0879dcc56471fc7639dc8efa7d0de832 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -589,7 +592,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -870,7 +873,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -895,7 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b0add45abc9929c5b8d1124879bc3e8acf2ab7c7 -R b67b9c989bcea8b245d245dba2997a91 -U dan -Z 95ee84a38eb35f38451c4014903841ae +P 772a3845f8ef5cd3131992c45f6ce607977820f3 +R 19decadc1bc3a350efa2fd91ea550cbd +U drh +Z 2bc94824009661f8875e8f0813b34047 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNMGkmoxKgR168RlERAivDAJwPBpJmw1CdPhCpfZB/zXbwtqt3ygCfQMOh +gcVN8uEte2YWEkQzdZ2raXY= +=99H9 +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 6744ad0de4..5b938e8c39 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -772a3845f8ef5cd3131992c45f6ce607977820f3 \ No newline at end of file +c80e9c1a0dc0e501b209874e147e1cb1348cb4a4 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index abf57dc34d..2485ffa097 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -688,11 +688,7 @@ static void pcache1Unpin(sqlite3_pcache *p, void *pPg, int reuseUnlikely){ pcache1RemoveFromHash(pPage); pcache1FreePage(pPage); }else{ - /* Add the page to the global LRU list. Normally, the page is added to - ** the head of the list (last page to be recycled). However, if the - ** reuseUnlikely flag passed to this function is true, the page is added - ** to the tail of the list (first page to be recycled). - */ + /* Add the page to the global LRU list. */ if( pcache1.pLruHead ){ pcache1.pLruHead->pLruPrev = pPage; pPage->pLruNext = pcache1.pLruHead; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 79a1e0810c..27121072ad 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5737,7 +5737,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** If the requested page is already in the page cache, then the page cache ** implementation must return a pointer to the page buffer with its content ** intact. If the requested page is not already in the cache, then the -** behavior of the cache implementation should use the value of the createFlag +** cache implementation should use the value of the createFlag ** parameter to help it determined what action to take: ** ** diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 From a5657d710bd5b34f889f9863186925e5dbdfbf82 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 14 Jan 2011 16:43:29 +0000 Subject: [PATCH 48/82] Rerun autoconf to bring the configure script up-to-date. FossilOrigin-Name: 142174640d60e834cae27ccaa78b02ecef8bcfe5 --- configure | 18 +++++++++--------- install-sh | 0 manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) mode change 100755 => 100644 install-sh diff --git a/configure b/configure index 3d617d0dd8..38343411eb 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.7.4. +# Generated by GNU Autoconf 2.62 for sqlite 3.7.5. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.7.4' -PACKAGE_STRING='sqlite 3.7.4' +PACKAGE_VERSION='3.7.5' +PACKAGE_STRING='sqlite 3.7.5' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1485,7 +1485,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.7.4 to adapt to many kinds of systems. +\`configure' configures sqlite 3.7.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1550,7 +1550,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.7.4:";; + short | recursive ) echo "Configuration of sqlite 3.7.5:";; esac cat <<\_ACEOF @@ -1666,7 +1666,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.7.4 +sqlite configure 3.7.5 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1680,7 +1680,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.7.4, which was +It was created by sqlite $as_me 3.7.5, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -13942,7 +13942,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.7.4, which was +This file was extended by sqlite $as_me 3.7.5, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13995,7 +13995,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.7.4 +sqlite config.status 3.7.5 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 8c4edfea74..764997be8c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\scomments,\sincluding\ssome\sdocumentation\scomments,\sin\sthe\spage\scache\nlogic.\s\sNo\scode\schanges. -D 2011-01-14T15:17:55.081 +C Rerun\sautoconf\sto\sbring\sthe\sconfigure\sscript\sup-to-date. +D 2011-01-14T16:43:29.515 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -25,7 +25,7 @@ F art/src_logo.gif 9341ef09f0e53cd44c0c9b6fc3c16f7f3d6c2ad9 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 868fdb48c028421a203470e15c69ada15b9ba673 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 4d325bb1fd4064fc4b8a2102e47e3c8966bbe2cf x +F configure 0eb10c03a6536d8e5ce52ab70fda0a152d8a3262 x F configure.ac 87a3c71bbe9c925381c154413eea7f3cdc397244 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 @@ -100,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 772a3845f8ef5cd3131992c45f6ce607977820f3 -R 19decadc1bc3a350efa2fd91ea550cbd +P c80e9c1a0dc0e501b209874e147e1cb1348cb4a4 +R d62e5db796e016b1bce5e2360445ed78 U drh -Z 2bc94824009661f8875e8f0813b34047 +Z b6feec9b043c1290ad807b91ea483a5f -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNMGkmoxKgR168RlERAivDAJwPBpJmw1CdPhCpfZB/zXbwtqt3ygCfQMOh -gcVN8uEte2YWEkQzdZ2raXY= -=99H9 +iD8DBQFNMH00oxKgR168RlERArInAJ0b8NDn9aIeEHssL2ciEGCxXpd+qgCeKe2T +1egStD90Yx8Agunusq4bieM= +=Bvx8 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 5b938e8c39..9096fc5ebb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c80e9c1a0dc0e501b209874e147e1cb1348cb4a4 \ No newline at end of file +142174640d60e834cae27ccaa78b02ecef8bcfe5 \ No newline at end of file From 39210bdaa62d80794113eac89e0661e94fbfc832 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 15 Jan 2011 16:52:10 +0000 Subject: [PATCH 49/82] Add a test case demonstrating the problem described by ticket [5d863f876e]. FossilOrigin-Name: af54963f0fa0afafbc2d0847f30543c041b182ec --- manifest | 27 +++++++------------- manifest.uuid | 2 +- test/progress.test | 0 test/tkt-5d863f876e.test | 53 ++++++++++++++++++++++++++++++++++++++++ tool/mkopts.tcl | 0 5 files changed, 63 insertions(+), 19 deletions(-) mode change 100644 => 100755 test/progress.test create mode 100644 test/tkt-5d863f876e.test mode change 100644 => 100755 tool/mkopts.tcl diff --git a/manifest b/manifest index 764997be8c..e6ffd13c90 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Rerun\sautoconf\sto\sbring\sthe\sconfigure\sscript\sup-to-date. -D 2011-01-14T16:43:29.515 +C Add\sa\stest\scase\sdemonstrating\sthe\sproblem\sdescribed\sby\sticket\s[5d863f876e]. +D 2011-01-15T16:52:11 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -592,7 +589,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -687,6 +684,7 @@ F test/tkt-38cb5df375.test 9e9b19857dba0896a8efdaf334d405ba423492f2 F test/tkt-3998683a16.test 6d1d04d551ed1704eb3396ca87bb9ccc8c5c1eb7 F test/tkt-3fe897352e.test 10de1a67bd5c66b238a4c96abe55531b37bb4f00 F test/tkt-4a03edc4c8.test 2865e4edbc075b954daa82f8da7cc973033ec76e +F test/tkt-5d863f876e.test 884072c2de496ddbb90c387c9ebc0d4f44a91b8e F test/tkt-5e10420e8d.test 904d1687b3c06d43e5b3555bbcf6802e7c0ffd84 F test/tkt-5ee23731f.test 3581260f2a71e51db94e1506ba6b0f7311d002a9 F test/tkt-78e04e52ea.test ab52f0c1e2de6e46c910f4cc16b086bba05952b7 @@ -873,7 +871,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -898,14 +896,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c80e9c1a0dc0e501b209874e147e1cb1348cb4a4 -R d62e5db796e016b1bce5e2360445ed78 -U drh -Z b6feec9b043c1290ad807b91ea483a5f ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNMH00oxKgR168RlERArInAJ0b8NDn9aIeEHssL2ciEGCxXpd+qgCeKe2T -1egStD90Yx8Agunusq4bieM= -=Bvx8 ------END PGP SIGNATURE----- +P 142174640d60e834cae27ccaa78b02ecef8bcfe5 +R d9ef404f44830db11f7a6ed5f8975a1f +U dan +Z 690a7330d2f219663b45235869cf7d49 diff --git a/manifest.uuid b/manifest.uuid index 9096fc5ebb..de402f1acc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -142174640d60e834cae27ccaa78b02ecef8bcfe5 \ No newline at end of file +af54963f0fa0afafbc2d0847f30543c041b182ec \ No newline at end of file diff --git a/test/progress.test b/test/progress.test old mode 100644 new mode 100755 diff --git a/test/tkt-5d863f876e.test b/test/tkt-5d863f876e.test new file mode 100644 index 0000000000..0a9017de11 --- /dev/null +++ b/test/tkt-5d863f876e.test @@ -0,0 +1,53 @@ +# 2011 January 15 +# +# 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. +# +# This file implements tests to verify that ticket [5d863f876e] has been +# fixed. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl + +do_multiclient_test tn { + do_test $tn.1 { + sql1 { + CREATE TABLE t1(a, b); + CREATE INDEX i1 ON t1(a, b); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); + PRAGMA journal_mode = WAL; + VACUUM; + PRAGMA journal_mode = DELETE; + } + } {wal delete} + + do_test $tn.2 { + sql2 { SELECT * FROM t1 } + } {1 2 3 4} + + do_test $tn.3 { + sql1 { + INSERT INTO t1 VALUES(5, 6); + PRAGMA journal_mode = WAL; + VACUUM; + PRAGMA journal_mode = DELETE; + } + } {wal delete} + + do_test $tn.2 { + sql2 { PRAGMA integrity_check } + } {ok} +} + + +finish_test diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100644 new mode 100755 From 104a7bba8cae6ca5410d6b0ce3c72a552a1bdde8 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 15 Jan 2011 17:12:59 +0000 Subject: [PATCH 50/82] Increment the change counter and update the SQLite version number whenever page 1 is added to the WAL. Ticket [5d863f876ee9561b9] FossilOrigin-Name: c1e0d09cd3f5feae123468a35f147021d839641c --- manifest | 28 +++++++++++++++++++--------- manifest.uuid | 2 +- src/pager.c | 28 ++++++++++++++++++++++++---- test/progress.test | 0 tool/mkopts.tcl | 0 5 files changed, 44 insertions(+), 14 deletions(-) mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/manifest b/manifest index e6ffd13c90..86cf2f03fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Add\sa\stest\scase\sdemonstrating\sthe\sproblem\sdescribed\sby\sticket\s[5d863f876e]. -D 2011-01-15T16:52:11 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Increment\sthe\schange\scounter\sand\supdate\sthe\sSQLite\sversion\snumber\swhenever\npage\s1\sis\sadded\sto\sthe\sWAL.\s\sTicket\s[5d863f876ee9561b9] +D 2011-01-15T17:12:59.482 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c ceceb5e20d8772cd6a1e3d6eb030fbcb1c052f61 +F src/pager.c 737025a2e7457ae7cfd4fe1f0cc69f69d88b29b4 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -589,7 +592,7 @@ F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -871,7 +874,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl e0db70c2c52b0e3d0867ca931229e5b90ffe7837 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -896,7 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 142174640d60e834cae27ccaa78b02ecef8bcfe5 -R d9ef404f44830db11f7a6ed5f8975a1f -U dan -Z 690a7330d2f219663b45235869cf7d49 +P af54963f0fa0afafbc2d0847f30543c041b182ec +R 2e070d9bb52da592e341dbace3cf5d95 +U drh +Z 2f025605b789f039118b3a16146dfc2d +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNMdWfoxKgR168RlERAmfoAJ9Y78wB/3baCsxKX+NyeGTMQLqGDACeOyQw +/EmrRAxlTmynxXA/PJ4j5Yo= +=dp+d +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index de402f1acc..e4f2521d70 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af54963f0fa0afafbc2d0847f30543c041b182ec \ No newline at end of file +c1e0d09cd3f5feae123468a35f147021d839641c \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d65c460afa..297ac99596 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2915,11 +2915,17 @@ static int pagerRollbackWal(Pager *pPager){ return rc; } +/* Forward declaration */ +static int pager_incr_changecounter(Pager*,int); + /* ** This function is a wrapper around sqlite3WalFrames(). As well as logging ** the contents of the list of pages headed by pList (connected by pDirty), ** this function notifies any active backup processes that the pages have -** changed. +** changed. +** +** The list of pages passed into this routine is always sorted by page number. +** Hence, if page 1 appears anywhere on the list, it will be the first page. */ static int pagerWalFrames( Pager *pPager, /* Pager object */ @@ -2929,8 +2935,23 @@ static int pagerWalFrames( int syncFlags /* Flags to pass to OsSync() (or 0) */ ){ int rc; /* Return code */ +#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES) + PgHdr *p; /* For looping over pages */ +#endif assert( pPager->pWal ); +#ifdef SQLITE_DEBUG + /* Verify that the page list is in accending order */ + for(p=pList; p && p->pDirty; p=p->pDirty){ + assert( p->pgno < p->pDirty->pgno ); + } +#endif + + if( pList->pgno==1 ){ + pPager->changeCountDone = 0; + pager_incr_changecounter(pPager,0); + pPager->changeCountDone = 0; + } rc = sqlite3WalFrames(pPager->pWal, pPager->pageSize, pList, nTruncate, isCommit, syncFlags ); @@ -2942,9 +2963,8 @@ static int pagerWalFrames( } #ifdef SQLITE_CHECK_PAGES - { - PgHdr *p; - for(p=pList; p; p=p->pDirty) pager_set_pagehash(p); + for(p=pList; p; p=p->pDirty){ + pager_set_pagehash(p); } #endif diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 From 54a7347aa1d25d87f3c4774c8a350912f4d76379 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 15 Jan 2011 18:11:12 +0000 Subject: [PATCH 51/82] Fix the change-counter increment for WAL pages so that it works even when invoked from xStress. Ticket [5d863f876ee9561b95e2]. FossilOrigin-Name: 228e7c34c64114670fe015747d47fdaa3b7e1270 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pager.c | 51 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index 86cf2f03fd..2944df000f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Increment\sthe\schange\scounter\sand\supdate\sthe\sSQLite\sversion\snumber\swhenever\npage\s1\sis\sadded\sto\sthe\sWAL.\s\sTicket\s[5d863f876ee9561b9] -D 2011-01-15T17:12:59.482 +C Fix\sthe\schange-counter\sincrement\sfor\sWAL\spages\sso\sthat\sit\sworks\seven\swhen\ninvoked\sfrom\sxStress.\s\sTicket\s[5d863f876ee9561b95e2]. +D 2011-01-15T18:11:12.573 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c 737025a2e7457ae7cfd4fe1f0cc69f69d88b29b4 +F src/pager.c 3e3e5cd39724107dc98edb39c1528b2d250c7b9a F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P af54963f0fa0afafbc2d0847f30543c041b182ec -R 2e070d9bb52da592e341dbace3cf5d95 +P c1e0d09cd3f5feae123468a35f147021d839641c +R f10af8d4a2b23d5e0a4042a0305ee5bd U drh -Z 2f025605b789f039118b3a16146dfc2d +Z e0ffffbf7b453d6eb6ed50379cb7cd3c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNMdWfoxKgR168RlERAmfoAJ9Y78wB/3baCsxKX+NyeGTMQLqGDACeOyQw -/EmrRAxlTmynxXA/PJ4j5Yo= -=dp+d +iD8DBQFNMeNDoxKgR168RlERAhpGAJ4lGMlKMGe3/3RAk9NL9lmCoMpu8wCfey5w +R2+PVnRtF1tBrMlvNBy+MRg= +=rI++ -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e4f2521d70..6c440bf13d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c1e0d09cd3f5feae123468a35f147021d839641c \ No newline at end of file +228e7c34c64114670fe015747d47fdaa3b7e1270 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 297ac99596..e0b4cd3c50 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2915,8 +2915,28 @@ static int pagerRollbackWal(Pager *pPager){ return rc; } -/* Forward declaration */ -static int pager_incr_changecounter(Pager*,int); + +/* +** Update the value of the change-counter at offsets 24 and 92 in +** the header and the sqlite version number at offset 96. +** +** This is an unconditional update. See also the pager_incr_changecounter() +** routine which only updates the change-counter if the update is actually +** needed, as determined by the pPager->changeCountDone state variable. +*/ +static void pager_write_changecounter(PgHdr *pPg){ + u32 change_counter; + + /* Increment the value just read and write it back to byte 24. */ + change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1; + put32bits(((char*)pPg->pData)+24, change_counter); + + /* Also store the SQLite version number in bytes 96..99 and in + ** bytes 92..95 store the change counter for which the version number + ** is valid. */ + put32bits(((char*)pPg->pData)+92, change_counter); + put32bits(((char*)pPg->pData)+96, SQLITE_VERSION_NUMBER); +} /* ** This function is a wrapper around sqlite3WalFrames(). As well as logging @@ -2947,11 +2967,7 @@ static int pagerWalFrames( } #endif - if( pList->pgno==1 ){ - pPager->changeCountDone = 0; - pager_incr_changecounter(pPager,0); - pPager->changeCountDone = 0; - } + if( pList->pgno==1 ) pager_write_changecounter(pList); rc = sqlite3WalFrames(pPager->pWal, pPager->pageSize, pList, nTruncate, isCommit, syncFlags ); @@ -5509,7 +5525,13 @@ void sqlite3PagerDontWrite(PgHdr *pPg){ /* ** This routine is called to increment the value of the database file ** change-counter, stored as a 4-byte big-endian integer starting at -** byte offset 24 of the pager file. +** byte offset 24 of the pager file. The secondary change counter at +** 92 is also updated, as is the SQLite version number at offset 96. +** +** But this only happens if the pPager->changeCountDone flag is false. +** To avoid excess churning of page 1, the update only happens once. +** See also the pager_write_changecounter() routine that does an +** unconditional update of the change counters. ** ** If the isDirectMode flag is zero, then this is done by calling ** sqlite3PagerWrite() on page 1, then modifying the contents of the @@ -5550,7 +5572,6 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ if( !pPager->changeCountDone && pPager->dbSize>0 ){ PgHdr *pPgHdr; /* Reference to page 1 */ - u32 change_counter; /* Initial value of change-counter field */ assert( !pPager->tempFile && isOpen(pPager->fd) ); @@ -5568,16 +5589,8 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ } if( rc==SQLITE_OK ){ - /* Increment the value just read and write it back to byte 24. */ - change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers); - change_counter++; - put32bits(((char*)pPgHdr->pData)+24, change_counter); - - /* Also store the SQLite version number in bytes 96..99 and in - ** bytes 92..95 store the change counter for which the version number - ** is valid. */ - put32bits(((char*)pPgHdr->pData)+92, change_counter); - put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER); + /* Actually do the update of the change counter */ + pager_write_changecounter(pPgHdr); /* If running in direct mode, write the contents of page 1 to the file. */ if( DIRECT_MODE ){ From d40d7ec78b4ac44c1b94fd8ac7356868966c811a Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 16 Jan 2011 00:56:19 +0000 Subject: [PATCH 52/82] Make sure the change-counter and SQLite-version fields of the header are set correctly even when doing a VACUUM with locking_mode=EXCLUSIVE. Ticket [5d863f876ee9561b]. FossilOrigin-Name: 04fa1e16905183b948ee6456675799a873d5f97d --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/pager.c | 3 ++- test/exclusive2.test | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index a2e7369c86..678c3b7d6e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Make\ssure\sthe\schange\scounter\sand\sSQLite\sversion\snumbers\sin\sthe\sheader\sare\nset\scorrectly,\seven\swhen\srunning\sin\sWAL\smode\sand\swhen\sVACUUMing\sin\sWAL\smode.\nTicket\s[5d863f876ee9561b9]. -D 2011-01-15T21:42:23.957 +C Make\ssure\sthe\schange-counter\sand\sSQLite-version\sfields\sof\sthe\sheader\sare\nset\scorrectly\seven\swhen\sdoing\sa\sVACUUM\swith\slocking_mode=EXCLUSIVE.\nTicket\s[5d863f876ee9561b]. +D 2011-01-16T00:56:19.189 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c 3e3e5cd39724107dc98edb39c1528b2d250c7b9a +F src/pager.c 8b6eb723cbf0774892a99465f7ddcf105c418638 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -377,7 +377,7 @@ F test/enc4.test 4b575ef09e0eff896e73bd24076f96c2aa6a42de F test/eqp.test 69670e7919030f21de29fb99bf1d68f97aedcbdb F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3 F test/exclusive.test 53e1841b422e554cecf0160f937c473d6d0e3062 -F test/exclusive2.test 76e63c05349cb70d09d60b99d2ae625525ff5155 +F test/exclusive2.test c2f2b2242dc436a12df8dd531e06843053bd3b9a F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/expr.test 620a636cf7b7d4e5834a0b9d83a4da372e24a7b7 F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P af54963f0fa0afafbc2d0847f30543c041b182ec 228e7c34c64114670fe015747d47fdaa3b7e1270 -R f10af8d4a2b23d5e0a4042a0305ee5bd +P 0be92a75769dbafbc08c3b229089aaac03a9a907 +R d8d7beadfbe9f74ad99892b81bbe4834 U drh -Z 6e401d9f8e8005a2d1afa0f68cfb5791 +Z 3a8faf9676cfe40a39d768a062675239 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNMhTEoxKgR168RlERAjWBAJwKez7r0WMgO4GDogJLKl9yAXwcqwCfZJEp -E+BxZJyeorWZrtHPF69nj0g= -=h8z+ +iD8DBQFNMkI4oxKgR168RlERAiL1AJ4+ojIGGkSFg5PKjeVFo2Q3S5VKTwCghUnC +uUw3JTyu+W3ezvTZ0vpp/zI= +=Qcvp -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e084a33966..c987bbb862 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0be92a75769dbafbc08c3b229089aaac03a9a907 \ No newline at end of file +04fa1e16905183b948ee6456675799a873d5f97d \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index e0b4cd3c50..846cdf63e3 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4005,6 +4005,7 @@ static int pager_write_pagelist(Pager *pPager, PgHdr *pList){ char *pData; /* Data to write */ assert( (pList->flags&PGHDR_NEED_SYNC)==0 ); + if( pList->pgno==1 ) pager_write_changecounter(pList); /* Encode the database */ CODEC2(pPager, pList->pData, pgno, 6, return SQLITE_NOMEM, pData); @@ -5584,7 +5585,7 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ ** direct mode, page 1 is always held in cache and hence the PagerGet() ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. */ - if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){ + if( !DIRECT_MODE && rc==SQLITE_OK ){ rc = sqlite3PagerWrite(pPgHdr); } diff --git a/test/exclusive2.test b/test/exclusive2.test index 6c3571d23b..4a167c7f42 100644 --- a/test/exclusive2.test +++ b/test/exclusive2.test @@ -299,13 +299,13 @@ do_test exclusive2-3.5 { INSERT INTO t1 VALUES(randstr(10, 400)); } readPagerChangeCounter test.db -} {4} +} {5} do_test exclusive2-3.6 { execsql { INSERT INTO t1 VALUES(randstr(10, 400)); } readPagerChangeCounter test.db -} {5} +} {6} sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) finish_test From c6aed5424b37c0432fd6f5d8def4bed32ed8fb47 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 16 Jan 2011 22:37:09 +0000 Subject: [PATCH 53/82] On a backup from a smaller to a larger page size, do not begin committing the transaction until the source pages after the pending byte have been copied. FossilOrigin-Name: 612e2599d3e1a17c268402fce018a53dee6dffe1 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/backup.c | 38 ++++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index 678c3b7d6e..c67c9ed302 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Make\ssure\sthe\schange-counter\sand\sSQLite-version\sfields\sof\sthe\sheader\sare\nset\scorrectly\seven\swhen\sdoing\sa\sVACUUM\swith\slocking_mode=EXCLUSIVE.\nTicket\s[5d863f876ee9561b]. -D 2011-01-16T00:56:19.189 +C On\sa\sbackup\sfrom\sa\ssmaller\sto\sa\slarger\spage\ssize,\sdo\snot\sbegin\scommitting\nthe\stransaction\suntil\sthe\ssource\spages\safter\sthe\spending\sbyte\shave\sbeen\ncopied. +D 2011-01-16T22:37:09.511 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -119,7 +119,7 @@ F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 F src/analyze.c 3af3fdb5edea9e69496b078935a3e6a2a1118b30 F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c ce552d975069f65ab1fc798950ff3582d8e76d58 +F src/backup.c 8c39a1ebba1e9dc385519cc4d434c7b0cab6638c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c a27c3b41082889fc258278ba501ff2594dda2a41 @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0be92a75769dbafbc08c3b229089aaac03a9a907 -R d8d7beadfbe9f74ad99892b81bbe4834 +P 04fa1e16905183b948ee6456675799a873d5f97d +R 3d005f718593bfc47c66fc1735978f86 U drh -Z 3a8faf9676cfe40a39d768a062675239 +Z 78481d4f7ffafe220d59a58e27e67e91 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNMkI4oxKgR168RlERAiL1AJ4+ojIGGkSFg5PKjeVFo2Q3S5VKTwCghUnC -uUw3JTyu+W3ezvTZ0vpp/zI= -=Qcvp +iD8DBQFNM3MZoxKgR168RlERAgouAJ9jAfVlLbWbhs2V9PnGaztVeVe3PACggVMY +rNuHhMxi5oUQ5cjcmZrMH5g= +=1Q7m -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index c987bbb862..b234784cbd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -04fa1e16905183b948ee6456675799a873d5f97d \ No newline at end of file +612e2599d3e1a17c268402fce018a53dee6dffe1 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index a37065080a..7258b26aa6 100644 --- a/src/backup.c +++ b/src/backup.c @@ -441,31 +441,33 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ */ const i64 iSize = (i64)pgszSrc * (i64)nSrcPage; sqlite3_file * const pFile = sqlite3PagerFile(pDestPager); + i64 iOff; + i64 iEnd; assert( pFile ); assert( (i64)nDestTruncate*(i64)pgszDest >= iSize || ( nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1) && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest )); - if( SQLITE_OK==(rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1)) - && SQLITE_OK==(rc = backupTruncateFile(pFile, iSize)) - && SQLITE_OK==(rc = sqlite3PagerSync(pDestPager)) + iEnd = MIN(PENDING_BYTE + pgszDest, iSize); + for( + iOff=PENDING_BYTE+pgszSrc; + rc==SQLITE_OK && iOff Date: Mon, 17 Jan 2011 02:24:12 +0000 Subject: [PATCH 54/82] Add back an ALWAYS() to regain full test coverage. FossilOrigin-Name: b93f6f3e679c7710f42580a8dd9ce43136376c1d --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index c67c9ed302..a1c36086a6 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C On\sa\sbackup\sfrom\sa\ssmaller\sto\sa\slarger\spage\ssize,\sdo\snot\sbegin\scommitting\nthe\stransaction\suntil\sthe\ssource\spages\safter\sthe\spending\sbyte\shave\sbeen\ncopied. -D 2011-01-16T22:37:09.511 +C Add\sback\san\sALWAYS()\sto\sregain\sfull\stest\scoverage. +D 2011-01-17T02:24:12.610 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c 8b6eb723cbf0774892a99465f7ddcf105c418638 +F src/pager.c 60d79b73d9fa7adce29e55231597416f1511d975 F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 04fa1e16905183b948ee6456675799a873d5f97d -R 3d005f718593bfc47c66fc1735978f86 +P 612e2599d3e1a17c268402fce018a53dee6dffe1 +R abd1ddc0cbd80cba70c03c409d8a0a78 U drh -Z 78481d4f7ffafe220d59a58e27e67e91 +Z 5deab45f651e1cc367fa113ca51b94f5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNM3MZoxKgR168RlERAgouAJ9jAfVlLbWbhs2V9PnGaztVeVe3PACggVMY -rNuHhMxi5oUQ5cjcmZrMH5g= -=1Q7m +iD8DBQFNM6hQoxKgR168RlERAnmGAJ9VtK6Ab9TW+dU+V6QdM+ALE833cQCfSTjg ++uTHGM0YHNJB4Zg+fvaxE9U= +=b8FC -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index b234784cbd..d6b6204659 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -612e2599d3e1a17c268402fce018a53dee6dffe1 \ No newline at end of file +b93f6f3e679c7710f42580a8dd9ce43136376c1d \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 846cdf63e3..39a3d5b86c 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5585,7 +5585,7 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ ** direct mode, page 1 is always held in cache and hence the PagerGet() ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. */ - if( !DIRECT_MODE && rc==SQLITE_OK ){ + if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){ rc = sqlite3PagerWrite(pPgHdr); } From 602acb4871657aaa998f48478fa44789b8a8dc62 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Jan 2011 17:42:37 +0000 Subject: [PATCH 55/82] Add the SQLITE_OMIT_AUTORESET compile-time option which if enabled causes the sqlite3_step() routine to return SQLITE_MISUSE if it is called after it has previously returned anything other than SQLITE_ROW, SQLITE_BUSY, or SQLITE_LOCKED. FossilOrigin-Name: 053ce76deb356d31358454507ba94947142e20ca --- install-sh | 0 manifest | 30 +++++++++++++++--------------- manifest.uuid | 2 +- src/ctime.c | 3 +++ src/sqlite.h.in | 18 +++++++++++------- src/test_config.c | 6 ++++++ src/vdbeapi.c | 25 ++++++++++++++++++++++--- test/capi2.test | 12 +++++++++--- test/fkey2.test | 12 +++++++++--- 9 files changed, 76 insertions(+), 32 deletions(-) mode change 100644 => 100755 install-sh diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index a1c36086a6..a59e3e3279 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sback\san\sALWAYS()\sto\sregain\sfull\stest\scoverage. -D 2011-01-17T02:24:12.610 +C Add\sthe\sSQLITE_OMIT_AUTORESET\scompile-time\soption\swhich\sif\senabled\scauses\nthe\ssqlite3_step()\sroutine\sto\sreturn\sSQLITE_MISUSE\sif\sit\sis\scalled\safter\nit\shas\spreviously\sreturned\sanything\sother\sthan\sSQLITE_ROW,\sSQLITE_BUSY,\sor\nSQLITE_LOCKED. +D 2011-01-17T17:42:37.670 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -100,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -128,7 +128,7 @@ F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 F src/build.c 00a327120d81ace6267e714ae8010c997d55de5d F src/callback.c a1d1b1c9c85415dff013af033e2fed9c8382d33b F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac -F src/ctime.c 4f3aadad62c6c9f0d4e5a96718516ac4e3c598df +F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd F src/expr.c 1810f3056b11de99cc10e24629edf00e5fbd3a75 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in e93b13af0879dcc56471fc7639dc8efa7d0de832 +F src/sqlite.h.in ca8b7b6329937e54a2cce2b897c3a4fa2ec5b3fb F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -199,7 +199,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c 55918873f0a2ebbd5b52417319987f9f99c401fa +F src/test_config.c 9f025a7f3686c94e82dc6d6bd3cbf0f89cd67487 F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c 13b582345fb1185a93e46c53310fae8547dcce20 @@ -234,7 +234,7 @@ F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f F src/vdbe.c 5d310eaf1a4d8383602126fa82e01291ab7d3cf3 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 6e6f28e9bccc6c703dca1372fd661c57b5c15fb0 -F src/vdbeapi.c 0f898cc77099f0b0b4d6a045e905c3501f9c8b27 +F src/vdbeapi.c 69c82283ab2b64c0c37a07799d771d4058330743 F src/vdbeaux.c 33448d23b857654dd69ed2103611f5c733606f68 F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 @@ -296,7 +296,7 @@ F test/boundary4.tcl 0bb4b1a94f4fc5ae59b79b9a2b7a140c405e2983 F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0 F test/cache.test 754baab2f18089fc9bcba7afaeb4dc907c6c6de2 -F test/capi2.test 00032d7504b9c14f1b36331670c5e7b0f73e3c5d +F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360 F test/capi3.test 1945a2ba75e3f4c49d5beb8fc092115b6292d471 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test bea67403a5e37a4b33230ee4723e315a2ffb31e7 @@ -384,7 +384,7 @@ F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e F test/filefmt.test f77c92141960b7933bc6691631d2ad62257ef40a F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da -F test/fkey2.test e028cd80aa0bd38541c99214e3ba2dfccadffe6f +F test/fkey2.test 080969fe219b3b082b0e097ac18c6af2e5b0631f F test/fkey3.test 42f88d6048d8dc079e2a8cf7baad1cc1483a7620 F test/fkey_malloc.test a5ede29bd2f6e56dea78c3d43fb86dd696c068c8 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 612e2599d3e1a17c268402fce018a53dee6dffe1 -R abd1ddc0cbd80cba70c03c409d8a0a78 +P b93f6f3e679c7710f42580a8dd9ce43136376c1d +R 6dc66aed498487341b067c32818edd59 U drh -Z 5deab45f651e1cc367fa113ca51b94f5 +Z e50fa3b22eb702afe6aa782a8e86a0c4 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNM6hQoxKgR168RlERAnmGAJ9VtK6Ab9TW+dU+V6QdM+ALE833cQCfSTjg -+uTHGM0YHNJB4Zg+fvaxE9U= -=b8FC +iD8DBQFNNH+RoxKgR168RlERArkrAKCNKjNRwcXopvvMlZTssdPU/VXRNgCfWDwM +8nE9/3MAUpfOEzl9WxkBTP4= +=RWjs -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index d6b6204659..eb5cfbe72f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b93f6f3e679c7710f42580a8dd9ce43136376c1d \ No newline at end of file +053ce76deb356d31358454507ba94947142e20ca \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index f7248f4fa0..a128f61a69 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -174,6 +174,9 @@ static const char * const azCompileOpt[] = { #ifdef SQLITE_OMIT_AUTOMATIC_INDEX "OMIT_AUTOMATIC_INDEX", #endif +#ifdef SQLITE_OMIT_AUTORESET + "OMIT_AUTORESET", +#endif #ifdef SQLITE_OMIT_AUTOVACUUM "OMIT_AUTOVACUUM", #endif diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 27121072ad..c258493928 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3078,13 +3078,17 @@ const void *sqlite3_column_decltype16(sqlite3_stmt*,int); ** be the case that the same database connection is being used by two or ** more threads at the same moment in time. ** -** For all versions of SQLite up to and including 3.6.23.1, it was required -** after sqlite3_step() returned anything other than [SQLITE_ROW] that -** [sqlite3_reset()] be called before any subsequent invocation of -** sqlite3_step(). Failure to invoke [sqlite3_reset()] in this way would -** result in an [SQLITE_MISUSE] return from sqlite3_step(). But after -** version 3.6.23.1, sqlite3_step() began calling [sqlite3_reset()] -** automatically in this circumstance rather than returning [SQLITE_MISUSE]. +** For all versions of SQLite up to and including 3.6.23.1, a call to +** [sqlite3_reset()] was required after sqlite3_step() returned anything +** other than [SQLITE_ROW] before any subsequent invocation of +** sqlite3_step(). Failure to reset the prepared statement using +** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from +** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began +** calling [sqlite3_reset()] automatically in this circumstance rather +** than returning [SQLITE_MISUSE]. This is not considered a compatibility +** break because any application that ever receives an SQLITE_MISUSE error +** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option +** can be used to restore the legacy behavior. ** ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any diff --git a/src/test_config.c b/src/test_config.c index 12df78709a..def12a9afc 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -133,6 +133,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "autoindex", "1", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_OMIT_AUTORESET + Tcl_SetVar2(interp, "sqlite_options", "autoreset", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "autoreset", "1", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_OMIT_AUTOVACUUM Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "0", TCL_GLOBAL_ONLY); #else diff --git a/src/vdbeapi.c b/src/vdbeapi.c index f08c296d1d..ca454acc20 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -345,11 +345,30 @@ static int sqlite3Step(Vdbe *p){ assert(p); if( p->magic!=VDBE_MAGIC_RUN ){ /* We used to require that sqlite3_reset() be called before retrying - ** sqlite3_step() after any error. But after 3.6.23, we changed this - ** so that sqlite3_reset() would be called automatically instead of - ** throwing the error. + ** sqlite3_step() after any error or after SQLITE_DONE. But beginning + ** with version 3.7.0, we changed this so that sqlite3_reset() would + ** be called automatically instead of throwing the SQLITE_MISUSE error. + ** This "automatic-reset" change is not technically an incompatibility, + ** since any application that receives an SQLITE_MISUSE is broken by + ** definition. + ** + ** Nevertheless, some published applications that were originally written + ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE + ** returns, and the so were broken by the automatic-reset change. As a + ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the + ** legacy behavior of returning SQLITE_MISUSE for cases where the + ** previous sqlite3_step() returned something other than a SQLITE_LOCKED + ** or SQLITE_BUSY error. */ +#ifdef SQLITE_OMIT_AUTORESET + if( p->rc==SQLITE_BUSY || p->rc==SQLITE_LOCKED ){ + sqlite3_reset((sqlite3_stmt*)p); + }else{ + return SQLITE_MISUSE_BKPT; + } +#else sqlite3_reset((sqlite3_stmt*)p); +#endif } /* Check that malloc() has not failed. If it has, return early. */ diff --git a/test/capi2.test b/test/capi2.test index b4aa970c8e..8b36ac6925 100644 --- a/test/capi2.test +++ b/test/capi2.test @@ -74,9 +74,15 @@ do_test capi2-1.7 { # This used to be SQLITE_MISUSE. But now we automatically reset prepared # statements. -do_test capi2-1.8 { - sqlite3_step $VM -} {SQLITE_ROW} +ifcapable autoreset { + do_test capi2-1.8 { + sqlite3_step $VM + } {SQLITE_ROW} +} else { + do_test capi2-1.8 { + sqlite3_step $VM + } {SQLITE_MISUSE} +} # Update: In v2, once SQLITE_MISUSE is returned the statement handle cannot # be interrogated for more information. However in v3, since the column diff --git a/test/fkey2.test b/test/fkey2.test index 07c47e4b49..f0cc4d244c 100644 --- a/test/fkey2.test +++ b/test/fkey2.test @@ -1414,9 +1414,15 @@ do_test fkey2-17.1.2 { set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy] sqlite3_step $STMT } {SQLITE_CONSTRAINT} -do_test fkey2-17.1.3 { - sqlite3_step $STMT -} {SQLITE_CONSTRAINT} +ifcapable autoreset { + do_test fkey2-17.1.3 { + sqlite3_step $STMT + } {SQLITE_CONSTRAINT} +} else { + do_test fkey2-17.1.3 { + sqlite3_step $STMT + } {SQLITE_MISUSE} +} do_test fkey2-17.1.4 { sqlite3_finalize $STMT } {SQLITE_CONSTRAINT} From eee50ca5a747cc40606d26a643be040d1445f5fe Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Jan 2011 18:30:10 +0000 Subject: [PATCH 56/82] Fix a typo in the documentation for sqlite3_stmt_readonly(). FossilOrigin-Name: 56417a3386fc84dd36bf1488e88149b1ac6a0d02 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a59e3e3279..efbad616ed 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sthe\sSQLITE_OMIT_AUTORESET\scompile-time\soption\swhich\sif\senabled\scauses\nthe\ssqlite3_step()\sroutine\sto\sreturn\sSQLITE_MISUSE\sif\sit\sis\scalled\safter\nit\shas\spreviously\sreturned\sanything\sother\sthan\sSQLITE_ROW,\sSQLITE_BUSY,\sor\nSQLITE_LOCKED. -D 2011-01-17T17:42:37.670 +C Fix\sa\stypo\sin\sthe\sdocumentation\sfor\ssqlite3_stmt_readonly(). +D 2011-01-17T18:30:10.560 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in ca8b7b6329937e54a2cce2b897c3a4fa2ec5b3fb +F src/sqlite.h.in 18a60e7e9f846fce21081b58d0f172dc5f3ee8ef F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b93f6f3e679c7710f42580a8dd9ce43136376c1d -R 6dc66aed498487341b067c32818edd59 +P 053ce76deb356d31358454507ba94947142e20ca +R f54d561af253c3d1376dc02d1c240211 U drh -Z e50fa3b22eb702afe6aa782a8e86a0c4 +Z 8c25e4062798f189ea989bddedbb0345 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNNH+RoxKgR168RlERArkrAKCNKjNRwcXopvvMlZTssdPU/VXRNgCfWDwM -8nE9/3MAUpfOEzl9WxkBTP4= -=RWjs +iD8DBQFNNIq1oxKgR168RlERAhJIAJ41aqeYSwX6tnjlDZCSWspksdAFOACfbM7B +qyqhJCGIuNC0hRiUIh/Gvzw= +=CR8k -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index eb5cfbe72f..2bfaca6792 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -053ce76deb356d31358454507ba94947142e20ca \ No newline at end of file +56417a3386fc84dd36bf1488e88149b1ac6a0d02 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index c258493928..3392170a3b 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2661,7 +2661,7 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt); ** CAPI3REF: Determine If An SQL Statement Writes The Database ** ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if -** and only if the [prepared statement] X is makes no direct changes to +** and only if the [prepared statement] X makes no direct changes to ** the content of the database file. ** ** Note that [application-defined SQL functions] or From 9f8cf9da27353565f6770a311a88529b373817b6 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Jan 2011 21:32:24 +0000 Subject: [PATCH 57/82] Here is a completely new implementation of the mutex-free-pcache. This one uses a common code base and automatically selects whether or not to use mutexes depending on compile-time and start-time options. FossilOrigin-Name: d094a1bfb7569a52b637fe9ba5d3fa6ce5ea6d94 --- manifest | 22 ++-- manifest.uuid | 2 +- src/pcache1.c | 334 +++++++++++++++++++++++++++++++------------------- 3 files changed, 224 insertions(+), 134 deletions(-) diff --git a/manifest b/manifest index efbad616ed..1291f1bd4b 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\stypo\sin\sthe\sdocumentation\sfor\ssqlite3_stmt_readonly(). -D 2011-01-17T18:30:10.560 +C Here\sis\sa\scompletely\snew\simplementation\sof\sthe\smutex-free-pcache.\s\sThis\none\suses\sa\scommon\scode\sbase\sand\sautomatically\sselects\swhether\sor\snot\sto\s\nuse\smutexes\sdepending\son\scompile-time\sand\sstart-time\soptions. +D 2011-01-17T21:32:24.379 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c 306389ff1a9677fc93533c3100b728c43cc007c0 +F src/pcache1.c 35f4d8d3e876708fa5b2174d32ce0b996470c88d F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc F src/printf.c 37e8bfd4c5a04eae4960adbe776b0f1fc4cad674 @@ -899,14 +899,18 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 053ce76deb356d31358454507ba94947142e20ca -R f54d561af253c3d1376dc02d1c240211 +P 56417a3386fc84dd36bf1488e88149b1ac6a0d02 +R 983645a96ff6d3f0292bd851bc48a03a +T *bgcolor * #a8d3c0 +T *branch * mutex-free-pcache +T *sym-mutex-free-pcache * +T -sym-trunk * U drh -Z 8c25e4062798f189ea989bddedbb0345 +Z a140fb68339099588b73b5639a289144 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNNIq1oxKgR168RlERAhJIAJ41aqeYSwX6tnjlDZCSWspksdAFOACfbM7B -qyqhJCGIuNC0hRiUIh/Gvzw= -=CR8k +iD4DBQFNNLVroxKgR168RlERAujGAJiIbOhYAepMRCuh0ytKZr7hYPulAKCJCvYa +QRfjhT9WvrqQrKNgWqHNNA== +=eKGZ -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 2bfaca6792..4d906cd39e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -56417a3386fc84dd36bf1488e88149b1ac6a0d02 \ No newline at end of file +d094a1bfb7569a52b637fe9ba5d3fa6ce5ea6d94 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 2485ffa097..8535e90ef0 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -22,6 +22,37 @@ typedef struct PCache1 PCache1; typedef struct PgHdr1 PgHdr1; typedef struct PgFreeslot PgFreeslot; +typedef struct PGroup PGroup; + +/* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set +** of one or more PCaches that are able to recycle each others unpinned +** pages when they are under memory pressure. A PGroup is an instance of +** the following object. +** +** This page cache implementation works in one of two modes: +** +** (1) Every PCache is the sole member of its own PGroup. There is +** one PGroup per PCache. +** +** (2) There is a single global PGroup that all PCaches are a member +** of. +** +** Mode 1 uses more memory (since PCache instances are not able to rob +** unused pages from other PCaches) but it also operates without a mutex, +** and is therefore often faster. Mode 2 requires a mutex in order to be +** threadsafe, but is able recycle pages more efficient. +** +** For mode (1), PGroup.mutex is NULL. For mode (2) there is only a single +** PGroup which is the pcache1.grp global variable and its mutex is +** SQLITE_MUTEX_STATIC_LRU. +*/ +struct PGroup { + sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ + int nMaxPage; /* Sum of nMax for purgeable caches */ + int nMinPage; /* Sum of nMin for purgeable caches */ + int nCurrentPage; /* Number of purgeable pages allocated */ + PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ +}; /* Each page cache is an instance of the following object. Every ** open database file (including each in-memory database and each @@ -35,16 +66,16 @@ struct PCache1 { /* Cache configuration parameters. Page size (szPage) and the purgeable ** flag (bPurgeable) are set when the cache is created. nMax may be ** modified at any time by a call to the pcache1CacheSize() method. - ** The global mutex must be held when accessing nMax. + ** The PGroup mutex must be held when accessing nMax. */ + PGroup *pGroup; /* PGroup this cache belongs to */ int szPage; /* Size of allocated pages in bytes */ int bPurgeable; /* True if cache is purgeable */ unsigned int nMin; /* Minimum number of pages reserved */ unsigned int nMax; /* Configured "cache_size" value */ /* Hash table of all pages. The following variables may only be accessed - ** when the accessor is holding the global mutex (see pcache1EnterMutex() - ** and pcache1LeaveMutex()). + ** when the accessor is holding the PGroup mutex. */ unsigned int nRecyclable; /* Number of pages in the LRU list */ unsigned int nPage; /* Total number of pages in apHash */ @@ -80,21 +111,27 @@ struct PgFreeslot { ** Global data used by this cache. */ static SQLITE_WSD struct PCacheGlobal { - sqlite3_mutex *mutex; /* static mutex MUTEX_STATIC_LRU */ + PGroup grp; /* The global PGroup for mode (2) */ - int nMaxPage; /* Sum of nMaxPage for purgeable caches */ - int nMinPage; /* Sum of nMinPage for purgeable caches */ - int nCurrentPage; /* Number of purgeable pages allocated */ - PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ - - /* Variables related to SQLITE_CONFIG_PAGECACHE settings. */ - int szSlot; /* Size of each free slot */ - int nSlot; /* The number of pcache slots */ - int nFreeSlot; /* Number of unused pcache slots */ - int nReserve; /* Try to keep nFreeSlot above this */ - void *pStart, *pEnd; /* Bounds of pagecache malloc range */ - PgFreeslot *pFree; /* Free page blocks */ - int isInit; /* True if initialized */ + /* Variables related to SQLITE_CONFIG_PAGECACHE settings. The + ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all + ** fixed at sqlite3_initialize() time and do not require mutex protection. + ** The nFreeSlot and pFree values do require mutex protection. + */ + int isInit; /* True if initialized */ + int szSlot; /* Size of each free slot */ + int nSlot; /* The number of pcache slots */ + int nReserve; /* Try to keep nFreeSlot above this */ + void *pStart, *pEnd; /* Bounds of pagecache malloc range */ + /* Above requires no mutex. Use mutex below for variable that follow. */ + sqlite3_mutex *mutex; /* Mutex for accessing the following: */ + int nFreeSlot; /* Number of unused pcache slots */ + PgFreeslot *pFree; /* Free page blocks */ + /* The following value requires a mutex to change. We skip the mutex on + ** reading because (1) most platforms read a 32-bit integer atomically and + ** (2) even if an incorrect value is read, no great harm is done since this + ** is really just an optimization. */ + int bUnderPressure; /* True if low on PAGECACHE memory */ } pcache1_g; /* @@ -120,10 +157,10 @@ static SQLITE_WSD struct PCacheGlobal { #define PAGE_TO_PGHDR1(c, p) (PgHdr1*)(((char*)p) + c->szPage) /* -** Macros to enter and leave the global LRU mutex. +** Macros to enter and leave the PCache LRU mutex. */ -#define pcache1EnterMutex() sqlite3_mutex_enter(pcache1.mutex) -#define pcache1LeaveMutex() sqlite3_mutex_leave(pcache1.mutex) +#define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex) +#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex) /******************************************************************************/ /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ @@ -133,6 +170,9 @@ static SQLITE_WSD struct PCacheGlobal { ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE ** verb to sqlite3_config(). Parameter pBuf points to an allocation large ** enough to contain 'n' buffers of 'sz' bytes each. +** +** This routine is called from sqlite3_initialize() and so it is guaranteed +** to be serialized already. There is no need for further mutexing. */ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){ if( pcache1.isInit ){ @@ -143,6 +183,7 @@ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){ pcache1.nReserve = n>90 ? 10 : (n/10 + 1); pcache1.pStart = pBuf; pcache1.pFree = 0; + pcache1.bUnderPressure = 0; while( n-- ){ p = (PgFreeslot*)pBuf; p->pNext = pcache1.pFree; @@ -158,29 +199,31 @@ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){ ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no ** such buffer exists or there is no space left in it, this function falls ** back to sqlite3Malloc(). +** +** Multiple threads can run this routine at the same time. Global variables +** in pcache1 need to be protected via mutex. */ static void *pcache1Alloc(int nByte){ - void *p; - assert( sqlite3_mutex_held(pcache1.mutex) ); + void *p = 0; + assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte); - if( nByte<=pcache1.szSlot && pcache1.pFree ){ - assert( pcache1.isInit ); + if( nByte<=pcache1.szSlot ){ + sqlite3_mutex_enter(pcache1.mutex); p = (PgHdr1 *)pcache1.pFree; - pcache1.pFree = pcache1.pFree->pNext; - pcache1.nFreeSlot--; - assert( pcache1.nFreeSlot>=0 ); - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); - }else{ - - /* Allocate a new buffer using sqlite3Malloc. Before doing so, exit the - ** global pcache mutex and unlock the pager-cache object pCache. This is - ** so that if the attempt to allocate a new buffer causes the the - ** configured soft-heap-limit to be breached, it will be possible to - ** reclaim memory from this pager-cache. + if( p ){ + pcache1.pFree = pcache1.pFree->pNext; + pcache1.nFreeSlot--; + pcache1.bUnderPressure = pcache1.nFreeSlot=0 ); + sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); + } + sqlite3_mutex_leave(pcache1.mutex); + } + if( p==0 ){ + /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get + ** it from sqlite3Malloc instead. */ - pcache1LeaveMutex(); p = sqlite3Malloc(nByte); - pcache1EnterMutex(); if( p ){ int sz = sqlite3MallocSize(p); sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); @@ -194,16 +237,18 @@ static void *pcache1Alloc(int nByte){ ** Free an allocated buffer obtained from pcache1Alloc(). */ static void pcache1Free(void *p){ - assert( sqlite3_mutex_held(pcache1.mutex) ); if( p==0 ) return; if( p>=pcache1.pStart && ppNext = pcache1.pFree; pcache1.pFree = pSlot; pcache1.nFreeSlot++; + pcache1.bUnderPressure = pcache1.nFreeSlot=pcache1.pStart && pbPurgeable ){ - pcache1.nCurrentPage++; + pCache->pGroup->nCurrentPage++; } }else{ p = 0; @@ -260,8 +304,9 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ */ static void pcache1FreePage(PgHdr1 *p){ if( ALWAYS(p) ){ - if( p->pCache->bPurgeable ){ - pcache1.nCurrentPage--; + PCache1 *pCache = p->pCache; + if( pCache->bPurgeable ){ + pCache->pGroup->nCurrentPage--; } pcache1Free(PGHDR1_TO_PAGE(p)); } @@ -273,20 +318,14 @@ static void pcache1FreePage(PgHdr1 *p){ ** exists, this function falls back to sqlite3Malloc(). */ void *sqlite3PageMalloc(int sz){ - void *p; - pcache1EnterMutex(); - p = pcache1Alloc(sz); - pcache1LeaveMutex(); - return p; + return pcache1Alloc(sz); } /* ** Free an allocated buffer obtained from sqlite3PageMalloc(). */ void sqlite3PageFree(void *p){ - pcache1EnterMutex(); pcache1Free(p); - pcache1LeaveMutex(); } @@ -307,9 +346,8 @@ void sqlite3PageFree(void *p){ ** the heap even further. */ static int pcache1UnderMemoryPressure(PCache1 *pCache){ - assert( sqlite3_mutex_held(pcache1.mutex) ); if( pcache1.nSlot && pCache->szPage<=pcache1.szSlot ){ - return pcache1.nFreeSlotpGroup->mutex) ); nNew = p->nHash*2; if( nNew<256 ){ nNew = 256; } - pcache1LeaveMutex(); + pcache1LeaveMutex(p->pGroup); if( p->nHash ){ sqlite3BeginBenignMalloc(); } apNew = (PgHdr1 **)sqlite3_malloc(sizeof(PgHdr1 *)*nNew); if( p->nHash ){ sqlite3EndBenignMalloc(); } - pcache1EnterMutex(); + pcache1EnterMutex(p->pGroup); if( apNew ){ memset(apNew, 0, sizeof(PgHdr1 *)*nNew); for(i=0; inHash; i++){ @@ -363,25 +401,33 @@ static int pcache1ResizeHash(PCache1 *p){ /* ** This function is used internally to remove the page pPage from the -** global LRU list, if is part of it. If pPage is not part of the global +** PGroup LRU list, if is part of it. If pPage is not part of the PGroup ** LRU list, then this function is a no-op. ** -** The global mutex must be held when this function is called. +** The PGroup mutex must be held when this function is called. +** +** If pPage is NULL then this routine is a no-op. */ static void pcache1PinPage(PgHdr1 *pPage){ - assert( sqlite3_mutex_held(pcache1.mutex) ); - if( pPage && (pPage->pLruNext || pPage==pcache1.pLruTail) ){ + PCache1 *pCache; + PGroup *pGroup; + + if( pPage==0 ) return; + pCache = pPage->pCache; + pGroup = pCache->pGroup; + assert( sqlite3_mutex_held(pGroup->mutex) ); + if( pPage->pLruNext || pPage==pGroup->pLruTail ){ if( pPage->pLruPrev ){ pPage->pLruPrev->pLruNext = pPage->pLruNext; } if( pPage->pLruNext ){ pPage->pLruNext->pLruPrev = pPage->pLruPrev; } - if( pcache1.pLruHead==pPage ){ - pcache1.pLruHead = pPage->pLruNext; + if( pGroup->pLruHead==pPage ){ + pGroup->pLruHead = pPage->pLruNext; } - if( pcache1.pLruTail==pPage ){ - pcache1.pLruTail = pPage->pLruPrev; + if( pGroup->pLruTail==pPage ){ + pGroup->pLruTail = pPage->pLruPrev; } pPage->pLruNext = 0; pPage->pLruPrev = 0; @@ -394,13 +440,14 @@ static void pcache1PinPage(PgHdr1 *pPage){ ** Remove the page supplied as an argument from the hash table ** (PCache1.apHash structure) that it is currently stored in. ** -** The global mutex must be held when this function is called. +** The PGroup mutex must be held when this function is called. */ static void pcache1RemoveFromHash(PgHdr1 *pPage){ unsigned int h; PCache1 *pCache = pPage->pCache; PgHdr1 **pp; + assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); h = pPage->iKey % pCache->nHash; for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext); *pp = (*pp)->pNext; @@ -409,13 +456,14 @@ static void pcache1RemoveFromHash(PgHdr1 *pPage){ } /* -** If there are currently more than pcache.nMaxPage pages allocated, try -** to recycle pages to reduce the number allocated to pcache.nMaxPage. +** If there are currently more than nMaxPage pages allocated, try +** to recycle pages to reduce the number allocated to nMaxPage. */ -static void pcache1EnforceMaxPage(void){ - assert( sqlite3_mutex_held(pcache1.mutex) ); - while( pcache1.nCurrentPage>pcache1.nMaxPage && pcache1.pLruTail ){ - PgHdr1 *p = pcache1.pLruTail; +static void pcache1EnforceMaxPage(PGroup *pGroup){ + assert( sqlite3_mutex_held(pGroup->mutex) ); + while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){ + PgHdr1 *p = pGroup->pLruTail; + assert( p->pCache->pGroup==pGroup ); pcache1PinPage(p); pcache1RemoveFromHash(p); pcache1FreePage(p); @@ -427,15 +475,15 @@ static void pcache1EnforceMaxPage(void){ ** greater than or equal to iLimit. Any pinned pages that meet this ** criteria are unpinned before they are discarded. ** -** The global mutex must be held when this function is called. +** The PCache mutex must be held when this function is called. */ static void pcache1TruncateUnsafe( - PCache1 *pCache, - unsigned int iLimit + PCache1 *pCache, /* The cache to truncate */ + unsigned int iLimit /* Drop pages with this pgno or larger */ ){ - TESTONLY( unsigned int nPage = 0; ) /* Used to assert pCache->nPage is correct */ + TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */ unsigned int h; - assert( sqlite3_mutex_held(pcache1.mutex) ); + assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); for(h=0; hnHash; h++){ PgHdr1 **pp = &pCache->apHash[h]; PgHdr1 *pPage; @@ -465,7 +513,8 @@ static int pcache1Init(void *NotUsed){ assert( pcache1.isInit==0 ); memset(&pcache1, 0, sizeof(pcache1)); if( sqlite3GlobalConfig.bCoreMutex ){ - pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); + pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); + pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2); } pcache1.isInit = 1; return SQLITE_OK; @@ -488,18 +537,45 @@ static void pcache1Shutdown(void *NotUsed){ ** Allocate a new cache. */ static sqlite3_pcache *pcache1Create(int szPage, int bPurgeable){ - PCache1 *pCache; + PCache1 *pCache; /* The newly created page cache */ + PGroup *pGroup; /* The group the new page cache will belong to */ + int sz; /* Bytes of memory required to allocate the new cache */ - pCache = (PCache1 *)sqlite3_malloc(sizeof(PCache1)); + /* + ** The seperateCache variable is true if each PCache has its own private + ** PGroup. In other words, separateCache is true for mode (1) where no + ** mutexing is required. + ** + ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT + ** + ** * Always use a unified cache in single-threaded applications + ** + ** * Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off) + ** use separate caches (mode-1) + */ +#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0 + const int separateCache = 0; +#else + int separateCache = sqlite3GlobalConfig.bCoreMutex>0; +#endif + + sz = sizeof(PCache1) + sizeof(PGroup)*separateCache; + pCache = (PCache1 *)sqlite3_malloc(sz); if( pCache ){ - memset(pCache, 0, sizeof(PCache1)); + memset(pCache, 0, sz); + if( separateCache ){ + pGroup = (PGroup*)&pCache[1]; + }else{ + pGroup = &pcache1_g.grp; + } + pCache->pGroup = pGroup; pCache->szPage = szPage; pCache->bPurgeable = (bPurgeable ? 1 : 0); if( bPurgeable ){ pCache->nMin = 10; - pcache1EnterMutex(); - pcache1.nMinPage += pCache->nMin; - pcache1LeaveMutex(); + pcache1EnterMutex(pGroup); + pGroup->nMinPage += pCache->nMin; + pcache1LeaveMutex(pGroup); } } return (sqlite3_pcache *)pCache; @@ -513,11 +589,12 @@ static sqlite3_pcache *pcache1Create(int szPage, int bPurgeable){ static void pcache1Cachesize(sqlite3_pcache *p, int nMax){ PCache1 *pCache = (PCache1 *)p; if( pCache->bPurgeable ){ - pcache1EnterMutex(); - pcache1.nMaxPage += (nMax - pCache->nMax); + PGroup *pGroup = pCache->pGroup; + pcache1EnterMutex(pGroup); + pGroup->nMaxPage += (nMax - pCache->nMax); pCache->nMax = nMax; - pcache1EnforceMaxPage(); - pcache1LeaveMutex(); + pcache1EnforceMaxPage(pGroup); + pcache1LeaveMutex(pGroup); } } @@ -526,9 +603,10 @@ static void pcache1Cachesize(sqlite3_pcache *p, int nMax){ */ static int pcache1Pagecount(sqlite3_pcache *p){ int n; - pcache1EnterMutex(); - n = ((PCache1 *)p)->nPage; - pcache1LeaveMutex(); + PCache1 *pCache = (PCache1*)p; + pcache1EnterMutex(pCache->pGroup); + n = pCache->nPage; + pcache1LeaveMutex(pCache->pGroup); return n; } @@ -589,10 +667,11 @@ static int pcache1Pagecount(sqlite3_pcache *p){ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ unsigned int nPinned; PCache1 *pCache = (PCache1 *)p; + PGroup *pGroup = pCache->pGroup; PgHdr1 *pPage = 0; assert( pCache->bPurgeable || createFlag!=1 ); - pcache1EnterMutex(); + pcache1EnterMutex(pGroup); if( createFlag==1 ) sqlite3BeginBenignMalloc(); /* Search the hash table for an existing entry. */ @@ -609,7 +688,7 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ /* Step 3 of header comment. */ nPinned = pCache->nPage - pCache->nRecyclable; if( createFlag==1 && ( - nPinned>=(pcache1.nMaxPage+pCache->nMin-pcache1.nMinPage) + nPinned>=(pGroup->nMaxPage+pCache->nMin-pGroup->nMinPage) || nPinned>=(pCache->nMax * 9 / 10) || pcache1UnderMemoryPressure(pCache) )){ @@ -621,19 +700,20 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ } /* Step 4. Try to recycle a page buffer if appropriate. */ - if( pCache->bPurgeable && pcache1.pLruTail && ( + if( pCache->bPurgeable && pGroup->pLruTail && ( (pCache->nPage+1>=pCache->nMax) - || pcache1.nCurrentPage>=pcache1.nMaxPage + || pGroup->nCurrentPage>=pGroup->nMaxPage || pcache1UnderMemoryPressure(pCache) )){ - pPage = pcache1.pLruTail; + pPage = pGroup->pLruTail; pcache1RemoveFromHash(pPage); pcache1PinPage(pPage); if( pPage->pCache->szPage!=pCache->szPage ){ pcache1FreePage(pPage); pPage = 0; }else{ - pcache1.nCurrentPage -= (pPage->pCache->bPurgeable - pCache->bPurgeable); + pGroup->nCurrentPage -= + (pPage->pCache->bPurgeable - pCache->bPurgeable); } } @@ -641,7 +721,9 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ ** attempt to allocate a new one. */ if( !pPage ){ + pcache1LeaveMutex(pGroup); pPage = pcache1AllocPage(pCache); + pcache1EnterMutex(pGroup); } if( pPage ){ @@ -661,7 +743,7 @@ fetch_out: pCache->iMaxKey = iKey; } if( createFlag==1 ) sqlite3EndBenignMalloc(); - pcache1LeaveMutex(); + pcache1LeaveMutex(pGroup); return (pPage ? PGHDR1_TO_PAGE(pPage) : 0); } @@ -674,33 +756,34 @@ fetch_out: static void pcache1Unpin(sqlite3_pcache *p, void *pPg, int reuseUnlikely){ PCache1 *pCache = (PCache1 *)p; PgHdr1 *pPage = PAGE_TO_PGHDR1(pCache, pPg); + PGroup *pGroup = pCache->pGroup; assert( pPage->pCache==pCache ); - pcache1EnterMutex(); + pcache1EnterMutex(pGroup); /* It is an error to call this function if the page is already - ** part of the global LRU list. + ** part of the PGroup LRU list. */ assert( pPage->pLruPrev==0 && pPage->pLruNext==0 ); - assert( pcache1.pLruHead!=pPage && pcache1.pLruTail!=pPage ); + assert( pGroup->pLruHead!=pPage && pGroup->pLruTail!=pPage ); - if( reuseUnlikely || pcache1.nCurrentPage>pcache1.nMaxPage ){ + if( reuseUnlikely || pGroup->nCurrentPage>pGroup->nMaxPage ){ pcache1RemoveFromHash(pPage); pcache1FreePage(pPage); }else{ - /* Add the page to the global LRU list. */ - if( pcache1.pLruHead ){ - pcache1.pLruHead->pLruPrev = pPage; - pPage->pLruNext = pcache1.pLruHead; - pcache1.pLruHead = pPage; + /* Add the page to the PGroup LRU list. */ + if( pGroup->pLruHead ){ + pGroup->pLruHead->pLruPrev = pPage; + pPage->pLruNext = pGroup->pLruHead; + pGroup->pLruHead = pPage; }else{ - pcache1.pLruTail = pPage; - pcache1.pLruHead = pPage; + pGroup->pLruTail = pPage; + pGroup->pLruHead = pPage; } pCache->nRecyclable++; } - pcache1LeaveMutex(); + pcache1LeaveMutex(pCache->pGroup); } /* @@ -719,7 +802,7 @@ static void pcache1Rekey( assert( pPage->iKey==iOld ); assert( pPage->pCache==pCache ); - pcache1EnterMutex(); + pcache1EnterMutex(pCache->pGroup); h = iOld%pCache->nHash; pp = &pCache->apHash[h]; @@ -736,7 +819,7 @@ static void pcache1Rekey( pCache->iMaxKey = iNew; } - pcache1LeaveMutex(); + pcache1LeaveMutex(pCache->pGroup); } /* @@ -748,12 +831,12 @@ static void pcache1Rekey( */ static void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){ PCache1 *pCache = (PCache1 *)p; - pcache1EnterMutex(); + pcache1EnterMutex(pCache->pGroup); if( iLimit<=pCache->iMaxKey ){ pcache1TruncateUnsafe(pCache, iLimit); pCache->iMaxKey = iLimit-1; } - pcache1LeaveMutex(); + pcache1LeaveMutex(pCache->pGroup); } /* @@ -763,13 +846,14 @@ static void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){ */ static void pcache1Destroy(sqlite3_pcache *p){ PCache1 *pCache = (PCache1 *)p; + PGroup *pGroup = pCache->pGroup; assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); - pcache1EnterMutex(); + pcache1EnterMutex(pGroup); pcache1TruncateUnsafe(pCache, 0); - pcache1.nMaxPage -= pCache->nMax; - pcache1.nMinPage -= pCache->nMin; - pcache1EnforceMaxPage(); - pcache1LeaveMutex(); + pGroup->nMaxPage -= pCache->nMax; + pGroup->nMinPage -= pCache->nMin; + pcache1EnforceMaxPage(pGroup); + pcache1LeaveMutex(pGroup); sqlite3_free(pCache->apHash); sqlite3_free(pCache); } @@ -808,16 +892,18 @@ void sqlite3PCacheSetDefault(void){ */ int sqlite3PcacheReleaseMemory(int nReq){ int nFree = 0; + assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); + assert( sqlite3_mutex_notheld(pcache1.mutex) ); if( pcache1.pStart==0 ){ PgHdr1 *p; - pcache1EnterMutex(); - while( (nReq<0 || nFreepLruNext){ + for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ nRecyclable++; } - *pnCurrent = pcache1.nCurrentPage; - *pnMax = pcache1.nMaxPage; - *pnMin = pcache1.nMinPage; + *pnCurrent = pcache1.grp.nCurrentPage; + *pnMax = pcache1.grp.nMaxPage; + *pnMin = pcache1.grp.nMinPage; *pnRecyclable = nRecyclable; } #endif From 40f9837ff6162acd5c7d9d9e78ade417bf0d2640 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 18 Jan 2011 15:17:57 +0000 Subject: [PATCH 58/82] Do not use SQLITE_MUTEX_STATIC_MEM2 since it has been reused as STATIC_OPEN. Instead, create a new static mutex STATIC_PMEM which is an alias for the unused STATIC_LRU2. FossilOrigin-Name: f1cf02efcb3a871fef49f8b5f41bcf07622a6d29 --- manifest | 24 ++++++++++-------------- manifest.uuid | 2 +- src/pcache1.c | 2 +- src/sqlite.h.in | 3 ++- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 1291f1bd4b..631c49db4e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Here\sis\sa\scompletely\snew\simplementation\sof\sthe\smutex-free-pcache.\s\sThis\none\suses\sa\scommon\scode\sbase\sand\sautomatically\sselects\swhether\sor\snot\sto\s\nuse\smutexes\sdepending\son\scompile-time\sand\sstart-time\soptions. -D 2011-01-17T21:32:24.379 +C Do\snot\suse\sSQLITE_MUTEX_STATIC_MEM2\ssince\sit\shas\sbeen\sreused\sas\sSTATIC_OPEN.\nInstead,\screate\sa\snew\sstatic\smutex\sSTATIC_PMEM\swhich\sis\san\salias\sfor\sthe\nunused\sSTATIC_LRU2. +D 2011-01-18T15:17:57.523 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c 35f4d8d3e876708fa5b2174d32ce0b996470c88d +F src/pcache1.c b02aafb8e6e83cf1e49321bdd53926f430beb4b6 F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc F src/printf.c 37e8bfd4c5a04eae4960adbe776b0f1fc4cad674 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in 18a60e7e9f846fce21081b58d0f172dc5f3ee8ef +F src/sqlite.h.in 45ae5d463b5b341420b3cbc236fb1dfb5c0cd1a8 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -899,18 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 56417a3386fc84dd36bf1488e88149b1ac6a0d02 -R 983645a96ff6d3f0292bd851bc48a03a -T *bgcolor * #a8d3c0 -T *branch * mutex-free-pcache -T *sym-mutex-free-pcache * -T -sym-trunk * +P d094a1bfb7569a52b637fe9ba5d3fa6ce5ea6d94 +R 5a6f30062ab18eb4f0689f1eb22606f0 U drh -Z a140fb68339099588b73b5639a289144 +Z 4ecccd4a56daba874bbeeabc61f35710 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD4DBQFNNLVroxKgR168RlERAujGAJiIbOhYAepMRCuh0ytKZr7hYPulAKCJCvYa -QRfjhT9WvrqQrKNgWqHNNA== -=eKGZ +iD8DBQFNNa8poxKgR168RlERApBYAJ0f/N4hkLyYC7T/pc8MNg5yYDKMUgCfTraD +26V7hw0ncBtQ25UIXFz1wYg= +=AgYe -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4d906cd39e..1b84a37735 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d094a1bfb7569a52b637fe9ba5d3fa6ce5ea6d94 \ No newline at end of file +f1cf02efcb3a871fef49f8b5f41bcf07622a6d29 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 8535e90ef0..7c046c20d3 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -514,7 +514,7 @@ static int pcache1Init(void *NotUsed){ memset(&pcache1, 0, sizeof(pcache1)); if( sqlite3GlobalConfig.bCoreMutex ){ pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); - pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2); + pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); } pcache1.isInit = 1; return SQLITE_OK; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 3392170a3b..6fe0a36485 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5266,7 +5266,8 @@ int sqlite3_mutex_notheld(sqlite3_mutex*); #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ -#define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ +#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ +#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ /* ** CAPI3REF: Retrieve the mutex for a database connection From 986d3b95bb201a125d7343dfafa1d57472fd56f4 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 18 Jan 2011 16:13:27 +0000 Subject: [PATCH 59/82] Get all test cases working with the mutex-free-pcache implementation. FossilOrigin-Name: 2dc98d29995bef51108e99aa8f7a56427cf9e1d7 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- test/memsubsys1.test | 3 ++- test/mutex1.test | 4 +++- test/pcache.test | 8 ++++++++ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 631c49db4e..1f5d0773e5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Do\snot\suse\sSQLITE_MUTEX_STATIC_MEM2\ssince\sit\shas\sbeen\sreused\sas\sSTATIC_OPEN.\nInstead,\screate\sa\snew\sstatic\smutex\sSTATIC_PMEM\swhich\sis\san\salias\sfor\sthe\nunused\sSTATIC_LRU2. -D 2011-01-18T15:17:57.523 +C Get\sall\stest\scases\sworking\swith\sthe\smutex-free-pcache\simplementation. +D 2011-01-18T16:13:27.224 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -556,7 +556,7 @@ F test/malloc_common.tcl 27087a2bfad8f695ca6f8b463ecac5d71b9b0712 F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c F test/memdb.test 0825155b2290e900264daaaf0334b6dfe69ea498 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 -F test/memsubsys1.test 4cbec6f202c91504bfc4717bfc2ffd6160316c4c +F test/memsubsys1.test 66bf4e153e0eccc08c3b6af3641eb4f42d391c32 F test/memsubsys2.test 72a731225997ad5e8df89fdbeae9224616b6aecc F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0 @@ -570,7 +570,7 @@ F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 F test/multiplex.test 92a4839213fd8cba8b59f86d42b7a1da1857db39 -F test/mutex1.test 5b71777fc127509cd257910c8db799de557a02de +F test/mutex1.test 2fe5d592763e1aad6612b59fd862c8b1b0e0304b F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test a44e04df1486fcfb02d32468cbcd3c8e1e433723 F test/notify1.test 8433bc74bd952fb8a6e3f8d7a4c2b28dfd69e310 @@ -586,7 +586,7 @@ F test/pagerfault.test 9de4d3e0c59970b4c6cb8dac511fa242f335d8a7 F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401 F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb -F test/pcache.test 4118a183908ecaed343a06fcef3ba82e87e0129d +F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16 F test/permutations.test c0ce0f3b741dd92a6d4c2671dbacba4b92dd81eb F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d094a1bfb7569a52b637fe9ba5d3fa6ce5ea6d94 -R 5a6f30062ab18eb4f0689f1eb22606f0 +P f1cf02efcb3a871fef49f8b5f41bcf07622a6d29 +R ae7dd673c03c5cec18f064cfaf72f5a8 U drh -Z 4ecccd4a56daba874bbeeabc61f35710 +Z 361d8d6f88c7d70dfbc961880b2d5a3c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNNa8poxKgR168RlERApBYAJ0f/N4hkLyYC7T/pc8MNg5yYDKMUgCfTraD -26V7hw0ncBtQ25UIXFz1wYg= -=AgYe +iD8DBQFNNbwqoxKgR168RlERAkwpAJ98UXBjNfDigdVNfL5U73DQ1Ji1XACfaeFe +sRz6NboclM0T0HvSkCmQEPs= +=DkPe -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 1b84a37735..f27c91d65c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f1cf02efcb3a871fef49f8b5f41bcf07622a6d29 \ No newline at end of file +2dc98d29995bef51108e99aa8f7a56427cf9e1d7 \ No newline at end of file diff --git a/test/memsubsys1.test b/test/memsubsys1.test index c24a8bf95d..eb2512631b 100644 --- a/test/memsubsys1.test +++ b/test/memsubsys1.test @@ -96,9 +96,10 @@ sqlite3_initialize reset_highwater_marks build_test_db memsubsys1-2 {PRAGMA page_size=1024} #show_memstats +set MEMORY_MANAGEMENT $sqlite_options(memorymanage) do_test memsubsys1-2.3 { set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] -} [expr ($AUTOVACUUM+$TEMP_STORE>=2)*1024] +} [expr ($AUTOVACUUM+$TEMP_STORE+$MEMORY_MANAGEMENT>=3)*1024] do_test memsubsys1-2.4 { set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] } 20 diff --git a/test/mutex1.test b/test/mutex1.test index ad6bd1470b..e2f7c89fb3 100644 --- a/test/mutex1.test +++ b/test/mutex1.test @@ -120,7 +120,9 @@ ifcapable threadsafe&&shared_cache { INSERT INTO abc VALUES(1, 2, 3); } } {} - + ifcapable !memorymanage { + regsub { static_lru} $mutexes {} mutexes + } do_test mutex1.2.$mode.3 { mutex_counters counters diff --git a/test/pcache.test b/test/pcache.test index e2bcd51319..5dc3059c44 100644 --- a/test/pcache.test +++ b/test/pcache.test @@ -21,6 +21,14 @@ source $testdir/tester.tcl # do_not_use_codec +# Only works with a mode-2 pcache where all pcaches share a single set +# of pages. +# +ifcapable {!memorymanage && threadsafe} { + finish_test + return +} + # The pcache module limits the number of pages available to purgeable # caches to the sum of the 'cache_size' values for the set of open # caches. This block of tests, pcache-1.*, test that the library behaves From 3a5676ce26169502537306b5c9db7c6eae3033b4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 19 Jan 2011 21:58:56 +0000 Subject: [PATCH 60/82] Comment improvements in pcache1.c. No changes to code. FossilOrigin-Name: 9660a0a22547656cc3765b673d0cee9e1dd829ef --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pcache1.c | 7 ++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 118063a234..f9bb697af7 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Do\snot\suse\smutexes\sin\sthe\spcache\simplementation\sunless\nSQLITE_ENABLE_MEMORY_MANAGMENT\sis\sdefined.\s\sThis\sis\sa\sperformance\senhancement.\nA\sside\seffect\sis\sthat\spcaches\swill\snot\ssteal\spages\sfrom\sone\sanother\sunless\nENABLE_MEMORY_MANAGEMENT\sis\sset,\sor\sunless\sSQLITE_THREADSAFE=0. -D 2011-01-18T17:03:26.554 +C Comment\simprovements\sin\spcache1.c.\s\sNo\schanges\sto\scode. +D 2011-01-19T21:58:56.344 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c b02aafb8e6e83cf1e49321bdd53926f430beb4b6 +F src/pcache1.c 2610bcebf127df5ff82730c0c130cb35d4d6debe F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc F src/printf.c 37e8bfd4c5a04eae4960adbe776b0f1fc4cad674 @@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 56417a3386fc84dd36bf1488e88149b1ac6a0d02 2dc98d29995bef51108e99aa8f7a56427cf9e1d7 -R ae7dd673c03c5cec18f064cfaf72f5a8 +P e5ca59e63b18ac45a8c82ca39dc8cce1c4ce903c +R 246c042190fbeb83b3f1f3c471b7048c U drh -Z 325abbc955397207600330822401f3ff +Z d4b4af53a8b712c86792c5f30e91ad66 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNNcfhoxKgR168RlERAkQlAJ4goobzjFc2tVGaK8jIdVviHMW2TwCfYV8B -rrsRGD/Sjq/hNYcI1Uavg6U= -=JG+V +iD8DBQFNN16joxKgR168RlERApzpAJ9ub7vBM3MbU8WJio56+Ng2W8PfBQCeLClb +tiAK9YA5ekgfGTTQ91uwQlY= +=gzKU -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 08777730f0..96c640d6cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e5ca59e63b18ac45a8c82ca39dc8cce1c4ce903c \ No newline at end of file +9660a0a22547656cc3765b673d0cee9e1dd829ef \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 7c046c20d3..4af41407f9 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -674,18 +674,19 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ pcache1EnterMutex(pGroup); if( createFlag==1 ) sqlite3BeginBenignMalloc(); - /* Search the hash table for an existing entry. */ + /* Step 1: Search the hash table for an existing entry. */ if( pCache->nHash>0 ){ unsigned int h = iKey % pCache->nHash; for(pPage=pCache->apHash[h]; pPage&&pPage->iKey!=iKey; pPage=pPage->pNext); } + /* Step 2: Abort if no existing page is found and createFlag is 0 */ if( pPage || createFlag==0 ){ pcache1PinPage(pPage); goto fetch_out; } - /* Step 3 of header comment. */ + /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ nPinned = pCache->nPage - pCache->nRecyclable; if( createFlag==1 && ( nPinned>=(pGroup->nMaxPage+pCache->nMin-pGroup->nMinPage) @@ -699,7 +700,7 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ goto fetch_out; } - /* Step 4. Try to recycle a page buffer if appropriate. */ + /* Step 4. Try to recycle a page. */ if( pCache->bPurgeable && pGroup->pLruTail && ( (pCache->nPage+1>=pCache->nMax) || pGroup->nCurrentPage>=pGroup->nMaxPage From f3aef49cbd4900f728dd4bed67faf859372e0262 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 21 Jan 2011 15:52:02 +0000 Subject: [PATCH 61/82] Add options to test command [do_faultsim_test] to support testing VFS implementations. FossilOrigin-Name: 503ad889da675b3dd83da7338e2902e42f69acac --- install-sh | 0 manifest | 26 ++++++++------------------ manifest.uuid | 2 +- test/malloc_common.tcl | 14 +++++++++++++- 4 files changed, 22 insertions(+), 20 deletions(-) mode change 100755 => 100644 install-sh diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index f9bb697af7..59328e76bf 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Comment\simprovements\sin\spcache1.c.\s\sNo\schanges\sto\scode. -D 2011-01-19T21:58:56.344 +C Add\soptions\sto\stest\scommand\s[do_faultsim_test]\sto\ssupport\stesting\sVFS\simplementations. +D 2011-01-21T15:52:02 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -100,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -552,7 +549,7 @@ F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6 F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e F test/mallocK.test d79968641d1b70d88f6c01bdb9a7eb4a55582cc9 -F test/malloc_common.tcl 27087a2bfad8f695ca6f8b463ecac5d71b9b0712 +F test/malloc_common.tcl 660b82ab528521cc4a48ff6df05ca3b6a00d47c5 F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c F test/memdb.test 0825155b2290e900264daaaf0334b6dfe69ea498 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 @@ -899,14 +896,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e5ca59e63b18ac45a8c82ca39dc8cce1c4ce903c -R 246c042190fbeb83b3f1f3c471b7048c -U drh -Z d4b4af53a8b712c86792c5f30e91ad66 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNN16joxKgR168RlERApzpAJ9ub7vBM3MbU8WJio56+Ng2W8PfBQCeLClb -tiAK9YA5ekgfGTTQ91uwQlY= -=gzKU ------END PGP SIGNATURE----- +P 9660a0a22547656cc3765b673d0cee9e1dd829ef +R f0e13f37f9a89d0d9982d76b8e865005 +U dan +Z 235ffebf829319266e0bdfb46955a46a diff --git a/manifest.uuid b/manifest.uuid index 96c640d6cf..d6eeac6d80 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9660a0a22547656cc3765b673d0cee9e1dd829ef \ No newline at end of file +503ad889da675b3dd83da7338e2902e42f69acac \ No newline at end of file diff --git a/test/malloc_common.tcl b/test/malloc_common.tcl index f3d2f4f880..379b970747 100644 --- a/test/malloc_common.tcl +++ b/test/malloc_common.tcl @@ -106,6 +106,10 @@ set FAULTSIM(cantopen-persistent) [list \ # # -test Script to execute after -body. # +# -install Script to execute after faultsim -injectinstall +# +# -uninstall Script to execute after faultsim -uninjectinstall +# proc do_faultsim_test {name args} { global FAULTSIM @@ -113,6 +117,8 @@ proc do_faultsim_test {name args} { set DEFAULT(-prep) "" set DEFAULT(-body) "" set DEFAULT(-test) "" + set DEFAULT(-install) "" + set DEFAULT(-uninstall) "" fix_testname name @@ -129,7 +135,9 @@ proc do_faultsim_test {name args} { set faultlist [concat $faultlist $flist] } - set testspec [list -prep $O(-prep) -body $O(-body) -test $O(-test)] + set testspec [list -prep $O(-prep) -body $O(-body) \ + -test $O(-test) -install $O(-install) -uninstall $O(-uninstall) + ] foreach f [lsort -unique $faultlist] { eval do_one_faultsim_test "$name-$f" $FAULTSIM($f) $testspec } @@ -294,6 +302,8 @@ proc do_one_faultsim_test {testname args} { set DEFAULT(-prep) "" set DEFAULT(-body) "" set DEFAULT(-test) "" + set DEFAULT(-install) "" + set DEFAULT(-uninstall) "" array set O [array get DEFAULT] array set O $args @@ -307,6 +317,7 @@ proc do_one_faultsim_test {testname args} { " eval $O(-injectinstall) + eval $O(-install) set stop 0 for {set iFail 1} {!$stop} {incr iFail} { @@ -338,6 +349,7 @@ proc do_one_faultsim_test {testname args} { if {$nfail==0} { set stop 1 } } + eval $O(-uninstall) eval $O(-injectuninstall) } From a9ef7097c718a7685b42faa6033d9b04aeb8ee21 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 21 Jan 2011 18:25:29 +0000 Subject: [PATCH 62/82] Change sqlite3StrAccumAppend() to use realloc instead of malloc. FossilOrigin-Name: 380f61df0754ceec6b3f6a758d04e951cce8c3d9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/printf.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 59328e76bf..5dfc84f214 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\soptions\sto\stest\scommand\s[do_faultsim_test]\sto\ssupport\stesting\sVFS\simplementations. -D 2011-01-21T15:52:02 +C Change\ssqlite3StrAccumAppend()\sto\suse\srealloc\sinstead\sof\smalloc. +D 2011-01-21T18:25:30 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2610bcebf127df5ff82730c0c130cb35d4d6debe F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc -F src/printf.c 37e8bfd4c5a04eae4960adbe776b0f1fc4cad674 +F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 @@ -896,7 +896,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9660a0a22547656cc3765b673d0cee9e1dd829ef -R f0e13f37f9a89d0d9982d76b8e865005 +P 503ad889da675b3dd83da7338e2902e42f69acac +R 581c91bca4bed9e9c246127dfff2a86d U dan -Z 235ffebf829319266e0bdfb46955a46a +Z 1951ee9d42233f0fe4bd03e6cd0ae9e1 diff --git a/manifest.uuid b/manifest.uuid index d6eeac6d80..37337becbb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -503ad889da675b3dd83da7338e2902e42f69acac \ No newline at end of file +380f61df0754ceec6b3f6a758d04e951cce8c3d9 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 755355de0c..c88bb30006 100644 --- a/src/printf.c +++ b/src/printf.c @@ -763,6 +763,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ return; } }else{ + char *zOld = (p->zText==p->zBase ? 0 : p->zText); i64 szNew = p->nChar; szNew += N + 1; if( szNew > p->mxAlloc ){ @@ -773,13 +774,12 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ p->nAlloc = (int)szNew; } if( p->useMalloc==1 ){ - zNew = sqlite3DbMallocRaw(p->db, p->nAlloc ); + zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc); }else{ - zNew = sqlite3_malloc(p->nAlloc); + zNew = sqlite3_realloc(zOld, p->nAlloc); } if( zNew ){ - memcpy(zNew, p->zText, p->nChar); - sqlite3StrAccumReset(p); + if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; }else{ p->mallocFailed = 1; From 27381bd5198436dc2b3e0fb0a247e36b28185a14 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 22 Jan 2011 13:32:29 +0000 Subject: [PATCH 63/82] Modify the trace callback mechanism so that SQL commands executed from within virtual table or user function callbacks are passed to the trace callback without parameter expansion and enclosed in SQL comments. FossilOrigin-Name: a764915b87564fa91ee68e9b1f41394ce0f1fc7e --- install-sh | 0 manifest | 19 +++--- manifest.uuid | 2 +- src/sqliteInt.h | 1 + src/vdbeapi.c | 2 + src/vdbetrace.c | 124 +++++++++++++++++++++----------------- test/trace2.test | 152 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 234 insertions(+), 66 deletions(-) mode change 100644 => 100755 install-sh create mode 100644 test/trace2.test diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 5dfc84f214..61daaed0f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\ssqlite3StrAccumAppend()\sto\suse\srealloc\sinstead\sof\smalloc. -D 2011-01-21T18:25:30 +C Modify\sthe\strace\scallback\smechanism\sso\sthat\sSQL\scommands\sexecuted\sfrom\swithin\svirtual\stable\sor\suser\sfunction\scallbacks\sare\spassed\sto\sthe\strace\scallback\swithout\sparameter\sexpansion\sand\senclosed\sin\sSQL\scomments. +D 2011-01-22T13:32:30 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -97,7 +97,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -178,7 +178,7 @@ F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 F src/sqlite.h.in 45ae5d463b5b341420b3cbc236fb1dfb5c0cd1a8 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c +F src/sqliteInt.h 45926deaf59b1ce3f55d21d5f91a8cecb6a7eb4c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -231,11 +231,11 @@ F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f F src/vdbe.c 5d310eaf1a4d8383602126fa82e01291ab7d3cf3 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 6e6f28e9bccc6c703dca1372fd661c57b5c15fb0 -F src/vdbeapi.c 69c82283ab2b64c0c37a07799d771d4058330743 +F src/vdbeapi.c 8e9324fd35eb70d0b5904bd1af40f2598744dc4d F src/vdbeaux.c 33448d23b857654dd69ed2103611f5c733606f68 F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 -F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 +F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 F src/wal.c dbca424f71678f663a286ab2a98f947af1d412a7 F src/wal.h c1aac6593a0b02b15dc625987e619edeab39292e @@ -786,6 +786,7 @@ F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd F test/tkt4018.test 7c2c9ba4df489c676a0a7a0e809a1fb9b2185bd1 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/trace.test 4b36a41a3e9c7842151af6da5998f5080cdad9e5 +F test/trace2.test 092bc2c5776272700450d60a36919921095bdc21 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test d5337e61de45e66b1fcbf9db833fa8c82e624b22 F test/trans3.test d728abaa318ca364dc370e06576aa7e5fbed7e97 @@ -896,7 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 503ad889da675b3dd83da7338e2902e42f69acac -R 581c91bca4bed9e9c246127dfff2a86d +P 380f61df0754ceec6b3f6a758d04e951cce8c3d9 +R 90a5119ad79fbdf46155bfdda925f6c3 U dan -Z 1951ee9d42233f0fe4bd03e6cd0ae9e1 +Z 22ba801a4079136db1b6273b2820344e diff --git a/manifest.uuid b/manifest.uuid index 37337becbb..302247b035 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -380f61df0754ceec6b3f6a758d04e951cce8c3d9 \ No newline at end of file +a764915b87564fa91ee68e9b1f41394ce0f1fc7e \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 5233e99f09..41c46fa269 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -816,6 +816,7 @@ struct sqlite3 { struct Vdbe *pVdbe; /* List of active virtual machines */ int activeVdbeCnt; /* Number of VDBEs currently executing */ int writeVdbeCnt; /* Number of active VDBEs that are writing */ + int vdbeExecCnt; /* Number of nested calls to VdbeExec() */ void (*xTrace)(void*,const char*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ diff --git a/src/vdbeapi.c b/src/vdbeapi.c index ca454acc20..5578b868e1 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -410,7 +410,9 @@ static int sqlite3Step(Vdbe *p){ }else #endif /* SQLITE_OMIT_EXPLAIN */ { + db->vdbeExecCnt++; rc = sqlite3VdbeExec(p); + db->vdbeExecCnt--; } #ifndef SQLITE_OMIT_TRACE diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 0d6b21211c..b422fa9eb1 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -44,9 +44,12 @@ static int findNextHostParameter(const char *zSql, int *pnToken){ } /* -** Return a pointer to a string in memory obtained form sqlite3DbMalloc() which -** holds a copy of zRawSql but with host parameters expanded to their -** current bindings. +** This function returns a pointer to a nul-terminated string in memory +** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the +** string contains a copy of zRawSql but with host parameters expanded to +** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1, +** then the returned string holds a copy of zRawSql with "-- " prepended +** to each line of text. ** ** The calling function is responsible for making sure the memory returned ** is eventually freed. @@ -77,63 +80,72 @@ char *sqlite3VdbeExpandSql( sqlite3StrAccumInit(&out, zBase, sizeof(zBase), db->aLimit[SQLITE_LIMIT_LENGTH]); out.db = db; - while( zRawSql[0] ){ - n = findNextHostParameter(zRawSql, &nToken); - assert( n>0 ); - sqlite3StrAccumAppend(&out, zRawSql, n); - zRawSql += n; - assert( zRawSql[0] || nToken==0 ); - if( nToken==0 ) break; - if( zRawSql[0]=='?' ){ - if( nToken>1 ){ - assert( sqlite3Isdigit(zRawSql[1]) ); - sqlite3GetInt32(&zRawSql[1], &idx); - }else{ - idx = nextIndex; - } - }else{ - assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' ); - testcase( zRawSql[0]==':' ); - testcase( zRawSql[0]=='$' ); - testcase( zRawSql[0]=='@' ); - idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken); - assert( idx>0 ); + if( db->vdbeExecCnt>1 ){ + while( *zRawSql ){ + const char *zStart = zRawSql; + while( *(zRawSql++)!='\n' && *zRawSql ); + sqlite3StrAccumAppend(&out, "-- ", 3); + sqlite3StrAccumAppend(&out, zStart, zRawSql-zStart); } - zRawSql += nToken; - nextIndex = idx + 1; - assert( idx>0 && idx<=p->nVar ); - pVar = &p->aVar[idx-1]; - if( pVar->flags & MEM_Null ){ - sqlite3StrAccumAppend(&out, "NULL", 4); - }else if( pVar->flags & MEM_Int ){ - sqlite3XPrintf(&out, "%lld", pVar->u.i); - }else if( pVar->flags & MEM_Real ){ - sqlite3XPrintf(&out, "%!.15g", pVar->r); - }else if( pVar->flags & MEM_Str ){ + }else{ + while( zRawSql[0] ){ + n = findNextHostParameter(zRawSql, &nToken); + assert( n>0 ); + sqlite3StrAccumAppend(&out, zRawSql, n); + zRawSql += n; + assert( zRawSql[0] || nToken==0 ); + if( nToken==0 ) break; + if( zRawSql[0]=='?' ){ + if( nToken>1 ){ + assert( sqlite3Isdigit(zRawSql[1]) ); + sqlite3GetInt32(&zRawSql[1], &idx); + }else{ + idx = nextIndex; + } + }else{ + assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' ); + testcase( zRawSql[0]==':' ); + testcase( zRawSql[0]=='$' ); + testcase( zRawSql[0]=='@' ); + idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken); + assert( idx>0 ); + } + zRawSql += nToken; + nextIndex = idx + 1; + assert( idx>0 && idx<=p->nVar ); + pVar = &p->aVar[idx-1]; + if( pVar->flags & MEM_Null ){ + sqlite3StrAccumAppend(&out, "NULL", 4); + }else if( pVar->flags & MEM_Int ){ + sqlite3XPrintf(&out, "%lld", pVar->u.i); + }else if( pVar->flags & MEM_Real ){ + sqlite3XPrintf(&out, "%!.15g", pVar->r); + }else if( pVar->flags & MEM_Str ){ #ifndef SQLITE_OMIT_UTF16 - u8 enc = ENC(db); - if( enc!=SQLITE_UTF8 ){ - Mem utf8; - memset(&utf8, 0, sizeof(utf8)); - utf8.db = db; - sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); - sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8); - sqlite3XPrintf(&out, "'%.*q'", utf8.n, utf8.z); - sqlite3VdbeMemRelease(&utf8); - }else + u8 enc = ENC(db); + if( enc!=SQLITE_UTF8 ){ + Mem utf8; + memset(&utf8, 0, sizeof(utf8)); + utf8.db = db; + sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); + sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8); + sqlite3XPrintf(&out, "'%.*q'", utf8.n, utf8.z); + sqlite3VdbeMemRelease(&utf8); + }else #endif - { - sqlite3XPrintf(&out, "'%.*q'", pVar->n, pVar->z); + { + sqlite3XPrintf(&out, "'%.*q'", pVar->n, pVar->z); + } + }else if( pVar->flags & MEM_Zero ){ + sqlite3XPrintf(&out, "zeroblob(%d)", pVar->u.nZero); + }else{ + assert( pVar->flags & MEM_Blob ); + sqlite3StrAccumAppend(&out, "x'", 2); + for(i=0; in; i++){ + sqlite3XPrintf(&out, "%02x", pVar->z[i]&0xff); + } + sqlite3StrAccumAppend(&out, "'", 1); } - }else if( pVar->flags & MEM_Zero ){ - sqlite3XPrintf(&out, "zeroblob(%d)", pVar->u.nZero); - }else{ - assert( pVar->flags & MEM_Blob ); - sqlite3StrAccumAppend(&out, "x'", 2); - for(i=0; in; i++){ - sqlite3XPrintf(&out, "%02x", pVar->z[i]&0xff); - } - sqlite3StrAccumAppend(&out, "'", 1); } } return sqlite3StrAccumFinish(&out); diff --git a/test/trace2.test b/test/trace2.test new file mode 100644 index 0000000000..2cf50d0811 --- /dev/null +++ b/test/trace2.test @@ -0,0 +1,152 @@ +# 2011 Jan 21 +# +# 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. +# +# This file implements tests for the "sqlite3_trace()" API. Specifically, +# it tests the special handling of nested SQL statements (those executed +# by virtual table or user function callbacks). These statements are treated +# differently in two respects: +# +# 1. Each line of the statement is prefixed with "-- " to turn it into +# an SQL comment. +# +# 2. Parameter expansion is not performed. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !trace { finish_test ; return } +set ::testprefix trace2 + +proc sql {zSql} { db one $zSql } +proc trace {zSql} { lappend ::trace $zSql } + +db func sql sql +db trace trace + +proc do_trace_test {tn sql expected} { + # Test that the list of string passed to the trace callback when $sql + # is executed is equivalent to the list of strings in $expected. + # + set ::trace [list] + execsql $sql + uplevel do_test $tn [list {set ::trace}] [list [list {*}$expected]] +} + +proc do_trace_select_test {tn sql expected} { + + uplevel [list do_trace_test ${tn}.a $sql $expected] + + # Now execute each SQL statement passed to the trace callback in the + # block above. Check that this causes the same set of strings to be + # passed to the trace callback again. i.e. that executing the output + # of the trace callback is equivalent to the SQL script in $sql. + # + set sqllist $::trace + set ::trace [list] + foreach item $sqllist { execsql $item } + uplevel do_test $tn.b [list {set ::trace}] [list $sqllist] +} + +do_trace_select_test 1.1 { + SELECT 1, 2, 3; +} { + "SELECT 1, 2, 3;" +} + +do_trace_select_test 1.2 { + SELECT sql('SELECT 1, 2, 3'); +} { + "SELECT sql('SELECT 1, 2, 3');" + "-- SELECT 1, 2, 3" +} + +do_trace_select_test 1.3 { + SELECT sql('SELECT 1, + 2, + 3' + ); +} { + "SELECT sql('SELECT 1, + 2, + 3' + );" + "-- SELECT 1, +-- 2, +-- 3" +} + +do_trace_select_test 1.4 { + SELECT sql('SELECT 1, + + + 3' + ); +} { + "SELECT sql('SELECT 1, + + + 3' + );" + "-- SELECT 1, +-- +-- +-- 3" +} + +do_trace_select_test 1.5 { + SELECT $var, sql('SELECT 1, + $var, + 3' + ); +} { + "SELECT NULL, sql('SELECT 1, + $var, + 3' + );" + "-- SELECT 1, +-- $var, +-- 3" +} + +ifcapable fts3 { + do_execsql_test 2.1 { + CREATE VIRTUAL TABLE x1 USING fts4; + INSERT INTO x1 VALUES('Cloudy, with a high near 16'); + INSERT INTO x1 VALUES('Wind chill values as low as -13'); + } + + do_trace_test 2.2 { + INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph'); + } { + "INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');" + "-- INSERT INTO 'main'.'x1_content' VALUES(?,?)" + "-- REPLACE INTO 'main'.'x1_docsize' VALUES(?,?)" + "-- SELECT value FROM 'main'.'x1_stat' WHERE id=0" + "-- REPLACE INTO 'main'.'x1_stat' VALUES(0,?)" + "-- SELECT (SELECT max(idx) FROM 'main'.'x1_segdir' WHERE level = ?) + 1" + "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)" + "-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)" + } + + do_trace_test 2.3 { + INSERT INTO x1(x1) VALUES('optimize'); + } { + "INSERT INTO x1(x1) VALUES('optimize');" + "-- SELECT count(*), max(level) FROM 'main'.'x1_segdir'" + "-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' ORDER BY level DESC, idx ASC" + "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)" + "-- DELETE FROM 'main'.'x1_segdir'" + "-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)" + } +} + +finish_test From 906b662060388c8ad079b1edd79fced9846f91a9 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 24 Jan 2011 19:14:06 +0000 Subject: [PATCH 64/82] Fix a harmless compiler warning (a shadowed local variable) in analyze.c. FossilOrigin-Name: a1ad7fb38bb38909ca2fddee31c7a8001f10686f --- manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- src/analyze.c | 6 +++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 61daaed0f0..0d60b8266e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Modify\sthe\strace\scallback\smechanism\sso\sthat\sSQL\scommands\sexecuted\sfrom\swithin\svirtual\stable\sor\suser\sfunction\scallbacks\sare\spassed\sto\sthe\strace\scallback\swithout\sparameter\sexpansion\sand\senclosed\sin\sSQL\scomments. -D 2011-01-22T13:32:30 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\sa\sharmless\scompiler\swarning\s(a\sshadowed\slocal\svariable)\sin\sanalyze.c. +D 2011-01-24T19:14:06.711 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -113,7 +116,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 -F src/analyze.c 3af3fdb5edea9e69496b078935a3e6a2a1118b30 +F src/analyze.c a038162344265ac21dfb24b3fcc06c666ebb9c07 F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 8c39a1ebba1e9dc385519cc4d434c7b0cab6638c @@ -897,7 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 380f61df0754ceec6b3f6a758d04e951cce8c3d9 -R 90a5119ad79fbdf46155bfdda925f6c3 -U dan -Z 22ba801a4079136db1b6273b2820344e +P a764915b87564fa91ee68e9b1f41394ce0f1fc7e +R 6011b1f56cf7fb8f5d17fa2302863158 +U drh +Z f19cd078d84fab44dfd272be754d8284 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNPc+BoxKgR168RlERAmkkAJ42UtOzZ0cpY34FbmH/Mw1FnHouMgCfXf/S +qOqg2bXMaMBkTm3sXPtNr/E= +=C1+6 +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 302247b035..97b556a1a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a764915b87564fa91ee68e9b1f41394ce0f1fc7e \ No newline at end of file +a1ad7fb38bb38909ca2fddee31c7a8001f10686f \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 3693aad833..0a8339bafb 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -286,11 +286,11 @@ static void analyzeOneTable( } sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); for(i=0; i Date: Mon, 24 Jan 2011 19:45:07 +0000 Subject: [PATCH 65/82] Fix a typo in the documentation for sqlite3_snprintf(). No changes to code. FossilOrigin-Name: 8d1065411aadf189880606c48ab63dd2a56b9793 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0d60b8266e..3dc015affc 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\sharmless\scompiler\swarning\s(a\sshadowed\slocal\svariable)\sin\sanalyze.c. -D 2011-01-24T19:14:06.711 +C Fix\sa\stypo\sin\sthe\sdocumentation\sfor\ssqlite3_snprintf().\s\sNo\schanges\sto\scode. +D 2011-01-24T19:45:07.502 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in 45ae5d463b5b341420b3cbc236fb1dfb5c0cd1a8 +F src/sqlite.h.in da5f52960e61bd8940413bd07da0e8150531552d F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 45926deaf59b1ce3f55d21d5f91a8cecb6a7eb4c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a764915b87564fa91ee68e9b1f41394ce0f1fc7e -R 6011b1f56cf7fb8f5d17fa2302863158 +P a1ad7fb38bb38909ca2fddee31c7a8001f10686f +R 349ecc89f1fc661fb811143965f431fa U drh -Z f19cd078d84fab44dfd272be754d8284 +Z 11b3511f8e54d33bab682c0aeff495b5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNPc+BoxKgR168RlERAmkkAJ42UtOzZ0cpY34FbmH/Mw1FnHouMgCfXf/S -qOqg2bXMaMBkTm3sXPtNr/E= -=C1+6 +iD8DBQFNPdbJoxKgR168RlERAljmAJ4ykVtcrE3jjcqoYkrf9IqX5cS8kwCdGgj/ +VuPr3CWSSz8fpBDULaW48ZA= +=9CR2 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 97b556a1a4..494d2e0ae1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a1ad7fb38bb38909ca2fddee31c7a8001f10686f \ No newline at end of file +8d1065411aadf189880606c48ab63dd2a56b9793 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 6fe0a36485..360ccd5779 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1849,7 +1849,7 @@ void sqlite3_free_table(char **result); ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough ** memory to hold the resulting string. ** -** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from +** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from ** the standard C library. The result is written into the ** buffer supplied as the second parameter whose size is given by ** the first parameter. Note that the order of the From 3778ac15dd075cd8feae394dde714726b6861cf4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 24 Jan 2011 20:18:05 +0000 Subject: [PATCH 66/82] Modify the test_quote.c demonstration shim so that it works when SQLITE_THREADSAFE=0 is defined. FossilOrigin-Name: b70bcccaf5597c8a59cccb64fb997523f7b8fe4f --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test_quota.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3dc015affc..86f9717d50 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\stypo\sin\sthe\sdocumentation\sfor\ssqlite3_snprintf().\s\sNo\schanges\sto\scode. -D 2011-01-24T19:45:07.502 +C Modify\sthe\stest_quote.c\sdemonstration\sshim\sso\sthat\sit\sworks\swhen\nSQLITE_THREADSAFE=0\sis\sdefined. +D 2011-01-24T20:18:05.760 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -215,7 +215,7 @@ F src/test_mutex.c ce06b59aca168cd8c520b77159a24352a7469bd3 F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec F src/test_osinst.c f408c6a181f2fb04c56273afd5c3e1e82f60392c F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8 -F src/test_quota.c 6d32dd5885777f432db91e3a6c9e39008dd67d86 +F src/test_quota.c b5576f17d701af461effd7ca1e71f0d100071192 F src/test_rtree.c 30c981837445a4e187ee850a49c4760d9642f7c3 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a1ad7fb38bb38909ca2fddee31c7a8001f10686f -R 349ecc89f1fc661fb811143965f431fa +P 8d1065411aadf189880606c48ab63dd2a56b9793 +R 0d85535bc15a93b18012673a71c32db9 U drh -Z 11b3511f8e54d33bab682c0aeff495b5 +Z 70d633de5e7a3d8ed3285ad89550ec3c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNPdbJoxKgR168RlERAljmAJ4ykVtcrE3jjcqoYkrf9IqX5cS8kwCdGgj/ -VuPr3CWSSz8fpBDULaW48ZA= -=9CR2 +iD8DBQFNPd6AoxKgR168RlERAv1EAJsHL7T752myN3OrKk+lrXEgPoRywwCffQlq +RmLBh/72A/WvCFzCC21cc98= +=oeId -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 494d2e0ae1..bb0e5367b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8d1065411aadf189880606c48ab63dd2a56b9793 \ No newline at end of file +b70bcccaf5597c8a59cccb64fb997523f7b8fe4f \ No newline at end of file diff --git a/src/test_quota.c b/src/test_quota.c index 352f289d3e..3c6db4d7cd 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -31,6 +31,20 @@ #include #include +/* +** For an build without mutexes, no-op the mutex calls. +*/ +#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0 +#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) +#define sqlite3_mutex_free(X) +#define sqlite3_mutex_enter(X) +#define sqlite3_mutex_try(X) SQLITE_OK +#define sqlite3_mutex_leave(X) +#define sqlite3_mutex_held(X) ((void)(X),1) +#define sqlite3_mutex_notheld(X) ((void)(X),1) +#endif /* SQLITE_THREADSAFE==0 */ + + /************************ Object Definitions ******************************/ /* Forward declaration of all object types */ From 41692e9d7c4eca48bb3ed00a7bdea9a97fbbb016 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Jan 2011 04:34:51 +0000 Subject: [PATCH 67/82] Shave a few cycles so that performance is better than 3.7.4 in speed tests. FossilOrigin-Name: e14649301138b6840e24a4bbd2cf5205c0f72409 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/btree.c | 7 +------ src/pcache1.c | 42 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 86f9717d50..82264d4976 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Modify\sthe\stest_quote.c\sdemonstration\sshim\sso\sthat\sit\sworks\swhen\nSQLITE_THREADSAFE=0\sis\sdefined. -D 2011-01-24T20:18:05.760 +C Shave\sa\sfew\scycles\sso\sthat\sperformance\sis\sbetter\sthan\s3.7.4\sin\sspeed\stests. +D 2011-01-25T04:34:51.468 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -122,7 +122,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 8c39a1ebba1e9dc385519cc4d434c7b0cab6638c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c a27c3b41082889fc258278ba501ff2594dda2a41 +F src/btree.c 9004c98fc576306eee4fc0562ffeb362ef53912c F src/btree.h 10f9296bf4edf034f5adce921b7b4383a56a1c90 F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 F src/build.c 00a327120d81ace6267e714ae8010c997d55de5d @@ -170,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c 2610bcebf127df5ff82730c0c130cb35d4d6debe +F src/pcache1.c 54401ef4ea296b5bc2950bfbf5e68d6e931ab676 F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8d1065411aadf189880606c48ab63dd2a56b9793 -R 0d85535bc15a93b18012673a71c32db9 +P b70bcccaf5597c8a59cccb64fb997523f7b8fe4f +R db20a3af8ef33b3a30d380bbda0431c6 U drh -Z 70d633de5e7a3d8ed3285ad89550ec3c +Z 4ead49fabdd8a6e774c2367e68e73ca5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNPd6AoxKgR168RlERAv1EAJsHL7T752myN3OrKk+lrXEgPoRywwCffQlq -RmLBh/72A/WvCFzCC21cc98= -=oeId +iD8DBQFNPlLvoxKgR168RlERApslAJ9T2ytfJxLqucALSfvcNNpr6129cACfegvL +qPLVUx7DCZ7ypVE082HOjX8= +=7+yb -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index bb0e5367b4..81467c911d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b70bcccaf5597c8a59cccb64fb997523f7b8fe4f \ No newline at end of file +e14649301138b6840e24a4bbd2cf5205c0f72409 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index bec19e315f..aa120159de 100644 --- a/src/btree.c +++ b/src/btree.c @@ -918,14 +918,9 @@ static void btreeParseCellPtr( /* This is the (easy) common case where the entire payload fits ** on the local page. No overflow is required. */ - int nSize; /* Total size of cell content in bytes */ - nSize = nPayload + n; + if( (pInfo->nSize = (u16)(n+nPayload))<4 ) pInfo->nSize = 4; pInfo->nLocal = (u16)nPayload; pInfo->iOverflow = 0; - if( (nSize & ~3)==0 ){ - nSize = 4; /* Minimum cell size is 4 */ - } - pInfo->nSize = (u16)nSize; }else{ /* If the payload will not fit completely on the local page, we have ** to decide how much to store locally and how much to spill onto diff --git a/src/pcache1.c b/src/pcache1.c index 4af41407f9..50765a2fac 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -50,6 +50,7 @@ struct PGroup { sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ int nMaxPage; /* Sum of nMax for purgeable caches */ int nMinPage; /* Sum of nMin for purgeable caches */ + int mxPinned; /* nMaxpage + 10 - nMinPage */ int nCurrentPage; /* Number of purgeable pages allocated */ PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ }; @@ -73,6 +74,7 @@ struct PCache1 { int bPurgeable; /* True if cache is purgeable */ unsigned int nMin; /* Minimum number of pages reserved */ unsigned int nMax; /* Configured "cache_size" value */ + unsigned int mxPinned; /* nMax*9/10 */ /* Hash table of all pages. The following variables may only be accessed ** when the accessor is holding the PGroup mutex. @@ -516,6 +518,7 @@ static int pcache1Init(void *NotUsed){ pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU); pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM); } + pcache1.grp.mxPinned = 10; pcache1.isInit = 1; return SQLITE_OK; } @@ -565,6 +568,7 @@ static sqlite3_pcache *pcache1Create(int szPage, int bPurgeable){ memset(pCache, 0, sz); if( separateCache ){ pGroup = (PGroup*)&pCache[1]; + pGroup->mxPinned = 10; }else{ pGroup = &pcache1_g.grp; } @@ -575,6 +579,7 @@ static sqlite3_pcache *pcache1Create(int szPage, int bPurgeable){ pCache->nMin = 10; pcache1EnterMutex(pGroup); pGroup->nMinPage += pCache->nMin; + pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pcache1LeaveMutex(pGroup); } } @@ -592,7 +597,9 @@ static void pcache1Cachesize(sqlite3_pcache *p, int nMax){ PGroup *pGroup = pCache->pGroup; pcache1EnterMutex(pGroup); pGroup->nMaxPage += (nMax - pCache->nMax); + pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pCache->nMax = nMax; + pCache->mxPinned = nMax*9/10; pcache1EnforceMaxPage(pGroup); pcache1LeaveMutex(pGroup); } @@ -667,12 +674,14 @@ static int pcache1Pagecount(sqlite3_pcache *p){ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ unsigned int nPinned; PCache1 *pCache = (PCache1 *)p; - PGroup *pGroup = pCache->pGroup; + PGroup *pGroup; PgHdr1 *pPage = 0; assert( pCache->bPurgeable || createFlag!=1 ); - pcache1EnterMutex(pGroup); - if( createFlag==1 ) sqlite3BeginBenignMalloc(); + assert( pCache->bPurgeable || pCache->nMin==0 ); + assert( pCache->bPurgeable==0 || pCache->nMin==10 ); + assert( pCache->nMin==0 || pCache->bPurgeable ); + pcache1EnterMutex(pGroup = pCache->pGroup); /* Step 1: Search the hash table for an existing entry. */ if( pCache->nHash>0 ){ @@ -686,11 +695,25 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ goto fetch_out; } + /* The pGroup local variable will normally be initialized by the + ** pcache1EnterMutex() macro above. But if SQLITE_MUTEX_OMIT is defined, + ** then pcache1EnterMutex() is a no-op, so we have to initialize the + ** local variable here. Delaying the initialization of pGroup is an + ** optimization: The common case is to exit the module before reaching + ** this point. + */ +#ifdef SQLITE_MUTEX_OMIT + pGroup = pCache->pGroup; +#endif + + /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ nPinned = pCache->nPage - pCache->nRecyclable; + assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage ); + assert( pCache->mxPinned == pCache->nMax*9/10 ); if( createFlag==1 && ( - nPinned>=(pGroup->nMaxPage+pCache->nMin-pGroup->nMinPage) - || nPinned>=(pCache->nMax * 9 / 10) + nPinned>=pGroup->mxPinned + || nPinned>=pCache->mxPinned || pcache1UnderMemoryPressure(pCache) )){ goto fetch_out; @@ -706,15 +729,16 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ || pGroup->nCurrentPage>=pGroup->nMaxPage || pcache1UnderMemoryPressure(pCache) )){ + PCache1 *pOtherCache; pPage = pGroup->pLruTail; pcache1RemoveFromHash(pPage); pcache1PinPage(pPage); - if( pPage->pCache->szPage!=pCache->szPage ){ + if( (pOtherCache = pPage->pCache)->szPage!=pCache->szPage ){ pcache1FreePage(pPage); pPage = 0; }else{ pGroup->nCurrentPage -= - (pPage->pCache->bPurgeable - pCache->bPurgeable); + (pOtherCache->bPurgeable - pCache->bPurgeable); } } @@ -722,9 +746,11 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ ** attempt to allocate a new one. */ if( !pPage ){ + if( createFlag==1 ) sqlite3BeginBenignMalloc(); pcache1LeaveMutex(pGroup); pPage = pcache1AllocPage(pCache); pcache1EnterMutex(pGroup); + if( createFlag==1 ) sqlite3EndBenignMalloc(); } if( pPage ){ @@ -743,7 +769,6 @@ fetch_out: if( pPage && iKey>pCache->iMaxKey ){ pCache->iMaxKey = iKey; } - if( createFlag==1 ) sqlite3EndBenignMalloc(); pcache1LeaveMutex(pGroup); return (pPage ? PGHDR1_TO_PAGE(pPage) : 0); } @@ -853,6 +878,7 @@ static void pcache1Destroy(sqlite3_pcache *p){ pcache1TruncateUnsafe(pCache, 0); pGroup->nMaxPage -= pCache->nMax; pGroup->nMinPage -= pCache->nMin; + pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pcache1EnforceMaxPage(pGroup); pcache1LeaveMutex(pGroup); sqlite3_free(pCache->apHash); From ff07ccadee076d17ef2335f5104b0681dbf3b926 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 25 Jan 2011 09:54:53 +0000 Subject: [PATCH 68/82] Fix a problem in memsubsys1.test. Modifications to test code only. FossilOrigin-Name: 7ef3f7cba768ef0c4782a6c80424833b4df6a059 --- manifest | 24 +++++++----------------- manifest.uuid | 2 +- test/memsubsys1.test | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 82264d4976..1cf8ce0c42 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Shave\sa\sfew\scycles\sso\sthat\sperformance\sis\sbetter\sthan\s3.7.4\sin\sspeed\stests. -D 2011-01-25T04:34:51.468 +C Fix\sa\sproblem\sin\smemsubsys1.test.\sModifications\sto\stest\scode\sonly. +D 2011-01-25T09:54:53 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -556,7 +553,7 @@ F test/malloc_common.tcl 660b82ab528521cc4a48ff6df05ca3b6a00d47c5 F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c F test/memdb.test 0825155b2290e900264daaaf0334b6dfe69ea498 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 -F test/memsubsys1.test 66bf4e153e0eccc08c3b6af3641eb4f42d391c32 +F test/memsubsys1.test 679db68394a5692791737b150852173b3e2fea10 F test/memsubsys2.test 72a731225997ad5e8df89fdbeae9224616b6aecc F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0 @@ -900,14 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b70bcccaf5597c8a59cccb64fb997523f7b8fe4f -R db20a3af8ef33b3a30d380bbda0431c6 -U drh -Z 4ead49fabdd8a6e774c2367e68e73ca5 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNPlLvoxKgR168RlERApslAJ9T2ytfJxLqucALSfvcNNpr6129cACfegvL -qPLVUx7DCZ7ypVE082HOjX8= -=7+yb ------END PGP SIGNATURE----- +P e14649301138b6840e24a4bbd2cf5205c0f72409 +R 2b26f3944d156c9f7b61f43415a5078b +U dan +Z a2506a0b9867e8f31ef3ef0d39599052 diff --git a/manifest.uuid b/manifest.uuid index 81467c911d..00b62a1357 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e14649301138b6840e24a4bbd2cf5205c0f72409 \ No newline at end of file +7ef3f7cba768ef0c4782a6c80424833b4df6a059 \ No newline at end of file diff --git a/test/memsubsys1.test b/test/memsubsys1.test index eb2512631b..3bb2cc71d4 100644 --- a/test/memsubsys1.test +++ b/test/memsubsys1.test @@ -99,7 +99,7 @@ build_test_db memsubsys1-2 {PRAGMA page_size=1024} set MEMORY_MANAGEMENT $sqlite_options(memorymanage) do_test memsubsys1-2.3 { set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] -} [expr ($AUTOVACUUM+$TEMP_STORE+$MEMORY_MANAGEMENT>=3)*1024] +} [expr ($TEMP_STORE>1 || $MEMORY_MANAGEMENT==0)*1024] do_test memsubsys1-2.4 { set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] } 20 From d1cf7e29726fda529e1ff257f3342a0ce40f20c3 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 25 Jan 2011 11:33:01 +0000 Subject: [PATCH 69/82] Fix a broken assert() in pager.c. FossilOrigin-Name: 13108ce13c281f31aa60b403567710ae3d925797 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1cf8ce0c42..e5ed493431 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\smemsubsys1.test.\sModifications\sto\stest\scode\sonly. -D 2011-01-25T09:54:53 +C Fix\sa\sbroken\sassert()\sin\spager.c. +D 2011-01-25T11:33:01 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +162,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c 60d79b73d9fa7adce29e55231597416f1511d975 +F src/pager.c eb355fc87cd84b47f70b479569f1ad1338fb4e2d F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -897,7 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e14649301138b6840e24a4bbd2cf5205c0f72409 -R 2b26f3944d156c9f7b61f43415a5078b +P 7ef3f7cba768ef0c4782a6c80424833b4df6a059 +R ba7b28c2183cb4939792757ce9044a5a U dan -Z a2506a0b9867e8f31ef3ef0d39599052 +Z 1be8a639466ca213ddcd4aee76a16760 diff --git a/manifest.uuid b/manifest.uuid index 00b62a1357..e349fb1816 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7ef3f7cba768ef0c4782a6c80424833b4df6a059 \ No newline at end of file +13108ce13c281f31aa60b403567710ae3d925797 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 39a3d5b86c..a6f7aac370 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5624,13 +5624,14 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ */ int sqlite3PagerSync(Pager *pPager){ int rc; /* Return code */ - assert( !MEMDB ); if( pPager->noSync ){ rc = SQLITE_OK; }else{ + assert( !MEMDB ); rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); } if( isOpen(pPager->fd) ){ + assert( !MEMDB ); sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, (void *)&rc); } return rc; From 0ecdeb2414240ffcf131f4d222c12a6b63bcd4db Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 25 Jan 2011 13:43:35 +0000 Subject: [PATCH 70/82] Fix a couple of typos in comments. No changes to actual code. FossilOrigin-Name: 9167fdb3560b1567a0bdc9a1906a87ec98e161f1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/prepare.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e5ed493431..d63ccb4da2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbroken\sassert()\sin\spager.c. -D 2011-01-25T11:33:01 +C Fix\sa\scouple\sof\stypos\sin\scomments.\sNo\schanges\sto\sactual\scode. +D 2011-01-25T13:43:35 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -169,7 +169,7 @@ F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 54401ef4ea296b5bc2950bfbf5e68d6e931ab676 F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 -F src/prepare.c c8b877b80721d70b68053fd9ae30ec6d63eeeadc +F src/prepare.c 395b3fab1b93f45b6aa194b23ebc201221c47b99 F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 @@ -897,7 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7ef3f7cba768ef0c4782a6c80424833b4df6a059 -R ba7b28c2183cb4939792757ce9044a5a +P 13108ce13c281f31aa60b403567710ae3d925797 +R 65a9c8caa43f6ab5a0a574c1c511a44f U dan -Z 1be8a639466ca213ddcd4aee76a16760 +Z e065b48f5c532f6c7bd5d8c0c158d9e1 diff --git a/manifest.uuid b/manifest.uuid index e349fb1816..e9cddf2565 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -13108ce13c281f31aa60b403567710ae3d925797 \ No newline at end of file +9167fdb3560b1567a0bdc9a1906a87ec98e161f1 \ No newline at end of file diff --git a/src/prepare.c b/src/prepare.c index 816abdf116..62a33b6717 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -784,7 +784,7 @@ int sqlite3_prepare_v2( */ static int sqlite3Prepare16( sqlite3 *db, /* Database handle. */ - const void *zSql, /* UTF-8 encoded SQL statement. */ + const void *zSql, /* UTF-16 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ int saveSqlFlag, /* True to save SQL text into the sqlite3_stmt */ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ @@ -834,7 +834,7 @@ static int sqlite3Prepare16( */ int sqlite3_prepare16( sqlite3 *db, /* Database handle. */ - const void *zSql, /* UTF-8 encoded SQL statement. */ + const void *zSql, /* UTF-16 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const void **pzTail /* OUT: End of parsed string */ @@ -846,7 +846,7 @@ int sqlite3_prepare16( } int sqlite3_prepare16_v2( sqlite3 *db, /* Database handle. */ - const void *zSql, /* UTF-8 encoded SQL statement. */ + const void *zSql, /* UTF-16 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const void **pzTail /* OUT: End of parsed string */ From 951596cdef06e386075280b0dd92cd3fc00764c0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Jan 2011 16:20:16 +0000 Subject: [PATCH 71/82] Change the name of SQLITE_FCNTL_SYNC to SQLITE_FCNTL_SYNC_OMITTED and only send it when PRAGMA synchronous=OFF. Add better documentation to explain what that file-control opcode is used for. FossilOrigin-Name: 64914980855dbbf19512642836ca962a507b3ddb --- manifest | 26 ++++++++++++++++++-------- manifest.uuid | 2 +- src/pager.c | 11 +++++------ src/sqlite.h.in | 16 ++++++++++------ 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index d63ccb4da2..f168e9a13f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\scouple\sof\stypos\sin\scomments.\sNo\schanges\sto\sactual\scode. -D 2011-01-25T13:43:35 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Change\sthe\sname\sof\sSQLITE_FCNTL_SYNC\sto\sSQLITE_FCNTL_SYNC_OMITTED\sand\sonly\nsend\sit\swhen\sPRAGMA\ssynchronous=OFF.\s\sAdd\sbetter\sdocumentation\sto\sexplain\nwhat\sthat\sfile-control\sopcode\sis\sused\sfor. +D 2011-01-25T16:20:16.289 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c eb355fc87cd84b47f70b479569f1ad1338fb4e2d +F src/pager.c c8975ac965895d507daa6b3e4e0aca8b4aaf629b F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -176,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in da5f52960e61bd8940413bd07da0e8150531552d +F src/sqlite.h.in a059e7c0128a656adeb923c34e99a117de99c23d F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 45926deaf59b1ce3f55d21d5f91a8cecb6a7eb4c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -897,7 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 13108ce13c281f31aa60b403567710ae3d925797 -R 65a9c8caa43f6ab5a0a574c1c511a44f -U dan -Z e065b48f5c532f6c7bd5d8c0c158d9e1 +P 9167fdb3560b1567a0bdc9a1906a87ec98e161f1 +R 96da40f86ab20bb4a774456ca34a544b +U drh +Z c8970634e68cbff2a072ebb3d5e57cae +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNPvhDoxKgR168RlERAqjUAJ9akpjzOSwn0PlU/phdYvzW8+YrjQCghpGF +iTJlh/160LuCnZw69rf6DrI= +=E72H +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e9cddf2565..5883969aa6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9167fdb3560b1567a0bdc9a1906a87ec98e161f1 \ No newline at end of file +64914980855dbbf19512642836ca962a507b3ddb \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index a6f7aac370..d2eb3d5e7e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5624,15 +5624,14 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ */ int sqlite3PagerSync(Pager *pPager){ int rc; /* Return code */ - if( pPager->noSync ){ - rc = SQLITE_OK; - }else{ + if( !pPager->noSync ){ assert( !MEMDB ); rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); - } - if( isOpen(pPager->fd) ){ + }else if( isOpen(pPager->fd) ){ assert( !MEMDB ); - sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, (void *)&rc); + sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, (void *)&rc); + }else{ + rc = SQLITE_OK; } return rc; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 360ccd5779..f3d709213c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -716,11 +716,15 @@ struct sqlite3_io_methods { ** connection. See the [sqlite3_file_control()] documentation for ** additional information. ** -** The [SQLITE_FCNTL_SYNC] opcode is used internally. SQLite calls -** the file-control method with this opcode immediately after the database -** file is synced, or if the database is running in synchronous=off mode -** immediately after it would have been synced otherwise. This makes it -** easier to write special VFS modules that depend on the xSync call. +** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by +** SQLite and sent to all VFSes in place of a call to the xSync method +** when the database connection has [PRAGMA synchronous] set to OFF.)^ +** Some specialized VFSes need this signal in order to operate correctly +** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most +** VFSes do not need this signal and should silently ignore this opcode. +** Applications should not call [sqlite3_file_control()] with this +** opcode as doing so may disrupt the operation of the specilized VFSes +** that do require it. */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_GET_LOCKPROXYFILE 2 @@ -729,7 +733,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_SIZE_HINT 5 #define SQLITE_FCNTL_CHUNK_SIZE 6 #define SQLITE_FCNTL_FILE_POINTER 7 -#define SQLITE_FCNTL_SYNC 8 +#define SQLITE_FCNTL_SYNC_OMITTED 8 /* From 534a58a76d22f39d88fa94ee0f80ad9a64038a0a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Jan 2011 16:48:56 +0000 Subject: [PATCH 72/82] Make sure the return code from doing an xSync is correctly initialized so that a valid return code is produced regardless of the path taken through the logic. FossilOrigin-Name: f12b5d76854c2f294ac60afe38a6dac37eb5b174 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pager.c | 4 +--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index f168e9a13f..dfb684e390 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Change\sthe\sname\sof\sSQLITE_FCNTL_SYNC\sto\sSQLITE_FCNTL_SYNC_OMITTED\sand\sonly\nsend\sit\swhen\sPRAGMA\ssynchronous=OFF.\s\sAdd\sbetter\sdocumentation\sto\sexplain\nwhat\sthat\sfile-control\sopcode\sis\sused\sfor. -D 2011-01-25T16:20:16.289 +C Make\ssure\sthe\sreturn\scode\sfrom\sdoing\san\sxSync\sis\scorrectly\sinitialized\nso\sthat\sa\svalid\sreturn\scode\sis\sproduced\sregardless\sof\sthe\spath\staken\sthrough\nthe\slogic. +D 2011-01-25T16:48:56.989 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad -F src/pager.c c8975ac965895d507daa6b3e4e0aca8b4aaf629b +F src/pager.c 37696d876b1c23aa95d8ad7e4afd72d8675984fa F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9167fdb3560b1567a0bdc9a1906a87ec98e161f1 -R 96da40f86ab20bb4a774456ca34a544b +P 64914980855dbbf19512642836ca962a507b3ddb +R 9dfb3a97b26cb66f3555d49b9adf879c U drh -Z c8970634e68cbff2a072ebb3d5e57cae +Z 00c400aa2e34e8badd39b4e9068a7ec7 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNPvhDoxKgR168RlERAqjUAJ9akpjzOSwn0PlU/phdYvzW8+YrjQCghpGF -iTJlh/160LuCnZw69rf6DrI= -=E72H +iD8DBQFNPv77oxKgR168RlERAl9SAJwJ3rffv8HI7U1fymg0vldV7CNxRwCcDVQE +5HWPR+CixXdxSOos4b+wQvs= +=F9X2 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 5883969aa6..8c88883723 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -64914980855dbbf19512642836ca962a507b3ddb \ No newline at end of file +f12b5d76854c2f294ac60afe38a6dac37eb5b174 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d2eb3d5e7e..28cf452546 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5623,15 +5623,13 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ ** function returns SQLITE_OK. Otherwise, an IO error code is returned. */ int sqlite3PagerSync(Pager *pPager){ - int rc; /* Return code */ + int rc = SQLITE_OK; if( !pPager->noSync ){ assert( !MEMDB ); rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); }else if( isOpen(pPager->fd) ){ assert( !MEMDB ); sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, (void *)&rc); - }else{ - rc = SQLITE_OK; } return rc; } From 4d26d585d6167c933bfc596e1cece107cb639871 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 25 Jan 2011 18:19:24 +0000 Subject: [PATCH 73/82] Add a missing call to sqlite3PagerSync() removed by [ce552d975] to the backup code. FossilOrigin-Name: 1965b85318c1fac62fae9691059021b298c17dde --- manifest | 24 +++++++----------------- manifest.uuid | 2 +- src/backup.c | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index dfb684e390..96c14ed460 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Make\ssure\sthe\sreturn\scode\sfrom\sdoing\san\sxSync\sis\scorrectly\sinitialized\nso\sthat\sa\svalid\sreturn\scode\sis\sproduced\sregardless\sof\sthe\spath\staken\sthrough\nthe\slogic. -D 2011-01-25T16:48:56.989 +C Add\sa\smissing\scall\sto\ssqlite3PagerSync()\sremoved\sby\s[ce552d975]\sto\sthe\sbackup\scode. +D 2011-01-25T18:19:25 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -119,7 +116,7 @@ F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 F src/analyze.c a038162344265ac21dfb24b3fcc06c666ebb9c07 F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 8c39a1ebba1e9dc385519cc4d434c7b0cab6638c +F src/backup.c 6728d6d48d55b449af76a3e51c0808849cb32a2e F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 9004c98fc576306eee4fc0562ffeb362ef53912c @@ -900,14 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 64914980855dbbf19512642836ca962a507b3ddb -R 9dfb3a97b26cb66f3555d49b9adf879c -U drh -Z 00c400aa2e34e8badd39b4e9068a7ec7 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNPv77oxKgR168RlERAl9SAJwJ3rffv8HI7U1fymg0vldV7CNxRwCcDVQE -5HWPR+CixXdxSOos4b+wQvs= -=F9X2 ------END PGP SIGNATURE----- +P f12b5d76854c2f294ac60afe38a6dac37eb5b174 +R 085f3541c695880a57ad39b45c4ccb90 +U dan +Z d44ae9b8b3c13e9672f7c0d2b1c1ba1f diff --git a/manifest.uuid b/manifest.uuid index 8c88883723..dc04c747e5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f12b5d76854c2f294ac60afe38a6dac37eb5b174 \ No newline at end of file +1965b85318c1fac62fae9691059021b298c17dde \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 7258b26aa6..5d8ea7f3fe 100644 --- a/src/backup.c +++ b/src/backup.c @@ -449,6 +449,16 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1) && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest )); + + /* This call 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. */ + rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); + + /* Write the extra pages and truncate the database file as required. */ iEnd = MIN(PENDING_BYTE + pgszDest, iSize); for( iOff=PENDING_BYTE+pgszSrc; @@ -465,10 +475,12 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ sqlite3PagerUnref(pSrcPg); } if( rc==SQLITE_OK ){ - rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); - if( rc==SQLITE_OK ){ - rc = backupTruncateFile(pFile, iSize); - } + rc = backupTruncateFile(pFile, iSize); + } + + /* Sync the database file to disk. */ + if( rc==SQLITE_OK ){ + rc = sqlite3PagerSync(pDestPager); } }else{ rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0); From 1e4040a4b46d6b5242985d6f7ecb51b7847789e3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Jan 2011 18:30:51 +0000 Subject: [PATCH 74/82] Fix new compiler warnings in pcache1.c that were introduced by the recent performance enhancement patches of [e14649301138b684]. FossilOrigin-Name: c17703ec1e604934f8bd5b1f66f34b19d17a6d1f --- manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- src/pcache1.c | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 96c14ed460..b261f28f5b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Add\sa\smissing\scall\sto\ssqlite3PagerSync()\sremoved\sby\s[ce552d975]\sto\sthe\sbackup\scode. -D 2011-01-25T18:19:25 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\snew\scompiler\swarnings\sin\spcache1.c\sthat\swere\sintroduced\sby\sthe\srecent\nperformance\senhancement\spatches\sof\s[e14649301138b684]. +D 2011-01-25T18:30:51.294 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c 54401ef4ea296b5bc2950bfbf5e68d6e931ab676 +F src/pcache1.c 71948ab1b3c792675a7676f991b53f3386cf0af4 F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c 395b3fab1b93f45b6aa194b23ebc201221c47b99 F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 @@ -897,7 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f12b5d76854c2f294ac60afe38a6dac37eb5b174 -R 085f3541c695880a57ad39b45c4ccb90 -U dan -Z d44ae9b8b3c13e9672f7c0d2b1c1ba1f +P 1965b85318c1fac62fae9691059021b298c17dde +R e2194786a7af1bc58874d331b4d38324 +U drh +Z 1ce03f19d621ba40ce2711b30eaeab7c +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNPxbeoxKgR168RlERAmLIAJ9qPhe/e/BRFS7gQNSAhVYcXdVllgCeNPtT +BRtjsNpdZ3Uj5WkxW69HZ1g= +=xwOA +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index dc04c747e5..6fe948e00c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1965b85318c1fac62fae9691059021b298c17dde \ No newline at end of file +c17703ec1e604934f8bd5b1f66f34b19d17a6d1f \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 50765a2fac..93435fecd7 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -672,7 +672,7 @@ static int pcache1Pagecount(sqlite3_pcache *p){ ** 5. Otherwise, allocate and return a new page buffer. */ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ - unsigned int nPinned; + int nPinned; PCache1 *pCache = (PCache1 *)p; PGroup *pGroup; PgHdr1 *pPage = 0; @@ -713,7 +713,7 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ assert( pCache->mxPinned == pCache->nMax*9/10 ); if( createFlag==1 && ( nPinned>=pGroup->mxPinned - || nPinned>=pCache->mxPinned + || nPinned>=(int)pCache->mxPinned || pcache1UnderMemoryPressure(pCache) )){ goto fetch_out; From 25ca568251968708456750718c2342e358aa7c93 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 26 Jan 2011 00:07:03 +0000 Subject: [PATCH 75/82] Rename the PCache1.mxPinned field to n90pct (since it is 90% of nMax) in order to distinguish it from PGroup.mxPinned. Fix the computation of n90pct so that it does not overflow adversely on excessively large cache sizes. FossilOrigin-Name: c85202baac49b22a4be36b9733d44f01d83edb28 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pcache1.c | 9 +++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index b261f28f5b..f452235443 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\snew\scompiler\swarnings\sin\spcache1.c\sthat\swere\sintroduced\sby\sthe\srecent\nperformance\senhancement\spatches\sof\s[e14649301138b684]. -D 2011-01-25T18:30:51.294 +C Rename\sthe\sPCache1.mxPinned\sfield\sto\sn90pct\s(since\sit\sis\s90%\sof\snMax)\sin\sorder\nto\sdistinguish\sit\sfrom\sPGroup.mxPinned.\s\sFix\sthe\scomputation\sof\sn90pct\sso\sthat\nit\sdoes\snot\soverflow\sadversely\son\sexcessively\slarge\scache\ssizes. +D 2011-01-26T00:07:03.942 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c 71948ab1b3c792675a7676f991b53f3386cf0af4 +F src/pcache1.c 6901229309a7896e7635ca404f224a0a591bdfb2 F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c 395b3fab1b93f45b6aa194b23ebc201221c47b99 F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1965b85318c1fac62fae9691059021b298c17dde -R e2194786a7af1bc58874d331b4d38324 +P c17703ec1e604934f8bd5b1f66f34b19d17a6d1f +R 109c7d92ff691fdbec42c31d55aa6410 U drh -Z 1ce03f19d621ba40ce2711b30eaeab7c +Z 0733d70beb9057473e955a3b5b264719 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNPxbeoxKgR168RlERAmLIAJ9qPhe/e/BRFS7gQNSAhVYcXdVllgCeNPtT -BRtjsNpdZ3Uj5WkxW69HZ1g= -=xwOA +iD8DBQFNP2WroxKgR168RlERArihAJ9FjxySq+QwzE3GYgMW9h2HMqvBogCfVKVW +Qn6jaMIKh2jPgnqXtNc05Yk= +=HMnc -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 6fe948e00c..a8c99a8928 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c17703ec1e604934f8bd5b1f66f34b19d17a6d1f \ No newline at end of file +c85202baac49b22a4be36b9733d44f01d83edb28 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 93435fecd7..4de01376b4 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -74,7 +74,7 @@ struct PCache1 { int bPurgeable; /* True if cache is purgeable */ unsigned int nMin; /* Minimum number of pages reserved */ unsigned int nMax; /* Configured "cache_size" value */ - unsigned int mxPinned; /* nMax*9/10 */ + unsigned int n90pct; /* nMax*9/10 */ /* Hash table of all pages. The following variables may only be accessed ** when the accessor is holding the PGroup mutex. @@ -599,7 +599,7 @@ static void pcache1Cachesize(sqlite3_pcache *p, int nMax){ pGroup->nMaxPage += (nMax - pCache->nMax); pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pCache->nMax = nMax; - pCache->mxPinned = nMax*9/10; + pCache->n90pct = pCache->nMax*9/10; pcache1EnforceMaxPage(pGroup); pcache1LeaveMutex(pGroup); } @@ -709,11 +709,12 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){ /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ nPinned = pCache->nPage - pCache->nRecyclable; + assert( nPinned>=0 ); assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage ); - assert( pCache->mxPinned == pCache->nMax*9/10 ); + assert( pCache->n90pct == pCache->nMax*9/10 ); if( createFlag==1 && ( nPinned>=pGroup->mxPinned - || nPinned>=(int)pCache->mxPinned + || nPinned>=(int)pCache->n90pct || pcache1UnderMemoryPressure(pCache) )){ goto fetch_out; From 7cfbeb7fb5be5f81aa9e0c469039530c1918b87a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 26 Jan 2011 06:13:14 +0000 Subject: [PATCH 76/82] Changes to exclusive2.test to make it more deterministic. FossilOrigin-Name: 84b0c2bc7125623be2ee526b5ca75e1b72debb93 --- manifest | 24 +++++++----------------- manifest.uuid | 2 +- test/exclusive2.test | 29 +++++++++++++++-------------- 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index f452235443..341d671a0e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Rename\sthe\sPCache1.mxPinned\sfield\sto\sn90pct\s(since\sit\sis\s90%\sof\snMax)\sin\sorder\nto\sdistinguish\sit\sfrom\sPGroup.mxPinned.\s\sFix\sthe\scomputation\sof\sn90pct\sso\sthat\nit\sdoes\snot\soverflow\sadversely\son\sexcessively\slarge\scache\ssizes. -D 2011-01-26T00:07:03.942 +C Changes\sto\sexclusive2.test\sto\smake\sit\smore\sdeterministic. +D 2011-01-26T06:13:15 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -377,7 +374,7 @@ F test/enc4.test 4b575ef09e0eff896e73bd24076f96c2aa6a42de F test/eqp.test 69670e7919030f21de29fb99bf1d68f97aedcbdb F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3 F test/exclusive.test 53e1841b422e554cecf0160f937c473d6d0e3062 -F test/exclusive2.test c2f2b2242dc436a12df8dd531e06843053bd3b9a +F test/exclusive2.test b65264c3e76e1db6c6eda15c02000a40743f6541 F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/expr.test 620a636cf7b7d4e5834a0b9d83a4da372e24a7b7 F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 @@ -900,14 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c17703ec1e604934f8bd5b1f66f34b19d17a6d1f -R 109c7d92ff691fdbec42c31d55aa6410 -U drh -Z 0733d70beb9057473e955a3b5b264719 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNP2WroxKgR168RlERArihAJ9FjxySq+QwzE3GYgMW9h2HMqvBogCfVKVW -Qn6jaMIKh2jPgnqXtNc05Yk= -=HMnc ------END PGP SIGNATURE----- +P c85202baac49b22a4be36b9733d44f01d83edb28 +R 85ac3b6bb904f05f09996814ba9f096b +U dan +Z 780b8c90621146e71b5a8492b6618973 diff --git a/manifest.uuid b/manifest.uuid index a8c99a8928..cda47ecd86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c85202baac49b22a4be36b9733d44f01d83edb28 \ No newline at end of file +84b0c2bc7125623be2ee526b5ca75e1b72debb93 \ No newline at end of file diff --git a/test/exclusive2.test b/test/exclusive2.test index 4a167c7f42..b2b98ff5c1 100644 --- a/test/exclusive2.test +++ b/test/exclusive2.test @@ -163,6 +163,7 @@ do_test exclusive2-1.10 { do_test exclusive2-1.11 { expr {[t1sig] eq $::sig} } {0} +db2 close #-------------------------------------------------------------------- # These tests - exclusive2-2.X - are similar to exclusive2-1.X, @@ -252,7 +253,6 @@ do_test exclusive2-2.8 { # db close -db2 close catch {close $::fd} file delete -force test.db file delete -force test.db-journal @@ -262,50 +262,51 @@ do_test exclusive2-3.0 { execsql { BEGIN; CREATE TABLE t1(a UNIQUE); - INSERT INTO t1 VALUES(randstr(10, 400)); - INSERT INTO t1 VALUES(randstr(10, 400)); + INSERT INTO t1 VALUES(randstr(200, 200)); + INSERT INTO t1 VALUES(randstr(200, 200)); COMMIT; } readPagerChangeCounter test.db } {1} do_test exclusive2-3.1 { execsql { - INSERT INTO t1 VALUES(randstr(10, 400)); + INSERT INTO t1 VALUES(randstr(200, 200)); } readPagerChangeCounter test.db } {2} do_test exclusive2-3.2 { execsql { - INSERT INTO t1 VALUES(randstr(10, 400)); + INSERT INTO t1 VALUES(randstr(200, 200)); } readPagerChangeCounter test.db } {3} do_test exclusive2-3.3 { execsql { PRAGMA locking_mode = exclusive; - INSERT INTO t1 VALUES(randstr(10, 400)); + INSERT INTO t1 VALUES(randstr(200, 200)); } readPagerChangeCounter test.db } {4} do_test exclusive2-3.4 { +breakpoint execsql { - INSERT INTO t1 VALUES(randstr(10, 400)); + INSERT INTO t1 VALUES(randstr(200, 200)); } readPagerChangeCounter test.db } {4} do_test exclusive2-3.5 { execsql { PRAGMA locking_mode = normal; - INSERT INTO t1 VALUES(randstr(10, 400)); + INSERT INTO t1 VALUES(randstr(200, 200)); + } + readPagerChangeCounter test.db +} {4} +do_test exclusive2-3.6 { + execsql { + INSERT INTO t1 VALUES(randstr(200, 200)); } readPagerChangeCounter test.db } {5} -do_test exclusive2-3.6 { - execsql { - INSERT INTO t1 VALUES(randstr(10, 400)); - } - readPagerChangeCounter test.db -} {6} sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) finish_test From 6d4fb833b7f70192f37c7926aca7f958d8ad0113 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 26 Jan 2011 07:25:32 +0000 Subject: [PATCH 77/82] Update mutex1.test so that it works with the memsubsys1 permutation (pagecache memory). Change a few instances of SQLITE_MUTEX_STATIC_LRU2 in comments and test code to STATIC_PMEM. FossilOrigin-Name: 456bd5c63b41bae8e389df81e318b830aa314000 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/mutex_unix.c | 2 +- src/mutex_w32.c | 2 +- src/test_mutex.c | 2 +- test/mutex1.test | 16 ++++++++++++++-- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 341d671a0e..ce3b4c2f72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\sexclusive2.test\sto\smake\sit\smore\sdeterministic. -D 2011-01-26T06:13:15 +C Update\smutex1.test\sso\sthat\sit\sworks\swith\sthe\smemsubsys1\spermutation\s(pagecache\smemory).\sChange\sa\sfew\sinstances\sof\sSQLITE_MUTEX_STATIC_LRU2\sin\scomments\sand\stest\scode\sto\sSTATIC_PMEM. +D 2011-01-26T07:25:33 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -153,8 +153,8 @@ F src/mutex.c 6949180803ff05a7d0e2b9334a95b4fb5a00e23f F src/mutex.h fe2ef5e1c4dae531d5a544f9241f19c56d26803d F src/mutex_noop.c d5cfbca87168c661a0b118cd8e329a908e453151 F src/mutex_os2.c 6a62583e374ba3ac1a3fcc0da2bfdac7d3942689 -F src/mutex_unix.c abb8c98a6c27c57280e71522d059e929c708d019 -F src/mutex_w32.c b7ed3366a1d44a62a17d4eaefdaa2e7c25f944c2 +F src/mutex_unix.c b4f4e923bb8de93ec3f251fadb50855f23df9579 +F src/mutex_w32.c 3ade5ae71449d1d023f0ebb3184c2ae6aa9307e4 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 @@ -208,7 +208,7 @@ F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_malloc.c fd6188b1501c0010fb4241ddc9f0d5ac402c688d F src/test_multiplex.c 5990431a852aa21c9a67da748f23d2cf1e21f8fc -F src/test_mutex.c ce06b59aca168cd8c520b77159a24352a7469bd3 +F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec F src/test_osinst.c f408c6a181f2fb04c56273afd5c3e1e82f60392c F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8 @@ -567,7 +567,7 @@ F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 F test/multiplex.test 92a4839213fd8cba8b59f86d42b7a1da1857db39 -F test/mutex1.test 2fe5d592763e1aad6612b59fd862c8b1b0e0304b +F test/mutex1.test 82327b00f725342ac037fa04f26abd188bf3d29f F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test a44e04df1486fcfb02d32468cbcd3c8e1e433723 F test/notify1.test 8433bc74bd952fb8a6e3f8d7a4c2b28dfd69e310 @@ -897,7 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c85202baac49b22a4be36b9733d44f01d83edb28 -R 85ac3b6bb904f05f09996814ba9f096b +P 84b0c2bc7125623be2ee526b5ca75e1b72debb93 +R 8125a99a44546cc6d7303e50e91f7f22 U dan -Z 780b8c90621146e71b5a8492b6618973 +Z 3df0eeee4d5857c3b53d4734fc7e090b diff --git a/manifest.uuid b/manifest.uuid index cda47ecd86..d56e71e3cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -84b0c2bc7125623be2ee526b5ca75e1b72debb93 \ No newline at end of file +456bd5c63b41bae8e389df81e318b830aa314000 \ No newline at end of file diff --git a/src/mutex_unix.c b/src/mutex_unix.c index 196975e717..aa9a8cf265 100644 --- a/src/mutex_unix.c +++ b/src/mutex_unix.c @@ -99,7 +99,7 @@ static int pthreadMutexEnd(void){ return SQLITE_OK; } **
  • SQLITE_MUTEX_STATIC_MEM2 **
  • SQLITE_MUTEX_STATIC_PRNG **
  • SQLITE_MUTEX_STATIC_LRU -**
  • SQLITE_MUTEX_STATIC_LRU2 +**
  • SQLITE_MUTEX_STATIC_PMEM ** ** ** The first two constants cause sqlite3_mutex_alloc() to create diff --git a/src/mutex_w32.c b/src/mutex_w32.c index fba964a461..8e257a91b0 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -156,7 +156,7 @@ static int winMutexEnd(void){ **
  • SQLITE_MUTEX_STATIC_MEM2 **
  • SQLITE_MUTEX_STATIC_PRNG **
  • SQLITE_MUTEX_STATIC_LRU -**
  • SQLITE_MUTEX_STATIC_LRU2 +**
  • SQLITE_MUTEX_STATIC_PMEM ** ** ** The first two constants cause sqlite3_mutex_alloc() to create diff --git a/src/test_mutex.c b/src/test_mutex.c index ff388f3769..0bb74375d8 100644 --- a/src/test_mutex.c +++ b/src/test_mutex.c @@ -247,7 +247,7 @@ static int test_read_mutex_counters( int ii; char *aName[8] = { "fast", "recursive", "static_master", "static_mem", - "static_open", "static_prng", "static_lru", "static_lru2" + "static_open", "static_prng", "static_lru", "static_pmem" }; if( objc!=1 ){ diff --git a/test/mutex1.test b/test/mutex1.test index e2f7c89fb3..eeb33c133f 100644 --- a/test/mutex1.test +++ b/test/mutex1.test @@ -101,10 +101,22 @@ ifcapable threadsafe&&shared_cache { set enable_shared_cache [sqlite3_enable_shared_cache 1] foreach {mode mutexes} { singlethread {} - multithread {fast static_lru static_master static_mem static_open static_prng } - serialized {fast recursive static_lru static_master static_mem static_open static_prng} + multithread { + fast static_lru static_master static_mem static_open static_prng + } + serialized { + fast recursive static_lru static_master static_mem static_open static_prng + } } { + # Permutation "memsubsys1" configures a block of PAGECACHE memory. In + # multi-threaded and serialized modes, this causes SQLite to use the + # STATIC_PMEM mutex as well. + # + if {[permutation] == "memsubsys1" && $mode != "singlethread"} { + lappend mutexes static_pmem + } + do_test mutex1.2.$mode.1 { catch {db close} sqlite3_shutdown From 9bf3da8eab7f6e14d9872ba58556602256013de2 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 26 Jan 2011 13:24:40 +0000 Subject: [PATCH 78/82] Add a mutex around an sqlite3StatusAdd() call to prevent the pagecount overflow measurements from getting off in multithreaded applications. FossilOrigin-Name: 3d8b298dc24fe13a3f390da41f79b8613a6f25a7 --- manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- src/pcache1.c | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ce3b4c2f72..65250024d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Update\smutex1.test\sso\sthat\sit\sworks\swith\sthe\smemsubsys1\spermutation\s(pagecache\smemory).\sChange\sa\sfew\sinstances\sof\sSQLITE_MUTEX_STATIC_LRU2\sin\scomments\sand\stest\scode\sto\sSTATIC_PMEM. -D 2011-01-26T07:25:33 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Add\sa\smutex\saround\san\ssqlite3StatusAdd()\scall\sto\sprevent\sthe\spagecount\noverflow\smeasurements\sfrom\sgetting\soff\sin\smultithreaded\sapplications. +D 2011-01-26T13:24:40.120 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c 6901229309a7896e7635ca404f224a0a591bdfb2 +F src/pcache1.c a3665bec02fd1859a448685bb9f62ddf75dafe7d F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c 395b3fab1b93f45b6aa194b23ebc201221c47b99 F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 @@ -897,7 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 84b0c2bc7125623be2ee526b5ca75e1b72debb93 -R 8125a99a44546cc6d7303e50e91f7f22 -U dan -Z 3df0eeee4d5857c3b53d4734fc7e090b +P 456bd5c63b41bae8e389df81e318b830aa314000 +R e9ff079b5376d2fdaa7dd27f5d3aa591 +U drh +Z 0347c394dd69de4fec8d697e37a04dc3 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNQCCboxKgR168RlERAgYTAJ949Xo1bAfltv62PyaX5TgKLvA4aACfTdqt +FRsrM3bWeZxqlcofaLsFcCo= +=atuH +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index d56e71e3cf..26ffaf510d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -456bd5c63b41bae8e389df81e318b830aa314000 \ No newline at end of file +3d8b298dc24fe13a3f390da41f79b8613a6f25a7 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 4de01376b4..f2b2b419c8 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -228,7 +228,9 @@ static void *pcache1Alloc(int nByte){ p = sqlite3Malloc(nByte); if( p ){ int sz = sqlite3MallocSize(p); + sqlite3_mutex_enter(pcache1.mutex); sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); + sqlite3_mutex_leave(pcache1.mutex); } sqlite3MemdebugSetType(p, MEMTYPE_PCACHE); } From 15ad92f2ae75d432a6e4e273a951fc361a91788f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 26 Jan 2011 13:28:06 +0000 Subject: [PATCH 79/82] More mutexes around another sqlite3StatusAdd() call. FossilOrigin-Name: e3b500fb5d93d98e6e1ddf6d494a841274d1b68d --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/pcache1.c | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 65250024d5..44177aef10 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sa\smutex\saround\san\ssqlite3StatusAdd()\scall\sto\sprevent\sthe\spagecount\noverflow\smeasurements\sfrom\sgetting\soff\sin\smultithreaded\sapplications. -D 2011-01-26T13:24:40.120 +C More\smutexes\saround\sanother\ssqlite3StatusAdd()\scall. +D 2011-01-26T13:28:06.817 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 -F src/pcache1.c a3665bec02fd1859a448685bb9f62ddf75dafe7d +F src/pcache1.c d548e31beafa792d1994b663a29a5303569efc4e F src/pragma.c 8a6cd3c787f882fa44f6490d2411fc26839ce8f3 F src/prepare.c 395b3fab1b93f45b6aa194b23ebc201221c47b99 F src/printf.c df2ff3bb5409e8958136933342c46464fbd017e7 @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 456bd5c63b41bae8e389df81e318b830aa314000 -R e9ff079b5376d2fdaa7dd27f5d3aa591 +P 3d8b298dc24fe13a3f390da41f79b8613a6f25a7 +R 8bec252fd5dcf071b20c7cceab03d8a2 U drh -Z 0347c394dd69de4fec8d697e37a04dc3 +Z 3c6d45926fd8efb972d0995d2c3bad6a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNQCCboxKgR168RlERAgYTAJ949Xo1bAfltv62PyaX5TgKLvA4aACfTdqt -FRsrM3bWeZxqlcofaLsFcCo= -=atuH +iD8DBQFNQCFqoxKgR168RlERAiwGAJ0cBumTFjZ5105DfX3qiQyGjRZTKACghazJ +nCeAfq7e8ZlzhwHXe9OFZXA= +=p/dR -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 26ffaf510d..8184da4041 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d8b298dc24fe13a3f390da41f79b8613a6f25a7 \ No newline at end of file +e3b500fb5d93d98e6e1ddf6d494a841274d1b68d \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index f2b2b419c8..ad443954bf 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -258,7 +258,9 @@ static void pcache1Free(void *p){ assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) ); sqlite3MemdebugSetType(p, MEMTYPE_HEAP); iSize = sqlite3MallocSize(p); + sqlite3_mutex_enter(pcache1.mutex); sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize); + sqlite3_mutex_leave(pcache1.mutex); sqlite3_free(p); } } From b69577d3b8fbf944ba032f39b4b6d5eb3ff99c85 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 26 Jan 2011 15:23:22 +0000 Subject: [PATCH 80/82] Update test file mutex1.test to account for [e3b500fb5d]. FossilOrigin-Name: c86e46f4fd8f485fa1d34c70e17ea3aa1b334ce3 --- manifest | 24 +++++++----------------- manifest.uuid | 2 +- test/mutex1.test | 12 +++--------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 44177aef10..ef611e732a 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C More\smutexes\saround\sanother\ssqlite3StatusAdd()\scall. -D 2011-01-26T13:28:06.817 +C Update\stest\sfile\smutex1.test\sto\saccount\sfor\s[e3b500fb5d]. +D 2011-01-26T15:23:23 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -570,7 +567,7 @@ F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 F test/multiplex.test 92a4839213fd8cba8b59f86d42b7a1da1857db39 -F test/mutex1.test 82327b00f725342ac037fa04f26abd188bf3d29f +F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test a44e04df1486fcfb02d32468cbcd3c8e1e433723 F test/notify1.test 8433bc74bd952fb8a6e3f8d7a4c2b28dfd69e310 @@ -900,14 +897,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3d8b298dc24fe13a3f390da41f79b8613a6f25a7 -R 8bec252fd5dcf071b20c7cceab03d8a2 -U drh -Z 3c6d45926fd8efb972d0995d2c3bad6a ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNQCFqoxKgR168RlERAiwGAJ0cBumTFjZ5105DfX3qiQyGjRZTKACghazJ -nCeAfq7e8ZlzhwHXe9OFZXA= -=p/dR ------END PGP SIGNATURE----- +P e3b500fb5d93d98e6e1ddf6d494a841274d1b68d +R ec3d93ba029710ba4b26f6ed28374b0b +U dan +Z fe9e3186d44ef416a58b3439b4308b42 diff --git a/manifest.uuid b/manifest.uuid index 8184da4041..0a5b768b88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e3b500fb5d93d98e6e1ddf6d494a841274d1b68d \ No newline at end of file +c86e46f4fd8f485fa1d34c70e17ea3aa1b334ce3 \ No newline at end of file diff --git a/test/mutex1.test b/test/mutex1.test index eeb33c133f..4bdf769ad3 100644 --- a/test/mutex1.test +++ b/test/mutex1.test @@ -103,20 +103,14 @@ ifcapable threadsafe&&shared_cache { singlethread {} multithread { fast static_lru static_master static_mem static_open static_prng + static_pmem } serialized { - fast recursive static_lru static_master static_mem static_open static_prng + fast recursive static_lru static_master static_mem static_open + static_prng static_pmem } } { - # Permutation "memsubsys1" configures a block of PAGECACHE memory. In - # multi-threaded and serialized modes, this causes SQLite to use the - # STATIC_PMEM mutex as well. - # - if {[permutation] == "memsubsys1" && $mode != "singlethread"} { - lappend mutexes static_pmem - } - do_test mutex1.2.$mode.1 { catch {db close} sqlite3_shutdown From 0b52b7d0cd6cca25a4fc1838a3de6e6584c33aaf Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 26 Jan 2011 19:46:22 +0000 Subject: [PATCH 81/82] Update all built-in VFSes to return SQLITE_OK for the SQLITE_FCNTL_SYNC_OMITTED file-control operation. Also change the xFileControl methods to return SQLITE_NOTFOUND for unrecognized operation codes. FossilOrigin-Name: 6f2c72a0f6579db3f40c079436ca40e3e52bd6d9 --- manifest | 34 ++++++++++++++++++++++------------ manifest.uuid | 2 +- src/main.c | 4 +++- src/os_os2.c | 2 +- src/os_unix.c | 5 ++++- src/os_win.c | 5 ++++- src/sqlite.h.in | 6 ++++-- src/test1.c | 6 +++--- 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index ef611e732a..f0231d549c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Update\stest\sfile\smutex1.test\sto\saccount\sfor\s[e3b500fb5d]. -D 2011-01-26T15:23:23 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Update\sall\sbuilt-in\sVFSes\sto\sreturn\sSQLITE_OK\sfor\sthe\nSQLITE_FCNTL_SYNC_OMITTED\sfile-control\soperation.\s\sAlso\schange\sthe\s\nxFileControl\smethods\sto\sreturn\sSQLITE_NOTFOUND\sfor\sunrecognized\noperation\scodes. +D 2011-01-26T19:46:22.347 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -141,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e -F src/main.c b82ea116fc9e2e059e77b9a1aba76267681f7149 +F src/main.c 6653e46db7ecb5a7449d8a12900147192f748b97 F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -159,9 +162,9 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f -F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e -F src/os_unix.c aeaf65d261219ad96c021cfd0672509d83c005e4 -F src/os_win.c 2f90f7bdec714fad51cd31b4ecad3cc1b4bb5aad +F src/os_os2.c 2e452c9f2ca507623ad351c33a8a8b27849b1863 +F src/os_unix.c 1be46a35bad4bec5171e4de88aaff817260eb378 +F src/os_win.c 9abdcdd925416d854eabb0996c96debd92abfef5 F src/pager.c 37696d876b1c23aa95d8ad7e4afd72d8675984fa F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 @@ -176,14 +179,14 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976 -F src/sqlite.h.in a059e7c0128a656adeb923c34e99a117de99c23d +F src/sqlite.h.in 76955fcd1c5371268ecc8afe0ce6c49ea750ae38 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 45926deaf59b1ce3f55d21d5f91a8cecb6a7eb4c F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 549859dc2c143f3deb6a92636a2d27973652c164 -F src/test1.c 397809a3069c171a507a49b6f6edfc4255b0afbc +F src/test1.c 771407a49ae199241f0efb7055634e4a1899c026 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc F src/test4.c 0528360b5025688002a5feb6be906ddce52eaaee @@ -897,7 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e3b500fb5d93d98e6e1ddf6d494a841274d1b68d -R ec3d93ba029710ba4b26f6ed28374b0b -U dan -Z fe9e3186d44ef416a58b3439b4308b42 +P c86e46f4fd8f485fa1d34c70e17ea3aa1b334ce3 +R 59a65e1de1a8ae7d9445e2c547dd8236 +U drh +Z d8fa84947260f63199b6f3837560c0db +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNQHoRoxKgR168RlERAvFoAJ9x71MhbzYFoS1hvlkP0CNPkaWXTgCdFiTy +LQ5ls4HAbAwWN5puhiqiVhM= +=VwZX +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0a5b768b88..a52d3a28df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c86e46f4fd8f485fa1d34c70e17ea3aa1b334ce3 \ No newline at end of file +6f2c72a0f6579db3f40c079436ca40e3e52bd6d9 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 4b93a2ba54..88dfcf0f3f 100644 --- a/src/main.c +++ b/src/main.c @@ -816,7 +816,7 @@ const char *sqlite3ErrStr(int rc){ /* SQLITE_INTERRUPT */ "interrupted", /* SQLITE_IOERR */ "disk I/O error", /* SQLITE_CORRUPT */ "database disk image is malformed", - /* SQLITE_NOTFOUND */ 0, + /* SQLITE_NOTFOUND */ "unknown operation", /* SQLITE_FULL */ "database or disk is full", /* SQLITE_CANTOPEN */ "unable to open database file", /* SQLITE_PROTOCOL */ "locking protocol", @@ -2364,6 +2364,8 @@ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ rc = SQLITE_OK; }else if( fd->pMethods ){ rc = sqlite3OsFileControl(fd, op, pArg); + }else{ + rc = SQLITE_NOTFOUND; } sqlite3BtreeLeave(pBtree); } diff --git a/src/os_os2.c b/src/os_os2.c index 7ac0cc7cd7..df5ad1026b 100644 --- a/src/os_os2.c +++ b/src/os_os2.c @@ -533,7 +533,7 @@ static int os2FileControl(sqlite3_file *id, int op, void *pArg){ return SQLITE_OK; } } - return SQLITE_ERROR; + return SQLITE_NOTFOUND; } /* diff --git a/src/os_unix.c b/src/os_unix.c index edc716c987..fa200ae800 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3135,8 +3135,11 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ return proxyFileControl(id,op,pArg); } #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ + case SQLITE_FCNTL_SYNC_OMITTED: { + return SQLITE_OK; /* A no-op */ + } } - return SQLITE_ERROR; + return SQLITE_NOTFOUND; } /* diff --git a/src/os_win.c b/src/os_win.c index 1be5149999..70425178e8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1183,8 +1183,11 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ SimulateIOErrorBenign(0); return SQLITE_OK; } + case SQLITE_FCNTL_SYNC_OMITTED: { + return SQLITE_OK; + } } - return SQLITE_ERROR; + return SQLITE_NOTFOUND; } /* diff --git a/src/sqlite.h.in b/src/sqlite.h.in index f3d709213c..eb97746385 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -385,7 +385,7 @@ int sqlite3_exec( #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ -#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ +#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ #define SQLITE_FULL 13 /* Insertion failed because database is full */ #define SQLITE_CANTOPEN 14 /* Unable to open the database file */ #define SQLITE_PROTOCOL 15 /* Database lock protocol error */ @@ -617,7 +617,9 @@ struct sqlite3_file { ** core reserves all opcodes less than 100 for its own use. ** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. ** Applications that define a custom xFileControl method should use opcodes -** greater than 100 to avoid conflicts. +** greater than 100 to avoid conflicts. VFS implementations should +** return [SQLITE_NOTFOUND] for file control opcodes that they do not +** recognize. ** ** The xSectorSize() method returns the sector size of the ** device that underlies the file. The sector size is the diff --git a/src/test1.c b/src/test1.c index bab78451fb..cf7e06b9c7 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4801,13 +4801,13 @@ static int file_control_test( } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite3_file_control(db, 0, 0, &iArg); - assert( rc==SQLITE_ERROR ); + assert( rc==SQLITE_NOTFOUND ); rc = sqlite3_file_control(db, "notadatabase", SQLITE_FCNTL_LOCKSTATE, &iArg); assert( rc==SQLITE_ERROR ); rc = sqlite3_file_control(db, "main", -1, &iArg); - assert( rc==SQLITE_ERROR ); + assert( rc==SQLITE_NOTFOUND ); rc = sqlite3_file_control(db, "temp", -1, &iArg); - assert( rc==SQLITE_ERROR ); + assert( rc==SQLITE_NOTFOUND || rc==SQLITE_ERROR ); return TCL_OK; } From 10431c306b257b3ed703692d87cafea4cea91915 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 27 Jan 2011 14:35:01 +0000 Subject: [PATCH 82/82] SQLite version 3.7.5 release candidate 1 FossilOrigin-Name: 35ac78f55159705af140b949ee33852aedd62816 --- manifest | 14 +++++++------- manifest.uuid | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f0231d549c..5a8fd8dea0 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Update\sall\sbuilt-in\sVFSes\sto\sreturn\sSQLITE_OK\sfor\sthe\nSQLITE_FCNTL_SYNC_OMITTED\sfile-control\soperation.\s\sAlso\schange\sthe\s\nxFileControl\smethods\sto\sreturn\sSQLITE_NOTFOUND\sfor\sunrecognized\noperation\scodes. -D 2011-01-26T19:46:22.347 +C SQLite\sversion\s3.7.5\srelease\scandidate\s1 +D 2011-01-27T14:35:01.967 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -900,14 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c86e46f4fd8f485fa1d34c70e17ea3aa1b334ce3 +P 6f2c72a0f6579db3f40c079436ca40e3e52bd6d9 R 59a65e1de1a8ae7d9445e2c547dd8236 U drh -Z d8fa84947260f63199b6f3837560c0db +Z 98b20f33ccda8aca8fd5329534c7e6b1 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNQHoRoxKgR168RlERAvFoAJ9x71MhbzYFoS1hvlkP0CNPkaWXTgCdFiTy -LQ5ls4HAbAwWN5puhiqiVhM= -=VwZX +iD8DBQFNQYKZoxKgR168RlERAoZXAJwJ1Csq9EFTXieXNgpSf4QMSqUs5QCfcNG/ +DEbh0HvWPBsaT4iBPcr+lKE= +=bDRk -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index a52d3a28df..dcf56e3c0c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f2c72a0f6579db3f40c079436ca40e3e52bd6d9 \ No newline at end of file +35ac78f55159705af140b949ee33852aedd62816 \ No newline at end of file