From: drh Date: Wed, 8 Dec 2010 18:30:19 +0000 (+0000) Subject: Update the sqlite3_stmt_readonly() interface so that its output is X-Git-Tag: version-3.7.5~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10fc727d35d4bc6b8a670e324d86f7377f38e34a;p=thirdparty%2Fsqlite.git Update the sqlite3_stmt_readonly() interface so that its output is well-defined for all prepared statements, and so that it gives the correct result for VACUUM. FossilOrigin-Name: 9c19b7ae3542fd1fac692b4471f1839b22685c76 --- diff --git a/manifest b/manifest index 36254014d3..2497116d8c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C The\scommand-line\sshell\signore\serrors\sin\ssqlite3_close()\swhen\sshutting\sdown. -D 2010-12-08T03:28:17 +C Update\sthe\ssqlite3_stmt_readonly()\sinterface\sso\sthat\sits\soutput\sis\s\nwell-defined\sfor\sall\sprepared\sstatements,\sand\sso\sthat\sit\sgives\sthe\s\ncorrect\sresult\sfor\sVACUUM. +D 2010-12-08T18:30:20 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7 F src/shell.c ee5905fef7bf8dfceaf31ee32db92a250c5acab4 -F src/sqlite.h.in d0cd88c447f25ead403bca04ebd8fe93e035f820 +F src/sqlite.h.in 2bd41c95c0a38a048511025b646b6fe3621f0753 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b96d5ddb8b419a2ed7cf69a7778b53872d73e8a7 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -235,7 +235,7 @@ F src/vdbe.c 5d310eaf1a4d8383602126fa82e01291ab7d3cf3 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 1f2137b905969f4de0648256aeb73abdf88f9213 F src/vdbeapi.c fb0036185b3c56e15916a5ee96309cd4acf6818f -F src/vdbeaux.c b810a66902ee40c71cdb9c64f43760da516c91df +F src/vdbeaux.c 33448d23b857654dd69ed2103611f5c733606f68 F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 @@ -897,14 +897,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e474fd9e7f89644a7840e33e9df03dbaa4dd28bd -R 7edcb2582417e56eb98f0dae455ae31e +P 925332c3d79f6252895ff1a367f795630619247e +R 21967790fc1d3a87411c7dc79f0363d8 U drh -Z b15026da9128033b9dc0a7b0dce2ca83 +Z 43b494b0390c277287ad8dcfa52377ca -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM/vtUoxKgR168RlERAi0wAJ4nUq0PfKIRivnR/wjbLVQFsF5neACfb8+m -fqFov7rgIDAItG1ZstpEvGo= -=CHf6 +iD8DBQFM/87BoxKgR168RlERAq7yAJ91YZzLtFsuVU7N+/YXYPca9gc1nQCggog3 +BbPOFe1Sz6rNVdsQrKMw7s8= +=vXgA -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 2287c208e6..c8a9082ca9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -925332c3d79f6252895ff1a367f795630619247e \ No newline at end of file +9c19b7ae3542fd1fac692b4471f1839b22685c76 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 7c259c8671..f2bd71b1ff 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2650,14 +2650,31 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If An SQL Statement Writes The Database ** -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if -** the [prepared statement] X is [SELECT] statement and false (zero) if -** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], -** [ALTER], or [REINDEX] statement. -** If X is a NULL pointer or any other kind of statement, including but -** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], -** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is -** undefined. +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if +** and only if the [prepared statement] X is makes no direct changes to +** the content of the database file. +** +** Note that [application-defined SQL functions] or +** [virtual tables] might change the database indirectly as a side effect. +** ^(For example, if an application defines a function "eval()" that +** calls [sqlite3_exec()], then the following SQL statement would +** change the database file through side-effects: +** +**
+**    SELECT eval('DELETE FROM t1') FROM t2;
+** 
+** +** But because the [SELECT] statement does not change the database file +** directly, sqlite3_stmt_readonly() would still return true.)^ +** +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, +** since the statements themselves do not actually modify the database but +** rather they control the timing of when other statements modify the +** database. ^The [ATTACH] and [DETACH] statements also cause +** sqlite3_stmt_readonly() to return true since, while those statements +** change the configuration of a database connection, they do not make +** changes to the content of the database files on disk. */ int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a9ac9b032d..de69e544e5 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -408,7 +408,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ pOp->opflags = sqlite3OpcodeProperty[opcode]; if( opcode==OP_Function || opcode==OP_AggStep ){ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; - }else if( opcode==OP_Transaction && pOp->p2!=0 ){ + }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){ p->readOnly = 0; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( opcode==OP_VUpdate ){