]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Bugfixes: Fix a segfault introduced as part of the new vtab code, deallocate memory...
authordanielk1977 <danielk1977@noemail.net>
Tue, 13 Jun 2006 04:11:43 +0000 (04:11 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 13 Jun 2006 04:11:43 +0000 (04:11 +0000)
FossilOrigin-Name: f9ea9704755eee3fd29af7a47be1d41620be8835

manifest
manifest.uuid
src/expr.c
src/test8.c
test/vtab1.test

index 854df9be6e071e58d28425705b03beef90457d90..58a59f42031ad7b57dc8857878f4dfd10bdf507b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Progress\stoward\sgetting\sthe\svirtual-table\scode\sgenerator\sto\swork.\s(CVS\s3220)
-D 2006-06-13T01:04:52
+C Bugfixes:\sFix\sa\ssegfault\sintroduced\sas\spart\sof\sthe\snew\svtab\scode,\sdeallocate\smemory\sin\sthe\sDestroy()\smethod\sof\sthe\secho\smodule.\s(CVS\s3221)
+D 2006-06-13T04:11:44
 F Makefile.in 56fd6261e83f60724e6dcd764e06ab68cbd53909
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -42,7 +42,7 @@ F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
 F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
 F src/delete.c f9a8c7837adb4bb4810a698a041a88d5ec7bfa9a
 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
-F src/expr.c 896f642936e9248b50c1449fd4b3924bcb149632
+F src/expr.c 8c873e05436ca8ee0ac4c7825d35ff898abb9c89
 F src/func.c acbbf533b55221f26760798d99b37de3ac5678fe
 F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
 F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
@@ -84,7 +84,7 @@ F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
 F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
 F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
 F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
-F src/test8.c 2a8676c42f20a34371244259a0bfad7a1dbfc419
+F src/test8.c c85eba7e98405e6c3d22ece241ee4e9ea4d154f8
 F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3
 F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
 F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
@@ -287,7 +287,7 @@ F test/vacuum.test 37f998b841cb335397c26d9bbc3457182af2565f
 F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
 F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
-F test/vtab1.test d3d4d38bd6fccb2ecec25357d9696bfea38d61e4
+F test/vtab1.test b3a93d0b4667bf27adfbb555154086c7e25ee597
 F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
 F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394
 F test/where3.test 3b5ad2c58069e12be2bd86bc5e211a82810521aa
@@ -363,7 +363,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 010965433140fbe508a907d861dbad79343bf7c2
-R 764c40e62a8b536cdb57327045ebbc4d
-U drh
-Z b3815508f49a0543b1d64dd34c187512
+P 3532f1340f939b0231c1d82a7b2d186cb096fb29
+R b50ded4b4061c3fa2b3bc042599da575
+U danielk1977
+Z d664bf5f89df9a39843ed66a526c4f5a
index e2e3a6310278ec6580ba26de638e4b192638215b..fa972dbbfd7a09b7e028fdd1bb8b4887f8e9670e 100644 (file)
@@ -1 +1 @@
-3532f1340f939b0231c1d82a7b2d186cb096fb29
\ No newline at end of file
+f9ea9704755eee3fd29af7a47be1d41620be8835
\ No newline at end of file
index 94eb8ec3521fb972a44ff3b1e31bdc274cb14a8f..d9f24c37bf8bdd6beddf138be1cfb279105f18e3 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains routines used for analyzing expressions and
 ** for generating VDBE code that evaluates expressions in SQLite.
 **
-** $Id: expr.c,v 1.260 2006/06/13 01:04:52 drh Exp $
+** $Id: expr.c,v 1.261 2006/06/13 04:11:44 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1489,8 +1489,8 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
       }else if( pExpr->iColumn>=0 ){
         Table *pTab = pExpr->pTab;
         int iCol = pExpr->iColumn;
-        sqlite3VdbeAddOp(v, pTab->isVirtual ? OP_VColumn : OP_Column,
-                            pExpr->iTable, iCol);
+        int op = (pTab && pTab->isVirtual) ? OP_VColumn : OP_Column;
+        sqlite3VdbeAddOp(v, op, pExpr->iTable, iCol);
         sqlite3ColumnDefault(v, pTab, iCol);
 #ifndef SQLITE_OMIT_FLOATING_POINT
         if( pTab && pTab->aCol[iCol].affinity==SQLITE_AFF_REAL ){
@@ -1498,8 +1498,9 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
         }
 #endif
       }else{
-        sqlite3VdbeAddOp(v, pExpr->pTab->isVirtual ? OP_VRowid : OP_Rowid,
-                         pExpr->iTable, 0);
+        Table *pTab = pExpr->pTab;
+        int op = (pTab && pTab->isVirtual) ? OP_VRowid : OP_Rowid;
+        sqlite3VdbeAddOp(v, op, pExpr->iTable, 0);
       }
       break;
     }
index 29402f5626152fa663bd6cfd162f9a6554c63785..5f8112d0928e1449710071ff2f1a7b95ad916d49 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test8.c,v 1.6 2006/06/13 01:04:53 drh Exp $
+** $Id: test8.c,v 1.7 2006/06/13 04:11:44 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -30,11 +30,6 @@ static void appendToEchoModule(Tcl_Interp *interp, const char *zArg){
   Tcl_SetVar(interp, "echo_module", zArg, flags);
 }
 
-static void appendToEchoTable(Tcl_Interp *interp, const char *zArg){
-  int flags = (TCL_APPEND_VALUE | TCL_LIST_ELEMENT | TCL_GLOBAL_ONLY);
-  Tcl_SetVar(interp, "echo_module", zArg, flags);
-}
-
 /*
 ** This function is called from within the echo-modules xCreate and
 ** xConnect methods. The argc and argv arguments are copies of those 
@@ -118,10 +113,9 @@ static int echoConnect(
   *ppVtab = &pVtab->base;
   pVtab->base.pModule = pModule;
   pVtab->interp = pModule->pAux;
-  Tcl_SetVar(interp, "echo_module", "xConnect", TCL_GLOBAL_ONLY);
+  appendToEchoModule(pVtab->interp, "xConnect");
   for(i=0; i<argc; i++){
-    Tcl_SetVar(interp, "echo_module", argv[i],
-                TCL_APPEND_VALUE | TCL_LIST_ELEMENT | TCL_GLOBAL_ONLY);
+    appendToEchoModule(pVtab->interp, argv[i]);
   }
 
   echoDeclareVtab(db, argc, argv);
@@ -129,14 +123,14 @@ static int echoConnect(
 }
 static int echoDisconnect(sqlite3_vtab *pVtab){
   echo_vtab *p = (echo_vtab*)pVtab;
-  appendToEchoTable(p->interp, "xDisconnect");
+  appendToEchoModule(p->interp, "xDisconnect");
   sqliteFree(pVtab);
   return 0;
 }
 static int echoDestroy(sqlite3_vtab *pVtab){
   echo_vtab *p = (echo_vtab*)pVtab;
-  Tcl_SetVar(p->interp, "echo_module", "xDestroy",
-                TCL_APPEND_VALUE | TCL_LIST_ELEMENT | TCL_GLOBAL_ONLY);
+  appendToEchoModule(p->interp, "xDestroy");
+  sqliteFree(pVtab);
   return 0;
 }
 
index 9ca5f5d940fca0eeec312df26f16c9c0ea1b15f3..689ae2e95f05022cb95fdc6c51eb31edee1aff61 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is creating and dropping virtual tables.
 #
-# $Id: vtab1.test,v 1.6 2006/06/12 16:01:23 danielk1977 Exp $
+# $Id: vtab1.test,v 1.7 2006/06/13 04:11:44 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -87,6 +87,7 @@ do_test vtab1-2.3 {
   set echo_module
 } [list xDisconnect xDisconnect]
 
+  set echo_module [list]
 # Re-open the database. Check that the schema of the virtual
 # table is still correct.
 do_test vtab1-2.4 {
@@ -108,6 +109,9 @@ do_test vtab1-2.5 {
   }
   set echo_module
 } [list xDestroy]
+
+finish_test
+
 do_test vtab1-2.6 {
   execsql { 
     PRAGMA table_info(t2); 
@@ -120,5 +124,18 @@ do_test vtab1-2.7 {
 } [list {CREATE VIRTUAL TABLE t1 USING echo} \
         {CREATE TABLE template(a, b, c)}     \
 ]
+do_test vtab1-2.8 {
+  set echo_module [list]
+  execsql { 
+    DROP TABLE t1;
+    DROP TABLE template;
+  }
+  set echo_module
+} [list]
+do_test vtab1-2.9 {
+  execsql {
+    SELECT sql FROM sqlite_master;
+  }
+} [list]
 
 finish_test