aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-07-10 13:33:49 +0000
committerdrh <drh@noemail.net>2013-07-10 13:33:49 +0000
commit13447bf6c7c63f247e5765d19086c006a57ebae3 (patch)
treeca9e48fc6c8937a93196d21e74d936b37658eeb1 /src
parent49afe3aaa067eb050d0e831d351683c8251cba42 (diff)
downloadsqlite-13447bf6c7c63f247e5765d19086c006a57ebae3.tar.gz
sqlite-13447bf6c7c63f247e5765d19086c006a57ebae3.zip
Experimental "PRAGMA query_only=BOOLEAN" statement that is able to turn
write capabilities on and off. FossilOrigin-Name: ece960c496717a3a6c25526ef77dd76b08d607bc
Diffstat (limited to 'src')
-rw-r--r--src/pragma.c1
-rw-r--r--src/sqliteInt.h1
-rw-r--r--src/vdbe.c4
3 files changed, 6 insertions, 0 deletions
diff --git a/src/pragma.c b/src/pragma.c
index 5803f6c4a..f38e679a4 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -177,6 +177,7 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
{ "fullfsync", SQLITE_FullFSync },
{ "checkpoint_fullfsync", SQLITE_CkptFullFSync },
{ "reverse_unordered_selects", SQLITE_ReverseOrder },
+ { "query_only", SQLITE_QueryOnly },
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
{ "automatic_index", SQLITE_AutoIndex },
#endif
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 5e3b4d0a0..48a1f96ea 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -1009,6 +1009,7 @@ struct sqlite3 {
#define SQLITE_PreferBuiltin 0x00100000 /* Preference to built-in funcs */
#define SQLITE_LoadExtension 0x00200000 /* Enable load_extension */
#define SQLITE_EnableTrigger 0x00400000 /* True to enable triggers */
+#define SQLITE_QueryOnly 0x00800000 /* Disable database changes */
/*
** Bits of the sqlite3.dbOptFlags field that are used by the
diff --git a/src/vdbe.c b/src/vdbe.c
index 9a56518c5..1fa21df6d 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -2946,6 +2946,10 @@ case OP_Transaction: {
assert( p->readOnly==0 || pOp->p2==0 );
assert( pOp->p1>=0 && pOp->p1<db->nDb );
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
+ if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){
+ rc = SQLITE_READONLY;
+ goto abort_due_to_error;
+ }
pBt = db->aDb[pOp->p1].pBt;
if( pBt ){