1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

The win32 driver compiles but does not yet work well. Many bugs

fixed. (CVS 4282)

FossilOrigin-Name: 3a68fcddfa9184e4b310ce0a21312c54b9462ec8
This commit is contained in:
drh
2007-08-24 03:51:33 +00:00
parent bae37537b0
commit 153c62c461
21 changed files with 781 additions and 1058 deletions

View File

@@ -1,5 +1,5 @@
C Make\scomments\sand\svariable\snaming\smore\sconsistent\sWRT\srowid\sversus\ndocid/blockid.\s\sThis\sshould\shave\sno\scode\simpact.\s(CVS\s4281) C The\swin32\sdriver\scompiles\sbut\sdoes\snot\syet\swork\swell.\s\sMany\sbugs\nfixed.\s(CVS\s4282)
D 2007-08-23T20:28:49 D 2007-08-24T03:51:33
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -80,13 +80,13 @@ F src/alter.c f0aac0060ae8102e58f210b44d35b53438d53173
F src/analyze.c a14237d869c6bea0846493b59317e4097e81a0b6 F src/analyze.c a14237d869c6bea0846493b59317e4097e81a0b6
F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8 F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3 F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3
F src/btree.c 8fa6341b74ab70a28001e4ed4bc5ba14ce1401a6 F src/btree.c fe9d292cee1a7fee1e5834ecaa3eb2103f7398bc
F src/btree.h 76c89673981cb77575300c0b78a76eaa00a28743 F src/btree.h 76c89673981cb77575300c0b78a76eaa00a28743
F src/btreeInt.h 7fc6e51dc3d4bbed15639a8ea1aae737631d6670 F src/btreeInt.h 7fc6e51dc3d4bbed15639a8ea1aae737631d6670
F src/build.c bc7406e2ea5bfa8276ee1abeae1db27a98fd0b33 F src/build.c bc7406e2ea5bfa8276ee1abeae1db27a98fd0b33
F src/callback.c a542236a68060caad378efa30006ca46cf77b1b2 F src/callback.c a542236a68060caad378efa30006ca46cf77b1b2
F src/complete.c b6dea59fb6d7b3201fa1e0e552cda8c2258a4f50 F src/complete.c b6dea59fb6d7b3201fa1e0e552cda8c2258a4f50
F src/date.c a80b33f6e70d619978622547d2c78ab8b036b31a F src/date.c af235f38f50809abd0a96da3bb3e0cc32be6226e
F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1 F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c 978afdceb2693ef58ec0040a43fe57afc6e4236c F src/expr.c 978afdceb2693ef58ec0040a43fe57afc6e4236c
@@ -98,34 +98,34 @@ F src/journal.c 03d6b5cc1afe7c5e3cd0af55415f5168eb094398
F src/legacy.c 7e1b1c57694e49cbadf561e2a7d9cd984dc743b5 F src/legacy.c 7e1b1c57694e49cbadf561e2a7d9cd984dc743b5
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35 F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
F src/loadext.c 8b31e2e0e961918fa045515459aee1c122d8c266 F src/loadext.c 8b31e2e0e961918fa045515459aee1c122d8c266
F src/main.c 527f27c74d22d83713abbd1550fd5a4ecce89aca F src/main.c 795ec066ce38908b5c35ca4353bb601d022e2275
F src/malloc.c 8078d4c3f9217c0bb018e432d8655c14996bb107 F src/malloc.c d4282f50964ab1ca31f504c97b7cf2fdb4d4195d
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c 7b023d45dd71944414db469c742457239e24d74d F src/mem1.c afe2fbf6d7e8247c6c9f69c1481358b1cad60c08
F src/mem2.c 48919353f72b8f6e957a0021eb9deaf863998189 F src/mem2.c dfe802143189d491ae00f2c5aa50ce619d02f5bf
F src/mutex.c 9cf641f556a4119ef90ed41b82f2d5647f81686e F src/mutex.c 9cf641f556a4119ef90ed41b82f2d5647f81686e
F src/os.c 86593b6e8cc22304d7c2d24b06c0aae49254b181 F src/os.c 3b0d37208ea3ec9e1f913fbdeaf88841ed443b9d
F src/os.h 399c89cafa93b9ef35c3dc70f77644d10936b535 F src/os.h 2bfbbad126a775e4d8c7d59eb4d9585a5fd7dfb5
F src/os_common.h a5c446d3b93f09f369d13bf217de4bed3437dd1c F src/os_common.h a5c446d3b93f09f369d13bf217de4bed3437dd1c
F src/os_os2.c 8769301bff502de642ad2634cedcb77d967ce199 F src/os_os2.c 8769301bff502de642ad2634cedcb77d967ce199
F src/os_os2.h c3f7d0af7e3453d1d7aa81b06c0a56f5a226530b F src/os_os2.h c3f7d0af7e3453d1d7aa81b06c0a56f5a226530b
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 3ff776e03535b64df12dcc272a913a52d69f3e4a F src/os_unix.c c45b20f868fab1178710ea2f1c8043ce706d3a99
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 29c0e19c1072679a4c7818c49fab2f35d2ad7747 F src/os_win.c 1cb94dd33d38e01de82d77bef107c7f3323463ec
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 0879439873a9da769ee400b3b8c0967afd786fe8 F src/pager.c 89dfc6a0bd72898d147264517a43bdf35348dd2c
F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8 F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8
F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590 F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5 F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5
F src/prepare.c 29ea14cf6b0558f2f80aa53e112bff55f1119e36 F src/prepare.c 29ea14cf6b0558f2f80aa53e112bff55f1119e36
F src/printf.c 0f46bc3a805d5620f5aedfec1c3768d293a5ee5e F src/printf.c 33d23a68e498006136ca9770579cf2d14a7ec68e
F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
F src/select.c 98c367bce3f38c5adfcc97de9ab5c79b0e5dc2b2 F src/select.c 98c367bce3f38c5adfcc97de9ab5c79b0e5dc2b2
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c ac29402b538515fa4697282387be9c1205e6e9eb F src/shell.c ac29402b538515fa4697282387be9c1205e6e9eb
F src/sqlite.h.in a1a5bc9e7e63bf73c2bb68be3749dec2bbd8cc44 F src/sqlite.h.in 09a5256ee80dfc7cb4353739f78e4267be323574
F src/sqlite3ext.h 9a26028378c288af500d8b94ed079666fed5806b F src/sqlite3ext.h 9a26028378c288af500d8b94ed079666fed5806b
F src/sqliteInt.h 951229c727f14f12f1c5555d2ed079bd2201415c F src/sqliteInt.h 951229c727f14f12f1c5555d2ed079bd2201415c
F src/sqliteLimit.h f14609c27636ebc217c9603ade26dbdd7d0f6afa F src/sqliteLimit.h f14609c27636ebc217c9603ade26dbdd7d0f6afa
@@ -136,7 +136,7 @@ F src/test2.c 4f742e99ed1bea5c14692f627bdb59a146f30504
F src/test3.c a7d011c51d6b2e2a73c43983d5c2b731d69c74d7 F src/test3.c a7d011c51d6b2e2a73c43983d5c2b731d69c74d7
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071 F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4 F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
F src/test6.c 5d6286568b12ec6c813cb30d2a14de8229f8e388 F src/test6.c de2dbcd67401f00bfa0affc044ba671aa62384a5
F src/test7.c a9d509d0e9ad214b4772696f49f6e61be26213d1 F src/test7.c a9d509d0e9ad214b4772696f49f6e61be26213d1
F src/test8.c e6a543c8b248efe120ae33a6859fcd55dcf46a96 F src/test8.c e6a543c8b248efe120ae33a6859fcd55dcf46a96
F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f
@@ -146,7 +146,7 @@ F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
F src/test_config.c f0b911bb615d93a192647e76910dce65cbbcf3ad F src/test_config.c f0b911bb615d93a192647e76910dce65cbbcf3ad
F src/test_hexio.c 82916f918687502658f02533b519c38cb180db6d F src/test_hexio.c 82916f918687502658f02533b519c38cb180db6d
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8 F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
F src/test_malloc.c 9d5fb38bc0647ba9376d8d954be5b5aa01e12c80 F src/test_malloc.c 5f5566bb799e72cb328df8933ef9fdb9d90d270e
F src/test_md5.c 34599caee5b1c73dcf86ca31f55846fab8c19ef7 F src/test_md5.c 34599caee5b1c73dcf86ca31f55846fab8c19ef7
F src/test_schema.c 12c9de7661d6294eec2d57afbb52e2af1128084f F src/test_schema.c 12c9de7661d6294eec2d57afbb52e2af1128084f
F src/test_server.c 319f6b1a99bab5f7149387442243d6e65a8ab4eb F src/test_server.c 319f6b1a99bab5f7149387442243d6e65a8ab4eb
@@ -160,12 +160,12 @@ F src/vacuum.c 318ccae7c4e3ddf241aeaee4d2611bfe1949a373
F src/vdbe.c 9d4d00589c174aad9a616f1615464ddddebba0ec F src/vdbe.c 9d4d00589c174aad9a616f1615464ddddebba0ec
F src/vdbe.h 001c5b257567c1d3de7feb2203aac71d0d7b16a3 F src/vdbe.h 001c5b257567c1d3de7feb2203aac71d0d7b16a3
F src/vdbeInt.h 39fb069ce04137545ca0bc790f80ddc64a8c99d9 F src/vdbeInt.h 39fb069ce04137545ca0bc790f80ddc64a8c99d9
F src/vdbeapi.c 81cb7f018e56c20b40365f005ff69e1af9ea9494 F src/vdbeapi.c bdd0aea216744482dd1b7fab56de18ba5b6fbdf4
F src/vdbeaux.c 8b41802973560274c15acdc1ac1d4147c110e8d7 F src/vdbeaux.c b040c3787ea1c32ba025b1c5822553469abe4efa
F src/vdbeblob.c d12ed95dac0992e1e372d079d76af047cc42f7c7 F src/vdbeblob.c d12ed95dac0992e1e372d079d76af047cc42f7c7
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6 F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 896fa3f8df9d2661eb15c7ce361857741b447268 F src/vdbemem.c 896fa3f8df9d2661eb15c7ce361857741b447268
F src/vtab.c 6a7ce44edf7ad824d7e9307394121fe943bb419c F src/vtab.c 72e5347cca4d55e55e180015f4dc78736f852e14
F src/where.c 2776a0caf8cbbfd6ec79cfb1cd9bc25074055e5e F src/where.c 2776a0caf8cbbfd6ec79cfb1cd9bc25074055e5e
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -238,7 +238,7 @@ F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
F test/descidx1.test 2177c4ad55edcf56ad5f4c6490f307d7774e8a10 F test/descidx1.test 2177c4ad55edcf56ad5f4c6490f307d7774e8a10
F test/descidx2.test eb3a2882ec58aa6e1e8131d9bb54436e5b4a3ce2 F test/descidx2.test eb3a2882ec58aa6e1e8131d9bb54436e5b4a3ce2
F test/descidx3.test 3a55b8d73bc3e9ad084e0da7fec781cf0d2a0356 F test/descidx3.test 3a55b8d73bc3e9ad084e0da7fec781cf0d2a0356
F test/diskfull.test a91fa95a8729b71fdac4738a49755f70b48c61f3 F test/diskfull.test 34ef53e88372c5b5e488ad1581514559a224c2b1
F test/distinctagg.test 2b89d1c5220d966a30ba4b40430338669301188b F test/distinctagg.test 2b89d1c5220d966a30ba4b40430338669301188b
F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
F test/enc2.test 45710bacfa9df29720bc84c067dfdf8c8ddfb797 F test/enc2.test 45710bacfa9df29720bc84c067dfdf8c8ddfb797
@@ -561,7 +561,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 6eb2d74a8cfce322930f05c97d4ec255f3711efb P 76f1e18ebc25d692f122784e87d202992c4cfed2
R 6c3888d041c9e4f3c4ea7193ec7eeec0 R 72f6a976f09cdaf5e13abeade770ec1c
U shess U drh
Z 0c8d40ad377805b9a794c415d7962113 Z 8bcbe7ef9d6a537a157463bef713e3c1

View File

@@ -1 +1 @@
76f1e18ebc25d692f122784e87d202992c4cfed2 3a68fcddfa9184e4b310ce0a21312c54b9462ec8

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give. ** May you share freely, never taking more than you give.
** **
************************************************************************* *************************************************************************
** $Id: btree.c,v 1.410 2007/08/23 02:47:53 drh Exp $ ** $Id: btree.c,v 1.411 2007/08/24 03:51:33 drh Exp $
** **
** This file implements a external (disk-based) database using BTrees. ** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information. ** See the header comment on "btreeInt.h" for additional information.
@@ -1102,13 +1102,6 @@ int sqlite3BtreeOpen(
int nReserve; int nReserve;
unsigned char zDbHeader[100]; unsigned char zDbHeader[100];
if( pSqlite ){
pVfs = pSqlite->pVfs;
}else{
pVfs = sqlite3_vfs_find(0);
}
assert( sqlite3BtreeMutexHeld(pSqlite->mutex) );
/* Set the variable isMemdb to true for an in-memory database, or /* Set the variable isMemdb to true for an in-memory database, or
** false for a file-based database. This symbol is only required if ** false for a file-based database. This symbol is only required if
** either of the shared-data or autovacuum features are compiled ** either of the shared-data or autovacuum features are compiled
@@ -1122,6 +1115,13 @@ int sqlite3BtreeOpen(
#endif #endif
#endif #endif
if( pSqlite ){
pVfs = pSqlite->pVfs;
}else{
pVfs = sqlite3_vfs_find(0);
}
assert( sqlite3BtreeMutexHeld(pSqlite->mutex) );
p = sqlite3MallocZero(sizeof(Btree)); p = sqlite3MallocZero(sizeof(Btree));
if( !p ){ if( !p ){
return SQLITE_NOMEM; return SQLITE_NOMEM;

View File

@@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope. ** All other code has file scope.
** **
** $Id: date.c,v 1.71 2007/08/21 19:33:56 drh Exp $ ** $Id: date.c,v 1.72 2007/08/24 03:51:33 drh Exp $
** **
** SQLite processes all times and dates as Julian Day numbers. The ** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon ** dates and times are stored as the number of days since noon
@@ -426,7 +426,7 @@ static double localtimeOffset(DateTime *p){
#else #else
{ {
struct tm *pTm; struct tm *pTm;
sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL)); sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
pTm = localtime(&t); pTm = localtime(&t);
y.Y = pTm->tm_year + 1900; y.Y = pTm->tm_year + 1900;
y.M = pTm->tm_mon + 1; y.M = pTm->tm_mon + 1;
@@ -434,7 +434,7 @@ static double localtimeOffset(DateTime *p){
y.h = pTm->tm_hour; y.h = pTm->tm_hour;
y.m = pTm->tm_min; y.m = pTm->tm_min;
y.s = pTm->tm_sec; y.s = pTm->tm_sec;
sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL)); sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
} }
#endif #endif
y.validYMD = 1; y.validYMD = 1;

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.396 2007/08/22 20:18:22 drh Exp $ ** $Id: main.c,v 1.397 2007/08/24 03:51:34 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -945,15 +945,16 @@ static int openDatabase(
if( db==0 ) goto opendb_out; if( db==0 ) goto opendb_out;
db->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE); db->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);
if( db->mutex==0 ){ if( db->mutex==0 ){
db->mallocFailed = 1; sqlite3_free(db);
db = 0;
goto opendb_out; goto opendb_out;
} }
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
db->pVfs = sqlite3_vfs_find(zVfs); db->pVfs = sqlite3_vfs_find(zVfs);
db->errMask = 0xff; db->errMask = 0xff;
db->priorNewRowid = 0; db->priorNewRowid = 0;
db->magic = SQLITE_MAGIC_BUSY;
db->nDb = 2; db->nDb = 2;
db->magic = SQLITE_MAGIC_BUSY;
db->aDb = db->aDbStatic; db->aDb = db->aDbStatic;
db->autoCommit = 1; db->autoCommit = 1;
db->flags |= SQLITE_ShortColNames db->flags |= SQLITE_ShortColNames
@@ -1076,7 +1077,7 @@ static int openDatabase(
#endif #endif
opendb_out: opendb_out:
if( db ){ if( db && db->mutex ){
sqlite3_mutex_leave(db->mutex); sqlite3_mutex_leave(db->mutex);
} }
if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){ if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){

View File

@@ -12,7 +12,7 @@
** Memory allocation functions used throughout sqlite. ** Memory allocation functions used throughout sqlite.
** **
** **
** $Id: malloc.c,v 1.10 2007/08/22 20:18:22 drh Exp $ ** $Id: malloc.c,v 1.11 2007/08/24 03:51:34 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <stdarg.h> #include <stdarg.h>
@@ -25,8 +25,8 @@
*/ */
static void softHeapLimitEnforcer( static void softHeapLimitEnforcer(
void *NotUsed, void *NotUsed,
sqlite3_uint64 inUse, sqlite3_int64 inUse,
unsigned int allocSize int allocSize
){ ){
sqlite3_release_memory(allocSize); sqlite3_release_memory(allocSize);
} }

View File

@@ -12,7 +12,7 @@
** This file contains the C functions that implement a memory ** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite. ** allocation subsystem for use by SQLite.
** **
** $Id: mem1.c,v 1.7 2007/08/22 20:18:22 drh Exp $ ** $Id: mem1.c,v 1.8 2007/08/24 03:51:34 drh Exp $
*/ */
/* /*
@@ -51,8 +51,8 @@ static struct {
** issued. The alarmBusy variable is set to prevent recursive ** issued. The alarmBusy variable is set to prevent recursive
** callbacks. ** callbacks.
*/ */
sqlite3_uint64 alarmThreshold; sqlite3_int64 alarmThreshold;
void (*alarmCallback)(void*, sqlite3_uint64, unsigned); void (*alarmCallback)(void*, sqlite3_int64,int);
void *alarmArg; void *alarmArg;
int alarmBusy; int alarmBusy;
@@ -64,22 +64,18 @@ static struct {
/* /*
** Current allocation and high-water mark. ** Current allocation and high-water mark.
*/ */
sqlite3_uint64 nowUsed; sqlite3_int64 nowUsed;
sqlite3_uint64 mxUsed; sqlite3_int64 mxUsed;
} mem = { /* This variable holds all of the local data */ } mem;
((sqlite3_uint64)1)<<63, /* alarmThreshold */
/* Everything else is initialized to zero */
};
/* /*
** Return the amount of memory currently checked out. ** Return the amount of memory currently checked out.
*/ */
sqlite3_uint64 sqlite3_memory_used(void){ sqlite3_int64 sqlite3_memory_used(void){
sqlite3_uint64 n; sqlite3_int64 n;
if( mem.mutex==0 ){ if( mem.mutex==0 ){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
} }
@@ -94,8 +90,8 @@ sqlite3_uint64 sqlite3_memory_used(void){
** checked out since either the beginning of this process ** checked out since either the beginning of this process
** or since the most recent reset. ** or since the most recent reset.
*/ */
sqlite3_uint64 sqlite3_memory_highwater(int resetFlag){ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
sqlite3_uint64 n; sqlite3_int64 n;
if( mem.mutex==0 ){ if( mem.mutex==0 ){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
} }
@@ -112,9 +108,9 @@ sqlite3_uint64 sqlite3_memory_highwater(int resetFlag){
** Change the alarm callback ** Change the alarm callback
*/ */
int sqlite3_memory_alarm( int sqlite3_memory_alarm(
void(*xCallback)(void *pArg, sqlite3_uint64 used, unsigned int N), void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
void *pArg, void *pArg,
sqlite3_uint64 iThreshold sqlite3_int64 iThreshold
){ ){
if( mem.mutex==0 ){ if( mem.mutex==0 ){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
@@ -130,9 +126,9 @@ int sqlite3_memory_alarm(
/* /*
** Trigger the alarm ** Trigger the alarm
*/ */
static void sqlite3MemsysAlarm(unsigned nByte){ static void sqlite3MemsysAlarm(int nByte){
void (*xCallback)(void*,sqlite3_uint64,unsigned); void (*xCallback)(void*,sqlite3_int64,int);
sqlite3_uint64 nowUsed; sqlite3_int64 nowUsed;
void *pArg; void *pArg;
if( mem.alarmCallback==0 || mem.alarmBusy ) return; if( mem.alarmCallback==0 || mem.alarmBusy ) return;
mem.alarmBusy = 1; mem.alarmBusy = 1;
@@ -149,7 +145,7 @@ static void sqlite3MemsysAlarm(unsigned nByte){
** Allocate nBytes of memory ** Allocate nBytes of memory
*/ */
void *sqlite3_malloc(int nBytes){ void *sqlite3_malloc(int nBytes){
sqlite3_uint64 *p; sqlite3_int64 *p;
if( nBytes<=0 ){ if( nBytes<=0 ){
return 0; return 0;
} }
@@ -157,7 +153,7 @@ void *sqlite3_malloc(int nBytes){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
} }
sqlite3_mutex_enter(mem.mutex); sqlite3_mutex_enter(mem.mutex);
if( mem.nowUsed+nBytes>=mem.alarmThreshold ){ if( mem.alarmCallback!=0 && mem.nowUsed+nBytes>=mem.alarmThreshold ){
sqlite3MemsysAlarm(nBytes); sqlite3MemsysAlarm(nBytes);
} }
p = malloc(nBytes+8); p = malloc(nBytes+8);
@@ -181,15 +177,15 @@ void *sqlite3_malloc(int nBytes){
** Free memory. ** Free memory.
*/ */
void sqlite3_free(void *pPrior){ void sqlite3_free(void *pPrior){
sqlite3_uint64 *p; sqlite3_int64 *p;
unsigned nByte; int nByte;
if( pPrior==0 ){ if( pPrior==0 ){
return; return;
} }
assert( mem.mutex!=0 ); assert( mem.mutex!=0 );
p = pPrior; p = pPrior;
p--; p--;
nByte = (unsigned int)*p; nByte = (int)*p;
sqlite3_mutex_enter(mem.mutex); sqlite3_mutex_enter(mem.mutex);
mem.nowUsed -= nByte; mem.nowUsed -= nByte;
free(p); free(p);
@@ -200,8 +196,8 @@ void sqlite3_free(void *pPrior){
** Change the size of an existing memory allocation ** Change the size of an existing memory allocation
*/ */
void *sqlite3_realloc(void *pPrior, int nBytes){ void *sqlite3_realloc(void *pPrior, int nBytes){
unsigned nOld; int nOld;
sqlite3_uint64 *p; sqlite3_int64 *p;
if( pPrior==0 ){ if( pPrior==0 ){
return sqlite3_malloc(nBytes); return sqlite3_malloc(nBytes);
} }
@@ -211,7 +207,7 @@ void *sqlite3_realloc(void *pPrior, int nBytes){
} }
p = pPrior; p = pPrior;
p--; p--;
nOld = (unsigned int)p[0]; nOld = (int)p[0];
assert( mem.mutex!=0 ); assert( mem.mutex!=0 );
sqlite3_mutex_enter(mem.mutex); sqlite3_mutex_enter(mem.mutex);
if( mem.nowUsed+nBytes-nOld>=mem.alarmThreshold ){ if( mem.nowUsed+nBytes-nOld>=mem.alarmThreshold ){

View File

@@ -12,7 +12,7 @@
** This file contains the C functions that implement a memory ** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite. ** allocation subsystem for use by SQLite.
** **
** $Id: mem2.c,v 1.8 2007/08/23 02:47:53 drh Exp $ ** $Id: mem2.c,v 1.9 2007/08/24 03:51:34 drh Exp $
*/ */
/* /*
@@ -71,11 +71,11 @@
*/ */
struct MemBlockHdr { struct MemBlockHdr {
struct MemBlockHdr *pNext, *pPrev; /* Linked list of all unfreed memory */ struct MemBlockHdr *pNext, *pPrev; /* Linked list of all unfreed memory */
unsigned int iSize; /* Size of this allocation */ int iSize; /* Size of this allocation */
unsigned char nBacktrace; /* Number of backtraces on this alloc */ char nBacktrace; /* Number of backtraces on this alloc */
unsigned char nBacktraceSlots; /* Available backtrace slots */ char nBacktraceSlots; /* Available backtrace slots */
unsigned short nTitle; /* Bytes of title; includes '\0' */ short nTitle; /* Bytes of title; includes '\0' */
unsigned int iForeGuard; /* Guard word for sanity */ int iForeGuard; /* Guard word for sanity */
}; };
/* /*
@@ -98,8 +98,8 @@ static struct {
** issued. The alarmBusy variable is set to prevent recursive ** issued. The alarmBusy variable is set to prevent recursive
** callbacks. ** callbacks.
*/ */
sqlite3_uint64 alarmThreshold; sqlite3_int64 alarmThreshold;
void (*alarmCallback)(void*, sqlite3_uint64, unsigned); void (*alarmCallback)(void*, sqlite3_int64, int);
void *alarmArg; void *alarmArg;
int alarmBusy; int alarmBusy;
@@ -111,8 +111,8 @@ static struct {
/* /*
** Current allocation and high-water mark. ** Current allocation and high-water mark.
*/ */
sqlite3_uint64 nowUsed; sqlite3_int64 nowUsed;
sqlite3_uint64 mxUsed; sqlite3_int64 mxUsed;
/* /*
** Head and tail of a linked list of all outstanding allocations ** Head and tail of a linked list of all outstanding allocations
@@ -147,18 +147,14 @@ static struct {
int disallow; /* Do not allow memory allocation */ int disallow; /* Do not allow memory allocation */
} mem = { /* This variable holds all of the local data */ } mem;
((sqlite3_uint64)1)<<63, /* alarmThreshold */
/* Everything else is initialized to zero */
};
/* /*
** Return the amount of memory currently checked out. ** Return the amount of memory currently checked out.
*/ */
sqlite3_uint64 sqlite3_memory_used(void){ sqlite3_int64 sqlite3_memory_used(void){
sqlite3_uint64 n; sqlite3_int64 n;
if( mem.mutex==0 ){ if( mem.mutex==0 ){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
} }
@@ -173,8 +169,8 @@ sqlite3_uint64 sqlite3_memory_used(void){
** checked out since either the beginning of this process ** checked out since either the beginning of this process
** or since the most recent reset. ** or since the most recent reset.
*/ */
sqlite3_uint64 sqlite3_memory_highwater(int resetFlag){ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
sqlite3_uint64 n; sqlite3_int64 n;
if( mem.mutex==0 ){ if( mem.mutex==0 ){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
} }
@@ -191,9 +187,9 @@ sqlite3_uint64 sqlite3_memory_highwater(int resetFlag){
** Change the alarm callback ** Change the alarm callback
*/ */
int sqlite3_memory_alarm( int sqlite3_memory_alarm(
void(*xCallback)(void *pArg, sqlite3_uint64 used, unsigned int N), void(*xCallback)(void *pArg, sqlite3_int64 used, int N),
void *pArg, void *pArg,
sqlite3_uint64 iThreshold sqlite3_int64 iThreshold
){ ){
if( mem.mutex==0 ){ if( mem.mutex==0 ){
mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
@@ -209,9 +205,9 @@ int sqlite3_memory_alarm(
/* /*
** Trigger the alarm ** Trigger the alarm
*/ */
static void sqlite3MemsysAlarm(unsigned nByte){ static void sqlite3MemsysAlarm(int nByte){
void (*xCallback)(void*,sqlite3_uint64,unsigned); void (*xCallback)(void*,sqlite3_int64,int);
sqlite3_uint64 nowUsed; sqlite3_int64 nowUsed;
void *pArg; void *pArg;
if( mem.alarmCallback==0 || mem.alarmBusy ) return; if( mem.alarmCallback==0 || mem.alarmBusy ) return;
mem.alarmBusy = 1; mem.alarmBusy = 1;
@@ -232,14 +228,14 @@ static void sqlite3MemsysAlarm(unsigned nByte){
*/ */
static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){
struct MemBlockHdr *p; struct MemBlockHdr *p;
unsigned int *pInt; int *pInt;
p = (struct MemBlockHdr*)pAllocation; p = (struct MemBlockHdr*)pAllocation;
p--; p--;
assert( p->iForeGuard==FOREGUARD ); assert( p->iForeGuard==FOREGUARD );
assert( (p->iSize & 3)==0 ); assert( (p->iSize & 3)==0 );
pInt = (unsigned int*)pAllocation; pInt = (int*)pAllocation;
assert( pInt[p->iSize/sizeof(unsigned int)]==REARGUARD ); assert( pInt[p->iSize/sizeof(int)]==REARGUARD );
return p; return p;
} }
@@ -260,9 +256,9 @@ void *sqlite3_malloc(int nByte){
struct MemBlockHdr *pHdr; struct MemBlockHdr *pHdr;
void **pBt; void **pBt;
char *z; char *z;
unsigned int *pInt; int *pInt;
void *p; void *p;
unsigned int totalSize; int totalSize;
if( nByte<=0 ){ if( nByte<=0 ){
return 0; return 0;
@@ -272,11 +268,11 @@ void *sqlite3_malloc(int nByte){
} }
sqlite3_mutex_enter(mem.mutex); sqlite3_mutex_enter(mem.mutex);
assert( mem.disallow==0 ); assert( mem.disallow==0 );
if( mem.nowUsed+nByte>=mem.alarmThreshold ){ if( mem.alarmCallback!=0 && mem.nowUsed+nByte>=mem.alarmThreshold ){
sqlite3MemsysAlarm(nByte); sqlite3MemsysAlarm(nByte);
} }
nByte = (nByte+3)&~3; nByte = (nByte+3)&~3;
totalSize = nByte + sizeof(*pHdr) + sizeof(unsigned int) + totalSize = nByte + sizeof(*pHdr) + sizeof(int) +
mem.nBacktrace*sizeof(void*) + mem.nTitle; mem.nBacktrace*sizeof(void*) + mem.nTitle;
if( mem.iFail>0 ){ if( mem.iFail>0 ){
if( mem.iFail==1 ){ if( mem.iFail==1 ){
@@ -323,8 +319,8 @@ void *sqlite3_malloc(int nByte){
memcpy(z, mem.zTitle, mem.nTitle); memcpy(z, mem.zTitle, mem.nTitle);
} }
pHdr->iSize = nByte; pHdr->iSize = nByte;
pInt = (unsigned int *)&pHdr[1]; pInt = (int*)&pHdr[1];
pInt[nByte/sizeof(unsigned int)] = REARGUARD; pInt[nByte/sizeof(int)] = REARGUARD;
memset(pInt, 0x65, nByte); memset(pInt, 0x65, nByte);
mem.nowUsed += nByte; mem.nowUsed += nByte;
if( mem.nowUsed>mem.mxUsed ){ if( mem.nowUsed>mem.mxUsed ){
@@ -369,7 +365,7 @@ void sqlite3_free(void *pPrior){
z = (char*)pBt; z = (char*)pBt;
z -= pHdr->nTitle; z -= pHdr->nTitle;
memset(z, 0x2b, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) + memset(z, 0x2b, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +
pHdr->iSize + sizeof(unsigned int) + pHdr->nTitle); pHdr->iSize + sizeof(int) + pHdr->nTitle);
free(z); free(z);
sqlite3_mutex_leave(mem.mutex); sqlite3_mutex_leave(mem.mutex);
} }
@@ -488,15 +484,6 @@ int sqlite3_memdebug_fail(int iFail, int iRepeat){
return n; return n;
} }
/*
** This routine returns the number of successful mallocs remaining until
** the next simulated malloc failure. -1 is returned if no simulated
** failure is currently scheduled.
*/
int sqlite3_memdebug_pending(void){
return mem.iFail-1;
}
/* /*
** The following two routines are used to assert that no memory ** The following two routines are used to assert that no memory
** allocations occur between one call and the next. The use of ** allocations occur between one call and the next. The use of

View File

@@ -110,40 +110,40 @@ int sqlite3OsOpen(
int flags, int flags,
int *pFlagsOut int *pFlagsOut
){ ){
return pVfs->xOpen(pVfs->pAppData, zPath, pFile, flags, pFlagsOut); return pVfs->xOpen(pVfs, zPath, pFile, flags, pFlagsOut);
} }
int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
return pVfs->xDelete(pVfs->pAppData, zPath, dirSync); return pVfs->xDelete(pVfs, zPath, dirSync);
} }
int sqlite3OsAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){ int sqlite3OsAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){
return pVfs->xAccess(pVfs->pAppData, zPath, flags); return pVfs->xAccess(pVfs, zPath, flags);
} }
int sqlite3OsGetTempName(sqlite3_vfs *pVfs, char *zBufOut){ int sqlite3OsGetTempName(sqlite3_vfs *pVfs, char *zBufOut){
return pVfs->xGetTempName(pVfs->pAppData, zBufOut); return pVfs->xGetTempName(pVfs, zBufOut);
} }
int sqlite3OsFullPathname(sqlite3_vfs *pVfs, const char *zPath, char *zPathOut){ int sqlite3OsFullPathname(sqlite3_vfs *pVfs, const char *zPath, char *zPathOut){
return pVfs->xFullPathname(pVfs->pAppData, zPath, zPathOut); return pVfs->xFullPathname(pVfs, zPath, zPathOut);
} }
void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){ void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
return pVfs->xDlOpen(pVfs->pAppData, zPath); return pVfs->xDlOpen(pVfs, zPath);
} }
void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
pVfs->xDlError(pVfs->pAppData, nByte, zBufOut); pVfs->xDlError(pVfs, nByte, zBufOut);
} }
void *sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){ void *sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){
return pVfs->xDlSym(pHandle, zSymbol); return pVfs->xDlSym(pVfs, pHandle, zSymbol);
} }
void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){ void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){
pVfs->xDlClose(pHandle); pVfs->xDlClose(pVfs, pHandle);
} }
int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
return pVfs->xRandomness(pVfs->pAppData, nByte, zBufOut); return pVfs->xRandomness(pVfs, nByte, zBufOut);
} }
int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){ int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){
return pVfs->xSleep(pVfs->pAppData, nMicro); return pVfs->xSleep(pVfs, nMicro);
} }
int sqlite3OsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ int sqlite3OsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){
return pVfs->xCurrentTime(pVfs->pAppData, pTimeOut); return pVfs->xCurrentTime(pVfs, pTimeOut);
} }
int sqlite3OsOpenMalloc( int sqlite3OsOpenMalloc(
@@ -176,14 +176,11 @@ int sqlite3OsCloseFree(sqlite3_file *pFile){
} }
/* /*
** Default vfs implementation. Defined by the various os_X.c implementations. ** The list of all registered VFS implementations. This list is
** initialized to the single VFS returned by sqlite3OsDefaultVfs()
** upon the first call to sqlite3_vfs_find().
*/ */
extern sqlite3_vfs sqlite3DefaultVfs; static sqlite3_vfs *vfsList = 0;
/*
** The list of all registered VFS implementations.
*/
static sqlite3_vfs *vfsList = &sqlite3DefaultVfs;
/* /*
** Locate a VFS by name. If no name is given, simply return the ** Locate a VFS by name. If no name is given, simply return the
@@ -192,7 +189,12 @@ static sqlite3_vfs *vfsList = &sqlite3DefaultVfs;
sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){ sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_vfs *pVfs; sqlite3_vfs *pVfs;
static int isInit = 0;
sqlite3_mutex_enter(mutex); sqlite3_mutex_enter(mutex);
if( !isInit ){
vfsList = sqlite3OsDefaultVfs();
isInit = 1;
}
for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){ for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){
if( zVfs==0 ) break; if( zVfs==0 ) break;
if( strcmp(zVfs, pVfs->zName)==0 ) break; if( strcmp(zVfs, pVfs->zName)==0 ) break;
@@ -217,7 +219,7 @@ int sqlite3_vfs_release(sqlite3_vfs *pVfs){
sqlite3_mutex_enter(mutex); sqlite3_mutex_enter(mutex);
assert( pVfs->nRef>0 ); assert( pVfs->nRef>0 );
pVfs->nRef--; pVfs->nRef--;
if( pVfs->nRef==0 ){ if( pVfs->nRef==0 && pVfs->vfsMutex ){
sqlite3_mutex_free(pVfs->vfsMutex); sqlite3_mutex_free(pVfs->vfsMutex);
pVfs->vfsMutex = 0; pVfs->vfsMutex = 0;
} }

View File

@@ -109,7 +109,7 @@
** If sqlite is being embedded in another program, you may wish to change the ** If sqlite is being embedded in another program, you may wish to change the
** prefix to reflect your program's name, so that if your program exits ** prefix to reflect your program's name, so that if your program exits
** prematurely, old temporary files can be easily identified. This can be done ** prematurely, old temporary files can be easily identified. This can be done
** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line. ** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line.
** **
** 2006-10-31: The default prefix used to be "sqlite_". But then ** 2006-10-31: The default prefix used to be "sqlite_". But then
** Mcafee started using SQLite in their anti-virus product and it ** Mcafee started using SQLite in their anti-virus product and it
@@ -123,8 +123,8 @@
** enough to know that calling the developer will not help get rid ** enough to know that calling the developer will not help get rid
** of the file. ** of the file.
*/ */
#ifndef TEMP_FILE_PREFIX #ifndef SQLITE_TEMP_FILE_PREFIX
# define TEMP_FILE_PREFIX "etilqs_" # define SQLITE_TEMP_FILE_PREFIX "etilqs_"
#endif #endif
/* /*
@@ -273,4 +273,18 @@ int sqlite3OsCloseFree(sqlite3_file *);
int sqlite3OsLockState(sqlite3_file *id); int sqlite3OsLockState(sqlite3_file *id);
#endif #endif
/*
** Each OS-specific backend defines an instance of the following
** structure for returning a pointer to its sqlite3_vfs. If OS_OTHER
** is defined (meaning that the application-defined OS interface layer
** is used) then there is no default VFS. The application must
** register one or more VFS structures using sqlite3_vfs_register()
** before attempting to use SQLite.
*/
#if OS_UNIX || OS_WIN || OS_OS2
sqlite3_vfs *sqlite3OsDefaultVfs(void);
#else
# define sqlite3OsDefaultVfs(X) 0
#endif
#endif /* _SQLITE_OS_H_ */ #endif /* _SQLITE_OS_H_ */

View File

@@ -108,13 +108,6 @@ struct unixFile {
*/ */
#include "os_common.h" #include "os_common.h"
/*
** Do not include any of the File I/O interface procedures if the
** SQLITE_OMIT_DISKIO macro is defined (indicating that the database
** will be in-memory only)
*/
#ifndef SQLITE_OMIT_DISKIO
/* /*
** Define various macros that are missing from some systems. ** Define various macros that are missing from some systems.
*/ */
@@ -2300,12 +2293,6 @@ static int fillInUnixFile(
} }
#endif /* SQLITE_ENABLE_LOCKING_STYLE */ #endif /* SQLITE_ENABLE_LOCKING_STYLE */
#endif /* SQLITE_OMIT_DISKIO */
/***************************************************************************
** Everything above deals with file I/O. Everything that follows deals
** with other miscellanous aspects of the operating system interface
****************************************************************************/
/* /*
** Open a file descriptor to the directory containing file zFilename. ** Open a file descriptor to the directory containing file zFilename.
** If successful, *pFd is set to the opened file descriptor and ** If successful, *pFd is set to the opened file descriptor and
@@ -2321,8 +2308,7 @@ static int openDirectory(const char *zFilename, int *pFd){
int fd; int fd;
char zDirname[MAX_PATHNAME+1]; char zDirname[MAX_PATHNAME+1];
strncpy(zDirname, zFilename, MAX_PATHNAME); sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
zDirname[MAX_PATHNAME-1] = '\0';
for(ii=strlen(zDirname); ii>=0 && zDirname[ii]!='/'; ii--); for(ii=strlen(zDirname); ii>=0 && zDirname[ii]!='/'; ii--);
if( ii>0 ){ if( ii>0 ){
zDirname[ii] = '\0'; zDirname[ii] = '\0';
@@ -2361,7 +2347,7 @@ static int openDirectory(const char *zFilename, int *pFd){
** OpenExclusive(). ** OpenExclusive().
*/ */
static int unixOpen( static int unixOpen(
void *pNotUsed, sqlite3_vfs *pVfs,
const char *zPath, const char *zPath,
sqlite3_file *pFile, sqlite3_file *pFile,
int flags, int flags,
@@ -2414,7 +2400,7 @@ static int unixOpen(
/* Failed to open the file for read/write access. Try read-only. */ /* Failed to open the file for read/write access. Try read-only. */
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
flags |= SQLITE_OPEN_READONLY; flags |= SQLITE_OPEN_READONLY;
return unixOpen(pNotUsed, zPath, pFile, flags, pOutFlags); return unixOpen(pVfs, zPath, pFile, flags, pOutFlags);
} }
if( fd<0 ){ if( fd<0 ){
return SQLITE_CANTOPEN; return SQLITE_CANTOPEN;
@@ -2441,7 +2427,7 @@ static int unixOpen(
** Delete the file at zPath. If the dirSync argument is true, fsync() ** Delete the file at zPath. If the dirSync argument is true, fsync()
** the directory after deleting the file. ** the directory after deleting the file.
*/ */
static int unixDelete(void *pNotUsed, const char *zPath, int dirSync){ static int unixDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
int rc = SQLITE_OK; int rc = SQLITE_OK;
SimulateIOError(return SQLITE_IOERR_DELETE); SimulateIOError(return SQLITE_IOERR_DELETE);
unlink(zPath); unlink(zPath);
@@ -2468,7 +2454,7 @@ static int unixDelete(void *pNotUsed, const char *zPath, int dirSync){
** **
** Otherwise return 0. ** Otherwise return 0.
*/ */
static int unixAccess(void *pNotUsed, const char *zPath, int flags){ static int unixAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){
int amode; int amode;
switch( flags ){ switch( flags ){
case SQLITE_ACCESS_EXISTS: case SQLITE_ACCESS_EXISTS:
@@ -2488,10 +2474,11 @@ static int unixAccess(void *pNotUsed, const char *zPath, int flags){
} }
/* /*
** Create a temporary file name in zBuf. zBuf must be big enough to ** Create a temporary file name in zBuf. zBuf must be allocated
** hold at least MAX_PATHNAME characters. ** by the calling process and must be big enough to hold at least
** pVfs->mxPathname bytes.
*/ */
static int unixGetTempName(void *pNotUsed, char *zBuf){ static int unixGetTempName(sqlite3_vfs *pVfs, char *zBuf){
static const char *azDirs[] = { static const char *azDirs[] = {
0, 0,
"/var/tmp", "/var/tmp",
@@ -2516,7 +2503,8 @@ static int unixGetTempName(void *pNotUsed, char *zBuf){
break; break;
} }
do{ do{
sqlite3_snprintf(MAX_PATHNAME-17, zBuf, "%s/"TEMP_FILE_PREFIX, zDir); assert( pVfs->mxPathname==MAX_PATHNAME );
sqlite3_snprintf(MAX_PATHNAME-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
j = strlen(zBuf); j = strlen(zBuf);
sqlite3Randomness(15, &zBuf[j]); sqlite3Randomness(15, &zBuf[j]);
for(i=0; i<15; i++, j++){ for(i=0; i<15; i++, j++){
@@ -2537,18 +2525,18 @@ static int unixGetTempName(void *pNotUsed, char *zBuf){
** (in this case, MAX_PATHNAME bytes). The full-path is written to ** (in this case, MAX_PATHNAME bytes). The full-path is written to
** this buffer before returning. ** this buffer before returning.
*/ */
static int unixFullPathname(void *pNotUsed, const char *zPath, char *zOut){ static int unixFullPathname(sqlite3_vfs *pVfs, const char *zPath, char *zOut){
assert( pVfs->mxPathname==MAX_PATHNAME );
zOut[MAX_PATHNAME-1] = '\0'; zOut[MAX_PATHNAME-1] = '\0';
if( zPath[0]=='/' ){ if( zPath[0]=='/' ){
strncpy(zOut, zPath, MAX_PATHNAME-1); sqlite3_snprintf(MAX_PATHNAME, zOut, "%s", zPath);
}else{ }else{
int nCwd; int nCwd;
if( getcwd(zOut, MAX_PATHNAME-1)==0 ){ if( getcwd(zOut, MAX_PATHNAME-1)==0 ){
return SQLITE_ERROR; return SQLITE_ERROR;
} }
nCwd = strlen(zOut); nCwd = strlen(zOut);
zOut[nCwd] = '/'; sqlite3_snprintf(MAX_PATHNAME-nCwd, &zOut[nCwd], "/%s", zPath);
strncpy(&zOut[nCwd+1], zPath, MAX_PATHNAME-1-nCwd-1);
} }
return SQLITE_OK; return SQLITE_OK;
@@ -2586,25 +2574,24 @@ static int unixFullPathname(void *pNotUsed, const char *zPath, char *zOut){
** within the shared library, and closing the shared library. ** within the shared library, and closing the shared library.
*/ */
#include <dlfcn.h> #include <dlfcn.h>
static void *unixDlOpen(void *pNotUsed, const char *zFilename){ static void *unixDlOpen(sqlite3_vfs *pVfs, const char *zFilename){
return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL); return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL);
} }
static void unixDlError(void *pNotUsed, int nBuf, char *zBufOut){ static void unixDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){
char *zErr; char *zErr;
enterMutex(); enterMutex();
zErr = dlerror(); zErr = dlerror();
if( zErr ){ if( zErr ){
strncpy(zBufOut, zErr, nBuf-1); sqlite3_snprintf(nBuf, zBufOut, "%s", zErr);
zBufOut[nBuf-1] = '\0';
}else if(nBuf>0) { }else if(nBuf>0) {
zBufOut[0] = '\0'; zBufOut[0] = '\0';
} }
leaveMutex(); leaveMutex();
} }
void *unixDlSym(void *pHandle, const char *zSymbol){ void *unixDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){
return dlsym(pHandle, zSymbol); return dlsym(pHandle, zSymbol);
} }
void unixDlClose(void *pHandle){ void unixDlClose(sqlite3_vfs *pVfs, void *pHandle){
dlclose(pHandle); dlclose(pHandle);
} }
#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */ #else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */
@@ -2617,7 +2604,7 @@ void unixDlClose(void *pHandle){
/* /*
** Write nBuf bytes of random data to the supplied buffer zBuf. ** Write nBuf bytes of random data to the supplied buffer zBuf.
*/ */
static int unixRandomness(void *pNotUsed, int nBuf, char *zBuf){ static int unixRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
assert(nBuf>=(sizeof(time_t)+sizeof(int))); assert(nBuf>=(sizeof(time_t)+sizeof(int)));
@@ -2662,7 +2649,7 @@ static int unixRandomness(void *pNotUsed, int nBuf, char *zBuf){
** might be greater than or equal to the argument, but not less ** might be greater than or equal to the argument, but not less
** than the argument. ** than the argument.
*/ */
static int unixSleep(void *pNotUsed, int microseconds){ static int unixSleep(sqlite3_vfs *pVfs, int microseconds){
#if defined(HAVE_USLEEP) && HAVE_USLEEP #if defined(HAVE_USLEEP) && HAVE_USLEEP
usleep(microseconds); usleep(microseconds);
return microseconds; return microseconds;
@@ -2686,7 +2673,7 @@ int sqlite3_current_time = 0;
** current time and date as a Julian Day number into *prNow and ** current time and date as a Julian Day number into *prNow and
** return 0. Return 1 if the time and date cannot be found. ** return 0. Return 1 if the time and date cannot be found.
*/ */
static int unixCurrentTime(void *pNotUsed, double *prNow){ static int unixCurrentTime(sqlite3_vfs *pVfs, double *prNow){
#ifdef NO_GETTOD #ifdef NO_GETTOD
time_t t; time_t t;
time(&t); time(&t);
@@ -2704,8 +2691,14 @@ static int unixCurrentTime(void *pNotUsed, double *prNow){
return 0; return 0;
} }
/*
sqlite3_vfs sqlite3DefaultVfs = { ** Return a pointer to the sqlite3DefaultVfs structure. We use
** a function rather than give the structure global scope because
** some compilers (MSVC) do not allow forward declarations of
** initialized structures.
*/
sqlite3_vfs *sqlite3OsDefaultVfs(void){
static sqlite3_vfs unixVfs = {
1, /* iVersion */ 1, /* iVersion */
sizeof(unixFile), /* szOsFile */ sizeof(unixFile), /* szOsFile */
MAX_PATHNAME, /* mxPathname */ MAX_PATHNAME, /* mxPathname */
@@ -2729,4 +2722,7 @@ sqlite3_vfs sqlite3DefaultVfs = {
unixCurrentTime /* xCurrentTime */ unixCurrentTime /* xCurrentTime */
}; };
return &unixVfs;
}
#endif /* OS_UNIX */ #endif /* OS_UNIX */

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while ** file simultaneously, or one process from reading the database while
** another is writing. ** another is writing.
** **
** @(#) $Id: pager.c,v 1.371 2007/08/23 14:48:24 danielk1977 Exp $ ** @(#) $Id: pager.c,v 1.372 2007/08/24 03:51:34 drh Exp $
*/ */
#ifndef SQLITE_OMIT_DISKIO #ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -1873,7 +1873,6 @@ int sqlite3PagerOpen(
){ ){
u8 *pPtr; u8 *pPtr;
Pager *pPager = 0; Pager *pPager = 0;
char *zFullPathname = 0;
int rc = SQLITE_OK; int rc = SQLITE_OK;
int i; int i;
int tempFile = 0; int tempFile = 0;
@@ -1905,8 +1904,7 @@ int sqlite3PagerOpen(
pPager->zJournal = &pPager->zDirectory[pVfs->mxPathname]; pPager->zJournal = &pPager->zDirectory[pVfs->mxPathname];
pPager->pVfs = pVfs; pPager->pVfs = pVfs;
/* Open the pager file and set zFullPathname to point at malloc()ed /* Open the pager file.
** memory containing the complete filename (i.e. including the directory).
*/ */
if( zFilename && zFilename[0] ){ if( zFilename && zFilename[0] ){
#ifndef SQLITE_OMIT_MEMORYDB #ifndef SQLITE_OMIT_MEMORYDB
@@ -1942,9 +1940,9 @@ int sqlite3PagerOpen(
pPager->pTmpSpace = (char *)sqlite3_malloc(SQLITE_DEFAULT_PAGE_SIZE); pPager->pTmpSpace = (char *)sqlite3_malloc(SQLITE_DEFAULT_PAGE_SIZE);
} }
/* If an error occured in either of the blocks above, free the memory /* If an error occured in either of the blocks above.
** pointed to by zFullPathname, free the Pager structure and close the ** Free the Pager structure and close the file.
** file. Since the pager is not allocated there is no need to set ** Since the pager is not allocated there is no need to set
** any Pager.errMask variables. ** any Pager.errMask variables.
*/ */
if( !pPager || !pPager->pTmpSpace ){ if( !pPager || !pPager->pTmpSpace ){
@@ -1953,8 +1951,8 @@ int sqlite3PagerOpen(
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc); return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
} }
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), zFullPathname); PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename);
IOTRACE(("OPEN %p %s\n", pPager, zFullPathname)) IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename))
/* Fill in Pager.zDirectory[] */ /* Fill in Pager.zDirectory[] */
memcpy(pPager->zDirectory, pPager->zFilename, pVfs->mxPathname); memcpy(pPager->zDirectory, pPager->zFilename, pVfs->mxPathname);
@@ -2682,6 +2680,7 @@ static PgHdr *sort_pagelist(PgHdr *pIn){
*/ */
static int pager_write_pagelist(PgHdr *pList){ static int pager_write_pagelist(PgHdr *pList){
Pager *pPager; Pager *pPager;
PgHdr *p;
int rc; int rc;
if( pList==0 ) return SQLITE_OK; if( pList==0 ) return SQLITE_OK;
@@ -2709,6 +2708,10 @@ static int pager_write_pagelist(PgHdr *pList){
} }
pList = sort_pagelist(pList); pList = sort_pagelist(pList);
for(p=pList; p; p=p->pDirty){
assert( p->dirty );
p->dirty = 0;
}
while( pList ){ while( pList ){
/* If the file has not yet been opened, open it now. */ /* If the file has not yet been opened, open it now. */
@@ -2718,7 +2721,6 @@ static int pager_write_pagelist(PgHdr *pList){
if( rc ) return rc; if( rc ) return rc;
} }
assert( pList->dirty );
/* If there are dirty pages in the page cache with page numbers greater /* If there are dirty pages in the page cache with page numbers greater
** than Pager.dbSize, this means sqlite3PagerTruncate() was called to ** than Pager.dbSize, this means sqlite3PagerTruncate() was called to
** make the file smaller (presumably by auto-vacuum code). Do not write ** make the file smaller (presumably by auto-vacuum code). Do not write
@@ -2743,7 +2745,6 @@ static int pager_write_pagelist(PgHdr *pList){
} }
#endif #endif
if( rc ) return rc; if( rc ) return rc;
pList->dirty = 0;
#ifdef SQLITE_CHECK_PAGES #ifdef SQLITE_CHECK_PAGES
pList->pageHash = pager_pagehash(pList); pList->pageHash = pager_pagehash(pList);
#endif #endif
@@ -2846,6 +2847,7 @@ static int pager_recycle(Pager *pPager, int syncOk, PgHdr **ppPg){
pPg->dirty = 1; pPg->dirty = 1;
pPg->pDirty = 0; pPg->pDirty = 0;
rc = pager_write_pagelist( pPg ); rc = pager_write_pagelist( pPg );
pPg->dirty = 0;
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
return rc; return rc;
} }
@@ -3698,11 +3700,14 @@ static void makeClean(PgHdr *pPg){
if( pPg->dirty ){ if( pPg->dirty ){
pPg->dirty = 0; pPg->dirty = 0;
if( pPg->pDirty ){ if( pPg->pDirty ){
assert( pPg->pDirty->pPrevDirty==pPg );
pPg->pDirty->pPrevDirty = pPg->pPrevDirty; pPg->pDirty->pPrevDirty = pPg->pPrevDirty;
} }
if( pPg->pPrevDirty ){ if( pPg->pPrevDirty ){
assert( pPg->pPrevDirty->pDirty==pPg );
pPg->pPrevDirty->pDirty = pPg->pDirty; pPg->pPrevDirty->pDirty = pPg->pDirty;
}else{ }else{
assert( pPg->pPager->pDirty==pPg );
pPg->pPager->pDirty = pPg->pDirty; pPg->pPager->pDirty = pPg->pDirty;
} }
} }
@@ -4263,7 +4268,11 @@ int sqlite3PagerCommitPhaseOne(Pager *pPager, const char *zMaster, Pgno nTrunc){
/* Write all dirty pages to the database file */ /* Write all dirty pages to the database file */
pPg = pager_get_all_dirty_pages(pPager); pPg = pager_get_all_dirty_pages(pPager);
rc = pager_write_pagelist(pPg); rc = pager_write_pagelist(pPg);
if( rc!=SQLITE_OK ) goto sync_exit; if( rc!=SQLITE_OK ){
while( pPg && !pPg->dirty ){ pPg = pPg->pDirty; }
pPager->pDirty = pPg;
goto sync_exit;
}
pPager->pDirty = 0; pPager->pDirty = 0;
/* Sync the database file. */ /* Sync the database file. */

View File

@@ -113,7 +113,7 @@ static const et_info fmtinfo[] = {
{ 'd', 10, 1, etRADIX, 0, 0 }, { 'd', 10, 1, etRADIX, 0, 0 },
{ 's', 0, 4, etSTRING, 0, 0 }, { 's', 0, 4, etSTRING, 0, 0 },
{ 'g', 0, 1, etGENERIC, 30, 0 }, { 'g', 0, 1, etGENERIC, 30, 0 },
{ 'z', 0, 6, etDYNSTRING, 0, 0 }, { 'z', 0, 4, etDYNSTRING, 0, 0 },
{ 'q', 0, 4, etSQLESCAPE, 0, 0 }, { 'q', 0, 4, etSQLESCAPE, 0, 0 },
{ 'Q', 0, 4, etSQLESCAPE2, 0, 0 }, { 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
{ 'w', 0, 4, etSQLESCAPE3, 0, 0 }, { 'w', 0, 4, etSQLESCAPE3, 0, 0 },

View File

@@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as ** the version number) and changes its name to "sqlite3.h" as
** part of the build process. ** part of the build process.
** **
** @(#) $Id: sqlite.h.in,v 1.238 2007/08/23 02:47:53 drh Exp $ ** @(#) $Id: sqlite.h.in,v 1.239 2007/08/24 03:51:34 drh Exp $
*/ */
#ifndef _SQLITE3_H_ #ifndef _SQLITE3_H_
#define _SQLITE3_H_ #define _SQLITE3_H_
@@ -339,10 +339,10 @@ int sqlite3_exec(
#define SQLITE_OPEN_EXCLUSIVE 0x00000010 #define SQLITE_OPEN_EXCLUSIVE 0x00000010
#define SQLITE_OPEN_MAIN_DB 0x00000100 #define SQLITE_OPEN_MAIN_DB 0x00000100
#define SQLITE_OPEN_TEMP_DB 0x00000200 #define SQLITE_OPEN_TEMP_DB 0x00000200
#define SQLITE_OPEN_MAIN_JOURNAL 0x00000300 #define SQLITE_OPEN_MAIN_JOURNAL 0x00000400
#define SQLITE_OPEN_TEMP_JOURNAL 0x00000400 #define SQLITE_OPEN_TEMP_JOURNAL 0x00000800
#define SQLITE_OPEN_SUBJOURNAL 0x00000500 #define SQLITE_OPEN_SUBJOURNAL 0x00001000
#define SQLITE_OPEN_MASTER_JOURNAL 0x00000600 #define SQLITE_OPEN_MASTER_JOURNAL 0x00002000
/* /*
** CAPI3REF: Device Characteristics ** CAPI3REF: Device Characteristics
@@ -424,7 +424,7 @@ int sqlite3_exec(
*/ */
typedef struct sqlite3_file sqlite3_file; typedef struct sqlite3_file sqlite3_file;
struct sqlite3_file { struct sqlite3_file {
struct sqlite3_io_methods *pMethods; /* Methods against the open file */ const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
}; };
/* /*
@@ -552,10 +552,10 @@ typedef struct sqlite3_mutex sqlite3_mutex;
** nRef transitions from 1 to 0. ** nRef transitions from 1 to 0.
** **
** Registered vfs modules are kept on a linked list formed by ** Registered vfs modules are kept on a linked list formed by
** the pNext and pPrev pointers. The [sqlite3_register_vfs()] ** the pNext pointer. The [sqlite3_register_vfs()]
** and [sqlite3_unregister_vfs()] interfaces manage this list ** and [sqlite3_unregister_vfs()] interfaces manage this list
** in a thread-safe way. The [sqlite3_acquire_vfs()] searches the ** in a thread-safe way. The [sqlite3_find_vfs()] interface
** list. ** searches the list.
** **
** The zName field holds the name of the VFS module. The name must ** The zName field holds the name of the VFS module. The name must
** be unique across all VFS modules. ** be unique across all VFS modules.
@@ -644,19 +644,19 @@ struct sqlite3_vfs {
sqlite3_vfs *pNext; /* Next registered VFS */ sqlite3_vfs *pNext; /* Next registered VFS */
const char *zName; /* Name of this virtual file system */ const char *zName; /* Name of this virtual file system */
void *pAppData; /* Application context */ void *pAppData; /* Application context */
int (*xOpen)(void *pAppData, const char *zName, sqlite3_file*, int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
int flags, int *pOutFlags); int flags, int *pOutFlags);
int (*xDelete)(void *pAppData, const char *zName, int syncDir); int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
int (*xAccess)(void *pAppData, const char *zName, int flags); int (*xAccess)(sqlite3_vfs*, const char *zName, int flags);
int (*xGetTempName)(void *pAppData, char *zOut); int (*xGetTempName)(sqlite3_vfs*, char *zOut);
int (*xFullPathname)(void *pAppData, const char *zName, char *zOut); int (*xFullPathname)(sqlite3_vfs*, const char *zName, char *zOut);
void *(*xDlOpen)(void *pAppData, const char *zFilename); void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
void (*xDlError)(void *pAppData, int nByte, char *zErrMsg); void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
void *(*xDlSym)(void*, const char *zSymbol); void *(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol);
void (*xDlClose)(void*); void (*xDlClose)(sqlite3_vfs*, void*);
int (*xRandomness)(void *pAppData, int nByte, char *zOut); int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
int (*xSleep)(void *pAppData, int microseconds); int (*xSleep)(sqlite3_vfs*, int microseconds);
int (*xCurrentTime)(void *pAppData, double*); int (*xCurrentTime)(sqlite3_vfs*, double*);
/* New fields may be appended in figure versions. The iVersion /* New fields may be appended in figure versions. The iVersion
** value will increment whenever this happens. */ ** value will increment whenever this happens. */
}; };
@@ -997,7 +997,7 @@ void sqlite3_free_table(char **result);
** These routines all implement some additional formatting ** These routines all implement some additional formatting
** options that are useful for constructing SQL statements. ** options that are useful for constructing SQL statements.
** All of the usual printf formatting options apply. In addition, there ** All of the usual printf formatting options apply. In addition, there
** is are "%q" and "%Q" options. ** is are "%q", "%Q", and "%z" options.
** **
** The %q option works like %s in that it substitutes a null-terminated ** The %q option works like %s in that it substitutes a null-terminated
** string from the argument list. But %q also doubles every '\'' character. ** string from the argument list. But %q also doubles every '\'' character.
@@ -1050,6 +1050,10 @@ void sqlite3_free_table(char **result);
** **
** The code above will render a correct SQL statement in the zSQL ** The code above will render a correct SQL statement in the zSQL
** variable even if the zText variable is a NULL pointer. ** variable even if the zText variable is a NULL pointer.
**
** The "%z" formatting option works exactly like "%s" with the
** addition that after the string has been read and copied into
** the result, [sqlite3_free()] is called on the input string.
*/ */
char *sqlite3_mprintf(const char*,...); char *sqlite3_mprintf(const char*,...);
char *sqlite3_vmprintf(const char*, va_list); char *sqlite3_vmprintf(const char*, va_list);
@@ -1092,8 +1096,8 @@ void sqlite3_free(void*);
** are provided by the default memory subsystem for diagnostic ** are provided by the default memory subsystem for diagnostic
** purposes. ** purposes.
*/ */
sqlite3_uint64 sqlite3_memory_used(void); sqlite3_int64 sqlite3_memory_used(void);
sqlite3_uint64 sqlite3_memory_highwater(int resetFlag); sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
/* /*
** CAPI3REF: Memory Allocation Alarms ** CAPI3REF: Memory Allocation Alarms
@@ -1124,9 +1128,9 @@ sqlite3_uint64 sqlite3_memory_highwater(int resetFlag);
** [sqlite3_soft_heap_limit()] module. ** [sqlite3_soft_heap_limit()] module.
*/ */
int sqlite3_memory_alarm( int sqlite3_memory_alarm(
void(*xCallback)(void *pArg, sqlite3_uint64 used, unsigned int N), void(*xCallback)(void *pArg, sqlite3_int64 used, int N),
void *pArg, void *pArg,
sqlite3_uint64 iThreshold sqlite3_int64 iThreshold
); );

View File

@@ -678,7 +678,7 @@ static int crashParamsObjCmd(
){ ){
int iDelay; int iDelay;
const char *zCrashFile; const char *zCrashFile;
int nCrashFile; int nCrashFile, iDc, iSectorSize;
static sqlite3_vfs crashVfs = { static sqlite3_vfs crashVfs = {
1, /* iVersion */ 1, /* iVersion */
@@ -704,6 +704,7 @@ static int crashParamsObjCmd(
cfCurrentTime /* xCurrentTime */ cfCurrentTime /* xCurrentTime */
}; };
if( crashVfs.pAppData==0 ){ if( crashVfs.pAppData==0 ){
sqlite3_vfs *pOriginalVfs = sqlite3_vfs_find(0); sqlite3_vfs *pOriginalVfs = sqlite3_vfs_find(0);
crashVfs.xDlError = pOriginalVfs->xDlError; crashVfs.xDlError = pOriginalVfs->xDlError;
@@ -717,8 +718,8 @@ static int crashParamsObjCmd(
sqlite3_vfs_register(&crashVfs, 1); sqlite3_vfs_register(&crashVfs, 1);
} }
int iDc = -1; iDc = -1;
int iSectorSize = -1; iSectorSize = -1;
if( objc<3 ){ if( objc<3 ){
Tcl_WrongNumArgs(interp, 1, objv, "?OPTIONS? DELAY CRASHFILE"); Tcl_WrongNumArgs(interp, 1, objv, "?OPTIONS? DELAY CRASHFILE");

View File

@@ -13,7 +13,7 @@
** This file contains code used to implement test interfaces to the ** This file contains code used to implement test interfaces to the
** memory allocation subsystem. ** memory allocation subsystem.
** **
** $Id: test_malloc.c,v 1.4 2007/08/23 02:47:53 drh Exp $ ** $Id: test_malloc.c,v 1.5 2007/08/24 03:51:34 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -287,25 +287,6 @@ static int test_memdebug_fail(
} }
/*
** Usage: sqlite3_memdebug_pending
**
** Return the number of successful mallocs remaining before the
** next simulated failure. Return -1 if no simulated failure is
** currently scheduled.
*/
static int test_memdebug_pending(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
extern int sqlite3_memdebug_pending(void);
Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_memdebug_pending()));
return TCL_OK;
}
/* /*
** Usage: sqlite3_memdebug_settitle TITLE ** Usage: sqlite3_memdebug_settitle TITLE
** **
@@ -354,7 +335,6 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){
{ "sqlite3_memdebug_backtrace", test_memdebug_backtrace }, { "sqlite3_memdebug_backtrace", test_memdebug_backtrace },
{ "sqlite3_memdebug_dump", test_memdebug_dump }, { "sqlite3_memdebug_dump", test_memdebug_dump },
{ "sqlite3_memdebug_fail", test_memdebug_fail }, { "sqlite3_memdebug_fail", test_memdebug_fail },
{ "sqlite3_memdebug_pending", test_memdebug_pending },
{ "sqlite3_memdebug_settitle", test_memdebug_settitle }, { "sqlite3_memdebug_settitle", test_memdebug_settitle },
}; };
int i; int i;

View File

@@ -702,9 +702,9 @@ static const void *columnName(
n = sqlite3_column_count(pStmt); n = sqlite3_column_count(pStmt);
if( N<n && N>=0 ){ if( N<n && N>=0 ){
N += useType*n; N += useType*n;
sqlite3_mutex_enter(p->db->mutex);
ret = xFunc(&p->aColName[N]); ret = xFunc(&p->aColName[N]);
#if 0
/* A malloc may have failed inside of the xFunc() call. If this /* A malloc may have failed inside of the xFunc() call. If this
** is the case, clear the mallocFailed flag and return NULL. ** is the case, clear the mallocFailed flag and return NULL.
*/ */
@@ -712,7 +712,7 @@ static const void *columnName(
p->db->mallocFailed = 0; p->db->mallocFailed = 0;
ret = 0; ret = 0;
} }
#endif sqlite3_mutex_leave(p->db->mutex);
} }
} }
return ret; return ret;

View File

@@ -1007,7 +1007,6 @@ static void Cleanup(Vdbe *p){
void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){ void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
Mem *pColName; Mem *pColName;
int n; int n;
sqlite3 *db = p->db;
releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
sqlite3_free(p->aColName); sqlite3_free(p->aColName);
@@ -1017,7 +1016,7 @@ void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
if( p->aColName==0 ) return; if( p->aColName==0 ) return;
while( n-- > 0 ){ while( n-- > 0 ){
pColName->flags = MEM_Null; pColName->flags = MEM_Null;
pColName->db = db; pColName->db = p->db;
pColName++; pColName++;
} }
} }

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to help implement virtual tables. ** This file contains code used to help implement virtual tables.
** **
** $Id: vtab.c,v 1.53 2007/08/23 02:47:53 drh Exp $ ** $Id: vtab.c,v 1.54 2007/08/24 03:51:34 drh Exp $
*/ */
#ifndef SQLITE_OMIT_VIRTUALTABLE #ifndef SQLITE_OMIT_VIRTUALTABLE
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -24,10 +24,11 @@ static int createModule(
void (*xDestroy)(void *) /* Module destructor function */ void (*xDestroy)(void *) /* Module destructor function */
) { ) {
int rc, nName; int rc, nName;
Module *pMod;
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
nName = strlen(zName); nName = strlen(zName);
Module *pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1); pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1);
if( pMod ){ if( pMod ){
char *zCopy = (char *)(&pMod[1]); char *zCopy = (char *)(&pMod[1]);
memcpy(zCopy, zName, nName+1); memcpy(zCopy, zName, nName+1);

View File

@@ -12,7 +12,7 @@
# focus of this file is testing for correct handling of disk full # focus of this file is testing for correct handling of disk full
# errors. # errors.
# #
# $Id: diskfull.test,v 1.6 2007/04/05 17:15:53 danielk1977 Exp $ # $Id: diskfull.test,v 1.7 2007/08/24 03:51:34 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -113,4 +113,3 @@ do_diskfull_test diskfull-2 VACUUM
# } # }
finish_test finish_test