Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88bdfb7201 | |||
| 3ae6c4f569 | |||
| 002bc1a34f | |||
| 50daa90ad5 | |||
| a8a2f51018 | |||
| ce49cf9c0a | |||
| b14fb28c4f | |||
| 9737c49e27 | |||
| 8ea1fb415b | |||
| e4df1b8175 |
@@ -1,5 +1,5 @@
|
||||
C Do\snot\sraise\san\serror\sif\san\sunknown\sSQL\sfunction\sis\sfound\sin\sa\sCHECK\nconstraint\swhile\sparsing\sthe\sschema\sof\san\sexisting\sdatabase.
|
||||
D 2013-01-08T12:48:10.683
|
||||
C Merge\supdates\sfrom\strunk.
|
||||
D 2013-01-08T17:24:25.899
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -134,7 +134,7 @@ F src/expr.c 4dff0b04eaaf133789279c6b8cd69175dfbb1691
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c 5b7a12e2f8620e855b0478a9a6798df9967bb277
|
||||
F src/func.c 8147799b048065a1590805be464d05b4913e652c
|
||||
F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a
|
||||
F src/global.c 36c6d6600b53d0ae68189d6b5fdc04b7bf90f190
|
||||
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
|
||||
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
|
||||
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
|
||||
@@ -143,7 +143,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
||||
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
|
||||
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
|
||||
F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d
|
||||
F src/main.c 448564ee3795b13c373bbc5c8590df8fbfe1d64c
|
||||
F src/main.c b24c1a6a7fe732cb766a67111a17cc6369f9fc3c
|
||||
F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa
|
||||
@@ -176,10 +176,10 @@ F src/resolve.c 0bca3bf694f14f96a13873d87f62d6a6f38f913f
|
||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
||||
F src/select.c 395e458a6dc611cbe1179f424753f0c344957607
|
||||
F src/shell.c 11c9611580bb2ffce3a232f31f7f8cc310df0843
|
||||
F src/sqlite.h.in 39cc33bb08897c748fe3383c29ccf56585704177
|
||||
F src/sqlite.h.in cd8236d4ebd64e1694f221a7f3ad4e5ccc96b413
|
||||
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
|
||||
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
|
||||
F src/sqliteInt.h e998703742455b2241731424c6ec142fd8d0258f
|
||||
F src/sqliteInt.h 8829b00e8d5898a47423f01b4e55a22ff2c25925
|
||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||
F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9
|
||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||
@@ -208,7 +208,7 @@ F src/test_intarray.c 07ddcebe4097d400ffca362770f1d883c112387a
|
||||
F src/test_intarray.h b999bb18d090b8d9d9c49d36ec37ef8f341fe169
|
||||
F src/test_journal.c f5c0a05b7b3d5930db769b5ee6c3766dc2221a64
|
||||
F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
|
||||
F src/test_malloc.c 6982a357a6a6c24f281b91c89303a5c31075c392
|
||||
F src/test_malloc.c c0f02f9fa48495b8d0a63ab90318566a9eed9758
|
||||
F src/test_multiplex.c ac0fbc1748e5b86a41a1d7a84654fae0d53a881d
|
||||
F src/test_multiplex.h 9b63b95f07acedee425fdfe49a47197c9bf5f9d8
|
||||
F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e
|
||||
@@ -639,7 +639,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 0d3040974bf402e19b7df4b783e447289d7ab394
|
||||
F test/openv2.test 74c994537a13c7e31982d597eab555491133cee4
|
||||
F test/orderby1.test f33968647da5c546528fe4d2bf86c6a6a2e5a7ae
|
||||
F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04
|
||||
F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
|
||||
@@ -1031,7 +1031,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||
P 7695b88fe0d73fd0a36fb7d8f95350b80615a89e
|
||||
R d208b87926befaabc0152564810a2c30
|
||||
U drh
|
||||
Z 406b832608500677fb00b4e113908c12
|
||||
P bf90f1fbf84a288e787a563a3952d30622b26ef9 cda790280a52d65f98a45bacb9123367b159ac7c
|
||||
R a6b6f92637c383655137b0d4f23b139b
|
||||
U mistachkin
|
||||
Z 48d114bd69c2bfe832a8e5ad8685199a
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
cda790280a52d65f98a45bacb9123367b159ac7c
|
||||
f29680c468d5635e5ea7711f12f56ff467824241
|
||||
@@ -147,6 +147,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
|
||||
SQLITE_THREADSAFE==1, /* bFullMutex */
|
||||
SQLITE_USE_URI, /* bOpenUri */
|
||||
SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
|
||||
0, /* bReadOnly */
|
||||
0x7ffffffe, /* mxStrlen */
|
||||
128, /* szLookaside */
|
||||
500, /* nLookaside */
|
||||
|
||||
+54
-4
@@ -496,6 +496,45 @@ int sqlite3_config(int op, ...){
|
||||
}
|
||||
#endif
|
||||
|
||||
case SQLITE_CONFIG_READONLY: {
|
||||
sqlite3GlobalConfig.bReadOnly = va_arg(ap, int);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
rc = SQLITE_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
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;
|
||||
@@ -2225,7 +2264,8 @@ static int openDatabase(
|
||||
const char *zFilename, /* Database filename UTF-8 encoded */
|
||||
sqlite3 **ppDb, /* OUT: Returned database handle */
|
||||
unsigned int flags, /* Operational flags */
|
||||
const char *zVfs /* Name of the VFS to use */
|
||||
const char *zVfs, /* Name of the VFS to use */
|
||||
int defaultFlags /* Zero if opening via sqlite3_open_v2 */
|
||||
){
|
||||
sqlite3 *db; /* Store allocated handle here */
|
||||
int rc; /* Return code */
|
||||
@@ -2295,6 +2335,16 @@ static int openDatabase(
|
||||
SQLITE_OPEN_WAL
|
||||
);
|
||||
|
||||
/* Check for global read-only mode */
|
||||
if( sqlite3GlobalConfig.bReadOnly ){
|
||||
if( defaultFlags ){
|
||||
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
|
||||
flags |= SQLITE_OPEN_READONLY;
|
||||
}else if( flags & SQLITE_OPEN_READWRITE ){
|
||||
return SQLITE_READONLY;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate the sqlite data structure */
|
||||
db = sqlite3MallocZero( sizeof(sqlite3) );
|
||||
if( db==0 ) goto opendb_out;
|
||||
@@ -2492,7 +2542,7 @@ int sqlite3_open(
|
||||
sqlite3 **ppDb
|
||||
){
|
||||
return openDatabase(zFilename, ppDb,
|
||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
|
||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0, 1);
|
||||
}
|
||||
int sqlite3_open_v2(
|
||||
const char *filename, /* Database filename (UTF-8) */
|
||||
@@ -2500,7 +2550,7 @@ int sqlite3_open_v2(
|
||||
int flags, /* Flags */
|
||||
const char *zVfs /* Name of VFS module to use */
|
||||
){
|
||||
return openDatabase(filename, ppDb, (unsigned int)flags, zVfs);
|
||||
return openDatabase(filename, ppDb, (unsigned int)flags, zVfs, 0);
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
@@ -2527,7 +2577,7 @@ int sqlite3_open16(
|
||||
zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);
|
||||
if( zFilename8 ){
|
||||
rc = openDatabase(zFilename8, ppDb,
|
||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
|
||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0, 1);
|
||||
assert( *ppDb || rc==SQLITE_NOMEM );
|
||||
if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
|
||||
ENC(*ppDb) = SQLITE_UTF16NATIVE;
|
||||
|
||||
+29
-9
@@ -1246,11 +1246,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
|
||||
@@ -1262,17 +1262,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
|
||||
@@ -1598,6 +1604,19 @@ struct sqlite3_mem_methods {
|
||||
** disable the optimization allows the older, buggy application code to work
|
||||
** without change even with newer versions of SQLite.
|
||||
**
|
||||
** [[SQLITE_CONFIG_READONLY]] <dt>SQLITE_CONFIG_READONLY
|
||||
** <dd> This option takes a single argument of type int. If non-zero, then
|
||||
** read-only mode for opening databases is globally enabled. If the parameter
|
||||
** is zero, then read-only mode for opening databases is globally disabled. If
|
||||
** read-only mode for opening databases is globally enabled, all databases
|
||||
** opened by [sqlite3_open()], [sqlite3_open16()], or specified as part of
|
||||
** [ATTACH] commands will be opened in read-only mode. Additionally, all calls
|
||||
** to [sqlite3_open_v2()] must have the [SQLITE_OPEN_READONLY] flag set in the
|
||||
** third argument; otherwise, a [SQLITE_READONLY] error will be returned. If it
|
||||
** is globally disabled, [sqlite3_open()], [sqlite3_open16()],
|
||||
** [sqlite3_open_v2()], and [ATTACH] commands will function normally. By
|
||||
** default, read-only mode is globally disabled.
|
||||
**
|
||||
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
|
||||
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
|
||||
** <dd> These options are obsolete and should not be used by new code.
|
||||
@@ -1641,6 +1660,7 @@ struct sqlite3_mem_methods {
|
||||
#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
|
||||
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
|
||||
#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
|
||||
#define SQLITE_CONFIG_READONLY 22 /* int */
|
||||
|
||||
/*
|
||||
** CAPI3REF: Database Connection Configuration Options
|
||||
|
||||
@@ -2484,6 +2484,7 @@ struct Sqlite3Config {
|
||||
int bFullMutex; /* True to enable full mutexing */
|
||||
int bOpenUri; /* True to interpret filenames as URIs */
|
||||
int bUseCis; /* Use covering indices for full-scans */
|
||||
int bReadOnly; /* True to force read-only mode */
|
||||
int mxStrlen; /* Maximum string length */
|
||||
int szLookaside; /* Default lookaside buffer size */
|
||||
int nLookaside; /* Default lookaside buffer count */
|
||||
|
||||
@@ -1226,6 +1226,48 @@ static int test_config_cis(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_config_readonly BOOLEAN
|
||||
** sqlite3_reconfig_readonly BOOLEAN
|
||||
**
|
||||
** Enables or disables global read-only mode using SQLITE_CONFIG_READONLY.
|
||||
*/
|
||||
static int test_config_readonly(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
int rc;
|
||||
int bReadOnly;
|
||||
|
||||
if( objc!=2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "BOOL");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetBooleanFromObj(interp, objv[1], &bReadOnly) ){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_dump_memsys3 FILENAME
|
||||
** sqlite3_dump_memsys5 FILENAME
|
||||
@@ -1477,6 +1519,8 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){
|
||||
{ "sqlite3_config_error", test_config_error ,0 },
|
||||
{ "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 },
|
||||
|
||||
@@ -52,4 +52,36 @@ do_test openv2-2.2 {
|
||||
} {1 {attempt to write a readonly database}}
|
||||
|
||||
|
||||
# Attempt to open a database with SQLITE_OPEN_READWRITE when the
|
||||
# SQLITE_CONFIG_READONLY flag is enabled.
|
||||
#
|
||||
db close
|
||||
sqlite3_reconfig_readonly 1
|
||||
|
||||
do_test openv2-3.1 {
|
||||
list [catch {sqlite3 db :memory:} msg] $msg
|
||||
} {1 {attempt to write a readonly database}}
|
||||
catch {db close}
|
||||
do_test openv2-3.2 {
|
||||
list [catch {sqlite3 db test.db} msg] $msg
|
||||
} {1 {attempt to write a readonly database}}
|
||||
catch {db close}
|
||||
do_test openv2-3.3 {
|
||||
list [catch {sqlite3 db :memory: -readonly 1} msg] $msg
|
||||
} {0 {}}
|
||||
catch {db close}
|
||||
do_test openv2-3.4 {
|
||||
list [catch {sqlite3 db test.db -readonly 1} msg] $msg
|
||||
} {0 {}}
|
||||
catch {db close}
|
||||
do_test openv2-3.5 {
|
||||
list [catch {sqlite3 db :memory: -readonly 0} msg] $msg
|
||||
} {1 {attempt to write a readonly database}}
|
||||
catch {db close}
|
||||
do_test openv2-3.6 {
|
||||
list [catch {sqlite3 db test.db -readonly 0} msg] $msg
|
||||
} {1 {attempt to write a readonly database}}
|
||||
catch {db close}
|
||||
|
||||
sqlite3_reconfig_readonly 0
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user