mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Work toward multithreading support. Currently crashes quickly on a test. (CVS 4253)
FossilOrigin-Name: 1315bd8e125602275fb718780f9b2730bd37f6ab
This commit is contained in:
4
main.mk
4
main.mk
@@ -281,8 +281,8 @@ last_change: $(SRC)
|
|||||||
cat $(SRC) | grep '$$Id: ' | sort -k 5 | tail -1 \
|
cat $(SRC) | grep '$$Id: ' | sort -k 5 | tail -1 \
|
||||||
| $(NAWK) '{print $$5,$$6}' >last_change
|
| $(NAWK) '{print $$5,$$6}' >last_change
|
||||||
|
|
||||||
libsqlite3.a: $(LIBOBJ) $(EXTOBJ)
|
libsqlite3.a: $(LIBOBJ)
|
||||||
$(AR) libsqlite3.a $(LIBOBJ) $(EXTOBJ)
|
$(AR) libsqlite3.a $(LIBOBJ)
|
||||||
$(RANLIB) libsqlite3.a
|
$(RANLIB) libsqlite3.a
|
||||||
|
|
||||||
sqlite3$(EXE): $(TOP)/src/shell.c libsqlite3.a sqlite3.h
|
sqlite3$(EXE): $(TOP)/src/shell.c libsqlite3.a sqlite3.h
|
||||||
|
54
manifest
54
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Oops\s-\sa\srandom\sfts2\stest\sI\shad\sabandoned\sslipped\sinto\sthe\sfts3\sbatch.\s(CVS\s4252)
|
C Work\stoward\smultithreading\ssupport.\s\sCurrently\scrashes\squickly\son\sa\stest.\s(CVS\s4253)
|
||||||
D 2007-08-20T17:53:00
|
D 2007-08-20T22:48:42
|
||||||
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
|
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
|
||||||
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -63,7 +63,7 @@ F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33
|
|||||||
F ext/icu/icu.c 61a345d8126686aa3487aa8d2d0f68abd655f7a4
|
F ext/icu/icu.c 61a345d8126686aa3487aa8d2d0f68abd655f7a4
|
||||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
||||||
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
|
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
|
||||||
F main.mk e90dcb16ce27c6d8d8ed18335c4cc03f5a5fed0b
|
F main.mk b1d97fe47a0633bc2ee5a09c7fdf7f4105156437
|
||||||
F mkdll.sh 37fa8a7412e51b5ab2bc6d4276135f022a0feffb
|
F mkdll.sh 37fa8a7412e51b5ab2bc6d4276135f022a0feffb
|
||||||
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
|
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
|
||||||
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
|
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
|
||||||
@@ -80,9 +80,9 @@ 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 5ea90bc93dfea46e9fe4bf531e14c7cd98219ecb
|
F src/auth.c 5ea90bc93dfea46e9fe4bf531e14c7cd98219ecb
|
||||||
F src/btree.c f8a04f35eb81360773899983f7c2008145e13935
|
F src/btree.c ae710a86a5ee2f27fbcba34033e4f048bd97cde9
|
||||||
F src/btree.h 91ee529d581c1473d8e6e15299acc3b8de1d0674
|
F src/btree.h 525105564c87111922412368f2e4301c36e74ac1
|
||||||
F src/btreeInt.h 9b4ca8999e52f713420e5f297dd86887a7a9820f
|
F src/btreeInt.h e93edf57832278138b98cf60cbc54241103c6988
|
||||||
F src/build.c add67be992307b4b11849a6611bfd3352aacde92
|
F src/build.c add67be992307b4b11849a6611bfd3352aacde92
|
||||||
F src/callback.c 143436453bb93e831c9574fea0b9b9eb90e40ff3
|
F src/callback.c 143436453bb93e831c9574fea0b9b9eb90e40ff3
|
||||||
F src/complete.c ea63834e798a0ab14159bdc6e6cabc3df21aa346
|
F src/complete.c ea63834e798a0ab14159bdc6e6cabc3df21aa346
|
||||||
@@ -97,20 +97,20 @@ F src/insert.c 633322aef1799f6604fa805e12488bc628570b0c
|
|||||||
F src/legacy.c 6013a7cb7da1b72550b3d35d4fc598b3c3e5b8c1
|
F src/legacy.c 6013a7cb7da1b72550b3d35d4fc598b3c3e5b8c1
|
||||||
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
|
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
|
||||||
F src/loadext.c c0ccda3dbda109da087a8fd762deebe5fdf24a1d
|
F src/loadext.c c0ccda3dbda109da087a8fd762deebe5fdf24a1d
|
||||||
F src/main.c 685aa31a7af0d650c94e6968d713c3a9374aa72e
|
F src/main.c 7310dd532c1ff751772b196c98f7e0534afd7e58
|
||||||
F src/malloc.c 613c65f12ff0ee4edd017aa458209ab7a23cd7b1
|
F src/malloc.c 613c65f12ff0ee4edd017aa458209ab7a23cd7b1
|
||||||
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
||||||
F src/mem1.c 30bf8be3846f92fdf88c490c5e5378512383bcbe
|
F src/mem1.c 30bf8be3846f92fdf88c490c5e5378512383bcbe
|
||||||
F src/mem2.c 661ca7ebf6e4b964fecc95d24e8c89dbcfc9dfea
|
F src/mem2.c 482f0aaf14e8ef1db64cb8c5b9a9bfe708297c92
|
||||||
F src/mutex.c 67b2efd36a1e67a7dc7b7fa852fd69953462c943
|
F src/mutex.c 60051a86c49cfe2ec15dd8b1d9d0d530b8893b07
|
||||||
F src/os.c 68c46a16bcd47aa3f9418a01dc2812b1ff2c4c17
|
F src/os.c c9f91550afa071c5b98042ce14d38a2d87c3f4df
|
||||||
F src/os.h da098cad985b4849fefdd6a96d671b332008aa55
|
F src/os.h da098cad985b4849fefdd6a96d671b332008aa55
|
||||||
F src/os_common.h a5c446d3b93f09f369d13bf217de4bed3437dd1c
|
F src/os_common.h a5c446d3b93f09f369d13bf217de4bed3437dd1c
|
||||||
F src/os_os2.c cba4e96fadb949076c717108fe0599d1a3c2e446
|
F src/os_os2.c cba4e96fadb949076c717108fe0599d1a3c2e446
|
||||||
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
|
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 10fb60a8d9174dcb609d72f6b97211c58da25b47
|
F src/os_unix.c 41a737d14d00b93fae8efd0d0555922f07a29ada
|
||||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||||
F src/os_win.c d868d5f9e95ec9c1b9e2a30c54c996053db6dddd
|
F src/os_win.c d868d5f9e95ec9c1b9e2a30c54c996053db6dddd
|
||||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||||
@@ -120,35 +120,35 @@ F src/parse.y c03529c3b82702ada98ce405b390e3a9409708cf
|
|||||||
F src/pragma.c 8f5e37c3cf6dbdeb3645bb80cc58cfc3324c0178
|
F src/pragma.c 8f5e37c3cf6dbdeb3645bb80cc58cfc3324c0178
|
||||||
F src/prepare.c 03292beeffce2d65debab12508a8ec1f5aec7241
|
F src/prepare.c 03292beeffce2d65debab12508a8ec1f5aec7241
|
||||||
F src/printf.c a8f46e0ed360c18d40e89aa636533be300b406c2
|
F src/printf.c a8f46e0ed360c18d40e89aa636533be300b406c2
|
||||||
F src/random.c 00b30565f018f3a256c157432935de070231c73b
|
F src/random.c af7264b4ed93330b3bf40dd123e16e7f8f62e5bb
|
||||||
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 a0baef0f4c969a4eb9dfc9096bf527ca543485e5
|
F src/sqlite.h.in 09d8d2780c2c25dedbcfdfcafc39e8b213fc8432
|
||||||
F src/sqlite3ext.h 647a6b8a8f76ff6c9611e4a071531d8e63ff2d6b
|
F src/sqlite3ext.h 647a6b8a8f76ff6c9611e4a071531d8e63ff2d6b
|
||||||
F src/sqliteInt.h 8932f2a2f855e5ce566ab3805002f074eb56ae11
|
F src/sqliteInt.h 6891d6864a6b9fc661eadaa0328e81dff7523584
|
||||||
F src/sqliteLimit.h f14609c27636ebc217c9603ade26dbdd7d0f6afa
|
F src/sqliteLimit.h f14609c27636ebc217c9603ade26dbdd7d0f6afa
|
||||||
F src/table.c c725e47f6f3092b9a7b569fc58e408e2173ee008
|
F src/table.c c725e47f6f3092b9a7b569fc58e408e2173ee008
|
||||||
F src/tclsqlite.c 0606c4f31711492eb4d7480a981eebb80914f3d9
|
F src/tclsqlite.c 0606c4f31711492eb4d7480a981eebb80914f3d9
|
||||||
F src/test1.c a226ab03048491aa6c5d43d26097df96bdb162e7
|
F src/test1.c 6ae17d70dac0f14ab632f66c026a44fb0c71f22e
|
||||||
F src/test2.c 016380989929fd41bdf790058b1f2fd698f8af28
|
F src/test2.c 4506b6635e193a19a9bccdbe366ff4aed09cbe79
|
||||||
F src/test3.c b87e8fcce45e1d3153aae9f04236076b7707a714
|
F src/test3.c b87e8fcce45e1d3153aae9f04236076b7707a714
|
||||||
F src/test4.c d22cb3ab4f9fdfd0a595b70d5328cee923b7322c
|
F src/test4.c 1f4d2ed89867bac187d49ed8004f121592987d3e
|
||||||
F src/test5.c 7bc8a87c2b6fd076ec2ca9972946e71a367883ad
|
F src/test5.c 7bc8a87c2b6fd076ec2ca9972946e71a367883ad
|
||||||
F src/test6.c d67117b2c1df9b07889f3f3779ecc9ec2663fd1e
|
F src/test6.c b0090b4826d5e06df2ff2d5acaddf3f8f708fcd2
|
||||||
F src/test7.c 91d914c2c2b2806157213f41f4185ad3a4970c07
|
F src/test7.c 0f9d91ce8018740d5eb6e258f0fac2a2943c40f0
|
||||||
F src/test8.c 719c284607c1e91a893f5425df1e92b74c859aef
|
F src/test8.c 719c284607c1e91a893f5425df1e92b74c859aef
|
||||||
F src/test9.c c0f38f7795cc51d37db6c63874d90f40f10d0f0e
|
F src/test9.c c0f38f7795cc51d37db6c63874d90f40f10d0f0e
|
||||||
F src/test_async.c 871ffbe4a520be74b403aca87aa622ebdb690232
|
F src/test_async.c ba48913e4bab43b149747d3bdd3b75b1f66658ec
|
||||||
F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
|
F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
|
||||||
F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
|
F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
|
||||||
F src/test_config.c 1d0da26fd51757765f2073c57a925db8ddc7120c
|
F src/test_config.c ddced28aedfa324292005d991d74b595d76a838a
|
||||||
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 d9ba6be85f9c4a439b19f6e0a72d91c369d72c63
|
F src/test_malloc.c d9ba6be85f9c4a439b19f6e0a72d91c369d72c63
|
||||||
F src/test_md5.c d9f828765b242ff86f58cd879259c3da4eaede02
|
F src/test_md5.c d9f828765b242ff86f58cd879259c3da4eaede02
|
||||||
F src/test_schema.c 12c9de7661d6294eec2d57afbb52e2af1128084f
|
F src/test_schema.c 12c9de7661d6294eec2d57afbb52e2af1128084f
|
||||||
F src/test_server.c 76c0baf509abe65ca6e5c7974ab0097cfdd8b833
|
F src/test_server.c 319f6b1a99bab5f7149387442243d6e65a8ab4eb
|
||||||
F src/test_tclvar.c 160290ba5c19964da7cb97defc6c104712074b69
|
F src/test_tclvar.c 160290ba5c19964da7cb97defc6c104712074b69
|
||||||
F src/tokenize.c 3a3fd71cfb2abb8e11ed6ab6b764b790c534defc
|
F src/tokenize.c 3a3fd71cfb2abb8e11ed6ab6b764b790c534defc
|
||||||
F src/trigger.c dccc6fbf37d12193c90ede5b026bbd195d505ff4
|
F src/trigger.c dccc6fbf37d12193c90ede5b026bbd195d505ff4
|
||||||
@@ -557,7 +557,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 24739f148e7687532fd04794a041aade8626c630
|
P 709f2aa18a4802a7ca6638c00b2b99440b4a3191
|
||||||
R 91022a585940fe2f4f8ce2cc48394d34
|
R dff2f29b0cfe4e6e9309aeb129fa4ba9
|
||||||
U shess
|
U drh
|
||||||
Z 50354b12eb6453839bc699aa3eacaa47
|
Z b2675de4c3469ebcd0e4f20229838975
|
||||||
|
@@ -1 +1 @@
|
|||||||
709f2aa18a4802a7ca6638c00b2b99440b4a3191
|
1315bd8e125602275fb718780f9b2730bd37f6ab
|
542
src/btree.c
542
src/btree.c
File diff suppressed because it is too large
Load Diff
10
src/btree.h
10
src/btree.h
@@ -13,7 +13,7 @@
|
|||||||
** subsystem. See comments in the source code for a detailed description
|
** subsystem. See comments in the source code for a detailed description
|
||||||
** of what each interface routine does.
|
** of what each interface routine does.
|
||||||
**
|
**
|
||||||
** @(#) $Id: btree.h,v 1.83 2007/08/17 01:14:38 drh Exp $
|
** @(#) $Id: btree.h,v 1.84 2007/08/20 22:48:42 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _BTREE_H_
|
#ifndef _BTREE_H_
|
||||||
#define _BTREE_H_
|
#define _BTREE_H_
|
||||||
@@ -100,12 +100,12 @@ int sqlite3BtreeLockTable(Btree *, int, u8);
|
|||||||
** use mutexes to access the BtShared structures. So make the
|
** use mutexes to access the BtShared structures. So make the
|
||||||
** Enter and Leave procedures no-ops.
|
** Enter and Leave procedures no-ops.
|
||||||
*/
|
*/
|
||||||
#ifdef SQLITE_OMIT_SHARED_CACHE
|
#if SQLITE_THREADSAFE && !defined(SQLITE_OMIT_SHARED_CACHE)
|
||||||
# define sqlite3BtreeEnter(X)
|
|
||||||
# define sqlite3BtreeLeave(X)
|
|
||||||
#else
|
|
||||||
void sqlite3BtreeEnter(Btree*);
|
void sqlite3BtreeEnter(Btree*);
|
||||||
void sqlite3BtreeLeave(Btree*);
|
void sqlite3BtreeLeave(Btree*);
|
||||||
|
#else
|
||||||
|
# define sqlite3BtreeEnter(X)
|
||||||
|
# define sqlite3BtreeLeave(X)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *sqlite3BtreeGetFilename(Btree *);
|
const char *sqlite3BtreeGetFilename(Btree *);
|
||||||
|
@@ -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: btreeInt.h,v 1.7 2007/08/20 13:14:29 drh Exp $
|
** $Id: btreeInt.h,v 1.8 2007/08/20 22:48:42 drh Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
@@ -264,6 +264,9 @@ typedef struct BtLock BtLock;
|
|||||||
** walk up the BTree from any leaf to the root. Care must be taken to
|
** walk up the BTree from any leaf to the root. Care must be taken to
|
||||||
** unref() the parent page pointer when this page is no longer referenced.
|
** unref() the parent page pointer when this page is no longer referenced.
|
||||||
** The pageDestructor() routine handles that chore.
|
** The pageDestructor() routine handles that chore.
|
||||||
|
**
|
||||||
|
** Access to all fields of this structure is controlled by the mutex
|
||||||
|
** stored in MemPage.pBt->mutex.
|
||||||
*/
|
*/
|
||||||
struct MemPage {
|
struct MemPage {
|
||||||
u8 isInit; /* True if previously initialized. MUST BE FIRST! */
|
u8 isInit; /* True if previously initialized. MUST BE FIRST! */
|
||||||
@@ -315,8 +318,7 @@ struct MemPage {
|
|||||||
** schema associated with the database file are all contained within
|
** schema associated with the database file are all contained within
|
||||||
** the BtShared object.
|
** the BtShared object.
|
||||||
**
|
**
|
||||||
** All fields in this structure are accessed under the sqlite3.pMutex
|
** All fields in this structure are accessed under the sqlite3.mutex.
|
||||||
** mutex.
|
|
||||||
*/
|
*/
|
||||||
struct Btree {
|
struct Btree {
|
||||||
sqlite3 *pSqlite; /* The database connection holding this btree */
|
sqlite3 *pSqlite; /* The database connection holding this btree */
|
||||||
@@ -416,9 +418,9 @@ struct CellInfo {
|
|||||||
** but cursors cannot be shared. Each cursor is associated with a
|
** but cursors cannot be shared. Each cursor is associated with a
|
||||||
** particular database connection identified BtCursor.pBtree.pSqlite.
|
** particular database connection identified BtCursor.pBtree.pSqlite.
|
||||||
**
|
**
|
||||||
** The fields in this structure are accessed under the sqlite3.pMutex
|
** Fields in this structure are accessed under the BtShared.mutex
|
||||||
** mutex, specifically the BtCurser.pBtree->pSqlite->pMutex mutex.
|
** mutex. The pBtree field is safe to access under the
|
||||||
** The pNext and pPrev fields also require the BtShared.mutex mutex.
|
** BtShared->pBtree->pSqlite->mutex mutex.
|
||||||
*/
|
*/
|
||||||
struct BtCursor {
|
struct BtCursor {
|
||||||
Btree *pBtree; /* The Btree to which this cursor belongs */
|
Btree *pBtree; /* The Btree to which this cursor belongs */
|
||||||
|
@@ -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.388 2007/08/20 17:37:48 shess Exp $
|
** $Id: main.c,v 1.389 2007/08/20 22:48:42 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -218,8 +218,8 @@ int sqlite3_close(sqlite3 *db){
|
|||||||
** structure?
|
** structure?
|
||||||
*/
|
*/
|
||||||
sqlite3_free(db->aDb[1].pSchema);
|
sqlite3_free(db->aDb[1].pSchema);
|
||||||
|
sqlite3_vfs_release(db->pVfs);
|
||||||
sqlite3_free(db);
|
sqlite3_free(db);
|
||||||
/* sqlite3ReleaseThreadData(); */
|
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,7 +900,7 @@ static int openDatabase(
|
|||||||
/* Allocate the sqlite data structure */
|
/* Allocate the sqlite data structure */
|
||||||
db = sqlite3MallocZero( sizeof(sqlite3) );
|
db = sqlite3MallocZero( sizeof(sqlite3) );
|
||||||
if( db==0 ) goto opendb_out;
|
if( db==0 ) goto opendb_out;
|
||||||
db->pVfs = sqlite3_find_vfs(0);
|
db->pVfs = sqlite3_vfs_find(0);
|
||||||
db->errMask = 0xff;
|
db->errMask = 0xff;
|
||||||
db->priorNewRowid = 0;
|
db->priorNewRowid = 0;
|
||||||
db->magic = SQLITE_MAGIC_BUSY;
|
db->magic = SQLITE_MAGIC_BUSY;
|
||||||
@@ -1385,7 +1385,7 @@ int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
|
|||||||
*/
|
*/
|
||||||
int sqlite3_sleep(int ms){
|
int sqlite3_sleep(int ms){
|
||||||
sqlite3_vfs *pVfs;
|
sqlite3_vfs *pVfs;
|
||||||
pVfs = sqlite3_find_vfs(0);
|
pVfs = sqlite3_vfs_find(0);
|
||||||
|
|
||||||
/* This function works in milliseconds, but the underlying OsSleep()
|
/* This function works in milliseconds, but the underlying OsSleep()
|
||||||
** API uses microseconds. Hence the 1000's.
|
** API uses microseconds. Hence the 1000's.
|
||||||
|
30
src/mem2.c
30
src/mem2.c
@@ -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.4 2007/08/16 19:40:17 drh Exp $
|
** $Id: mem2.c,v 1.5 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -133,6 +133,12 @@ static struct {
|
|||||||
int iReset; /* When malloc fails set iiFail to this value */
|
int iReset; /* When malloc fails set iiFail to this value */
|
||||||
int iFailCnt; /* Number of failures */
|
int iFailCnt; /* Number of failures */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** sqlite3MallocDisallow() increments the following counter.
|
||||||
|
** sqlite3MallocAllow() decrements it.
|
||||||
|
*/
|
||||||
|
int disallow; /* Do not allow memory allocation */
|
||||||
|
|
||||||
|
|
||||||
} mem = { /* This variable holds all of the local data */
|
} mem = { /* This variable holds all of the local data */
|
||||||
((sqlite3_uint64)1)<<63, /* alarmThreshold */
|
((sqlite3_uint64)1)<<63, /* alarmThreshold */
|
||||||
@@ -254,6 +260,7 @@ void *sqlite3_malloc(unsigned int nByte){
|
|||||||
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);
|
||||||
|
assert( mem.disallow==0 );
|
||||||
if( mem.nowUsed+nByte>=mem.alarmThreshold ){
|
if( mem.nowUsed+nByte>=mem.alarmThreshold ){
|
||||||
sqlite3MemsysAlarm(nByte);
|
sqlite3MemsysAlarm(nByte);
|
||||||
}
|
}
|
||||||
@@ -367,6 +374,7 @@ void *sqlite3_realloc(void *pPrior, unsigned int nByte){
|
|||||||
sqlite3_free(pPrior);
|
sqlite3_free(pPrior);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
assert( mem.disallow==0 );
|
||||||
pOldHdr = sqlite3MemsysGetHeader(pPrior);
|
pOldHdr = sqlite3MemsysGetHeader(pPrior);
|
||||||
pNew = sqlite3_malloc(nByte);
|
pNew = sqlite3_malloc(nByte);
|
||||||
if( pNew ){
|
if( pNew ){
|
||||||
@@ -440,4 +448,24 @@ int sqlite3_memdebug_fail(int iFail, int iRepeat){
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following two routines are used to assert that no memory
|
||||||
|
** allocations occur between one call and the next. The use of
|
||||||
|
** these routines does not change the computed results in any way.
|
||||||
|
** These routines are like asserts.
|
||||||
|
*/
|
||||||
|
void sqlite3MallocDisallow(void){
|
||||||
|
assert( mem.mutex!=0 );
|
||||||
|
sqlite3_mutex_enter(mem.mutex);
|
||||||
|
mem.disallow++;
|
||||||
|
sqlite3_mutex_leave(mem.mutex);
|
||||||
|
}
|
||||||
|
void sqlite3MallocAllow(void){
|
||||||
|
assert( mem.mutex );
|
||||||
|
sqlite3_mutex_enter(mem.mutex);
|
||||||
|
assert( mem.disallow>0 );
|
||||||
|
mem.disallow--;
|
||||||
|
sqlite3_mutex_leave(mem.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SQLITE_MEMDEBUG && !SQLITE_OMIT_MEMORY_ALLOCATION */
|
#endif /* SQLITE_MEMDEBUG && !SQLITE_OMIT_MEMORY_ALLOCATION */
|
||||||
|
28
src/mutex.c
28
src/mutex.c
@@ -12,7 +12,7 @@
|
|||||||
** This file contains the C functions that implement mutexes for
|
** This file contains the C functions that implement mutexes for
|
||||||
** use by the SQLite core.
|
** use by the SQLite core.
|
||||||
**
|
**
|
||||||
** $Id: mutex.c,v 1.4 2007/08/17 01:14:38 drh Exp $
|
** $Id: mutex.c,v 1.5 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
** that means that a mutex could not be allocated.
|
** that means that a mutex could not be allocated.
|
||||||
*/
|
*/
|
||||||
sqlite3_mutex *sqlite3_mutex_alloc(int idNotUsed){
|
sqlite3_mutex *sqlite3_mutex_alloc(int idNotUsed){
|
||||||
return (sqlite3_mutex*)sqlite3_mutex_alloc;
|
return (sqlite3_mutex*)8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -64,13 +64,24 @@ void sqlite3_mutex_enter(sqlite3_mutex *pNotUsed){}
|
|||||||
int sqlite3_mutex_try(sqlite3_mutex *pNotUsed){ return SQLITE_OK; }
|
int sqlite3_mutex_try(sqlite3_mutex *pNotUsed){ return SQLITE_OK; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The sqlite3_mutex_exit() routine exits a mutex that was
|
** The sqlite3_mutex_leave() routine exits a mutex that was
|
||||||
** previously entered by the same thread. The behavior
|
** previously entered by the same thread. The behavior
|
||||||
** is undefined if the mutex is not currently entered or
|
** is undefined if the mutex is not currently entered or
|
||||||
** is not currently allocated. SQLite will never do either.
|
** is not currently allocated. SQLite will never do either.
|
||||||
*/
|
*/
|
||||||
void sqlite3_mutex_leave(sqlite3_mutex *pNotUsed){}
|
void sqlite3_mutex_leave(sqlite3_mutex *pNotUsed){}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
|
||||||
|
** intended for use inside assert() statements.
|
||||||
|
*/
|
||||||
|
int sqlite3_mutex_held(sqlite3_mutex *pNotUsed){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int sqlite3_mutex_notheld(sqlite3_mutex *pNotUsed){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/**************** Non-recursive Pthread Mutex Implementation *****************
|
/**************** Non-recursive Pthread Mutex Implementation *****************
|
||||||
**
|
**
|
||||||
@@ -293,6 +304,17 @@ void sqlite3_mutex_leave(sqlite3_mutex *pMutex){
|
|||||||
pthread_mutex_unlock(&p->auxMutex);
|
pthread_mutex_unlock(&p->auxMutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
|
||||||
|
** intended for use inside assert() statements.
|
||||||
|
*/
|
||||||
|
int sqlite3_mutex_held(sqlite3_mutex *pNotUsed){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int sqlite3_mutex_notheld(sqlite3_mutex *pNotUsed){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
#endif /* non-recursive pthreads */
|
#endif /* non-recursive pthreads */
|
||||||
|
|
||||||
#endif /* !defined(SQLITE_MUTEX_APPDEF) */
|
#endif /* !defined(SQLITE_MUTEX_APPDEF) */
|
||||||
|
100
src/os.c
100
src/os.c
@@ -74,6 +74,10 @@ int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The next group of routines are convenience wrappers around the
|
||||||
|
** VFS methods.
|
||||||
|
*/
|
||||||
int sqlite3OsOpen(
|
int sqlite3OsOpen(
|
||||||
sqlite3_vfs *pVfs,
|
sqlite3_vfs *pVfs,
|
||||||
const char *zPath,
|
const char *zPath,
|
||||||
@@ -81,9 +85,6 @@ int sqlite3OsOpen(
|
|||||||
int flags,
|
int flags,
|
||||||
int *pFlagsOut
|
int *pFlagsOut
|
||||||
){
|
){
|
||||||
#if defined(SQLITE_TEST) && !defined(SQLITE_OMIT_DISKIO)
|
|
||||||
return sqlite3CrashFileOpen(pVfs, zPath, pFile, flags, pFlagsOut);
|
|
||||||
#endif
|
|
||||||
return pVfs->xOpen(pVfs->pAppData, zPath, pFile, flags, pFlagsOut);
|
return pVfs->xOpen(pVfs->pAppData, zPath, pFile, flags, pFlagsOut);
|
||||||
}
|
}
|
||||||
int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
|
int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
|
||||||
@@ -154,7 +155,96 @@ int sqlite3OsCloseFree(sqlite3_file *pFile){
|
|||||||
*/
|
*/
|
||||||
extern sqlite3_vfs sqlite3DefaultVfs;
|
extern sqlite3_vfs sqlite3DefaultVfs;
|
||||||
|
|
||||||
sqlite3_vfs *sqlite3_find_vfs(const char *zVfs){
|
/*
|
||||||
return &sqlite3DefaultVfs;
|
** 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
|
||||||
|
** first VFS on the list.
|
||||||
|
*/
|
||||||
|
sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
|
||||||
|
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||||
|
sqlite3_vfs *pVfs;
|
||||||
|
sqlite3_mutex_enter(mutex);
|
||||||
|
for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){
|
||||||
|
if( zVfs==0 ) break;
|
||||||
|
if( strcmp(zVfs, pVfs->zName)==0 ) break;
|
||||||
|
}
|
||||||
|
if( pVfs ){
|
||||||
|
pVfs->nRef++;
|
||||||
|
assert( pVfs->nRef==1 || pVfs->vfsMutex!=0 );
|
||||||
|
assert( pVfs->nRef>1 || pVfs->vfsMutex==0 );
|
||||||
|
if( pVfs->vfsMutex==0 ){
|
||||||
|
pVfs->vfsMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sqlite3_mutex_leave(mutex);
|
||||||
|
return pVfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Release a VFS once it is no longer needed.
|
||||||
|
*/
|
||||||
|
int sqlite3_vfs_release(sqlite3_vfs *pVfs){
|
||||||
|
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||||
|
sqlite3_mutex_enter(mutex);
|
||||||
|
assert( pVfs->nRef>0 );
|
||||||
|
pVfs->nRef--;
|
||||||
|
if( pVfs->nRef==0 ){
|
||||||
|
sqlite3_mutex_free(pVfs->vfsMutex);
|
||||||
|
pVfs->vfsMutex = 0;
|
||||||
|
}
|
||||||
|
sqlite3_mutex_leave(mutex);
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Unlink a VFS from the linked list
|
||||||
|
*/
|
||||||
|
static void vfsUnlink(sqlite3_vfs *pVfs){
|
||||||
|
assert( sqlite3_mutex_held(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)) );
|
||||||
|
if( vfsList==pVfs ){
|
||||||
|
vfsList = pVfs->pNext;
|
||||||
|
}else{
|
||||||
|
sqlite3_vfs *p = vfsList;
|
||||||
|
while( p->pNext && p->pNext!=pVfs ){
|
||||||
|
p = p->pNext;
|
||||||
|
}
|
||||||
|
if( p->pNext==pVfs ){
|
||||||
|
p->pNext = pVfs->pNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Register a VFS with the system. It is harmless to register the same
|
||||||
|
** VFS multiple times. The new VFS becomes the default if makeDflt is
|
||||||
|
** true.
|
||||||
|
*/
|
||||||
|
int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
|
||||||
|
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||||
|
sqlite3_mutex_enter(mutex);
|
||||||
|
vfsUnlink(pVfs);
|
||||||
|
if( makeDflt || vfsList==0 ){
|
||||||
|
pVfs->pNext = vfsList;
|
||||||
|
vfsList = pVfs;
|
||||||
|
}else{
|
||||||
|
pVfs->pNext = vfsList->pNext;
|
||||||
|
pVfs->pNext = pVfs;
|
||||||
|
}
|
||||||
|
sqlite3_mutex_leave(mutex);
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Unregister a VFS so that it is no longer accessible.
|
||||||
|
*/
|
||||||
|
int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
|
||||||
|
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||||
|
sqlite3_mutex_enter(mutex);
|
||||||
|
vfsUnlink(pVfs);
|
||||||
|
sqlite3_mutex_leave(mutex);
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
|
@@ -25,12 +25,12 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Macros used to determine whether or not to use threads. The
|
** Macros used to determine whether or not to use threads. The
|
||||||
** SQLITE_UNIX_THREADS macro is defined if we are synchronizing for
|
** SQLITE_OS2_THREADS macro is defined if we are synchronizing for
|
||||||
** Posix threads and SQLITE_W32_THREADS is defined if we are
|
** Posix threads and SQLITE_W32_THREADS is defined if we are
|
||||||
** synchronizing using Win32 threads.
|
** synchronizing using Win32 threads.
|
||||||
*/
|
*/
|
||||||
/* this mutex implementation only available with EMX */
|
/* this mutex implementation only available with EMX */
|
||||||
#if defined(THREADSAFE) && THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
# include <sys/builtin.h>
|
# include <sys/builtin.h>
|
||||||
# include <sys/smutex.h>
|
# include <sys/smutex.h>
|
||||||
# define SQLITE_OS2_THREADS 1
|
# define SQLITE_OS2_THREADS 1
|
||||||
|
@@ -59,10 +59,7 @@
|
|||||||
** If we are to be thread-safe, include the pthreads header and define
|
** If we are to be thread-safe, include the pthreads header and define
|
||||||
** the SQLITE_UNIX_THREADS macro.
|
** the SQLITE_UNIX_THREADS macro.
|
||||||
*/
|
*/
|
||||||
#ifndef THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
# define THREADSAFE 1
|
|
||||||
#endif
|
|
||||||
#if THREADSAFE
|
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# define SQLITE_UNIX_THREADS 1
|
# define SQLITE_UNIX_THREADS 1
|
||||||
#endif
|
#endif
|
||||||
@@ -102,7 +99,7 @@ struct unixFile {
|
|||||||
unsigned char locktype; /* The type of lock held on this fd */
|
unsigned char locktype; /* The type of lock held on this fd */
|
||||||
unsigned char isOpen; /* True if needs to be closed */
|
unsigned char isOpen; /* True if needs to be closed */
|
||||||
int dirfd; /* File descriptor for the directory */
|
int dirfd; /* File descriptor for the directory */
|
||||||
#ifdef SQLITE_UNIX_THREADS
|
#if SQLITE_THREADSAFE
|
||||||
pthread_t tid; /* The thread that "owns" this unixFile */
|
pthread_t tid; /* The thread that "owns" this unixFile */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -150,7 +147,7 @@ struct unixFile {
|
|||||||
** The threadid macro resolves to the thread-id or to 0. Used for
|
** The threadid macro resolves to the thread-id or to 0. Used for
|
||||||
** testing and debugging only.
|
** testing and debugging only.
|
||||||
*/
|
*/
|
||||||
#ifdef SQLITE_UNIX_THREADS
|
#if SQLITE_THREADSAFE
|
||||||
#define threadid pthread_self()
|
#define threadid pthread_self()
|
||||||
#else
|
#else
|
||||||
#define threadid 0
|
#define threadid 0
|
||||||
@@ -172,7 +169,7 @@ struct unixFile {
|
|||||||
** recomputed because its key includes the thread-id. See the
|
** recomputed because its key includes the thread-id. See the
|
||||||
** transferOwnership() function below for additional information
|
** transferOwnership() function below for additional information
|
||||||
*/
|
*/
|
||||||
#if defined(SQLITE_UNIX_THREADS)
|
#if SQLITE_THREADSAFE
|
||||||
# define SET_THREADID(X) (X)->tid = pthread_self()
|
# define SET_THREADID(X) (X)->tid = pthread_self()
|
||||||
# define CHECK_THREADID(X) (threadsOverrideEachOthersLocks==0 && \
|
# define CHECK_THREADID(X) (threadsOverrideEachOthersLocks==0 && \
|
||||||
!pthread_equal((X)->tid, pthread_self()))
|
!pthread_equal((X)->tid, pthread_self()))
|
||||||
@@ -293,7 +290,7 @@ struct unixFile {
|
|||||||
struct lockKey {
|
struct lockKey {
|
||||||
dev_t dev; /* Device number */
|
dev_t dev; /* Device number */
|
||||||
ino_t ino; /* Inode number */
|
ino_t ino; /* Inode number */
|
||||||
#ifdef SQLITE_UNIX_THREADS
|
#if SQLITE_THREADSAFE
|
||||||
pthread_t tid; /* Thread ID or zero if threads can override each other */
|
pthread_t tid; /* Thread ID or zero if threads can override each other */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -383,7 +380,7 @@ static void leaveMutex(){
|
|||||||
sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL));
|
sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE_UNIX_THREADS
|
#if SQLITE_THREADSAFE
|
||||||
/*
|
/*
|
||||||
** This variable records whether or not threads can override each others
|
** This variable records whether or not threads can override each others
|
||||||
** locks.
|
** locks.
|
||||||
@@ -520,7 +517,7 @@ static void testThreadLockingBehavior(int fd_orig){
|
|||||||
close(fd);
|
close(fd);
|
||||||
threadsOverrideEachOthersLocks = d[0].result==0 && d[1].result==0;
|
threadsOverrideEachOthersLocks = d[0].result==0 && d[1].result==0;
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_UNIX_THREADS */
|
#endif /* SQLITE_THREADSAFE */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Release a lockInfo structure previously allocated by findLockInfo().
|
** Release a lockInfo structure previously allocated by findLockInfo().
|
||||||
@@ -648,7 +645,7 @@ static int findLockInfo(
|
|||||||
memset(&key1, 0, sizeof(key1));
|
memset(&key1, 0, sizeof(key1));
|
||||||
key1.dev = statbuf.st_dev;
|
key1.dev = statbuf.st_dev;
|
||||||
key1.ino = statbuf.st_ino;
|
key1.ino = statbuf.st_ino;
|
||||||
#ifdef SQLITE_UNIX_THREADS
|
#if SQLITE_THREADSAFE
|
||||||
if( threadsOverrideEachOthersLocks<0 ){
|
if( threadsOverrideEachOthersLocks<0 ){
|
||||||
testThreadLockingBehavior(fd);
|
testThreadLockingBehavior(fd);
|
||||||
}
|
}
|
||||||
@@ -744,7 +741,7 @@ static const char *locktypeName(int locktype){
|
|||||||
** If the unixFile is locked and an ownership is wrong, then return
|
** If the unixFile is locked and an ownership is wrong, then return
|
||||||
** SQLITE_MISUSE. SQLITE_OK is returned if everything works.
|
** SQLITE_MISUSE. SQLITE_OK is returned if everything works.
|
||||||
*/
|
*/
|
||||||
#ifdef SQLITE_UNIX_THREADS
|
#if SQLITE_THREADSAFE
|
||||||
static int transferOwnership(unixFile *pFile){
|
static int transferOwnership(unixFile *pFile){
|
||||||
int rc;
|
int rc;
|
||||||
pthread_t hSelf;
|
pthread_t hSelf;
|
||||||
@@ -2717,7 +2714,6 @@ sqlite3_vfs sqlite3DefaultVfs = {
|
|||||||
0, /* nRef */
|
0, /* nRef */
|
||||||
0, /* vfsMutex */
|
0, /* vfsMutex */
|
||||||
0, /* pNext */
|
0, /* pNext */
|
||||||
0, /* pPrev */
|
|
||||||
"unix", /* zName */
|
"unix", /* zName */
|
||||||
0, /* pAppData */
|
0, /* pAppData */
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
** Random numbers are used by some of the database backends in order
|
** Random numbers are used by some of the database backends in order
|
||||||
** to generate random integer keys for tables or random filenames.
|
** to generate random integer keys for tables or random filenames.
|
||||||
**
|
**
|
||||||
** $Id: random.c,v 1.17 2007/08/17 15:53:37 danielk1977 Exp $
|
** $Id: random.c,v 1.18 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -63,7 +63,7 @@ static int randomByte(void){
|
|||||||
char k[256];
|
char k[256];
|
||||||
prng.j = 0;
|
prng.j = 0;
|
||||||
prng.i = 0;
|
prng.i = 0;
|
||||||
sqlite3OsRandomness(sqlite3_find_vfs(0), 256, k);
|
sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);
|
||||||
for(i=0; i<256; i++){
|
for(i=0; i<256; i++){
|
||||||
prng.s[i] = i;
|
prng.s[i] = i;
|
||||||
}
|
}
|
||||||
|
@@ -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.230 2007/08/18 10:59:21 danielk1977 Exp $
|
** @(#) $Id: sqlite.h.in,v 1.231 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE3_H_
|
#ifndef _SQLITE3_H_
|
||||||
#define _SQLITE3_H_
|
#define _SQLITE3_H_
|
||||||
@@ -548,7 +548,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
|
|||||||
** 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 and pPrev pointers. 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_find_vfs()] searches the
|
** in a thread-safe way. The [sqlite3_acquire_vfs()] searches the
|
||||||
** list.
|
** 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
|
||||||
@@ -636,7 +636,6 @@ struct sqlite3_vfs {
|
|||||||
int nRef; /* Number of references to this structure */
|
int nRef; /* Number of references to this structure */
|
||||||
sqlite3_mutex *vfsMutex; /* A mutex for this VFS */
|
sqlite3_mutex *vfsMutex; /* A mutex for this VFS */
|
||||||
sqlite3_vfs *pNext; /* Next registered VFS */
|
sqlite3_vfs *pNext; /* Next registered VFS */
|
||||||
sqlite3_vfs *pPrev; /* Previous 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)(void *pAppData, const char *zName, sqlite3_file*,
|
||||||
@@ -859,6 +858,13 @@ int sqlite3_complete16(const void *sql);
|
|||||||
** connection. Setting a new busy handler clears any previous one.
|
** connection. Setting a new busy handler clears any previous one.
|
||||||
** Note that calling [sqlite3_busy_timeout()] will also set or clear
|
** Note that calling [sqlite3_busy_timeout()] will also set or clear
|
||||||
** the busy handler.
|
** the busy handler.
|
||||||
|
**
|
||||||
|
** When operating in [sqlite3_enable_shared_cache | shared cache mode],
|
||||||
|
** only a single busy handler can be defined for each database file.
|
||||||
|
** So if two database connections share a single cache, then changing
|
||||||
|
** the busy handler on one connection will also change the busy
|
||||||
|
** handler in the other connection. The busy handler is invoked
|
||||||
|
** in the thread that was running when the SQLITE_BUSY was hit.
|
||||||
*/
|
*/
|
||||||
int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
|
int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
|
||||||
|
|
||||||
@@ -3162,24 +3168,28 @@ int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
|
|||||||
** New VFSes can be registered and existing VFSes can be unregistered.
|
** New VFSes can be registered and existing VFSes can be unregistered.
|
||||||
** The following interfaces are provided.
|
** The following interfaces are provided.
|
||||||
**
|
**
|
||||||
** The sqlite3_find_vfs() interface returns a pointer to a VFS given its
|
** The sqlite3_vfs_find() interface returns a pointer to a VFS given its
|
||||||
** name. Names are case sensitive. If there is no match, a NULL
|
** name. Names are case sensitive. If there is no match, a NULL
|
||||||
** pointer is returned. If zVfsName is NULL then the default
|
** pointer is returned. If zVfsName is NULL then the default
|
||||||
** VFS is returned.
|
** VFS is returned. If a valid VFS pointer is returned, its
|
||||||
|
** vfsMutex field will have been initialized and nRef will be
|
||||||
|
** greater than zero. The sqlite3_vfs_release() function should
|
||||||
|
** be used to release the VFS when it is no longer needed.
|
||||||
**
|
**
|
||||||
** New VFSes are registered with sqlite3_register_vfs(). Each
|
** New VFSes are registered with sqlite3_vfs_register(). Each
|
||||||
** new VFS becomes the default VFS if the makeDflt flag is set.
|
** new VFS becomes the default VFS if the makeDflt flag is set.
|
||||||
** The same VFS can be registered multiple times without injury.
|
** The same VFS can be registered multiple times without injury.
|
||||||
** To make an existing VFS into the default VFS, register it again
|
** To make an existing VFS into the default VFS, register it again
|
||||||
** with the makeDflt flag set.
|
** with the makeDflt flag set.
|
||||||
**
|
**
|
||||||
** Unregister a VFS with the sqlite3_unregister_vfs() interface.
|
** Unregister a VFS with the sqlite3_vfs_unregister() interface.
|
||||||
** If the default VFS is unregistered, another VFS is chosen as
|
** If the default VFS is unregistered, another VFS is chosen as
|
||||||
** the default. The choice for the new VFS is arbitrary.
|
** the default. The choice for the new VFS is arbitrary.
|
||||||
*/
|
*/
|
||||||
sqlite3_vfs *sqlite3_find_vfs(const char *zVfsName);
|
sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
|
||||||
int sqlite3_register_vfs(sqlite3_vfs*, int makeDflt);
|
int sqlite3_vfs_release(sqlite3_vfs*);
|
||||||
int sqlite3_unregister_vfs(sqlite3_vfs*);
|
int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
|
||||||
|
int sqlite3_vfs_unregister(sqlite3_vfs*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Mutexes
|
** CAPI3REF: Mutexes
|
||||||
@@ -3273,12 +3283,33 @@ int sqlite3_unregister_vfs(sqlite3_vfs*);
|
|||||||
** previously entered by the same thread. The behavior
|
** previously entered by the same thread. The behavior
|
||||||
** is undefined if the mutex is not currently entered or
|
** is undefined if the mutex is not currently entered or
|
||||||
** is not currently allocated. SQLite will never do either.
|
** is not currently allocated. SQLite will never do either.
|
||||||
|
**
|
||||||
|
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
|
||||||
|
** are intended for use inside assert() statements. They should
|
||||||
|
** return true if the mutex in their argument is held or not held,
|
||||||
|
** respectively, by the current thread. The implementation is
|
||||||
|
** not required to provided working implementations of these
|
||||||
|
** routines as their intended use is within assert() statements
|
||||||
|
** only. If the implementation does not provide working
|
||||||
|
** versions of these routines, it must at least provide stubs
|
||||||
|
** that always return true.
|
||||||
|
**
|
||||||
|
** If the argument to sqlite3_mutex_held() is a NULL pointer then
|
||||||
|
** the routine should return 1. This seems counter-intuitive since
|
||||||
|
** clearly the mutex cannot be held if it does not exist. But the
|
||||||
|
** the reason the mutex does not exist is because the build is not
|
||||||
|
** using mutexes. And we do not want the assert() containing the
|
||||||
|
** call to sqlite3_mutex_held() to fail, so a non-zero return is
|
||||||
|
** the appropriate thing to do. The sqlite3_mutex_notheld()
|
||||||
|
** interface should also return 1 when given a NULL pointer.
|
||||||
*/
|
*/
|
||||||
sqlite3_mutex *sqlite3_mutex_alloc(int);
|
sqlite3_mutex *sqlite3_mutex_alloc(int);
|
||||||
void sqlite3_mutex_free(sqlite3_mutex*);
|
void sqlite3_mutex_free(sqlite3_mutex*);
|
||||||
void sqlite3_mutex_enter(sqlite3_mutex*);
|
void sqlite3_mutex_enter(sqlite3_mutex*);
|
||||||
int sqlite3_mutex_try(sqlite3_mutex*);
|
int sqlite3_mutex_try(sqlite3_mutex*);
|
||||||
void sqlite3_mutex_leave(sqlite3_mutex*);
|
void sqlite3_mutex_leave(sqlite3_mutex*);
|
||||||
|
int sqlite3_mutex_held(sqlite3_mutex*);
|
||||||
|
int sqlite3_mutex_notheld(sqlite3_mutex*);
|
||||||
#define SQLITE_MUTEX_FAST 0
|
#define SQLITE_MUTEX_FAST 0
|
||||||
#define SQLITE_MUTEX_RECURSIVE 1
|
#define SQLITE_MUTEX_RECURSIVE 1
|
||||||
#define SQLITE_MUTEX_STATIC_MASTER 2
|
#define SQLITE_MUTEX_STATIC_MASTER 2
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.592 2007/08/20 14:23:44 danielk1977 Exp $
|
** @(#) $Id: sqliteInt.h,v 1.593 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITEINT_H_
|
#ifndef _SQLITEINT_H_
|
||||||
#define _SQLITEINT_H_
|
#define _SQLITEINT_H_
|
||||||
@@ -33,6 +33,19 @@
|
|||||||
# define NDEBUG 1
|
# define NDEBUG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The SQLITE_THREADSAFE macro must be defined as either 0 or 1.
|
||||||
|
** Older versions of SQLite used an optional THREADSAFE macro.
|
||||||
|
** We support that for legacy
|
||||||
|
*/
|
||||||
|
#if !defined(SQLITE_THREADSAFE)
|
||||||
|
#if defined(THREADSAFE)
|
||||||
|
# define SQLITE_THREADSAFE THREADSAFE
|
||||||
|
#else
|
||||||
|
# define SQLTIE_THREADSAFE 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** These #defines should enable >2GB file support on Posix if the
|
** These #defines should enable >2GB file support on Posix if the
|
||||||
** underlying operating system supports it. If the OS lacks
|
** underlying operating system supports it. If the OS lacks
|
||||||
@@ -399,7 +412,7 @@ struct sqlite3 {
|
|||||||
int magic; /* Magic number for detect library misuse */
|
int magic; /* Magic number for detect library misuse */
|
||||||
int nChange; /* Value returned by sqlite3_changes() */
|
int nChange; /* Value returned by sqlite3_changes() */
|
||||||
int nTotalChange; /* Value returned by sqlite3_total_changes() */
|
int nTotalChange; /* Value returned by sqlite3_total_changes() */
|
||||||
sqlite3_mutex *pMutex; /* Connection mutex */
|
sqlite3_mutex *mutex; /* Connection mutex */
|
||||||
struct sqlite3InitInfo { /* Information used during initialization */
|
struct sqlite3InitInfo { /* Information used during initialization */
|
||||||
int iDb; /* When back is being initialized */
|
int iDb; /* When back is being initialized */
|
||||||
int newTnum; /* Rootpage of table being initialized */
|
int newTnum; /* Rootpage of table being initialized */
|
||||||
@@ -1818,10 +1831,17 @@ void sqlite3Parser(void*, int, Token, Parse*);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** FIX ME: create these routines
|
** The MallocDisallow() and MallocAllow() routines are like asserts.
|
||||||
|
** Call them around a section of code that you do not expect to do
|
||||||
|
** any memory allocation.
|
||||||
*/
|
*/
|
||||||
#define sqlite3MallocDisallow()
|
#ifdef SQLITE_MEMDEBUG
|
||||||
#define sqlite3MallocAllow()
|
void sqlite3MallocDisallow(void);
|
||||||
|
void sqlite3MallocAllow(void);
|
||||||
|
#else
|
||||||
|
# define sqlite3MallocDisallow()
|
||||||
|
# define sqlite3MallocAllow()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef SQLITE_OMIT_VIRTUALTABLE
|
#ifdef SQLITE_OMIT_VIRTUALTABLE
|
||||||
@@ -1850,7 +1870,6 @@ void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
|
|||||||
int sqlite3Reprepare(Vdbe*);
|
int sqlite3Reprepare(Vdbe*);
|
||||||
void sqlite3ExprListCheckLength(Parse*, ExprList*, int, const char*);
|
void sqlite3ExprListCheckLength(Parse*, ExprList*, int, const char*);
|
||||||
CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
|
CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
|
||||||
int sqlite3CrashFileOpen(sqlite3_vfs*, const char*, sqlite3_file*, int,int*);
|
|
||||||
|
|
||||||
#if SQLITE_MAX_EXPR_DEPTH>0
|
#if SQLITE_MAX_EXPR_DEPTH>0
|
||||||
void sqlite3ExprSetHeight(Expr *);
|
void sqlite3ExprSetHeight(Expr *);
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test1.c,v 1.264 2007/08/17 15:53:37 danielk1977 Exp $
|
** $Id: test1.c,v 1.265 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@@ -4330,7 +4330,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
|||||||
extern int sqlite3_pager_writedb_count;
|
extern int sqlite3_pager_writedb_count;
|
||||||
extern int sqlite3_pager_writej_count;
|
extern int sqlite3_pager_writej_count;
|
||||||
extern int sqlite3_pager_pgfree_count;
|
extern int sqlite3_pager_pgfree_count;
|
||||||
#if OS_UNIX && defined(SQLITE_TEST) && defined(THREADSAFE) && THREADSAFE
|
#if OS_UNIX && defined(SQLITE_TEST) && SQLITE_THREADSAFE
|
||||||
extern int threadsOverrideEachOthersLocks;
|
extern int threadsOverrideEachOthersLocks;
|
||||||
#endif
|
#endif
|
||||||
#if OS_WIN
|
#if OS_WIN
|
||||||
@@ -4380,7 +4380,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
|||||||
Tcl_LinkVar(interp, "unaligned_string_counter",
|
Tcl_LinkVar(interp, "unaligned_string_counter",
|
||||||
(char*)&unaligned_string_counter, TCL_LINK_INT);
|
(char*)&unaligned_string_counter, TCL_LINK_INT);
|
||||||
#endif
|
#endif
|
||||||
#if OS_UNIX && defined(SQLITE_TEST) && defined(THREADSAFE) && THREADSAFE
|
#if OS_UNIX && defined(SQLITE_TEST) && SQLITE_THREADSAFE
|
||||||
Tcl_LinkVar(interp, "threadsOverrideEachOthersLocks",
|
Tcl_LinkVar(interp, "threadsOverrideEachOthersLocks",
|
||||||
(char*)&threadsOverrideEachOthersLocks, TCL_LINK_INT);
|
(char*)&threadsOverrideEachOthersLocks, TCL_LINK_INT);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test2.c,v 1.48 2007/08/20 14:23:44 danielk1977 Exp $
|
** $Id: test2.c,v 1.49 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -78,7 +78,7 @@ static int pager_open(
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
|
if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
|
||||||
rc = sqlite3PagerOpen(sqlite3_find_vfs(0), &pPager, argv[1], 0, 0);
|
rc = sqlite3PagerOpen(sqlite3_vfs_find(0), &pPager, argv[1], 0, 0);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
@@ -540,7 +540,7 @@ static int fake_big_file(
|
|||||||
}
|
}
|
||||||
if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;
|
if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;
|
||||||
|
|
||||||
pVfs = sqlite3_find_vfs(0);
|
pVfs = sqlite3_vfs_find(0);
|
||||||
rc = sqlite3OsOpenMalloc(pVfs, argv[2], &fd,
|
rc = sqlite3OsOpenMalloc(pVfs, argv[2], &fd,
|
||||||
(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB), 0
|
(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB), 0
|
||||||
);
|
);
|
||||||
|
@@ -11,12 +11,12 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Code for testing the the SQLite library in a multithreaded environment.
|
** Code for testing the the SQLite library in a multithreaded environment.
|
||||||
**
|
**
|
||||||
** $Id: test4.c,v 1.18 2007/08/16 04:30:40 drh Exp $
|
** $Id: test4.c,v 1.19 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#if defined(OS_UNIX) && OS_UNIX==1 && defined(THREADSAFE) && THREADSAFE==1
|
#if defined(OS_UNIX) && OS_UNIX==1 && SQLITE_THREADSAFE
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
30
src/test6.c
30
src/test6.c
@@ -451,6 +451,14 @@ static const sqlite3_io_methods CrashFileVtab = {
|
|||||||
cfDeviceCharacteristics /* xDeviceCharacteristics */
|
cfDeviceCharacteristics /* xDeviceCharacteristics */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Application data for the crash VFS
|
||||||
|
*/
|
||||||
|
struct crashAppData {
|
||||||
|
int (*xOpen)(void*,const char*,sqlite3_file*,int,int*); /* Original xOpen */
|
||||||
|
void *pAppData; /* Original pAppData */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Open a crash-file file handle. The vfs pVfs is used to open
|
** Open a crash-file file handle. The vfs pVfs is used to open
|
||||||
** the underlying real file.
|
** the underlying real file.
|
||||||
@@ -461,7 +469,7 @@ static const sqlite3_io_methods CrashFileVtab = {
|
|||||||
** sqlite3_malloc(). The assumption here is (pVfs->szOsFile) is
|
** sqlite3_malloc(). The assumption here is (pVfs->szOsFile) is
|
||||||
** equal or greater than sizeof(CrashFile).
|
** equal or greater than sizeof(CrashFile).
|
||||||
*/
|
*/
|
||||||
int sqlite3CrashFileOpen(
|
static int sqlite3CrashFileOpen(
|
||||||
sqlite3_vfs *pVfs,
|
sqlite3_vfs *pVfs,
|
||||||
const char *zName,
|
const char *zName,
|
||||||
sqlite3_file *pFile,
|
sqlite3_file *pFile,
|
||||||
@@ -499,7 +507,8 @@ int sqlite3CrashFileOpen(
|
|||||||
sqlite3OsClose(pFile);
|
sqlite3OsClose(pFile);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
rc = pVfs->xOpen(pVfs->pAppData, zName, pFile, flags, pOutFlags);
|
struct crashAppData *pData = (struct crashAppData*)pVfs->pAppData;
|
||||||
|
rc = pData->xOpen(pData->pAppData, zName, pFile, flags, pOutFlags);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -528,11 +537,26 @@ static int crashParamsObjCmd(
|
|||||||
int objc,
|
int objc,
|
||||||
Tcl_Obj *CONST objv[]
|
Tcl_Obj *CONST objv[]
|
||||||
){
|
){
|
||||||
sqlite3_vfs *pVfs;
|
|
||||||
int i;
|
int i;
|
||||||
int iDelay;
|
int iDelay;
|
||||||
const char *zCrashFile;
|
const char *zCrashFile;
|
||||||
int nCrashFile;
|
int nCrashFile;
|
||||||
|
static sqlite3_vfs crashVfs, *pOriginalVfs;
|
||||||
|
static struct crashAppData appData;
|
||||||
|
|
||||||
|
if( pOriginalVfs==0 ){
|
||||||
|
pOriginalVfs = sqlite3_vfs_find(0);
|
||||||
|
crashVfs = *pOriginalVfs;
|
||||||
|
crashVfs.xOpen = sqlite3CrashFileOpen;
|
||||||
|
crashVfs.vfsMutex = 0;
|
||||||
|
crashVfs.nRef = 0;
|
||||||
|
crashVfs.pAppData = &appData;
|
||||||
|
appData.xOpen = pOriginalVfs->xOpen;
|
||||||
|
appData.pAppData = pOriginalVfs->pAppData;
|
||||||
|
sqlite3_vfs_release(pOriginalVfs);
|
||||||
|
sqlite3_vfs_unregister(pOriginalVfs);
|
||||||
|
sqlite3_vfs_register(&crashVfs, 1);
|
||||||
|
}
|
||||||
|
|
||||||
int iDc = 0;
|
int iDc = 0;
|
||||||
int iSectorSize = 0;
|
int iSectorSize = 0;
|
||||||
|
@@ -12,17 +12,17 @@
|
|||||||
** Code for testing the client/server version of the SQLite library.
|
** Code for testing the client/server version of the SQLite library.
|
||||||
** Derived from test4.c.
|
** Derived from test4.c.
|
||||||
**
|
**
|
||||||
** $Id: test7.c,v 1.5 2007/08/16 04:30:40 drh Exp $
|
** $Id: test7.c,v 1.6 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This test only works on UNIX with a THREADSAFE build that includes
|
** This test only works on UNIX with a SQLITE_THREADSAFE build that includes
|
||||||
** the SQLITE_SERVER option.
|
** the SQLITE_SERVER option.
|
||||||
*/
|
*/
|
||||||
#if OS_UNIX && defined(THREADSAFE) && THREADSAFE==1 && \
|
#if OS_UNIX && SQLITE_THREADSAFE && \
|
||||||
defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE)
|
defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE)
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@@ -74,11 +74,6 @@
|
|||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include <tcl.h>
|
#include <tcl.h>
|
||||||
|
|
||||||
/* If the THREADSAFE macro is not set, assume that it is turned off. */
|
|
||||||
#ifndef THREADSAFE
|
|
||||||
# define THREADSAFE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This test uses pthreads and hence only works on unix and with
|
** This test uses pthreads and hence only works on unix and with
|
||||||
** a threadsafe build of SQLite. It also requires that the redefinable
|
** a threadsafe build of SQLite. It also requires that the redefinable
|
||||||
@@ -86,7 +81,7 @@
|
|||||||
** default. If a required element is missing, almost all of the code
|
** default. If a required element is missing, almost all of the code
|
||||||
** in this file is commented out.
|
** in this file is commented out.
|
||||||
*/
|
*/
|
||||||
#if OS_UNIX && THREADSAFE && defined(SQLITE_ENABLE_REDEF_IO)
|
#if OS_UNIX && SQLITE_THREADSAFE && defined(SQLITE_ENABLE_REDEF_IO)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This demo uses pthreads. If you do not have a pthreads implementation
|
** This demo uses pthreads. If you do not have a pthreads implementation
|
||||||
@@ -1249,7 +1244,7 @@ static int testAsyncWait(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* OS_UNIX and THREADSAFE and defined(SQLITE_ENABLE_REDEF_IO) */
|
#endif /* OS_UNIX and SQLITE_THREADSAFE and defined(SQLITE_ENABLE_REDEF_IO) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This routine registers the custom TCL commands defined in this
|
** This routine registers the custom TCL commands defined in this
|
||||||
@@ -1257,7 +1252,7 @@ static int testAsyncWait(
|
|||||||
** of this module.
|
** of this module.
|
||||||
*/
|
*/
|
||||||
int Sqlitetestasync_Init(Tcl_Interp *interp){
|
int Sqlitetestasync_Init(Tcl_Interp *interp){
|
||||||
#if OS_UNIX && THREADSAFE && defined(SQLITE_ENABLE_REDEF_IO)
|
#if OS_UNIX && SQLITE_THREADSAFE && defined(SQLITE_ENABLE_REDEF_IO)
|
||||||
Tcl_CreateObjCommand(interp,"sqlite3async_enable",testAsyncEnable,0,0);
|
Tcl_CreateObjCommand(interp,"sqlite3async_enable",testAsyncEnable,0,0);
|
||||||
Tcl_CreateObjCommand(interp,"sqlite3async_halt",testAsyncHalt,0,0);
|
Tcl_CreateObjCommand(interp,"sqlite3async_halt",testAsyncHalt,0,0);
|
||||||
Tcl_CreateObjCommand(interp,"sqlite3async_delay",testAsyncDelay,0,0);
|
Tcl_CreateObjCommand(interp,"sqlite3async_delay",testAsyncDelay,0,0);
|
||||||
@@ -1265,6 +1260,6 @@ int Sqlitetestasync_Init(Tcl_Interp *interp){
|
|||||||
Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0);
|
Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0);
|
||||||
Tcl_LinkVar(interp, "sqlite3async_trace",
|
Tcl_LinkVar(interp, "sqlite3async_trace",
|
||||||
(char*)&sqlite3async_trace, TCL_LINK_INT);
|
(char*)&sqlite3async_trace, TCL_LINK_INT);
|
||||||
#endif /* OS_UNIX and THREADSAFE and defined(SQLITE_ENABLE_REDEF_IO) */
|
#endif /* OS_UNIX and SQLITE_THREADSAFE and defined(SQLITE_ENABLE_REDEF_IO) */
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
** The focus of this file is providing the TCL testing layer
|
** The focus of this file is providing the TCL testing layer
|
||||||
** access to compile-time constants.
|
** access to compile-time constants.
|
||||||
**
|
**
|
||||||
** $Id: test_config.c,v 1.8 2007/08/20 17:37:48 shess Exp $
|
** $Id: test_config.c,v 1.9 2007/08/20 22:48:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@@ -197,12 +197,6 @@ static void set_options(Tcl_Interp *interp){
|
|||||||
Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY);
|
Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SQLITE_ENABLE_FTS3
|
|
||||||
Tcl_SetVar2(interp, "sqlite_options", "fts3", "1", TCL_GLOBAL_ONLY);
|
|
||||||
#else
|
|
||||||
Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SQLITE_OMIT_GLOBALRECOVER
|
#ifdef SQLITE_OMIT_GLOBALRECOVER
|
||||||
Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "0", TCL_GLOBAL_ONLY);
|
Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "0", TCL_GLOBAL_ONLY);
|
||||||
#else
|
#else
|
||||||
@@ -334,7 +328,7 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
|
|||||||
Tcl_SetVar2(interp, "sqlite_options", "tclvar", "1", TCL_GLOBAL_ONLY);
|
Tcl_SetVar2(interp, "sqlite_options", "tclvar", "1", TCL_GLOBAL_ONLY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(THREADSAFE) && THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "1", TCL_GLOBAL_ONLY);
|
Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "1", TCL_GLOBAL_ONLY);
|
||||||
#else
|
#else
|
||||||
Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "0", TCL_GLOBAL_ONLY);
|
Tcl_SetVar2(interp, "sqlite_options", "threadsafe", "0", TCL_GLOBAL_ONLY);
|
||||||
|
@@ -197,11 +197,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Only compile the code in this file on UNIX with a THREADSAFE build
|
** Only compile the code in this file on UNIX with a SQLITE_THREADSAFE build
|
||||||
** and only if the SQLITE_SERVER macro is defined.
|
** and only if the SQLITE_SERVER macro is defined.
|
||||||
*/
|
*/
|
||||||
#if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE)
|
#if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE)
|
||||||
#if defined(OS_UNIX) && OS_UNIX && defined(THREADSAFE) && THREADSAFE
|
#if defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** We require only pthreads and the public interface of SQLite.
|
** We require only pthreads and the public interface of SQLite.
|
||||||
@@ -483,5 +483,5 @@ void sqlite3_server_stop(void){
|
|||||||
pthread_mutex_unlock(&g.serverMutex);
|
pthread_mutex_unlock(&g.serverMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined(OS_UNIX) && OS_UNIX && defined(THREADSAFE) && THREADSAFE */
|
#endif /* defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE */
|
||||||
#endif /* defined(SQLITE_SERVER) */
|
#endif /* defined(SQLITE_SERVER) */
|
||||||
|
Reference in New Issue
Block a user