From 2d8d7cebe17ada23544ff4dc6e16965e0a71bb98 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 Feb 2010 15:17:05 +0000 Subject: [PATCH 01/50] Fix a typo in the documentation for the OP_OpenPseudo opcode. FossilOrigin-Name: 9acfb0694059c80b2efc08a60232d4be91575c32 --- manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e12c1afa2b..86c08d180c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Merged\stracing\sand\sinitialization\schanges\sfrom\smutex_unix.c. -D 2010-02-13T02:31:09 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\sa\stypo\sin\sthe\sdocumentation\sfor\sthe\sOP_OpenPseudo\sopcode. +D 2010-02-15T15:17:06 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -209,7 +212,7 @@ F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 F src/util.c aa0b1da8f71edff84b4b41dbe05fe6ac75d819c6 F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de -F src/vdbe.c 78f2167915a8a9611e79eeaf13318d247abed185 +F src/vdbe.c 428411c6fbd49e9a4ce043dad87a0b079d403714 F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e F src/vdbeapi.c a8b6a6617fc9a0492e4f7d6626d3afe994ddd3f2 @@ -787,7 +790,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 2bb38bb96ff6b9fb91dd1cf214041cf113ac5508 -R 232b63cb29b9e4506009aea6dd09a4d6 -U shaneh -Z 85585006145b2cc2993f7e2137036d14 +P 942aa1f6a91655356cc32a8185cb447331d405dc +R 96ed7c8828d98879cc72ca6f67e06ea7 +U drh +Z b17df2ad7162be0be25a28fbf6e0b8be +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLeWV1oxKgR168RlERAkXLAKCKwAiZiL6LVwUZ5Xo7V1gh47mmNQCdGXl+ +hNkVcTOcCExujWunCRv/xwU= +=LcuG +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4d742758ea..400e4283b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -942aa1f6a91655356cc32a8185cb447331d405dc \ No newline at end of file +9acfb0694059c80b2efc08a60232d4be91575c32 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 35a35ddb8a..df73c46290 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3119,7 +3119,7 @@ case OP_OpenEphemeral: { ** register P2. In other words, cursor P1 becomes an alias for the ** MEM_Blob content contained in register P2. ** -** A pseudo-table created by this opcode is used to hold the a single +** A pseudo-table created by this opcode is used to hold a single ** row output from the sorter so that the row can be decomposed into ** individual columns using the OP_Column opcode. The OP_Column opcode ** is the only cursor opcode that works with a pseudo-table. From a8c62df904fe2321dbb33c6e7a64c3adad988da7 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 Feb 2010 15:47:18 +0000 Subject: [PATCH 02/50] Fix a compiler warning in shell.c. Updates to comments in trigger.c. FossilOrigin-Name: c727601eecd85a26dbd4fc36823d77bec34da3c3 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/shell.c | 4 ++-- src/trigger.c | 14 +++++++------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 86c08d180c..7c46ac4177 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\stypo\sin\sthe\sdocumentation\sfor\sthe\sOP_OpenPseudo\sopcode. -D 2010-02-15T15:17:06 +C Fix\sa\scompiler\swarning\sin\sshell.c.\s\sUpdates\sto\scomments\sin\strigger.c. +D 2010-02-15T15:47:18 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -166,7 +166,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 56ecd50851afa9dbcc1803ef86a9b17b3f3d3b89 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 -F src/shell.c d7408dbe4d17fbefc0e63e85f6498634962922f9 +F src/shell.c 56521a172567f5f9f59f528599bf63380e150ac4 F src/sqlite.h.in 2afdca943d145f84f55468b1ab608df0d719c318 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h a1df33a2c9a0c5062088b655ddf10237f1bcef2f @@ -207,7 +207,7 @@ F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c 00fed80690ae7f1525483a35861511c48bc579f2 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d -F src/trigger.c d46f9389e3bf3dd1cc1d288aba2f289c96b34200 +F src/trigger.c a188f616acd9092231068c841e15cb531ff2bc0d F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 F src/util.c aa0b1da8f71edff84b4b41dbe05fe6ac75d819c6 @@ -790,14 +790,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 942aa1f6a91655356cc32a8185cb447331d405dc -R 96ed7c8828d98879cc72ca6f67e06ea7 +P 9acfb0694059c80b2efc08a60232d4be91575c32 +R f3f1e356ae050092c353da0201c436cd U drh -Z b17df2ad7162be0be25a28fbf6e0b8be +Z 5a688a63ea61023caa210ca9d98db903 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLeWV1oxKgR168RlERAkXLAKCKwAiZiL6LVwUZ5Xo7V1gh47mmNQCdGXl+ -hNkVcTOcCExujWunCRv/xwU= -=LcuG +iD8DBQFLeWyJoxKgR168RlERAltLAJ9EhYGSB7HNvlpLXs8n7ZXBinUlkACfUxu8 +32nUfmidvypW0Im8sUgkg7U= +=aFCH -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 400e4283b3..924897296c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9acfb0694059c80b2efc08a60232d4be91575c32 \ No newline at end of file +c727601eecd85a26dbd4fc36823d77bec34da3c3 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index af56792ecd..5f912f4306 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1853,9 +1853,9 @@ static int shell_exec( /* echo the sql statement if echo on */ if( pArg->echoOn ){ - char *zStmtSql = sqlite3_sql(pStmt); + const char *zStmtSql = sqlite3_sql(pStmt); fprintf(pArg->out,"%s\n", zStmtSql ? zStmtSql : zSql); - } + } /* perform the first step. this will tell us if we ** have a result set or not and how wide it is. diff --git a/src/trigger.c b/src/trigger.c index 51969ce230..642833cb14 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -254,12 +254,12 @@ void sqlite3FinishTrigger( TriggerStep *pStepList, /* The triggered program */ Token *pAll /* Token that describes the complete CREATE TRIGGER */ ){ - Trigger *pTrig = pParse->pNewTrigger; /* Trigger being finished */ - char *zName; /* Name of trigger */ - sqlite3 *db = pParse->db; /* The database */ - DbFixer sFix; - int iDb; /* Database containing the trigger */ - Token nameToken; /* Trigger name for error reporting */ + Trigger *pTrig = pParse->pNewTrigger; /* Trigger being finished */ + char *zName; /* Name of trigger */ + sqlite3 *db = pParse->db; /* The database */ + DbFixer sFix; /* Fixer object */ + int iDb; /* Database containing the trigger */ + Token nameToken; /* Trigger name for error reporting */ pTrig = pParse->pNewTrigger; pParse->pNewTrigger = 0; @@ -278,7 +278,7 @@ void sqlite3FinishTrigger( goto triggerfinish_cleanup; } - /* if we are not initializing, and this trigger is not on a TEMP table, + /* if we are not initializing, ** build the sqlite_master entry */ if( !db->init.busy ){ From 622d2887900da4a6499eec4a5bd8b2af32fb7bc4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 Feb 2010 16:54:55 +0000 Subject: [PATCH 03/50] When creating a trigger on a main database table when there is a TEMP table with the same name, make sure the trigger is bound to the main table. Ticket [985771e11612]. FossilOrigin-Name: ec914af32675e472694270d46f3ba2214eb2fe90 --- manifest | 20 +++++++++---------- manifest.uuid | 2 +- src/trigger.c | 3 ++- test/triggerD.test | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 7c46ac4177..dfea442e14 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\scompiler\swarning\sin\sshell.c.\s\sUpdates\sto\scomments\sin\strigger.c. -D 2010-02-15T15:47:18 +C When\screating\sa\strigger\son\sa\smain\sdatabase\stable\swhen\sthere\sis\sa\sTEMP\stable\nwith\sthe\ssame\sname,\smake\ssure\sthe\strigger\sis\sbound\sto\sthe\smain\stable.\nTicket\s[985771e11612]. +D 2010-02-15T16:54:55 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -207,7 +207,7 @@ F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c 00fed80690ae7f1525483a35861511c48bc579f2 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d -F src/trigger.c a188f616acd9092231068c841e15cb531ff2bc0d +F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 F src/util.c aa0b1da8f71edff84b4b41dbe05fe6ac75d819c6 @@ -717,7 +717,7 @@ F test/trigger9.test 5b0789f1c5c4600961f8e68511b825b87be53e31 F test/triggerA.test 0718ad2d9bfef27c7af00e636df79bee6b988da7 F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe F test/triggerC.test 4083c64d80854d271bad211268a08985f3d61cbd -F test/triggerD.test df3813735294734e276aee16419438efc4ecb348 +F test/triggerD.test c6add3817351451e419f6ff9e9a259b02b6e2de7 F test/types.test 9a825ec8eea4e965d7113b74c76a78bb5240f2ac F test/types2.test 3555aacf8ed8dc883356e59efc314707e6247a84 F test/types3.test a0f66bf12f80fad89493535474f7a6d16fa58150 @@ -790,14 +790,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9acfb0694059c80b2efc08a60232d4be91575c32 -R f3f1e356ae050092c353da0201c436cd +P c727601eecd85a26dbd4fc36823d77bec34da3c3 +R 45004b2e132c529777330e8469a3dee0 U drh -Z 5a688a63ea61023caa210ca9d98db903 +Z b2e9d944fd601fa751cf2872dbab1f73 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLeWyJoxKgR168RlERAltLAJ9EhYGSB7HNvlpLXs8n7ZXBinUlkACfUxu8 -32nUfmidvypW0Im8sUgkg7U= -=aFCH +iD8DBQFLeXxioxKgR168RlERAlHrAJ4+sjtvvNq54HhErGM+S2FPfikqFwCfQzkv +9UxvOxpkUFkuGCjFzxJh+7w= +=TAZV -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 924897296c..2601e3cb66 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c727601eecd85a26dbd4fc36823d77bec34da3c3 \ No newline at end of file +ec914af32675e472694270d46f3ba2214eb2fe90 \ No newline at end of file diff --git a/src/trigger.c b/src/trigger.c index 642833cb14..f57d5600f2 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -126,7 +126,8 @@ void sqlite3BeginTrigger( goto trigger_cleanup; } pTab = sqlite3SrcListLookup(pParse, pTableName); - if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){ + if( db->init.busy==0 && pName2->n==0 && pTab + && pTab->pSchema==db->aDb[1].pSchema ){ iDb = 1; } diff --git a/test/triggerD.test b/test/triggerD.test index 050edc9724..08945081da 100644 --- a/test/triggerD.test +++ b/test/triggerD.test @@ -123,4 +123,52 @@ do_test triggerD-2.4 { } } {r5 1 1 1 201 r6 1 1 1 201} + +########################################################################### +# +# Ticket [985771e1161200ae5eac3162686ea6711c035d08]: +# +# When both a main database table and a TEMP table have the same name, +# and a main database trigge is created on the main table, the trigger +# is incorrectly bound to the TEMP table. For example: +# +# CREATE TABLE t1(x); +# CREATE TEMP TABLE t1(x); +# CREATE TABLE t2(z); +# CREATE TRIGGER main.r1 AFTER INSERT ON t1 BEGIN +# INSERT INTO t2 VALUES(10000 + new.x); +# END; +# INSERT INTO main.t1 VALUES(3); +# INSERT INTO temp.t1 VALUES(4); +# SELECT * FROM t2; +# +# The r1 trigger fires when the value 4 is inserted into the temp.t1 +# table, rather than when value 3 is inserted into main.t1. +# +do_test triggerD-3.1 { + db eval { + CREATE TABLE t300(x); + CREATE TEMP TABLE t300(x); + CREATE TABLE t301(y); + CREATE TRIGGER main.r300 AFTER INSERT ON t300 BEGIN + INSERT INTO t301 VALUES(10000 + new.x); + END; + INSERT INTO main.t300 VALUES(3); + INSERT INTO temp.t300 VALUES(4); + SELECT * FROM t301; + } +} {10003} +do_test triggerD-3.2 { + db eval { + DELETE FROM t301; + CREATE TRIGGER temp.r301 AFTER INSERT ON t300 BEGIN + INSERT INTO t301 VALUES(20000 + new.x); + END; + INSERT INTO main.t300 VALUES(3); + INSERT INTO temp.t300 VALUES(4); + SELECT * FROM t301; + } +} {10003 20004} + + finish_test From 9a6ffc845ba1cd37f6754837224f37dac33bfcb4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 Feb 2010 18:03:20 +0000 Subject: [PATCH 04/50] Fix the ALTER TABLE RENAME command so that it converts FOREIGN KEY constraints in ATTACH-ed and in TEMP tables as well as in the main database. Ticket [13336e9c3c8c3f]. FossilOrigin-Name: ab197d0aaf18016ac2dd3674f49bea5f1556451c --- manifest | 22 +++---- manifest.uuid | 2 +- src/alter.c | 4 +- test/fkey2.test | 163 ++++++++++++++++++++++++++++++++++++++++++++++++ test/tester.tcl | 17 +++-- 5 files changed, 189 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index dfea442e14..ff847cc77c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C When\screating\sa\strigger\son\sa\smain\sdatabase\stable\swhen\sthere\sis\sa\sTEMP\stable\nwith\sthe\ssame\sname,\smake\ssure\sthe\strigger\sis\sbound\sto\sthe\smain\stable.\nTicket\s[985771e11612]. -D 2010-02-15T16:54:55 +C Fix\sthe\sALTER\sTABLE\sRENAME\scommand\sso\sthat\sit\sconverts\sFOREIGN\sKEY\sconstraints\nin\sATTACH-ed\sand\sin\sTEMP\stables\sas\swell\sas\sin\sthe\smain\sdatabase.\nTicket\s[13336e9c3c8c3f]. +D 2010-02-15T18:03:20 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -104,7 +104,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad -F src/alter.c 92ba938565d7cc6bfe92aad6cc90c00800ff21d3 +F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05 F src/analyze.c 55155f05ee9ab4ce33b7a4d19c449053f8935200 F src/attach.c a6b5e97c84c46c731aad064c413e40e12cb718b7 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 @@ -341,7 +341,7 @@ F test/expr.test 9f521ae22f00e074959f72ce2e55d46b9ed23f68 F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8 F test/filefmt.test 84e3d0fe9f12d0d2ac852465c6f8450aea0d6f43 F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da -F test/fkey2.test add654160d1b066f7b866d63d4435954ccbcab7d +F test/fkey2.test e71f5baf9bb42cdba4700d73cba6f4d82fd6b925 F test/fkey3.test 42f88d6048d8dc079e2a8cf7baad1cc1483a7620 F test/fkey_malloc.test a5ede29bd2f6e56dea78c3d43fb86dd696c068c8 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -596,7 +596,7 @@ F test/tclsqlite.test bf4227eb236a4c097aa7974a2bf7d3225acf34be F test/tempdb.test 1bf52da28a9c24e29717362a87722dff08feb72b F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 -F test/tester.tcl f38dd7ca63d81197c853989dbd39dfa3582c9ce7 +F test/tester.tcl e1f581c7a2648a0aaa51135c4d2e7be68f4b9292 F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca @@ -790,14 +790,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c727601eecd85a26dbd4fc36823d77bec34da3c3 -R 45004b2e132c529777330e8469a3dee0 +P ec914af32675e472694270d46f3ba2214eb2fe90 +R b63197d6039614d907827a453eecec99 U drh -Z b2e9d944fd601fa751cf2872dbab1f73 +Z 49dfd565a21afaa90179ba63716c3b3a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLeXxioxKgR168RlERAlHrAJ4+sjtvvNq54HhErGM+S2FPfikqFwCfQzkv -9UxvOxpkUFkuGCjFzxJh+7w= -=TAZV +iD8DBQFLeYxroxKgR168RlERAp42AJ9eXZoQAtGar3vAWWJ+ElAji3XDgACfTqUL +/luMg2NSLMumM1Iu2R9tVWU= +=ahs6 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 2601e3cb66..2f6721b605 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec914af32675e472694270d46f3ba2214eb2fe90 \ No newline at end of file +ab197d0aaf18016ac2dd3674f49bea5f1556451c \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index c4117cf7ef..694b243bd3 100644 --- a/src/alter.c +++ b/src/alter.c @@ -479,9 +479,9 @@ void sqlite3AlterRenameTable( ** for which the renamed table is the parent table. */ if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){ sqlite3NestedParse(pParse, - "UPDATE sqlite_master SET " + "UPDATE \"%w\".%s SET " "sql = sqlite_rename_parent(sql, %Q, %Q) " - "WHERE %s;", zTabName, zName, zWhere); + "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere); sqlite3DbFree(db, zWhere); } } diff --git a/test/fkey2.test b/test/fkey2.test index dc6529be13..10a624ef0a 100644 --- a/test/fkey2.test +++ b/test/fkey2.test @@ -1003,6 +1003,169 @@ ifcapable altertable { do_test fkey2-14.2.2.7 { execsql { INSERT INTO t3 VALUES(1, NULL, 1) } } {} + + # Repeat for TEMP tables + # + drop_all_tables + do_test fkey2-14.1tmp.1 { + # Adding a column with a REFERENCES clause is not supported. + execsql { + CREATE TEMP TABLE t1(a PRIMARY KEY); + CREATE TEMP TABLE t2(a, b); + } + catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 } + } {0 {}} + do_test fkey2-14.1tmp.2 { + catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 } + } {0 {}} + do_test fkey2-14.1tmp.3 { + catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL} + } {0 {}} + do_test fkey2-14.1tmp.4 { + catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'} + } {1 {Cannot add a REFERENCES column with non-NULL default value}} + do_test fkey2-14.1tmp.5 { + catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 } + } {1 {Cannot add a REFERENCES column with non-NULL default value}} + do_test fkey2-14.1tmp.6 { + execsql { + PRAGMA foreign_keys = off; + ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1; + PRAGMA foreign_keys = on; + SELECT sql FROM sqlite_temp_master WHERE name='t2'; + } + } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}} + + do_test fkey2-14.2tmp.1.1 { + test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3 + } {{CREATE TABLE t1(a REFERENCES "t3")}} + do_test fkey2-14.2tmp.1.2 { + test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3 + } {{CREATE TABLE t1(a REFERENCES t2)}} + do_test fkey2-14.2tmp.1.3 { + test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3 + } {{CREATE TABLE t1(a REFERENCES "t3")}} + + # Test ALTER TABLE RENAME TABLE a bit. + # + do_test fkey2-14.2tmp.2.1 { + drop_all_tables + execsql { + CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1); + CREATE TEMP TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2); + CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1); + } + execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'} + } [list \ + {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \ + {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \ + {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \ + ] + do_test fkey2-14.2tmp.2.2 { + execsql { ALTER TABLE t1 RENAME TO t4 } + execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'} + } [list \ + {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \ + {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \ + {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \ + ] + do_test fkey2-14.2tmp.2.3 { + catchsql { INSERT INTO t3 VALUES(1, 2, 3) } + } {1 {foreign key constraint failed}} + do_test fkey2-14.2tmp.2.4 { + execsql { INSERT INTO t4 VALUES(1, NULL) } + } {} + do_test fkey2-14.2tmp.2.5 { + catchsql { UPDATE t4 SET b = 5 } + } {1 {foreign key constraint failed}} + do_test fkey2-14.2tmp.2.6 { + catchsql { UPDATE t4 SET b = 1 } + } {0 {}} + do_test fkey2-14.2tmp.2.7 { + execsql { INSERT INTO t3 VALUES(1, NULL, 1) } + } {} + + # Repeat for ATTACH-ed tables + # + drop_all_tables + do_test fkey2-14.1aux.1 { + # Adding a column with a REFERENCES clause is not supported. + execsql { + ATTACH ':memory:' AS aux; + CREATE TABLE aux.t1(a PRIMARY KEY); + CREATE TABLE aux.t2(a, b); + } + catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 } + } {0 {}} + do_test fkey2-14.1aux.2 { + catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 } + } {0 {}} + do_test fkey2-14.1aux.3 { + catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL} + } {0 {}} + do_test fkey2-14.1aux.4 { + catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'} + } {1 {Cannot add a REFERENCES column with non-NULL default value}} + do_test fkey2-14.1aux.5 { + catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 } + } {1 {Cannot add a REFERENCES column with non-NULL default value}} + do_test fkey2-14.1aux.6 { + execsql { + PRAGMA foreign_keys = off; + ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1; + PRAGMA foreign_keys = on; + SELECT sql FROM aux.sqlite_master WHERE name='t2'; + } + } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}} + + do_test fkey2-14.2aux.1.1 { + test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3 + } {{CREATE TABLE t1(a REFERENCES "t3")}} + do_test fkey2-14.2aux.1.2 { + test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3 + } {{CREATE TABLE t1(a REFERENCES t2)}} + do_test fkey2-14.2aux.1.3 { + test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3 + } {{CREATE TABLE t1(a REFERENCES "t3")}} + + # Test ALTER TABLE RENAME TABLE a bit. + # + do_test fkey2-14.2aux.2.1 { + drop_all_tables + execsql { + CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1); + CREATE TABLE aux.t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2); + CREATE TABLE aux.t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1); + } + execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'} + } [list \ + {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \ + {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \ + {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \ + ] + do_test fkey2-14.2aux.2.2 { + execsql { ALTER TABLE t1 RENAME TO t4 } + execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'} + } [list \ + {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \ + {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \ + {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \ + ] + do_test fkey2-14.2aux.2.3 { + catchsql { INSERT INTO t3 VALUES(1, 2, 3) } + } {1 {foreign key constraint failed}} + do_test fkey2-14.2aux.2.4 { + execsql { INSERT INTO t4 VALUES(1, NULL) } + } {} + do_test fkey2-14.2aux.2.5 { + catchsql { UPDATE t4 SET b = 5 } + } {1 {foreign key constraint failed}} + do_test fkey2-14.2aux.2.6 { + catchsql { UPDATE t4 SET b = 1 } + } {0 {}} + do_test fkey2-14.2aux.2.7 { + execsql { INSERT INTO t3 VALUES(1, NULL, 1) } + } {} } do_test fkey-2.14.3.1 { diff --git a/test/tester.tcl b/test/tester.tcl index 136e116159..8fe877ec01 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -964,11 +964,18 @@ proc drop_all_tables {{db db}} { set pk [$db one "PRAGMA foreign_keys"] $db eval "PRAGMA foreign_keys = OFF" } - foreach {t type} [$db eval { - SELECT name, type FROM sqlite_master - WHERE type IN('table', 'view') AND name NOT like 'sqlite_%' - }] { - $db eval "DROP $type $t" + foreach {idx name file} [db eval {PRAGMA database_list}] { + if {$idx==1} { + set master sqlite_temp_master + } else { + set master $name.sqlite_master + } + foreach {t type} [$db eval " + SELECT name, type FROM $master + WHERE type IN('table', 'view') AND name NOT like 'sqlite_%' + "] { + $db eval "DROP $type $t" + } } ifcapable trigger&&foreignkey { $db eval "PRAGMA foreign_keys = $pk" From 5dcb3937b607322929794c50831a9bd38e456fb3 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Feb 2010 10:59:40 +0000 Subject: [PATCH 05/50] Fix for [e9a9fde1f4]. When opening an existing rtree, determine the node size by inspecting the root node of the r-tree structure (instead of assuming it is a function of the page-size). FossilOrigin-Name: ebc9433fddf78ef7b4237686951d8d79c1c98f03 --- ext/rtree/rtree.c | 137 +++++++++++++++++++++++++----------------- ext/rtree/rtree7.test | 58 ++++++++++++++++++ manifest | 25 +++----- manifest.uuid | 2 +- 4 files changed, 149 insertions(+), 73 deletions(-) create mode 100644 ext/rtree/rtree7.test diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 49c00a35bd..90a9595405 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -423,6 +423,7 @@ nodeAcquire( rc = sqlite3_step(pRtree->pReadNode); if( rc==SQLITE_ROW ){ const u8 *zBlob = sqlite3_column_blob(pRtree->pReadNode, 0); + assert( sqlite3_column_bytes(pRtree->pReadNode, 0)==pRtree->iNodeSize ); memcpy(pNode->zData, zBlob, pRtree->iNodeSize); nodeReference(pParent); }else{ @@ -2619,31 +2620,69 @@ static int rtreeSqlInit( } /* -** This routine queries database handle db for the page-size used by -** database zDb. If successful, the page-size in bytes is written to -** *piPageSize and SQLITE_OK returned. Otherwise, and an SQLite error -** code is returned. +** The second argument to this function contains the text of an SQL statement +** that returns a single integer value. The statement is compiled and executed +** using database connection db. If successful, the integer value returned +** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error +** code is returned and the value of *piVal after returning is not defined. */ -static int getPageSize(sqlite3 *db, const char *zDb, int *piPageSize){ +static int getIntFromStmt(sqlite3 *db, const char *zSql, int *piVal){ int rc = SQLITE_NOMEM; + if( zSql ){ + sqlite3_stmt *pStmt = 0; + rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); + if( rc==SQLITE_OK ){ + if( SQLITE_ROW==sqlite3_step(pStmt) ){ + *piVal = sqlite3_column_int(pStmt, 0); + } + rc = sqlite3_finalize(pStmt); + } + } + return rc; +} + +/* +** This function is called from within the xConnect() or xCreate() method to +** determine the node-size used by the rtree table being created or connected +** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned. +** Otherwise, an SQLite error code is returned. +** +** If this function is being called as part of an xConnect(), then the rtree +** table already exists. In this case the node-size is determined by inspecting +** the root node of the tree. +** +** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. +** This ensures that each node is stored on a single database page. If the +** database page-size is so large that more than RTREE_MAXCELLS entries +** would fit in a single node, use a smaller node-size. +*/ +static int getNodeSize( + sqlite3 *db, /* Database handle */ + Rtree *pRtree, /* Rtree handle */ + int isCreate /* True for xCreate, false for xConnect */ +){ + int rc; char *zSql; - sqlite3_stmt *pStmt = 0; - - zSql = sqlite3_mprintf("PRAGMA %Q.page_size", zDb); - if( !zSql ){ - return SQLITE_NOMEM; + if( isCreate ){ + int iPageSize; + zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); + rc = getIntFromStmt(db, zSql, &iPageSize); + if( rc==SQLITE_OK ){ + pRtree->iNodeSize = iPageSize-64; + if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)iNodeSize ){ + pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS; + } + } + }else{ + zSql = sqlite3_mprintf( + "SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1", + pRtree->zDb, pRtree->zName + ); + rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize); } - rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); - if( rc!=SQLITE_OK ){ - return rc; - } - - if( SQLITE_ROW==sqlite3_step(pStmt) ){ - *piPageSize = sqlite3_column_int(pStmt, 0); - } - return sqlite3_finalize(pStmt); + return rc; } /* @@ -2683,11 +2722,6 @@ static int rtreeInit( return SQLITE_ERROR; } - rc = getPageSize(db, argv[1], &iPageSize); - if( rc!=SQLITE_OK ){ - return rc; - } - /* Allocate the sqlite3_vtab structure */ nDb = strlen(argv[1]); nName = strlen(argv[2]); @@ -2706,44 +2740,37 @@ static int rtreeInit( memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); - /* Figure out the node size to use. By default, use 64 bytes less than - ** the database page-size. This ensures that each node is stored on - ** a single database page. - ** - ** If the databasd page-size is so large that more than RTREE_MAXCELLS - ** entries would fit in a single node, use a smaller node-size. - */ - pRtree->iNodeSize = iPageSize-64; - if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)iNodeSize ){ - pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS; - } + /* Figure out the node size to use. */ + rc = getNodeSize(db, pRtree, isCreate); /* Create/Connect to the underlying relational database schema. If ** that is successful, call sqlite3_declare_vtab() to configure ** the r-tree table schema. */ - if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){ - *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); - }else{ - char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]); - char *zTmp; - int ii; - for(ii=4; zSql && ii Date: Tue, 16 Feb 2010 12:18:47 +0000 Subject: [PATCH 06/50] Change a C++ style comment in os_unix.c to use normal C style commenting. FossilOrigin-Name: 7a1933097f2a95bd495c1621fca99e8952a1b25a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c7e7aebcd9..948de7d862 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfor\s[e9a9fde1f4].\sWhen\sopening\san\sexisting\srtree,\sdetermine\sthe\snode\ssize\sby\sinspecting\sthe\sroot\snode\sof\sthe\sr-tree\sstructure\s(instead\sof\sassuming\sit\sis\sa\sfunction\sof\sthe\spage-size). -D 2010-02-16T10:59:41 +C Change\sa\sC++\sstyle\scomment\sin\sos_unix.c\sto\suse\snormal\sC\sstyle\scommenting. +D 2010-02-16T12:18:48 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -149,7 +149,7 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306 F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30 F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f -F src/os_unix.c 85479b27b995c2924a0905e4767d58598fb45000 +F src/os_unix.c 0af0a55e2dd55bc4f4c3ccf04cc8f1f4a2e2e65f F src/os_win.c 5ffab20249a61e0625f869efe157fa009747039b F src/pager.c 5dee83c3cf4e94b72fcd81dca67abd7617227217 F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54 @@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ab197d0aaf18016ac2dd3674f49bea5f1556451c -R 881d2a8a41b8ae3c95eeef834233ccdb +P ebc9433fddf78ef7b4237686951d8d79c1c98f03 +R b5dfe1f1114f3d23dae72982ad21694f U dan -Z 64c445e5b0bc8d218abafa630888b286 +Z cf26dc12bf459704264dda128f7767fa diff --git a/manifest.uuid b/manifest.uuid index c100d6117a..d566b45fa9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebc9433fddf78ef7b4237686951d8d79c1c98f03 \ No newline at end of file +7a1933097f2a95bd495c1621fca99e8952a1b25a \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 9dc2075579..fd64cb06e3 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5262,7 +5262,7 @@ static int proxyTakeConch(unixFile *pFile){ */ forceNewLockPath = 1; tryOldLockPath = 0; - continue; // go back to the do {} while start point, try again + continue; /* go back to the do {} while start point, try again */ } } if( rc==SQLITE_OK ){ From 4a0b43caadb21ed2bf5a6c6ee7622ac5b734f58b Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 16 Feb 2010 22:00:35 +0000 Subject: [PATCH 07/50] Added additional rounding tests. FossilOrigin-Name: b8ee76bc1fd355110149bd9135dd31a5724c2ac6 --- manifest | 14 ++++----- manifest.uuid | 2 +- test/func.test | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 948de7d862..f1a5dde15d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sa\sC++\sstyle\scomment\sin\sos_unix.c\sto\suse\snormal\sC\sstyle\scommenting. -D 2010-02-16T12:18:48 +C Added\sadditional\srounding\stests. +D 2010-02-16T22:00:36 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -408,7 +408,7 @@ F test/fts3query.test 154fe4b015fd61af523ee083570a134f508f5be7 F test/fts3rnd.test 2f5761db9dd92f6fe09d08976ac658ef521846ed F test/fts3snippet.test 5745ce7270fb754b4f998c6bc33bf843791f6e36 F test/fts4aa.test 9a9bc506487399c17284fa82a72f16d5ced2910c -F test/func.test af106ed834001738246d276659406823e35cde7b +F test/func.test c12663a99d9ad96737b6a3efd65e0d2d436ff4ab F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/fuzz.test a4174c3009a3e2c2e14b31b364ebf7ddb49de2c9 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ebc9433fddf78ef7b4237686951d8d79c1c98f03 -R b5dfe1f1114f3d23dae72982ad21694f -U dan -Z cf26dc12bf459704264dda128f7767fa +P 7a1933097f2a95bd495c1621fca99e8952a1b25a +R ca399e3d0f2d6f8be8f0f4b20e5d3fb6 +U shaneh +Z b58ba50cfe1c773cd5719e055e92f490 diff --git a/manifest.uuid b/manifest.uuid index d566b45fa9..e62bc2eea5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a1933097f2a95bd495c1621fca99e8952a1b25a \ No newline at end of file +b8ee76bc1fd355110149bd9135dd31a5724c2ac6 \ No newline at end of file diff --git a/test/func.test b/test/func.test index 91ae0a5925..ccdda0cd8a 100644 --- a/test/func.test +++ b/test/func.test @@ -235,6 +235,84 @@ ifcapable floatingpoint { do_test func-4.16 { catchsql {SELECT round(b,2.0) FROM t1 ORDER BY b} } {0 {-2.0 1.23 2.0}} + # Verify some values reported on the mailing list. + # Some of these fail on MSVC builds with 64-bit + # long doubles, but not on GCC builds with 80-bit + # long doubles. + for {set i 1} {$i<999} {incr i} { + set x1 [expr 40222.0 + $i + 0.5] + set x2 [expr 40223.0 + $i] + do_test func-4.17.$i { + execsql {SELECT round($x1);} + } $x2 + } + do_test func-4.18 { + execsql {SELECT round(41051.5);} + } {41052.0} + do_test func-4.19 { + execsql {SELECT round(41224.5);} + } {41225.0} + do_test func-4.20 { + execsql {SELECT round(40223.4999999999);} + } {40223.0} + do_test func-4.21 { + execsql {SELECT round(40224.4999999999);} + } {40224.0} + do_test func-4.22 { + execsql {SELECT round(40225.4999999999);} + } {40225.0} + for {set i 1} {$i<10} {incr i} { + do_test func-4.23.$i { + execsql {SELECT round(40223.4999999999,$i);} + } {40223.5} + do_test func-4.24.$i { + execsql {SELECT round(40224.4999999999,$i);} + } {40224.5} + do_test func-4.25.$i { + execsql {SELECT round(40225.4999999999,$i);} + } {40225.5} + } + for {set i 10} {$i<32} {incr i} { + do_test func-4.26.$i { + execsql {SELECT round(40223.4999999999,$i);} + } {40223.4999999999} + do_test func-4.27.$i { + execsql {SELECT round(40224.4999999999,$i);} + } {40224.4999999999} + do_test func-4.28.$i { + execsql {SELECT round(40225.4999999999,$i);} + } {40225.4999999999} + } + do_test func-4.29 { + execsql {SELECT round(1234567890.5);} + } {1234567891.0} + do_test func-4.30 { + execsql {SELECT round(12345678901.5);} + } {12345678902.0} + do_test func-4.31 { + execsql {SELECT round(123456789012.5);} + } {123456789013.0} + do_test func-4.32 { + execsql {SELECT round(1234567890123.5);} + } {1234567890124.0} + do_test func-4.33 { + execsql {SELECT round(12345678901234.5);} + } {12345678901235.0} + do_test func-4.34 { + execsql {SELECT round(1234567890123.35,1);} + } {1234567890123.4} + do_test func-4.35 { + execsql {SELECT round(1234567890123.445,2);} + } {1234567890123.45} + do_test func-4.36 { + execsql {SELECT round(99999999999994.5);} + } {99999999999995.0} + do_test func-4.37 { + execsql {SELECT round(9999999999999.55,1);} + } {9999999999999.6} + do_test func-4.38 { + execsql {SELECT round(9999999999999.555,2);} + } {9999999999999.56} } # Test the upper() and lower() functions From 030ea3179784ccf44d6fe50b2dc39b8e16515edc Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 16 Feb 2010 22:06:30 +0000 Subject: [PATCH 08/50] Remove duplicated assignment in realloc. FossilOrigin-Name: c419955df0ad0507ecb3869786d48458366d4e8f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/mem1.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f1a5dde15d..f6c0a746b8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\sadditional\srounding\stests. -D 2010-02-16T22:00:36 +C Remove\sduplicated\sassignment\sin\srealloc. +D 2010-02-16T22:06:31 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -133,7 +133,7 @@ F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 F src/main.c a0f6dfbdd79e01baf75ad62bdbfdeae9e560eb96 F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 -F src/mem1.c 552f7e11486272f27948d2de9c012884d1f52908 +F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 F src/mem2.c 92b4f772b1ee7469e256f1c2eff0b51a0ba19460 F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3 F src/mem5.c 4837b795ebdecc0cfe1522cd0c8b2c5d84ea490d @@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7a1933097f2a95bd495c1621fca99e8952a1b25a -R ca399e3d0f2d6f8be8f0f4b20e5d3fb6 +P b8ee76bc1fd355110149bd9135dd31a5724c2ac6 +R 5e2126b9b3083501eb493eb6933f3f29 U shaneh -Z b58ba50cfe1c773cd5719e055e92f490 +Z 0a666a93623a5a83ee6f99d90ca54163 diff --git a/manifest.uuid b/manifest.uuid index e62bc2eea5..ddfb159a9a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8ee76bc1fd355110149bd9135dd31a5724c2ac6 \ No newline at end of file +c419955df0ad0507ecb3869786d48458366d4e8f \ No newline at end of file diff --git a/src/mem1.c b/src/mem1.c index fbfa35eb91..67dd474537 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -75,7 +75,6 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){ sqlite3_int64 *p = (sqlite3_int64*)pPrior; assert( pPrior!=0 && nByte>0 ); nByte = ROUND8(nByte); - p = (sqlite3_int64*)pPrior; p--; p = realloc(p, nByte+8 ); if( p ){ From 35c1a793ce5a08da2b26c99bdb7cac3813892afe Mon Sep 17 00:00:00 2001 From: shaneh Date: Wed, 17 Feb 2010 03:57:58 +0000 Subject: [PATCH 09/50] More rounding tests. FossilOrigin-Name: 3863638b8cd8d41cf4abf8b0d618892de845e91f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/func.test | 15 ++++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index f6c0a746b8..b7bb5a4838 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sduplicated\sassignment\sin\srealloc. -D 2010-02-16T22:06:31 +C More\srounding\stests. +D 2010-02-17T03:57:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -408,7 +408,7 @@ F test/fts3query.test 154fe4b015fd61af523ee083570a134f508f5be7 F test/fts3rnd.test 2f5761db9dd92f6fe09d08976ac658ef521846ed F test/fts3snippet.test 5745ce7270fb754b4f998c6bc33bf843791f6e36 F test/fts4aa.test 9a9bc506487399c17284fa82a72f16d5ced2910c -F test/func.test c12663a99d9ad96737b6a3efd65e0d2d436ff4ab +F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/fuzz.test a4174c3009a3e2c2e14b31b364ebf7ddb49de2c9 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b8ee76bc1fd355110149bd9135dd31a5724c2ac6 -R 5e2126b9b3083501eb493eb6933f3f29 +P c419955df0ad0507ecb3869786d48458366d4e8f +R 0374c8d9925a8aac2f74883dcb36ba86 U shaneh -Z 0a666a93623a5a83ee6f99d90ca54163 +Z b4ee0a92d3d0f07e677dbd80998fc3a0 diff --git a/manifest.uuid b/manifest.uuid index ddfb159a9a..168d6eb9e5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c419955df0ad0507ecb3869786d48458366d4e8f \ No newline at end of file +3863638b8cd8d41cf4abf8b0d618892de845e91f \ No newline at end of file diff --git a/test/func.test b/test/func.test index ccdda0cd8a..eef0543986 100644 --- a/test/func.test +++ b/test/func.test @@ -240,18 +240,19 @@ ifcapable floatingpoint { # long doubles, but not on GCC builds with 80-bit # long doubles. for {set i 1} {$i<999} {incr i} { - set x1 [expr 40222.0 + $i + 0.5] + set x1 [expr 40222.5 + $i] set x2 [expr 40223.0 + $i] do_test func-4.17.$i { execsql {SELECT round($x1);} } $x2 } - do_test func-4.18 { - execsql {SELECT round(41051.5);} - } {41052.0} - do_test func-4.19 { - execsql {SELECT round(41224.5);} - } {41225.0} + for {set i 1} {$i<999} {incr i} { + set x1 [expr 40222.05 + $i] + set x2 [expr 40222.10 + $i] + do_test func-4.18.$i { + execsql {SELECT round($x1,1);} + } $x2 + } do_test func-4.20 { execsql {SELECT round(40223.4999999999);} } {40223.0} From 147e176affed4dc2377eaa24dfee4fa2b3004198 Mon Sep 17 00:00:00 2001 From: shaneh Date: Wed, 17 Feb 2010 04:19:27 +0000 Subject: [PATCH 10/50] Avoid using the internal printf routine for round(x,y) in the common case where y==0. FossilOrigin-Name: d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index b7bb5a4838..cb78cc3fd5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\srounding\stests. -D 2010-02-17T03:57:59 +C Avoid\susing\sthe\sinternal\sprintf\sroutine\sfor\sround(x,y)\sin\sthe\scommon\scase\swhere\sy==0. +D 2010-02-17T04:19:27 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -120,7 +120,7 @@ F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581 F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0 -F src/func.c 7cd1b3abad8bcccf555fad9274d608da972467a3 +F src/func.c 3864490a90a03ab1d657cdd04da78879c18b18d1 F src/global.c 75946a4a2ab41c6ae58f10ca0ed31b3449694b26 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c419955df0ad0507ecb3869786d48458366d4e8f -R 0374c8d9925a8aac2f74883dcb36ba86 +P 3863638b8cd8d41cf4abf8b0d618892de845e91f +R 4a859d44fd44fb2e90c77b0569157d3b U shaneh -Z b4ee0a92d3d0f07e677dbd80998fc3a0 +Z 9dee3f892d9b2c7e04d5a57e6362923c diff --git a/manifest.uuid b/manifest.uuid index 168d6eb9e5..3eae5f6ee4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3863638b8cd8d41cf4abf8b0d618892de845e91f \ No newline at end of file +d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf \ No newline at end of file diff --git a/src/func.c b/src/func.c index c1d3e9060f..d633ff83c3 100644 --- a/src/func.c +++ b/src/func.c @@ -271,14 +271,24 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; r = sqlite3_value_double(argv[0]); - zBuf = sqlite3_mprintf("%.*f",n,r); - if( zBuf==0 ){ - sqlite3_result_error_nomem(context); + /* If Y==0 and X will fit in a 64-bit int, + ** handle the rounding directly, + ** otherwise use printf. + */ + if( n==0 && r>=0 && r Date: Wed, 17 Feb 2010 17:48:46 +0000 Subject: [PATCH 11/50] Consistent use of #ifdef for SQLITE_HAS_CODEC to avoid confusion. FossilOrigin-Name: 34a3413a5318050254b246ad859c91c134516a32 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/attach.c | 2 +- src/pragma.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index cb78cc3fd5..98c2c6cdc7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\susing\sthe\sinternal\sprintf\sroutine\sfor\sround(x,y)\sin\sthe\scommon\scase\swhere\sy==0. -D 2010-02-17T04:19:27 +C Consistent\suse\sof\s#ifdef\sfor\sSQLITE_HAS_CODEC\sto\savoid\sconfusion. +D 2010-02-17T17:48:47 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -104,7 +104,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05 F src/analyze.c 55155f05ee9ab4ce33b7a4d19c449053f8935200 -F src/attach.c a6b5e97c84c46c731aad064c413e40e12cb718b7 +F src/attach.c f6d33268019460724e4c57aeec543eaaa55d8310 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 744e98359dfc79fed43e8dec911e33e108b06aae F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 @@ -157,7 +157,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 -F src/pragma.c 55cfa9daa145075cdb928dfce53e55665d6ad709 +F src/pragma.c 5febf8b5d88cc331effb3f2e14d0473488649b1e F src/prepare.c d4cd38ccfb51f1424d0e61d4878a810b7e1ebb60 F src/printf.c 2c2702dc4955394dae554b7c45f45656eb42de7f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3863638b8cd8d41cf4abf8b0d618892de845e91f -R 4a859d44fd44fb2e90c77b0569157d3b +P d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf +R a0fcf012eeeaa6a43756a232ecac05ef U shaneh -Z 9dee3f892d9b2c7e04d5a57e6362923c +Z 6db38cc05906d785948a9a447f1df2f3 diff --git a/manifest.uuid b/manifest.uuid index 3eae5f6ee4..5568ba96f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf \ No newline at end of file +34a3413a5318050254b246ad859c91c134516a32 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 984d62fce7..f4b9428c0f 100644 --- a/src/attach.c +++ b/src/attach.c @@ -150,7 +150,7 @@ static void attachFunc( aNew->zName = sqlite3DbStrDup(db, zName); aNew->safety_level = 3; -#if SQLITE_HAS_CODEC +#ifdef SQLITE_HAS_CODEC if( rc==SQLITE_OK ){ extern int sqlite3CodecAttach(sqlite3*, int, const void*, int); extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*); diff --git a/src/pragma.c b/src/pragma.c index bcc85cbb77..de5a15e27d 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1393,7 +1393,7 @@ void sqlite3Pragma( }else #endif -#if SQLITE_HAS_CODEC +#ifdef SQLITE_HAS_CODEC if( sqlite3StrICmp(zLeft, "key")==0 && zRight ){ sqlite3_key(db, zRight, sqlite3Strlen30(zRight)); }else @@ -1416,9 +1416,9 @@ void sqlite3Pragma( } }else #endif -#if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD) +#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD) if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){ -#if SQLITE_HAS_CODEC +#ifdef SQLITE_HAS_CODEC if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){ sqlite3_activate_see(&zRight[4]); } From da730f6eb4e1df1b844b8c0cb0b68f3389a37960 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Feb 2010 08:19:19 +0000 Subject: [PATCH 12/50] Allow statements like "REPLACE INTO tbl(rowid) VALUES(...)" to run without a statement journal as long as there are no triggers, foreign keys or indexes. FossilOrigin-Name: 0e4225804010cb0e3f254e2dbffc4fe0e7d982ce --- manifest | 17 ++++----- manifest.uuid | 2 +- src/insert.c | 24 ++++++++++--- test/fts3snippet.test | 2 +- test/stmt.test | 80 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 test/stmt.test diff --git a/manifest b/manifest index 98c2c6cdc7..6ed19049b8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Consistent\suse\sof\s#ifdef\sfor\sSQLITE_HAS_CODEC\sto\savoid\sconfusion. -D 2010-02-17T17:48:47 +C Allow\sstatements\slike\s"REPLACE\sINTO\stbl(rowid)\sVALUES(...)"\sto\srun\swithout\sa\sstatement\sjournal\sas\slong\sas\sthere\sare\sno\striggers,\sforeign\skeys\sor\sindexes. +D 2010-02-18T08:19:20 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -125,7 +125,7 @@ F src/global.c 75946a4a2ab41c6ae58f10ca0ed31b3449694b26 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 11eeb4f2e5d57b7c106f0c28eea8d0dd896dfd70 +F src/insert.c 76d6b44a9f9050134fd81205f4b792cbdac7c925 F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e @@ -406,7 +406,7 @@ F test/fts3malloc.test 059592c4f37ccd30138bbf8e3e5b7982cb5c8f2e F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 F test/fts3query.test 154fe4b015fd61af523ee083570a134f508f5be7 F test/fts3rnd.test 2f5761db9dd92f6fe09d08976ac658ef521846ed -F test/fts3snippet.test 5745ce7270fb754b4f998c6bc33bf843791f6e36 +F test/fts3snippet.test 9f9a4a7e396c5d8ce2898be65ebabc429555430f F test/fts4aa.test 9a9bc506487399c17284fa82a72f16d5ced2910c F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f @@ -584,6 +584,7 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/sqllimits1.test e90a0ed94452076f6a10209d378e06b5f75ef0a0 +F test/stmt.test 877d41d41bfbbf27365b4e498c4b5b4b4d61818d F test/subquery.test b524f57c9574b2c0347045b4510ef795d4686796 F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a @@ -788,7 +789,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf -R a0fcf012eeeaa6a43756a232ecac05ef -U shaneh -Z 6db38cc05906d785948a9a447f1df2f3 +P 34a3413a5318050254b246ad859c91c134516a32 +R 9abb5e0ed22f7d06fb4491d50076ada9 +U dan +Z a6ef964fdd6cde6844284b1aa32499cc diff --git a/manifest.uuid b/manifest.uuid index 5568ba96f1..e82bce46c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34a3413a5318050254b246ad859c91c134516a32 \ No newline at end of file +0e4225804010cb0e3f254e2dbffc4fe0e7d982ce \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 9bd9085343..5379762069 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1261,19 +1261,33 @@ void sqlite3GenerateConstraintChecks( ** the triggers and remove both the table and index b-tree entries. ** ** Otherwise, if there are no triggers or the recursive-triggers - ** flag is not set, call GenerateRowIndexDelete(). This removes - ** the index b-tree entries only. The table b-tree entry will be - ** replaced by the new entry when it is inserted. */ + ** flag is not set, but the table has one or more indexes, call + ** GenerateRowIndexDelete(). This removes the index b-tree entries + ** only. The table b-tree entry will be replaced by the new entry + ** when it is inserted. + ** + ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called, + ** also invoke MultiWrite() to indicate that this VDBE may require + ** statement rollback (if the statement is aborted after the delete + ** takes place). Earlier versions called sqlite3MultiWrite() regardless, + ** but being more selective here allows statements like: + ** + ** REPLACE INTO t(rowid) VALUES($newrowid) + ** + ** to run without a statement journal if there are no indexes on the + ** table. + */ Trigger *pTrigger = 0; if( pParse->db->flags&SQLITE_RecTriggers ){ pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); } - sqlite3MultiWrite(pParse); if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ + sqlite3MultiWrite(pParse); sqlite3GenerateRowDelete( pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace ); - }else{ + }else if( pTab->pIndex ){ + sqlite3MultiWrite(pParse); sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0); } seenReplace = 1; diff --git a/test/fts3snippet.test b/test/fts3snippet.test index 614691a8b1..e7adaee046 100644 --- a/test/fts3snippet.test +++ b/test/fts3snippet.test @@ -342,7 +342,7 @@ foreach {DO_MALLOC_TEST enc} { } execsql COMMIT } {} - do_snippet_test $T.7.2 {one two} -1 3 {*}$testresults + eval [list do_snippet_test $T.7.2 {one two} -1 3] $testresults ########################################################################## # Test the matchinfo function. diff --git a/test/stmt.test b/test/stmt.test new file mode 100644 index 0000000000..56faa896d6 --- /dev/null +++ b/test/stmt.test @@ -0,0 +1,80 @@ +# 2010 February 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. +# +#*********************************************************************** +# +# The tests in this file check that SQLite uses (or does not use) a +# statement journal for various SQL statements. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_test stmt-1.1 { + execsql { CREATE TABLE t1(a integer primary key, b INTEGER NOT NULL) } +} {} + +# The following tests verify the method used for the tests in this file - +# that if a statement journal is required by a statement it is opened and +# remains open until the current transaction is committed or rolled back. +# +do_test stmt-1.2 { + set sqlite_open_file_count +} {1} +do_test stmt-1.3 { + execsql { + BEGIN; + INSERT INTO t1 VALUES(1, 1); + } + set sqlite_open_file_count +} {2} +do_test stmt-1.4 { + execsql { + INSERT INTO t1 SELECT a+1, b+1 FROM t1; + } + set sqlite_open_file_count +} {3} +do_test stmt-1.5 { + execsql COMMIT + set sqlite_open_file_count +} {1} +do_test stmt-1.6 { + execsql { + BEGIN; + INSERT INTO t1 SELECT a+2, b+2 FROM t1; + } + set sqlite_open_file_count +} {3} +do_test stmt-1.7 { + execsql COMMIT + set sqlite_open_file_count +} {1} + + +proc filecount {testname sql expected} { + uplevel [list do_test $testname [subst -nocommand { + execsql BEGIN + execsql { $sql } + set ret [set sqlite_open_file_count] + execsql ROLLBACK + set ret + }] $expected] +} + +filecount stmt-2.1 { INSERT INTO t1 VALUES(5, 5) } 2 +filecount stmt-2.2 { REPLACE INTO t1 VALUES(5, 5) } 2 +filecount stmt-2.3 { INSERT INTO t1 SELECT 5, 5 } 3 + +do_test stmt-2.4 { + execsql { CREATE INDEX i1 ON t1(b) } +} {} +filecount stmt-2.5 { REPLACE INTO t1 VALUES(5, 5) } 3 + +finish_test + From 3f280701095c788a830a80927cc0af9ae9cfd036 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Feb 2010 18:45:09 +0000 Subject: [PATCH 13/50] Add a new, experimental logging interface designed to aid in debugging of deeply embedded projects that use SQLite. FossilOrigin-Name: 103321e37ae46eacfad4e127d13477ad5dd02bab --- manifest | 32 +++++++++++++++++++++----------- manifest.uuid | 2 +- src/global.c | 2 ++ src/main.c | 10 ++++++++++ src/printf.c | 22 ++++++++++++++++++++++ src/sqlite.h.in | 16 +++++++++++++++- src/sqliteInt.h | 2 ++ 7 files changed, 73 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 6ed19049b8..58fc3f466d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Allow\sstatements\slike\s"REPLACE\sINTO\stbl(rowid)\sVALUES(...)"\sto\srun\swithout\sa\sstatement\sjournal\sas\slong\sas\sthere\sare\sno\striggers,\sforeign\skeys\sor\sindexes. -D 2010-02-18T08:19:20 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Add\sa\snew,\sexperimental\slogging\sinterface\sdesigned\sto\said\sin\sdebugging\sof\ndeeply\sembedded\sprojects\sthat\suse\sSQLite. +D 2010-02-18T18:45:10 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -121,7 +124,7 @@ F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0 F src/func.c 3864490a90a03ab1d657cdd04da78879c18b18d1 -F src/global.c 75946a4a2ab41c6ae58f10ca0ed31b3449694b26 +F src/global.c 5a9c1e3c93213ca574786ac1caa976ce8f709105 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 @@ -130,7 +133,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c a0f6dfbdd79e01baf75ad62bdbfdeae9e560eb96 +F src/main.c 36c1c11ee2677ae247e0c947f9293749ee5ac85f F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 @@ -159,15 +162,15 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 F src/pragma.c 5febf8b5d88cc331effb3f2e14d0473488649b1e F src/prepare.c d4cd38ccfb51f1424d0e61d4878a810b7e1ebb60 -F src/printf.c 2c2702dc4955394dae554b7c45f45656eb42de7f +F src/printf.c 35d62dffdcae3d905561fdeb78eb0f17049a103e F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 56ecd50851afa9dbcc1803ef86a9b17b3f3d3b89 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 F src/shell.c 56521a172567f5f9f59f528599bf63380e150ac4 -F src/sqlite.h.in 2afdca943d145f84f55468b1ab608df0d719c318 +F src/sqlite.h.in 7725ebcd19ea2bc3cb64631682dda9b773a31b6b F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 -F src/sqliteInt.h a1df33a2c9a0c5062088b655ddf10237f1bcef2f +F src/sqliteInt.h f86cce6239b02a913aad6bf8052c2541a2c0e813 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 F src/status.c e651be6b30d397d86384c6867bc016e4913bcac7 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -789,7 +792,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 34a3413a5318050254b246ad859c91c134516a32 -R 9abb5e0ed22f7d06fb4491d50076ada9 -U dan -Z a6ef964fdd6cde6844284b1aa32499cc +P 0e4225804010cb0e3f254e2dbffc4fe0e7d982ce +R e1b84b3199b12981899c4cf8ff08b1fe +U drh +Z 01212a28378b63d61c38823b1b1cabd0 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.10 (Darwin) + +iEYEARECAAYFAkt9irYACgkQoxKgR168RlFqLACfTtjHG4O+0YQ6hh1MZq3NFfjO +3wAAn2U6GgjbwSAri4XLyLGkLsGJgnkn +=i25A +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e82bce46c1..0ead8aa2d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e4225804010cb0e3f254e2dbffc4fe0e7d982ce \ No newline at end of file +103321e37ae46eacfad4e127d13477ad5dd02bab \ No newline at end of file diff --git a/src/global.c b/src/global.c index bdfd1ff293..673a274ccc 100644 --- a/src/global.c +++ b/src/global.c @@ -164,6 +164,8 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { 0, /* isPCacheInit */ 0, /* pInitMutex */ 0, /* nRefInitMutex */ + 0, /* xLog */ + 0, /* pLogArg */ }; diff --git a/src/main.c b/src/main.c index 07fe15ce72..e4419d269d 100644 --- a/src/main.c +++ b/src/main.c @@ -378,6 +378,16 @@ int sqlite3_config(int op, ...){ sqlite3GlobalConfig.nLookaside = va_arg(ap, int); break; } + + /* Record a pointer to the logger funcction and its first argument. + ** The default is NULL. Logging is disabled if the function pointer is + ** NULL. + */ + case SQLITE_CONFIG_LOG: { + sqlite3GlobalConfig.xLog = va_arg(ap, void(*)(void*,int,const char*)); + sqlite3GlobalConfig.pLogArg = va_arg(ap, void*); + break; + } default: { rc = SQLITE_ERROR; diff --git a/src/printf.c b/src/printf.c index fdd4793c36..2966946f95 100644 --- a/src/printf.c +++ b/src/printf.c @@ -939,6 +939,28 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ return z; } +/* +** Format and write a message to the log if logging is enabled. +*/ +void sqlite3_log(int iPriority, const char *zFormat, ...){ + void (*xLog)(void*, int, const char*); /* The global logger function */ + void *pLogArg; /* First argument to the logger */ + va_list ap; /* Vararg list */ + char *zMsg; /* Complete log message */ + + xLog = sqlite3GlobalConfig.xLog; + if( xLog ){ + va_start(ap, zFormat); + sqlite3BeginBenignMalloc(); + zMsg = sqlite3_vmprintf(zFormat, ap); + sqlite3EndBenignMalloc(); + va_end(ap); + pLogArg = sqlite3GlobalConfig.pLogArg; + xLog(pLogArg, iPriority, zMsg ? zMsg : zFormat); + sqlite3_free(zMsg); + } +} + #if defined(SQLITE_DEBUG) /* ** A version of printf() that understands %lld. Used for debugging. diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e1b8dc61fb..bd610834ef 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -914,7 +914,6 @@ int sqlite3_os_end(void); /* ** CAPI3REF: Configuring The SQLite Library -** EXPERIMENTAL ** ** The sqlite3_config() interface is used to make global configuration ** changes to SQLite in order to tune SQLite to the specific needs of @@ -1255,6 +1254,7 @@ struct sqlite3_mem_methods { #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ +#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ /* ** CAPI3REF: Configuration Options @@ -5663,6 +5663,20 @@ int sqlite3_unlock_notify( */ int sqlite3_strnicmp(const char *, const char *, int); +/* +** CAPI3REF: Error Logging Interface +** EXPERIMENTAL +** +** ^The [sqlite3_log()] interface writes a message into the error log +** established by the [SQLITE_CONFIG_ERRORLOG] option to [sqlite3_config()]. +** +** The sqlite3_log() interface is intended for use by extensions such as +** virtual tables, collating functions, and SQL functions. While there is +** nothing to prevent an application from calling sqlite3_log(), doing so +** is considered bad form. +*/ +void sqlite3_log(int iPriority, const char *zFormat, ...); + /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ff90e03079..a576dd6823 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2370,6 +2370,8 @@ struct Sqlite3Config { int isPCacheInit; /* True after malloc is initialized */ sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ int nRefInitMutex; /* Number of users of pInitMutex */ + void (*xLog)(void*,int,const char*); /* Function for logging */ + void *pLogArg; /* First argument to xLog() */ }; /* From 195475d839e18baa543bb8fe0d8b223e3e91f076 Mon Sep 17 00:00:00 2001 From: shaneh Date: Fri, 19 Feb 2010 04:28:08 +0000 Subject: [PATCH 14/50] Changes to pragma integrity_check to check rowid order. Tests of same in corruptE.test. FossilOrigin-Name: cae47c5b09cb122689bcb020a66ce14982cc4aa8 --- manifest | 27 +++---- manifest.uuid | 2 +- src/btree.c | 63 +++++++++++++++-- test/corrupt7.test | 2 +- test/corruptE.test | 171 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 239 insertions(+), 26 deletions(-) create mode 100644 test/corruptE.test diff --git a/manifest b/manifest index 58fc3f466d..48afeee08a 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Add\sa\snew,\sexperimental\slogging\sinterface\sdesigned\sto\said\sin\sdebugging\sof\ndeeply\sembedded\sprojects\sthat\suse\sSQLite. -D 2010-02-18T18:45:10 +C Changes\sto\spragma\sintegrity_check\sto\scheck\srowid\sorder.\s\sTests\sof\ssame\sin\scorruptE.test. +D 2010-02-19T04:28:09 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -112,7 +109,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 744e98359dfc79fed43e8dec911e33e108b06aae F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c c9ee3c30fbf21ebb4f45c244bd47d7999e6f2704 +F src/btree.c b7ac4420d10662259ad3421145eab16a279f5bd3 F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 81412e0f3cabd0cc7a71a1644c46d9ccad9613f5 @@ -300,13 +297,14 @@ F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32 F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff F test/corrupt5.test c23da7bfb20917cc7fdbb13ee25c7cc4e9fffeff F test/corrupt6.test e69b877d478224deab7b66844566258cecacd25e -F test/corrupt7.test e66cb109ed64e7ac985d8b4a3422c213d074c62d +F test/corrupt7.test 1eb2214f29474fa6b155aa3da8a7d46bf52089e1 F test/corrupt8.test 9992ef7f67cefc576b92373f6bf5ab8775280f51 F test/corrupt9.test 4aa1cb1ef091cb0e13e89a819c72911631b5176a F test/corruptA.test 99e95620b980161cb3e79f06a884a4bb8ae265ff F test/corruptB.test 66b4544104dd03d0f33ea69ddac3fa4a682cd3c2 F test/corruptC.test 691ed070baef5e1345939caadf270a52837a5064 F test/corruptD.test 3ae6e2dc6e2226c6935a8a40d4b5ee3eba75f8c0 +F test/corruptE.test dbf66cae4c0e977ca9625a9114cdd01df8967bef F test/count.test 454e1ce985c94d13efeac405ce54439f49336163 F test/crash.test 1b6ac8410689ff78028887f445062dc897c9ac89 F test/crash2.test 5b14d4eb58b880e231361d3b609b216acda86651 @@ -792,14 +790,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0e4225804010cb0e3f254e2dbffc4fe0e7d982ce -R e1b84b3199b12981899c4cf8ff08b1fe -U drh -Z 01212a28378b63d61c38823b1b1cabd0 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.10 (Darwin) - -iEYEARECAAYFAkt9irYACgkQoxKgR168RlFqLACfTtjHG4O+0YQ6hh1MZq3NFfjO -3wAAn2U6GgjbwSAri4XLyLGkLsGJgnkn -=i25A ------END PGP SIGNATURE----- +P 103321e37ae46eacfad4e127d13477ad5dd02bab +R becff0b48e882ac8f957bf23a46ac2b6 +U shaneh +Z 75f7bf2a2627891ab273971d988089a2 diff --git a/manifest.uuid b/manifest.uuid index 0ead8aa2d9..459fd3c446 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -103321e37ae46eacfad4e127d13477ad5dd02bab \ No newline at end of file +cae47c5b09cb122689bcb020a66ce14982cc4aa8 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 68f2907203..7754f3a213 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7411,7 +7411,9 @@ static void checkList( static int checkTreePage( IntegrityCk *pCheck, /* Context for the sanity check */ int iPage, /* Page number of the page to check */ - char *zParentContext /* Parent context */ + char *zParentContext, /* Parent context */ + i64 *pnParentMinKey, + i64 *pnParentMaxKey ){ MemPage *pPage; int i, rc, depth, d2, pgno, cnt; @@ -7422,6 +7424,8 @@ static int checkTreePage( int usableSize; char zContext[100]; char *hit = 0; + i64 nMinKey = 0; + i64 nMaxKey = 0; sqlite3_snprintf(sizeof(zContext), zContext, "Page %d: ", iPage); @@ -7464,6 +7468,16 @@ static int checkTreePage( btreeParseCellPtr(pPage, pCell, &info); sz = info.nData; if( !pPage->intKey ) sz += (int)info.nKey; + /* For intKey pages, check that the keys are in order. + */ + else if( i==0 ) nMinKey = nMaxKey = info.nKey; + else{ + if( info.nKey <= nMaxKey ){ + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (previous was %lld)", info.nKey, nMaxKey); + } + nMaxKey = info.nKey; + } assert( sz==info.nPayload ); if( (sz>info.nLocal) && (&pCell[info.iOverflow]<=&pPage->aData[pBt->usableSize]) @@ -7487,25 +7501,62 @@ static int checkTreePage( checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext); } #endif - d2 = checkTreePage(pCheck, pgno, zContext); + d2 = checkTreePage(pCheck, pgno, zContext, &nMinKey, i==0 ? NULL : &nMaxKey); if( i>0 && d2!=depth ){ checkAppendMsg(pCheck, zContext, "Child page depth differs"); } depth = d2; } } + if( !pPage->leaf ){ pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]); sqlite3_snprintf(sizeof(zContext), zContext, "On page %d at right child: ", iPage); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ - checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, 0); + checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext); } #endif - checkTreePage(pCheck, pgno, zContext); + checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey); } + /* For intKey leaf pages, check that the min/max keys are in order + ** with any left/parent/right pages. + */ + if( pPage->leaf && pPage->intKey ){ + /* if we are a left child page */ + if( pnParentMinKey ){ + /* if we are the left most child page */ + if( !pnParentMaxKey ){ + if( nMaxKey > *pnParentMinKey ){ + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (max larger than parent min of %lld)", + nMaxKey, *pnParentMinKey); + } + }else{ + if( nMinKey <= *pnParentMinKey ){ + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (min less than parent min of %lld)", + nMinKey, *pnParentMinKey); + } + if( nMaxKey > *pnParentMaxKey ){ + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (max larger than parent max of %lld)", + nMaxKey, *pnParentMaxKey); + } + *pnParentMinKey = nMaxKey; + } + /* else if we're a right child page */ + } else if( pnParentMaxKey ){ + if( nMinKey <= *pnParentMaxKey ){ + checkAppendMsg(pCheck, zContext, + "Rowid %lld out of order (min less than parent max of %lld)", + nMinKey, *pnParentMaxKey); + } + } + } + /* Check for complete coverage of the page */ data = pPage->aData; @@ -7529,7 +7580,7 @@ static int checkTreePage( } if( (pc+size-1)>=usableSize ){ checkAppendMsg(pCheck, 0, - "Corruption detected in cell %d on page %d",i,iPage,0); + "Corruption detected in cell %d on page %d",i,iPage); }else{ for(j=pc+size-1; j>=pc; j--) hit[j]++; } @@ -7635,7 +7686,7 @@ char *sqlite3BtreeIntegrityCheck( checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0, 0); } #endif - checkTreePage(&sCheck, aRoot[i], "List of tree roots: "); + checkTreePage(&sCheck, aRoot[i], "List of tree roots: ", NULL, NULL); } /* Make sure every page in the file is referenced diff --git a/test/corrupt7.test b/test/corrupt7.test index 8f8d437a62..39aa62018e 100644 --- a/test/corrupt7.test +++ b/test/corrupt7.test @@ -89,7 +89,7 @@ Corruption detected in cell 15 on page 2}} sqlite3 db test.db db eval {PRAGMA integrity_check(1)} } {{*** in database main *** -Corruption detected in cell 15 on page 2}} +On tree page 2 cell 15: Rowid 0 out of order (previous was 15)}} } # The code path that was causing the buffer overrun that this test diff --git a/test/corruptE.test b/test/corruptE.test new file mode 100644 index 0000000000..35fa545b4d --- /dev/null +++ b/test/corruptE.test @@ -0,0 +1,171 @@ +# 2010 February 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. +# +# This file implements tests to make sure SQLite does not crash or +# segfault if it sees a corrupt database file. It specifcally +# focuses on rowid order corruption. +# +# $Id: corruptE.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $ + +catch {file delete -force test.db test.db-journal test.bu} + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Construct a compact, dense database for testing. +# +do_test corruptE-1.1 { + execsql { + PRAGMA auto_vacuum = 0; + PRAGMA legacy_file_format=1; + BEGIN; + CREATE TABLE t1(x,y); + INSERT INTO t1 VALUES(1,1); + INSERT OR IGNORE INTO t1 SELECT x*2,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*3,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*5,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*7,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*11,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*13,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*17,y FROM t1; + INSERT OR IGNORE INTO t1 SELECT x*19,y FROM t1; + CREATE INDEX t1i1 ON t1(x); + CREATE TABLE t2 AS SELECT x,2 as y FROM t1 WHERE rowid%5!=0; + COMMIT; + } +} {} + +ifcapable {integrityck} { + integrity_check corruptE-1.2 +} + +# Copy file $from into $to +# +proc copy_file {from to} { + file copy -force $from $to +} + +# Setup for the tests. Make a backup copy of the good database in test.bu. +# +db close +copy_file test.db test.bu +sqlite3 db test.db +set fsize [file size test.db] + + +do_test corruptE-2.1 { + db close + copy_file test.bu test.db + + # insert corrupt byte(s) + hexio_write test.db 2041 [format %02x 0x2e] + + sqlite3 db test.db + + set res [ catchsql {PRAGMA integrity_check} ] + set ans [lindex $res 1] + + list [regexp {out of order.*previous was} $ans] \ + [regexp {out of order.*max larger than parent max} $ans] +} {1 1} + +do_test corruptE-2.2 { + db close + copy_file test.bu test.db + + # insert corrupt byte(s) + hexio_write test.db 2047 [format %02x 0x84] + + sqlite3 db test.db + + set res [ catchsql {PRAGMA integrity_check} ] + set ans [lindex $res 1] + + list [regexp {out of order.*previous was} $ans] \ + [regexp {out of order.*min less than parent min} $ans] +} {1 1} + +do_test corruptE-2.3 { + db close + copy_file test.bu test.db + + # insert corrupt byte(s) + hexio_write test.db 7420 [format %02x 0xa8] + hexio_write test.db 10459 [format %02x 0x8d] + + sqlite3 db test.db + + set res [ catchsql {PRAGMA integrity_check} ] + set ans [lindex $res 1] + + list [regexp {out of order.*max larger than parent min} $ans] +} {1} + +do_test corruptE-2.4 { + db close + copy_file test.bu test.db + + # insert corrupt byte(s) + hexio_write test.db 10233 [format %02x 0xd0] + + sqlite3 db test.db + + set res [ catchsql {PRAGMA integrity_check} ] + set ans [lindex $res 1] + + list [regexp {out of order.*min less than parent max} $ans] +} {1} + + +set tests [list {10233 0xd0} \ + {941 0x42} \ + {1028 0x53} \ + {2041 0xd0} \ + {2042 0x1f} \ + {2047 0xaa} \ + {2263 0x29} \ + {2274 0x75} \ + {3267 0xf2} \ + {4104 0x2c} \ + {5113 0x36} \ + {10233 0x84} \ + {10234 0x74} \ + {10239 0x41} \ + {10453 0x11} \ + {11273 0x28} \ + {11455 0x11} \ + {11461 0xe6} \ + {12281 0x99} \ + {12296 0x9e} \ + {12297 0xd7} \ + {13303 0x53} ] + +set tc 1 +foreach test $tests { + do_test corruptE-3.$tc { + db close + copy_file test.bu test.db + + # insert corrupt byte(s) + hexio_write test.db [lindex $test 0] [format %02x [lindex $test 1]] + + sqlite3 db test.db + + set res [ catchsql {PRAGMA integrity_check} ] + set ans [lindex $res 1] + + list [regexp {out of order} $ans] + } {1} + incr tc 1 +} + +finish_test From a756466349526075311db0e7e5aca63bff482d00 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 22 Feb 2010 19:32:31 +0000 Subject: [PATCH 15/50] Log all error messages if logging is enabled. FossilOrigin-Name: a8076aede33c07e9a2aaa05be8a888f37b45e41c --- manifest | 36 +++++++++++++++++++++++------------- manifest.uuid | 2 +- src/backup.c | 2 +- src/build.c | 5 ++--- src/printf.c | 6 +++--- src/resolve.c | 13 +++++++++---- src/sqlite.h.in | 22 +++++++++++----------- src/sqliteInt.h | 2 +- src/util.c | 25 ++++++++++++------------- 9 files changed, 63 insertions(+), 50 deletions(-) diff --git a/manifest b/manifest index 48afeee08a..56d862bfc7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Changes\sto\spragma\sintegrity_check\sto\scheck\srowid\sorder.\s\sTests\sof\ssame\sin\scorruptE.test. -D 2010-02-19T04:28:09 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Log\sall\serror\smessages\sif\slogging\sis\senabled. +D 2010-02-22T19:32:32 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -106,13 +109,13 @@ F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05 F src/analyze.c 55155f05ee9ab4ce33b7a4d19c449053f8935200 F src/attach.c f6d33268019460724e4c57aeec543eaaa55d8310 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 744e98359dfc79fed43e8dec911e33e108b06aae +F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c b7ac4420d10662259ad3421145eab16a279f5bd3 F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 -F src/build.c 81412e0f3cabd0cc7a71a1644c46d9ccad9613f5 +F src/build.c 254a273acb8923f3bdecc933d787f4f67737c489 F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f F src/complete.c 4c8a742c4a4a6d9c835912648f5c8f032ea36c7b F src/date.c 485a4409a384310e6d93fd1104a9d0a8658becd9 @@ -159,15 +162,15 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 F src/pragma.c 5febf8b5d88cc331effb3f2e14d0473488649b1e F src/prepare.c d4cd38ccfb51f1424d0e61d4878a810b7e1ebb60 -F src/printf.c 35d62dffdcae3d905561fdeb78eb0f17049a103e +F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 -F src/resolve.c 56ecd50851afa9dbcc1803ef86a9b17b3f3d3b89 +F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 F src/shell.c 56521a172567f5f9f59f528599bf63380e150ac4 -F src/sqlite.h.in 7725ebcd19ea2bc3cb64631682dda9b773a31b6b +F src/sqlite.h.in 16f33c1ceb971bfa7a04a73039947630f445146e F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 -F src/sqliteInt.h f86cce6239b02a913aad6bf8052c2541a2c0e813 +F src/sqliteInt.h d5fe1c8335b5bf376639837fa42124327cdb6767 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 F src/status.c e651be6b30d397d86384c6867bc016e4913bcac7 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -208,7 +211,7 @@ F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 -F src/util.c aa0b1da8f71edff84b4b41dbe05fe6ac75d819c6 +F src/util.c 88b16cd614f42cbbe22e48633f220506e38fa654 F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de F src/vdbe.c 428411c6fbd49e9a4ce043dad87a0b079d403714 F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 @@ -790,7 +793,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 103321e37ae46eacfad4e127d13477ad5dd02bab -R becff0b48e882ac8f957bf23a46ac2b6 -U shaneh -Z 75f7bf2a2627891ab273971d988089a2 +P cae47c5b09cb122689bcb020a66ce14982cc4aa8 +R d7121689968b9a49bfb3b115f6caae1f +U drh +Z 756dc0e686614f50b3726f7d79fbf33e +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLgtvToxKgR168RlERAgD+AJ9pel9BuoeQ60Zg2RwC7UUcyLa15QCgjQyw +eVPi7VygVLOyvzAZ+LPjDAY= +=r/gG +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 459fd3c446..d862becaf1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cae47c5b09cb122689bcb020a66ce14982cc4aa8 \ No newline at end of file +a8076aede33c07e9a2aaa05be8a888f37b45e41c \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 422198bfa6..2d01ddbb58 100644 --- a/src/backup.c +++ b/src/backup.c @@ -98,10 +98,10 @@ static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){ }else{ pParse->db = pDb; if( sqlite3OpenTempDatabase(pParse) ){ - sqlite3ErrorClear(pParse); sqlite3Error(pErrorDb, pParse->rc, "%s", pParse->zErrMsg); rc = SQLITE_ERROR; } + sqlite3DbFree(pErrorDb, pParse->zErrMsg); sqlite3StackFree(pErrorDb, pParse); } if( rc ){ diff --git a/src/build.c b/src/build.c index 6f656d840b..9f32876d0b 100644 --- a/src/build.c +++ b/src/build.c @@ -1974,13 +1974,12 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ } assert( pParse->nErr==0 ); assert( pName->nSrc==1 ); + if( noErr ) db->suppressErr++; pTab = sqlite3LocateTable(pParse, isView, pName->a[0].zName, pName->a[0].zDatabase); + if( noErr ) db->suppressErr--; if( pTab==0 ){ - if( noErr ){ - sqlite3ErrorClear(pParse); - } goto exit_drop_table; } iDb = sqlite3SchemaToIndex(db, pTab->pSchema); diff --git a/src/printf.c b/src/printf.c index 2966946f95..081289417a 100644 --- a/src/printf.c +++ b/src/printf.c @@ -942,21 +942,21 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ /* ** Format and write a message to the log if logging is enabled. */ -void sqlite3_log(int iPriority, const char *zFormat, ...){ +void sqlite3_log(int iErrCode, const char *zFormat, ...){ void (*xLog)(void*, int, const char*); /* The global logger function */ void *pLogArg; /* First argument to the logger */ va_list ap; /* Vararg list */ char *zMsg; /* Complete log message */ xLog = sqlite3GlobalConfig.xLog; - if( xLog ){ + if( xLog && zFormat ){ va_start(ap, zFormat); sqlite3BeginBenignMalloc(); zMsg = sqlite3_vmprintf(zFormat, ap); sqlite3EndBenignMalloc(); va_end(ap); pLogArg = sqlite3GlobalConfig.pLogArg; - xLog(pLogArg, iPriority, zMsg ? zMsg : zFormat); + xLog(pLogArg, iErrCode, zMsg ? zMsg : zFormat); sqlite3_free(zMsg); } } diff --git a/src/resolve.c b/src/resolve.c index 3b48baa6f3..3a44aef623 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -664,6 +664,9 @@ static int resolveOrderByTermToExprList( int i; /* Loop counter */ ExprList *pEList; /* The columns of the result set */ NameContext nc; /* Name context for resolving pE */ + sqlite3 *db; /* Database connection */ + int rc; /* Return code from subprocedures */ + u8 savedSuppErr; /* Saved value of db->suppressErr */ assert( sqlite3ExprIsInteger(pE, &i)==0 ); pEList = pSelect->pEList; @@ -676,10 +679,12 @@ static int resolveOrderByTermToExprList( nc.pEList = pEList; nc.allowAgg = 1; nc.nErr = 0; - if( sqlite3ResolveExprNames(&nc, pE) ){ - sqlite3ErrorClear(pParse); - return 0; - } + db = pParse->db; + savedSuppErr = db->suppressErr; + db->suppressErr = 1; + rc = sqlite3ResolveExprNames(&nc, pE); + db->suppressErr = savedSuppErr; + if( rc ) return 0; /* Try to match the ORDER BY expression against an expression ** in the result set. Return an 1-based index of the matching diff --git a/src/sqlite.h.in b/src/sqlite.h.in index bd610834ef..1c0a5bf52b 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3657,7 +3657,7 @@ int sqlite3_collation_needed16( void(*)(void*,sqlite3*,int eTextRep,const void*) ); -#if SQLITE_HAS_CODEC +#if SQLITE_HAS_CODEC /* ** Specify the key for an encrypted database. This routine should be ** called right after sqlite3_open(). @@ -3687,19 +3687,19 @@ int sqlite3_rekey( ** Specify the activation key for a SEE database. Unless ** activated, none of the SEE routines will work. */ -void sqlite3_activate_see( - const char *zPassPhrase /* Activation phrase */ -); -#endif - -#ifdef SQLITE_ENABLE_CEROD +void sqlite3_activate_see( + const char *zPassPhrase /* Activation phrase */ +); +#endif + +#ifdef SQLITE_ENABLE_CEROD /* ** Specify the activation key for a CEROD database. Unless ** activated, none of the CEROD routines will work. */ -void sqlite3_activate_cerod( - const char *zPassPhrase /* Activation phrase */ -); +void sqlite3_activate_cerod( + const char *zPassPhrase /* Activation phrase */ +); #endif /* @@ -5675,7 +5675,7 @@ int sqlite3_strnicmp(const char *, const char *, int); ** nothing to prevent an application from calling sqlite3_log(), doing so ** is considered bad form. */ -void sqlite3_log(int iPriority, const char *zFormat, ...); +void sqlite3_log(int iErrCode, const char *zFormat, ...); /* ** Undo the hack that converts floating point types to integer for diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a576dd6823..4e79cea5fd 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -794,6 +794,7 @@ struct sqlite3 { u8 dfltLockMode; /* Default locking-mode for attached dbs */ u8 dfltJournalMode; /* Default journal mode for attached dbs */ signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ + u8 suppressErr; /* Do not issue error messages if true */ int nextPagesize; /* Pagesize after VACUUM if >0 */ int nTable; /* Number of tables in the database */ CollSeq *pDfltColl; /* The default collating sequence (BINARY) */ @@ -2554,7 +2555,6 @@ char *sqlite3MAppendf(sqlite3*,char*,const char*,...); #endif void sqlite3SetString(char **, sqlite3*, const char*, ...); void sqlite3ErrorMsg(Parse*, const char*, ...); -void sqlite3ErrorClear(Parse*); int sqlite3Dequote(char*); int sqlite3KeywordCode(const unsigned char*, int); int sqlite3RunParser(Parse*, const char*, char **); diff --git a/src/util.c b/src/util.c index f5c996425c..7bf2df8d93 100644 --- a/src/util.c +++ b/src/util.c @@ -123,6 +123,7 @@ void sqlite3Error(sqlite3 *db, int err_code, const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); + sqlite3_log(err_code, z); sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC); }else{ sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC); @@ -148,23 +149,21 @@ void sqlite3Error(sqlite3 *db, int err_code, const char *zFormat, ...){ ** (sqlite3_step() etc.). */ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ + char *zMsg; va_list ap; sqlite3 *db = pParse->db; - pParse->nErr++; - sqlite3DbFree(db, pParse->zErrMsg); va_start(ap, zFormat); - pParse->zErrMsg = sqlite3VMPrintf(db, zFormat, ap); + zMsg = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); - pParse->rc = SQLITE_ERROR; -} - -/* -** Clear the error message in pParse, if any -*/ -void sqlite3ErrorClear(Parse *pParse){ - sqlite3DbFree(pParse->db, pParse->zErrMsg); - pParse->zErrMsg = 0; - pParse->nErr = 0; + if( db->suppressErr ){ + sqlite3DbFree(db, zMsg); + }else{ + pParse->nErr++; + sqlite3DbFree(db, pParse->zErrMsg); + pParse->zErrMsg = zMsg; + pParse->rc = SQLITE_ERROR; + sqlite3_log(SQLITE_ERROR, pParse->zErrMsg); + } } /* From 4ec84f35e2bde4d94ac4c6ab0808025085005c1b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 22 Feb 2010 23:17:42 +0000 Subject: [PATCH 16/50] Fix an assertion-fault/segfault problem that comes up when trying to VACUUM an auto-vacuumed database with a large schema. Ticket [da1151f97df244]. FossilOrigin-Name: 86d50ce57feb78440956192e37a03686ffa1e196 --- manifest | 19 +++++++------- manifest.uuid | 2 +- src/pager.c | 2 +- test/vacuum4.test | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 test/vacuum4.test diff --git a/manifest b/manifest index 079aeed488..3c9769f42d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Merge\sin\sthe\smassive\sclean-up\sand\sANSI-fication\sof\sLemon\scarried\sout\nby\sRyan\sGordon.\s\sThere\sare\sno\sfunctional\schanges\sto\sSQLite\sitself\s-\sLemon\nstill\sgenerates\sexactly\sthe\ssame\sparsing\sautomaton\sfrom\sexactly\sthe\ssame\ngrammar. -D 2010-02-22T19:37:44 +C Fix\san\sassertion-fault/segfault\sproblem\sthat\scomes\sup\swhen\strying\sto\nVACUUM\san\sauto-vacuumed\sdatabase\swith\sa\slarge\sschema.\s\nTicket\s[da1151f97df244]. +D 2010-02-22T23:17:42 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -154,7 +154,7 @@ F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30 F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f F src/os_unix.c 0af0a55e2dd55bc4f4c3ccf04cc8f1f4a2e2e65f F src/os_win.c 5ffab20249a61e0625f869efe157fa009747039b -F src/pager.c 5dee83c3cf4e94b72fcd81dca67abd7617227217 +F src/pager.c d0e53cd301c82d3b67ee69c7b900b56e5b17070d F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54 F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e @@ -730,6 +730,7 @@ F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 68e39b2228b4b772166debef4a82accf6ddd32f3 F test/vacuum2.test ec57f21d394b7b72249b11f8e4b5d487bab56539 F test/vacuum3.test f39ad1428347c5808cd2da7578c470f186a4d0ce +F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test e265401afefa994cdf2fe4b6f286b1e87c2f9b9d F test/view.test 45f518205ecdb6dd23a86dd4a99bb4ae945e625d @@ -793,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a8076aede33c07e9a2aaa05be8a888f37b45e41c 721f33e7221c5fc907e9e293ac3242843f4fcfb7 -R 450fcba6aea5b20aec6d511bce230dbe +P 1e8b842039cc06b57a321226633c55b94eb8dcd7 +R 06756ad8541fef8ef0cebc9ff5692f8d U drh -Z f72661ff70306bbed226b0e608b0a014 +Z b557d7fb4d0e234f9fa6b902c44ce00a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLgt0LoxKgR168RlERAoxeAJ9pMwbfj9A/W4G3C1CtQ290wQ3EXwCcCH1G -03zT6XIKKGdbivHexIMUwAE= -=j4CO +iD8DBQFLgxCZoxKgR168RlERAnKMAJ4sis2aZYWJRDTipYeWbj/CPDSbGwCdFGgm +Uu4h1w5TiR0CYCeH1mIeplU= +=d4Ru -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index d759e97241..8713b33e94 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e8b842039cc06b57a321226633c55b94eb8dcd7 \ No newline at end of file +86d50ce57feb78440956192e37a03686ffa1e196 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 83f02940ac..b5c7fe4945 100644 --- a/src/pager.c +++ b/src/pager.c @@ -3840,7 +3840,7 @@ int sqlite3PagerAcquire( goto pager_acquire_err; } - if( MEMDB || nMax<(int)pgno || noContent ){ + if( MEMDB || nMax<(int)pgno || noContent || !isOpen(pPager->fd) ){ if( pgno>pPager->mxPgno ){ rc = SQLITE_FULL; goto pager_acquire_err; diff --git a/test/vacuum4.test b/test/vacuum4.test new file mode 100644 index 0000000000..326d037276 --- /dev/null +++ b/test/vacuum4.test @@ -0,0 +1,67 @@ +# 2010 February 21 +# +# 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 a test of ticket [da1151f97df244a1]: An +# assertion fault while VACUUMing an auto_vacuumed database with +# large schema. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# If the VACUUM statement is disabled in the current build, skip all +# the tests in this file. +# +ifcapable !vacuum { + finish_test + return +} + +do_test vacuum4-1.1 { + db eval { + PRAGMA auto_vacuum=FULL; + CREATE TABLE t1( + c000, c001, c002, c003, c004, c005, c006, c007, c008, c009, + c010, c011, c012, c013, c014, c015, c016, c017, c018, c019, + c020, c021, c022, c023, c024, c025, c026, c027, c028, c029, + c030, c031, c032, c033, c034, c035, c036, c037, c038, c039, + c040, c041, c042, c043, c044, c045, c046, c047, c048, c049, + c050, c051, c052, c053, c054, c055, c056, c057, c058, c059, + c060, c061, c062, c063, c064, c065, c066, c067, c068, c069, + c070, c071, c072, c073, c074, c075, c076, c077, c078, c079, + c080, c081, c082, c083, c084, c085, c086, c087, c088, c089, + c090, c091, c092, c093, c094, c095, c096, c097, c098, c099, + c100, c101, c102, c103, c104, c105, c106, c107, c108, c109, + c110, c111, c112, c113, c114, c115, c116, c117, c118, c119, + c120, c121, c122, c123, c124, c125, c126, c127, c128, c129, + c130, c131, c132, c133, c134, c135, c136, c137, c138, c139, + c140, c141, c142, c143, c144, c145, c146, c147, c148, c149 + ); + CREATE TABLE t2( + c000, c001, c002, c003, c004, c005, c006, c007, c008, c009, + c010, c011, c012, c013, c014, c015, c016, c017, c018, c019, + c020, c021, c022, c023, c024, c025, c026, c027, c028, c029, + c030, c031, c032, c033, c034, c035, c036, c037, c038, c039, + c040, c041, c042, c043, c044, c045, c046, c047, c048, c049, + c050, c051, c052, c053, c054, c055, c056, c057, c058, c059, + c060, c061, c062, c063, c064, c065, c066, c067, c068, c069, + c070, c071, c072, c073, c074, c075, c076, c077, c078, c079, + c080, c081, c082, c083, c084, c085, c086, c087, c088, c089, + c090, c091, c092, c093, c094, c095, c096, c097, c098, c099, + c100, c101, c102, c103, c104, c105, c106, c107, c108, c109, + c110, c111, c112, c113, c114, c115, c116, c117, c118, c119, + c120, c121, c122, c123, c124, c125, c126, c127, c128, c129, + c130, c131, c132, c133, c134, c135, c136, c137, c138, c139, + c140, c141, c142, c143, c144, c145, c146, c147, c148, c149 + ); + VACUUM; + } +} {} From 5bd1d051e870d6087f27db3da852d69b7c7a1049 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Feb 2010 01:01:58 +0000 Subject: [PATCH 17/50] Remove the ".genfkey" command from the shell. We've had foreign-key support in the core since 3.6.19. Anyone who still needs the simulated foreign-key triggers can always generate them with an older version of the shell. FossilOrigin-Name: c4401fc93b66c5339422d7e765a4a32b1ef96bdb --- manifest | 18 +- manifest.uuid | 2 +- src/shell.c | 937 -------------------------------------------------- 3 files changed, 10 insertions(+), 947 deletions(-) diff --git a/manifest b/manifest index 3c9769f42d..a06283e83c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\san\sassertion-fault/segfault\sproblem\sthat\scomes\sup\swhen\strying\sto\nVACUUM\san\sauto-vacuumed\sdatabase\swith\sa\slarge\sschema.\s\nTicket\s[da1151f97df244]. -D 2010-02-22T23:17:42 +C Remove\sthe\s".genfkey"\scommand\sfrom\sthe\sshell.\s\sWe've\shad\sforeign-key\ssupport\nin\sthe\score\ssince\s3.6.19.\s\sAnyone\swho\sstill\sneeds\sthe\ssimulated\sforeign-key\ntriggers\scan\salways\sgenerate\sthem\swith\san\solder\sversion\sof\sthe\sshell. +D 2010-02-23T01:01:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -167,7 +167,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 -F src/shell.c 56521a172567f5f9f59f528599bf63380e150ac4 +F src/shell.c 285a9a83bebd12265841cea7e84f4b6088fe676e F src/sqlite.h.in 16f33c1ceb971bfa7a04a73039947630f445146e F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h d5fe1c8335b5bf376639837fa42124327cdb6767 @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1e8b842039cc06b57a321226633c55b94eb8dcd7 -R 06756ad8541fef8ef0cebc9ff5692f8d +P 86d50ce57feb78440956192e37a03686ffa1e196 +R d7e4885c2790f006c9fb03f523fb52e7 U drh -Z b557d7fb4d0e234f9fa6b902c44ce00a +Z ce6478007e315584d717adb0d5a3c11c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLgxCZoxKgR168RlERAnKMAJ4sis2aZYWJRDTipYeWbj/CPDSbGwCdFGgm -Uu4h1w5TiR0CYCeH1mIeplU= -=d4Ru +iD8DBQFLgykLoxKgR168RlERAtBUAJ0WyBEJgyN2CRLORdcgGbStXZq3KQCdEb8r +rzZD4GEkFRgOhQAEyCwafJo= +=dDQ/ -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 8713b33e94..dda01bb480 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86d50ce57feb78440956192e37a03686ffa1e196 \ No newline at end of file +c4401fc93b66c5339422d7e765a4a32b1ef96bdb \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 5f912f4306..fdf6db7171 100644 --- a/src/shell.c +++ b/src/shell.c @@ -195,868 +195,6 @@ static void endTimer(void){ */ #define UNUSED_PARAMETER(x) (void)(x) - -/************************************************************************** -*************************************************************************** -** Begin genfkey logic. -*/ -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined SQLITE_OMIT_SUBQUERY - -#define GENFKEY_ERROR 1 -#define GENFKEY_DROPTRIGGER 2 -#define GENFKEY_CREATETRIGGER 3 -static int genfkey_create_triggers(sqlite3 *, const char *, void *, - int (*)(void *, int, const char *) -); - -struct GenfkeyCb { - void *pCtx; - int eType; - int (*xData)(void *, int, const char *); -}; -typedef struct GenfkeyCb GenfkeyCb; - -/* The code in this file defines a sqlite3 virtual-table module that -** provides a read-only view of the current database schema. There is one -** row in the schema table for each column in the database schema. -*/ -#define SCHEMA \ -"CREATE TABLE x(" \ - "database," /* Name of database (i.e. main, temp etc.) */ \ - "tablename," /* Name of table */ \ - "cid," /* Column number (from left-to-right, 0 upward) */ \ - "name," /* Column name */ \ - "type," /* Specified type (i.e. VARCHAR(32)) */ \ - "not_null," /* Boolean. True if NOT NULL was specified */ \ - "dflt_value," /* Default value for this column */ \ - "pk" /* True if this column is part of the primary key */ \ -")" - -#define SCHEMA2 \ -"CREATE TABLE x(" \ - "database," /* Name of database (i.e. main, temp etc.) */ \ - "from_tbl," /* Name of table */ \ - "fkid," \ - "seq," \ - "to_tbl," \ - "from_col," \ - "to_col," \ - "on_update," \ - "on_delete," \ - "match" \ -")" - -#define SCHEMA3 \ -"CREATE TABLE x(" \ - "database," /* Name of database (i.e. main, temp etc.) */ \ - "tablename," /* Name of table */ \ - "seq," \ - "name," \ - "isunique" \ -")" - -#define SCHEMA4 \ -"CREATE TABLE x(" \ - "database," /* Name of database (i.e. main, temp etc.) */ \ - "indexname," /* Name of table */ \ - "seqno," \ - "cid," \ - "name" \ -")" - -#define SCHEMA5 \ -"CREATE TABLE x(" \ - "database," /* Name of database (i.e. main, temp etc.) */ \ - "triggername," /* Name of trigger */ \ - "dummy" /* Unused */ \ -")" - -typedef struct SchemaTable SchemaTable; -static struct SchemaTable { - const char *zName; - const char *zObject; - const char *zPragma; - const char *zSchema; -} aSchemaTable[] = { - { "table_info", "table", "PRAGMA %Q.table_info(%Q)", SCHEMA }, - { "foreign_key_list", "table", "PRAGMA %Q.foreign_key_list(%Q)", SCHEMA2 }, - { "index_list", "table", "PRAGMA %Q.index_list(%Q)", SCHEMA3 }, - { "index_info", "index", "PRAGMA %Q.index_info(%Q)", SCHEMA4 }, - { "trigger_list", "trigger", "SELECT 1", SCHEMA5 }, - { 0, 0, 0, 0 } -}; - -typedef struct schema_vtab schema_vtab; -typedef struct schema_cursor schema_cursor; - -/* A schema table object */ -struct schema_vtab { - sqlite3_vtab base; - sqlite3 *db; - SchemaTable *pType; -}; - -/* A schema table cursor object */ -struct schema_cursor { - sqlite3_vtab_cursor base; - sqlite3_stmt *pDbList; - sqlite3_stmt *pTableList; - sqlite3_stmt *pColumnList; - int rowid; -}; - -/* -** Table destructor for the schema module. -*/ -static int schemaDestroy(sqlite3_vtab *pVtab){ - sqlite3_free(pVtab); - return 0; -} - -/* -** Table constructor for the schema module. -*/ -static int schemaCreate( - sqlite3 *db, - void *pAux, - int argc, const char *const*argv, - sqlite3_vtab **ppVtab, - char **pzErr -){ - int rc = SQLITE_NOMEM; - schema_vtab *pVtab; - SchemaTable *pType = &aSchemaTable[0]; - - UNUSED_PARAMETER(pzErr); - if( argc>3 ){ - int i; - pType = 0; - for(i=0; aSchemaTable[i].zName; i++){ - if( 0==strcmp(argv[3], aSchemaTable[i].zName) ){ - pType = &aSchemaTable[i]; - } - } - if( !pType ){ - return SQLITE_ERROR; - } - } - - pVtab = sqlite3_malloc(sizeof(schema_vtab)); - if( pVtab ){ - memset(pVtab, 0, sizeof(schema_vtab)); - pVtab->db = (sqlite3 *)pAux; - pVtab->pType = pType; - rc = sqlite3_declare_vtab(db, pType->zSchema); - } - *ppVtab = (sqlite3_vtab *)pVtab; - return rc; -} - -/* -** Open a new cursor on the schema table. -*/ -static int schemaOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ - int rc = SQLITE_NOMEM; - schema_cursor *pCur; - UNUSED_PARAMETER(pVTab); - pCur = sqlite3_malloc(sizeof(schema_cursor)); - if( pCur ){ - memset(pCur, 0, sizeof(schema_cursor)); - *ppCursor = (sqlite3_vtab_cursor *)pCur; - rc = SQLITE_OK; - } - return rc; -} - -/* -** Close a schema table cursor. -*/ -static int schemaClose(sqlite3_vtab_cursor *cur){ - schema_cursor *pCur = (schema_cursor *)cur; - sqlite3_finalize(pCur->pDbList); - sqlite3_finalize(pCur->pTableList); - sqlite3_finalize(pCur->pColumnList); - sqlite3_free(pCur); - return SQLITE_OK; -} - -static void columnToResult(sqlite3_context *ctx, sqlite3_stmt *pStmt, int iCol){ - switch( sqlite3_column_type(pStmt, iCol) ){ - case SQLITE_NULL: - sqlite3_result_null(ctx); - break; - case SQLITE_INTEGER: - sqlite3_result_int64(ctx, sqlite3_column_int64(pStmt, iCol)); - break; - case SQLITE_FLOAT: - sqlite3_result_double(ctx, sqlite3_column_double(pStmt, iCol)); - break; - case SQLITE_TEXT: { - const char *z = (const char *)sqlite3_column_text(pStmt, iCol); - sqlite3_result_text(ctx, z, -1, SQLITE_TRANSIENT); - break; - } - } -} - -/* -** Retrieve a column of data. -*/ -static int schemaColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ - schema_cursor *pCur = (schema_cursor *)cur; - switch( i ){ - case 0: - columnToResult(ctx, pCur->pDbList, 1); - break; - case 1: - columnToResult(ctx, pCur->pTableList, 0); - break; - default: - columnToResult(ctx, pCur->pColumnList, i-2); - break; - } - return SQLITE_OK; -} - -/* -** Retrieve the current rowid. -*/ -static int schemaRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ - schema_cursor *pCur = (schema_cursor *)cur; - *pRowid = pCur->rowid; - return SQLITE_OK; -} - -static int finalize(sqlite3_stmt **ppStmt){ - int rc = sqlite3_finalize(*ppStmt); - *ppStmt = 0; - return rc; -} - -static int schemaEof(sqlite3_vtab_cursor *cur){ - schema_cursor *pCur = (schema_cursor *)cur; - return (pCur->pDbList ? 0 : 1); -} - -/* -** Advance the cursor to the next row. -*/ -static int schemaNext(sqlite3_vtab_cursor *cur){ - int rc = SQLITE_OK; - schema_cursor *pCur = (schema_cursor *)cur; - schema_vtab *pVtab = (schema_vtab *)(cur->pVtab); - char *zSql = 0; - - while( !pCur->pColumnList || SQLITE_ROW!=sqlite3_step(pCur->pColumnList) ){ - if( SQLITE_OK!=(rc = finalize(&pCur->pColumnList)) ) goto next_exit; - - while( !pCur->pTableList || SQLITE_ROW!=sqlite3_step(pCur->pTableList) ){ - if( SQLITE_OK!=(rc = finalize(&pCur->pTableList)) ) goto next_exit; - - assert(pCur->pDbList); - while( SQLITE_ROW!=sqlite3_step(pCur->pDbList) ){ - rc = finalize(&pCur->pDbList); - goto next_exit; - } - - /* Set zSql to the SQL to pull the list of tables from the - ** sqlite_master (or sqlite_temp_master) table of the database - ** identfied by the row pointed to by the SQL statement pCur->pDbList - ** (iterating through a "PRAGMA database_list;" statement). - */ - if( sqlite3_column_int(pCur->pDbList, 0)==1 ){ - zSql = sqlite3_mprintf( - "SELECT name FROM sqlite_temp_master WHERE type=%Q", - pVtab->pType->zObject - ); - }else{ - sqlite3_stmt *pDbList = pCur->pDbList; - zSql = sqlite3_mprintf( - "SELECT name FROM %Q.sqlite_master WHERE type=%Q", - sqlite3_column_text(pDbList, 1), pVtab->pType->zObject - ); - } - if( !zSql ){ - rc = SQLITE_NOMEM; - goto next_exit; - } - - rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pTableList, 0); - sqlite3_free(zSql); - if( rc!=SQLITE_OK ) goto next_exit; - } - - /* Set zSql to the SQL to the table_info pragma for the table currently - ** identified by the rows pointed to by statements pCur->pDbList and - ** pCur->pTableList. - */ - zSql = sqlite3_mprintf(pVtab->pType->zPragma, - sqlite3_column_text(pCur->pDbList, 1), - sqlite3_column_text(pCur->pTableList, 0) - ); - - if( !zSql ){ - rc = SQLITE_NOMEM; - goto next_exit; - } - rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pColumnList, 0); - sqlite3_free(zSql); - if( rc!=SQLITE_OK ) goto next_exit; - } - pCur->rowid++; - -next_exit: - /* TODO: Handle rc */ - return rc; -} - -/* -** Reset a schema table cursor. -*/ -static int schemaFilter( - sqlite3_vtab_cursor *pVtabCursor, - int idxNum, const char *idxStr, - int argc, sqlite3_value **argv -){ - int rc; - schema_vtab *pVtab = (schema_vtab *)(pVtabCursor->pVtab); - schema_cursor *pCur = (schema_cursor *)pVtabCursor; - UNUSED_PARAMETER(idxNum); - UNUSED_PARAMETER(idxStr); - UNUSED_PARAMETER(argc); - UNUSED_PARAMETER(argv); - pCur->rowid = 0; - finalize(&pCur->pTableList); - finalize(&pCur->pColumnList); - finalize(&pCur->pDbList); - rc = sqlite3_prepare(pVtab->db,"SELECT 0, 'main'", -1, &pCur->pDbList, 0); - return (rc==SQLITE_OK ? schemaNext(pVtabCursor) : rc); -} - -/* -** Analyse the WHERE condition. -*/ -static int schemaBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ - UNUSED_PARAMETER(tab); - UNUSED_PARAMETER(pIdxInfo); - return SQLITE_OK; -} - -/* -** A virtual table module that merely echos method calls into TCL -** variables. -*/ -static sqlite3_module schemaModule = { - 0, /* iVersion */ - schemaCreate, - schemaCreate, - schemaBestIndex, - schemaDestroy, - schemaDestroy, - schemaOpen, /* xOpen - open a cursor */ - schemaClose, /* xClose - close a cursor */ - schemaFilter, /* xFilter - configure scan constraints */ - schemaNext, /* xNext - advance a cursor */ - schemaEof, /* xEof */ - schemaColumn, /* xColumn - read data */ - schemaRowid, /* xRowid - read data */ - 0, /* xUpdate */ - 0, /* xBegin */ - 0, /* xSync */ - 0, /* xCommit */ - 0, /* xRollback */ - 0, /* xFindMethod */ - 0, /* xRename */ -}; - -/* -** Extension load function. -*/ -static int installSchemaModule(sqlite3 *db, sqlite3 *sdb){ - sqlite3_create_module(db, "schema", &schemaModule, (void *)sdb); - return 0; -} - -/* -** sj(zValue, zJoin) -** -** The following block contains the implementation of an aggregate -** function that returns a string. Each time the function is stepped, -** it appends data to an internal buffer. When the aggregate is finalized, -** the contents of the buffer are returned. -** -** The first time the aggregate is stepped the buffer is set to a copy -** of the first argument. The second time and subsequent times it is -** stepped a copy of the second argument is appended to the buffer, then -** a copy of the first. -** -** Example: -** -** INSERT INTO t1(a) VALUES('1'); -** INSERT INTO t1(a) VALUES('2'); -** INSERT INTO t1(a) VALUES('3'); -** SELECT sj(a, ', ') FROM t1; -** -** => "1, 2, 3" -** -*/ -struct StrBuffer { - char *zBuf; -}; -typedef struct StrBuffer StrBuffer; -static void joinFinalize(sqlite3_context *context){ - StrBuffer *p; - p = (StrBuffer *)sqlite3_aggregate_context(context, sizeof(StrBuffer)); - sqlite3_result_text(context, p->zBuf, -1, SQLITE_TRANSIENT); - sqlite3_free(p->zBuf); -} -static void joinStep( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - StrBuffer *p; - UNUSED_PARAMETER(argc); - p = (StrBuffer *)sqlite3_aggregate_context(context, sizeof(StrBuffer)); - if( p->zBuf==0 ){ - p->zBuf = sqlite3_mprintf("%s", sqlite3_value_text(argv[0])); - }else{ - char *zTmp = p->zBuf; - p->zBuf = sqlite3_mprintf("%s%s%s", - zTmp, sqlite3_value_text(argv[1]), sqlite3_value_text(argv[0]) - ); - sqlite3_free(zTmp); - } -} - -/* -** dq(zString) -** -** This scalar function accepts a single argument and interprets it as -** a text value. The return value is the argument enclosed in double -** quotes. If any double quote characters are present in the argument, -** these are escaped. -** -** dq('the raven "Nevermore."') == '"the raven ""Nevermore."""' -*/ -static void doublequote( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - int ii; - char *zOut; - char *zCsr; - const char *zIn = (const char *)sqlite3_value_text(argv[0]); - int nIn = sqlite3_value_bytes(argv[0]); - - UNUSED_PARAMETER(argc); - zOut = sqlite3_malloc(nIn*2+3); - zCsr = zOut; - *zCsr++ = '"'; - for(ii=0; iinMalloc ){ - char *zNew; - nMalloc = 16 + (nOut+nCopy)*2; - zNew = (char*)sqlite3_realloc(zOut, nMalloc); - if( zNew==0 ){ - sqlite3_result_error_nomem(context); - return; - }else{ - zOut = zNew; - } - } - assert( nMalloc>=(nOut+nCopy) ); - memcpy(&zOut[nOut], zCopy, nCopy); - i += nReplace; - nOut += nCopy; - } - - sqlite3_result_text(context, zOut, nOut, SQLITE_TRANSIENT); - sqlite3_free(zOut); -} - -/* -** A callback for sqlite3_exec() invokes the callback specified by the -** GenfkeyCb structure pointed to by the void* passed as the first argument. -*/ -static int invokeCallback(void *p, int nArg, char **azArg, char **azCol){ - GenfkeyCb *pCb = (GenfkeyCb *)p; - UNUSED_PARAMETER(nArg); - UNUSED_PARAMETER(azCol); - return pCb->xData(pCb->pCtx, pCb->eType, azArg[0]); -} - -static int detectSchemaProblem( - sqlite3 *db, /* Database connection */ - const char *zMessage, /* English language error message */ - const char *zSql, /* SQL statement to run */ - GenfkeyCb *pCb -){ - sqlite3_stmt *pStmt; - int rc; - rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); - if( rc!=SQLITE_OK ){ - return rc; - } - while( SQLITE_ROW==sqlite3_step(pStmt) ){ - char *zDel; - int iFk = sqlite3_column_int(pStmt, 0); - const char *zTab = (const char *)sqlite3_column_text(pStmt, 1); - zDel = sqlite3_mprintf("Error in table %s: %s", zTab, zMessage); - rc = pCb->xData(pCb->pCtx, pCb->eType, zDel); - sqlite3_free(zDel); - if( rc!=SQLITE_OK ) return rc; - zDel = sqlite3_mprintf( - "DELETE FROM temp.fkey WHERE from_tbl = %Q AND fkid = %d" - , zTab, iFk - ); - sqlite3_exec(db, zDel, 0, 0, 0); - sqlite3_free(zDel); - } - sqlite3_finalize(pStmt); - return SQLITE_OK; -} - -/* -** Create and populate temporary table "fkey". -*/ -static int populateTempTable(sqlite3 *db, GenfkeyCb *pCallback){ - int rc; - - rc = sqlite3_exec(db, - "CREATE VIRTUAL TABLE temp.v_fkey USING schema(foreign_key_list);" - "CREATE VIRTUAL TABLE temp.v_col USING schema(table_info);" - "CREATE VIRTUAL TABLE temp.v_idxlist USING schema(index_list);" - "CREATE VIRTUAL TABLE temp.v_idxinfo USING schema(index_info);" - "CREATE VIRTUAL TABLE temp.v_triggers USING schema(trigger_list);" - "CREATE TABLE temp.fkey AS " - "SELECT from_tbl, to_tbl, fkid, from_col, to_col, on_update, on_delete " - "FROM temp.v_fkey WHERE database = 'main';" - , 0, 0, 0 - ); - if( rc!=SQLITE_OK ) return rc; - - rc = detectSchemaProblem(db, "foreign key columns do not exist", - "SELECT fkid, from_tbl " - "FROM temp.fkey " - "WHERE to_col IS NOT NULL AND NOT EXISTS (SELECT 1 " - "FROM temp.v_col WHERE tablename=to_tbl AND name==to_col" - ")", pCallback - ); - if( rc!=SQLITE_OK ) return rc; - - /* At this point the temp.fkey table is mostly populated. If any foreign - ** keys were specified so that they implicitly refer to they primary - ** key of the parent table, the "to_col" values of the temp.fkey rows - ** are still set to NULL. - ** - ** This is easily fixed for single column primary keys, but not for - ** composites. With a composite primary key, there is no way to reliably - ** query sqlite for the order in which the columns that make up the - ** composite key were declared i.e. there is no way to tell if the - ** schema actually contains "PRIMARY KEY(a, b)" or "PRIMARY KEY(b, a)". - ** Therefore, this case is not handled. The following function call - ** detects instances of this case. - */ - rc = detectSchemaProblem(db, "implicit mapping to composite primary key", - "SELECT fkid, from_tbl " - "FROM temp.fkey " - "WHERE to_col IS NULL " - "GROUP BY fkid, from_tbl HAVING count(*) > 1", pCallback - ); - if( rc!=SQLITE_OK ) return rc; - - /* Detect attempts to implicitly map to the primary key of a table - ** that has no primary key column. - */ - rc = detectSchemaProblem(db, "implicit mapping to non-existant primary key", - "SELECT fkid, from_tbl " - "FROM temp.fkey " - "WHERE to_col IS NULL AND NOT EXISTS " - "(SELECT 1 FROM temp.v_col WHERE pk AND tablename = temp.fkey.to_tbl)" - , pCallback - ); - if( rc!=SQLITE_OK ) return rc; - - /* Fix all the implicit primary key mappings in the temp.fkey table. */ - rc = sqlite3_exec(db, - "UPDATE temp.fkey SET to_col = " - "(SELECT name FROM temp.v_col WHERE pk AND tablename=temp.fkey.to_tbl)" - " WHERE to_col IS NULL;" - , 0, 0, 0 - ); - if( rc!=SQLITE_OK ) return rc; - - /* Now check that all all parent keys are either primary keys or - ** subject to a unique constraint. - */ - rc = sqlite3_exec(db, - "CREATE TABLE temp.idx2 AS SELECT " - "il.tablename AS tablename," - "ii.indexname AS indexname," - "ii.name AS col " - "FROM temp.v_idxlist AS il, temp.v_idxinfo AS ii " - "WHERE il.isunique AND il.database='main' AND ii.indexname = il.name;" - "INSERT INTO temp.idx2 " - "SELECT tablename, 'pk', name FROM temp.v_col WHERE pk;" - - "CREATE TABLE temp.idx AS SELECT " - "tablename, indexname, sj(dq(col),',') AS cols " - "FROM (SELECT * FROM temp.idx2 ORDER BY col) " - "GROUP BY tablename, indexname;" - - "CREATE TABLE temp.fkey2 AS SELECT " - "fkid, from_tbl, to_tbl, sj(dq(to_col),',') AS cols " - "FROM (SELECT * FROM temp.fkey ORDER BY to_col) " - "GROUP BY fkid, from_tbl;" - - "CREATE TABLE temp.triggers AS SELECT " - "triggername FROM temp.v_triggers WHERE database='main' AND " - "triggername LIKE 'genfkey%';" - , 0, 0, 0 - ); - if( rc!=SQLITE_OK ) return rc; - rc = detectSchemaProblem(db, "foreign key is not unique", - "SELECT fkid, from_tbl " - "FROM temp.fkey2 " - "WHERE NOT EXISTS (SELECT 1 " - "FROM temp.idx WHERE tablename=to_tbl AND fkey2.cols==idx.cols" - ")", pCallback - ); - if( rc!=SQLITE_OK ) return rc; - - return rc; -} - -#define GENFKEY_ERROR 1 -#define GENFKEY_DROPTRIGGER 2 -#define GENFKEY_CREATETRIGGER 3 -static int genfkey_create_triggers( - sqlite3 *sdb, /* Connection to read schema from */ - const char *zDb, /* Name of db to read ("main", "temp") */ - void *pCtx, /* Context pointer to pass to xData */ - int (*xData)(void *, int, const char *) -){ - const char *zSql = - "SELECT multireplace('" - - "-- Triggers for foreign key mapping:\n" - "--\n" - "-- /from_readable/ REFERENCES /to_readable/\n" - "-- on delete /on_delete/\n" - "-- on update /on_update/\n" - "--\n" - - /* The "BEFORE INSERT ON " trigger. This trigger's job is to - ** throw an exception if the user tries to insert a row into the - ** referencing table for which there is no corresponding row in - ** the referenced table. - */ - "CREATE TRIGGER /name/_insert_referencing BEFORE INSERT ON /tbl/ WHEN \n" - " /key_notnull/ AND NOT EXISTS (SELECT 1 FROM /ref/ WHERE /cond1/)\n" - "BEGIN\n" - " SELECT RAISE(ABORT, ''constraint failed'');\n" - "END;\n" - - /* The "BEFORE UPDATE ON " trigger. This trigger's job - ** is to throw an exception if the user tries to update a row in the - ** referencing table causing it to correspond to no row in the - ** referenced table. - */ - "CREATE TRIGGER /name/_update_referencing BEFORE\n" - " UPDATE OF /rkey_list/ ON /tbl/ WHEN \n" - " /key_notnull/ AND \n" - " NOT EXISTS (SELECT 1 FROM /ref/ WHERE /cond1/)\n" - "BEGIN\n" - " SELECT RAISE(ABORT, ''constraint failed'');\n" - "END;\n" - - - /* The "BEFORE DELETE ON " trigger. This trigger's job - ** is to detect when a row is deleted from the referenced table to - ** which rows in the referencing table correspond. The action taken - ** depends on the value of the 'ON DELETE' clause. - */ - "CREATE TRIGGER /name/_delete_referenced BEFORE DELETE ON /ref/ WHEN\n" - " EXISTS (SELECT 1 FROM /tbl/ WHERE /cond2/)\n" - "BEGIN\n" - " /delete_action/\n" - "END;\n" - - /* The "AFTER UPDATE ON " trigger. This trigger's job - ** is to detect when the key columns of a row in the referenced table - ** to which one or more rows in the referencing table correspond are - ** updated. The action taken depends on the value of the 'ON UPDATE' - ** clause. - */ - "CREATE TRIGGER /name/_update_referenced AFTER\n" - " UPDATE OF /fkey_list/ ON /ref/ WHEN \n" - " EXISTS (SELECT 1 FROM /tbl/ WHERE /cond2/)\n" - "BEGIN\n" - " /update_action/\n" - "END;\n" - "'" - - /* These are used in the SQL comment written above each set of triggers */ - ", '/from_readable/', from_tbl || '(' || sj(from_col, ', ') || ')'" - ", '/to_readable/', to_tbl || '(' || sj(to_col, ', ') || ')'" - ", '/on_delete/', on_delete" - ", '/on_update/', on_update" - - ", '/name/', 'genfkey' || min(rowid)" - ", '/tbl/', dq(from_tbl)" - ", '/ref/', dq(to_tbl)" - ", '/key_notnull/', sj('new.' || dq(from_col) || ' IS NOT NULL', ' AND ')" - - ", '/fkey_list/', sj(dq(to_col), ', ')" - ", '/rkey_list/', sj(dq(from_col), ', ')" - - ", '/cond1/', sj(multireplace('new./from/ == /to/'" - ", '/from/', dq(from_col)" - ", '/to/', dq(to_col)" - "), ' AND ')" - ", '/cond2/', sj(multireplace('old./to/ == /from/'" - ", '/from/', dq(from_col)" - ", '/to/', dq(to_col)" - "), ' AND ')" - - ", '/update_action/', CASE on_update " - "WHEN 'SET NULL' THEN " - "multireplace('UPDATE /tbl/ SET /setlist/ WHERE /where/;' " - ", '/setlist/', sj(dq(from_col)||' = NULL',', ')" - ", '/tbl/', dq(from_tbl)" - ", '/where/', sj(dq(from_col)||' = old.'||dq(to_col),' AND ')" - ")" - "WHEN 'CASCADE' THEN " - "multireplace('UPDATE /tbl/ SET /setlist/ WHERE /where/;' " - ", '/setlist/', sj(dq(from_col)||' = new.'||dq(to_col),', ')" - ", '/tbl/', dq(from_tbl)" - ", '/where/', sj(dq(from_col)||' = old.'||dq(to_col),' AND ')" - ")" - "ELSE " - " 'SELECT RAISE(ABORT, ''constraint failed'');'" - "END " - - ", '/delete_action/', CASE on_delete " - "WHEN 'SET NULL' THEN " - "multireplace('UPDATE /tbl/ SET /setlist/ WHERE /where/;' " - ", '/setlist/', sj(dq(from_col)||' = NULL',', ')" - ", '/tbl/', dq(from_tbl)" - ", '/where/', sj(dq(from_col)||' = old.'||dq(to_col),' AND ')" - ")" - "WHEN 'CASCADE' THEN " - "multireplace('DELETE FROM /tbl/ WHERE /where/;' " - ", '/tbl/', dq(from_tbl)" - ", '/where/', sj(dq(from_col)||' = old.'||dq(to_col),' AND ')" - ")" - "ELSE " - " 'SELECT RAISE(ABORT, ''constraint failed'');'" - "END " - - ") FROM temp.fkey " - "GROUP BY from_tbl, fkid" - ; - - int rc; - const int enc = SQLITE_UTF8; - sqlite3 *db = 0; - - GenfkeyCb cb; - cb.xData = xData; - cb.pCtx = pCtx; - - UNUSED_PARAMETER(zDb); - - /* Open the working database handle. */ - rc = sqlite3_open(":memory:", &db); - if( rc!=SQLITE_OK ) goto genfkey_exit; - - /* Create the special scalar and aggregate functions used by this program. */ - sqlite3_create_function(db, "dq", 1, enc, 0, doublequote, 0, 0); - sqlite3_create_function(db, "multireplace", -1, enc, db, multireplace, 0, 0); - sqlite3_create_function(db, "sj", 2, enc, 0, 0, joinStep, joinFinalize); - - /* Install the "schema" virtual table module */ - installSchemaModule(db, sdb); - - /* Create and populate a temp table with the information required to - ** build the foreign key triggers. See function populateTempTable() - ** for details. - */ - cb.eType = GENFKEY_ERROR; - rc = populateTempTable(db, &cb); - if( rc!=SQLITE_OK ) goto genfkey_exit; - - /* Unless the --no-drop option was specified, generate DROP TRIGGER - ** statements to drop any triggers in the database generated by a - ** previous run of this program. - */ - cb.eType = GENFKEY_DROPTRIGGER; - rc = sqlite3_exec(db, - "SELECT 'DROP TRIGGER main.' || dq(triggername) || ';' FROM triggers" - ,invokeCallback, (void *)&cb, 0 - ); - if( rc!=SQLITE_OK ) goto genfkey_exit; - - /* Run the main query to create the trigger definitions. */ - cb.eType = GENFKEY_CREATETRIGGER; - rc = sqlite3_exec(db, zSql, invokeCallback, (void *)&cb, 0); - if( rc!=SQLITE_OK ) goto genfkey_exit; - -genfkey_exit: - sqlite3_close(db); - return rc; -} - - -#endif -/* End genfkey logic. */ -/*************************************************************************/ -/*************************************************************************/ - /* ** If the following flag is set, then command execution stops ** at an error if we are not interactive. @@ -2059,62 +1197,6 @@ static int run_schema_dump_query( return rc; } -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_SUBQUERY) -struct GenfkeyCmd { - sqlite3 *db; /* Database handle */ - struct callback_data *pCb; /* Callback data */ - int isIgnoreErrors; /* True for --ignore-errors */ - int isExec; /* True for --exec */ - int isNoDrop; /* True for --no-drop */ - int nErr; /* Number of errors seen so far */ -}; -typedef struct GenfkeyCmd GenfkeyCmd; - -static int genfkeyParseArgs(GenfkeyCmd *p, char **azArg, int nArg){ - int ii; - memset(p, 0, sizeof(GenfkeyCmd)); - - for(ii=0; ii2 && n<10 && 0==strncmp(azArg[ii], "--no-drop", n) ){ - p->isNoDrop = 1; - }else if( n>2 && n<16 && 0==strncmp(azArg[ii], "--ignore-errors", n) ){ - p->isIgnoreErrors = 1; - }else if( n>2 && n<7 && 0==strncmp(azArg[ii], "--exec", n) ){ - p->isExec = 1; - }else{ - fprintf(stderr, "unknown option: %s\n", azArg[ii]); - return -1; - } - } - - return SQLITE_OK; -} - -static int genfkeyCmdCb(void *pCtx, int eType, const char *z){ - GenfkeyCmd *p = (GenfkeyCmd *)pCtx; - if( eType==GENFKEY_ERROR && !p->isIgnoreErrors ){ - p->nErr++; - fprintf(stderr, "%s\n", z); - } - - if( p->nErr==0 && ( - (eType==GENFKEY_CREATETRIGGER) - || (eType==GENFKEY_DROPTRIGGER && !p->isNoDrop) - )){ - if( p->isExec ){ - sqlite3_exec(p->db, z, 0, 0, 0); - }else{ - char *zCol = "sql"; - callback((void *)p->pCb, 1, (char **)&z, (char **)&zCol); - } - } - - return SQLITE_OK; -} -#endif - /* ** Text of a help message */ @@ -2129,14 +1211,6 @@ static char zHelp[] = ".exit Exit this program\n" ".explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.\n" " With no args, it turns EXPLAIN on.\n" -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_SUBQUERY) - ".genfkey ?OPTIONS? Options are:\n" - " --no-drop: Do not drop old fkey triggers.\n" - " --ignore-errors: Ignore tables with fkey errors\n" - " --exec: Execute generated SQL immediately\n" - " See file tool/genfkey.README in the source \n" - " distribution for further information.\n" -#endif ".header(s) ON|OFF Turn display of headers on or off\n" ".help Show this message\n" ".import FILE TABLE Import data from FILE into TABLE\n" @@ -2456,17 +1530,6 @@ static int do_meta_command(char *zLine, struct callback_data *p){ } }else -#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_SUBQUERY) - if( c=='g' && strncmp(azArg[0], "genfkey", n)==0 ){ - GenfkeyCmd cmd; - if( 0==genfkeyParseArgs(&cmd, &azArg[1], nArg-1) ){ - cmd.db = p->db; - cmd.pCb = p; - genfkey_create_triggers(p->db, "main", (void *)&cmd, genfkeyCmdCb); - } - }else -#endif - if( c=='h' && (strncmp(azArg[0], "header", n)==0 || strncmp(azArg[0], "headers", n)==0) && nArg>1 && nArg<3 ){ p->showHeader = booleanValue(azArg[1]); From 127f9d75e289e3a4cd45a16889bced0d94a1a608 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Feb 2010 01:47:00 +0000 Subject: [PATCH 18/50] Add the ".log" command to the shell. This shows that some errors are logged multiple times and other errors are never logged at all. FossilOrigin-Name: 6d910245ad0097521cf1619449cc3d202137b8b8 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/shell.c | 33 +++++++++++++++++++++++++++++++++ src/util.c | 2 +- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a06283e83c..c851c5f870 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Remove\sthe\s".genfkey"\scommand\sfrom\sthe\sshell.\s\sWe've\shad\sforeign-key\ssupport\nin\sthe\score\ssince\s3.6.19.\s\sAnyone\swho\sstill\sneeds\sthe\ssimulated\sforeign-key\ntriggers\scan\salways\sgenerate\sthem\swith\san\solder\sversion\sof\sthe\sshell. -D 2010-02-23T01:01:59 +C Add\sthe\s".log"\scommand\sto\sthe\sshell.\s\sThis\sshows\sthat\ssome\serrors\sare\slogged\nmultiple\stimes\sand\sother\serrors\sare\snever\slogged\sat\sall. +D 2010-02-23T01:47:00 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -167,7 +167,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 -F src/shell.c 285a9a83bebd12265841cea7e84f4b6088fe676e +F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 F src/sqlite.h.in 16f33c1ceb971bfa7a04a73039947630f445146e F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h d5fe1c8335b5bf376639837fa42124327cdb6767 @@ -211,7 +211,7 @@ F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 -F src/util.c 88b16cd614f42cbbe22e48633f220506e38fa654 +F src/util.c 5b5353ff9427422b0bb89a5bc8ddf818399c0401 F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de F src/vdbe.c 428411c6fbd49e9a4ce043dad87a0b079d403714 F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 86d50ce57feb78440956192e37a03686ffa1e196 -R d7e4885c2790f006c9fb03f523fb52e7 +P c4401fc93b66c5339422d7e765a4a32b1ef96bdb +R 1b44bf57e7d9a663688d30603c70b44c U drh -Z ce6478007e315584d717adb0d5a3c11c +Z 75784795cda6fd26f0b8feb0805d2536 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLgykLoxKgR168RlERAtBUAJ0WyBEJgyN2CRLORdcgGbStXZq3KQCdEb8r -rzZD4GEkFRgOhQAEyCwafJo= -=dDQ/ +iD8DBQFLgzOYoxKgR168RlERAgluAJ9q3mIeRrQvfpzpmiNDDWtRun1WrQCeME9w +x+Fdmmhc/ksLrbX58/ixhCk= +=d2xc -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index dda01bb480..f774487e26 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4401fc93b66c5339422d7e765a4a32b1ef96bdb \ No newline at end of file +6d910245ad0097521cf1619449cc3d202137b8b8 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index fdf6db7171..525a450e9a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -415,6 +415,7 @@ struct callback_data { char outfile[FILENAME_MAX]; /* Filename for *out */ const char *zDbFilename; /* name of the database file */ sqlite3_stmt *pStmt; /* Current statement if any. */ + FILE *pLog; /* Write log output here */ }; /* @@ -457,6 +458,16 @@ static int strlen30(const char *z){ return 0x3fffffff & (int)(z2 - z); } +/* +** A callback for the sqlite3_log() interface. +*/ +static void shellLog(void *pArg, int iErrCode, const char *zMsg){ + struct callback_data *p = (struct callback_data*)pArg; + if( p->pLog==0 ) return; + fprintf(p->pLog, "(%d) %s\n", iErrCode, zMsg); + fflush(p->pLog); +} + /* ** Output the given string as a hex-encoded blob (eg. X'1234' ) */ @@ -1223,6 +1234,7 @@ static char zHelp[] = #ifndef SQLITE_OMIT_LOAD_EXTENSION ".load FILE ?ENTRY? Load an extension library\n" #endif + ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n" ".mode MODE ?TABLE? Set output mode where MODE is one of:\n" " csv Comma-separated values\n" " column Left-aligned columns. (See .width)\n" @@ -1738,6 +1750,26 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else #endif + if( c=='l' && strncmp(azArg[0], "log", n)==0 && nArg>=1 ){ + const char *zFile = azArg[1]; + if( p->pLog && p->pLog!=stdout && p->pLog!=stderr ){ + fclose(p->pLog); + p->pLog = 0; + } + if( strcmp(zFile,"stdout")==0 ){ + p->pLog = stdout; + }else if( strcmp(zFile, "stderr")==0 ){ + p->pLog = stderr; + }else if( strcmp(zFile, "off")==0 ){ + p->pLog = 0; + }else{ + p->pLog = fopen(zFile, "w"); + if( p->pLog==0 ){ + fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); + } + } + }else + if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg==2 ){ int n2 = strlen30(azArg[1]); if( (n2==4 && strncmp(azArg[1],"line",n2)==0) @@ -2383,6 +2415,7 @@ static void main_init(struct callback_data *data) { data->mode = MODE_List; memcpy(data->separator,"|", 2); data->showHeader = 0; + sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); } diff --git a/src/util.c b/src/util.c index 7bf2df8d93..c173b4f9cf 100644 --- a/src/util.c +++ b/src/util.c @@ -123,7 +123,7 @@ void sqlite3Error(sqlite3 *db, int err_code, const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); - sqlite3_log(err_code, z); + sqlite3_log(err_code, "%s", z); sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC); }else{ sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC); From bdea6d13685fd9b33e27c7b89558496a2dbd7a9b Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 23 Feb 2010 04:19:54 +0000 Subject: [PATCH 19/50] Test new api to report which options (defines) were used to compile SQLite. FossilOrigin-Name: 84c9756993caf82710a0905ed1987d144bc764fd --- manifest | 32 ++-- manifest.uuid | 2 +- src/func.c | 16 ++ src/main.c | 396 ++++++++++++++++++++++++++++++++++++++++++++++++ src/sqlite.h.in | 12 +- 5 files changed, 434 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index c851c5f870..69ae5b8fc2 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Add\sthe\s".log"\scommand\sto\sthe\sshell.\s\sThis\sshows\sthat\ssome\serrors\sare\slogged\nmultiple\stimes\sand\sother\serrors\sare\snever\slogged\sat\sall. -D 2010-02-23T01:47:00 +C Test\snew\sapi\sto\sreport\swhich\soptions\s(defines)\swere\sused\sto\scompile\sSQLite. +D 2010-02-23T04:19:55 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -123,7 +120,7 @@ F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581 F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0 -F src/func.c 3864490a90a03ab1d657cdd04da78879c18b18d1 +F src/func.c 8854b7a234b4272a78941fcc899c117d1839cd4e F src/global.c 5a9c1e3c93213ca574786ac1caa976ce8f709105 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -133,7 +130,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c 36c1c11ee2677ae247e0c947f9293749ee5ac85f +F src/main.c e3e88f01f0f3555b837c867f6cdb9342a5ea3333 F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 @@ -168,7 +165,7 @@ F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 -F src/sqlite.h.in 16f33c1ceb971bfa7a04a73039947630f445146e +F src/sqlite.h.in 451a5a8bb2f6183ac50ae65f45f6e2b8ef4c6439 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h d5fe1c8335b5bf376639837fa42124327cdb6767 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 @@ -794,14 +791,11 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c4401fc93b66c5339422d7e765a4a32b1ef96bdb -R 1b44bf57e7d9a663688d30603c70b44c -U drh -Z 75784795cda6fd26f0b8feb0805d2536 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLgzOYoxKgR168RlERAgluAJ9q3mIeRrQvfpzpmiNDDWtRun1WrQCeME9w -x+Fdmmhc/ksLrbX58/ixhCk= -=d2xc ------END PGP SIGNATURE----- +P 6d910245ad0097521cf1619449cc3d202137b8b8 +R dedbbaae7790d6d9129d67a846293910 +T *bgcolor * pink +T *branch * compile_opts +T *sym-compile_opts * +T -sym-trunk * +U shaneh +Z a5cfd4374a14e6e3e3c31ae8396a940a diff --git a/manifest.uuid b/manifest.uuid index f774487e26..47e5608e9d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d910245ad0097521cf1619449cc3d202137b8b8 \ No newline at end of file +84c9756993caf82710a0905ed1987d144bc764fd \ No newline at end of file diff --git a/src/func.c b/src/func.c index d633ff83c3..19903e71db 100644 --- a/src/func.c +++ b/src/func.c @@ -774,6 +774,21 @@ static void sourceidFunc( sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC); } +/* +** Implementation of the sqlite_compile_opts() function. The result is a string +** that identifies the compiler options used to build SQLite. +*/ +static void compileoptsFunc( + sqlite3_context *context, + int NotUsed, + sqlite3_value **NotUsed2 +){ + UNUSED_PARAMETER2(NotUsed, NotUsed2); + /* IMP: R-xxxx This function is an SQL wrapper around the + ** sqlite3_compileopts() C interface. */ + sqlite3_result_text(context, sqlite3_compileopts(), -1, SQLITE_STATIC); +} + /* Array for converting from half-bytes (nybbles) into ASCII hex ** digits. */ static const char hexdigits[] = { @@ -1505,6 +1520,7 @@ void sqlite3RegisterGlobalFunctions(void){ FUNCTION(nullif, 2, 0, 1, nullifFunc ), FUNCTION(sqlite_version, 0, 0, 0, versionFunc ), FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), + FUNCTION(sqlite_compile_opts,0, 0, 0, compileoptsFunc ), FUNCTION(quote, 1, 0, 0, quoteFunc ), FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), FUNCTION(changes, 0, 0, 0, changes ), diff --git a/src/main.c b/src/main.c index e4419d269d..78e11d2334 100644 --- a/src/main.c +++ b/src/main.c @@ -36,6 +36,402 @@ const char *sqlite3_libversion(void){ return sqlite3_version; } const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } +const char *sqlite3_compileopts(void){ + static char zOpts[32] = ""; + sqlite_int64 iEnable = 0; /* bitmask of all the SQLITE_ENABLE* defines */ + sqlite_int64 iOmit = 0; /* bitmask of all the SQLITE_OMIT* defines */ + sqlite_int64 iOther = 0; /* bitmask of all the SQLITE_* defines except */ + /* SQLITE_MAX* and SQLITE_DEF* */ + +#ifdef SQLITE_32BIT_ROWID + iOther |= ((sqlite_int64)1<<0); +#endif +#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC + iOther |= ((sqlite_int64)1<<1); +#endif +#ifdef SQLITE_AMALGAMATION + iOther |= ((sqlite_int64)1<<2); +#endif +#ifdef SQLITE_API + iOther |= ((sqlite_int64)1<<3); +#endif +#ifdef SQLITE_ASCII + iOther |= ((sqlite_int64)1<<4); +#endif +#ifdef SQLITE_BIG_DBL + iOther |= ((sqlite_int64)1<<5); +#endif +#ifdef SQLITE_CASE_SENSITIVE_LIKE + iOther |= ((sqlite_int64)1<<6); +#endif +#ifdef SQLITE_CHECK_PAGES + iOther |= ((sqlite_int64)1<<7); +#endif +#ifdef SQLITE_CORE + iOther |= ((sqlite_int64)1<<8); +#endif +#ifdef SQLITE_COVERAGE_TEST + iOther |= ((sqlite_int64)1<<9); +#endif +#ifdef SQLITE_DEBUG + iOther |= ((sqlite_int64)1<<10); +#endif +#ifdef SQLITE_DISABLE_DIRSYNC + iOther |= ((sqlite_int64)1<<11); +#endif +#ifdef SQLITE_DISABLE_LFS + iOther |= ((sqlite_int64)1<<12); +#endif +#ifdef SQLITE_EBCDIC + iOther |= ((sqlite_int64)1<<13); +#endif +#ifdef SQLITE_ENABLE_ATOMIC_WRITE + iEnable |= ((sqlite_int64)1<<0); +#endif +#ifdef SQLITE_ENABLE_CEROD + iEnable |= ((sqlite_int64)1<<1); +#endif +#ifdef SQLITE_ENABLE_COLUMN_METADATA + iEnable |= ((sqlite_int64)1<<2); +#endif +#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT + iEnable |= ((sqlite_int64)1<<3); +#endif +#ifdef SQLITE_ENABLE_FTS1 + iEnable |= ((sqlite_int64)1<<4); +#endif +#ifdef SQLITE_ENABLE_FTS2 + iEnable |= ((sqlite_int64)1<<5); +#endif +#ifdef SQLITE_ENABLE_FTS3 + iEnable |= ((sqlite_int64)1<<6); +#endif +#ifdef SQLITE_ENABLE_FTS4 + iEnable |= ((sqlite_int64)1<<7); +#endif +#ifdef SQLITE_ENABLE_ICU + iEnable |= ((sqlite_int64)1<<8); +#endif +#ifdef SQLITE_ENABLE_IOTRACE + iEnable |= ((sqlite_int64)1<<9); +#endif +#ifdef SQLITE_ENABLE_LOAD_EXTENSION + iEnable |= ((sqlite_int64)1<<10); +#endif +#ifdef SQLITE_ENABLE_LOCKING_STYLE + iEnable |= ((sqlite_int64)1<<11); +#endif +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT + iEnable |= ((sqlite_int64)1<<12); +#endif +#ifdef SQLITE_ENABLE_MEMSYS3 + iEnable |= ((sqlite_int64)1<<13); +#endif +#ifdef SQLITE_ENABLE_MEMSYS5 + iEnable |= ((sqlite_int64)1<<14); +#endif +#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK + iEnable |= ((sqlite_int64)1<<15); +#endif +#ifdef SQLITE_ENABLE_RTREE + iEnable |= ((sqlite_int64)1<<16); +#endif +#ifdef SQLITE_ENABLE_STAT2 + iEnable |= ((sqlite_int64)1<<17); +#endif +#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY + iEnable |= ((sqlite_int64)1<<18); +#endif +#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT + iEnable |= ((sqlite_int64)1<<19); +#endif +#ifdef SQLITE_EXTERN + iOther |= ((sqlite_int64)1<<14); +#endif +#ifdef SQLITE_FILE_HEADER + iOther |= ((sqlite_int64)1<<15); +#endif +#ifdef SQLITE_HAS_CODEC + iOther |= ((sqlite_int64)1<<16); +#endif +#ifdef SQLITE_HAVE_ISNAN + iOther |= ((sqlite_int64)1<<17); +#endif +#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX + iOther |= ((sqlite_int64)1<<18); +#endif +#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS + iOther |= ((sqlite_int64)1<<19); +#endif +#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS + iOther |= ((sqlite_int64)1<<20); +#endif +#ifdef SQLITE_INT64_TYPE + iOther |= ((sqlite_int64)1<<21); +#endif +#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX + iOther |= ((sqlite_int64)1<<22); +#endif +#ifdef SQLITE_LOCK_TRACE + iOther |= ((sqlite_int64)1<<23); +#endif +#ifdef SQLITE_MALLOC_SOFT_LIMIT + iOther |= ((sqlite_int64)1<<24); +#endif +#ifdef SQLITE_MEMDEBUG + iOther |= ((sqlite_int64)1<<25); +#endif +#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT + iOther |= ((sqlite_int64)1<<26); +#endif +#ifdef SQLITE_MUTEX_NOOP + iOther |= ((sqlite_int64)1<<27); +#endif +#ifdef SQLITE_MUTEX_OMIT + iOther |= ((sqlite_int64)1<<28); +#endif +#ifdef SQLITE_MUTEX_OS2 + iOther |= ((sqlite_int64)1<<29); +#endif +#ifdef SQLITE_MUTEX_PTHREADS + iOther |= ((sqlite_int64)1<<30); +#endif +#ifdef SQLITE_MUTEX_W32 + iOther |= ((sqlite_int64)1<<31); +#endif +#ifdef SQLITE_NO_SYNC + iOther |= ((sqlite_int64)1<<32); +#endif +#ifdef SQLITE_N_COLCACHE + iOther |= ((sqlite_int64)1<<33); +#endif +#ifdef SQLITE_N_KEYWORD + iOther |= ((sqlite_int64)1<<34); +#endif +#ifdef SQLITE_OMIT_ALTERTABLE + iOmit |= ((sqlite_int64)1<<0); +#endif +#ifdef SQLITE_OMIT_ANALYZE + iOmit |= ((sqlite_int64)1<<1); +#endif +#ifdef SQLITE_OMIT_ATTACH + iOmit |= ((sqlite_int64)1<<2); +#endif +#ifdef SQLITE_OMIT_AUTHORIZATION + iOmit |= ((sqlite_int64)1<<3); +#endif +#ifdef SQLITE_OMIT_AUTOINCREMENT + iOmit |= ((sqlite_int64)1<<4); +#endif +#ifdef SQLITE_OMIT_AUTOINIT + iOmit |= ((sqlite_int64)1<<5); +#endif +#ifdef SQLITE_OMIT_AUTOVACUUM + iOmit |= ((sqlite_int64)1<<6); +#endif +#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<7); +#endif +#ifdef SQLITE_OMIT_BLOB_LITERAL + iOmit |= ((sqlite_int64)1<<8); +#endif +#ifdef SQLITE_OMIT_BTREECOUNT + iOmit |= ((sqlite_int64)1<<9); +#endif +#ifdef SQLITE_OMIT_BUILTIN_TEST + iOmit |= ((sqlite_int64)1<<10); +#endif +#ifdef SQLITE_OMIT_CAST + iOmit |= ((sqlite_int64)1<<11); +#endif +#ifdef SQLITE_OMIT_CHECK + iOmit |= ((sqlite_int64)1<<12); +#endif +#ifdef SQLITE_OMIT_COMPLETE + iOmit |= ((sqlite_int64)1<<13); +#endif +#ifdef SQLITE_OMIT_COMPOUND_SELECT + iOmit |= ((sqlite_int64)1<<14); +#endif +#ifdef SQLITE_OMIT_DATETIME_FUNCS + iOmit |= ((sqlite_int64)1<<15); +#endif +#ifdef SQLITE_OMIT_DECLTYPE + iOmit |= ((sqlite_int64)1<<16); +#endif +#ifdef SQLITE_OMIT_DEPRECATED + iOmit |= ((sqlite_int64)1<<17); +#endif +#ifdef SQLITE_OMIT_DISKIO + iOmit |= ((sqlite_int64)1<<18); +#endif +#ifdef SQLITE_OMIT_EXPLAIN + iOmit |= ((sqlite_int64)1<<19); +#endif +#ifdef SQLITE_OMIT_FLAG_PRAGMAS + iOmit |= ((sqlite_int64)1<<20); +#endif +#ifdef SQLITE_OMIT_FLOATING_POINT + iOmit |= ((sqlite_int64)1<<21); +#endif +#ifdef SQLITE_OMIT_FOREIGN_KEY + iOmit |= ((sqlite_int64)1<<22); +#endif +#ifdef SQLITE_OMIT_GET_TABLE + iOmit |= ((sqlite_int64)1<<23); +#endif +#ifdef SQLITE_OMIT_GLOBALRECOVER + iOmit |= ((sqlite_int64)1<<24); +#endif +#ifdef SQLITE_OMIT_INCRBLOB + iOmit |= ((sqlite_int64)1<<25); +#endif +#ifdef SQLITE_OMIT_INTEGRITY_CHECK + iOmit |= ((sqlite_int64)1<<26); +#endif +#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<27); +#endif +#ifdef SQLITE_OMIT_LOAD_EXTENSION + iOmit |= ((sqlite_int64)1<<28); +#endif +#ifdef SQLITE_OMIT_LOCALTIME + iOmit |= ((sqlite_int64)1<<29); +#endif +#ifdef SQLITE_OMIT_LOOKASIDE + iOmit |= ((sqlite_int64)1<<30); +#endif +#ifdef SQLITE_OMIT_MEMORYDB + iOmit |= ((sqlite_int64)1<<31); +#endif +#ifdef SQLITE_OMIT_OR_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<32); +#endif +#ifdef SQLITE_OMIT_PAGER_PRAGMAS + iOmit |= ((sqlite_int64)1<<33); +#endif +#ifdef SQLITE_OMIT_PRAGMA + iOmit |= ((sqlite_int64)1<<34); +#endif +#ifdef SQLITE_OMIT_PROGRESS_CALLBACK + iOmit |= ((sqlite_int64)1<<35); +#endif +#ifdef SQLITE_OMIT_QUICKBALANCE + iOmit |= ((sqlite_int64)1<<36); +#endif +#ifdef SQLITE_OMIT_REINDEX + iOmit |= ((sqlite_int64)1<<37); +#endif +#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS + iOmit |= ((sqlite_int64)1<<38); +#endif +#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS + iOmit |= ((sqlite_int64)1<<39); +#endif +#ifdef SQLITE_OMIT_SHARED_CACHE + iOmit |= ((sqlite_int64)1<<40); +#endif +#ifdef SQLITE_OMIT_SUBQUERY + iOmit |= ((sqlite_int64)1<<41); +#endif +#ifdef SQLITE_OMIT_TCL_VARIABLE + iOmit |= ((sqlite_int64)1<<42); +#endif +#ifdef SQLITE_OMIT_TEMPDB + iOmit |= ((sqlite_int64)1<<43); +#endif +#ifdef SQLITE_OMIT_TRACE + iOmit |= ((sqlite_int64)1<<44); +#endif +#ifdef SQLITE_OMIT_TRIGGER + iOmit |= ((sqlite_int64)1<<45); +#endif +#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<46); +#endif +#ifdef SQLITE_OMIT_UTF16 + iOmit |= ((sqlite_int64)1<<47); +#endif +#ifdef SQLITE_OMIT_VACUUM + iOmit |= ((sqlite_int64)1<<48); +#endif +#ifdef SQLITE_OMIT_VIEW + iOmit |= ((sqlite_int64)1<<49); +#endif +#ifdef SQLITE_OMIT_VIRTUALTABLE + iOmit |= ((sqlite_int64)1<<50); +#endif +#ifdef SQLITE_OMIT_WSD + iOmit |= ((sqlite_int64)1<<51); +#endif +#ifdef SQLITE_OMIT_XFER_OPT + iOmit |= ((sqlite_int64)1<<52); +#endif +#ifdef SQLITE_OS_OTHER + iOther |= ((sqlite_int64)1<<35); +#endif +#ifdef SQLITE_OS_UNIX + iOther |= ((sqlite_int64)1<<36); +#endif +#ifdef SQLITE_PERFORMANCE_TRACE + iOther |= ((sqlite_int64)1<<37); +#endif +#ifdef SQLITE_PRINT_BUF_SIZE + iOther |= ((sqlite_int64)1<<38); +#endif +#ifdef SQLITE_PRIVATE + iOther |= ((sqlite_int64)1<<39); +#endif +#ifdef SQLITE_PROXY_DEBUG + iOther |= ((sqlite_int64)1<<40); +#endif +#ifdef SQLITE_SECURE_DELETE + iOther |= ((sqlite_int64)1<<41); +#endif +#ifdef SQLITE_SMALL_STACK + iOther |= ((sqlite_int64)1<<42); +#endif +#ifdef SQLITE_SOUNDEX + iOther |= ((sqlite_int64)1<<43); +#endif +#ifdef SQLITE_SYSTEM_MALLOC + iOther |= ((sqlite_int64)1<<44); +#endif +#ifdef SQLITE_TCL + iOther |= ((sqlite_int64)1<<45); +#endif +#ifdef SQLITE_TEMP_FILE_PREFIX + iOther |= ((sqlite_int64)1<<46); +#endif +#ifdef SQLITE_TEMP_STORE + iOther |= ((sqlite_int64)1<<47); +#endif +#ifdef SQLITE_TEST + iOther |= ((sqlite_int64)1<<48); +#endif +#ifdef SQLITE_TEXT + iOther |= ((sqlite_int64)1<<49); +#endif +#ifdef SQLITE_THREADSAFE + iOther |= ((sqlite_int64)1<<50); +#endif +#ifdef SQLITE_USE_ALLOCA + iOther |= ((sqlite_int64)1<<51); +#endif +#ifdef SQLITE_VERSION + iOther |= ((sqlite_int64)1<<52); +#endif +#ifdef SQLITE_VERSION_NUMBER + iOther |= ((sqlite_int64)1<<53); +#endif +#ifdef SQLITE_ZERO_MALLOC + iOther |= ((sqlite_int64)1<<54); +#endif + + sqlite3_snprintf(sizeof(zOpts)-1, zOpts, + "%016llx%016llx%016llx", iEnable, iOmit, iOther); + return zOpts; +} #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) /* diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1c0a5bf52b..d7860a392d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -130,16 +130,20 @@ extern "C" { ** function is provided for use in DLLs since DLL users usually do not have ** direct access to string constants within the DLL. ^The ** sqlite3_libversion_number() function returns an integer equal to -** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function a pointer -** to a string constant whose value is the same as the [SQLITE_SOURCE_ID] -** C preprocessor macro. +** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns +** a pointer to a string constant whose value is the same as the +** [SQLITE_SOURCE_ID] C preprocessor macro. ^The sqlite3_compileopts() +** function returns a pointer to a string constant whose value describes +** the compiler options used. ** -** See also: [sqlite_version()] and [sqlite_source_id()]. +** See also: [sqlite_version()], [sqlite_source_id()], +** and [sqlite_compile_opts()]. */ SQLITE_EXTERN const char sqlite3_version[]; const char *sqlite3_libversion(void); const char *sqlite3_sourceid(void); int sqlite3_libversion_number(void); +const char *sqlite3_compileopts(void); /* ** CAPI3REF: Test To See If The Library Is Threadsafe From ca07b9df47e615a8f510faff023d585ef889206c Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 23 Feb 2010 05:17:51 +0000 Subject: [PATCH 20/50] Removed checking of some compile options from the sqlite3_compileopts() API. FossilOrigin-Name: 833da702ff9bd99d62640756d80e094256efff5c --- manifest | 16 +- manifest.uuid | 2 +- src/main.c | 707 +++++++++++++++++++++++--------------------------- 3 files changed, 329 insertions(+), 396 deletions(-) diff --git a/manifest b/manifest index 69ae5b8fc2..6e5969c25e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\snew\sapi\sto\sreport\swhich\soptions\s(defines)\swere\sused\sto\scompile\sSQLite. -D 2010-02-23T04:19:55 +C Removed\schecking\sof\ssome\scompile\soptions\sfrom\sthe\ssqlite3_compileopts()\sAPI. +D 2010-02-23T05:17:52 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -130,7 +130,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c e3e88f01f0f3555b837c867f6cdb9342a5ea3333 +F src/main.c e75d96a0bd6f874a18d5dac855d330a4739de0b2 F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 @@ -791,11 +791,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 6d910245ad0097521cf1619449cc3d202137b8b8 -R dedbbaae7790d6d9129d67a846293910 -T *bgcolor * pink -T *branch * compile_opts -T *sym-compile_opts * -T -sym-trunk * +P 84c9756993caf82710a0905ed1987d144bc764fd +R f5089208430b2ba4dd4063929e4e20e6 U shaneh -Z a5cfd4374a14e6e3e3c31ae8396a940a +Z 9884f73578eca45685b3905c76fc5c0d diff --git a/manifest.uuid b/manifest.uuid index 47e5608e9d..519435ec1f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -84c9756993caf82710a0905ed1987d144bc764fd \ No newline at end of file +833da702ff9bd99d62640756d80e094256efff5c \ No newline at end of file diff --git a/src/main.c b/src/main.c index 78e11d2334..2bd43fbe17 100644 --- a/src/main.c +++ b/src/main.c @@ -36,397 +36,334 @@ const char *sqlite3_libversion(void){ return sqlite3_version; } const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } -const char *sqlite3_compileopts(void){ +const char *sqlite3_compileopts(void){ static char zOpts[32] = ""; sqlite_int64 iEnable = 0; /* bitmask of all the SQLITE_ENABLE* defines */ sqlite_int64 iOmit = 0; /* bitmask of all the SQLITE_OMIT* defines */ sqlite_int64 iOther = 0; /* bitmask of all the SQLITE_* defines except */ /* SQLITE_MAX* and SQLITE_DEF* */ -#ifdef SQLITE_32BIT_ROWID - iOther |= ((sqlite_int64)1<<0); -#endif -#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC - iOther |= ((sqlite_int64)1<<1); -#endif -#ifdef SQLITE_AMALGAMATION - iOther |= ((sqlite_int64)1<<2); -#endif -#ifdef SQLITE_API - iOther |= ((sqlite_int64)1<<3); -#endif -#ifdef SQLITE_ASCII - iOther |= ((sqlite_int64)1<<4); -#endif -#ifdef SQLITE_BIG_DBL - iOther |= ((sqlite_int64)1<<5); -#endif -#ifdef SQLITE_CASE_SENSITIVE_LIKE - iOther |= ((sqlite_int64)1<<6); -#endif -#ifdef SQLITE_CHECK_PAGES - iOther |= ((sqlite_int64)1<<7); -#endif -#ifdef SQLITE_CORE - iOther |= ((sqlite_int64)1<<8); -#endif -#ifdef SQLITE_COVERAGE_TEST - iOther |= ((sqlite_int64)1<<9); -#endif -#ifdef SQLITE_DEBUG - iOther |= ((sqlite_int64)1<<10); -#endif -#ifdef SQLITE_DISABLE_DIRSYNC - iOther |= ((sqlite_int64)1<<11); -#endif -#ifdef SQLITE_DISABLE_LFS - iOther |= ((sqlite_int64)1<<12); -#endif -#ifdef SQLITE_EBCDIC - iOther |= ((sqlite_int64)1<<13); -#endif -#ifdef SQLITE_ENABLE_ATOMIC_WRITE - iEnable |= ((sqlite_int64)1<<0); -#endif -#ifdef SQLITE_ENABLE_CEROD - iEnable |= ((sqlite_int64)1<<1); -#endif -#ifdef SQLITE_ENABLE_COLUMN_METADATA - iEnable |= ((sqlite_int64)1<<2); -#endif -#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT - iEnable |= ((sqlite_int64)1<<3); -#endif -#ifdef SQLITE_ENABLE_FTS1 - iEnable |= ((sqlite_int64)1<<4); -#endif -#ifdef SQLITE_ENABLE_FTS2 - iEnable |= ((sqlite_int64)1<<5); -#endif -#ifdef SQLITE_ENABLE_FTS3 - iEnable |= ((sqlite_int64)1<<6); -#endif -#ifdef SQLITE_ENABLE_FTS4 - iEnable |= ((sqlite_int64)1<<7); -#endif -#ifdef SQLITE_ENABLE_ICU - iEnable |= ((sqlite_int64)1<<8); -#endif -#ifdef SQLITE_ENABLE_IOTRACE - iEnable |= ((sqlite_int64)1<<9); -#endif -#ifdef SQLITE_ENABLE_LOAD_EXTENSION - iEnable |= ((sqlite_int64)1<<10); -#endif -#ifdef SQLITE_ENABLE_LOCKING_STYLE - iEnable |= ((sqlite_int64)1<<11); -#endif -#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT - iEnable |= ((sqlite_int64)1<<12); -#endif -#ifdef SQLITE_ENABLE_MEMSYS3 - iEnable |= ((sqlite_int64)1<<13); -#endif -#ifdef SQLITE_ENABLE_MEMSYS5 - iEnable |= ((sqlite_int64)1<<14); -#endif -#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK - iEnable |= ((sqlite_int64)1<<15); -#endif -#ifdef SQLITE_ENABLE_RTREE - iEnable |= ((sqlite_int64)1<<16); -#endif -#ifdef SQLITE_ENABLE_STAT2 - iEnable |= ((sqlite_int64)1<<17); -#endif -#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY - iEnable |= ((sqlite_int64)1<<18); -#endif -#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT - iEnable |= ((sqlite_int64)1<<19); -#endif -#ifdef SQLITE_EXTERN - iOther |= ((sqlite_int64)1<<14); -#endif -#ifdef SQLITE_FILE_HEADER - iOther |= ((sqlite_int64)1<<15); -#endif -#ifdef SQLITE_HAS_CODEC - iOther |= ((sqlite_int64)1<<16); -#endif -#ifdef SQLITE_HAVE_ISNAN - iOther |= ((sqlite_int64)1<<17); -#endif -#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX - iOther |= ((sqlite_int64)1<<18); -#endif -#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS - iOther |= ((sqlite_int64)1<<19); -#endif -#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS - iOther |= ((sqlite_int64)1<<20); -#endif -#ifdef SQLITE_INT64_TYPE - iOther |= ((sqlite_int64)1<<21); -#endif -#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX - iOther |= ((sqlite_int64)1<<22); -#endif -#ifdef SQLITE_LOCK_TRACE - iOther |= ((sqlite_int64)1<<23); -#endif -#ifdef SQLITE_MALLOC_SOFT_LIMIT - iOther |= ((sqlite_int64)1<<24); -#endif -#ifdef SQLITE_MEMDEBUG - iOther |= ((sqlite_int64)1<<25); -#endif -#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT - iOther |= ((sqlite_int64)1<<26); -#endif -#ifdef SQLITE_MUTEX_NOOP - iOther |= ((sqlite_int64)1<<27); -#endif -#ifdef SQLITE_MUTEX_OMIT - iOther |= ((sqlite_int64)1<<28); -#endif -#ifdef SQLITE_MUTEX_OS2 - iOther |= ((sqlite_int64)1<<29); -#endif -#ifdef SQLITE_MUTEX_PTHREADS - iOther |= ((sqlite_int64)1<<30); -#endif -#ifdef SQLITE_MUTEX_W32 - iOther |= ((sqlite_int64)1<<31); -#endif -#ifdef SQLITE_NO_SYNC - iOther |= ((sqlite_int64)1<<32); -#endif -#ifdef SQLITE_N_COLCACHE - iOther |= ((sqlite_int64)1<<33); -#endif -#ifdef SQLITE_N_KEYWORD - iOther |= ((sqlite_int64)1<<34); -#endif -#ifdef SQLITE_OMIT_ALTERTABLE - iOmit |= ((sqlite_int64)1<<0); -#endif -#ifdef SQLITE_OMIT_ANALYZE - iOmit |= ((sqlite_int64)1<<1); -#endif -#ifdef SQLITE_OMIT_ATTACH - iOmit |= ((sqlite_int64)1<<2); -#endif -#ifdef SQLITE_OMIT_AUTHORIZATION - iOmit |= ((sqlite_int64)1<<3); -#endif -#ifdef SQLITE_OMIT_AUTOINCREMENT - iOmit |= ((sqlite_int64)1<<4); -#endif -#ifdef SQLITE_OMIT_AUTOINIT - iOmit |= ((sqlite_int64)1<<5); -#endif -#ifdef SQLITE_OMIT_AUTOVACUUM - iOmit |= ((sqlite_int64)1<<6); -#endif -#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION - iOmit |= ((sqlite_int64)1<<7); -#endif -#ifdef SQLITE_OMIT_BLOB_LITERAL - iOmit |= ((sqlite_int64)1<<8); -#endif -#ifdef SQLITE_OMIT_BTREECOUNT - iOmit |= ((sqlite_int64)1<<9); -#endif -#ifdef SQLITE_OMIT_BUILTIN_TEST - iOmit |= ((sqlite_int64)1<<10); -#endif -#ifdef SQLITE_OMIT_CAST - iOmit |= ((sqlite_int64)1<<11); -#endif -#ifdef SQLITE_OMIT_CHECK - iOmit |= ((sqlite_int64)1<<12); -#endif -#ifdef SQLITE_OMIT_COMPLETE - iOmit |= ((sqlite_int64)1<<13); -#endif -#ifdef SQLITE_OMIT_COMPOUND_SELECT - iOmit |= ((sqlite_int64)1<<14); -#endif -#ifdef SQLITE_OMIT_DATETIME_FUNCS - iOmit |= ((sqlite_int64)1<<15); -#endif -#ifdef SQLITE_OMIT_DECLTYPE - iOmit |= ((sqlite_int64)1<<16); -#endif -#ifdef SQLITE_OMIT_DEPRECATED - iOmit |= ((sqlite_int64)1<<17); -#endif -#ifdef SQLITE_OMIT_DISKIO - iOmit |= ((sqlite_int64)1<<18); -#endif -#ifdef SQLITE_OMIT_EXPLAIN - iOmit |= ((sqlite_int64)1<<19); -#endif -#ifdef SQLITE_OMIT_FLAG_PRAGMAS - iOmit |= ((sqlite_int64)1<<20); -#endif -#ifdef SQLITE_OMIT_FLOATING_POINT - iOmit |= ((sqlite_int64)1<<21); -#endif -#ifdef SQLITE_OMIT_FOREIGN_KEY - iOmit |= ((sqlite_int64)1<<22); -#endif -#ifdef SQLITE_OMIT_GET_TABLE - iOmit |= ((sqlite_int64)1<<23); -#endif -#ifdef SQLITE_OMIT_GLOBALRECOVER - iOmit |= ((sqlite_int64)1<<24); -#endif -#ifdef SQLITE_OMIT_INCRBLOB - iOmit |= ((sqlite_int64)1<<25); -#endif -#ifdef SQLITE_OMIT_INTEGRITY_CHECK - iOmit |= ((sqlite_int64)1<<26); -#endif -#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION - iOmit |= ((sqlite_int64)1<<27); -#endif -#ifdef SQLITE_OMIT_LOAD_EXTENSION - iOmit |= ((sqlite_int64)1<<28); -#endif -#ifdef SQLITE_OMIT_LOCALTIME - iOmit |= ((sqlite_int64)1<<29); -#endif -#ifdef SQLITE_OMIT_LOOKASIDE - iOmit |= ((sqlite_int64)1<<30); -#endif -#ifdef SQLITE_OMIT_MEMORYDB - iOmit |= ((sqlite_int64)1<<31); -#endif -#ifdef SQLITE_OMIT_OR_OPTIMIZATION - iOmit |= ((sqlite_int64)1<<32); -#endif -#ifdef SQLITE_OMIT_PAGER_PRAGMAS - iOmit |= ((sqlite_int64)1<<33); -#endif -#ifdef SQLITE_OMIT_PRAGMA - iOmit |= ((sqlite_int64)1<<34); -#endif -#ifdef SQLITE_OMIT_PROGRESS_CALLBACK - iOmit |= ((sqlite_int64)1<<35); -#endif -#ifdef SQLITE_OMIT_QUICKBALANCE - iOmit |= ((sqlite_int64)1<<36); -#endif -#ifdef SQLITE_OMIT_REINDEX - iOmit |= ((sqlite_int64)1<<37); -#endif -#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS - iOmit |= ((sqlite_int64)1<<38); -#endif -#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS - iOmit |= ((sqlite_int64)1<<39); -#endif -#ifdef SQLITE_OMIT_SHARED_CACHE - iOmit |= ((sqlite_int64)1<<40); -#endif -#ifdef SQLITE_OMIT_SUBQUERY - iOmit |= ((sqlite_int64)1<<41); -#endif -#ifdef SQLITE_OMIT_TCL_VARIABLE - iOmit |= ((sqlite_int64)1<<42); -#endif -#ifdef SQLITE_OMIT_TEMPDB - iOmit |= ((sqlite_int64)1<<43); -#endif -#ifdef SQLITE_OMIT_TRACE - iOmit |= ((sqlite_int64)1<<44); -#endif -#ifdef SQLITE_OMIT_TRIGGER - iOmit |= ((sqlite_int64)1<<45); -#endif -#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION - iOmit |= ((sqlite_int64)1<<46); -#endif -#ifdef SQLITE_OMIT_UTF16 - iOmit |= ((sqlite_int64)1<<47); -#endif -#ifdef SQLITE_OMIT_VACUUM - iOmit |= ((sqlite_int64)1<<48); -#endif -#ifdef SQLITE_OMIT_VIEW - iOmit |= ((sqlite_int64)1<<49); -#endif -#ifdef SQLITE_OMIT_VIRTUALTABLE - iOmit |= ((sqlite_int64)1<<50); -#endif -#ifdef SQLITE_OMIT_WSD - iOmit |= ((sqlite_int64)1<<51); -#endif -#ifdef SQLITE_OMIT_XFER_OPT - iOmit |= ((sqlite_int64)1<<52); -#endif -#ifdef SQLITE_OS_OTHER - iOther |= ((sqlite_int64)1<<35); -#endif -#ifdef SQLITE_OS_UNIX - iOther |= ((sqlite_int64)1<<36); -#endif -#ifdef SQLITE_PERFORMANCE_TRACE - iOther |= ((sqlite_int64)1<<37); -#endif -#ifdef SQLITE_PRINT_BUF_SIZE - iOther |= ((sqlite_int64)1<<38); -#endif -#ifdef SQLITE_PRIVATE - iOther |= ((sqlite_int64)1<<39); -#endif -#ifdef SQLITE_PROXY_DEBUG - iOther |= ((sqlite_int64)1<<40); -#endif -#ifdef SQLITE_SECURE_DELETE - iOther |= ((sqlite_int64)1<<41); -#endif -#ifdef SQLITE_SMALL_STACK - iOther |= ((sqlite_int64)1<<42); -#endif -#ifdef SQLITE_SOUNDEX - iOther |= ((sqlite_int64)1<<43); -#endif -#ifdef SQLITE_SYSTEM_MALLOC - iOther |= ((sqlite_int64)1<<44); -#endif -#ifdef SQLITE_TCL - iOther |= ((sqlite_int64)1<<45); -#endif -#ifdef SQLITE_TEMP_FILE_PREFIX - iOther |= ((sqlite_int64)1<<46); -#endif -#ifdef SQLITE_TEMP_STORE - iOther |= ((sqlite_int64)1<<47); -#endif -#ifdef SQLITE_TEST - iOther |= ((sqlite_int64)1<<48); -#endif -#ifdef SQLITE_TEXT - iOther |= ((sqlite_int64)1<<49); -#endif -#ifdef SQLITE_THREADSAFE - iOther |= ((sqlite_int64)1<<50); -#endif -#ifdef SQLITE_USE_ALLOCA - iOther |= ((sqlite_int64)1<<51); -#endif -#ifdef SQLITE_VERSION - iOther |= ((sqlite_int64)1<<52); -#endif -#ifdef SQLITE_VERSION_NUMBER - iOther |= ((sqlite_int64)1<<53); -#endif -#ifdef SQLITE_ZERO_MALLOC - iOther |= ((sqlite_int64)1<<54); -#endif +#ifdef SQLITE_32BIT_ROWID + iOther |= ((sqlite_int64)1<<0); +#endif +#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC + iOther |= ((sqlite_int64)1<<1); +#endif +#ifdef SQLITE_API + iOther |= ((sqlite_int64)1<<2); +#endif +#ifdef SQLITE_CASE_SENSITIVE_LIKE + iOther |= ((sqlite_int64)1<<3); +#endif +#ifdef SQLITE_CHECK_PAGES + iOther |= ((sqlite_int64)1<<4); +#endif +#ifdef SQLITE_COVERAGE_TEST + iOther |= ((sqlite_int64)1<<5); +#endif +#ifdef SQLITE_DEBUG + iOther |= ((sqlite_int64)1<<6); +#endif +#ifdef SQLITE_DISABLE_DIRSYNC + iOther |= ((sqlite_int64)1<<7); +#endif +#ifdef SQLITE_DISABLE_LFS + iOther |= ((sqlite_int64)1<<8); +#endif +#ifdef SQLITE_ENABLE_ATOMIC_WRITE + iEnable |= ((sqlite_int64)1<<0); +#endif +#ifdef SQLITE_ENABLE_CEROD + iEnable |= ((sqlite_int64)1<<1); +#endif +#ifdef SQLITE_ENABLE_COLUMN_METADATA + iEnable |= ((sqlite_int64)1<<2); +#endif +#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT + iEnable |= ((sqlite_int64)1<<3); +#endif +#ifdef SQLITE_ENABLE_FTS1 + iEnable |= ((sqlite_int64)1<<4); +#endif +#ifdef SQLITE_ENABLE_FTS2 + iEnable |= ((sqlite_int64)1<<5); +#endif +#ifdef SQLITE_ENABLE_FTS3 + iEnable |= ((sqlite_int64)1<<6); +#endif +#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS + iEnable |= ((sqlite_int64)1<<7); +#endif +#ifdef SQLITE_ENABLE_FTS4 + iEnable |= ((sqlite_int64)1<<8); +#endif +#ifdef SQLITE_ENABLE_ICU + iEnable |= ((sqlite_int64)1<<9); +#endif +#ifdef SQLITE_ENABLE_IOTRACE + iEnable |= ((sqlite_int64)1<<10); +#endif +#ifdef SQLITE_ENABLE_LOAD_EXTENSION + iEnable |= ((sqlite_int64)1<<11); +#endif +#ifdef SQLITE_ENABLE_LOCKING_STYLE + iEnable |= ((sqlite_int64)1<<12); +#endif +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT + iEnable |= ((sqlite_int64)1<<13); +#endif +#ifdef SQLITE_ENABLE_MEMSYS3 + iEnable |= ((sqlite_int64)1<<14); +#endif +#ifdef SQLITE_ENABLE_MEMSYS5 + iEnable |= ((sqlite_int64)1<<15); +#endif +#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK + iEnable |= ((sqlite_int64)1<<16); +#endif +#ifdef SQLITE_ENABLE_RTREE + iEnable |= ((sqlite_int64)1<<17); +#endif +#ifdef SQLITE_ENABLE_STAT2 + iEnable |= ((sqlite_int64)1<<18); +#endif +#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY + iEnable |= ((sqlite_int64)1<<19); +#endif +#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT + iEnable |= ((sqlite_int64)1<<20); +#endif +#ifdef SQLITE_HAS_CODEC + iOther |= ((sqlite_int64)1<<9); +#endif +#ifdef SQLITE_HAVE_ISNAN + iOther |= ((sqlite_int64)1<<10); +#endif +#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX + iOther |= ((sqlite_int64)1<<11); +#endif +#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS + iOther |= ((sqlite_int64)1<<12); +#endif +#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS + iOther |= ((sqlite_int64)1<<13); +#endif +#ifdef SQLITE_INT64_TYPE + iOther |= ((sqlite_int64)1<<14); +#endif +#ifdef SQLITE_LOCK_TRACE + iOther |= ((sqlite_int64)1<<15); +#endif +#ifdef SQLITE_MEMDEBUG + iOther |= ((sqlite_int64)1<<16); +#endif +#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT + iOther |= ((sqlite_int64)1<<17); +#endif +#ifdef SQLITE_MUTEX_NOOP + iOther |= ((sqlite_int64)1<<18); +#endif +#ifdef SQLITE_MUTEX_OMIT + iOther |= ((sqlite_int64)1<<19); +#endif +#ifdef SQLITE_MUTEX_OS2 + iOther |= ((sqlite_int64)1<<20); +#endif +#ifdef SQLITE_MUTEX_PTHREADS + iOther |= ((sqlite_int64)1<<21); +#endif +#ifdef SQLITE_MUTEX_W32 + iOther |= ((sqlite_int64)1<<22); +#endif +#ifdef SQLITE_NO_SYNC + iOther |= ((sqlite_int64)1<<23); +#endif +#ifdef SQLITE_OMIT_ALTERTABLE + iOmit |= ((sqlite_int64)1<<0); +#endif +#ifdef SQLITE_OMIT_ANALYZE + iOmit |= ((sqlite_int64)1<<1); +#endif +#ifdef SQLITE_OMIT_ATTACH + iOmit |= ((sqlite_int64)1<<2); +#endif +#ifdef SQLITE_OMIT_AUTHORIZATION + iOmit |= ((sqlite_int64)1<<3); +#endif +#ifdef SQLITE_OMIT_AUTOINCREMENT + iOmit |= ((sqlite_int64)1<<4); +#endif +#ifdef SQLITE_OMIT_AUTOINIT + iOmit |= ((sqlite_int64)1<<5); +#endif +#ifdef SQLITE_OMIT_AUTOVACUUM + iOmit |= ((sqlite_int64)1<<6); +#endif +#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<7); +#endif +#ifdef SQLITE_OMIT_BLOB_LITERAL + iOmit |= ((sqlite_int64)1<<8); +#endif +#ifdef SQLITE_OMIT_BTREECOUNT + iOmit |= ((sqlite_int64)1<<9); +#endif +#ifdef SQLITE_OMIT_BUILTIN_TEST + iOmit |= ((sqlite_int64)1<<10); +#endif +#ifdef SQLITE_OMIT_CAST + iOmit |= ((sqlite_int64)1<<11); +#endif +#ifdef SQLITE_OMIT_CHECK + iOmit |= ((sqlite_int64)1<<12); +#endif +#ifdef SQLITE_OMIT_COMPLETE + iOmit |= ((sqlite_int64)1<<13); +#endif +#ifdef SQLITE_OMIT_COMPOUND_SELECT + iOmit |= ((sqlite_int64)1<<14); +#endif +#ifdef SQLITE_OMIT_DATETIME_FUNCS + iOmit |= ((sqlite_int64)1<<15); +#endif +#ifdef SQLITE_OMIT_DECLTYPE + iOmit |= ((sqlite_int64)1<<16); +#endif +#ifdef SQLITE_OMIT_DEPRECATED + iOmit |= ((sqlite_int64)1<<17); +#endif +#ifdef SQLITE_OMIT_DISKIO + iOmit |= ((sqlite_int64)1<<18); +#endif +#ifdef SQLITE_OMIT_EXPLAIN + iOmit |= ((sqlite_int64)1<<19); +#endif +#ifdef SQLITE_OMIT_FLAG_PRAGMAS + iOmit |= ((sqlite_int64)1<<20); +#endif +#ifdef SQLITE_OMIT_FLOATING_POINT + iOmit |= ((sqlite_int64)1<<21); +#endif +#ifdef SQLITE_OMIT_FOREIGN_KEY + iOmit |= ((sqlite_int64)1<<22); +#endif +#ifdef SQLITE_OMIT_GET_TABLE + iOmit |= ((sqlite_int64)1<<23); +#endif +#ifdef SQLITE_OMIT_GLOBALRECOVER + iOmit |= ((sqlite_int64)1<<24); +#endif +#ifdef SQLITE_OMIT_INCRBLOB + iOmit |= ((sqlite_int64)1<<25); +#endif +#ifdef SQLITE_OMIT_INTEGRITY_CHECK + iOmit |= ((sqlite_int64)1<<26); +#endif +#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<27); +#endif +#ifdef SQLITE_OMIT_LOAD_EXTENSION + iOmit |= ((sqlite_int64)1<<28); +#endif +#ifdef SQLITE_OMIT_LOCALTIME + iOmit |= ((sqlite_int64)1<<29); +#endif +#ifdef SQLITE_OMIT_LOOKASIDE + iOmit |= ((sqlite_int64)1<<30); +#endif +#ifdef SQLITE_OMIT_MEMORYDB + iOmit |= ((sqlite_int64)1<<31); +#endif +#ifdef SQLITE_OMIT_OR_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<32); +#endif +#ifdef SQLITE_OMIT_PAGER_PRAGMAS + iOmit |= ((sqlite_int64)1<<33); +#endif +#ifdef SQLITE_OMIT_PRAGMA + iOmit |= ((sqlite_int64)1<<34); +#endif +#ifdef SQLITE_OMIT_PROGRESS_CALLBACK + iOmit |= ((sqlite_int64)1<<35); +#endif +#ifdef SQLITE_OMIT_QUICKBALANCE + iOmit |= ((sqlite_int64)1<<36); +#endif +#ifdef SQLITE_OMIT_REINDEX + iOmit |= ((sqlite_int64)1<<37); +#endif +#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS + iOmit |= ((sqlite_int64)1<<38); +#endif +#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS + iOmit |= ((sqlite_int64)1<<39); +#endif +#ifdef SQLITE_OMIT_SHARED_CACHE + iOmit |= ((sqlite_int64)1<<40); +#endif +#ifdef SQLITE_OMIT_SUBQUERY + iOmit |= ((sqlite_int64)1<<41); +#endif +#ifdef SQLITE_OMIT_TCL_VARIABLE + iOmit |= ((sqlite_int64)1<<42); +#endif +#ifdef SQLITE_OMIT_TEMPDB + iOmit |= ((sqlite_int64)1<<43); +#endif +#ifdef SQLITE_OMIT_TRACE + iOmit |= ((sqlite_int64)1<<44); +#endif +#ifdef SQLITE_OMIT_TRIGGER + iOmit |= ((sqlite_int64)1<<45); +#endif +#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION + iOmit |= ((sqlite_int64)1<<46); +#endif +#ifdef SQLITE_OMIT_UTF16 + iOmit |= ((sqlite_int64)1<<47); +#endif +#ifdef SQLITE_OMIT_VACUUM + iOmit |= ((sqlite_int64)1<<48); +#endif +#ifdef SQLITE_OMIT_VIEW + iOmit |= ((sqlite_int64)1<<49); +#endif +#ifdef SQLITE_OMIT_VIRTUALTABLE + iOmit |= ((sqlite_int64)1<<50); +#endif +#ifdef SQLITE_OMIT_WSD + iOmit |= ((sqlite_int64)1<<51); +#endif +#ifdef SQLITE_OMIT_XFER_OPT + iOmit |= ((sqlite_int64)1<<52); +#endif +#ifdef SQLITE_PERFORMANCE_TRACE + iOther |= ((sqlite_int64)1<<24); +#endif +#ifdef SQLITE_PROXY_DEBUG + iOther |= ((sqlite_int64)1<<25); +#endif +#ifdef SQLITE_SECURE_DELETE + iOther |= ((sqlite_int64)1<<26); +#endif +#ifdef SQLITE_SMALL_STACK + iOther |= ((sqlite_int64)1<<27); +#endif +#ifdef SQLITE_SOUNDEX + iOther |= ((sqlite_int64)1<<28); +#endif +#ifdef SQLITE_TCL + iOther |= ((sqlite_int64)1<<29); +#endif +#ifdef SQLITE_TEST + iOther |= ((sqlite_int64)1<<30); +#endif +#ifdef SQLITE_USE_ALLOCA + iOther |= ((sqlite_int64)1<<31); +#endif +#ifdef SQLITE_ZERO_MALLOC + iOther |= ((sqlite_int64)1<<32); +#endif sqlite3_snprintf(sizeof(zOpts)-1, zOpts, "%016llx%016llx%016llx", iEnable, iOmit, iOther); From 440ac39bc05282fdaef8cc8d386f9eba17f31ff6 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Feb 2010 10:56:15 +0000 Subject: [PATCH 21/50] Fix a segfault that can occur if a malloc fails in ATTACH in shared-cache mode. FossilOrigin-Name: 875f8fa32708b8dbf314fd7056fac2fefdacfa36 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/attach.c | 6 +++++- test/attachmalloc.test | 13 +++++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6e5969c25e..55720089d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Removed\schecking\sof\ssome\scompile\soptions\sfrom\sthe\ssqlite3_compileopts()\sAPI. -D 2010-02-23T05:17:52 +C Fix\sa\ssegfault\sthat\scan\soccur\sif\sa\smalloc\sfails\sin\sATTACH\sin\sshared-cache\smode. +D 2010-02-23T10:56:16 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -104,7 +104,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05 F src/analyze.c 55155f05ee9ab4ce33b7a4d19c449053f8935200 -F src/attach.c f6d33268019460724e4c57aeec543eaaa55d8310 +F src/attach.c 01fd6ce19ee1567fea8d647eaec7486588756d8f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 @@ -240,7 +240,7 @@ F test/async5.test f3592d79c84d6e83a5f50d3fd500445f7d97dfdf F test/attach.test ce9660e51768fab93cf129787be886c5d6c4fd81 F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437 F test/attach3.test bd9830bc3a0d22ed1310c9bff6896927937017dc -F test/attachmalloc.test cf8cf17d183de357b1147a9baacbdfc85b940b61 +F test/attachmalloc.test 38d2da5fdaf09ba0add57296967a3061e5842584 F test/auth.test 8f21c160a4562f54f27618e85bac869efcecbcaf F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882 F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5 @@ -791,7 +791,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 84c9756993caf82710a0905ed1987d144bc764fd -R f5089208430b2ba4dd4063929e4e20e6 -U shaneh -Z 9884f73578eca45685b3905c76fc5c0d +P 833da702ff9bd99d62640756d80e094256efff5c +R 266d27e76a2b37d15f5a03e24c556a22 +U dan +Z 060e5b129e7fc7dc7958eb9fd3924fd7 diff --git a/manifest.uuid b/manifest.uuid index 519435ec1f..2887d00aa7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -833da702ff9bd99d62640756d80e094256efff5c \ No newline at end of file +875f8fa32708b8dbf314fd7056fac2fefdacfa36 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index f4b9428c0f..b9a5bee695 100644 --- a/src/attach.c +++ b/src/attach.c @@ -147,8 +147,12 @@ static void attachFunc( sqlite3BtreeSecureDelete(aNew->pBt, sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) ); } - aNew->zName = sqlite3DbStrDup(db, zName); aNew->safety_level = 3; + aNew->zName = sqlite3DbStrDup(db, zName); + if( rc==SQLITE_OK && aNew->zName==0 ){ + rc = SQLITE_NOMEM; + } + #ifdef SQLITE_HAS_CODEC if( rc==SQLITE_OK ){ diff --git a/test/attachmalloc.test b/test/attachmalloc.test index 30841cea76..cc506bee6a 100644 --- a/test/attachmalloc.test +++ b/test/attachmalloc.test @@ -60,4 +60,17 @@ do_malloc_test attachmalloc-2 -tclprep { ATTACH 'test2.db' AS db1; } +set enable_shared_cache [sqlite3_enable_shared_cache 1] +sqlite3 dbaux test2.db +dbaux eval {SELECT * FROM sqlite_master} +do_malloc_test attachmalloc-3 -sqlbody { + SELECT * FROM sqlite_master; + ATTACH 'test2.db' AS two; +} -cleanup { + db eval { DETACH two } +} +dbaux close +sqlite3_enable_shared_cache $enable_shared_cache + + finish_test From 9978c97ec5d480741365687534690f04bc8cc6e4 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Feb 2010 17:36:32 +0000 Subject: [PATCH 22/50] Remove the obsolete sqlite3SafetyOn() mechanism. Add additional logging output for CORRUPT, and CANTOPEN errors. FossilOrigin-Name: 7c4cca6d1a23a6d1591b62f58c3716a944969947 --- manifest | 51 +++-- manifest.uuid | 2 +- src/analyze.c | 6 - src/attach.c | 2 - src/btree.c | 4 +- src/complete.c | 566 +++++++++++++++++++++++------------------------ src/main.c | 29 ++- src/os_unix.c | 10 +- src/os_win.c | 4 +- src/pager.c | 4 +- src/prepare.c | 15 -- src/sqliteInt.h | 29 +-- src/util.c | 65 +----- src/vdbe.c | 34 +-- src/vdbeapi.c | 8 - src/vdbeaux.c | 9 +- src/vdbeblob.c | 13 +- src/vtab.c | 22 +- src/where.c | 2 - test/safety.test | 93 -------- 20 files changed, 358 insertions(+), 610 deletions(-) delete mode 100644 test/safety.test diff --git a/manifest b/manifest index c851c5f870..5d0e427ccc 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sthe\s".log"\scommand\sto\sthe\sshell.\s\sThis\sshows\sthat\ssome\serrors\sare\slogged\nmultiple\stimes\sand\sother\serrors\sare\snever\slogged\sat\sall. -D 2010-02-23T01:47:00 +C Remove\sthe\sobsolete\ssqlite3SafetyOn()\smechanism.\s\sAdd\sadditional\slogging\noutput\sfor\sCORRUPT,\sand\sCANTOPEN\serrors. +D 2010-02-23T17:36:33 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -106,18 +106,18 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05 -F src/analyze.c 55155f05ee9ab4ce33b7a4d19c449053f8935200 -F src/attach.c f6d33268019460724e4c57aeec543eaaa55d8310 +F src/analyze.c 92a65a5a402898a52b03695c7f0cd383724d711f +F src/attach.c d855b36c7ebe31643bb64b8f2a4f799599f57f97 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c b7ac4420d10662259ad3421145eab16a279f5bd3 +F src/btree.c ae804d16fb1ed8d3a0087b0fba2dcf37f312275c F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 254a273acb8923f3bdecc933d787f4f67737c489 F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f -F src/complete.c 4c8a742c4a4a6d9c835912648f5c8f032ea36c7b +F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/date.c 485a4409a384310e6d93fd1104a9d0a8658becd9 F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581 F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 @@ -133,7 +133,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c 36c1c11ee2677ae247e0c947f9293749ee5ac85f +F src/main.c fb31256305eb419c9d9ab3092cce4e8c6a065610 F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 @@ -152,16 +152,16 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306 F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30 F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f -F src/os_unix.c 0af0a55e2dd55bc4f4c3ccf04cc8f1f4a2e2e65f -F src/os_win.c 5ffab20249a61e0625f869efe157fa009747039b -F src/pager.c d0e53cd301c82d3b67ee69c7b900b56e5b17070d +F src/os_unix.c 13b5d1ffc04cc420ff9fab2938d0093e62a327bf +F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053 +F src/pager.c ace73a84f53a551fb8b9334205af210a29874b2c F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54 F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 F src/pragma.c 5febf8b5d88cc331effb3f2e14d0473488649b1e -F src/prepare.c d4cd38ccfb51f1424d0e61d4878a810b7e1ebb60 +F src/prepare.c bd9e778f46d2cff460b5f238a3cc13ee0ffe1300 F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b @@ -170,7 +170,7 @@ F src/select.c 0109b993c360d649857523abb72919e1794f9b45 F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 F src/sqlite.h.in 16f33c1ceb971bfa7a04a73039947630f445146e F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 -F src/sqliteInt.h d5fe1c8335b5bf376639837fa42124327cdb6767 +F src/sqliteInt.h 32e6eb47d2f6fad587e16b0abbbfe3f7d55f2ec0 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 F src/status.c e651be6b30d397d86384c6867bc016e4913bcac7 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -211,19 +211,19 @@ F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 -F src/util.c 5b5353ff9427422b0bb89a5bc8ddf818399c0401 +F src/util.c 32a7a4ce395b818b5659ff9c1fc7eff09932ccad F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de -F src/vdbe.c 428411c6fbd49e9a4ce043dad87a0b079d403714 +F src/vdbe.c b0769a0751cdf7eb52311ef94d44f379ea103a72 F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e -F src/vdbeapi.c a8b6a6617fc9a0492e4f7d6626d3afe994ddd3f2 -F src/vdbeaux.c 8f30e619a8077ee516fa1494fa603550fa951726 -F src/vdbeblob.c 84f924700a7a889152aeebef77ca5f4e3875ffb4 +F src/vdbeapi.c c1432e2aaa97e918901a55186199e23aa9047805 +F src/vdbeaux.c 417ee0c5677188b3b72a0ccdda5668183e28bb51 +F src/vdbeblob.c 94d4715bb782b91ef183c999a4b81f4dd5494ab5 F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 -F src/vtab.c 7c7713d66cda699f16bf1cc601d8d4f5070ab935 +F src/vtab.c 08df673f3341a0376037f795afbeb669d30d30a2 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 1041ef1174ad36679d078188510f56f2801737a5 +F src/where.c 9269ec75e1e36e69748fd918ac5a636020c85e7e F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -543,7 +543,6 @@ F test/rollback.test 73355ad4492ff9a3a31e61c7e5eb5e01a1de94ca F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287 F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9 -F test/safety.test b69e2b2dd5d52a3f78e216967086884bbc1a09c6 F test/savepoint.test f2ede4b643ad87ead36c041c72d774a1f5c8a564 F test/savepoint2.test 427c8b20f43d3edf17a290c6788ae9e2703ac51c F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec @@ -794,14 +793,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P c4401fc93b66c5339422d7e765a4a32b1ef96bdb -R 1b44bf57e7d9a663688d30603c70b44c +P 6d910245ad0097521cf1619449cc3d202137b8b8 +R 4a55fdf9e3eb291dfcc82c0590d9deb7 U drh -Z 75784795cda6fd26f0b8feb0805d2536 +Z 26147ac467d0ee1674ecf48b84753d80 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLgzOYoxKgR168RlERAgluAJ9q3mIeRrQvfpzpmiNDDWtRun1WrQCeME9w -x+Fdmmhc/ksLrbX58/ixhCk= -=d2xc +iD8DBQFLhBIkoxKgR168RlERAl/sAJ9uSxPewxWPXcY00iSJJIp+Q1yjKQCcCt45 +2X5N2P2VUOeqI8eEiWATH4s= +=TuL6 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index f774487e26..df5d34d5d0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d910245ad0097521cf1619449cc3d202137b8b8 \ No newline at end of file +7c4cca6d1a23a6d1591b62f58c3716a944969947 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 2e2e1d896c..283a0e9d1e 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -559,9 +559,7 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ if( zSql==0 ){ rc = SQLITE_NOMEM; }else{ - (void)sqlite3SafetyOff(db); rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); - (void)sqlite3SafetyOn(db); sqlite3DbFree(db, zSql); } @@ -579,14 +577,11 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ if( !zSql ){ rc = SQLITE_NOMEM; }else{ - (void)sqlite3SafetyOff(db); rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); - (void)sqlite3SafetyOn(db); sqlite3DbFree(db, zSql); } if( rc==SQLITE_OK ){ - (void)sqlite3SafetyOff(db); while( sqlite3_step(pStmt)==SQLITE_ROW ){ char *zIndex = (char *)sqlite3_column_text(pStmt, 0); Index *pIdx = sqlite3FindIndex(db, zIndex, sInfo.zDatabase); @@ -636,7 +631,6 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ } } rc = sqlite3_finalize(pStmt); - (void)sqlite3SafetyOn(db); } } #endif diff --git a/src/attach.c b/src/attach.c index f4b9428c0f..5b934de143 100644 --- a/src/attach.c +++ b/src/attach.c @@ -186,11 +186,9 @@ static void attachFunc( ** we found it. */ if( rc==SQLITE_OK ){ - (void)sqlite3SafetyOn(db); sqlite3BtreeEnterAll(db); rc = sqlite3Init(db, &zErrDyn); sqlite3BtreeLeaveAll(db); - (void)sqlite3SafetyOff(db); } if( rc ){ int iDb = db->nDb - 1; diff --git a/src/btree.c b/src/btree.c index 7754f3a213..3d0e313f7a 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5919,7 +5919,7 @@ static int balance_nonroot( if( leafData ){ i--; } subtotal = 0; k++; - if( k>NB+1 ){ rc = SQLITE_CORRUPT; goto balance_cleanup; } + if( k>NB+1 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; } } } szNew[k] = subtotal; @@ -5973,7 +5973,7 @@ static int balance_nonroot( ** Allocate k new pages. Reuse old pages where possible. */ if( apOld[0]->pgno<=1 ){ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; } pageFlags = apOld[0]->aData[0]; diff --git a/src/complete.c b/src/complete.c index 9799a6ae30..9e9140085c 100644 --- a/src/complete.c +++ b/src/complete.c @@ -1,283 +1,283 @@ -/* -** 2001 September 15 -** -** 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. -** -************************************************************************* -** An tokenizer for SQL -** -** This file contains C code that implements the sqlite3_complete() API. -** This code used to be part of the tokenizer.c source file. But by -** separating it out, the code will be automatically omitted from -** static links that do not use it. -*/ -#include "sqliteInt.h" -#ifndef SQLITE_OMIT_COMPLETE - -/* -** This is defined in tokenize.c. We just have to import the definition. -*/ -#ifndef SQLITE_AMALGAMATION -#ifdef SQLITE_ASCII -#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) -#endif -#ifdef SQLITE_EBCDIC -extern const char sqlite3IsEbcdicIdChar[]; -#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) -#endif -#endif /* SQLITE_AMALGAMATION */ - - -/* -** Token types used by the sqlite3_complete() routine. See the header -** comments on that procedure for additional information. -*/ -#define tkSEMI 0 -#define tkWS 1 -#define tkOTHER 2 -#ifndef SQLITE_OMIT_TRIGGER -#define tkEXPLAIN 3 -#define tkCREATE 4 -#define tkTEMP 5 -#define tkTRIGGER 6 -#define tkEND 7 -#endif - -/* -** Return TRUE if the given SQL string ends in a semicolon. -** -** Special handling is require for CREATE TRIGGER statements. -** Whenever the CREATE TRIGGER keywords are seen, the statement -** must end with ";END;". -** -** This implementation uses a state machine with 8 states: -** -** (0) INVALID We have not yet seen a non-whitespace character. -** -** (1) START At the beginning or end of an SQL statement. This routine -** returns 1 if it ends in the START state and 0 if it ends -** in any other state. -** -** (2) NORMAL We are in the middle of statement which ends with a single -** semicolon. -** -** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of -** a statement. -** -** (4) CREATE The keyword CREATE has been seen at the beginning of a -** statement, possibly preceeded by EXPLAIN and/or followed by -** TEMP or TEMPORARY -** -** (5) TRIGGER We are in the middle of a trigger definition that must be -** ended by a semicolon, the keyword END, and another semicolon. -** -** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at -** the end of a trigger definition. -** -** (7) END We've seen the ";END" of the ";END;" that occurs at the end -** of a trigger difinition. -** -** Transitions between states above are determined by tokens extracted -** from the input. The following tokens are significant: -** -** (0) tkSEMI A semicolon. -** (1) tkWS Whitespace. -** (2) tkOTHER Any other SQL token. -** (3) tkEXPLAIN The "explain" keyword. -** (4) tkCREATE The "create" keyword. -** (5) tkTEMP The "temp" or "temporary" keyword. -** (6) tkTRIGGER The "trigger" keyword. -** (7) tkEND The "end" keyword. -** -** Whitespace never causes a state transition and is always ignored. -** This means that a SQL string of all whitespace is invalid. -** -** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed -** to recognize the end of a trigger can be omitted. All we have to do -** is look for a semicolon that is not part of an string or comment. -*/ -int sqlite3_complete(const char *zSql){ - u8 state = 0; /* Current state, using numbers defined in header comment */ - u8 token; /* Value of the next token */ - -#ifndef SQLITE_OMIT_TRIGGER - /* A complex statement machine used to detect the end of a CREATE TRIGGER - ** statement. This is the normal case. - */ - static const u8 trans[8][8] = { - /* Token: */ - /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */ - /* 0 INVALID: */ { 1, 0, 2, 3, 4, 2, 2, 2, }, - /* 1 START: */ { 1, 1, 2, 3, 4, 2, 2, 2, }, - /* 2 NORMAL: */ { 1, 2, 2, 2, 2, 2, 2, 2, }, - /* 3 EXPLAIN: */ { 1, 3, 3, 2, 4, 2, 2, 2, }, - /* 4 CREATE: */ { 1, 4, 2, 2, 2, 4, 5, 2, }, - /* 5 TRIGGER: */ { 6, 5, 5, 5, 5, 5, 5, 5, }, - /* 6 SEMI: */ { 6, 6, 5, 5, 5, 5, 5, 7, }, - /* 7 END: */ { 1, 7, 5, 5, 5, 5, 5, 5, }, - }; -#else - /* If triggers are not supported by this compile then the statement machine - ** used to detect the end of a statement is much simplier - */ - static const u8 trans[3][3] = { - /* Token: */ - /* State: ** SEMI WS OTHER */ - /* 0 INVALID: */ { 1, 0, 2, }, - /* 1 START: */ { 1, 1, 2, }, - /* 2 NORMAL: */ { 1, 2, 2, }, - }; -#endif /* SQLITE_OMIT_TRIGGER */ - - while( *zSql ){ - switch( *zSql ){ - case ';': { /* A semicolon */ - token = tkSEMI; - break; - } - case ' ': - case '\r': - case '\t': - case '\n': - case '\f': { /* White space is ignored */ - token = tkWS; - break; - } - case '/': { /* C-style comments */ - if( zSql[1]!='*' ){ - token = tkOTHER; - break; - } - zSql += 2; - while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; } - if( zSql[0]==0 ) return 0; - zSql++; - token = tkWS; - break; - } - case '-': { /* SQL-style comments from "--" to end of line */ - if( zSql[1]!='-' ){ - token = tkOTHER; - break; - } - while( *zSql && *zSql!='\n' ){ zSql++; } - if( *zSql==0 ) return state==1; - token = tkWS; - break; - } - case '[': { /* Microsoft-style identifiers in [...] */ - zSql++; - while( *zSql && *zSql!=']' ){ zSql++; } - if( *zSql==0 ) return 0; - token = tkOTHER; - break; - } - case '`': /* Grave-accent quoted symbols used by MySQL */ - case '"': /* single- and double-quoted strings */ - case '\'': { - int c = *zSql; - zSql++; - while( *zSql && *zSql!=c ){ zSql++; } - if( *zSql==0 ) return 0; - token = tkOTHER; - break; - } - default: { -#ifdef SQLITE_EBCDIC - unsigned char c; -#endif - if( IdChar((u8)*zSql) ){ - /* Keywords and unquoted identifiers */ - int nId; - for(nId=1; IdChar(zSql[nId]); nId++){} -#ifdef SQLITE_OMIT_TRIGGER - token = tkOTHER; -#else - switch( *zSql ){ - case 'c': case 'C': { - if( nId==6 && sqlite3StrNICmp(zSql, "create", 6)==0 ){ - token = tkCREATE; - }else{ - token = tkOTHER; - } - break; - } - case 't': case 'T': { - if( nId==7 && sqlite3StrNICmp(zSql, "trigger", 7)==0 ){ - token = tkTRIGGER; - }else if( nId==4 && sqlite3StrNICmp(zSql, "temp", 4)==0 ){ - token = tkTEMP; - }else if( nId==9 && sqlite3StrNICmp(zSql, "temporary", 9)==0 ){ - token = tkTEMP; - }else{ - token = tkOTHER; - } - break; - } - case 'e': case 'E': { - if( nId==3 && sqlite3StrNICmp(zSql, "end", 3)==0 ){ - token = tkEND; - }else -#ifndef SQLITE_OMIT_EXPLAIN - if( nId==7 && sqlite3StrNICmp(zSql, "explain", 7)==0 ){ - token = tkEXPLAIN; - }else -#endif - { - token = tkOTHER; - } - break; - } - default: { - token = tkOTHER; - break; - } - } -#endif /* SQLITE_OMIT_TRIGGER */ - zSql += nId-1; - }else{ - /* Operators and special symbols */ - token = tkOTHER; - } - break; - } - } - state = trans[state][token]; - zSql++; - } - return state==1; -} - -#ifndef SQLITE_OMIT_UTF16 -/* -** This routine is the same as the sqlite3_complete() routine described -** above, except that the parameter is required to be UTF-16 encoded, not -** UTF-8. -*/ -int sqlite3_complete16(const void *zSql){ - sqlite3_value *pVal; - char const *zSql8; - int rc = SQLITE_NOMEM; - -#ifndef SQLITE_OMIT_AUTOINIT - rc = sqlite3_initialize(); - if( rc ) return rc; -#endif - pVal = sqlite3ValueNew(0); - sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC); - zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8); - if( zSql8 ){ - rc = sqlite3_complete(zSql8); - }else{ - rc = SQLITE_NOMEM; - } - sqlite3ValueFree(pVal); - return sqlite3ApiExit(0, rc); -} -#endif /* SQLITE_OMIT_UTF16 */ -#endif /* SQLITE_OMIT_COMPLETE */ +/* +** 2001 September 15 +** +** 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. +** +************************************************************************* +** An tokenizer for SQL +** +** This file contains C code that implements the sqlite3_complete() API. +** This code used to be part of the tokenizer.c source file. But by +** separating it out, the code will be automatically omitted from +** static links that do not use it. +*/ +#include "sqliteInt.h" +#ifndef SQLITE_OMIT_COMPLETE + +/* +** This is defined in tokenize.c. We just have to import the definition. +*/ +#ifndef SQLITE_AMALGAMATION +#ifdef SQLITE_ASCII +#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0) +#endif +#ifdef SQLITE_EBCDIC +extern const char sqlite3IsEbcdicIdChar[]; +#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40])) +#endif +#endif /* SQLITE_AMALGAMATION */ + + +/* +** Token types used by the sqlite3_complete() routine. See the header +** comments on that procedure for additional information. +*/ +#define tkSEMI 0 +#define tkWS 1 +#define tkOTHER 2 +#ifndef SQLITE_OMIT_TRIGGER +#define tkEXPLAIN 3 +#define tkCREATE 4 +#define tkTEMP 5 +#define tkTRIGGER 6 +#define tkEND 7 +#endif + +/* +** Return TRUE if the given SQL string ends in a semicolon. +** +** Special handling is require for CREATE TRIGGER statements. +** Whenever the CREATE TRIGGER keywords are seen, the statement +** must end with ";END;". +** +** This implementation uses a state machine with 8 states: +** +** (0) INVALID We have not yet seen a non-whitespace character. +** +** (1) START At the beginning or end of an SQL statement. This routine +** returns 1 if it ends in the START state and 0 if it ends +** in any other state. +** +** (2) NORMAL We are in the middle of statement which ends with a single +** semicolon. +** +** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of +** a statement. +** +** (4) CREATE The keyword CREATE has been seen at the beginning of a +** statement, possibly preceeded by EXPLAIN and/or followed by +** TEMP or TEMPORARY +** +** (5) TRIGGER We are in the middle of a trigger definition that must be +** ended by a semicolon, the keyword END, and another semicolon. +** +** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at +** the end of a trigger definition. +** +** (7) END We've seen the ";END" of the ";END;" that occurs at the end +** of a trigger difinition. +** +** Transitions between states above are determined by tokens extracted +** from the input. The following tokens are significant: +** +** (0) tkSEMI A semicolon. +** (1) tkWS Whitespace. +** (2) tkOTHER Any other SQL token. +** (3) tkEXPLAIN The "explain" keyword. +** (4) tkCREATE The "create" keyword. +** (5) tkTEMP The "temp" or "temporary" keyword. +** (6) tkTRIGGER The "trigger" keyword. +** (7) tkEND The "end" keyword. +** +** Whitespace never causes a state transition and is always ignored. +** This means that a SQL string of all whitespace is invalid. +** +** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed +** to recognize the end of a trigger can be omitted. All we have to do +** is look for a semicolon that is not part of an string or comment. +*/ +int sqlite3_complete(const char *zSql){ + u8 state = 0; /* Current state, using numbers defined in header comment */ + u8 token; /* Value of the next token */ + +#ifndef SQLITE_OMIT_TRIGGER + /* A complex statement machine used to detect the end of a CREATE TRIGGER + ** statement. This is the normal case. + */ + static const u8 trans[8][8] = { + /* Token: */ + /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */ + /* 0 INVALID: */ { 1, 0, 2, 3, 4, 2, 2, 2, }, + /* 1 START: */ { 1, 1, 2, 3, 4, 2, 2, 2, }, + /* 2 NORMAL: */ { 1, 2, 2, 2, 2, 2, 2, 2, }, + /* 3 EXPLAIN: */ { 1, 3, 3, 2, 4, 2, 2, 2, }, + /* 4 CREATE: */ { 1, 4, 2, 2, 2, 4, 5, 2, }, + /* 5 TRIGGER: */ { 6, 5, 5, 5, 5, 5, 5, 5, }, + /* 6 SEMI: */ { 6, 6, 5, 5, 5, 5, 5, 7, }, + /* 7 END: */ { 1, 7, 5, 5, 5, 5, 5, 5, }, + }; +#else + /* If triggers are not supported by this compile then the statement machine + ** used to detect the end of a statement is much simplier + */ + static const u8 trans[3][3] = { + /* Token: */ + /* State: ** SEMI WS OTHER */ + /* 0 INVALID: */ { 1, 0, 2, }, + /* 1 START: */ { 1, 1, 2, }, + /* 2 NORMAL: */ { 1, 2, 2, }, + }; +#endif /* SQLITE_OMIT_TRIGGER */ + + while( *zSql ){ + switch( *zSql ){ + case ';': { /* A semicolon */ + token = tkSEMI; + break; + } + case ' ': + case '\r': + case '\t': + case '\n': + case '\f': { /* White space is ignored */ + token = tkWS; + break; + } + case '/': { /* C-style comments */ + if( zSql[1]!='*' ){ + token = tkOTHER; + break; + } + zSql += 2; + while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; } + if( zSql[0]==0 ) return 0; + zSql++; + token = tkWS; + break; + } + case '-': { /* SQL-style comments from "--" to end of line */ + if( zSql[1]!='-' ){ + token = tkOTHER; + break; + } + while( *zSql && *zSql!='\n' ){ zSql++; } + if( *zSql==0 ) return state==1; + token = tkWS; + break; + } + case '[': { /* Microsoft-style identifiers in [...] */ + zSql++; + while( *zSql && *zSql!=']' ){ zSql++; } + if( *zSql==0 ) return 0; + token = tkOTHER; + break; + } + case '`': /* Grave-accent quoted symbols used by MySQL */ + case '"': /* single- and double-quoted strings */ + case '\'': { + int c = *zSql; + zSql++; + while( *zSql && *zSql!=c ){ zSql++; } + if( *zSql==0 ) return 0; + token = tkOTHER; + break; + } + default: { +#ifdef SQLITE_EBCDIC + unsigned char c; +#endif + if( IdChar((u8)*zSql) ){ + /* Keywords and unquoted identifiers */ + int nId; + for(nId=1; IdChar(zSql[nId]); nId++){} +#ifdef SQLITE_OMIT_TRIGGER + token = tkOTHER; +#else + switch( *zSql ){ + case 'c': case 'C': { + if( nId==6 && sqlite3StrNICmp(zSql, "create", 6)==0 ){ + token = tkCREATE; + }else{ + token = tkOTHER; + } + break; + } + case 't': case 'T': { + if( nId==7 && sqlite3StrNICmp(zSql, "trigger", 7)==0 ){ + token = tkTRIGGER; + }else if( nId==4 && sqlite3StrNICmp(zSql, "temp", 4)==0 ){ + token = tkTEMP; + }else if( nId==9 && sqlite3StrNICmp(zSql, "temporary", 9)==0 ){ + token = tkTEMP; + }else{ + token = tkOTHER; + } + break; + } + case 'e': case 'E': { + if( nId==3 && sqlite3StrNICmp(zSql, "end", 3)==0 ){ + token = tkEND; + }else +#ifndef SQLITE_OMIT_EXPLAIN + if( nId==7 && sqlite3StrNICmp(zSql, "explain", 7)==0 ){ + token = tkEXPLAIN; + }else +#endif + { + token = tkOTHER; + } + break; + } + default: { + token = tkOTHER; + break; + } + } +#endif /* SQLITE_OMIT_TRIGGER */ + zSql += nId-1; + }else{ + /* Operators and special symbols */ + token = tkOTHER; + } + break; + } + } + state = trans[state][token]; + zSql++; + } + return state==1; +} + +#ifndef SQLITE_OMIT_UTF16 +/* +** This routine is the same as the sqlite3_complete() routine described +** above, except that the parameter is required to be UTF-16 encoded, not +** UTF-8. +*/ +int sqlite3_complete16(const void *zSql){ + sqlite3_value *pVal; + char const *zSql8; + int rc = SQLITE_NOMEM; + +#ifndef SQLITE_OMIT_AUTOINIT + rc = sqlite3_initialize(); + if( rc ) return rc; +#endif + pVal = sqlite3ValueNew(0); + sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC); + zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8); + if( zSql8 ){ + rc = sqlite3_complete(zSql8); + }else{ + rc = SQLITE_NOMEM; + } + sqlite3ValueFree(pVal); + return sqlite3ApiExit(0, rc); +} +#endif /* SQLITE_OMIT_UTF16 */ +#endif /* SQLITE_OMIT_COMPLETE */ diff --git a/src/main.c b/src/main.c index e4419d269d..348ddb5656 100644 --- a/src/main.c +++ b/src/main.c @@ -1939,16 +1939,31 @@ int sqlite3_get_autocommit(sqlite3 *db){ return db->autoCommit; } -#ifdef SQLITE_DEBUG /* -** The following routine is subtituted for constant SQLITE_CORRUPT in -** debugging builds. This provides a way to set a breakpoint for when -** corruption is first detected. +** The following routines are subtitutes for constants SQLITE_CORRUPT, +** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error +** constants. They server two purposes: +** +** 1. Serve as a convenient place to set a breakpoint in a debugger +** to detect when version error conditions occurs. +** +** 2. Invoke sqlite3_log() to provide the source code location where +** a low-level error is first detected. */ -int sqlite3Corrupt(void){ +int sqlite3CorruptError(int lineno){ + sqlite3_log(SQLITE_CORRUPT, + "database corruption found by source line %d", lineno); return SQLITE_CORRUPT; } -#endif +int sqlite3MisuseError(int lineno){ + sqlite3_log(SQLITE_MISUSE, "misuse detected by source line %d", lineno); + return SQLITE_MISUSE; +} +int sqlite3CantopenError(int lineno){ + sqlite3_log(SQLITE_CANTOPEN, "cannot open file at source line %d", lineno); + return SQLITE_CANTOPEN; +} + #ifndef SQLITE_OMIT_DEPRECATED /* @@ -1992,7 +2007,6 @@ int sqlite3_table_column_metadata( /* Ensure the database schema has been loaded */ sqlite3_mutex_enter(db->mutex); - (void)sqlite3SafetyOn(db); sqlite3BtreeEnterAll(db); rc = sqlite3Init(db, &zErrMsg); if( SQLITE_OK!=rc ){ @@ -2051,7 +2065,6 @@ int sqlite3_table_column_metadata( error_out: sqlite3BtreeLeaveAll(db); - (void)sqlite3SafetyOff(db); /* Whether the function call succeeded or failed, set the output parameters ** to whatever their local counterparts contain. If an error did occur, diff --git a/src/os_unix.c b/src/os_unix.c index fd64cb06e3..80c966b56d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3867,7 +3867,7 @@ static int openDirectory(const char *zFilename, int *pFd){ } } *pFd = fd; - return (fd>=0?SQLITE_OK:SQLITE_CANTOPEN); + return (fd>=0?SQLITE_OK:SQLITE_CANTOPEN_BKPT); } /* @@ -4130,7 +4130,7 @@ static int unixOpen( fd = open(zName, openFlags, openMode); } if( fd<0 ){ - rc = SQLITE_CANTOPEN; + rc = SQLITE_CANTOPEN_BKPT; goto open_finished; } } @@ -4354,7 +4354,7 @@ static int unixFullPathname( }else{ int nCwd; if( getcwd(zOut, nOut-1)==0 ){ - return SQLITE_CANTOPEN; + return SQLITE_CANTOPEN_BKPT; } nCwd = (int)strlen(zOut); sqlite3_snprintf(nOut-nCwd, &zOut[nCwd], "/%s", zPath); @@ -4865,7 +4865,7 @@ static int proxyCreateUnixFile( case EIO: return SQLITE_IOERR_LOCK; /* even though it is the conch */ default: - return SQLITE_CANTOPEN; + return SQLITE_CANTOPEN_BKPT; } } @@ -5249,7 +5249,7 @@ static int proxyTakeConch(unixFile *pFile){ if( fd>=0 ){ pFile->h = fd; }else{ - rc=SQLITE_CANTOPEN; /* SQLITE_BUSY? proxyTakeConch called + rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called during locking */ } } diff --git a/src/os_win.c b/src/os_win.c index bd23a848d3..4721eadff8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1417,7 +1417,7 @@ static int winOpen( return winOpen(pVfs, zName, id, ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags); }else{ - return SQLITE_CANTOPEN; + return SQLITE_CANTOPEN_BKPT; } } if( pOutFlags ){ @@ -1439,7 +1439,7 @@ static int winOpen( ){ CloseHandle(h); free(zConverted); - return SQLITE_CANTOPEN; + return SQLITE_CANTOPEN_BKPT; } if( isTemp ){ pFile->zDeleteOnClose = zConverted; diff --git a/src/pager.c b/src/pager.c index b5c7fe4945..97a6a8e6eb 100644 --- a/src/pager.c +++ b/src/pager.c @@ -3162,7 +3162,7 @@ int sqlite3PagerOpen( ** as it will not be possible to open the journal file or even ** check for a hot-journal before reading. */ - rc = SQLITE_CANTOPEN; + rc = SQLITE_CANTOPEN_BKPT; } if( rc!=SQLITE_OK ){ sqlite3_free(zPathname); @@ -3621,7 +3621,7 @@ int sqlite3PagerSharedLock(Pager *pPager){ rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout); assert( rc!=SQLITE_OK || isOpen(pPager->jfd) ); if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){ - rc = SQLITE_CANTOPEN; + rc = SQLITE_CANTOPEN_BKPT; sqlite3OsClose(pPager->jfd); } }else{ diff --git a/src/prepare.c b/src/prepare.c index 15aafbeadb..2bb1ff6902 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -192,9 +192,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ initData.iDb = iDb; initData.rc = SQLITE_OK; initData.pzErrMsg = pzErrMsg; - (void)sqlite3SafetyOff(db); sqlite3InitCallback(&initData, 3, (char **)azArg, 0); - (void)sqlite3SafetyOn(db); if( initData.rc ){ rc = initData.rc; goto error_out; @@ -317,7 +315,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ zSql = sqlite3MPrintf(db, "SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid", db->aDb[iDb].zName, zMasterName); - (void)sqlite3SafetyOff(db); #ifndef SQLITE_OMIT_AUTHORIZATION { int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); @@ -330,7 +327,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ } #endif if( rc==SQLITE_OK ) rc = initData.rc; - (void)sqlite3SafetyOn(db); sqlite3DbFree(db, zSql); #ifndef SQLITE_OMIT_ANALYZE if( rc==SQLITE_OK ){ @@ -539,11 +535,6 @@ static int sqlite3Prepare( goto end_prepare; } pParse->pReprepare = pReprepare; - - if( sqlite3SafetyOn(db) ){ - rc = SQLITE_MISUSE; - goto end_prepare; - } assert( ppStmt && *ppStmt==0 ); assert( !db->mallocFailed ); assert( sqlite3_mutex_held(db->mutex) ); @@ -579,7 +570,6 @@ static int sqlite3Prepare( if( rc ){ const char *zDb = db->aDb[i].zName; sqlite3Error(db, rc, "database schema is locked: %s", zDb); - (void)sqlite3SafetyOff(db); testcase( db->flags & SQLITE_ReadUncommitted ); goto end_prepare; } @@ -596,7 +586,6 @@ static int sqlite3Prepare( testcase( nBytes==mxLen+1 ); if( nBytes>mxLen ){ sqlite3Error(db, SQLITE_TOOBIG, "statement too long"); - (void)sqlite3SafetyOff(db); rc = sqlite3ApiExit(db, SQLITE_TOOBIG); goto end_prepare; } @@ -653,10 +642,6 @@ static int sqlite3Prepare( } #endif - if( sqlite3SafetyOff(db) ){ - rc = SQLITE_MISUSE; - } - assert( db->init.busy==0 || saveSqlFlag==0 ); if( db->init.busy==0 ){ Vdbe *pVdbe = pParse->pVdbe; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4e79cea5fd..c14c3c4cb0 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2414,17 +2414,19 @@ int sqlite3WalkSelectFrom(Walker*, Select*); } /* -** The SQLITE_CORRUPT_BKPT macro can be either a constant (for production -** builds) or a function call (for debugging). If it is a function call, -** it allows the operator to set a breakpoint at the spot where database -** corruption is first detected. +** The SQLITE_*_BKPT macros are substitutes for the error codes with +** the same name but without the _BKPT suffix. These macros invoke +** routines that report the line-number on which the error originated +** using sqlite3_log(). The routines also provide a convenient place +** to set a debugger breakpoint. */ -#ifdef SQLITE_DEBUG - int sqlite3Corrupt(void); -# define SQLITE_CORRUPT_BKPT sqlite3Corrupt() -#else -# define SQLITE_CORRUPT_BKPT SQLITE_CORRUPT -#endif +int sqlite3CorruptError(int); +int sqlite3MisuseError(int); +int sqlite3CantopenError(int); +#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__) +#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__) +#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__) + /* ** FTS4 is really an extension for FTS3. It is enabled using the @@ -2724,13 +2726,6 @@ FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); void sqlite3RegisterBuiltinFunctions(sqlite3*); void sqlite3RegisterDateTimeFunctions(void); void sqlite3RegisterGlobalFunctions(void); -#ifdef SQLITE_DEBUG - int sqlite3SafetyOn(sqlite3*); - int sqlite3SafetyOff(sqlite3*); -#else -# define sqlite3SafetyOn(A) 0 -# define sqlite3SafetyOff(A) 0 -#endif int sqlite3SafetyCheckOk(sqlite3*); int sqlite3SafetyCheckSickOrOk(sqlite3*); void sqlite3ChangeCookie(Parse*, int); diff --git a/src/util.c b/src/util.c index c173b4f9cf..813ef6e62c 100644 --- a/src/util.c +++ b/src/util.c @@ -123,7 +123,6 @@ void sqlite3Error(sqlite3 *db, int err_code, const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); - sqlite3_log(err_code, "%s", z); sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC); }else{ sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC); @@ -1012,64 +1011,6 @@ void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){ #endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */ -/* -** Change the sqlite.magic from SQLITE_MAGIC_OPEN to SQLITE_MAGIC_BUSY. -** Return an error (non-zero) if the magic was not SQLITE_MAGIC_OPEN -** when this routine is called. -** -** This routine is called when entering an SQLite API. The SQLITE_MAGIC_OPEN -** value indicates that the database connection passed into the API is -** open and is not being used by another thread. By changing the value -** to SQLITE_MAGIC_BUSY we indicate that the connection is in use. -** sqlite3SafetyOff() below will change the value back to SQLITE_MAGIC_OPEN -** when the API exits. -** -** This routine is a attempt to detect if two threads use the -** same sqlite* pointer at the same time. There is a race -** condition so it is possible that the error is not detected. -** But usually the problem will be seen. The result will be an -** error which can be used to debug the application that is -** using SQLite incorrectly. -** -** Ticket #202: If db->magic is not a valid open value, take care not -** to modify the db structure at all. It could be that db is a stale -** pointer. In other words, it could be that there has been a prior -** call to sqlite3_close(db) and db has been deallocated. And we do -** not want to write into deallocated memory. -*/ -#ifdef SQLITE_DEBUG -int sqlite3SafetyOn(sqlite3 *db){ - if( db->magic==SQLITE_MAGIC_OPEN ){ - db->magic = SQLITE_MAGIC_BUSY; - assert( sqlite3_mutex_held(db->mutex) ); - return 0; - }else if( db->magic==SQLITE_MAGIC_BUSY ){ - db->magic = SQLITE_MAGIC_ERROR; - db->u1.isInterrupted = 1; - } - return 1; -} -#endif - -/* -** Change the magic from SQLITE_MAGIC_BUSY to SQLITE_MAGIC_OPEN. -** Return an error (non-zero) if the magic was not SQLITE_MAGIC_BUSY -** when this routine is called. -*/ -#ifdef SQLITE_DEBUG -int sqlite3SafetyOff(sqlite3 *db){ - if( db->magic==SQLITE_MAGIC_BUSY ){ - db->magic = SQLITE_MAGIC_OPEN; - assert( sqlite3_mutex_held(db->mutex) ); - return 0; - }else{ - db->magic = SQLITE_MAGIC_ERROR; - db->u1.isInterrupted = 1; - return 1; - } -} -#endif - /* ** Check to make sure we have a valid db pointer. This test is not ** foolproof but it does provide some measure of protection against @@ -1088,11 +1029,7 @@ int sqlite3SafetyCheckOk(sqlite3 *db){ u32 magic; if( db==0 ) return 0; magic = db->magic; - if( magic!=SQLITE_MAGIC_OPEN -#ifdef SQLITE_DEBUG - && magic!=SQLITE_MAGIC_BUSY -#endif - ){ + if( magic!=SQLITE_MAGIC_OPEN ){ return 0; }else{ return 1; diff --git a/src/vdbe.c b/src/vdbe.c index df73c46290..74bd919865 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -563,7 +563,6 @@ int sqlite3VdbeExec( /*** INSERT STACK UNION HERE ***/ assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */ - assert( db->magic==SQLITE_MAGIC_BUSY ); sqlite3VdbeMutexArrayEnter(p); if( p->rc==SQLITE_NOMEM ){ /* This happens if a malloc() inside a call to sqlite3_column_text() or @@ -648,9 +647,7 @@ int sqlite3VdbeExec( if( checkProgress ){ if( db->nProgressOps==nProgressOps ){ int prc; - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; - prc =db->xProgress(db->pProgressArg); - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; + prc = db->xProgress(db->pProgressArg); if( prc!=0 ){ rc = SQLITE_INTERRUPT; goto vdbe_error_halt; @@ -1400,21 +1397,12 @@ case OP_Function: { assert( pOp[-1].opcode==OP_CollSeq ); ctx.pColl = pOp[-1].p4.pColl; } - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; (*ctx.pFunc->xFunc)(&ctx, n, apVal); - if( sqlite3SafetyOn(db) ){ - sqlite3VdbeMemRelease(&ctx.s); - goto abort_due_to_misuse; - } if( db->mallocFailed ){ /* Even though a malloc() has failed, the implementation of the ** user function may have called an sqlite3_result_XXX() function ** to return a value. The following call releases any resources ** associated with such a value. - ** - ** Note: Maybe MemRelease() should be called if sqlite3SafetyOn() - ** fails also (the if(...) statement above). But if people are - ** misusing sqlite, they have bigger problems than a leaked value. */ sqlite3VdbeMemRelease(&ctx.s); goto no_mem; @@ -4049,12 +4037,10 @@ case OP_Rowid: { /* out2-prerelease */ pVtab = pC->pVtabCursor->pVtab; pModule = pVtab->pModule; assert( pModule->xRowid ); - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xRowid(pC->pVtabCursor, &v); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; #endif /* SQLITE_OMIT_VIRTUALTABLE */ }else{ assert( pC->pCursor!=0 ); @@ -4590,7 +4576,6 @@ case OP_ParseSchema: { if( zSql==0 ){ rc = SQLITE_NOMEM; }else{ - (void)sqlite3SafetyOff(db); assert( db->init.busy==0 ); db->init.busy = 1; initData.rc = SQLITE_OK; @@ -4599,7 +4584,6 @@ case OP_ParseSchema: { if( rc==SQLITE_OK ) rc = initData.rc; sqlite3DbFree(db, zSql); db->init.busy = 0; - (void)sqlite3SafetyOn(db); } } sqlite3BtreeLeaveAll(db); @@ -5169,9 +5153,7 @@ case OP_AggFinal: { ** a transaction. */ case OP_Vacuum: { - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = sqlite3RunVacuum(&p->zErrMsg, db); - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; break; } #endif @@ -5315,12 +5297,10 @@ case OP_VOpen: { pVtab = pOp->p4.pVtab->pVtab; pModule = (sqlite3_module *)pVtab->pModule; assert(pVtab && pModule); - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xOpen(pVtab, &pVtabCursor); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( SQLITE_OK==rc ){ /* Initialize sqlite3_vtab_cursor base class */ pVtabCursor->pVtab = pVtab; @@ -5394,7 +5374,6 @@ case OP_VFilter: { /* jump */ sqlite3VdbeMemStoreType(apArg[i]); } - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; p->inVtabMethod = 1; rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg); p->inVtabMethod = 0; @@ -5404,7 +5383,6 @@ case OP_VFilter: { /* jump */ if( rc==SQLITE_OK ){ res = pModule->xEof(pVtabCursor); } - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( res ){ pc = pOp->p2 - 1; @@ -5450,7 +5428,6 @@ case OP_VColumn: { sqlite3VdbeMemMove(&sContext.s, pDest); MemSetTypeFlag(&sContext.s, MEM_Null); - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xColumn(pCur->pVtabCursor, &sContext, pOp->p2); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; @@ -5468,9 +5445,6 @@ case OP_VColumn: { REGISTER_TRACE(pOp->p3, pDest); UPDATE_MAX_BLOBSIZE(pDest); - if( sqlite3SafetyOn(db) ){ - goto abort_due_to_misuse; - } if( sqlite3VdbeMemTooBig(pDest) ){ goto too_big; } @@ -5507,7 +5481,6 @@ case OP_VNext: { /* jump */ ** data is available) and the error code returned when xColumn or ** some other method is next invoked on the save virtual table cursor. */ - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; p->inVtabMethod = 1; rc = pModule->xNext(pCur->pVtabCursor); p->inVtabMethod = 0; @@ -5517,7 +5490,6 @@ case OP_VNext: { /* jump */ if( rc==SQLITE_OK ){ res = pModule->xEof(pCur->pVtabCursor); } - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( !res ){ /* If there is data, jump to P2 */ @@ -5543,12 +5515,10 @@ case OP_VRename: { assert( pVtab->pModule->xRename ); REGISTER_TRACE(pOp->p1, pName); assert( pName->flags & MEM_Str ); - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pVtab->pModule->xRename(pVtab, pName->z); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; break; } @@ -5599,12 +5569,10 @@ case OP_VUpdate: { apArg[i] = pX; pX++; } - if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; - if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( rc==SQLITE_OK && pOp->p1 ){ assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) ); db->lastRowid = rowid; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 964c620e3c..242d428e02 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -316,10 +316,6 @@ static int sqlite3Step(Vdbe *p){ rc = SQLITE_ERROR; goto end_of_step; } - if( sqlite3SafetyOn(db) ){ - p->rc = SQLITE_MISUSE; - return SQLITE_MISUSE; - } if( p->pc<0 ){ /* If there are no other statements currently running, then ** reset the interrupt flag. This prevents a call to sqlite3_interrupt @@ -352,10 +348,6 @@ static int sqlite3Step(Vdbe *p){ rc = sqlite3VdbeExec(p); } - if( sqlite3SafetyOff(db) ){ - rc = SQLITE_MISUSE; - } - #ifndef SQLITE_OMIT_TRACE /* Invoke the profile callback if there is one */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index c8cf4af854..98b8bf1980 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1059,7 +1059,6 @@ int sqlite3VdbeList( assert( p->explain ); assert( p->magic==VDBE_MAGIC_RUN ); - assert( db->magic==SQLITE_MAGIC_BUSY ); assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); /* Even though this opcode does not use dynamic strings for @@ -1474,9 +1473,7 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor; const sqlite3_module *pModule = pCx->pModule; p->inVtabMethod = 1; - (void)sqlite3SafetyOff(p->db); pModule->xClose(pVtabCursor); - (void)sqlite3SafetyOn(p->db); p->inVtabMethod = 0; } #endif @@ -1657,9 +1654,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){ /* If there are any write-transactions at all, invoke the commit hook */ if( needXcommit && db->xCommitCallback ){ - (void)sqlite3SafetyOff(db); rc = db->xCommitCallback(db->pCommitArg); - (void)sqlite3SafetyOn(db); if( rc ){ return SQLITE_CONSTRAINT; } @@ -2213,9 +2208,7 @@ int sqlite3VdbeReset(Vdbe *p){ ** error, then it might not have been halted properly. So halt ** it now. */ - (void)sqlite3SafetyOn(db); sqlite3VdbeHalt(p); - (void)sqlite3SafetyOff(db); /* If the VDBE has be run even partially, then transfer the error code ** and error message from the VDBE into the main database structure. But @@ -3017,7 +3010,7 @@ int sqlite3VdbeIdxKeyCompare( ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ if( nCellKey<=0 || nCellKey>0x7fffffff ){ *res = 0; - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_BKPT; } memset(&m, 0, sizeof(m)); rc = sqlite3VdbeMemFromBtree(pC->pCursor, 0, (int)nCellKey, 1, &m); diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 6a6c6a71fc..2871f1ad1a 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -95,13 +95,6 @@ int sqlite3_blob_open( memset(pParse, 0, sizeof(Parse)); pParse->db = db; - if( sqlite3SafetyOn(db) ){ - sqlite3DbFree(db, zErr); - sqlite3StackFree(db, pParse); - sqlite3_mutex_leave(db->mutex); - return SQLITE_MISUSE; - } - sqlite3BtreeEnterAll(db); pTab = sqlite3LocateTable(pParse, 0, zTable, zDb); if( pTab && IsVirtual(pTab) ){ @@ -121,7 +114,6 @@ int sqlite3_blob_open( pParse->zErrMsg = 0; } rc = SQLITE_ERROR; - (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } @@ -136,7 +128,6 @@ int sqlite3_blob_open( sqlite3DbFree(db, zErr); zErr = sqlite3MPrintf(db, "no such column: \"%s\"", zColumn); rc = SQLITE_ERROR; - (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } @@ -177,7 +168,6 @@ int sqlite3_blob_open( sqlite3DbFree(db, zErr); zErr = sqlite3MPrintf(db, "cannot open %s column for writing", zFault); rc = SQLITE_ERROR; - (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } @@ -227,8 +217,7 @@ int sqlite3_blob_open( } sqlite3BtreeLeaveAll(db); - rc = sqlite3SafetyOff(db); - if( NEVER(rc!=SQLITE_OK) || db->mallocFailed ){ + if( db->mallocFailed ){ goto blob_open_out; } diff --git a/src/vtab.c b/src/vtab.c index d0bc22dcee..bd1c16a987 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -123,16 +123,7 @@ void sqlite3VtabUnlock(VTable *pVTab){ if( pVTab->nRef==0 ){ sqlite3_vtab *p = pVTab->pVtab; if( p ){ -#ifdef SQLITE_DEBUG - if( pVTab->db->magic==SQLITE_MAGIC_BUSY ){ - (void)sqlite3SafetyOff(db); - p->pModule->xDisconnect(p); - (void)sqlite3SafetyOn(db); - } else -#endif - { - p->pModule->xDisconnect(p); - } + p->pModule->xDisconnect(p); } sqlite3DbFree(db, pVTab); } @@ -468,9 +459,7 @@ static int vtabCallConstructor( db->pVTab = pTab; /* Invoke the virtual table constructor */ - (void)sqlite3SafetyOff(db); rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr); - (void)sqlite3SafetyOn(db); if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; if( SQLITE_OK!=rc ){ @@ -717,10 +706,8 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){ if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){ VTable *p = vtabDisconnectAll(db, pTab); - rc = sqlite3SafetyOff(db); assert( rc==SQLITE_OK ); rc = p->pMod->pModule->xDestroy(p->pVtab); - (void)sqlite3SafetyOn(db); /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ if( rc==SQLITE_OK ){ @@ -772,10 +759,8 @@ static void callFinaliser(sqlite3 *db, int offset){ int sqlite3VtabSync(sqlite3 *db, char **pzErrmsg){ int i; int rc = SQLITE_OK; - int rcsafety; VTable **aVTrans = db->aVTrans; - rc = sqlite3SafetyOff(db); db->aVTrans = 0; for(i=0; rc==SQLITE_OK && inVTrans; i++){ int (*x)(sqlite3_vtab *); @@ -788,11 +773,6 @@ int sqlite3VtabSync(sqlite3 *db, char **pzErrmsg){ } } db->aVTrans = aVTrans; - rcsafety = sqlite3SafetyOn(db); - - if( rc==SQLITE_OK ){ - rc = rcsafety; - } return rc; } diff --git a/src/where.c b/src/where.c index 1e6fea87af..f27ce66928 100644 --- a/src/where.c +++ b/src/where.c @@ -1758,12 +1758,10 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){ int i; int rc; - (void)sqlite3SafetyOff(pParse->db); WHERETRACE(("xBestIndex for %s\n", pTab->zName)); TRACE_IDX_INPUTS(p); rc = pVtab->pModule->xBestIndex(pVtab, p); TRACE_IDX_OUTPUTS(p); - (void)sqlite3SafetyOn(pParse->db); if( rc!=SQLITE_OK ){ if( rc==SQLITE_NOMEM ){ diff --git a/test/safety.test b/test/safety.test deleted file mode 100644 index 9cca57c1c4..0000000000 --- a/test/safety.test +++ /dev/null @@ -1,93 +0,0 @@ -# 2005 January 11 -# -# 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 file is testing the sqlite3SafetyOn and sqlite3SafetyOff -# functions. Those routines are not strictly necessary - they are -# designed to detect misuse of the library. -# -# $Id: safety.test,v 1.4 2008/03/18 13:46:53 drh Exp $ - -set testdir [file dirname $argv0] -source $testdir/tester.tcl - -ifcapable !debug { - puts "Skipping safety tests since SQLITE_DEBUG is off" - finish_test - return -} - -# 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 -} - - -do_test safety-1.1 { - set DB [sqlite3_connection_pointer db] - db eval {CREATE TABLE t1(a)} - sqlite_set_magic $DB SQLITE_MAGIC_BUSY - catchsql { - SELECT name FROM sqlite_master; - } -} {1 {library routine called out of sequence}} -do_test safety-1.2 { - sqlite_set_magic $DB SQLITE_MAGIC_OPEN - catchsql { - SELECT name FROM sqlite_master - } -} {0 t1} - -do_test safety-2.1 { - proc safety_on {} "sqlite_set_magic $DB SQLITE_MAGIC_BUSY" - db function safety_on safety_on - catchsql { - SELECT safety_on(), name FROM sqlite_master - } -} {1 {library routine called out of sequence}} -ifcapable {utf16} { - do_test safety-2.1.1 { - utf8 [sqlite3_errmsg16 db] - } {library routine called out of sequence} -} -do_test safety-2.2 { - catchsql { - SELECT 'hello' - } -} {1 {library routine called out of sequence}} -do_test safety-2.3 { - sqlite3_close $DB -} {SQLITE_MISUSE} -do_test safety-2.4 { - sqlite_set_magic $DB SQLITE_MAGIC_OPEN - execsql { - SELECT name FROM sqlite_master - } -} {t1} - -do_test safety-3.1 { - set rc [catch { - db eval {SELECT name FROM sqlite_master} { - sqlite_set_magic $DB SQLITE_MAGIC_BUSY - } - } msg] - lappend rc $msg -} {1 {library routine called out of sequence}} -sqlite_set_magic $DB SQLITE_MAGIC_OPEN - -finish_test From 39547b418b5dcb64de22a39acf6a25ca4d79cacc Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Feb 2010 11:05:26 +0000 Subject: [PATCH 23/50] Fix a segfault that can occur if a malloc fails in ATTACH in shared-cache mode. FossilOrigin-Name: e37137376a2b23062e2625b5285299b33630b326 --- manifest | 26 ++++++++------------------ manifest.uuid | 2 +- src/attach.c | 6 +++++- test/attachmalloc.test | 13 +++++++++++++ 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 5d0e427ccc..1772d89b18 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Remove\sthe\sobsolete\ssqlite3SafetyOn()\smechanism.\s\sAdd\sadditional\slogging\noutput\sfor\sCORRUPT,\sand\sCANTOPEN\serrors. -D 2010-02-23T17:36:33 +C Fix\sa\ssegfault\sthat\scan\soccur\sif\sa\smalloc\sfails\sin\sATTACH\sin\sshared-cache\smode. +D 2010-02-23T11:05:26 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -107,7 +104,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05 F src/analyze.c 92a65a5a402898a52b03695c7f0cd383724d711f -F src/attach.c d855b36c7ebe31643bb64b8f2a4f799599f57f97 +F src/attach.c 7abe1607c2054585377cdba3c219e8572f84ca5e F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 @@ -243,7 +240,7 @@ F test/async5.test f3592d79c84d6e83a5f50d3fd500445f7d97dfdf F test/attach.test ce9660e51768fab93cf129787be886c5d6c4fd81 F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437 F test/attach3.test bd9830bc3a0d22ed1310c9bff6896927937017dc -F test/attachmalloc.test cf8cf17d183de357b1147a9baacbdfc85b940b61 +F test/attachmalloc.test 38d2da5fdaf09ba0add57296967a3061e5842584 F test/auth.test 8f21c160a4562f54f27618e85bac869efcecbcaf F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882 F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5 @@ -793,14 +790,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 6d910245ad0097521cf1619449cc3d202137b8b8 -R 4a55fdf9e3eb291dfcc82c0590d9deb7 -U drh -Z 26147ac467d0ee1674ecf48b84753d80 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLhBIkoxKgR168RlERAl/sAJ9uSxPewxWPXcY00iSJJIp+Q1yjKQCcCt45 -2X5N2P2VUOeqI8eEiWATH4s= -=TuL6 ------END PGP SIGNATURE----- +P 7c4cca6d1a23a6d1591b62f58c3716a944969947 +R 29083e92256fe9431ab529b4a073f35b +U dan +Z aeca5acb27017a622d1ae758ae6aaf7d diff --git a/manifest.uuid b/manifest.uuid index df5d34d5d0..50f37872cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c4cca6d1a23a6d1591b62f58c3716a944969947 \ No newline at end of file +e37137376a2b23062e2625b5285299b33630b326 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 5b934de143..6f0acef947 100644 --- a/src/attach.c +++ b/src/attach.c @@ -147,8 +147,12 @@ static void attachFunc( sqlite3BtreeSecureDelete(aNew->pBt, sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) ); } - aNew->zName = sqlite3DbStrDup(db, zName); aNew->safety_level = 3; + aNew->zName = sqlite3DbStrDup(db, zName); + if( rc==SQLITE_OK && aNew->zName==0 ){ + rc = SQLITE_NOMEM; + } + #ifdef SQLITE_HAS_CODEC if( rc==SQLITE_OK ){ diff --git a/test/attachmalloc.test b/test/attachmalloc.test index 30841cea76..cc506bee6a 100644 --- a/test/attachmalloc.test +++ b/test/attachmalloc.test @@ -60,4 +60,17 @@ do_malloc_test attachmalloc-2 -tclprep { ATTACH 'test2.db' AS db1; } +set enable_shared_cache [sqlite3_enable_shared_cache 1] +sqlite3 dbaux test2.db +dbaux eval {SELECT * FROM sqlite_master} +do_malloc_test attachmalloc-3 -sqlbody { + SELECT * FROM sqlite_master; + ATTACH 'test2.db' AS two; +} -cleanup { + db eval { DETACH two } +} +dbaux close +sqlite3_enable_shared_cache $enable_shared_cache + + finish_test From dc97a8cdc195a3f6e3786e3b7b25c7d9b6598bf6 Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 23 Feb 2010 20:08:35 +0000 Subject: [PATCH 24/50] Refactored compile time option diagnostic support to use strings identifiers instead of bitmask. FossilOrigin-Name: 76a0294ab4208a0858a13bab0858e1bc1448b651 --- Makefile.in | 5 + Makefile.vxworks | 3 +- main.mk | 1 + manifest | 29 ++-- manifest.uuid | 2 +- src/ctime.c | 368 ++++++++++++++++++++++++++++++++++++++++++++ src/func.c | 52 +++++-- src/main.c | 340 +--------------------------------------- src/pragma.c | 28 ++++ src/sqlite.h.in | 37 ++++- tool/mksqlite3c.tcl | 1 + 11 files changed, 500 insertions(+), 366 deletions(-) create mode 100644 src/ctime.c diff --git a/Makefile.in b/Makefile.in index 3bc5d8fda3..883da44de5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -204,6 +204,7 @@ SRC = \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ + $(TOP)/src/ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ @@ -339,6 +340,7 @@ TESTSRC2 = \ $(TOP)/src/btree.c \ $(TOP)/src/build.c \ $(TOP)/src/date.c \ + $(TOP)/src/ctime.c \ $(TOP)/src/expr.c \ $(TOP)/src/func.c \ $(TOP)/src/insert.c \ @@ -542,6 +544,9 @@ callback.lo: $(TOP)/src/callback.c $(HDR) complete.lo: $(TOP)/src/complete.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/complete.c +ctime.lo: $(TOP)/src/ctime.c $(HDR) + $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/ctime.c + date.lo: $(TOP)/src/date.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/date.c diff --git a/Makefile.vxworks b/Makefile.vxworks index 141b7061a5..273ce131d2 100644 --- a/Makefile.vxworks +++ b/Makefile.vxworks @@ -231,6 +231,7 @@ SRC = \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ + $(TOP)/src/ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ @@ -392,7 +393,7 @@ TESTSRC = \ TESTSRC2 = \ $(TOP)/src/attach.c $(TOP)/src/backup.c $(TOP)/src/btree.c \ - $(TOP)/src/build.c $(TOP)/src/date.c \ + $(TOP)/src/build.c $(TOP)/src/ctime.c $(TOP)/src/date.c \ $(TOP)/src/expr.c $(TOP)/src/func.c $(TOP)/src/insert.c $(TOP)/src/os.c \ $(TOP)/src/os_os2.c $(TOP)/src/os_unix.c $(TOP)/src/os_win.c \ $(TOP)/src/pager.c $(TOP)/src/pragma.c $(TOP)/src/prepare.c \ diff --git a/main.mk b/main.mk index 2e15cc421d..3d7ba0c866 100644 --- a/main.mk +++ b/main.mk @@ -86,6 +86,7 @@ SRC = \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ + $(TOP)/src/ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ diff --git a/manifest b/manifest index 55720089d3..1d8be4544e 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sa\ssegfault\sthat\scan\soccur\sif\sa\smalloc\sfails\sin\sATTACH\sin\sshared-cache\smode. -D 2010-02-23T10:56:16 +C Refactored\scompile\stime\soption\sdiagnostic\ssupport\sto\suse\sstrings\sidentifiers\sinstead\sof\sbitmask. +D 2010-02-23T20:08:36 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 -F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 +F Makefile.in df88fba41a6d14b79ab8cd9afa2cff8fa30f201e F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 -F Makefile.vxworks 10010ddbf52e2503c7c49c7c0b7c7a096f8638a6 +F Makefile.vxworks ab005d301296c40e021ccd0133ce49ca811e319f F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION 2f8d921ecf804e9eb01e836a09512d0318ebd4d3 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -89,7 +89,7 @@ F ext/rtree/tkt3363.test 2bf324f7908084a5f463de3109db9c6e607feb1b F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 93d7ab227d0110d996d0db430a9a27d42980c7be +F main.mk 37efe9fdc797e5d410d3b09f4ce3d8e469709c2e F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -115,12 +115,13 @@ F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 254a273acb8923f3bdecc933d787f4f67737c489 F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f F src/complete.c 4c8a742c4a4a6d9c835912648f5c8f032ea36c7b +F src/ctime.c 97598003ee7177fc34f1cc008a689b10708e8843 F src/date.c 485a4409a384310e6d93fd1104a9d0a8658becd9 F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581 F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0 -F src/func.c 8854b7a234b4272a78941fcc899c117d1839cd4e +F src/func.c 248e2e88e5b9ff38bbd18ab4e2899adf8dc7df15 F src/global.c 5a9c1e3c93213ca574786ac1caa976ce8f709105 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -130,7 +131,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c e75d96a0bd6f874a18d5dac855d330a4739de0b2 +F src/main.c 49c1133cd28dd45bb1b95c0000b786577ace2ee0 F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 @@ -157,7 +158,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 -F src/pragma.c 5febf8b5d88cc331effb3f2e14d0473488649b1e +F src/pragma.c 1ee3a5bea3e79bd4ad2519eb9745e1781bf443ea F src/prepare.c d4cd38ccfb51f1424d0e61d4878a810b7e1ebb60 F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -165,7 +166,7 @@ F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 0109b993c360d649857523abb72919e1794f9b45 F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 -F src/sqlite.h.in 451a5a8bb2f6183ac50ae65f45f6e2b8ef4c6439 +F src/sqlite.h.in d04ee7db03b3e7bc69581d2eed26ebf3d4d8177d F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h d5fe1c8335b5bf376639837fa42124327cdb6767 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 @@ -771,7 +772,7 @@ F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 -F tool/mksqlite3c.tcl 1da28229695fdebdfe8a7d19902ef6c76d6c1c2d +F tool/mksqlite3c.tcl e1245579315f821e83e06934e93732b4c60a0375 F tool/mksqlite3h.tcl eb100dce83f24b501b325b340f8b5eb8e5106b3b F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a @@ -791,7 +792,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 833da702ff9bd99d62640756d80e094256efff5c -R 266d27e76a2b37d15f5a03e24c556a22 -U dan -Z 060e5b129e7fc7dc7958eb9fd3924fd7 +P 875f8fa32708b8dbf314fd7056fac2fefdacfa36 +R cdc4eebebe40861bae38fc9e53a75e94 +U shaneh +Z a7385ef8c8d8c43ce8853ca9ce26557f diff --git a/manifest.uuid b/manifest.uuid index 2887d00aa7..3f6c58085c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -875f8fa32708b8dbf314fd7056fac2fefdacfa36 \ No newline at end of file +76a0294ab4208a0858a13bab0858e1bc1448b651 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c new file mode 100644 index 0000000000..88f581e88c --- /dev/null +++ b/src/ctime.c @@ -0,0 +1,368 @@ +/* +** 2010 February 23 +** +** 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 routines used to report what compile-time options +** SQLite was built with. +*/ + +#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS + +#include "sqliteInt.h" + +/* +** An array of names of all compile-time options. +** +** This array looks large, but in a typical installation actually uses +** only a handful of compile-time options, so most this array is usually +** rather short and uses little memory space. +*/ +static const char * const azCompileOpt[] = { +#ifdef SQLITE_32BIT_ROWID + "32BIT_ROWID", +#endif +#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC + "4_BYTE_ALIGNED_MALLOC", +#endif +#ifdef SQLITE_CASE_SENSITIVE_LIKE + "CASE_SENSITIVE_LIKE", +#endif +#ifdef SQLITE_CHECK_PAGES + "CHECK_PAGES", +#endif +#ifdef SQLITE_COVERAGE_TEST + "COVERAGE_TEST", +#endif +#ifdef SQLITE_DEBUG + "DEBUG", +#endif +#ifdef SQLITE_DISABLE_DIRSYNC + "DISABLE_DIRSYNC", +#endif +#ifdef SQLITE_DISABLE_LFS + "DISABLE_LFS", +#endif +#ifdef SQLITE_ENABLE_ATOMIC_WRITE + "ENABLE_ATOMIC_WRITE", +#endif +#ifdef SQLITE_ENABLE_CEROD + "ENABLE_CEROD", +#endif +#ifdef SQLITE_ENABLE_COLUMN_METADATA + "ENABLE_COLUMN_METADATA", +#endif +#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT + "ENABLE_EXPENSIVE_ASSERT", +#endif +#ifdef SQLITE_ENABLE_FTS1 + "ENABLE_FTS1", +#endif +#ifdef SQLITE_ENABLE_FTS2 + "ENABLE_FTS2", +#endif +#ifdef SQLITE_ENABLE_FTS3 + "ENABLE_FTS3", +#endif +#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS + "ENABLE_FTS3_PARENTHESIS", +#endif +#ifdef SQLITE_ENABLE_FTS4 + "ENABLE_FTS4", +#endif +#ifdef SQLITE_ENABLE_ICU + "ENABLE_ICU", +#endif +#ifdef SQLITE_ENABLE_IOTRACE + "ENABLE_IOTRACE", +#endif +#ifdef SQLITE_ENABLE_LOAD_EXTENSION + "ENABLE_LOAD_EXTENSION", +#endif +#ifdef SQLITE_ENABLE_LOCKING_STYLE + "ENABLE_LOCKING_STYLE", +#endif +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT + "ENABLE_MEMORY_MANAGEMENT", +#endif +#ifdef SQLITE_ENABLE_MEMSYS3 + "ENABLE_MEMSYS3", +#endif +#ifdef SQLITE_ENABLE_MEMSYS5 + "ENABLE_MEMSYS5", +#endif +#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK + "ENABLE_OVERSIZE_CELL_CHECK", +#endif +#ifdef SQLITE_ENABLE_RTREE + "ENABLE_RTREE", +#endif +#ifdef SQLITE_ENABLE_STAT2 + "ENABLE_STAT2", +#endif +#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY + "ENABLE_UNLOCK_NOTIFY", +#endif +#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT + "ENABLE_UPDATE_DELETE_LIMIT", +#endif +#ifdef SQLITE_HAS_CODEC + "HAS_CODEC", +#endif +#ifdef SQLITE_HAVE_ISNAN + "HAVE_ISNAN", +#endif +#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX + "HOMEGROWN_RECURSIVE_MUTEX", +#endif +#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS + "IGNORE_AFP_LOCK_ERRORS", +#endif +#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS + "IGNORE_FLOCK_LOCK_ERRORS", +#endif +#ifdef SQLITE_INT64_TYPE + "INT64_TYPE", +#endif +#ifdef SQLITE_LOCK_TRACE + "LOCK_TRACE", +#endif +#ifdef SQLITE_MEMDEBUG + "MEMDEBUG", +#endif +#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT + "MIXED_ENDIAN_64BIT_FLOAT", +#endif +#ifdef SQLITE_NO_SYNC + "NO_SYNC", +#endif +#ifdef SQLITE_OMIT_ALTERTABLE + "OMIT_ALTERTABLE", +#endif +#ifdef SQLITE_OMIT_ANALYZE + "OMIT_ANALYZE", +#endif +#ifdef SQLITE_OMIT_ATTACH + "OMIT_ATTACH", +#endif +#ifdef SQLITE_OMIT_AUTHORIZATION + "OMIT_AUTHORIZATION", +#endif +#ifdef SQLITE_OMIT_AUTOINCREMENT + "OMIT_AUTOINCREMENT", +#endif +#ifdef SQLITE_OMIT_AUTOINIT + "OMIT_AUTOINIT", +#endif +#ifdef SQLITE_OMIT_AUTOVACUUM + "OMIT_AUTOVACUUM", +#endif +#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION + "OMIT_BETWEEN_OPTIMIZATION", +#endif +#ifdef SQLITE_OMIT_BLOB_LITERAL + "OMIT_BLOB_LITERAL", +#endif +#ifdef SQLITE_OMIT_BTREECOUNT + "OMIT_BTREECOUNT", +#endif +#ifdef SQLITE_OMIT_BUILTIN_TEST + "OMIT_BUILTIN_TEST", +#endif +#ifdef SQLITE_OMIT_CAST + "OMIT_CAST", +#endif +#ifdef SQLITE_OMIT_CHECK + "OMIT_CHECK", +#endif +#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS + "OMIT_COMPILEOPTION_DIAGS", +#endif +#ifdef SQLITE_OMIT_COMPLETE + "OMIT_COMPLETE", +#endif +#ifdef SQLITE_OMIT_COMPOUND_SELECT + "OMIT_COMPOUND_SELECT", +#endif +#ifdef SQLITE_OMIT_DATETIME_FUNCS + "OMIT_DATETIME_FUNCS", +#endif +#ifdef SQLITE_OMIT_DECLTYPE + "OMIT_DECLTYPE", +#endif +#ifdef SQLITE_OMIT_DEPRECATED + "OMIT_DEPRECATED", +#endif +#ifdef SQLITE_OMIT_DISKIO + "OMIT_DISKIO", +#endif +#ifdef SQLITE_OMIT_EXPLAIN + "OMIT_EXPLAIN", +#endif +#ifdef SQLITE_OMIT_FLAG_PRAGMAS + "OMIT_FLAG_PRAGMAS", +#endif +#ifdef SQLITE_OMIT_FLOATING_POINT + "OMIT_FLOATING_POINT", +#endif +#ifdef SQLITE_OMIT_FOREIGN_KEY + "OMIT_FOREIGN_KEY", +#endif +#ifdef SQLITE_OMIT_GET_TABLE + "OMIT_GET_TABLE", +#endif +#ifdef SQLITE_OMIT_GLOBALRECOVER + "OMIT_GLOBALRECOVER", +#endif +#ifdef SQLITE_OMIT_INCRBLOB + "OMIT_INCRBLOB", +#endif +#ifdef SQLITE_OMIT_INTEGRITY_CHECK + "OMIT_INTEGRITY_CHECK", +#endif +#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION + "OMIT_LIKE_OPTIMIZATION", +#endif +#ifdef SQLITE_OMIT_LOAD_EXTENSION + "OMIT_LOAD_EXTENSION", +#endif +#ifdef SQLITE_OMIT_LOCALTIME + "OMIT_LOCALTIME", +#endif +#ifdef SQLITE_OMIT_LOOKASIDE + "OMIT_LOOKASIDE", +#endif +#ifdef SQLITE_OMIT_MEMORYDB + "OMIT_MEMORYDB", +#endif +#ifdef SQLITE_OMIT_OR_OPTIMIZATION + "OMIT_OR_OPTIMIZATION", +#endif +#ifdef SQLITE_OMIT_PAGER_PRAGMAS + "OMIT_PAGER_PRAGMAS", +#endif +#ifdef SQLITE_OMIT_PRAGMA + "OMIT_PRAGMA", +#endif +#ifdef SQLITE_OMIT_PROGRESS_CALLBACK + "OMIT_PROGRESS_CALLBACK", +#endif +#ifdef SQLITE_OMIT_QUICKBALANCE + "OMIT_QUICKBALANCE", +#endif +#ifdef SQLITE_OMIT_REINDEX + "OMIT_REINDEX", +#endif +#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS + "OMIT_SCHEMA_PRAGMAS", +#endif +#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS + "OMIT_SCHEMA_VERSION_PRAGMAS", +#endif +#ifdef SQLITE_OMIT_SHARED_CACHE + "OMIT_SHARED_CACHE", +#endif +#ifdef SQLITE_OMIT_SUBQUERY + "OMIT_SUBQUERY", +#endif +#ifdef SQLITE_OMIT_TCL_VARIABLE + "OMIT_TCL_VARIABLE", +#endif +#ifdef SQLITE_OMIT_TEMPDB + "OMIT_TEMPDB", +#endif +#ifdef SQLITE_OMIT_TRACE + "OMIT_TRACE", +#endif +#ifdef SQLITE_OMIT_TRIGGER + "OMIT_TRIGGER", +#endif +#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION + "OMIT_TRUNCATE_OPTIMIZATION", +#endif +#ifdef SQLITE_OMIT_UTF16 + "OMIT_UTF16", +#endif +#ifdef SQLITE_OMIT_VACUUM + "OMIT_VACUUM", +#endif +#ifdef SQLITE_OMIT_VIEW + "OMIT_VIEW", +#endif +#ifdef SQLITE_OMIT_VIRTUALTABLE + "OMIT_VIRTUALTABLE", +#endif +#ifdef SQLITE_OMIT_WSD + "OMIT_WSD", +#endif +#ifdef SQLITE_OMIT_XFER_OPT + "OMIT_XFER_OPT", +#endif +#ifdef SQLITE_PERFORMANCE_TRACE + "PERFORMANCE_TRACE", +#endif +#ifdef SQLITE_PROXY_DEBUG + "PROXY_DEBUG", +#endif +#ifdef SQLITE_SECURE_DELETE + "SECURE_DELETE", +#endif +#ifdef SQLITE_SMALL_STACK + "SMALL_STACK", +#endif +#ifdef SQLITE_SOUNDEX + "SOUNDEX", +#endif +#ifdef SQLITE_TCL + "TCL", +#endif +#ifdef SQLITE_TEST + "TEST", +#endif +#ifdef SQLITE_USE_ALLOCA + "USE_ALLOCA", +#endif +#ifdef SQLITE_ZERO_MALLOC + "ZERO_MALLOC", +#endif +}; + +/* +** Given the name of a compile-time option, return true if that option +** was used and false if not. +** +** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix +** is not required for a match. +*/ +int sqlite3_compileoption_used(const char *zOptName){ + int i, n; + if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7; + n = sqlite3Strlen30(zOptName); + + /* Since ArraySize(azCompileOpt) is normally in single digits, a + ** linear search is adequate. No need for a binary search. */ + for(i=0; i=0 && N) + ** + ** The first form returns a single row for each option that was + ** defined at compile time. The second form returns 0 or 1 + ** indicating whether the specified option was defined at + ** compile time. + */ + if( sqlite3StrICmp(zLeft, "compile_option")==0 && zRight ){ + int used = sqlite3_compileoption_used(zRight); + returnSingleInt(pParse, zRight, used); + }else + + if( sqlite3StrICmp(zLeft, "compile_options")==0 && !zRight ){ + int i = 0; + const char *zOpt; + sqlite3VdbeSetNumCols(v, 1); + pParse->nMem = 1; + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC); + while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){ + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } + }else +#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ + #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) /* ** Report the current state of file logs for all databases diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d7860a392d..153688eae7 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -108,7 +108,7 @@ extern "C" { /* ** CAPI3REF: Run-Time Library Version Numbers -** KEYWORDS: sqlite3_version +** KEYWORDS: sqlite3_version, sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros @@ -132,18 +132,41 @@ extern "C" { ** sqlite3_libversion_number() function returns an integer equal to ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns ** a pointer to a string constant whose value is the same as the -** [SQLITE_SOURCE_ID] C preprocessor macro. ^The sqlite3_compileopts() -** function returns a pointer to a string constant whose value describes -** the compiler options used. +** [SQLITE_SOURCE_ID] C preprocessor macro. ** -** See also: [sqlite_version()], [sqlite_source_id()], -** and [sqlite_compile_opts()]. +** See also: [sqlite_version()] and [sqlite_source_id()]. */ SQLITE_EXTERN const char sqlite3_version[]; const char *sqlite3_libversion(void); const char *sqlite3_sourceid(void); int sqlite3_libversion_number(void); -const char *sqlite3_compileopts(void); + +/* +** CAPI3REF: Run-Time Library Compilation Options Diagnostics +** KEYWORDS: sqlite3_compileoption_used, sqlite3_compileoption_get +** +** ^The sqlite3_compileoption_used() function returns 0 or 1 +** indicating whether the specified option was defined at +** compile time. ^The SQLITE_ prefix may be omitted from the +** option name passed to sqlite3_compileoption_used(). +** +** ^The sqlite3_compileoption_get() function allows interating +** over the list of options that were defined at compile time by +** returning the N-th compile time option string. ^If N is out of range, +** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ +** prefix is omitted from any strings returned by +** sqlite3_compileoption_get(). +** +** ^Support for the diagnostic functions sqlite3_compileoption_used() +** and sqlite3_compileoption_get() may be omitted by specifing the +** SQLITE_OMIT_COMPILEOPTION_DIAGS option at compile time. +** +** See also: [sqlite_compile_option_used()] and [sqlite_compile_option_get()]. +*/ +#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS +int sqlite3_compileoption_used(const char *zOptName); +const char * const sqlite3_compileoption_get(int N); +#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ /* ** CAPI3REF: Test To See If The Library Is Threadsafe diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index c14df4e8af..bda08bc4ab 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -266,6 +266,7 @@ foreach file { auth.c build.c callback.c + ctime.c delete.c func.c fkey.c From 413c3d36a27bd070034648c68673ad621e22312d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Feb 2010 20:11:56 +0000 Subject: [PATCH 25/50] Continuing improvements to error reporting and the sqlite3_log() routine. FossilOrigin-Name: edea3bb740ddd096a46e00678b59d465bb1e2903 --- manifest | 48 ++++++++++++++---------- manifest.uuid | 2 +- src/legacy.c | 2 +- src/main.c | 14 +++---- src/mem1.c | 30 +++++++++------ src/mem5.c | 5 ++- src/os_unix.c | 6 +-- src/prepare.c | 4 +- src/status.c | 2 +- src/tokenize.c | 1 + src/util.c | 28 ++++++++++++-- src/vdbe.c | 9 ++--- src/vdbeapi.c | 100 ++++++++++++++++++++++++++++++++----------------- src/vdbeblob.c | 2 +- src/vtab.c | 2 +- 15 files changed, 161 insertions(+), 94 deletions(-) diff --git a/manifest b/manifest index 1772d89b18..a87c0bdb3c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\ssegfault\sthat\scan\soccur\sif\sa\smalloc\sfails\sin\sATTACH\sin\sshared-cache\smode. -D 2010-02-23T11:05:26 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Continuing\simprovements\sto\serror\sreporting\sand\sthe\ssqlite3_log()\sroutine. +D 2010-02-23T20:11:57 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -127,16 +130,16 @@ F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 76d6b44a9f9050134fd81205f4b792cbdac7c925 F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c -F src/legacy.c 16f385490f377c2c80a6c7357391d499087defed +F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c fb31256305eb419c9d9ab3092cce4e8c6a065610 +F src/main.c d94ccec07c2c8fccdabe4e70515e6875638e11d1 F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 -F src/mem1.c 86f33483a343873bab8ae1b648c2eac55462da74 +F src/mem1.c 760dbac6ead11b901a8dcfa210f891b638a87507 F src/mem2.c 92b4f772b1ee7469e256f1c2eff0b51a0ba19460 F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3 -F src/mem5.c 4837b795ebdecc0cfe1522cd0c8b2c5d84ea490d +F src/mem5.c 7060e51b8dfe04c3d1e4297ccdbbba3a331c9673 F src/memjournal.c 5bfc2f33c914946e2f77ed3f882aff14dfc9355d F src/mutex.c 581a272e09098040ca3ef543cb5f3d643eff7d50 F src/mutex.h 6fde601e55fa6c3fae768783c439797ab84c87c6 @@ -149,7 +152,7 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306 F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30 F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f -F src/os_unix.c 13b5d1ffc04cc420ff9fab2938d0093e62a327bf +F src/os_unix.c 79f2b9aec313d3e168e52b3527578c22a251bc63 F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053 F src/pager.c ace73a84f53a551fb8b9334205af210a29874b2c F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54 @@ -158,7 +161,7 @@ F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 F src/pragma.c 5febf8b5d88cc331effb3f2e14d0473488649b1e -F src/prepare.c bd9e778f46d2cff460b5f238a3cc13ee0ffe1300 +F src/prepare.c 341413e4703df1f0430e595a78c33e722e6cb8d0 F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b @@ -169,7 +172,7 @@ F src/sqlite.h.in 16f33c1ceb971bfa7a04a73039947630f445146e F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h 32e6eb47d2f6fad587e16b0abbbfe3f7d55f2ec0 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 -F src/status.c e651be6b30d397d86384c6867bc016e4913bcac7 +F src/status.c d329385a2cba3ea49d9d68af0ad84b22d46b4f40 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c bad6570a005b234ea670b9f7b48256da19a032d3 F src/test1.c db4d8fd2849ab9aca0f27fd3773b8d68d078cf86 @@ -204,21 +207,21 @@ F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c 00fed80690ae7f1525483a35861511c48bc579f2 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 -F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d +F src/tokenize.c 25ceb0f0a746ea1d0f9553787f3f0a56853cfaeb F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 -F src/util.c 32a7a4ce395b818b5659ff9c1fc7eff09932ccad +F src/util.c 57256361d9794ae9b8c7d7d9df8ee239ba7f9b01 F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de -F src/vdbe.c b0769a0751cdf7eb52311ef94d44f379ea103a72 +F src/vdbe.c eb8b083191412e89292b864687f86afa28f4dc3f F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e -F src/vdbeapi.c c1432e2aaa97e918901a55186199e23aa9047805 +F src/vdbeapi.c e9a5abc45877b228925cc69d765df2dc134efb9f F src/vdbeaux.c 417ee0c5677188b3b72a0ccdda5668183e28bb51 -F src/vdbeblob.c 94d4715bb782b91ef183c999a4b81f4dd5494ab5 +F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 -F src/vtab.c 08df673f3341a0376037f795afbeb669d30d30a2 +F src/vtab.c 606adf51cd6d4ba51a8c6dccede06a6f7b0dd72d F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 9269ec75e1e36e69748fd918ac5a636020c85e7e F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -790,7 +793,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7c4cca6d1a23a6d1591b62f58c3716a944969947 -R 29083e92256fe9431ab529b4a073f35b -U dan -Z aeca5acb27017a622d1ae758ae6aaf7d +P e37137376a2b23062e2625b5285299b33630b326 +R ff1cb485ed704c1bce9db4fcbca8cdc6 +U drh +Z 168aca2978964e709184819b947f4e6a +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLhDaRoxKgR168RlERAv9oAJ0SA4nqkb1+S5qfHoZ3kSPAMZT2bgCfafXz +c0zqsF+MwQrPWlRJNCAoywk= +=o/6s +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 50f37872cb..5c4942327f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e37137376a2b23062e2625b5285299b33630b326 \ No newline at end of file +edea3bb740ddd096a46e00678b59d465bb1e2903 \ No newline at end of file diff --git a/src/legacy.c b/src/legacy.c index 871e15863c..ebab2de37d 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -41,7 +41,7 @@ int sqlite3_exec( int nRetry = 0; /* Number of retry attempts */ int callbackIsInit; /* True if callback data is initialized */ - if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE; + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; if( zSql==0 ) zSql = ""; sqlite3_mutex_enter(db->mutex); diff --git a/src/main.c b/src/main.c index 348ddb5656..f31c83267e 100644 --- a/src/main.c +++ b/src/main.c @@ -257,7 +257,7 @@ int sqlite3_config(int op, ...){ /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while ** the SQLite library is in use. */ - if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE; + if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE_BKPT; va_start(ap, op); switch( op ){ @@ -601,7 +601,7 @@ int sqlite3_close(sqlite3 *db){ return SQLITE_OK; } if( !sqlite3SafetyCheckSickOrOk(db) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } sqlite3_mutex_enter(db->mutex); @@ -948,7 +948,7 @@ int sqlite3CreateFunc( (!xFunc && (!xFinal && xStep)) || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) || (255<(nName = sqlite3Strlen30( zFunctionName))) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } #ifndef SQLITE_OMIT_UTF16 @@ -1279,7 +1279,7 @@ const char *sqlite3_errmsg(sqlite3 *db){ return sqlite3ErrStr(SQLITE_NOMEM); } if( !sqlite3SafetyCheckSickOrOk(db) ){ - return sqlite3ErrStr(SQLITE_MISUSE); + return sqlite3ErrStr(SQLITE_MISUSE_BKPT); } sqlite3_mutex_enter(db->mutex); if( db->mallocFailed ){ @@ -1348,7 +1348,7 @@ const void *sqlite3_errmsg16(sqlite3 *db){ */ int sqlite3_errcode(sqlite3 *db){ if( db && !sqlite3SafetyCheckSickOrOk(db) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } if( !db || db->mallocFailed ){ return SQLITE_NOMEM; @@ -1357,7 +1357,7 @@ int sqlite3_errcode(sqlite3 *db){ } int sqlite3_extended_errcode(sqlite3 *db){ if( db && !sqlite3SafetyCheckSickOrOk(db) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } if( !db || db->mallocFailed ){ return SQLITE_NOMEM; @@ -1395,7 +1395,7 @@ static int createCollation( enc2 = SQLITE_UTF16NATIVE; } if( enc2SQLITE_UTF16BE ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } /* Check if this call is removing or replacing an existing collation diff --git a/src/mem1.c b/src/mem1.c index 67dd474537..558eed8474 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -42,6 +42,8 @@ static void *sqlite3MemMalloc(int nByte){ if( p ){ p[0] = nByte; p++; + }else{ + sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); } return (void *)p; } @@ -61,6 +63,18 @@ static void sqlite3MemFree(void *pPrior){ free(p); } +/* +** Report the allocated size of a prior return from xMalloc() +** or xRealloc(). +*/ +static int sqlite3MemSize(void *pPrior){ + sqlite3_int64 *p; + if( pPrior==0 ) return 0; + p = (sqlite3_int64*)pPrior; + p--; + return (int)p[0]; +} + /* ** Like realloc(). Resize an allocation previously obtained from ** sqlite3MemMalloc(). @@ -80,22 +94,14 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){ if( p ){ p[0] = nByte; p++; + }else{ + sqlite3_log(SQLITE_NOMEM, + "failed memory resize %u to %u bytes", + sqlite3MemSize(pPrior), nByte); } return (void*)p; } -/* -** Report the allocated size of a prior return from xMalloc() -** or xRealloc(). -*/ -static int sqlite3MemSize(void *pPrior){ - sqlite3_int64 *p; - if( pPrior==0 ) return 0; - p = (sqlite3_int64*)pPrior; - p--; - return (int)p[0]; -} - /* ** Round up a request size to the next valid allocation size. */ diff --git a/src/mem5.c b/src/mem5.c index 3fe04e2455..feb1cb7e99 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -268,7 +268,10 @@ static void *memsys5MallocUnsafe(int nByte){ ** two in order to create a new free block of size iLogsize. */ for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){} - if( iBin>LOGMAX ) return 0; + if( iBin>LOGMAX ){ + sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte); + return 0; + } i = memsys5UnlinkFirst(iBin); while( iBin>iLogsize ){ int newSize; diff --git a/src/os_unix.c b/src/os_unix.c index 80c966b56d..1cce7dac10 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1111,7 +1111,7 @@ static int transferOwnership(unixFile *pFile){ } if( pFile->locktype!=NO_LOCK ){ /* We cannot change ownership while we are holding a lock! */ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } OSTRACE4("Transfer ownership of %d from %d to %d\n", pFile->h, pFile->tid, hSelf); @@ -1512,7 +1512,7 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){ return SQLITE_OK; } if( CHECK_THREADID(pFile) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } unixEnterMutex(); h = pFile->h; @@ -2735,7 +2735,7 @@ static int afpUnlock(sqlite3_file *id, int locktype) { return SQLITE_OK; } if( CHECK_THREADID(pFile) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } unixEnterMutex(); pLock = pFile->pLock; diff --git a/src/prepare.c b/src/prepare.c index 2bb1ff6902..c8cd6f6f62 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -689,7 +689,7 @@ static int sqlite3LockAndPrepare( assert( ppStmt!=0 ); *ppStmt = 0; if( !sqlite3SafetyCheckOk(db) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } sqlite3_mutex_enter(db->mutex); sqlite3BtreeEnterAll(db); @@ -797,7 +797,7 @@ static int sqlite3Prepare16( assert( ppStmt ); *ppStmt = 0; if( !sqlite3SafetyCheckOk(db) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } sqlite3_mutex_enter(db->mutex); zSql8 = sqlite3Utf16to8(db, zSql, nBytes); diff --git a/src/status.c b/src/status.c index 58a7e68c19..f4c77a9109 100644 --- a/src/status.c +++ b/src/status.c @@ -83,7 +83,7 @@ void sqlite3StatusSet(int op, int X){ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){ wsdStatInit; if( op<0 || op>=ArraySize(wsdStat.nowValue) ){ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } *pCurrent = wsdStat.nowValue[op]; *pHighwater = wsdStat.mxValue[op]; diff --git a/src/tokenize.c b/src/tokenize.c index a93eeaa781..4b40770d53 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -480,6 +480,7 @@ abort_parse: assert( pzErrMsg!=0 ); if( pParse->zErrMsg ){ *pzErrMsg = pParse->zErrMsg; + sqlite3_log(pParse->rc, "%s", *pzErrMsg); pParse->zErrMsg = 0; nErr++; } diff --git a/src/util.c b/src/util.c index 813ef6e62c..159da1eea6 100644 --- a/src/util.c +++ b/src/util.c @@ -161,7 +161,6 @@ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ sqlite3DbFree(db, pParse->zErrMsg); pParse->zErrMsg = zMsg; pParse->rc = SQLITE_ERROR; - sqlite3_log(SQLITE_ERROR, pParse->zErrMsg); } } @@ -1010,6 +1009,17 @@ void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){ } #endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */ +/* +** Log an error that is an API call on a connection pointer that should +** not have been used. The "type" of connection pointer is given as the +** argument. The zType is a word like "NULL" or "closed" or "invalid". +*/ +static void logBadConnection(const char *zType){ + sqlite3_log(SQLITE_MISUSE, + "API call with %s database connection pointer", + zType + ); +} /* ** Check to make sure we have a valid db pointer. This test is not @@ -1027,9 +1037,15 @@ void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){ */ int sqlite3SafetyCheckOk(sqlite3 *db){ u32 magic; - if( db==0 ) return 0; + if( db==0 ){ + logBadConnection("NULL"); + return 0; + } magic = db->magic; if( magic!=SQLITE_MAGIC_OPEN ){ + if( !sqlite3SafetyCheckSickOrOk(db) ){ + logBadConnection("unopened"); + } return 0; }else{ return 1; @@ -1040,6 +1056,10 @@ int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ magic = db->magic; if( magic!=SQLITE_MAGIC_SICK && magic!=SQLITE_MAGIC_OPEN && - magic!=SQLITE_MAGIC_BUSY ) return 0; - return 1; + magic!=SQLITE_MAGIC_BUSY ){ + logBadConnection( magic==SQLITE_MAGIC_CLOSED ? "closed" : "invalid" ); + return 0; + }else{ + return 1; + } } diff --git a/src/vdbe.c b/src/vdbe.c index 74bd919865..71fa635d09 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -847,7 +847,9 @@ case OP_Halt: { p->errorAction = (u8)pOp->p2; p->pc = pc; if( pOp->p4.z ){ + assert( p->rc!=SQLITE_OK ); sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z); + sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pc, p->zSql, pOp->p4.z); } rc = sqlite3VdbeHalt(p); assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); @@ -5697,6 +5699,7 @@ default: { /* This is really OP_Noop and OP_Explain */ vdbe_error_halt: assert( rc ); p->rc = rc; + sqlite3_log(rc, "prepared statement aborts at %d: [%s]", pc, p->zSql); sqlite3VdbeHalt(p); if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1; rc = SQLITE_ERROR; @@ -5725,12 +5728,6 @@ no_mem: rc = SQLITE_NOMEM; goto vdbe_error_halt; - /* Jump to here for an SQLITE_MISUSE error. - */ -abort_due_to_misuse: - rc = SQLITE_MISUSE; - /* Fall thru into abort_due_to_error */ - /* Jump to here for any other kind of fatal error. The "rc" variable ** should hold the error number. */ diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 242d428e02..060f272246 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -31,6 +31,28 @@ int sqlite3_expired(sqlite3_stmt *pStmt){ } #endif +/* +** Check on a Vdbe to make sure it has not been finalized. Log +** an error and return true if it has been finalized (or is otherwise +** invalid). Return false if it is ok. +*/ +static int vdbeSafety(Vdbe *p){ + if( p->db==0 ){ + sqlite3_log(SQLITE_MISUSE, "API called with finalized prepared statement"); + return 1; + }else{ + return 0; + } +} +static int vdbeSafetyNotNull(Vdbe *p){ + if( p==0 ){ + sqlite3_log(SQLITE_MISUSE, "API called with NULL prepared statement"); + return 1; + }else{ + return vdbeSafety(p); + } +} + /* ** The following routine destroys a virtual machine that is created by ** the sqlite3_compile() routine. The integer returned is an SQLITE_ @@ -50,7 +72,7 @@ int sqlite3_finalize(sqlite3_stmt *pStmt){ #if SQLITE_THREADSAFE sqlite3_mutex *mutex; #endif - if( db==0 ) return SQLITE_MISUSE; + if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT; #if SQLITE_THREADSAFE mutex = v->db->mutex; #endif @@ -299,7 +321,9 @@ static int sqlite3Step(Vdbe *p){ assert(p); if( p->magic!=VDBE_MAGIC_RUN ){ - return SQLITE_MISUSE; + sqlite3_log(SQLITE_MISUSE, + "attempt to step a halted statement: [%s]", p->zSql); + return SQLITE_MISUSE_BKPT; } /* Check that malloc() has not failed. If it has, return early. */ @@ -394,39 +418,41 @@ end_of_step: ** call sqlite3Reprepare() and try again. */ int sqlite3_step(sqlite3_stmt *pStmt){ - int rc = SQLITE_MISUSE; + int rc = SQLITE_OK; Vdbe *v = (Vdbe*)pStmt; - if( v && (v->db)!=0 ){ - int cnt = 0; - sqlite3 *db = v->db; - sqlite3_mutex_enter(db->mutex); - while( (rc = sqlite3Step(v))==SQLITE_SCHEMA - && cnt++ < 5 - && (rc = sqlite3Reprepare(v))==SQLITE_OK ){ - sqlite3_reset(pStmt); - v->expired = 0; - } - if( rc==SQLITE_SCHEMA && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ - /* This case occurs after failing to recompile an sql statement. - ** The error message from the SQL compiler has already been loaded - ** into the database handle. This block copies the error message - ** from the database handle into the statement and sets the statement - ** program counter to 0 to ensure that when the statement is - ** finalized or reset the parser error message is available via - ** sqlite3_errmsg() and sqlite3_errcode(). - */ - const char *zErr = (const char *)sqlite3_value_text(db->pErr); - sqlite3DbFree(db, v->zErrMsg); - if( !db->mallocFailed ){ - v->zErrMsg = sqlite3DbStrDup(db, zErr); - } else { - v->zErrMsg = 0; - v->rc = SQLITE_NOMEM; - } - } - rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(db->mutex); + int cnt = 0; + sqlite3 *db; + if( vdbeSafetyNotNull(v) ){ + return SQLITE_MISUSE_BKPT; } + db = v->db; + sqlite3_mutex_enter(db->mutex); + while( (rc = sqlite3Step(v))==SQLITE_SCHEMA + && cnt++ < 5 + && (rc = sqlite3Reprepare(v))==SQLITE_OK ){ + sqlite3_reset(pStmt); + v->expired = 0; + } + if( rc==SQLITE_SCHEMA && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ + /* This case occurs after failing to recompile an sql statement. + ** The error message from the SQL compiler has already been loaded + ** into the database handle. This block copies the error message + ** from the database handle into the statement and sets the statement + ** program counter to 0 to ensure that when the statement is + ** finalized or reset the parser error message is available via + ** sqlite3_errmsg() and sqlite3_errcode(). + */ + const char *zErr = (const char *)sqlite3_value_text(db->pErr); + sqlite3DbFree(db, v->zErrMsg); + if( !db->mallocFailed ){ + v->zErrMsg = sqlite3DbStrDup(db, zErr); + } else { + v->zErrMsg = 0; + v->rc = SQLITE_NOMEM; + } + } + rc = sqlite3ApiExit(db, rc); + sqlite3_mutex_leave(db->mutex); return rc; } @@ -896,12 +922,16 @@ const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){ */ static int vdbeUnbind(Vdbe *p, int i){ Mem *pVar; - if( p==0 ) return SQLITE_MISUSE; + if( vdbeSafetyNotNull(p) ){ + return SQLITE_MISUSE_BKPT; + } sqlite3_mutex_enter(p->db->mutex); if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){ sqlite3Error(p->db, SQLITE_MISUSE, 0); sqlite3_mutex_leave(p->db->mutex); - return SQLITE_MISUSE; + sqlite3_log(SQLITE_MISUSE, + "bind on a busy prepared statement: [%s]", p->zSql); + return SQLITE_MISUSE_BKPT; } if( i<1 || i>p->nVar ){ sqlite3Error(p->db, SQLITE_RANGE, 0); diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 2871f1ad1a..829b6de6dd 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -318,7 +318,7 @@ static int blobReadWrite( Vdbe *v; sqlite3 *db; - if( p==0 ) return SQLITE_MISUSE; + if( p==0 ) return SQLITE_MISUSE_BKPT; db = p->db; sqlite3_mutex_enter(db->mutex); v = (Vdbe*)p->pStmt; diff --git a/src/vtab.c b/src/vtab.c index bd1c16a987..cbb7523549 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -647,7 +647,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ if( !pTab ){ sqlite3Error(db, SQLITE_MISUSE, 0); sqlite3_mutex_leave(db->mutex); - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } assert( (pTab->tabFlags & TF_Virtual)!=0 ); From 78e0fcf914c8e61c6ef3602aa76e296c0bf98055 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Feb 2010 21:08:40 +0000 Subject: [PATCH 26/50] Fix the stmt.test test script so that it works with SQLITE_TEMP_STORE=3. FossilOrigin-Name: 8bf710ce6dfab0e6fd4de7d6d3157008cc70d192 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/stmt.test | 7 ++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 526fd97ae6..7b06c0ffa5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Merge\sthe\scompile-time\soption\sintrospection\sinterfaces\sinto\sthe\strunk. -D 2010-02-23T20:32:15 +C Fix\sthe\sstmt.test\stest\sscript\sso\sthat\sit\sworks\swith\sSQLITE_TEMP_STORE=3. +D 2010-02-23T21:08:41 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -588,7 +588,7 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/sqllimits1.test e90a0ed94452076f6a10209d378e06b5f75ef0a0 -F test/stmt.test 877d41d41bfbbf27365b4e498c4b5b4b4d61818d +F test/stmt.test ac97e59879fd3bd52ecd60ef4efb03ba16292829 F test/subquery.test b524f57c9574b2c0347045b4510ef795d4686796 F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P edea3bb740ddd096a46e00678b59d465bb1e2903 76a0294ab4208a0858a13bab0858e1bc1448b651 -R b35175023051c7d34a934eed9c09fecc +P 9f429434c0404f03a3e5c6741b769afe98a5c6c9 +R bde76a4d1143f986e520d9d13648dec0 U drh -Z b813deaa3c8e80f7d379ad8d205f30b4 +Z 0edbafdd674ccf625fff856abe89b43e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD4DBQFLhDtToxKgR168RlERAiIJAJ4sxDb50Ahh6anzP0DgFOww+gn3JgCYoVgL -XxKHjRo8pYgc4TchsfsZyA== -=0chk +iD8DBQFLhEPdoxKgR168RlERAtn2AJ9MgEQumymw12j/wVK7twO3+yl+LACfcJCz +zJFAoZng83uA0nnQGrI10GM= +=jzra -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 44df1fea59..75d7d99d77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f429434c0404f03a3e5c6741b769afe98a5c6c9 \ No newline at end of file +8bf710ce6dfab0e6fd4de7d6d3157008cc70d192 \ No newline at end of file diff --git a/test/stmt.test b/test/stmt.test index 56faa896d6..45e9ac5371 100644 --- a/test/stmt.test +++ b/test/stmt.test @@ -24,6 +24,12 @@ do_test stmt-1.1 { # that if a statement journal is required by a statement it is opened and # remains open until the current transaction is committed or rolled back. # +# This only work if SQLITE_TEMP_STORE!=3 +# +if {$::TEMP_STORE==3} { + finish_test + return +} do_test stmt-1.2 { set sqlite_open_file_count } {1} @@ -77,4 +83,3 @@ do_test stmt-2.4 { filecount stmt-2.5 { REPLACE INTO t1 VALUES(5, 5) } 3 finish_test - From 5a29d9cbc525a986e5defe479021be2dbadb675d Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Feb 2010 15:10:14 +0000 Subject: [PATCH 27/50] Fix an assertion fault that occurs when two different virtual tables are used in a single UPDATE statement. Ticket [d2f02d37f52b]. FossilOrigin-Name: ff61e0fd802c46c2d84c4b0c0bc8a0f34959bb25 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/select.c | 25 +++++++++++++------------ test/vtabA.test | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 7b06c0ffa5..60ca55281c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sthe\sstmt.test\stest\sscript\sso\sthat\sit\sworks\swith\sSQLITE_TEMP_STORE=3. -D 2010-02-23T21:08:41 +C Fix\san\sassertion\sfault\sthat\soccurs\swhen\stwo\sdifferent\svirtual\stables\sare\nused\sin\sa\ssingle\sUPDATE\sstatement.\nTicket\s[d2f02d37f52b]. +D 2010-02-24T15:10:14 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -167,7 +167,7 @@ F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 -F src/select.c 0109b993c360d649857523abb72919e1794f9b45 +F src/select.c 4113ef360430ed4e7533690ef46d06c20204adce F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 F src/sqlite.h.in a9f51302109f32e3048358122d1e38fd3ead593f F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 @@ -743,7 +743,7 @@ F test/vtab6.test c7f290d172609d636fbfc58166eadcb55d5c117c F test/vtab7.test a8c3c3cb3eb60be364991bd714e4927e26c4cd85 F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583 F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b -F test/vtabA.test 0dcd4c81ffb56649f47d1b5fb9c5ae807ccf41f7 +F test/vtabA.test c86e1990b7e1e2bb34602a06fffa4c69f2b516dc F test/vtabB.test 04df5dc531b9f44d9ca65b9c1b79f12b5922a796 F test/vtabC.test 1cf7896ab6859bfe3074244b2b0e12de5cbdd766 F test/vtabD.test 74167b1578e5886fe4c886d6bef2fd1406444c42 @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9f429434c0404f03a3e5c6741b769afe98a5c6c9 -R bde76a4d1143f986e520d9d13648dec0 +P 8bf710ce6dfab0e6fd4de7d6d3157008cc70d192 +R bebac69f9e91e2bdba37c73f6ba495f8 U drh -Z 0edbafdd674ccf625fff856abe89b43e +Z 0be4993a1f8e20282f72f2cbfcc52d54 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhEPdoxKgR168RlERAtn2AJ9MgEQumymw12j/wVK7twO3+yl+LACfcJCz -zJFAoZng83uA0nnQGrI10GM= -=jzra +iD8DBQFLhUFaoxKgR168RlERAp+bAJ9aIMVDQ8Dp1bj/Ib3bZe0DoRm3AACgiGAa +9wkaSzZ50yED/siF1Ki8y5I= +=FpV3 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 75d7d99d77..bbb86a5880 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bf710ce6dfab0e6fd4de7d6d3157008cc70d192 \ No newline at end of file +ff61e0fd802c46c2d84c4b0c0bc8a0f34959bb25 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 021c156a50..be4b95c055 100644 --- a/src/select.c +++ b/src/select.c @@ -3327,18 +3327,19 @@ static int selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ struct SrcList_item *pFrom; assert( p->selFlags & SF_Resolved ); - assert( (p->selFlags & SF_HasTypeInfo)==0 ); - p->selFlags |= SF_HasTypeInfo; - pParse = pWalker->pParse; - pTabList = p->pSrc; - for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ - Table *pTab = pFrom->pTab; - if( ALWAYS(pTab!=0) && (pTab->tabFlags & TF_Ephemeral)!=0 ){ - /* A sub-query in the FROM clause of a SELECT */ - Select *pSel = pFrom->pSelect; - assert( pSel ); - while( pSel->pPrior ) pSel = pSel->pPrior; - selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSel); + if( (p->selFlags & SF_HasTypeInfo)==0 ){ + p->selFlags |= SF_HasTypeInfo; + pParse = pWalker->pParse; + pTabList = p->pSrc; + for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ + Table *pTab = pFrom->pTab; + if( ALWAYS(pTab!=0) && (pTab->tabFlags & TF_Ephemeral)!=0 ){ + /* A sub-query in the FROM clause of a SELECT */ + Select *pSel = pFrom->pSelect; + assert( pSel ); + while( pSel->pPrior ) pSel = pSel->pPrior; + selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSel); + } } } return WRC_Continue; diff --git a/test/vtabA.test b/test/vtabA.test index 5eba5b5ffa..928cc2b703 100644 --- a/test/vtabA.test +++ b/test/vtabA.test @@ -131,4 +131,23 @@ do_test vtabA-2.4 { analyse_parse {(a whatelse can i hidden test, b HIDDEN hidden)} {a b} } {{} {whatelse can i test} hidden} + +# Ticket [d2f02d37f52bfe23e421f2c60fbb8586ac76ff01]: +# assertion failure on an UPDATE involving two virtual tables. +# +do_test vtabA-3.1 { + db eval { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + CREATE TABLE t1(a,b); + INSERT INTO t1 VALUES(1,2); + CREATE TABLE t2(x,y); + INSERT INTO t2 VALUES(3,4); + CREATE VIRTUAL TABLE vt1 USING echo(t1); + CREATE VIRTUAL TABLE vt2 USING echo(t2); + UPDATE vt2 SET x=(SELECT a FROM vt1 WHERE b=2) WHERE y=4; + SELECT * FROM t2; + } +} {1 4} + finish_test From a6129fa79aa68543a1075ef94bbd24e5de756d07 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Feb 2010 17:15:19 +0000 Subject: [PATCH 28/50] Enhancements to the way errors are reported up when an automatic statement reprepare fails. FossilOrigin-Name: 1a6d4bb130382564093b6370818ae4a7633f4074 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/prepare.c | 2 +- src/vdbeapi.c | 17 ++++++++++------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 60ca55281c..d469ad5df7 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\san\sassertion\sfault\sthat\soccurs\swhen\stwo\sdifferent\svirtual\stables\sare\nused\sin\sa\ssingle\sUPDATE\sstatement.\nTicket\s[d2f02d37f52b]. -D 2010-02-24T15:10:14 +C Enhancements\sto\sthe\sway\serrors\sare\sreported\sup\swhen\san\sautomatic\nstatement\sreprepare\sfails. +D 2010-02-24T17:15:19 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -162,7 +162,7 @@ F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 F src/pragma.c 1ee3a5bea3e79bd4ad2519eb9745e1781bf443ea -F src/prepare.c 341413e4703df1f0430e595a78c33e722e6cb8d0 +F src/prepare.c c80630169d82945070a50ebf298611fd9f1485f1 F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b @@ -217,7 +217,7 @@ F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de F src/vdbe.c eb8b083191412e89292b864687f86afa28f4dc3f F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e -F src/vdbeapi.c e9a5abc45877b228925cc69d765df2dc134efb9f +F src/vdbeapi.c a8e8b6292864e71998df527f69cc5dde778a96c0 F src/vdbeaux.c 417ee0c5677188b3b72a0ccdda5668183e28bb51 F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8bf710ce6dfab0e6fd4de7d6d3157008cc70d192 -R bebac69f9e91e2bdba37c73f6ba495f8 +P ff61e0fd802c46c2d84c4b0c0bc8a0f34959bb25 +R 658916f84409712fa7dd2548647c2d32 U drh -Z 0be4993a1f8e20282f72f2cbfcc52d54 +Z ccb108eaf5c8840f33d32e69034f28ee -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhUFaoxKgR168RlERAp+bAJ9aIMVDQ8Dp1bj/Ib3bZe0DoRm3AACgiGAa -9wkaSzZ50yED/siF1Ki8y5I= -=FpV3 +iD8DBQFLhV6poxKgR168RlERAkKMAKCK4ulcjdItzZ4IyBdUjP6qgi/oLwCcDgEl +48bCZk0NWHJfXdvLWtlvzcQ= +=+4UP -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index bbb86a5880..396a73712f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff61e0fd802c46c2d84c4b0c0bc8a0f34959bb25 \ No newline at end of file +1a6d4bb130382564093b6370818ae4a7633f4074 \ No newline at end of file diff --git a/src/prepare.c b/src/prepare.c index c8cd6f6f62..c15cd13020 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -728,7 +728,7 @@ int sqlite3Reprepare(Vdbe *p){ db->mallocFailed = 1; } assert( pNew==0 ); - return (rc==SQLITE_LOCKED) ? SQLITE_LOCKED : SQLITE_SCHEMA; + return rc; }else{ assert( pNew!=0 ); } diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 060f272246..26695db018 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -418,10 +418,12 @@ end_of_step: ** call sqlite3Reprepare() and try again. */ int sqlite3_step(sqlite3_stmt *pStmt){ - int rc = SQLITE_OK; - Vdbe *v = (Vdbe*)pStmt; - int cnt = 0; - sqlite3 *db; + int rc = SQLITE_OK; /* Result from sqlite3Step() */ + int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */ + Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */ + int cnt = 0; /* Counter to prevent infinite loop of reprepares */ + sqlite3 *db; /* The database connection */ + if( vdbeSafetyNotNull(v) ){ return SQLITE_MISUSE_BKPT; } @@ -429,11 +431,11 @@ int sqlite3_step(sqlite3_stmt *pStmt){ sqlite3_mutex_enter(db->mutex); while( (rc = sqlite3Step(v))==SQLITE_SCHEMA && cnt++ < 5 - && (rc = sqlite3Reprepare(v))==SQLITE_OK ){ + && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){ sqlite3_reset(pStmt); v->expired = 0; } - if( rc==SQLITE_SCHEMA && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ + if( rc2!=SQLITE_OK && v->isPrepareV2 && db->pErr ){ /* This case occurs after failing to recompile an sql statement. ** The error message from the SQL compiler has already been loaded ** into the database handle. This block copies the error message @@ -446,9 +448,10 @@ int sqlite3_step(sqlite3_stmt *pStmt){ sqlite3DbFree(db, v->zErrMsg); if( !db->mallocFailed ){ v->zErrMsg = sqlite3DbStrDup(db, zErr); + v->rc = rc2; } else { v->zErrMsg = 0; - v->rc = SQLITE_NOMEM; + v->rc = rc = SQLITE_NOMEM; } } rc = sqlite3ApiExit(db, rc); From 31caa42afd714ae0ef7bfadf62b7aa0bebbad58d Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Feb 2010 18:25:58 +0000 Subject: [PATCH 29/50] Remove an unused variable from rtree. FossilOrigin-Name: 8e60d3995a1ea940de9751dd3bbd7ef41b0bb00a --- ext/rtree/rtree.c | 1 - manifest | 18 +++++++++--------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 90a9595405..3111cc2e96 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -2703,7 +2703,6 @@ static int rtreeInit( int isCreate /* True for xCreate, false for xConnect */ ){ int rc = SQLITE_OK; - int iPageSize = 0; Rtree *pRtree; int nDb; /* Length of string argv[1] */ int nName; /* Length of string argv[2] */ diff --git a/manifest b/manifest index d469ad5df7..998fcd42dc 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Enhancements\sto\sthe\sway\serrors\sare\sreported\sup\swhen\san\sautomatic\nstatement\sreprepare\sfails. -D 2010-02-24T17:15:19 +C Remove\san\sunused\svariable\sfrom\srtree. +D 2010-02-24T18:25:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -77,7 +77,7 @@ F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33 F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c b82403b0320a7278e0a0e6562c08c8bba17ee0dd +F ext/rtree/rtree.c a354f6be11a91706680936fdf77b4588f0b34dbe F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test f72885ed80a329d6bd7991043016d74b51edf2c5 F ext/rtree/rtree2.test 7b665c44d25e51b3098068d983a39902b2e2d7a1 @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ff61e0fd802c46c2d84c4b0c0bc8a0f34959bb25 -R 658916f84409712fa7dd2548647c2d32 +P 1a6d4bb130382564093b6370818ae4a7633f4074 +R d7cbaa8b7d7b278e9482fb7d1f098fcd U drh -Z ccb108eaf5c8840f33d32e69034f28ee +Z 688d557fd57a83deb71613699a5870da -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhV6poxKgR168RlERAkKMAKCK4ulcjdItzZ4IyBdUjP6qgi/oLwCcDgEl -48bCZk0NWHJfXdvLWtlvzcQ= -=+4UP +iD8DBQFLhW86oxKgR168RlERAkDjAJ9QKX0HcqzLExmawk0KoyogwLBMlQCcCLE5 +kf1ZeFqoFZCHiKNtKjnTtrc= +=hvc6 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 396a73712f..1eb6b3d6e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a6d4bb130382564093b6370818ae4a7633f4074 \ No newline at end of file +8e60d3995a1ea940de9751dd3bbd7ef41b0bb00a \ No newline at end of file From 7823006011b7374514fcac1e1fd7466df967c7fb Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Feb 2010 18:40:39 +0000 Subject: [PATCH 30/50] Fix an incorrect ALWAYS() macro in vdbeapi.c. Fix the output of a few test cases that changed due to better error propagation out of reprepare. FossilOrigin-Name: a8c984c1d6cb6e2fc95a07eb32befeea122e8ed3 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/vdbeapi.c | 2 +- test/capi3c.test | 2 +- test/schema.test | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 998fcd42dc..21dc9f5c35 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Remove\san\sunused\svariable\sfrom\srtree. -D 2010-02-24T18:25:59 +C Fix\san\sincorrect\sALWAYS()\smacro\sin\svdbeapi.c.\s\sFix\sthe\soutput\sof\sa\sfew\ntest\scases\sthat\schanged\sdue\sto\sbetter\serror\spropagation\sout\sof\sreprepare. +D 2010-02-24T18:40:39 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -217,7 +217,7 @@ F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de F src/vdbe.c eb8b083191412e89292b864687f86afa28f4dc3f F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e -F src/vdbeapi.c a8e8b6292864e71998df527f69cc5dde778a96c0 +F src/vdbeapi.c e0398d74af46911033b92088f740582f3c400515 F src/vdbeaux.c 417ee0c5677188b3b72a0ccdda5668183e28bb51 F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 @@ -277,7 +277,7 @@ F test/cache.test 3ff445c445742a7b6b9ba6e1d62a25263f9424b9 F test/capi2.test 172c717ed101e78e0798dd21b9896a22366f35b4 F test/capi3.test 168e2cd66c58c510955b0f299750e4de73b8d952 F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97 -F test/capi3c.test d9d293ce8fd4dc2944ce2dae5718fc7a6184a567 +F test/capi3c.test 493385107dcedfaf4f2b1c3738c8c1fa00362006 F test/capi3d.test 57d83b690d7364bde02cddbf8339a4b50d80ce23 F test/cast.test 166951664a0b0a2e0f8fb5997a152490c6363932 F test/check.test db2b29d557544347d28e25b8406f5d5ecc3d1bc3 @@ -550,7 +550,7 @@ F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0 F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd F test/savepoint6.test 2df1d093e59e78d688c64eb20e0457aaea7d08f9 -F test/schema.test 23a2909d2b1f8494d28d355c1254f075b0af8ffc +F test/schema.test 8f7999be894260f151adf15c2c7540f1c6d6a481 F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5 F test/securedel.test 328d2921c0ca49bdd3352e516b0377fc07143254 F test/select1.test f67ca2dfc05df41c7b86eb32ca409b427a5f43b0 @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1a6d4bb130382564093b6370818ae4a7633f4074 -R d7cbaa8b7d7b278e9482fb7d1f098fcd +P 8e60d3995a1ea940de9751dd3bbd7ef41b0bb00a +R 6982e34d63d3f7c4c63beeb945356ebf U drh -Z 688d557fd57a83deb71613699a5870da +Z c4ecc3e66bf0fd4aae2b5b5dd8f1451e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhW86oxKgR168RlERAkDjAJ9QKX0HcqzLExmawk0KoyogwLBMlQCcCLE5 -kf1ZeFqoFZCHiKNtKjnTtrc= -=hvc6 +iD8DBQFLhXKqoxKgR168RlERAv3oAJ4/CLWQPurMHkYouSQ4hYLZQvLwUACfbzJS +CpVug0wu1S3JGMsgNXNc/uA= +=PJke -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 1eb6b3d6e4..0cd4c7fda6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e60d3995a1ea940de9751dd3bbd7ef41b0bb00a \ No newline at end of file +a8c984c1d6cb6e2fc95a07eb32befeea122e8ed3 \ No newline at end of file diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 26695db018..aac898a82a 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -334,7 +334,7 @@ static int sqlite3Step(Vdbe *p){ } if( p->pc<=0 && p->expired ){ - if( ALWAYS(p->rc==SQLITE_OK || p->rc==SQLITE_SCHEMA) ){ + if( p->rc==SQLITE_OK ){ p->rc = SQLITE_SCHEMA; } rc = SQLITE_ERROR; diff --git a/test/capi3c.test b/test/capi3c.test index 1bcc4373c2..55f4667e15 100644 --- a/test/capi3c.test +++ b/test/capi3c.test @@ -1176,7 +1176,7 @@ do_test capi3c-19.4 { sqlite3_reset $STMT db eval {DROP TABLE t3} sqlite3_step $STMT -} SQLITE_SCHEMA +} SQLITE_ERROR do_test capi3c-19.4.1 { sqlite3_errmsg $DB } {no such table: t3} diff --git a/test/schema.test b/test/schema.test index 5e9f17573f..afca39ed60 100644 --- a/test/schema.test +++ b/test/schema.test @@ -376,15 +376,15 @@ do_test schema-13.1 { return SQLITE_OK } sqlite3_step $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} do_test schema-13.2 { sqlite3_step $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} do_test schema-13.3 { sqlite3_finalize $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} } From cda455b7ff100ee7e86b6125b41efe3f21754cc9 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Feb 2010 19:23:56 +0000 Subject: [PATCH 31/50] Add a sqlite3_log() call on anonymous constraint failures. Fix the output of test cases having to do with improved reprepare reporting. Fix the VACUUM command to report more helpful error messages when things go wrong. FossilOrigin-Name: 69a493182fd77bec91598516ee42c11a6db1d039 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/vacuum.c | 47 +++++++++++++++++++++++++++++----------------- src/vdbe.c | 2 ++ test/analyze3.test | 12 ++++++------ 5 files changed, 50 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index 21dc9f5c35..e65efe1116 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\san\sincorrect\sALWAYS()\smacro\sin\svdbeapi.c.\s\sFix\sthe\soutput\sof\sa\sfew\ntest\scases\sthat\schanged\sdue\sto\sbetter\serror\spropagation\sout\sof\sreprepare. -D 2010-02-24T18:40:39 +C Add\sa\ssqlite3_log()\scall\son\sanonymous\sconstraint\sfailures.\nFix\sthe\soutput\sof\stest\scases\shaving\sto\sdo\swith\simproved\sreprepare\sreporting.\nFix\sthe\sVACUUM\scommand\sto\sreport\smore\shelpful\serror\smessages\swhen\sthings\sgo\nwrong. +D 2010-02-24T19:23:56 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -213,8 +213,8 @@ F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 F src/util.c 57256361d9794ae9b8c7d7d9df8ee239ba7f9b01 -F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de -F src/vdbe.c eb8b083191412e89292b864687f86afa28f4dc3f +F src/vacuum.c deb50c41c39849770ab1bf27e8a35ba1036e3962 +F src/vdbe.c 815ec0f55b184be47f7e354790d55e505eb3b8d3 F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e F src/vdbeapi.c e0398d74af46911033b92088f740582f3c400515 @@ -235,7 +235,7 @@ F test/alter4.test 9386ffd1e9c7245f43eca412b2058d747509cc1f F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/analyze.test ad5329098fe4de4a96852231d53e3e9e6283ad4b F test/analyze2.test a2ad7b0a4e13801ee3968fe70f22aff52326569c -F test/analyze3.test ae06e0f8b3eaae0dd644ac9ac9d617058b5ac131 +F test/analyze3.test 506203875258ffd8ffa879b9c3c5432022d2b6d8 F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e @@ -794,14 +794,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8e60d3995a1ea940de9751dd3bbd7ef41b0bb00a -R 6982e34d63d3f7c4c63beeb945356ebf +P a8c984c1d6cb6e2fc95a07eb32befeea122e8ed3 +R 2b722edc5008cbf38737ae2ef5623db4 U drh -Z c4ecc3e66bf0fd4aae2b5b5dd8f1451e +Z 8f72e9f3a584b7bfbd7a9cae96339e61 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhXKqoxKgR168RlERAv3oAJ4/CLWQPurMHkYouSQ4hYLZQvLwUACfbzJS -CpVug0wu1S3JGMsgNXNc/uA= -=PJke +iD8DBQFLhXzPoxKgR168RlERAhuKAJ0bK7dYcMKjnA8nUy8KJNd03rqo5gCfbk0E +IcFdGuxfI3OrBOGRpsZhtkE= +=e87x -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0cd4c7fda6..0b734ae578 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a8c984c1d6cb6e2fc95a07eb32befeea122e8ed3 \ No newline at end of file +69a493182fd77bec91598516ee42c11a6db1d039 \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 9d26da3dae..4975426918 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -18,28 +18,42 @@ #include "vdbeInt.h" #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) +/* +** Finalize a prepared statement. If there was an error, store the +** text of the error message in *pzErrMsg. Return the result code. +*/ +static int vacuumFinalize(sqlite3 *db, sqlite3_stmt *pStmt, char **pzErrMsg){ + int rc; + rc = sqlite3VdbeFinalize((Vdbe*)pStmt); + if( rc ){ + sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db)); + } + return rc; +} + /* ** Execute zSql on database db. Return an error code. */ -static int execSql(sqlite3 *db, const char *zSql){ +static int execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){ sqlite3_stmt *pStmt; VVA_ONLY( int rc; ) if( !zSql ){ return SQLITE_NOMEM; } if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ + sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db)); return sqlite3_errcode(db); } VVA_ONLY( rc = ) sqlite3_step(pStmt); assert( rc!=SQLITE_ROW ); - return sqlite3_finalize(pStmt); + return vacuumFinalize(db, pStmt, pzErrMsg); } /* ** Execute zSql on database db. The statement returns exactly ** one column. Execute this as SQL on the same database. */ -static int execExecSql(sqlite3 *db, const char *zSql){ +static int execExecSql(sqlite3 *db, char **pzErrMsg, const char *zSql){ sqlite3_stmt *pStmt; int rc; @@ -47,14 +61,14 @@ static int execExecSql(sqlite3 *db, const char *zSql){ if( rc!=SQLITE_OK ) return rc; while( SQLITE_ROW==sqlite3_step(pStmt) ){ - rc = execSql(db, (char*)sqlite3_column_text(pStmt, 0)); + rc = execSql(db, pzErrMsg, (char*)sqlite3_column_text(pStmt, 0)); if( rc!=SQLITE_OK ){ - sqlite3_finalize(pStmt); + vacuumFinalize(db, pStmt, pzErrMsg); return rc; } } - return sqlite3_finalize(pStmt); + return vacuumFinalize(db, pStmt, pzErrMsg); } /* @@ -125,7 +139,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ ** to write the journal header file. */ zSql = "ATTACH '' AS vacuum_db;"; - rc = execSql(db, zSql); + rc = execSql(db, pzErrMsg, zSql); if( rc!=SQLITE_OK ) goto end_of_vacuum; pDb = &db->aDb[db->nDb-1]; assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 ); @@ -157,7 +171,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ rc = SQLITE_NOMEM; goto end_of_vacuum; } - rc = execSql(db, "PRAGMA vacuum_db.synchronous=OFF"); + rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); if( rc!=SQLITE_OK ){ goto end_of_vacuum; } @@ -168,23 +182,23 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ #endif /* Begin a transaction */ - rc = execSql(db, "BEGIN EXCLUSIVE;"); + rc = execSql(db, pzErrMsg, "BEGIN EXCLUSIVE;"); if( rc!=SQLITE_OK ) goto end_of_vacuum; /* Query the schema of the main database. Create a mirror schema ** in the temporary database. */ - rc = execExecSql(db, + rc = execExecSql(db, pzErrMsg, "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" " AND rootpage>0" ); if( rc!=SQLITE_OK ) goto end_of_vacuum; - rc = execExecSql(db, + rc = execExecSql(db, pzErrMsg, "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)" " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' "); if( rc!=SQLITE_OK ) goto end_of_vacuum; - rc = execExecSql(db, + rc = execExecSql(db, pzErrMsg, "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) " " FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'"); if( rc!=SQLITE_OK ) goto end_of_vacuum; @@ -193,24 +207,23 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy ** the contents to the temporary database. */ - rc = execExecSql(db, + rc = execExecSql(db, pzErrMsg, "SELECT 'INSERT INTO vacuum_db.' || quote(name) " "|| ' SELECT * FROM main.' || quote(name) || ';'" "FROM main.sqlite_master " "WHERE type = 'table' AND name!='sqlite_sequence' " " AND rootpage>0" - ); if( rc!=SQLITE_OK ) goto end_of_vacuum; /* Copy over the sequence table */ - rc = execExecSql(db, + rc = execExecSql(db, pzErrMsg, "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' " "FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' " ); if( rc!=SQLITE_OK ) goto end_of_vacuum; - rc = execExecSql(db, + rc = execExecSql(db, pzErrMsg, "SELECT 'INSERT INTO vacuum_db.' || quote(name) " "|| ' SELECT * FROM main.' || quote(name) || ';' " "FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';" @@ -223,7 +236,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ ** associated storage, so all we have to do is copy their entries ** from the SQLITE_MASTER table. */ - rc = execSql(db, + rc = execSql(db, pzErrMsg, "INSERT INTO vacuum_db.sqlite_master " " SELECT type, name, tbl_name, rootpage, sql" " FROM main.sqlite_master" diff --git a/src/vdbe.c b/src/vdbe.c index 71fa635d09..5fbeaf49e6 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -850,6 +850,8 @@ case OP_Halt: { assert( p->rc!=SQLITE_OK ); sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z); sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pc, p->zSql, pOp->p4.z); + }else if( p->rc ){ + sqlite3_log(pOp->p1, "constraint failed at %d in [%s]", pc, p->zSql); } rc = sqlite3VdbeHalt(p); assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); diff --git a/test/analyze3.test b/test/analyze3.test index f623f987a4..438ecd7b2b 100644 --- a/test/analyze3.test +++ b/test/analyze3.test @@ -481,10 +481,10 @@ do_test analyze3-4.1.2 { sqlite3_bind_text $S 2 "abc" 3 execsql { DROP TABLE t1 } sqlite3_step $S -} {SQLITE_SCHEMA} +} {SQLITE_ERROR} do_test analyze3-4.1.3 { sqlite3_finalize $S -} {SQLITE_SCHEMA} +} {SQLITE_ERROR} # Check an authorization error. # @@ -511,10 +511,10 @@ do_test analyze3-4.2.2 { sqlite3_reset $S sqlite3_bind_text $S 2 "abc" 3 sqlite3_step $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} do_test analyze3-4.2.4 { sqlite3_finalize $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} # Check the effect of an authorization error that occurs in a re-prepare # performed by sqlite3_step() is the same as one that occurs within @@ -526,10 +526,10 @@ do_test analyze3-4.3.1 { execsql { CREATE TABLE t2(d, e, f) } db auth auth sqlite3_step $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} do_test analyze3-4.3.2 { sqlite3_finalize $S -} {SQLITE_SCHEMA} +} {SQLITE_AUTH} db auth {} #------------------------------------------------------------------------- From 915c8bdbbdbeb1cf01e733caa293cfc5e8cc4697 Mon Sep 17 00:00:00 2001 From: shaneh Date: Wed, 24 Feb 2010 19:36:10 +0000 Subject: [PATCH 32/50] Changes to compile time option diags to report values for some defines. Added test cases to TCL test suite (ctime.test). FossilOrigin-Name: dd480f62afa56ff85c2dd57ee7a16eee427e823f --- manifest | 27 ++---- manifest.uuid | 2 +- src/ctime.c | 27 +++++- src/test_config.c | 6 +- test/ctime.test | 239 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 276 insertions(+), 25 deletions(-) create mode 100644 test/ctime.test diff --git a/manifest b/manifest index e65efe1116..5bbc634bb5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Add\sa\ssqlite3_log()\scall\son\sanonymous\sconstraint\sfailures.\nFix\sthe\soutput\sof\stest\scases\shaving\sto\sdo\swith\simproved\sreprepare\sreporting.\nFix\sthe\sVACUUM\scommand\sto\sreport\smore\shelpful\serror\smessages\swhen\sthings\sgo\nwrong. -D 2010-02-24T19:23:56 +C Changes\sto\scompile\stime\soption\sdiags\sto\sreport\svalues\sfor\ssome\sdefines.\s\s\nAdded\stest\scases\sto\sTCL\stest\ssuite\s(ctime.test). +D 2010-02-24T19:36:10 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -118,7 +115,7 @@ F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 254a273acb8923f3bdecc933d787f4f67737c489 F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac -F src/ctime.c af27b864e4f6aa179cae9488e20d9bc281200e50 +F src/ctime.c ceb247eb31620bba66a94c3f697db489a1652353 F src/date.c 485a4409a384310e6d93fd1104a9d0a8658becd9 F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581 F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 @@ -189,7 +186,7 @@ F src/test_async.c c1656facbaf43cb2e71b62621e5b9eb080e2621c F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c 220a67047af393756f55760fdf442d935d0d88f3 +F src/test_config.c 5844274bf6cec4af3e6461fb3e2d349082635e81 F src/test_devsym.c de3c9af2bb9a8b1e44525c449e4ec3f88e3d4110 F src/test_func.c 13b582345fb1185a93e46c53310fae8547dcce20 F src/test_hexio.c 1237f000ec7a491009b1233f5c626ea71bce1ea2 @@ -321,6 +318,7 @@ F test/crash8.test 5b32966fcb58fd616d24ce94303420351d076eb9 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c +F test/ctime.test aa0953d27564dac33d6c3fd5903312788b7fa383 F test/date.test 0b8473ed9ab6fd4283b4a01f035e1067762ba734 F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc F test/delete.test f7629d9eb245dfca170169cc5c7a735dec34aeb4 @@ -794,14 +792,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a8c984c1d6cb6e2fc95a07eb32befeea122e8ed3 -R 2b722edc5008cbf38737ae2ef5623db4 -U drh -Z 8f72e9f3a584b7bfbd7a9cae96339e61 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLhXzPoxKgR168RlERAhuKAJ0bK7dYcMKjnA8nUy8KJNd03rqo5gCfbk0E -IcFdGuxfI3OrBOGRpsZhtkE= -=e87x ------END PGP SIGNATURE----- +P 69a493182fd77bec91598516ee42c11a6db1d039 +R 0595378132dd801ca4b7473a352dc602 +U shaneh +Z ced54587bc46e680be6da59f4025dfb3 diff --git a/manifest.uuid b/manifest.uuid index 0b734ae578..53793aad9e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69a493182fd77bec91598516ee42c11a6db1d039 \ No newline at end of file +dd480f62afa56ff85c2dd57ee7a16eee427e823f \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 63e577015a..dacdc5883c 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -19,13 +19,20 @@ #include "sqliteInt.h" /* -** An array of names of all compile-time options. +** An array of names of all compile-time options. This array should +** be sorted A-Z. ** ** This array looks large, but in a typical installation actually uses -** only a handful of compile-time options, so most this array is usually +** only a handful of compile-time options, so most times this array is usually ** rather short and uses little memory space. */ static const char * const azCompileOpt[] = { + +/* These macros are provided to "stringify" the value of the define +** for those options in which the value is meaningful. */ +#define CTIMEOPT_VAL_(opt) #opt +#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) + #ifdef SQLITE_32BIT_ROWID "32BIT_ROWID", #endif @@ -44,6 +51,9 @@ static const char * const azCompileOpt[] = { #ifdef SQLITE_DEBUG "DEBUG", #endif +#ifdef SQLITE_DEFAULT_LOCKING_MODE + "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), +#endif #ifdef SQLITE_DISABLE_DIRSYNC "DISABLE_DIRSYNC", #endif @@ -87,7 +97,7 @@ static const char * const azCompileOpt[] = { "ENABLE_LOAD_EXTENSION", #endif #ifdef SQLITE_ENABLE_LOCKING_STYLE - "ENABLE_LOCKING_STYLE", + "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), #endif #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT "ENABLE_MEMORY_MANAGEMENT", @@ -323,14 +333,20 @@ static const char * const azCompileOpt[] = { #ifdef SQLITE_TCL "TCL", #endif +#ifdef SQLITE_TEMP_STORE + "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE), +#endif #ifdef SQLITE_TEST "TEST", #endif +#ifdef SQLITE_THREADSAFE + "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), +#endif #ifdef SQLITE_USE_ALLOCA "USE_ALLOCA", #endif #ifdef SQLITE_ZERO_MALLOC - "ZERO_MALLOC", + "ZERO_MALLOC" #endif }; @@ -349,7 +365,8 @@ int sqlite3_compileoption_used(const char *zOptName){ /* Since ArraySize(azCompileOpt) is normally in single digits, a ** linear search is adequate. No need for a binary search. */ for(i=0; i Date: Wed, 24 Feb 2010 21:44:07 +0000 Subject: [PATCH 33/50] Add testcase() macros beside each sqlite3_log() call to make sure it is tested with both logging enable and disabled. FossilOrigin-Name: 1168763d2cd96acfa0488198e8bc82f0c4fa35a3 --- manifest | 32 +++++++++++++++++++++----------- manifest.uuid | 2 +- src/main.c | 3 +++ src/mem1.c | 2 ++ src/mem5.c | 1 + src/util.c | 2 +- src/vdbe.c | 2 ++ 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 5bbc634bb5..c7103b9a91 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Changes\sto\scompile\stime\soption\sdiags\sto\sreport\svalues\sfor\ssome\sdefines.\s\s\nAdded\stest\scases\sto\sTCL\stest\ssuite\s(ctime.test). -D 2010-02-24T19:36:10 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Add\stestcase()\smacros\sbeside\seach\ssqlite3_log()\scall\sto\smake\ssure\sit\sis\ntested\swith\sboth\slogging\senable\sand\sdisabled. +D 2010-02-24T21:44:07 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -131,13 +134,13 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581 -F src/main.c f4226ebd8c0e7d6ee712072356455e7712ce99c9 +F src/main.c 5e4a918c068b9d6c87fb4721b0b5c21cd52f0f4e F src/malloc.c 5fa175797f982b178eaf38afba9c588a866be729 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 -F src/mem1.c 760dbac6ead11b901a8dcfa210f891b638a87507 +F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2 F src/mem2.c 92b4f772b1ee7469e256f1c2eff0b51a0ba19460 F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3 -F src/mem5.c 7060e51b8dfe04c3d1e4297ccdbbba3a331c9673 +F src/mem5.c eb7a5cb98915dd7a086fa415ce3a5a0f20d0acff F src/memjournal.c 5bfc2f33c914946e2f77ed3f882aff14dfc9355d F src/mutex.c 581a272e09098040ca3ef543cb5f3d643eff7d50 F src/mutex.h 6fde601e55fa6c3fae768783c439797ab84c87c6 @@ -209,9 +212,9 @@ F src/tokenize.c 25ceb0f0a746ea1d0f9553787f3f0a56853cfaeb F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 -F src/util.c 57256361d9794ae9b8c7d7d9df8ee239ba7f9b01 +F src/util.c 5a15aa0cc1a642aeb3ebb37c8c2bba7e1c014581 F src/vacuum.c deb50c41c39849770ab1bf27e8a35ba1036e3962 -F src/vdbe.c 815ec0f55b184be47f7e354790d55e505eb3b8d3 +F src/vdbe.c 6de14d95ade1193f2a694ce673f69ac20032fa17 F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e F src/vdbeapi.c e0398d74af46911033b92088f740582f3c400515 @@ -792,7 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 69a493182fd77bec91598516ee42c11a6db1d039 -R 0595378132dd801ca4b7473a352dc602 -U shaneh -Z ced54587bc46e680be6da59f4025dfb3 +P dd480f62afa56ff85c2dd57ee7a16eee427e823f +R c9523526f48a8860988dae54cadcdbf1 +U drh +Z 1dbd84d12743933d537cbe784ede4bca +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLhZ2qoxKgR168RlERAtqjAJ9ekluC7QTqJi+Q6cIzjOZVf34HNACfUmiQ +TteOSExg+iy0J6i1CF0ncys= +=oaDc +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 53793aad9e..d00c919731 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dd480f62afa56ff85c2dd57ee7a16eee427e823f \ No newline at end of file +1168763d2cd96acfa0488198e8bc82f0c4fa35a3 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 37567348d9..879907fadb 100644 --- a/src/main.c +++ b/src/main.c @@ -1956,15 +1956,18 @@ int sqlite3_get_autocommit(sqlite3 *db){ ** a low-level error is first detected. */ int sqlite3CorruptError(int lineno){ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_CORRUPT, "database corruption found by source line %d", lineno); return SQLITE_CORRUPT; } int sqlite3MisuseError(int lineno){ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_MISUSE, "misuse detected by source line %d", lineno); return SQLITE_MISUSE; } int sqlite3CantopenError(int lineno){ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_CANTOPEN, "cannot open file at source line %d", lineno); return SQLITE_CANTOPEN; } diff --git a/src/mem1.c b/src/mem1.c index 558eed8474..1a01839992 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -43,6 +43,7 @@ static void *sqlite3MemMalloc(int nByte){ p[0] = nByte; p++; }else{ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); } return (void *)p; @@ -95,6 +96,7 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){ p[0] = nByte; p++; }else{ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed memory resize %u to %u bytes", sqlite3MemSize(pPrior), nByte); diff --git a/src/mem5.c b/src/mem5.c index feb1cb7e99..a828cf812e 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -269,6 +269,7 @@ static void *memsys5MallocUnsafe(int nByte){ */ for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){} if( iBin>LOGMAX ){ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte); return 0; } diff --git a/src/util.c b/src/util.c index 159da1eea6..4c635c6452 100644 --- a/src/util.c +++ b/src/util.c @@ -1057,7 +1057,7 @@ int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ if( magic!=SQLITE_MAGIC_SICK && magic!=SQLITE_MAGIC_OPEN && magic!=SQLITE_MAGIC_BUSY ){ - logBadConnection( magic==SQLITE_MAGIC_CLOSED ? "closed" : "invalid" ); + logBadConnection("invalid"); return 0; }else{ return 1; diff --git a/src/vdbe.c b/src/vdbe.c index 5fbeaf49e6..746be2aae4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -849,8 +849,10 @@ case OP_Halt: { if( pOp->p4.z ){ assert( p->rc!=SQLITE_OK ); sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z); + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pc, p->zSql, pOp->p4.z); }else if( p->rc ){ + testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(pOp->p1, "constraint failed at %d in [%s]", pc, p->zSql); } rc = sqlite3VdbeHalt(p); From 5e767c579344d6b980ec84940bbd9d72009a21bc Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Feb 2010 04:15:47 +0000 Subject: [PATCH 34/50] Make sure the ON clause of a LEFT JOIN does not cause an index to be used to speed access to a table to the left of the join. Ticket [ebdbadade5] FossilOrigin-Name: f0ae251abb9e8a8793f46a30b79b2ce541cf14d5 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/where.c | 5 +++-- test/where6.test | 24 ++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index c7103b9a91..94a98d047e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\stestcase()\smacros\sbeside\seach\ssqlite3_log()\scall\sto\smake\ssure\sit\sis\ntested\swith\sboth\slogging\senable\sand\sdisabled. -D 2010-02-24T21:44:07 +C Make\ssure\sthe\sON\sclause\sof\sa\sLEFT\sJOIN\sdoes\snot\scause\san\sindex\sto\sbe\nused\sto\sspeed\saccess\sto\sa\stable\sto\sthe\sleft\sof\sthe\sjoin.\nTicket\s[ebdbadade5] +D 2010-02-25T04:15:48 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -224,7 +224,7 @@ F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vtab.c 606adf51cd6d4ba51a8c6dccede06a6f7b0dd72d F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 9269ec75e1e36e69748fd918ac5a636020c85e7e +F src/where.c 399ea4c090284c9d16f76d685b9b44e8b9b4442b F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -757,7 +757,7 @@ F test/where2.test 45eacc126aabb37959a387aa83e59ce1f1f03820 F test/where3.test 97d3936e6a443b968f1a61cdcc0f673252000e94 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 -F test/where6.test 42c4373595f4409d9c6a9987b4a60000ad664faf +F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b F test/where7.test fdd58ab9dec9f97679e65d4414bf5e07d725d79f F test/where8.test 2bb8ea44b745fcc93db150fac9ce33d12e499760 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 @@ -795,14 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P dd480f62afa56ff85c2dd57ee7a16eee427e823f -R c9523526f48a8860988dae54cadcdbf1 +P 1168763d2cd96acfa0488198e8bc82f0c4fa35a3 +R 1756ec34ec14812b999545b49c238389 U drh -Z 1dbd84d12743933d537cbe784ede4bca +Z cef349c135ac8fde894db77ffb6c3cd3 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhZ2qoxKgR168RlERAtqjAJ9ekluC7QTqJi+Q6cIzjOZVf34HNACfUmiQ -TteOSExg+iy0J6i1CF0ncys= -=oaDc +iD8DBQFLhfl5oxKgR168RlERAuYtAJ9UCQXaWqORFlTB8prfqFcd5VDUngCcDDwZ +5GuaCQJQEFY+u7p5eZA7abU= +=4lWh -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index d00c919731..e4b48db311 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1168763d2cd96acfa0488198e8bc82f0c4fa35a3 \ No newline at end of file +f0ae251abb9e8a8793f46a30b79b2ce541cf14d5 \ No newline at end of file diff --git a/src/where.c b/src/where.c index f27ce66928..5f81ce0768 100644 --- a/src/where.c +++ b/src/where.c @@ -1096,7 +1096,7 @@ static void exprAnalyze( Expr *pExpr; /* The expression to be analyzed */ Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */ Bitmask prereqAll; /* Prerequesites of pExpr */ - Bitmask extraRight = 0; /* */ + Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */ int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */ int noCase = 0; /* LIKE/GLOB distinguishes case */ @@ -1168,7 +1168,8 @@ static void exprAnalyze( pLeft = pDup->pLeft; pNew->leftCursor = pLeft->iTable; pNew->u.leftColumn = pLeft->iColumn; - pNew->prereqRight = prereqLeft; + testcase( (prereqLeft | extraRight) != prereqLeft ); + pNew->prereqRight = prereqLeft | extraRight; pNew->prereqAll = prereqAll; pNew->eOperator = operatorMask(pDup->op); } diff --git a/test/where6.test b/test/where6.test index bcea6540a5..83e975b7dd 100644 --- a/test/where6.test +++ b/test/where6.test @@ -127,4 +127,28 @@ do_test where6-2.14 { } } {1 3 1 3} +# Ticket [ebdbadade5b]: +# If the ON close on a LEFT JOIN is of the form x=y where both x and y +# are indexed columns on tables to left of the join, then do not use that +# term with indices to either table. +# +do_test where6-3.1 { + db eval { + CREATE TABLE t4(x UNIQUE); + INSERT INTO t4 VALUES('abc'); + INSERT INTO t4 VALUES('def'); + INSERT INTO t4 VALUES('ghi'); + CREATE TABLE t5(a, b, c, PRIMARY KEY(a,b)); + INSERT INTO t5 VALUES('abc','def',123); + INSERT INTO t5 VALUES('def','ghi',456); + + SELECT t4a.x, t4b.x, t5.c, t6.v + FROM t4 AS t4a + INNER JOIN t4 AS t4b + LEFT JOIN t5 ON t5.a=t4a.x AND t5.b=t4b.x + LEFT JOIN (SELECT 1 AS v) AS t6 ON t4a.x=t4b.x + ORDER BY 1, 2, 3; + } +} {abc abc {} 1 abc def 123 {} abc ghi {} {} def abc {} {} def def {} 1 def ghi 456 {} ghi abc {} {} ghi def {} {} ghi ghi {} 1} + finish_test From 4611d925a9e4b4609db4507a42be1c2c00d83c56 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Feb 2010 14:47:01 +0000 Subject: [PATCH 35/50] Expire pragma statements when reset, even if they were not run to completion. FossilOrigin-Name: 78351d289bba83e536b64666c566b7bfc57351da --- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/pragma.c | 7 +------ src/vdbe.h | 1 + src/vdbeInt.h | 1 + src/vdbeaux.c | 8 ++++++++ 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 94a98d047e..fde1e49c03 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Make\ssure\sthe\sON\sclause\sof\sa\sLEFT\sJOIN\sdoes\snot\scause\san\sindex\sto\sbe\nused\sto\sspeed\saccess\sto\sa\stable\sto\sthe\sleft\sof\sthe\sjoin.\nTicket\s[ebdbadade5] -D 2010-02-25T04:15:48 +C Expire\spragma\sstatements\swhen\sreset,\seven\sif\sthey\swere\snot\srun\sto\scompletion. +D 2010-02-25T14:47:02 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -161,7 +161,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 -F src/pragma.c 1ee3a5bea3e79bd4ad2519eb9745e1781bf443ea +F src/pragma.c edaded19e5a5f2c96aeab08928d6643b8de14eba F src/prepare.c c80630169d82945070a50ebf298611fd9f1485f1 F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -215,10 +215,10 @@ F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 F src/util.c 5a15aa0cc1a642aeb3ebb37c8c2bba7e1c014581 F src/vacuum.c deb50c41c39849770ab1bf27e8a35ba1036e3962 F src/vdbe.c 6de14d95ade1193f2a694ce673f69ac20032fa17 -F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2 -F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e +F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3 +F src/vdbeInt.h ae1e6ba0dd3fb4a886898d2829d748be701b01f8 F src/vdbeapi.c e0398d74af46911033b92088f740582f3c400515 -F src/vdbeaux.c 417ee0c5677188b3b72a0ccdda5668183e28bb51 +F src/vdbeaux.c 9089e0cdcc7ed3bc4564f2684ce84f5911973ea9 F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 @@ -795,14 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1168763d2cd96acfa0488198e8bc82f0c4fa35a3 -R 1756ec34ec14812b999545b49c238389 +P f0ae251abb9e8a8793f46a30b79b2ce541cf14d5 +R 8b107df37b458e983784936eaf5fdbea U drh -Z cef349c135ac8fde894db77ffb6c3cd3 +Z c22f338e59aad7a1b1c2424e3a89156a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhfl5oxKgR168RlERAuYtAJ9UCQXaWqORFlTB8prfqFcd5VDUngCcDDwZ -5GuaCQJQEFY+u7p5eZA7abU= -=4lWh +iD8DBQFLho1poxKgR168RlERAtzRAJ9394HBtSKDbf1COfLt9MZN1jx3oQCfYvjd +a+BqRtJmrba2rkJpR5hhYk4= +=hG6d -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e4b48db311..01e9522f52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0ae251abb9e8a8793f46a30b79b2ce541cf14d5 \ No newline at end of file +78351d289bba83e536b64666c566b7bfc57351da \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index e322ebd4bf..93a933c48b 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -285,6 +285,7 @@ void sqlite3Pragma( Db *pDb; Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(db); if( v==0 ) return; + sqlite3VdbeRunOnlyOnce(v); pParse->nMem = 2; /* Interpret the [database.] part of the pragma statement. iDb is the @@ -1462,12 +1463,6 @@ void sqlite3Pragma( {/* Empty ELSE clause */} - /* Code an OP_Expire at the end of each PRAGMA program to cause - ** the VDBE implementing the pragma to expire. Most (all?) pragmas - ** are only valid for a single execution. - */ - sqlite3VdbeAddOp2(v, OP_Expire, 1, 0); - /* ** Reset the safety level, in case the fullfsync flag or synchronous ** setting changed. diff --git a/src/vdbe.h b/src/vdbe.h index f67e903b85..c234d51a5b 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -182,6 +182,7 @@ void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); void sqlite3VdbeUsesBtree(Vdbe*, int); VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); int sqlite3VdbeMakeLabel(Vdbe*); +void sqlite3VdbeRunOnlyOnce(Vdbe*); void sqlite3VdbeDelete(Vdbe*); void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int); int sqlite3VdbeFinalize(Vdbe*); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index dd958cdd0a..489e8da6a7 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -301,6 +301,7 @@ struct Vdbe { u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ + u8 runOnlyOnce; /* Automatically expire on reset */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ u8 usesStmtJournal; /* True if uses a statement journal */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 98b8bf1980..3612a1aa86 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -255,6 +255,13 @@ void sqlite3VdbeResolveLabel(Vdbe *p, int x){ } } +/* +** Mark the VDBE as one that can only be run one time. +*/ +void sqlite3VdbeRunOnlyOnce(Vdbe *p){ + p->runOnlyOnce = 1; +} + #ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */ /* @@ -2228,6 +2235,7 @@ int sqlite3VdbeReset(Vdbe *p){ }else{ sqlite3Error(db, SQLITE_OK, 0); } + if( p->runOnlyOnce ) p->expired = 1; }else if( p->rc && p->expired ){ /* The expired flag was set on the VDBE before the first call ** to sqlite3_step(). For consistency (since sqlite3_step() was From 264a2d4de1201316d20112acf359d7d62010a80e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Feb 2010 15:28:41 +0000 Subject: [PATCH 36/50] Minor simplifications to the compile-time option reporting functions and pragmas to facilitate coverage testing. FossilOrigin-Name: 633d874783a94f923ff8240f9153764033d37a89 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/func.c | 5 +---- src/pragma.c | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index fde1e49c03..465b8108ef 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Expire\spragma\sstatements\swhen\sreset,\seven\sif\sthey\swere\snot\srun\sto\scompletion. -D 2010-02-25T14:47:02 +C Minor\ssimplifications\sto\sthe\scompile-time\soption\sreporting\sfunctions\sand\npragmas\sto\sfacilitate\scoverage\stesting. +D 2010-02-25T15:28:42 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -124,7 +124,7 @@ F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581 F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0 -F src/func.c d1fbbfe135a25778294c77cee031e5ced39bda72 +F src/func.c 374f45d2a5dcebc0aedc8755c2e9abe71b4e49b0 F src/global.c 5a9c1e3c93213ca574786ac1caa976ce8f709105 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -161,7 +161,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 -F src/pragma.c edaded19e5a5f2c96aeab08928d6643b8de14eba +F src/pragma.c d610d4f4fc55dca58919890fb5323d441b385362 F src/prepare.c c80630169d82945070a50ebf298611fd9f1485f1 F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -795,14 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f0ae251abb9e8a8793f46a30b79b2ce541cf14d5 -R 8b107df37b458e983784936eaf5fdbea +P 78351d289bba83e536b64666c566b7bfc57351da +R fc8b2f3b47f245eabb47345addf3c287 U drh -Z c22f338e59aad7a1b1c2424e3a89156a +Z 4e47927e3bcb66e5fb9f95fb6ecab24b -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLho1poxKgR168RlERAtzRAJ9394HBtSKDbf1COfLt9MZN1jx3oQCfYvjd -a+BqRtJmrba2rkJpR5hhYk4= -=hG6d +iD8DBQFLhpctoxKgR168RlERAqODAJ9s1JUohWfuDCMn8r6UjUKPuWx+sgCfVoJZ +FiEbzo9If4ZwffR72z1peFY= +=7Yci -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 01e9522f52..421eaf9518 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -78351d289bba83e536b64666c566b7bfc57351da \ No newline at end of file +633d874783a94f923ff8240f9153764033d37a89 \ No newline at end of file diff --git a/src/func.c b/src/func.c index f24215477c..12ee5168b4 100644 --- a/src/func.c +++ b/src/func.c @@ -790,11 +790,8 @@ static void compileoptionusedFunc( UNUSED_PARAMETER(argc); /* IMP: R-xxxx This function is an SQL wrapper around the ** sqlite3_compileoption_used() C interface. */ - if ( ( sqlite3_value_type(argv[0])==SQLITE_TEXT ) - && ( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 )){ + if( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 ){ sqlite3_result_int(context, sqlite3_compileoption_used(zOptName)); - }else{ - sqlite3_result_null(context); } } #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ diff --git a/src/pragma.c b/src/pragma.c index 93a933c48b..9a72d643c6 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1375,7 +1375,7 @@ void sqlite3Pragma( returnSingleInt(pParse, zRight, used); }else - if( sqlite3StrICmp(zLeft, "compile_options")==0 && !zRight ){ + if( sqlite3StrICmp(zLeft, "compile_options")==0 ){ int i = 0; const char *zOpt; sqlite3VdbeSetNumCols(v, 1); From 88ba618ee73be0d1bf87f16c6ca17801550ecf01 Mon Sep 17 00:00:00 2001 From: shaneh Date: Thu, 25 Feb 2010 18:07:59 +0000 Subject: [PATCH 37/50] Fixed numbering of a few tests; minor tweaks on others. Added a couple new tests to stress previous simplifications. FossilOrigin-Name: 9b18dfd19e825b09c1d246c826e179b9892308df --- manifest | 24 +++++++----------------- manifest.uuid | 2 +- test/ctime.test | 28 ++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 465b8108ef..066b3980cc 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Minor\ssimplifications\sto\sthe\scompile-time\soption\sreporting\sfunctions\sand\npragmas\sto\sfacilitate\scoverage\stesting. -D 2010-02-25T15:28:42 +C Fixed\snumbering\sof\sa\sfew\stests;\sminor\stweaks\son\sothers.\s\s\nAdded\sa\scouple\snew\stests\sto\sstress\sprevious\ssimplifications. +D 2010-02-25T18:07:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -321,7 +318,7 @@ F test/crash8.test 5b32966fcb58fd616d24ce94303420351d076eb9 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c -F test/ctime.test aa0953d27564dac33d6c3fd5903312788b7fa383 +F test/ctime.test 50e1fd7bc76a89014e27c73381e7b5ec75bb17cb F test/date.test 0b8473ed9ab6fd4283b4a01f035e1067762ba734 F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc F test/delete.test f7629d9eb245dfca170169cc5c7a735dec34aeb4 @@ -795,14 +792,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 78351d289bba83e536b64666c566b7bfc57351da -R fc8b2f3b47f245eabb47345addf3c287 -U drh -Z 4e47927e3bcb66e5fb9f95fb6ecab24b ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLhpctoxKgR168RlERAqODAJ9s1JUohWfuDCMn8r6UjUKPuWx+sgCfVoJZ -FiEbzo9If4ZwffR72z1peFY= -=7Yci ------END PGP SIGNATURE----- +P 633d874783a94f923ff8240f9153764033d37a89 +R b415f1e2575ca4e2284804631588393c +U shaneh +Z 6fde487eda25da0e582d84373048848c diff --git a/manifest.uuid b/manifest.uuid index 421eaf9518..97133aee30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -633d874783a94f923ff8240f9153764033d37a89 \ No newline at end of file +9b18dfd19e825b09c1d246c826e179b9892308df \ No newline at end of file diff --git a/test/ctime.test b/test/ctime.test index 119100778f..e94da495e4 100644 --- a/test/ctime.test +++ b/test/ctime.test @@ -110,7 +110,7 @@ do_test ctime-1.4.5 { } } {0 1} -do_test ctime-1.4 { +do_test ctime-1.5 { set ans1 [ catchsql { PRAGMA compile_option('THREADSAFE=0'); } ] @@ -120,17 +120,18 @@ do_test ctime-1.4 { lsort [ list $ans1 $ans2 ] } {{0 0} {0 1}} -do_test ctime-1.5 { +do_test ctime-1.6 { execsql { PRAGMA compile_option('THREADSAFE='); } } {0} -do_test ctime-1.6 { + +do_test ctime-1.7.1 { execsql { PRAGMA compile_option('SQLITE_OMIT_COMPILEOPTION_DIAGS'); } } {0} -do_test ctime-1.7 { +do_test ctime-1.7.2 { execsql { PRAGMA compile_option('OMIT_COMPILEOPTION_DIAGS'); } @@ -169,6 +170,21 @@ do_test ctime-2.1.6 { SELECT sqlite_compile_option_used('THREADSAFE', 0); } } {1 {wrong number of arguments to function sqlite_compile_option_used()}} +do_test ctime-2.1.7 { + catchsql { + SELECT sqlite_compile_option_used(0); + } +} {0 0} +do_test ctime-2.1.8 { + catchsql { + SELECT sqlite_compile_option_used('0'); + } +} {0 0} +do_test ctime-2.1.9 { + catchsql { + SELECT sqlite_compile_option_used(1.0); + } +} {0 0} do_test ctime-2.2.1 { catchsql { @@ -192,10 +208,10 @@ do_test ctime-2.3 { # This assumes there is at least 1 compile time option # (see SQLITE_THREADSAFE above). do_test ctime-2.4 { - set res [ catchsql { + set ans [ catchsql { SELECT sqlite_compile_option_get(0); } ] - list [lindex $res 0] + list [lindex $ans 0] } {0} # Get the list of defines using the pragma, From 887d4b2b43435b3b92416e0a186a14cd8d085763 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 25 Feb 2010 12:09:16 +0000 Subject: [PATCH 38/50] Add experimental fix for corruption detection problem. This may well be revised yet. FossilOrigin-Name: 1cc4be7ebc463921827e61da724f0de946c061f6 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 20 +++++++++++++++++++- test/corrupt.test | 22 ++++++++++++++++++++-- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 066b3980cc..672b547a75 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixed\snumbering\sof\sa\sfew\stests;\sminor\stweaks\son\sothers.\s\s\nAdded\sa\scouple\snew\stests\sto\sstress\sprevious\ssimplifications. -D 2010-02-25T18:07:59 +C Add\sexperimental\sfix\sfor\scorruption\sdetection\sproblem.\sThis\smay\swell\sbe\srevised\syet. +D 2010-02-25T12:09:16 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -109,7 +109,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c ae804d16fb1ed8d3a0087b0fba2dcf37f312275c +F src/btree.c 0fc16c6faa2358ad5d892da528cedaade06b70e4 F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 254a273acb8923f3bdecc933d787f4f67737c489 @@ -292,7 +292,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 087c42997754b8c648819832241daf724f813322 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 0ed68b11f22721052d880ee80bd528a0e0828236 -F test/corrupt.test 85c3fececa01bc6d24ff5d7bf1373844840c0b98 +F test/corrupt.test f413a96e5f7a3df55529a530339c5194efce59e0 F test/corrupt2.test a571e30ea4e82318f319a24b6cc55935ce862079 F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32 F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff @@ -792,7 +792,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 633d874783a94f923ff8240f9153764033d37a89 -R b415f1e2575ca4e2284804631588393c -U shaneh -Z 6fde487eda25da0e582d84373048848c +P 9b18dfd19e825b09c1d246c826e179b9892308df +R eafa7db6f5fb13e5c1fd5ab7d385d1ec +U dan +Z 4907aa0adf782240299c0dcbeaf7f20b diff --git a/manifest.uuid b/manifest.uuid index 97133aee30..4335db5716 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b18dfd19e825b09c1d246c826e179b9892308df \ No newline at end of file +1cc4be7ebc463921827e61da724f0de946c061f6 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 3d0e313f7a..7daeacd5e8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5061,7 +5061,25 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){ rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext); if( rc ) return rc; } - rc = freePage2(pBt, pOvfl, ovflPgno); + + if( (pOvfl || (pOvfl = btreePageLookup(pBt, ovflPgno))) + && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1 + ){ + /* There is no reason any cursor should have an outstanding reference + ** to an overflow page belonging to a cell that is being deleted/updated. + ** So if there exists more than one reference to this page, then it + ** must not really be an overflow page and the database must be corrupt. + ** It is helpful to detect this before calling freePage2(), as + ** freePage2() may zero the page contents if secure-delete mode is + ** enabled. If this 'overflow' page happens to be a page that the + ** caller is iterating through or using in some other way, this + ** can be problematic. + */ + rc = SQLITE_CORRUPT_BKPT; + }else{ + rc = freePage2(pBt, pOvfl, ovflPgno); + } + if( pOvfl ){ sqlite3PagerUnref(pOvfl->pDbPage); } diff --git a/test/corrupt.test b/test/corrupt.test index be6236ea37..1d3b5cfad9 100644 --- a/test/corrupt.test +++ b/test/corrupt.test @@ -1,4 +1,4 @@ -# 2004 August 30 +# 2004 August 30 {} # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -71,7 +71,7 @@ set junk [string range $junk 0 255] # of the file. Then do various operations on the file to make sure that # the database engine can recover gracefully from the corruption. # -for {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} { +for {set i [expr {1*256}]} {0 && $i<$fsize-256} {incr i 256} { set tn [expr {$i/256}] db close copy_file test.bu test.db @@ -311,4 +311,22 @@ ifcapable oversize_cell_check { } {1 {database disk image is malformed}} } +db close +file delete -force test.db test.db-journal +do_test corrupt-8.1 { + sqlite3 db test.db + execsql { + PRAGMA page_size = 1024; + PRAGMA secure_delete = on; + PRAGMA auto_vacuum = 0; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y); + INSERT INTO t1 VALUES(5, randomblob(1900)); + } + + hexio_write test.db 2044 [hexio_render_int32 2] + hexio_write test.db 24 [hexio_render_int32 45] + + catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) } +} {1 {database disk image is malformed}} + finish_test From bee8065e3752b38945f0757036f749aea6458f03 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Feb 2010 21:27:58 +0000 Subject: [PATCH 39/50] Test coverage enhancements. Additional documentation detail on the new sqlite3_log() interface. FossilOrigin-Name: d986e9289388fd72257b26cb2f9c972177255cd4 --- manifest | 28 +++++++++++++++++++--------- manifest.uuid | 2 +- src/printf.c | 2 +- src/sqlite.h.in | 4 ++++ src/vdbeapi.c | 6 ++---- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 672b547a75..0541a4bac6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Add\sexperimental\sfix\sfor\scorruption\sdetection\sproblem.\sThis\smay\swell\sbe\srevised\syet. -D 2010-02-25T12:09:16 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Test\scoverage\senhancements.\s\sAdditional\sdocumentation\sdetail\son\sthe\snew\nsqlite3_log()\sinterface. +D 2010-02-25T21:27:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -160,13 +163,13 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 F src/pragma.c d610d4f4fc55dca58919890fb5323d441b385362 F src/prepare.c c80630169d82945070a50ebf298611fd9f1485f1 -F src/printf.c f5c160b471e4a4dd22b756cb4ffe0c6979fd6d24 +F src/printf.c aa793722d793520fa31c54d81ddab26b0b410562 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 4113ef360430ed4e7533690ef46d06c20204adce F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 -F src/sqlite.h.in a9f51302109f32e3048358122d1e38fd3ead593f +F src/sqlite.h.in 336ed7bab1080e7e63d5fc48e39bd3fa995da6f0 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h 32e6eb47d2f6fad587e16b0abbbfe3f7d55f2ec0 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 @@ -214,7 +217,7 @@ F src/vacuum.c deb50c41c39849770ab1bf27e8a35ba1036e3962 F src/vdbe.c 6de14d95ade1193f2a694ce673f69ac20032fa17 F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3 F src/vdbeInt.h ae1e6ba0dd3fb4a886898d2829d748be701b01f8 -F src/vdbeapi.c e0398d74af46911033b92088f740582f3c400515 +F src/vdbeapi.c 74c25680046a116b24b95393914d3669c23305dc F src/vdbeaux.c 9089e0cdcc7ed3bc4564f2684ce84f5911973ea9 F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9 @@ -792,7 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9b18dfd19e825b09c1d246c826e179b9892308df -R eafa7db6f5fb13e5c1fd5ab7d385d1ec -U dan -Z 4907aa0adf782240299c0dcbeaf7f20b +P 1cc4be7ebc463921827e61da724f0de946c061f6 +R 1c73afd7cbcdebdb258490d2c24799bd +U drh +Z 275be1edf4f26aa0d7cebaa1746de83b +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLhutjoxKgR168RlERAlrFAJoC7p9doKclaKmbSgjogvOsoOZUUQCeLm7H +KHa6uF4qzTRfmkYuWOIa0Ao= +=0tVZ +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4335db5716..347e5ffb6b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1cc4be7ebc463921827e61da724f0de946c061f6 \ No newline at end of file +d986e9289388fd72257b26cb2f9c972177255cd4 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 081289417a..e67d48ee17 100644 --- a/src/printf.c +++ b/src/printf.c @@ -949,7 +949,7 @@ void sqlite3_log(int iErrCode, const char *zFormat, ...){ char *zMsg; /* Complete log message */ xLog = sqlite3GlobalConfig.xLog; - if( xLog && zFormat ){ + if( xLog ){ va_start(ap, zFormat); sqlite3BeginBenignMalloc(); zMsg = sqlite3_vmprintf(zFormat, ap); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 37c8df2014..178824b8e3 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5696,11 +5696,15 @@ int sqlite3_strnicmp(const char *, const char *, int); ** ** ^The [sqlite3_log()] interface writes a message into the error log ** established by the [SQLITE_CONFIG_ERRORLOG] option to [sqlite3_config()]. +** ^If logging is enabled, the zFormat string and subsequent arguments are +** passed through to [sqlite3_vmprintf()] to generate the final output string. ** ** The sqlite3_log() interface is intended for use by extensions such as ** virtual tables, collating functions, and SQL functions. While there is ** nothing to prevent an application from calling sqlite3_log(), doing so ** is considered bad form. +** +** The zFormat string must not be NULL. */ void sqlite3_log(int iErrCode, const char *zFormat, ...); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index aac898a82a..125f325d18 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -334,9 +334,7 @@ static int sqlite3Step(Vdbe *p){ } if( p->pc<=0 && p->expired ){ - if( p->rc==SQLITE_OK ){ - p->rc = SQLITE_SCHEMA; - } + p->rc = SQLITE_SCHEMA; rc = SQLITE_ERROR; goto end_of_step; } @@ -435,7 +433,7 @@ int sqlite3_step(sqlite3_stmt *pStmt){ sqlite3_reset(pStmt); v->expired = 0; } - if( rc2!=SQLITE_OK && v->isPrepareV2 && db->pErr ){ + if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ /* This case occurs after failing to recompile an sql statement. ** The error message from the SQL compiler has already been loaded ** into the database handle. This block copies the error message From e294da02ba631a0a4ab7575c2714c6543cd64a64 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Feb 2010 23:44:15 +0000 Subject: [PATCH 40/50] Fix to the database connection validity checker. Other test coverage enhancements. FossilOrigin-Name: 0f6291bbbd31673e2a65f38c7fc364c33719d25e --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/build.c | 2 +- src/util.c | 4 +++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 0541a4bac6..bd63d3549a 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Test\scoverage\senhancements.\s\sAdditional\sdocumentation\sdetail\son\sthe\snew\nsqlite3_log()\sinterface. -D 2010-02-25T21:27:59 +C Fix\sto\sthe\sdatabase\sconnection\svalidity\schecker.\s\sOther\stest\scoverage\nenhancements. +D 2010-02-25T23:44:15 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -115,7 +115,7 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 0fc16c6faa2358ad5d892da528cedaade06b70e4 F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 -F src/build.c 254a273acb8923f3bdecc933d787f4f67737c489 +F src/build.c 11100b66fb97638d2d874c1d34d8db90650bb1d7 F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ceb247eb31620bba66a94c3f697db489a1652353 @@ -212,7 +212,7 @@ F src/tokenize.c 25ceb0f0a746ea1d0f9553787f3f0a56853cfaeb F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 -F src/util.c 5a15aa0cc1a642aeb3ebb37c8c2bba7e1c014581 +F src/util.c 0a28d634d41031be63da19cc7cdfbc4a7e0bfea6 F src/vacuum.c deb50c41c39849770ab1bf27e8a35ba1036e3962 F src/vdbe.c 6de14d95ade1193f2a694ce673f69ac20032fa17 F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3 @@ -795,14 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1cc4be7ebc463921827e61da724f0de946c061f6 -R 1c73afd7cbcdebdb258490d2c24799bd +P d986e9289388fd72257b26cb2f9c972177255cd4 +R af8ab02c230217b95a74eec41f7db4ef U drh -Z 275be1edf4f26aa0d7cebaa1746de83b +Z 92bbdbd809aca6154a1ba44c761f4d15 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLhutjoxKgR168RlERAlrFAJoC7p9doKclaKmbSgjogvOsoOZUUQCeLm7H -KHa6uF4qzTRfmkYuWOIa0Ao= -=0tVZ +iD8DBQFLhwtSoxKgR168RlERAiPdAJ9I+vTQM4qOnnLxOSTsB57ZAynIbwCggZiC +VIO6ZAEyzKFZ08ul9s3wUMk= +=f8rU -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 347e5ffb6b..a7735b3eaa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d986e9289388fd72257b26cb2f9c972177255cd4 \ No newline at end of file +0f6291bbbd31673e2a65f38c7fc364c33719d25e \ No newline at end of file diff --git a/src/build.c b/src/build.c index 9f32876d0b..8e343864fa 100644 --- a/src/build.c +++ b/src/build.c @@ -202,7 +202,7 @@ void sqlite3FinishCoding(Parse *pParse){ pParse->isMultiWrite && pParse->mayAbort); pParse->rc = SQLITE_DONE; pParse->colNamesSet = 0; - }else if( pParse->rc==SQLITE_OK ){ + }else{ pParse->rc = SQLITE_ERROR; } pParse->nTab = 0; diff --git a/src/util.c b/src/util.c index 4c635c6452..647ecb9029 100644 --- a/src/util.c +++ b/src/util.c @@ -1043,7 +1043,8 @@ int sqlite3SafetyCheckOk(sqlite3 *db){ } magic = db->magic; if( magic!=SQLITE_MAGIC_OPEN ){ - if( !sqlite3SafetyCheckSickOrOk(db) ){ + if( sqlite3SafetyCheckSickOrOk(db) ){ + testcase( sqlite3GlobalConfig.xLog!=0 ); logBadConnection("unopened"); } return 0; @@ -1057,6 +1058,7 @@ int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ if( magic!=SQLITE_MAGIC_SICK && magic!=SQLITE_MAGIC_OPEN && magic!=SQLITE_MAGIC_BUSY ){ + testcase( sqlite3GlobalConfig.xLog!=0 ); logBadConnection("invalid"); return 0; }else{ From 84f4b2f237b10580cb6e9bd42a1d32b588e863ab Mon Sep 17 00:00:00 2001 From: shaneh Date: Fri, 26 Feb 2010 01:46:54 +0000 Subject: [PATCH 41/50] Minor changes to silence some compiler warnings with MSVC. FossilOrigin-Name: 4927c62d6214d93e582bf1266215ed3519630c15 --- ext/fts3/fts3_snippet.c | 7 ++++++- ext/fts3/fts3_write.c | 6 ++++-- manifest | 30 ++++++++++-------------------- manifest.uuid | 2 +- src/btree.c | 4 ++-- src/vdbe.c | 2 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 8b8a67380d..d78d19856a 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -213,6 +213,8 @@ static int fts3ExprLoadDoclistsCb1(Fts3Expr *pExpr, int iPhrase, void *ctx){ int rc = SQLITE_OK; LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; + UNUSED_PARAMETER(iPhrase); + p->nPhrase++; p->nToken += pExpr->pPhrase->nToken; @@ -233,6 +235,8 @@ static int fts3ExprLoadDoclistsCb1(Fts3Expr *pExpr, int iPhrase, void *ctx){ ** fts3ExprLoadDoclists(). */ static int fts3ExprLoadDoclistsCb2(Fts3Expr *pExpr, int iPhrase, void *ctx){ + UNUSED_PARAMETER(iPhrase); + UNUSED_PARAMETER(ctx); if( pExpr->aDoclist ){ pExpr->pCurrent = pExpr->aDoclist; pExpr->iCurrent = 0; @@ -522,7 +526,7 @@ static int fts3StringAppend( int nAppend /* Size of zAppend in bytes (or -1) */ ){ if( nAppend<0 ){ - nAppend = strlen(zAppend); + nAppend = (int)strlen(zAppend); } /* If there is insufficient space allocated at StrBuffer.z, use realloc() @@ -1024,6 +1028,7 @@ static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){ char *pList; /* Pointer to position list for phrase */ int iPos = 0; /* First position in position-list */ + UNUSED_PARAMETER(iPhrase); pList = sqlite3Fts3FindPositions(pExpr, p->iDocid, p->iCol); nTerm = pExpr->pPhrase->nToken; if( pList ){ diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index e30aef7116..23b8866049 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -2274,9 +2274,11 @@ static void fts3DecodeIntArray( int nBuf /* size of the BLOB */ ){ int i, j; + UNUSED_PARAMETER(nBuf); for(i=j=0; inColumn+1) ); + memset(a, 0, sizeof(u32)*(p->nColumn+1) ); } sqlite3_reset(pStmt); - if( nChng<0 && a[0]<-nChng ){ + if( nChng<0 && a[0]<(u32)(-nChng) ){ a[0] = 0; }else{ a[0] += nChng; diff --git a/manifest b/manifest index bd63d3549a..dc221a18c5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Fix\sto\sthe\sdatabase\sconnection\svalidity\schecker.\s\sOther\stest\scoverage\nenhancements. -D 2010-02-25T23:44:15 +C Minor\schanges\sto\ssilence\ssome\scompiler\swarnings\swith\sMSVC. +D 2010-02-26T01:46:54 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -67,11 +64,11 @@ F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295 F ext/fts3/fts3_porter.c 7546e4503e286a67fd4f2a82159620e3e9c7a1bc -F ext/fts3/fts3_snippet.c 9cba9a321fbea2e73a2de8cdd0003e4b1717130c +F ext/fts3/fts3_snippet.c 9cb2e78f4d09f30ea7861ee3fc9b7221ae948c8e F ext/fts3/fts3_tokenizer.c 1a49ee3d79cbf0b9386250370d9cbfe4bb89c8ff F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c b6d86d1d750787db5c168c73da4e87670ed890a1 -F ext/fts3/fts3_write.c 26b1151e601aee83adf82e8727bb896e4b91ce4b +F ext/fts3/fts3_write.c bff9bea026d6e627ab8e78e2ade310981128e0bd F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33 F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2 @@ -112,7 +109,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c 0fc16c6faa2358ad5d892da528cedaade06b70e4 +F src/btree.c fa6f583496cd84a1490d7b51231679a7b1707555 F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 11100b66fb97638d2d874c1d34d8db90650bb1d7 @@ -214,7 +211,7 @@ F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052 F src/util.c 0a28d634d41031be63da19cc7cdfbc4a7e0bfea6 F src/vacuum.c deb50c41c39849770ab1bf27e8a35ba1036e3962 -F src/vdbe.c 6de14d95ade1193f2a694ce673f69ac20032fa17 +F src/vdbe.c 8b705e48cf4b6d0493ad0f109763d60c1b429487 F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3 F src/vdbeInt.h ae1e6ba0dd3fb4a886898d2829d748be701b01f8 F src/vdbeapi.c 74c25680046a116b24b95393914d3669c23305dc @@ -795,14 +792,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d986e9289388fd72257b26cb2f9c972177255cd4 -R af8ab02c230217b95a74eec41f7db4ef -U drh -Z 92bbdbd809aca6154a1ba44c761f4d15 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLhwtSoxKgR168RlERAiPdAJ9I+vTQM4qOnnLxOSTsB57ZAynIbwCggZiC -VIO6ZAEyzKFZ08ul9s3wUMk= -=f8rU ------END PGP SIGNATURE----- +P 0f6291bbbd31673e2a65f38c7fc364c33719d25e +R 0416664a3dc7f6b03e53bf4af7ac78bd +U shaneh +Z ea521e1682af37a17d6d1d2bff6e15f9 diff --git a/manifest.uuid b/manifest.uuid index a7735b3eaa..bdbc2c0350 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f6291bbbd31673e2a65f38c7fc364c33719d25e \ No newline at end of file +4927c62d6214d93e582bf1266215ed3519630c15 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7daeacd5e8..a54366241a 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4928,8 +4928,8 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){ /* If the secure_delete option is enabled, then ** always fully overwrite deleted information with zeros. */ - if( (!pPage && (rc = btreeGetPage(pBt, iPage, &pPage, 0))) - || (rc = sqlite3PagerWrite(pPage->pDbPage)) + if( (!pPage && ((rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0) ) + || ((rc = sqlite3PagerWrite(pPage->pDbPage))!=0) ){ goto freepage_out; } diff --git a/src/vdbe.c b/src/vdbe.c index 746be2aae4..7eae498985 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -538,7 +538,7 @@ static int checkSavepointCount(sqlite3 *db){ int sqlite3VdbeExec( Vdbe *p /* The VDBE */ ){ - int pc; /* The program counter */ + int pc=0; /* The program counter */ Op *aOp = p->aOp; /* Copy of p->aOp */ Op *pOp; /* Current operation */ int rc = SQLITE_OK; /* Value to return */ From 0d06d98980982e839a329470d2677424dcfa8fed Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 26 Feb 2010 12:58:50 +0000 Subject: [PATCH 42/50] Increase the version number to 3.6.23 in preparation for the next release. FossilOrigin-Name: b5835d3e3d7f3fbf04431f9afe27dfef7b7f23c9 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 26 ++++++++++++++++++-------- manifest.uuid | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) mode change 100644 => 100755 configure diff --git a/VERSION b/VERSION index 4cc5902cfc..2d6744e051 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.6.22 +3.6.23 diff --git a/configure b/configure old mode 100644 new mode 100755 index 5ce6104f00..a95c3b3c29 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.6.22. +# Generated by GNU Autoconf 2.62 for sqlite 3.6.23. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.6.22' -PACKAGE_STRING='sqlite 3.6.22' +PACKAGE_VERSION='3.6.23' +PACKAGE_STRING='sqlite 3.6.23' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1487,7 +1487,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.6.22 to adapt to many kinds of systems. +\`configure' configures sqlite 3.6.23 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1552,7 +1552,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.6.22:";; + short | recursive ) echo "Configuration of sqlite 3.6.23:";; esac cat <<\_ACEOF @@ -1670,7 +1670,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.6.22 +sqlite configure 3.6.23 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1684,7 +1684,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.6.22, which was +It was created by sqlite $as_me 3.6.23, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -13972,7 +13972,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.6.22, which was +This file was extended by sqlite $as_me 3.6.23, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14025,7 +14025,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.6.22 +sqlite config.status 3.6.23 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/manifest b/manifest index dc221a18c5..2f8a1bdf74 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,14 @@ -C Minor\schanges\sto\ssilence\ssome\scompiler\swarnings\swith\sMSVC. -D 2010-02-26T01:46:54 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Increase\sthe\sversion\snumber\sto\s3.6.23\sin\spreparation\sfor\sthe\snext\srelease. +D 2010-02-26T12:58:51 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.vxworks ab005d301296c40e021ccd0133ce49ca811e319f F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 -F VERSION 2f8d921ecf804e9eb01e836a09512d0318ebd4d3 +F VERSION 3e18b3dd7290883913c25d66c0ddb409ce318654 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 17dc593f791f874d2c23a0f9360850ded0286531 F art/2005osaward.gif 0d1851b2a7c1c9d0ccce545f3e14bca42d7fd248 @@ -19,7 +22,7 @@ F art/src_logo.gif 9341ef09f0e53cd44c0c9b6fc3c16f7f3d6c2ad9 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 868fdb48c028421a203470e15c69ada15b9ba673 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 8bcd25791aa958ecb255385d1c2d91ab1c5acd93 +F configure 72c0ad7c8cfabbffeaf8ca61e1d24143cf857eb2 x F configure.ac 14740970ddb674d92a9f5da89083dff1179014ff F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 @@ -792,7 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0f6291bbbd31673e2a65f38c7fc364c33719d25e -R 0416664a3dc7f6b03e53bf4af7ac78bd -U shaneh -Z ea521e1682af37a17d6d1d2bff6e15f9 +P 4927c62d6214d93e582bf1266215ed3519630c15 +R af4a7e45e4a4a9405e99108a38202106 +U drh +Z 3162c30bb0f99d38c354b0e173e5f3de +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLh8WRoxKgR168RlERAhAqAJ0QiRyipYMpY436kmCSp0ScHxdx9gCeLtq3 +QFma8bnc+p2xYKTQw6Gq194= +=XP77 +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index bdbc2c0350..4d950516a0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4927c62d6214d93e582bf1266215ed3519630c15 \ No newline at end of file +b5835d3e3d7f3fbf04431f9afe27dfef7b7f23c9 \ No newline at end of file From 383d30f48392d64e1a27789f4e8b8fe8fb95bdd2 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 26 Feb 2010 13:07:37 +0000 Subject: [PATCH 43/50] Avoid incorrect compiler warnings by doing a couple of needless variable initializations. FossilOrigin-Name: 8f29490da62df07ea922b03cab52b6edd2669edb --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/btree.c | 2 +- src/os_unix.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 2f8a1bdf74..4035effaba 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Increase\sthe\sversion\snumber\sto\s3.6.23\sin\spreparation\sfor\sthe\snext\srelease. -D 2010-02-26T12:58:51 +C Avoid\sincorrect\scompiler\swarnings\sby\sdoing\sa\scouple\sof\sneedless\nvariable\sinitializations. +D 2010-02-26T13:07:37 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -112,7 +112,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c fa6f583496cd84a1490d7b51231679a7b1707555 +F src/btree.c 65359edf313363a84a8d951a211873ad16ede53a F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 11100b66fb97638d2d874c1d34d8db90650bb1d7 @@ -153,7 +153,7 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306 F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30 F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f -F src/os_unix.c 79f2b9aec313d3e168e52b3527578c22a251bc63 +F src/os_unix.c 97c2d5dd1015c35aabef8f18399c28bb9bcb7664 F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053 F src/pager.c ace73a84f53a551fb8b9334205af210a29874b2c F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54 @@ -795,14 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 4927c62d6214d93e582bf1266215ed3519630c15 -R af4a7e45e4a4a9405e99108a38202106 +P b5835d3e3d7f3fbf04431f9afe27dfef7b7f23c9 +R feb7fcb2626a9c46d3d79459fa07572c U drh -Z 3162c30bb0f99d38c354b0e173e5f3de +Z 93c6029ace8e0b4c79551ba55a03f862 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLh8WRoxKgR168RlERAhAqAJ0QiRyipYMpY436kmCSp0ScHxdx9gCeLtq3 -QFma8bnc+p2xYKTQw6Gq194= -=XP77 +iD8DBQFLh8ecoxKgR168RlERAq/AAJ4kRAjfg0SA3XpKduC7rNmZht37jwCeOopy +3XEDjK4K1rR5rmo2LEX+6NQ= +=Fiyc -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4d950516a0..b7775b5722 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b5835d3e3d7f3fbf04431f9afe27dfef7b7f23c9 \ No newline at end of file +8f29490da62df07ea922b03cab52b6edd2669edb \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index a54366241a..827eceb17f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5323,7 +5323,7 @@ static void insertCell( Pgno iChild, /* If non-zero, replace first 4 bytes with this value */ int *pRC /* Read and write return code from here */ ){ - int idx; /* Where to write new cell content in data[] */ + int idx = 0; /* Where to write new cell content in data[] */ int j; /* Loop counter */ int end; /* First byte past the last cell pointer in data[] */ int ins; /* Index in data[] where new cell pointer is inserted */ diff --git a/src/os_unix.c b/src/os_unix.c index 1cce7dac10..88263df664 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1248,7 +1248,7 @@ static int unixLock(sqlite3_file *id, int locktype){ struct unixLockInfo *pLock = pFile->pLock; struct flock lock; int s = 0; - int tErrno; + int tErrno = 0; assert( pFile ); OSTRACE7("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h, From 2ed11e7b18ead8e903ad47b2a6fe9341b81f9e82 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Feb 2010 15:09:19 +0000 Subject: [PATCH 44/50] Avoid a buffer overwrite that can occur with a corrupt database if secure-delete is enabled. FossilOrigin-Name: 7bdb1e05faceddbb0b8e3efee7d070ad8c4611a3 --- manifest | 26 ++++++++------------------ manifest.uuid | 2 +- src/btree.c | 11 +++++++++-- test/corrupt.test | 21 ++++++++++++++++++++- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 4035effaba..3dbc1246f5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Avoid\sincorrect\scompiler\swarnings\sby\sdoing\sa\scouple\sof\sneedless\nvariable\sinitializations. -D 2010-02-26T13:07:37 +C Avoid\sa\sbuffer\soverwrite\sthat\scan\soccur\swith\sa\scorrupt\sdatabase\sif\ssecure-delete\sis\senabled. +D 2010-02-26T15:09:20 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -112,7 +109,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff -F src/btree.c 65359edf313363a84a8d951a211873ad16ede53a +F src/btree.c 22bcd5cbc53a1f9ce4b39763aaf43a7333d9346b F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa F src/btreeInt.h 71ed5e7f009caf17b7dc304350b3cb64b5970135 F src/build.c 11100b66fb97638d2d874c1d34d8db90650bb1d7 @@ -295,7 +292,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 087c42997754b8c648819832241daf724f813322 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 0ed68b11f22721052d880ee80bd528a0e0828236 -F test/corrupt.test f413a96e5f7a3df55529a530339c5194efce59e0 +F test/corrupt.test 0d346c9fe064ca71281685a8a732fcc83461bb99 F test/corrupt2.test a571e30ea4e82318f319a24b6cc55935ce862079 F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32 F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff @@ -795,14 +792,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b5835d3e3d7f3fbf04431f9afe27dfef7b7f23c9 -R feb7fcb2626a9c46d3d79459fa07572c -U drh -Z 93c6029ace8e0b4c79551ba55a03f862 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLh8ecoxKgR168RlERAq/AAJ4kRAjfg0SA3XpKduC7rNmZht37jwCeOopy -3XEDjK4K1rR5rmo2LEX+6NQ= -=Fiyc ------END PGP SIGNATURE----- +P 8f29490da62df07ea922b03cab52b6edd2669edb +R 7b8c852b73b99027be1973f856f673bb +U dan +Z 2b638b55505849de93efc222bb43dd70 diff --git a/manifest.uuid b/manifest.uuid index b7775b5722..683efb2340 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f29490da62df07ea922b03cab52b6edd2669edb \ No newline at end of file +7bdb1e05faceddbb0b8e3efee7d070ad8c4611a3 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 827eceb17f..cf21b025fc 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5815,8 +5815,15 @@ static int balance_nonroot( ** buffer. It will be copied out again as soon as the aSpace[] buffer ** is allocated. */ if( pBt->secureDelete ){ - memcpy(&aOvflSpace[apDiv[i]-pParent->aData], apDiv[i], szNew[i]); - apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData]; + int iOff = apDiv[i] - pParent->aData; + if( (iOff+szNew[i])>pBt->usableSize ){ + rc = SQLITE_CORRUPT_BKPT; + memset(apOld, 0, (i+1)*sizeof(MemPage*)); + goto balance_cleanup; + }else{ + memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); + apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData]; + } } dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc); } diff --git a/test/corrupt.test b/test/corrupt.test index 1d3b5cfad9..fc84033fc4 100644 --- a/test/corrupt.test +++ b/test/corrupt.test @@ -71,7 +71,7 @@ set junk [string range $junk 0 255] # of the file. Then do various operations on the file to make sure that # the database engine can recover gracefully from the corruption. # -for {set i [expr {1*256}]} {0 && $i<$fsize-256} {incr i 256} { +for {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} { set tn [expr {$i/256}] db close copy_file test.bu test.db @@ -329,4 +329,23 @@ do_test corrupt-8.1 { catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) } } {1 {database disk image is malformed}} +db close +file delete -force test.db test.db-journal +do_test corrupt-8.2 { + sqlite3 db test.db + execsql { + PRAGMA page_size = 1024; + PRAGMA secure_delete = on; + PRAGMA auto_vacuum = 0; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y); + INSERT INTO t1 VALUES(5, randomblob(900)); + INSERT INTO t1 VALUES(6, randomblob(900)); + } + + hexio_write test.db 2047 FF + hexio_write test.db 24 [hexio_render_int32 45] + + catchsql { INSERT INTO t1 VALUES(4, randomblob(1900)) } +} {1 {database disk image is malformed}} + finish_test From 71caabf0cc0c163472cd59c13fd7b96de64e171e Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 26 Feb 2010 15:39:24 +0000 Subject: [PATCH 45/50] Remove the compile_option pragma (retaining compile_options - with an "s"). Updates to documentation. FossilOrigin-Name: 733778df996a2dda7c31ff7b544cb6f9a6ed4c97 --- manifest | 26 ++++++++++++++++++-------- manifest.uuid | 2 +- src/pragma.c | 12 ++---------- src/sqlite.h.in | 10 +++++----- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 3dbc1246f5..16b8c54fa9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Avoid\sa\sbuffer\soverwrite\sthat\scan\soccur\swith\sa\scorrupt\sdatabase\sif\ssecure-delete\sis\senabled. -D 2010-02-26T15:09:20 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Remove\sthe\scompile_option\spragma\s(retaining\scompile_options\s-\swith\san\s"s").\nUpdates\sto\sdocumentation. +D 2010-02-26T15:39:24 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -158,7 +161,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8 -F src/pragma.c d610d4f4fc55dca58919890fb5323d441b385362 +F src/pragma.c 56d95f76154a5f873c32eae485bb625f3c70be46 F src/prepare.c c80630169d82945070a50ebf298611fd9f1485f1 F src/printf.c aa793722d793520fa31c54d81ddab26b0b410562 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -166,7 +169,7 @@ F src/resolve.c a1648d98e869937b29f4f697461fe4d60f220a7b F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 4113ef360430ed4e7533690ef46d06c20204adce F src/shell.c 31cd555125a1fda4a6d8dce019690f043a8e5d75 -F src/sqlite.h.in 336ed7bab1080e7e63d5fc48e39bd3fa995da6f0 +F src/sqlite.h.in 8793d52e7d4e1124dc3cc94ff56376a97b67965f F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h 32e6eb47d2f6fad587e16b0abbbfe3f7d55f2ec0 F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6 @@ -792,7 +795,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8f29490da62df07ea922b03cab52b6edd2669edb -R 7b8c852b73b99027be1973f856f673bb -U dan -Z 2b638b55505849de93efc222bb43dd70 +P 7bdb1e05faceddbb0b8e3efee7d070ad8c4611a3 +R 166632f05beccd6e33784984b6d9675d +U drh +Z ed08651f41dc2c7225f33203915e8063 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFLh+svoxKgR168RlERArQvAJ95o9BxgjMp3G3ev6cCRTv/xZJZmgCdEowj +KQEVfyphDS5oiwkCBBNOI7Q= +=1Xz8 +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 683efb2340..c0089ea99e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7bdb1e05faceddbb0b8e3efee7d070ad8c4611a3 \ No newline at end of file +733778df996a2dda7c31ff7b544cb6f9a6ed4c97 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 9a72d643c6..bd96e47c18 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1363,18 +1363,10 @@ void sqlite3Pragma( #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* ** PRAGMA compile_options - ** PRAGMA compile_option(