When an automatic re-prepare occurs, take care not to reset the internal
schema symbol table. Ticket #2156. This change also includes some debugging enhancements. (CVS 3578) FossilOrigin-Name: 43fe7fc1c38f8d9b3c1346cb1d890c2e25cefe15
This commit is contained in:
parent
f1d89f0dd9
commit
3c23a88562
24
manifest
24
manifest
@ -1,5 +1,5 @@
|
||||
C Additional\stests\sof\ssqlite3_prepare_v2.\s(CVS\s3577)
|
||||
D 2007-01-08T22:40:33
|
||||
C When\san\sautomatic\sre-prepare\soccurs,\stake\scare\snot\sto\sreset\sthe\sinternal\nschema\ssymbol\stable.\s\sTicket\s#2156.\s\sThis\schange\salso\sincludes\ssome\sdebugging\nenhancements.\s(CVS\s3578)
|
||||
D 2007-01-09T14:01:13
|
||||
F Makefile.in 7fa74bf4359aa899da5586e394d17735f221315f
|
||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -89,7 +89,7 @@ F src/pager.c d6ad66eb119602cb2e6a097f8f635372ba677d23
|
||||
F src/pager.h 2e6d42f4ae004ae748a037b8468112b851c447a7
|
||||
F src/parse.y 2f571c5f6219428d7fb08737db3d113742b1cceb
|
||||
F src/pragma.c fd4df6cf0857dd78a7cb5be5f9805419b53ae7a0
|
||||
F src/prepare.c 25edfaebfa899a7327d19601bae2c30ec2f49c9a
|
||||
F src/prepare.c 484389c6811415b8f23d259ac9c029613e1c72c3
|
||||
F src/printf.c b179b6ed12f793e028dd169e2e2e2b2a37eedc63
|
||||
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
||||
F src/select.c 52f09127b53697b1a95835a9b0db9309cca8079f
|
||||
@ -100,7 +100,7 @@ F src/sqlite3ext.h 2c2156cc32a158e2b7bd9042d42accf94bff2e40
|
||||
F src/sqliteInt.h 90dad3c0ba7a5151c48361748ccdada9ff2eff78
|
||||
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
|
||||
F src/tclsqlite.c d344c7f394d6f055ce3abfe0049b0480c5e34e56
|
||||
F src/test1.c 1194cd78dbc5180e0c1a44e6d7eb27577bb9122e
|
||||
F src/test1.c 053f5224697efaefff1f4c647fd90fdea9346cc5
|
||||
F src/test2.c ca74a1d8aeb7d9606e8f6b762c5daf85c1a3f92b
|
||||
F src/test3.c fa0e85ddd1784f2dda5861a2cb4e7d27d1c932c1
|
||||
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
||||
@ -121,14 +121,14 @@ F src/update.c 951f95ef044cf6d28557c48dc35cb0711a0b9129
|
||||
F src/utf.c 67ecb1032bc0b42c105e88d65ef9d9f626eb0e1f
|
||||
F src/util.c 91d4cb189476906639ae611927d939691d1365f6
|
||||
F src/vacuum.c b4569b08aaa5afb141af3f76d0315745db4e9e4b
|
||||
F src/vdbe.c dcf6b17660a117291254794ac8a866279c518243
|
||||
F src/vdbe.h f20886fba4a15d816014c52e652b5a9f30bf0be3
|
||||
F src/vdbe.c 074cda811466f8f752c2dd71b1dcaea001f4be64
|
||||
F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
|
||||
F src/vdbeInt.h 1ca07f2d7446c90230346aed7fbf990c032460bc
|
||||
F src/vdbeapi.c 2d1e6843af8705a1172e54a418d2a3d5febd1dd7
|
||||
F src/vdbeaux.c 5085f15af740fed8ab17dc40863fc6206e1fb7ab
|
||||
F src/vdbeaux.c c5324d62f51529bccc5be3b04bac2e4eeae1569a
|
||||
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
||||
F src/vdbemem.c 26623176bf1c616aa478da958fac49502491a921
|
||||
F src/vtab.c 2e367db8c41ac099ba7b7690f4e9bc3c509436ff
|
||||
F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
|
||||
F src/where.c f55d4459a122457a135cf9ec859bf28777d9156f
|
||||
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
@ -340,7 +340,7 @@ F test/vacuum.test cf839fc3ff24d601057319bbb5c700ce9c8e0fb0
|
||||
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
|
||||
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
||||
F test/view.test 852bd4101e6d171c46ad682eb5c5faf662b2eba4
|
||||
F test/vtab1.test 30f82f7c3ee7ff9c0bba293d83b249488349c371
|
||||
F test/vtab1.test 03c4ad3180b78866993ef56af9d3b7c145ea4e4d
|
||||
F test/vtab2.test 43763026b124e68785de05d3fbf957a4b5f81a0d
|
||||
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
|
||||
F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87
|
||||
@ -424,7 +424,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P 3401388dba6c150f788397a4dfbcdb01313247e2
|
||||
R c581f3929841b43348392d34680cf0ca
|
||||
P b0650aa6cfcb4c59fd8556b8f5523573538bd7e5
|
||||
R 925739aa888e1b0daa724e8337ce1a17
|
||||
U drh
|
||||
Z 7f0a5792bf1db982fb0c8c14ae2b6732
|
||||
Z f3d972a9c7563d33546c3abd9115d1bf
|
||||
|
@ -1 +1 @@
|
||||
b0650aa6cfcb4c59fd8556b8f5523573538bd7e5
|
||||
43fe7fc1c38f8d9b3c1346cb1d890c2e25cefe15
|
@ -13,7 +13,7 @@
|
||||
** interface, and routines that contribute to loading the database schema
|
||||
** from disk.
|
||||
**
|
||||
** $Id: prepare.c,v 1.42 2007/01/08 21:07:18 drh Exp $
|
||||
** $Id: prepare.c,v 1.43 2007/01/09 14:01:13 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -577,7 +577,8 @@ int sqlite3Reprepare(Vdbe *p){
|
||||
}
|
||||
sqlite3VdbeSwap(pNew, p);
|
||||
sqlite3_transfer_bindings((sqlite3_stmt*)pNew, (sqlite3_stmt*)p);
|
||||
sqlite3_finalize((sqlite3_stmt*)pNew);
|
||||
sqlite3VdbeResetStepResult(pNew);
|
||||
sqlite3VdbeFinalize(pNew);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
27
src/test1.c
27
src/test1.c
@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test1.c,v 1.226 2007/01/03 23:37:28 drh Exp $
|
||||
** $Id: test1.c,v 1.227 2007/01/09 14:01:13 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@ -760,6 +760,30 @@ static int test_create_aggregate(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Usage: printf TEXT
|
||||
**
|
||||
** Send output to printf. Use this rather than puts to merge the output
|
||||
** in the correct sequence with debugging printfs inserted into C code.
|
||||
** Puts uses a separate buffer and debugging statements will be out of
|
||||
** sequence if it is used.
|
||||
*/
|
||||
static int test_printf(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int argc, /* Number of arguments */
|
||||
char **argv /* Text of each argument */
|
||||
){
|
||||
if( argc!=2 ){
|
||||
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||
" TEXT\"", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
printf("%s\n", argv[1]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_mprintf_int FORMAT INTEGER INTEGER INTEGER
|
||||
@ -4035,6 +4059,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
{ "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit },
|
||||
{ "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used },
|
||||
{ "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout },
|
||||
{ "printf", (Tcl_CmdProc*)test_printf },
|
||||
};
|
||||
static struct {
|
||||
char *zName;
|
||||
|
29
src/vdbe.c
29
src/vdbe.c
@ -43,7 +43,7 @@
|
||||
** in this file for details. If in doubt, do not deviate from existing
|
||||
** commenting and indentation practices when changing or adding code.
|
||||
**
|
||||
** $Id: vdbe.c,v 1.584 2007/01/05 16:39:43 drh Exp $
|
||||
** $Id: vdbe.c,v 1.585 2007/01/09 14:01:14 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -454,6 +454,21 @@ int sqlite3VdbeExec(
|
||||
p->resOnStack = 0;
|
||||
db->busyHandler.nBusy = 0;
|
||||
CHECK_FOR_INTERRUPT;
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( (p->db->flags & SQLITE_VdbeListing)!=0
|
||||
|| sqlite3OsFileExists("vdbe_explain")
|
||||
){
|
||||
int i;
|
||||
printf("VDBE Program Listing:\n");
|
||||
sqlite3VdbePrintSql(p);
|
||||
for(i=0; i<p->nOp; i++){
|
||||
sqlite3VdbePrintOp(stdout, i, &p->aOp[i]);
|
||||
}
|
||||
}
|
||||
if( sqlite3OsFileExists("vdbe_trace") ){
|
||||
p->trace = stdout;
|
||||
}
|
||||
#endif
|
||||
for(pc=p->pc; rc==SQLITE_OK; pc++){
|
||||
assert( pc>=0 && pc<p->nOp );
|
||||
assert( pTos<=&p->aStack[pc] );
|
||||
@ -4004,10 +4019,14 @@ case OP_CreateTable: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: ParseSchema P1 * P3
|
||||
/* Opcode: ParseSchema P1 P2 P3
|
||||
**
|
||||
** Read and parse all entries from the SQLITE_MASTER table of database P1
|
||||
** that match the WHERE clause P3.
|
||||
** that match the WHERE clause P3. P2 is the "force" flag. Always do
|
||||
** the parsing if P2 is true. If P2 is false, then this routine is a
|
||||
** no-op if the schema is not currently loaded. In other words, if P2
|
||||
** is false, the SQLITE_MASTER table is only parsed if the rest of the
|
||||
** schema is already loaded into the symbol table.
|
||||
**
|
||||
** This opcode invokes the parser to create a new virtual machine,
|
||||
** then runs the new virtual machine. It is thus a reentrant opcode.
|
||||
@ -4019,7 +4038,9 @@ case OP_ParseSchema: { /* no-push */
|
||||
InitData initData;
|
||||
|
||||
assert( iDb>=0 && iDb<db->nDb );
|
||||
if( !DbHasProperty(db, iDb, DB_SchemaLoaded) ) break;
|
||||
if( !pOp->p2 && !DbHasProperty(db, iDb, DB_SchemaLoaded) ){
|
||||
break;
|
||||
}
|
||||
zMaster = SCHEMA_TABLE(iDb);
|
||||
initData.db = db;
|
||||
initData.iDb = pOp->p1;
|
||||
|
@ -15,7 +15,7 @@
|
||||
** or VDBE. The VDBE implements an abstract machine that runs a
|
||||
** simple program to access and modify the underlying database.
|
||||
**
|
||||
** $Id: vdbe.h,v 1.107 2007/01/08 21:07:18 drh Exp $
|
||||
** $Id: vdbe.h,v 1.108 2007/01/09 14:01:14 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITE_VDBE_H_
|
||||
#define _SQLITE_VDBE_H_
|
||||
@ -129,6 +129,7 @@ int sqlite3VdbeFinalize(Vdbe*);
|
||||
void sqlite3VdbeResolveLabel(Vdbe*, int);
|
||||
int sqlite3VdbeCurrentAddr(Vdbe*);
|
||||
void sqlite3VdbeTrace(Vdbe*,FILE*);
|
||||
void sqlite3VdbeResetStepResult(Vdbe*);
|
||||
int sqlite3VdbeReset(Vdbe*);
|
||||
int sqliteVdbeSetVariables(Vdbe*,int,const char**);
|
||||
void sqlite3VdbeSetNumCols(Vdbe*,int);
|
||||
|
@ -852,21 +852,6 @@ void sqlite3VdbeMakeReady(
|
||||
p->aMem[n].flags = MEM_Null;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( (p->db->flags & SQLITE_VdbeListing)!=0
|
||||
|| sqlite3OsFileExists("vdbe_explain")
|
||||
){
|
||||
int i;
|
||||
printf("VDBE Program Listing:\n");
|
||||
sqlite3VdbePrintSql(p);
|
||||
for(i=0; i<p->nOp; i++){
|
||||
sqlite3VdbePrintOp(stdout, i, &p->aOp[i]);
|
||||
}
|
||||
}
|
||||
if( sqlite3OsFileExists("vdbe_trace") ){
|
||||
p->trace = stdout;
|
||||
}
|
||||
#endif
|
||||
p->pTos = &p->aStack[-1];
|
||||
p->pc = -1;
|
||||
p->rc = SQLITE_OK;
|
||||
@ -1464,6 +1449,14 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Each VDBE holds the result of the most recent sqlite3_step() call
|
||||
** in p->rc. This routine sets that result back to SQLITE_OK.
|
||||
*/
|
||||
void sqlite3VdbeResetStepResult(Vdbe *p){
|
||||
p->rc = SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Clean up a VDBE after execution but do not delete the VDBE just yet.
|
||||
** Write any error messages into *pzErrMsg. Return the result code.
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to help implement virtual tables.
|
||||
**
|
||||
** $Id: vtab.c,v 1.38 2007/01/05 14:41:07 drh Exp $
|
||||
** $Id: vtab.c,v 1.39 2007/01/09 14:01:14 drh Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#include "sqliteInt.h"
|
||||
@ -230,7 +230,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
||||
|
||||
sqlite3VdbeAddOp(v, OP_Expire, 0, 0);
|
||||
zWhere = sqlite3MPrintf("name='%q'", pTab->zName);
|
||||
sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 0, zWhere, P3_DYNAMIC);
|
||||
sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 1, zWhere, P3_DYNAMIC);
|
||||
sqlite3VdbeOp3(v, OP_VCreate, iDb, 0, pTab->zName, strlen(pTab->zName) + 1);
|
||||
}
|
||||
|
||||
|
@ -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.38 2006/09/16 21:45:14 drh Exp $
|
||||
# $Id: vtab1.test,v 1.39 2007/01/09 14:01:14 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -96,6 +96,29 @@ do_test vtab1-1.6 {
|
||||
}
|
||||
} {}
|
||||
|
||||
# Ticket #2156. Using the sqlite3_prepare_v2() API, make sure that
|
||||
# a CREATE VIRTUAL TABLE statement can be used multiple times.
|
||||
#
|
||||
do_test vtab1-1.2152.1 {
|
||||
set DB [sqlite3_connection_pointer db]
|
||||
set sql {CREATE VIRTUAL TABLE t2152a USING echo(t2152b)}
|
||||
set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]
|
||||
sqlite3_step $STMT
|
||||
} SQLITE_ERROR
|
||||
do_test vtab-1.2152.2 {
|
||||
sqlite3_reset $STMT
|
||||
sqlite3_step $STMT
|
||||
} SQLITE_ERROR
|
||||
do_test vtab-1.2152.3 {
|
||||
sqlite3_reset $STMT
|
||||
db eval {CREATE TABLE t2152b(x,y)}
|
||||
sqlite3_step $STMT
|
||||
} SQLITE_DONE
|
||||
do_test vtab-1.2152.4 {
|
||||
sqlite3_finalize $STMT
|
||||
db eval {DROP TABLE t2152a; DROP TABLE t2152b}
|
||||
} {}
|
||||
|
||||
# Test to make sure nothing goes wrong and no memory is leaked if we
|
||||
# select an illegal table-name (i.e a reserved name or the name of a
|
||||
# table that already exists).
|
||||
|
Loading…
Reference in New Issue
Block a user