]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Always generate code, even if it is a no-op, for CREATE and DROP statements
authordrh <drh@noemail.net>
Sat, 18 Feb 2006 16:36:45 +0000 (16:36 +0000)
committerdrh <drh@noemail.net>
Sat, 18 Feb 2006 16:36:45 +0000 (16:36 +0000)
that use the IF EXISTS or IF NOT EXISTS clause. (CVS 3106)

FossilOrigin-Name: f8173e6aea8e90f64f5907f3f7ff4f34281f40da

manifest
manifest.uuid
src/build.c
test/capi3.test

index ab79be5a8d7f2972542adc8ceeff55598b48bd4e..57afd0690cfedb60cf26cdcffaa3a9c61340db48 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sbug\spreventing\scompliation\swithout\sMEMDEBUG\swhen\sENABLE_MEMORY_MANAGE\sis\sdefined.\s(CVS\s3105)
-D 2006-02-17T15:01:36
+C Always\sgenerate\scode,\seven\sif\sit\sis\sa\sno-op,\sfor\sCREATE\sand\sDROP\sstatements\nthat\suse\sthe\sIF\sEXISTS\sor\sIF\sNOT\sEXISTS\sclause.\s(CVS\s3106)
+D 2006-02-18T16:36:45
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -36,7 +36,7 @@ F src/attach.c d73a3505de3fb9e373d0a158978116c4212031d0
 F src/auth.c 9ae84d2d94eb96195e04515715e08e85963e96c2
 F src/btree.c 23bbfb4745e549ca224f6c933a6e9bc106d77f56
 F src/btree.h 40055cfc09defd1146bc5b922399c035f969e56d
-F src/build.c e0cecb858aa43d983ba7cfb9437b96107f06eda2
+F src/build.c f96e57e6a05c3e039c0dde9219d4a3753974d874
 F src/callback.c 1bf497306c32229114f826707054df7ebe10abf2
 F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
 F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
@@ -133,7 +133,7 @@ F test/btree7.test a6d3b842db22af97dd14b989e90a2fd96066b72f
 F test/btree8.test fadc112bcbd6a0c622d34c813fc8a648eacf8804
 F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211
 F test/capi2.test cddd151c7b687e9e00fde408b9547ec93c2146a4
-F test/capi3.test 6f9f22408b03ee1cef747caa15f7ed55cbe0d08c
+F test/capi3.test 6553fb89a4d6918e42b5f953c1d880bacb6917fe
 F test/capi3b.test 5f0bc94b104e11086b1103b20277e1910f59c7f4
 F test/cast.test aabdcb3873bb2f40d855bf63950f6d99a5a196c7
 F test/check.test 55ad950d7ad24d6eb3328c54149f90d38a39a962
@@ -354,7 +354,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 1e4644b2369547da65fcaa9a3c8ddd206a3c82ae
-R 264a524f59c325c01de8c7c5135ec4f0
-U danielk1977
-Z d4257cc0376e2524b4b1d5c966469142
+P 76912b33b1a15ee4baea9f7c8685933b4d551e91
+R 51f0f5479b574a2964e0c830b22f5d2e
+U drh
+Z b961471d43e1407a28289e616baefbcf
index 8560cb26f622987391705a762549ab093da0650f..0075709b24aba5b4ee99a23a3f1c94054bf495ac 100644 (file)
@@ -1 +1 @@
-76912b33b1a15ee4baea9f7c8685933b4d551e91
\ No newline at end of file
+f8173e6aea8e90f64f5907f3f7ff4f34281f40da
\ No newline at end of file
index 7d012838428db7aec6c95a4354038aad79407911..b8ae5501e4e43206a5d871b7a455c1616f848a80 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.387 2006/02/17 12:25:15 danielk1977 Exp $
+** $Id: build.c,v 1.388 2006/02/18 16:36:45 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -135,8 +135,8 @@ void sqlite3FinishCoding(Parse *pParse){
   if( !pParse->pVdbe ){
     if( pParse->rc==SQLITE_OK && pParse->nErr ){
       pParse->rc = SQLITE_ERROR;
+      return;
     }
-    return;
   }
 
   /* Begin by generating some termination code at the end of the
@@ -185,7 +185,7 @@ void sqlite3FinishCoding(Parse *pParse){
 
   /* Get the VDBE program ready for execution
   */
-  if( v && pParse->nErr==0 ){
+  if( v && pParse->nErr==0 && !sqlite3MallocFailed() ){
     FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
     sqlite3VdbeTrace(v, trace);
     sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem+3,
index fdff97e412a7643bf53ca033e6c47a191218d492..c1ba721f795f94c0328d7d537644faec216435b3 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script testing the callback-free C/C++ API.
 #
-# $Id: capi3.test,v 1.43 2006/02/10 07:07:16 danielk1977 Exp $
+# $Id: capi3.test,v 1.44 2006/02/18 16:36:46 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -999,4 +999,37 @@ do_test capi3-15.3 {
   sqlite3_finalize $STMT
 } {SQLITE_OK}
 
+# Make sure code is always generated even if an IF EXISTS or 
+# IF NOT EXISTS clause is present that the table does not or
+# does exists.  That way we will always have a prepared statement
+# to expire when the schema changes.
+#
+do_test capi3-16.1 {
+  set sql {DROP TABLE IF EXISTS t3}
+  set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+  sqlite3_finalize $STMT
+  expr {$STMT!=""}
+} {1}
+do_test capi3-16.2 {
+  set sql {CREATE TABLE IF NOT EXISTS t1(x,y)}
+  set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+  sqlite3_finalize $STMT
+  expr {$STMT!=""}
+} {1}
+
+# But still we do not generate code if there is no SQL
+#
+do_test capi3-16.3 {
+  set STMT [sqlite3_prepare $DB {} -1 TAIL]
+  sqlite3_finalize $STMT
+  expr {$STMT==""}
+} {1}
+do_test capi3-16.4 {
+  set STMT [sqlite3_prepare $DB {;} -1 TAIL]
+  sqlite3_finalize $STMT
+  expr {$STMT==""}
+} {1}
+
+
+
 finish_test