From: danielk1977 Date: Tue, 13 Jun 2006 04:11:43 +0000 (+0000) Subject: Bugfixes: Fix a segfault introduced as part of the new vtab code, deallocate memory... X-Git-Tag: version-3.6.10~2946 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dabaa126a81380fa1391570c24c5bd34c1e5943;p=thirdparty%2Fsqlite.git Bugfixes: Fix a segfault introduced as part of the new vtab code, deallocate memory in the Destroy() method of the echo module. (CVS 3221) FossilOrigin-Name: f9ea9704755eee3fd29af7a47be1d41620be8835 --- diff --git a/manifest b/manifest index 854df9be6e..58a59f4203 100644 --- 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 diff --git a/manifest.uuid b/manifest.uuid index e2e3a63102..fa972dbbfd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3532f1340f939b0231c1d82a7b2d186cb096fb29 \ No newline at end of file +f9ea9704755eee3fd29af7a47be1d41620be8835 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 94eb8ec352..d9f24c37bf 100644 --- a/src/expr.c +++ b/src/expr.c @@ -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 @@ -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; } diff --git a/src/test8.c b/src/test8.c index 29402f5626..5f8112d092 100644 --- a/src/test8.c +++ b/src/test8.c @@ -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; iinterp, 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; } diff --git a/test/vtab1.test b/test/vtab1.test index 9ca5f5d940..689ae2e95f 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -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