From: danielk1977 Date: Tue, 17 Apr 2007 08:32:33 +0000 (+0000) Subject: Avoid reloading the db schema after a failed OP_VerifyCookie if the in-memory schema... X-Git-Tag: version-3.6.10~2321 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=896e792463d4d738ace632b0ecef245186783be3;p=thirdparty%2Fsqlite.git Avoid reloading the db schema after a failed OP_VerifyCookie if the in-memory schema cookie already matches the database file. (CVS 3849) FossilOrigin-Name: 61c1d06d10257575e1406303af331bcc4d00deb0 --- diff --git a/manifest b/manifest index fdafc7aced..1cc428598c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sintroduced\sby\s(3842)\sassociated\swith\sticket\s#2296.\s(CVS\s3848) -D 2007-04-16T17:07:55 +C Avoid\sreloading\sthe\sdb\sschema\safter\sa\sfailed\sOP_VerifyCookie\sif\sthe\sin-memory\sschema\scookie\salready\smatches\sthe\sdatabase\sfile.\s(CVS\s3849) +D 2007-04-17T08:32:34 F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -124,7 +124,7 @@ F src/update.c 3359041db390a8f856d67272f299600e2104f350 F src/utf.c e64a48bc21aa973eb622dd47da87d56a4cdcf528 F src/util.c b6344325378e75b9e18175d8b6aed1723d73dad9 F src/vacuum.c 8bd895d29e7074e78d4e80f948e35ddc9cf2beef -F src/vdbe.c 8f5faea02cfcd21cd0799fe170e76ab0f99295d8 +F src/vdbe.c cf7808e8db2e5d1547e898ce29531295183ede6e F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691 F src/vdbeInt.h 4b19fd8febad3fd14c4c97adaefc06754d323132 F src/vdbeapi.c 1fca7ff056d03f131caa6b1296bb221da65ed7f4 @@ -459,7 +459,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 66e468adfcf0132e558a666b847ce7c1e024d6fd -R 3b50384c2975fd4abff376a4b850ec92 -U drh -Z 608cb9d6d6e4358bd5d53def8d3cbd39 +P cdc7608b8d590b2ca19be37f94f2cd17423ba8ac +R a95eb9701833203362ade6cf45a79fc8 +U danielk1977 +Z 5fca2c9a355f9d34fbf42735e6435fcb diff --git a/manifest.uuid b/manifest.uuid index 99d143e280..20e789d0c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cdc7608b8d590b2ca19be37f94f2cd17423ba8ac \ No newline at end of file +61c1d06d10257575e1406303af331bcc4d00deb0 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index e63d00e7c0..839c2b1a46 100644 --- a/src/vdbe.c +++ b/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.599 2007/04/16 15:06:25 danielk1977 Exp $ +** $Id: vdbe.c,v 1.600 2007/04/17 08:32:34 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -2521,7 +2521,23 @@ case OP_VerifyCookie: { /* no-push */ } if( rc==SQLITE_OK && iMeta!=pOp->p2 ){ sqlite3SetString(&p->zErrMsg, "database schema has changed", (char*)0); - sqlite3ResetInternalSchema(db, pOp->p1); + /* If the schema-cookie from the database file matches the cookie + ** stored with the in-memory representation of the schema, do + ** not reload the schema from the database file. + ** + ** If virtual-tables are in use, this is not just an optimisation. + ** Often, v-tables store their data in other SQLite tables, which + ** are queried from within xNext() and other v-table methods using + ** prepared queries. If such a query is out-of-date, we do not want to + ** discard the database schema, as the user code implementing the + ** v-table would have to be ready for the sqlite3_vtab structure itself + ** to be invalidated whenever sqlite3_step() is called from within + ** a v-table method. + */ + if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){ + sqlite3ResetInternalSchema(db, pOp->p1); + } + sqlite3ExpirePreparedStatements(db); rc = SQLITE_SCHEMA; }