Add experimental sqlite3_reconfig() interface to more fully support the SQLITE_CONFIG_READONLY option.

FossilOrigin-Name: 9dc2eaa64b6a9f69bd6f3ff28de2c97682a69e0a
This commit is contained in:
mistachkin
2012-10-03 20:20:15 +00:00
parent 8ea1fb415b
commit 9737c49e27
6 changed files with 77 additions and 28 deletions
+9 -9
View File
@@ -1,5 +1,5 @@
C Merge\supdates\sfrom\strunk.
D 2012-09-25T12:45:03.240
C Add\sexperimental\ssqlite3_reconfig()\sinterface\sto\smore\sfully\ssupport\sthe\sSQLITE_CONFIG_READONLY\soption.
D 2012-10-03T20:20:15.903
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416
F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d
F src/main.c aa1b70eb184c62be0e57939223f49616fa330c6f
F src/main.c e538e0d91faf92a163bebb3d7e3183be92a99e78
F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa
@@ -176,7 +176,7 @@ F src/resolve.c 9e28280ec98035f31900fdd1db01f86f68ca6c32
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 1fad66b73a69c4004c9969a95b46d1f03390677d
F src/shell.c 8ee5a3cb502e2d574f97b43972e6c1e275e7bec7
F src/sqlite.h.in 360dadb3a8e24011349cfe45406a313657cc964c
F src/sqlite.h.in 7a8c818775136fa20f8cd5d2a5ab2e15723f375f
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
F src/sqliteInt.h a07fdc863510639b287d0721ba16a8d130af2c3e
@@ -208,7 +208,7 @@ F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99
F src/test_intarray.h 489edb9068bb926583445cb02589344961054207
F src/test_journal.c f5c0a05b7b3d5930db769b5ee6c3766dc2221a64
F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
F src/test_malloc.c 3f25943939e8ec73fa5de60744f93381e138a126
F src/test_malloc.c b813ffd7e62f5abe2f69cbe94ee3519f77147341
F src/test_multiplex.c ac0fbc1748e5b86a41a1d7a84654fae0d53a881d
F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d
F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e
@@ -633,7 +633,7 @@ F test/notify2.test 9503e51b9a272a5405c205ad61b7623d5a9ca489
F test/notify3.test a86259abbfb923aa27d30f0fc038c88e5251488a
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test d1dbebe1573a440dc4a4bd6b7e6125272a0ec56b
F test/openv2.test 74c994537a13c7e31982d597eab555491133cee4
F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
F test/pager1.test 2163c6ef119f497a71a84137c957c63763e640ab
F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
@@ -1016,7 +1016,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
P 7c3401657a0410dd121d49742db102c6e7494964 349a55cd8ba9ce65ebfd987ecfebd1204f7d0a85
R ed3fa0fcbd93fed891c622a4358fe97e
P 4a470741b65938dd38418c9c1a6e87dad6a84fc7
R 3a95b597f4b95f489ae5426e808d1d1a
U mistachkin
Z d5df0a65995ef30255cb29bc68e328f8
Z 77430a21fa898fed0cc20a439fb47dc9
+1 -1
View File
@@ -1 +1 @@
4a470741b65938dd38418c9c1a6e87dad6a84fc7
9dc2eaa64b6a9f69bd6f3ff28de2c97682a69e0a
+34
View File
@@ -494,6 +494,40 @@ int sqlite3_config(int op, ...){
return rc;
}
/*
** This API allows applications to modify the global configuration of
** the SQLite library at run-time.
**
** This routine differs from sqlite3_config() in that it may be called when
** there are outstanding database connections and/or memory allocations.
** This routine is threadsafe.
*/
int sqlite3_reconfig(int op, ...){
va_list ap;
int rc = SQLITE_OK;
va_start(ap, op);
switch( op ){
case SQLITE_CONFIG_READONLY: {
/*
** On platforms where assignment of an integer value is atomic, there
** is no need for a mutex here. On other platforms, there could be a
** subtle race condition here; however, the effect would simply be that
** a call to open a database would fail with SQLITE_READONLY.
*/
sqlite3GlobalConfig.bReadOnly = va_arg(ap, int);
break;
}
default: {
rc = SQLITE_ERROR;
break;
}
}
va_end(ap);
return rc;
}
/*
** Set up the lookaside buffers for a database connection.
** Return SQLITE_OK on success.
+15 -9
View File
@@ -1223,11 +1223,11 @@ int sqlite3_os_end(void);
/*
** CAPI3REF: Configuring The SQLite Library
**
** The sqlite3_config() interface is used to make global configuration
** changes to SQLite in order to tune SQLite to the specific needs of
** the application. The default configuration is recommended for most
** applications and so this routine is usually not necessary. It is
** provided to support rare applications with unusual needs.
** The sqlite3_config() and sqlite3_reconfig() interfaces are used to make
** global configuration changes to SQLite in order to tune SQLite to the
** specific needs of the application. The default configuration is recommended
** for most applications and so this routine is usually not necessary. They
** are provided to support rare applications with unusual needs.
**
** The sqlite3_config() interface is not threadsafe. The application
** must insure that no other SQLite interfaces are invoked by other
@@ -1239,17 +1239,23 @@ int sqlite3_os_end(void);
** Note, however, that ^sqlite3_config() can be called as part of the
** implementation of an application-defined [sqlite3_os_init()].
**
** The first argument to sqlite3_config() is an integer
** [configuration option] that determines
** The sqlite3_reconfig() interface is threadsafe and may be called at any
** time. However, it supports only a small subset of the configuration
** options available for use with sqlite3_config().
**
** The first argument to both sqlite3_config() and sqlite3_reconfig() is an
** integer [configuration option] that determines
** what property of SQLite is to be configured. Subsequent arguments
** vary depending on the [configuration option]
** in the first argument.
**
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
** ^When a configuration option is set, both sqlite3_config() and
** sqlite3_reconfig() return [SQLITE_OK].
** ^If the option is unknown or SQLite is unable to set the option
** then this routine returns a non-zero [error code].
** then these routines returns a non-zero [error code].
*/
int sqlite3_config(int, ...);
int sqlite3_reconfig(int, ...);
/*
** CAPI3REF: Configure database connections
+16 -1
View File
@@ -1228,6 +1228,7 @@ static int test_config_cis(
/*
** Usage: sqlite3_config_readonly BOOLEAN
** sqlite3_reconfig_readonly BOOLEAN
**
** Enables or disables global read-only mode using SQLITE_CONFIG_READONLY.
*/
@@ -1248,7 +1249,20 @@ static int test_config_readonly(
return TCL_ERROR;
}
rc = sqlite3_config(SQLITE_CONFIG_READONLY, bReadOnly);
switch( SQLITE_PTR_TO_INT(clientData) ){
case 0: {
rc = sqlite3_config(SQLITE_CONFIG_READONLY, bReadOnly);
break;
}
case 1: {
rc = sqlite3_reconfig(SQLITE_CONFIG_READONLY, bReadOnly);
break;
}
default: {
rc = SQLITE_ERROR;
break;
}
}
Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
return TCL_OK;
@@ -1506,6 +1520,7 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){
{ "sqlite3_config_uri", test_config_uri ,0 },
{ "sqlite3_config_cis", test_config_cis ,0 },
{ "sqlite3_config_readonly", test_config_readonly ,0 },
{ "sqlite3_reconfig_readonly", test_config_readonly ,1 },
{ "sqlite3_db_config_lookaside",test_db_config_lookaside ,0 },
{ "sqlite3_dump_memsys3", test_dump_memsys3 ,3 },
{ "sqlite3_dump_memsys5", test_dump_memsys3 ,5 },
+2 -8
View File
@@ -56,10 +56,7 @@ do_test openv2-2.2 {
# SQLITE_CONFIG_READONLY flag is enabled.
#
db close
sqlite3_shutdown
sqlite3_config_readonly 1
sqlite3_initialize
autoinstall_test_functions
sqlite3_reconfig_readonly 1
do_test openv2-3.1 {
list [catch {sqlite3 db :memory:} msg] $msg
@@ -86,8 +83,5 @@ do_test openv2-3.6 {
} {1 {attempt to write a readonly database}}
catch {db close}
sqlite3_shutdown
sqlite3_config_readonly 0
sqlite3_initialize
autoinstall_test_functions
sqlite3_reconfig_readonly 0
finish_test