]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem in the shell tool. In some cases sqlite3_errmsg() was being called...
authordan <dan@noemail.net>
Tue, 5 Jan 2010 04:59:56 +0000 (04:59 +0000)
committerdan <dan@noemail.net>
Tue, 5 Jan 2010 04:59:56 +0000 (04:59 +0000)
FossilOrigin-Name: e5d07045fabe0803715cfb291aa9e971235cb08a

manifest
manifest.uuid
src/shell.c
tool/shell1.test
tool/shell2.test

index 3ac9c70913cbdd6e900b10cc4368f2bcee9c1c3f..b9482c2f6d2734e09a09e53cf3e8da0b589985de 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C In\sthe\sdebugging\smemory\sallocator,\sinitialize\snew\smemory\sallocations\sto\npseudo-randomness\sin\san\seffort\sto\sfind\sproblems\swith\smemcmp()\sof\sstructures\nthat\shave\suninitialized\spad\sbytes.
-D 2010-01-05T03:30:15
+C Fix\sa\sproblem\sin\sthe\sshell\stool.\sIn\ssome\scases\ssqlite3_errmsg()\swas\sbeing\scalled\sbefore\ssqlite3_finalize(),\scausing\serror\smessages\sto\sbe\smore\sgeneric\sthan\sthey\sshould\sbe.
+D 2010-01-05T04:59:57
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -166,7 +163,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
 F src/resolve.c 69a45df25039eb58e321653914ad670ffe49d486
 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
 F src/select.c 0109b993c360d649857523abb72919e1794f9b45
-F src/shell.c b9fae60b0f2ce306c20fa99e83c75023bf35f15b
+F src/shell.c b95c5fcfe458027f192914a47474652969a1ec0f
 F src/sqlite.h.in d493cf5029de67fe7252324473d89140a007a6c4
 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
 F src/sqliteInt.h d6c48b1a5cd6485151e1d1b071dbe0a85ceb70fe
@@ -772,8 +769,8 @@ F tool/mksqlite3h.tcl eb100dce83f24b501b325b340f8b5eb8e5106b3b
 F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
 F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a
 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
-F tool/shell1.test e71c1a177f07e1987996479fa57ab7b3e18c93de
-F tool/shell2.test 2cfb66b5ad2f83fea0f8de93f45224ca1e7ac371
+F tool/shell1.test ef08a3e738b9fee4fc228920956950bc35db0575
+F tool/shell2.test 91824fff77514b6b00227744c475c09c34134a4e
 F tool/shell3.test ff663e83100670a295d473515c12beb8103a78b6
 F tool/showdb.c 8ab8b3b53884312aafb7ef60982e255a6c31d238
 F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
@@ -786,14 +783,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P e02f25560216c7c96c5e1c7e71a8531650b3a96f
-R 0a313dee315b72c3b419645fb9cfd73c
-U drh
-Z 4d3d5214f091be48926cc62b09c41b4c
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFLQrJKoxKgR168RlERAlC8AJwOg5AslX/pB3YH7ewA4+9wmshQXQCfdzWI
-f4ZfaOxedp3VuJNU/z/Hj64=
-=6YvT
------END PGP SIGNATURE-----
+P 6462817b2f817a6105449b0ea3e1e336e42571d1
+R 9bce1ef60ed204cfc7f1e0bb2bf15d25
+U dan
+Z 8e70d59d100b7e6a49e556eb5a97a125
index 555e1c55a9d78e47352a67f7a1c615db79ceccb8..1e0ac3b9842232d8ac86802140da62c16a9aa563 100644 (file)
@@ -1 +1 @@
-6462817b2f817a6105449b0ea3e1e336e42571d1
\ No newline at end of file
+e5d07045fabe0803715cfb291aa9e971235cb08a
\ No newline at end of file
index 621ff1252fbccc12df31e4c158bea07b030ce751..8c7a91f08da60c3bf72abb4dc6dc764c2fe94065 100644 (file)
@@ -1833,10 +1833,9 @@ static int shell_exec(
   struct callback_data *pArg,                 /* Pointer to struct callback_data */
   char **pzErrMsg                             /* Error msg written here */
 ){
-  sqlite3_stmt *pStmt = NULL;
-  int rc = SQLITE_OK;
-  int rc2;
-  const char *zLeftover;      /* Tail of unprocessed SQL */
+  sqlite3_stmt *pStmt = NULL;     /* Statement to execute. */
+  int rc = SQLITE_OK;             /* Return Code */
+  const char *zLeftover;          /* Tail of unprocessed SQL */
 
   if( pzErrMsg ){
     *pzErrMsg = NULL;
@@ -1917,28 +1916,15 @@ static int shell_exec(
         }
       }
 
-      /* if the last sqlite3_step() didn't complete successfully... */
-      if( (SQLITE_OK != rc) && (SQLITE_DONE != rc) ){ 
-        if( pzErrMsg ){
-          *pzErrMsg = save_err_msg(db);
-        }
-      }else{
-        rc = SQLITE_OK;
-      }
-
-      rc2 = sqlite3_finalize(pStmt);
-      /* if the last sqlite3_finalize() didn't complete successfully 
-      ** AND we don't have a saved error from sqlite3_step ... */
-      if( (SQLITE_OK != rc2) && (SQLITE_OK == rc) ){
-        rc = rc2;
-        if( pzErrMsg ){
-          *pzErrMsg = save_err_msg(db);
-        }
-      }
-
-      if( SQLITE_OK == rc ){ 
+      /* Finalize the statement just executed. If this fails, save a 
+      ** copy of the error message. Otherwise, set zSql to point to the
+      ** next statement to execute. */
+      rc = sqlite3_finalize(pStmt);
+      if( rc==SQLITE_OK ){
         zSql = zLeftover;
         while( isspace(zSql[0]) ) zSql++;
+      }else if( pzErrMsg ){
+        *pzErrMsg = save_err_msg(db);
       }
     }
   } /* end while */
index 8de7385c8df31fd29b56900124791360524a8b2e..5d625b2449aaaf30045d7b5fc6a6c6e0ea8ff1c3 100644 (file)
@@ -195,7 +195,7 @@ do_test shell1-1.15.3 {
 # -version             show SQLite version
 do_test shell1-1.16.1 {
   catchcmd "-version test.db" "" 
-} {0 3.6.21}
+} {0 3.6.22}
 
 #----------------------------------------------------------------------------
 # Test cases shell1-2.*: Basic "dot" command token parsing.
@@ -703,4 +703,4 @@ do_test shell1-3.27.4 {
 } {1 {Error: unknown command or invalid arguments:  "timer". Enter ".help" for help}}
 
 
-#
\ No newline at end of file
+#
index dae82ababb9beb649fc7193203d5ce5e24211963..03fee23fa7d32a7df09eb9bcddb52d9e8e8df3e4 100644 (file)
@@ -81,5 +81,21 @@ do_test shell2-1.2.1 {
        [regexp {Error: too many options: "select 4"} $msg]
 } {1 1}
 
+# Test a problem reported on the mailing list. The shell was at one point
+# returning the generic SQLITE_ERROR message ("SQL error or missing database")
+# instead of the "too many levels..." message in the test below.
+#
+do_test shell2-1.3 {
+  catchcmd "-batch test.db" {
+    PRAGMA recursive_triggers = ON;
+    CREATE TABLE t5(a PRIMARY KEY, b, c);
+    INSERT INTO t5 VALUES(1, 2, 3);
+    CREATE TRIGGER au_tble AFTER UPDATE ON t5 BEGIN
+      UPDATE OR IGNORE t5 SET a = new.a, c = 10;
+    END;
+
+    UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;
+  }
+} {1 {Error: near line 9: too many levels of trigger recursion}}