From f03d9ccc453e4be5dba043a9c9557ebb2c7db9e1 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Nov 2010 23:10:25 +0000 Subject: [PATCH 1/6] Adding the sqlite3_stmt_readonly() interface. FossilOrigin-Name: fd5b2f23dd5111d2f0934dd828bae36b755024c1 --- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/sqlite.h.in | 15 +++++++++++++++ src/test1.c | 28 ++++++++++++++++++++++++++++ src/vdbeapi.c | 8 ++++++++ test/capi3d.test | 27 +++++++++++++++++++++++++-- 6 files changed, 89 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index d06d475d13..0a258e04dd 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Use\sthe\sestimated\snumber\sof\srows\scomputed\sfor\ssubqueries\sin\sthe\scost\ncomputations\sfor\souter\squeries. -D 2010-11-16T02:49:16 +C Adding\sthe\ssqlite3_stmt_readonly()\sinterface. +D 2010-11-16T23:10:26 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,14 +179,14 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 550d67688f5e8bc8022faf6d014838afba1415af F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056 -F src/sqlite.h.in f47e09412fc9a129f759fa4d96ef21f4b3d529eb +F src/sqlite.h.in 533fbbd82130f0edc01396f1e53a698cdf1b590e F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h dd28f6138c74cf4833e032a989b6ff7885798cf6 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 496913d4e8441195f6f2a75b1c95993a45b9b30b F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c e1c485fa323e3ef02e5b10fe6a016e7638013eb9 -F src/test1.c a1339ecea631f3287b7dafcc8d55d343f7c5d193 +F src/test1.c c2aa29d0fd6db7506fb7f0de7bff1386078296df F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc F src/test4.c 0528360b5025688002a5feb6be906ddce52eaaee @@ -233,7 +233,7 @@ F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f F src/vdbe.c e1aa917961e69f71c80f46ce231b496d3c841ae1 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4 -F src/vdbeapi.c 5368714fa750270cf6430160287c21adff44582d +F src/vdbeapi.c fb0036185b3c56e15916a5ee96309cd4acf6818f F src/vdbeaux.c 762c2b146cf5fe7a7f743af1bbfed4a966aa937a F src/vdbeblob.c e0ce3c54cc0c183af2ec67b63a289acf92251df4 F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9 @@ -298,7 +298,7 @@ F test/capi2.test 00032d7504b9c14f1b36331670c5e7b0f73e3c5d F test/capi3.test 1945a2ba75e3f4c49d5beb8fc092115b6292d471 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test bea67403a5e37a4b33230ee4723e315a2ffb31e7 -F test/capi3d.test 57d83b690d7364bde02cddbf8339a4b50d80ce23 +F test/capi3d.test cd36571f014f34bdc4421967f6453cbb597d5d16 F test/cast.test 166951664a0b0a2e0f8fb5997a152490c6363932 F test/check.test db2b29d557544347d28e25b8406f5d5ecc3d1bc3 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 @@ -889,14 +889,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d52b593978aa1776af7aeb957c4f8df0c5cb7e43 -R d49dbce342d6074d2c08ca15a1061dc2 +P 56bbc539246a6dc9f1ae1edb898db7a4f6f6d322 +R 72844ae88a5f828dd3936f0015dc03a4 U drh -Z 1d0a2a683be8d99ef69f89af3e0fc4c3 +Z 48d737e0936d03f220e9650734c5994d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM4fEvoxKgR168RlERAtLBAJ0duCZxNY8VlhlVLo/NezKrqI5noACdE3GU -LDKZgeEbRVz6H1/mucVVNUQ= -=B2su +iD8DBQFM4w9loxKgR168RlERAicMAJ9C8dDp3QsQXrjRY7uCIkkgU8xQjwCePeD8 +5VbOBryk2e4pErKiCR+rel8= +=5cE5 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 5f256ca04e..8883b02e12 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -56bbc539246a6dc9f1ae1edb898db7a4f6f6d322 \ No newline at end of file +fd5b2f23dd5111d2f0934dd828bae36b755024c1 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e08d5ce596..fc96c31caa 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2628,6 +2628,21 @@ int sqlite3_prepare16_v2( */ 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 guaranteed to leave the database file +** unmodified. ^If the sqlite3_stmt_readonly(X) interface returns false (zero) +** then evaluating the statement might change the database file, but this +** is not guaranteed as the write operation might be conditional and the +** condition might not be met. ^If X is a NULL pointer then +** sqlite3_stmt_readonly(X) returns true. If X is a non-NULL pointer but +** is not a pointer to a valid, unfinalized prepared statement, then the +** behavior is undefined and probably harmful. +*/ +int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); + /* ** CAPI3REF: Dynamically Typed Value Object ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} diff --git a/src/test1.c b/src/test1.c index 57b86f5b28..27834f36e1 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2299,6 +2299,33 @@ static int test_next_stmt( return TCL_OK; } +/* +** Usage: sqlite3_stmt_readonly STMT +** +** Return true if STMT is a NULL pointer or a pointer to a statement +** that is guaranteed to leave the database unmodified. +*/ +static int test_stmt_readonly( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + int rc; + + if( objc!=2 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); + return TCL_ERROR; + } + + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; + rc = sqlite3_stmt_readonly(pStmt); + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); + return TCL_OK; +} + /* ** Usage: sqlite3_reset STMT @@ -5392,6 +5419,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_step", test_step ,0 }, { "sqlite3_sql", test_sql ,0 }, { "sqlite3_next_stmt", test_next_stmt ,0 }, + { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, { "sqlite3_release_memory", test_release_memory, 0}, { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, diff --git a/src/vdbeapi.c b/src/vdbeapi.c index e51555658c..93689ebcee 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1266,6 +1266,14 @@ sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){ return pStmt ? ((Vdbe*)pStmt)->db : 0; } +/* +** Return true if the prepared statement is guaranteed to not modify the +** database. +*/ +int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){ + return pStmt ? ((Vdbe*)pStmt)->readOnly : 1; +} + /* ** Return a pointer to the next prepared statement after pStmt associated ** with database connection pDb. If pStmt is NULL, return the first diff --git a/test/capi3d.test b/test/capi3d.test index e346029f92..49e64476eb 100644 --- a/test/capi3d.test +++ b/test/capi3d.test @@ -10,7 +10,8 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # -# This file is devoted to testing the sqlite3_next_stmt interface. +# This file is devoted to testing the sqlite3_next_stmt and +# sqlite3_stmt_readonly interfaces. # # $Id: capi3d.test,v 1.2 2008/07/14 15:11:20 drh Exp $ # @@ -88,6 +89,28 @@ for {set i 1} {$i<=100} {incr i} { sqlite3_next_stmt db 0 } {} } - + +# Tests for the is-read-only interface. +# +proc test_is_readonly {testname sql truth} { + do_test $testname [format { + set DB [sqlite3_connection_pointer db] + set STMT [sqlite3_prepare $DB {%s} -1 TAIL] + set rc [sqlite3_stmt_readonly $STMT] + sqlite3_finalize $STMT + set rc + } $sql] $truth +} + +test_is_readonly capi3d-2.1 {SELECT * FROM sqlite_master} 1 +test_is_readonly capi3d-2.2 {CREATE TABLE t1(x)} 0 +db eval {CREATE TABLE t1(x)} +test_is_readonly capi3d-2.3 {INSERT INTO t1 VALUES(5)} 0 +test_is_readonly capi3d-2.4 {UPDATE t1 SET x=x+1 WHERE x<0} 0 +test_is_readonly capi3d-2.5 {SELECT * FROM t1} 1 +do_test capi3-2.99 { + sqlite3_stmt_readonly 0 +} 1 + finish_test From 79d086dffca88b4eed942776313b3eac66dcad3a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 17 Nov 2010 02:02:45 +0000 Subject: [PATCH 2/6] Restrict the scope of the sqlite3_stmt_readonly() interface to a specific subset of prepared statement types. FossilOrigin-Name: 919b06c3a803abb9236606a9b5885f0d8181e730 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 15 +++++++-------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 0a258e04dd..f89fd33fe7 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Adding\sthe\ssqlite3_stmt_readonly()\sinterface. -D 2010-11-16T23:10:26 +C Restrict\sthe\sscope\sof\sthe\ssqlite3_stmt_readonly()\sinterface\sto\sa\sspecific\nsubset\sof\sprepared\sstatement\stypes. +D 2010-11-17T02:02:45 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 550d67688f5e8bc8022faf6d014838afba1415af F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056 -F src/sqlite.h.in 533fbbd82130f0edc01396f1e53a698cdf1b590e +F src/sqlite.h.in 74768e9a569d65a62c99f3d383b37904b4ed7f66 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h dd28f6138c74cf4833e032a989b6ff7885798cf6 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -889,14 +889,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 56bbc539246a6dc9f1ae1edb898db7a4f6f6d322 -R 72844ae88a5f828dd3936f0015dc03a4 +P fd5b2f23dd5111d2f0934dd828bae36b755024c1 +R 04175f994d2ff5506b0ca53f6db141f4 U drh -Z 48d737e0936d03f220e9650734c5994d +Z d3d5e28e20342a905a65b4d0c97cc8b0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM4w9loxKgR168RlERAicMAJ9C8dDp3QsQXrjRY7uCIkkgU8xQjwCePeD8 -5VbOBryk2e4pErKiCR+rel8= -=5cE5 +iD8DBQFM4zfIoxKgR168RlERAmoJAJ41/nrY6W9922DAT1NyVkj5MHWhBQCbBEkI +2Mj3PkQzdDaLvqg80qEt7sc= +=l7B2 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 8883b02e12..ec9b011248 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd5b2f23dd5111d2f0934dd828bae36b755024c1 \ No newline at end of file +919b06c3a803abb9236606a9b5885f0d8181e730 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index fc96c31caa..1138cb2a59 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2632,14 +2632,13 @@ 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 guaranteed to leave the database file -** unmodified. ^If the sqlite3_stmt_readonly(X) interface returns false (zero) -** then evaluating the statement might change the database file, but this -** is not guaranteed as the write operation might be conditional and the -** condition might not be met. ^If X is a NULL pointer then -** sqlite3_stmt_readonly(X) returns true. If X is a non-NULL pointer but -** is not a pointer to a valid, unfinalized prepared statement, then the -** behavior is undefined and probably harmful. +** 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. */ int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); From e5a8a1df0d44a3df70c31bcbfefa19e07fd912e8 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Nov 2010 12:31:24 +0000 Subject: [PATCH 3/6] Prevent a possible segfault when the sqlite3_value_numeric_type() interface is misused to try to determine the numeric type of the NULL value returned from sqlite3_column_value() with an invalid column number. FossilOrigin-Name: 501b743bcb60cda0acf63bcf8a4abbf00797b347 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbe.c | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index f89fd33fe7..c95b5772da 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Restrict\sthe\sscope\sof\sthe\ssqlite3_stmt_readonly()\sinterface\sto\sa\sspecific\nsubset\sof\sprepared\sstatement\stypes. -D 2010-11-17T02:02:45 +C Prevent\sa\spossible\ssegfault\swhen\sthe\ssqlite3_value_numeric_type()\sinterface\sis\nmisused\sto\stry\sto\sdetermine\sthe\snumeric\stype\sof\sthe\sNULL\svalue\sreturned\nfrom\ssqlite3_column_value()\swith\san\sinvalid\scolumn\snumber. +D 2010-11-18T12:31:24 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/update.c 227e6cd512108b84f69421fc6c7aa1b83d60d6e0 F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685 F src/util.c cd78524566fe45671863eee78685969a4bfd4e4c F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f -F src/vdbe.c e1aa917961e69f71c80f46ce231b496d3c841ae1 +F src/vdbe.c 63bb1e56a035bc65b20d6f9c7d7c876f19b4605f F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4 F src/vdbeapi.c fb0036185b3c56e15916a5ee96309cd4acf6818f @@ -889,14 +889,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P fd5b2f23dd5111d2f0934dd828bae36b755024c1 -R 04175f994d2ff5506b0ca53f6db141f4 +P 919b06c3a803abb9236606a9b5885f0d8181e730 +R f97c8e924509d527d263305f6db2ea8c U drh -Z d3d5e28e20342a905a65b4d0c97cc8b0 +Z cdfd67772a9f3b2481027958d7a1c7cc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM4zfIoxKgR168RlERAmoJAJ41/nrY6W9922DAT1NyVkj5MHWhBQCbBEkI -2Mj3PkQzdDaLvqg80qEt7sc= -=l7B2 +iD8DBQFM5RyfoxKgR168RlERAk12AKCFZ9RAxJldNTKoz5+tmS7oBoyIwQCfQTx6 +ziVsVfEF14r8UoUq+M0FtUk= +=ZxBI -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index ec9b011248..56d48e8ccb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -919b06c3a803abb9236606a9b5885f0d8181e730 \ No newline at end of file +501b743bcb60cda0acf63bcf8a4abbf00797b347 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 02d1a406c9..cfcb15bbd7 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -311,13 +311,13 @@ static void applyAffinity( ** into a numeric representation. Use either INTEGER or REAL whichever ** is appropriate. But only do the conversion if it is possible without ** loss of information and return the revised type of the argument. -** -** This is an EXPERIMENTAL api and is subject to change or removal. */ int sqlite3_value_numeric_type(sqlite3_value *pVal){ Mem *pMem = (Mem*)pVal; - applyNumericAffinity(pMem); - sqlite3VdbeMemStoreType(pMem); + if( pMem->type==SQLITE_TEXT ){ + applyNumericAffinity(pMem); + sqlite3VdbeMemStoreType(pMem); + } return pMem->type; } From 437261d0775bf0c744ff95fc0e183e40aff1ea96 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Nov 2010 13:47:50 +0000 Subject: [PATCH 4/6] Fix compiler warnings. FossilOrigin-Name: 6c4f1d5c24522d1f541a2b96b229ad0374f99c19 --- ext/fts3/fts3.c | 36 ------------------------------------ ext/rtree/rtree.c | 10 ---------- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/where.c | 2 +- 5 files changed, 13 insertions(+), 59 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 023787c3bf..a211a11dbb 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -605,42 +605,6 @@ static int fts3CreateTables(Fts3Table *p){ return rc; } -/* -** An sqlite3_exec() callback for fts3TableExists. -*/ -static int fts3TableExistsCallback(void *pArg, int n, char **pp1, char **pp2){ - UNUSED_PARAMETER(n); - UNUSED_PARAMETER(pp1); - UNUSED_PARAMETER(pp2); - *(int*)pArg = 1; - return 1; -} - -/* -** Determine if a table currently exists in the database. -*/ -static void fts3TableExists( - int *pRc, /* Success code */ - sqlite3 *db, /* The database connection to test */ - const char *zDb, /* ATTACHed database within the connection */ - const char *zName, /* Name of the FTS3 table */ - const char *zSuffix, /* Shadow table extension */ - u8 *pResult /* Write results here */ -){ - int rc = SQLITE_OK; - int res = 0; - char *zSql; - if( *pRc ) return; - zSql = sqlite3_mprintf( - "SELECT 1 FROM %Q.sqlite_master WHERE name='%q%s'", - zDb, zName, zSuffix - ); - rc = sqlite3_exec(db, zSql, fts3TableExistsCallback, &res, 0); - sqlite3_free(zSql); - *pResult = (u8)(res & 0xff); - if( rc!=SQLITE_ABORT ) *pRc = rc; -} - /* ** Store the current database page-size in bytes in p->nPgsz. ** diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index b805676b79..9cac2f3c07 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -2649,16 +2649,6 @@ static int newRowid(Rtree *pRtree, i64 *piRowid){ return rc; } -#ifndef NDEBUG -static int hashIsEmpty(Rtree *pRtree){ - int ii; - for(ii=0; iiaHash[ii] ); - } - return 1; -} -#endif - /* ** The xUpdate method for rtree module virtual tables. */ diff --git a/manifest b/manifest index c95b5772da..d630d853a8 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Prevent\sa\spossible\ssegfault\swhen\sthe\ssqlite3_value_numeric_type()\sinterface\sis\nmisused\sto\stry\sto\sdetermine\sthe\snumeric\stype\sof\sthe\sNULL\svalue\sreturned\nfrom\ssqlite3_column_value()\swith\san\sinvalid\scolumn\snumber. -D 2010-11-18T12:31:24 +C Fix\scompiler\swarnings. +D 2010-11-18T13:47:51 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -64,7 +64,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 9da9f1d5bc4b087540255ffdb7a4428fe708edf0 +F ext/fts3/fts3.c 98e6f7c094060b47c5660e8779d883219da10e5d F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h bbcd6d671228c9ae2ed5514723fcc6217821d0a6 F ext/fts3/fts3_expr.c ee48b9278b8b2432a05a03320fbcacba151dbaa5 @@ -83,7 +83,7 @@ F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 7dffd6d90dac2e504b7315572f49c754772525dc +F ext/rtree/rtree.c 1a15546893b4c05df810ebc18d3bf910ac8ca601 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test dbd4250ac0ad367a262eb9676f7e3080b0368206 F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -242,7 +242,7 @@ F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 F src/wal.c f26b8d297bd11cb792e609917f9d4c6718ac8e0e F src/wal.h c1aac6593a0b02b15dc625987e619edeab39292e F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c d5cc65f51661a038a2c6a663a945d5cf4c277b81 +F src/where.c fa22d45b2577c77146f2e894d58011d472d64103 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 6745008c144bd2956d58864d21f7b304689c1cce @@ -889,14 +889,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 919b06c3a803abb9236606a9b5885f0d8181e730 -R f97c8e924509d527d263305f6db2ea8c +P 501b743bcb60cda0acf63bcf8a4abbf00797b347 +R eaffc000adc323845124c605d8131353 U drh -Z cdfd67772a9f3b2481027958d7a1c7cc +Z 129e4da2047508451bbae193888369af -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM5RyfoxKgR168RlERAk12AKCFZ9RAxJldNTKoz5+tmS7oBoyIwQCfQTx6 -ziVsVfEF14r8UoUq+M0FtUk= -=ZxBI +iD8DBQFM5S6KoxKgR168RlERAlxMAKCCj1He0nir70Dh29Hs1JaoNodGdQCggzyL +124Zyx5njb0rKyAwAZS9FWs= +=7jLu -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 56d48e8ccb..80424a5c7e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -501b743bcb60cda0acf63bcf8a4abbf00797b347 \ No newline at end of file +6c4f1d5c24522d1f541a2b96b229ad0374f99c19 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 751c7a99c2..b8d1d6b276 100644 --- a/src/where.c +++ b/src/where.c @@ -4487,7 +4487,7 @@ WhereInfo *sqlite3WhereBegin( */ notReady = ~(Bitmask)0; for(i=0; ia[i]; + pLevel = &pWInfo->a[i]; explainOneScan(pParse, pTabList, pLevel, i, pLevel->iFrom, wctrlFlags); notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); pWInfo->iContinue = pLevel->addrCont; From 3b691b546634e5a4f98e7b38cb067bc9fd999a79 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Nov 2010 13:52:34 +0000 Subject: [PATCH 5/6] Restrict the scope of the fts3ExprCost() subroutine inside of FTS3. FossilOrigin-Name: 76681870a4705179f78976e7fda638a6fea0b9f9 --- ext/fts3/fts3.c | 2 +- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index a211a11dbb..5618934695 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2520,7 +2520,7 @@ static void fts3ExprFreeSegReaders(Fts3Expr *pExpr){ ** function must be called after Fts3SegReaderArrays have been allocated ** for all tokens using fts3ExprAllocateSegReaders(). */ -int fts3ExprCost(Fts3Expr *pExpr){ +static int fts3ExprCost(Fts3Expr *pExpr){ int nCost; /* Return value */ if( pExpr->eType==FTSQUERY_PHRASE ){ Fts3Phrase *pPhrase = pExpr->pPhrase; diff --git a/manifest b/manifest index d630d853a8..52d72cf809 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\scompiler\swarnings. -D 2010-11-18T13:47:51 +C Restrict\sthe\sscope\sof\sthe\sfts3ExprCost()\ssubroutine\sinside\sof\sFTS3. +D 2010-11-18T13:52:34 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -64,7 +64,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 98e6f7c094060b47c5660e8779d883219da10e5d +F ext/fts3/fts3.c 7e01fd82fa289decbc21bcebb924d44d307eb757 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h bbcd6d671228c9ae2ed5514723fcc6217821d0a6 F ext/fts3/fts3_expr.c ee48b9278b8b2432a05a03320fbcacba151dbaa5 @@ -889,14 +889,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 501b743bcb60cda0acf63bcf8a4abbf00797b347 -R eaffc000adc323845124c605d8131353 +P 6c4f1d5c24522d1f541a2b96b229ad0374f99c19 +R ac913fc20e1e02fd0b006b5e555bc903 U drh -Z 129e4da2047508451bbae193888369af +Z b87890169f2f3c0ac5b674e9aa2c08bf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFM5S6KoxKgR168RlERAlxMAKCCj1He0nir70Dh29Hs1JaoNodGdQCggzyL -124Zyx5njb0rKyAwAZS9FWs= -=7jLu +iD8DBQFM5S+loxKgR168RlERAq0hAJ4uVME2ihBNvqhgUgbGV8emWfA7cwCfTZeO +DPJoe01N82TXmbetUlKsCvM= +=x8Xm -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 80424a5c7e..3daa67bb60 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c4f1d5c24522d1f541a2b96b229ad0374f99c19 \ No newline at end of file +76681870a4705179f78976e7fda638a6fea0b9f9 \ No newline at end of file From 13acedf254147d2b0c7bc7e258c61c586e1bfcff Mon Sep 17 00:00:00 2001 From: shaneh Date: Thu, 18 Nov 2010 15:44:59 +0000 Subject: [PATCH 6/6] Added some tests to check that umlaut characters are supported in filenames. FossilOrigin-Name: c36f275d70ec8f6dead6adac02885026fdff9666 --- manifest | 23 +++------- manifest.uuid | 2 +- test/capi3e.test | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 17 deletions(-) create mode 100644 test/capi3e.test diff --git a/manifest b/manifest index 52d72cf809..3cb5c587f0 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Restrict\sthe\sscope\sof\sthe\sfts3ExprCost()\ssubroutine\sinside\sof\sFTS3. -D 2010-11-18T13:52:34 +C Added\ssome\stests\sto\scheck\sthat\sumlaut\scharacters\sare\ssupported\sin\sfilenames. +D 2010-11-18T15:44:59 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -299,6 +296,7 @@ F test/capi3.test 1945a2ba75e3f4c49d5beb8fc092115b6292d471 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test bea67403a5e37a4b33230ee4723e315a2ffb31e7 F test/capi3d.test cd36571f014f34bdc4421967f6453cbb597d5d16 +F test/capi3e.test f57488502e00902e6a1f560a0620a96dcc0b8efb F test/cast.test 166951664a0b0a2e0f8fb5997a152490c6363932 F test/check.test db2b29d557544347d28e25b8406f5d5ecc3d1bc3 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 @@ -889,14 +887,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 6c4f1d5c24522d1f541a2b96b229ad0374f99c19 -R ac913fc20e1e02fd0b006b5e555bc903 -U drh -Z b87890169f2f3c0ac5b674e9aa2c08bf ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFM5S+loxKgR168RlERAq0hAJ4uVME2ihBNvqhgUgbGV8emWfA7cwCfTZeO -DPJoe01N82TXmbetUlKsCvM= -=x8Xm ------END PGP SIGNATURE----- +P 76681870a4705179f78976e7fda638a6fea0b9f9 +R 919bf4eab147c8998416dfbf378b675b +U shaneh +Z aafd80be2caa03cdbfe5df1baca3e3f0 diff --git a/manifest.uuid b/manifest.uuid index 3daa67bb60..749e222b90 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76681870a4705179f78976e7fda638a6fea0b9f9 \ No newline at end of file +c36f275d70ec8f6dead6adac02885026fdff9666 \ No newline at end of file diff --git a/test/capi3e.test b/test/capi3e.test new file mode 100644 index 0000000000..c4f9d47c20 --- /dev/null +++ b/test/capi3e.test @@ -0,0 +1,115 @@ +# 2010 Novemeber 18 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this script testing the callback-free C/C++ API. +# +# $Id: capi3e.test,v 1.70 2009/01/09 02:49:32 drh Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Do not use a codec for tests in this file, as the database file is +# manipulated directly using tcl scripts (using the [hexio_write] command). +# +do_not_use_codec + +# Return the UTF-16 representation of the supplied UTF-8 string $str. +# If $nt is true, append two 0x00 bytes as a nul terminator. +proc utf16 {str {nt 1}} { + set r [encoding convertto unicode $str] + if {$nt} { + append r "\x00\x00" + } + return $r +} + +# Return the UTF-8 representation of the supplied UTF-16 string $str. +proc utf8 {str} { + # If $str ends in two 0x00 0x00 bytes, knock these off before + # converting to UTF-8 using TCL. + binary scan $str \c* vals + if {[lindex $vals end]==0 && [lindex $vals end-1]==0} { + set str [binary format \c* [lrange $vals 0 end-2]] + } + + set r [encoding convertfrom unicode $str] + return $r +} + +# These tests complement those in capi2.test. They are organized +# as follows: +# +# capi3e-1.*: Test sqlite3_open with various UTF8 filenames +# capi3e-2.*: Test sqlite3_open16 with various UTF8 filenames +# capi3e-3.*: Test ATTACH with various UTF8 filenames + +db close + +# here's the list of file names we're testing +set names {t 1 t. 1. t.d 1.d t-1 1-1 t.db ä.db ë.db ö.db ü.db ÿ.db} + +set i 0 +foreach name $names { + incr i + do_test capi3e-1.1.$i { + set db2 [sqlite3_open $name {}] + sqlite3_errcode $db2 + } {SQLITE_OK} + do_test capi3e-1.2.$i { + sqlite3_close $db2 + } {SQLITE_OK} + do_test capi3e-1.3.$i { + file isfile $name + } {1} +} + +set i 0 +foreach name $names { + incr i + do_test capi3e-2.1.$i { + set db2 [sqlite3_open16 [utf16 $name] {}] + sqlite3_errcode $db2 + } {SQLITE_OK} + do_test capi3e-2.2.$i { + sqlite3_close $db2 + } {SQLITE_OK} + do_test capi3e-2.3.$i { + file isfile $name + } {1} +} + +ifcapable attach { + do_test capi3e-3.1 { + sqlite3 db2 base.db + } {} + set i 0 + foreach name $names { + incr i + do_test capi3e-3.2.$i { + db2 eval "ATTACH DATABASE '$name' AS db$i;" + } {} + do_test capi3e-3.3.$i { + db2 eval "DETACH DATABASE db$i;" + } {} + } + do_test capi3e-3.4 { + db2 close + } {} +} + +# clean up +forcedelete base.db +foreach name $names { + forcedelete $name +} + +finish_test