Merge the fix to ticket [f7b4edece25c99485] into the sessions branch.

FossilOrigin-Name: 1b736ac2934f2361dee5062e9033cbf26b41fc3a
This commit is contained in:
drh 2011-03-19 02:37:38 +00:00
commit 516ae18005
12 changed files with 121 additions and 24 deletions

0
install-sh Normal file → Executable file
View File

View File

@ -1,5 +1,8 @@
C Hold\sthe\sdatabase\smutex\sfor\sthe\sduration\sof\san\ssqlite3changeset_apply()\scall.\sAlso\sfor\sthe\sduration\sof\sall\ssqlite3session_xxx()\scalls.
D 2011-03-18T18:03:14
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Merge\sthe\sfix\sto\sticket\s[f7b4edece25c99485]\sinto\sthe\ssessions\sbranch.
D 2011-03-19T02:37:38.712
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -102,7 +105,7 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F ext/session/sqlite3session.c d4ba709d457a7b184a72ccd3ab07e5a1e9dd9196
F ext/session/sqlite3session.h 9551c002efd5fde07c52994c6b592308e0df2d6a
F ext/session/test_session.c 2559ef68e421c7fb83e2c19ef08a17343b70d535
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F main.mk ae0868e05c76eaa8a0ae3d6927a949b1c8e810d7
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
@ -127,8 +130,8 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff
F src/btree.c 43302cc4f3de6479b90fa6bb271b65d86333d00e
F src/btree.h e2f2cd9933bf30724f53ffa12c4c5a3a864bbd6e
F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4
F src/build.c 00a327120d81ace6267e714ae8010c997d55de5d
F src/callback.c a1d1b1c9c85415dff013af033e2fed9c8382d33b
F src/build.c 3b86c8efc0cbe716d82c510463f448b9cdee0619
F src/callback.c 5069f224882cbdccd559f591271d28d7f37745bc
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01
F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b
@ -183,7 +186,7 @@ F src/select.c d24406c45dd2442eb2eeaac413439066b149c944
F src/shell.c 4a5e0ad845475c84881f0b25b1abba2ddaab0a72
F src/sqlite.h.in 208dc372c9b8d89ca962babcb7cb0c1b16d32bc4
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
F src/sqliteInt.h e427f9cff8fcf85ea23f95eb8b70e4b588d24212
F src/sqliteInt.h 6d71ab98edf64d1605d6b49ee1bd880d16be927e
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@ -234,12 +237,12 @@ F src/update.c aa39db6c39a1e234e8badf49768e1389dbb34650
F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685
F src/util.c cd997077bad039efc0597eb027c929658f93c018
F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
F src/vdbe.c 94cd191b1b20b0124e09b056bbce3d09f79821b3
F src/vdbe.c 3f6d91163b5b7b3d2609bf5f21461d902989cdc5
F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
F src/vdbeInt.h 20d13da932eed0667a2e2383a9cb0f80099a5fd3
F src/vdbeapi.c 0e53620e9a4889257eece201d517163d3093ee41
F src/vdbeaux.c 9807ae2e6974172b1d7b077327f862f6bd4dda2a
F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c
F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562
F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b
F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5
F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30
@ -302,7 +305,7 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b
F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0
F test/cache.test 754baab2f18089fc9bcba7afaeb4dc907c6c6de2
F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360
F test/capi3.test 1945a2ba75e3f4c49d5beb8fc092115b6292d471
F test/capi3.test 5c1ea6c940f2d7c4d5af8ef1ec2f92a267d2e37a
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
F test/capi3c.test bea67403a5e37a4b33230ee4723e315a2ffb31e7
F test/capi3d.test cd36571f014f34bdc4421967f6453cbb597d5d16
@ -605,7 +608,7 @@ F test/permutations.test 5b2a4cb756ffb2407cb4743163668d1d769febb6
F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8
@ -718,6 +721,7 @@ F test/tkt-d11f09d36e.test fb44f7961aa6d4b632fb7b9768239832210b5fc7
F test/tkt-d82e3f3721.test 731359dfdcdb36fea0559cd33fec39dd0ceae8e6
F test/tkt-f3e5abed55.test 19fb59268da6f20a69a181b9c14154132d1c65e3
F test/tkt-f777251dc7a.test 6f24c053bc5cdb7e1e19be9a72c8887cf41d5e87
F test/tkt-f7b4edec.test d998a08ff2b18b7f62edce8e3044317c45efe6c7
F test/tkt-f973c7ac31.test 1da0ed15ec2c7749fb5ce2828cd69d07153ad9f4
F test/tkt-fc62af4523.test 72825d3febdedcd5593a27989fc05accdbfc2bb4
F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00
@ -893,7 +897,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027
F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc
F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c.tcl cf44512a48112b1ba09590548660a5a6877afdb3
F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff
@ -918,7 +922,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 9604d13001e0a195718c7f03fc0e73e352226caa
R 54e501f64ecb85ba88c3d3201e5dcd9b
U dan
Z 255e99dc78fad5aee707e21b8ff77ea9
P c615c38c3283e21c33550c093099a793761123a7 eedbcf0a0ba91bb8b9cd3d115081ba297e9959fe
R d0ca47f6483ae12a6d0c994e1006aea9
U drh
Z 5fff78b74e6c376b68b45fceb2b4a735
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFNhBb2oxKgR168RlERAgoXAKCNG+a12IdNjhU70FvIK6nf6CqkoQCfbtYL
k5XHY8ri1b+IAtTgBjHO+hs=
=5lEb
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
c615c38c3283e21c33550c093099a793761123a7
1b736ac2934f2361dee5062e9033cbf26b41fc3a

View File

@ -156,7 +156,9 @@ void sqlite3FinishCoding(Parse *pParse){
sqlite3VdbeUsesBtree(v, iDb);
sqlite3VdbeAddOp2(v,OP_Transaction, iDb, (mask & pParse->writeMask)!=0);
if( db->init.busy==0 ){
sqlite3VdbeAddOp2(v,OP_VerifyCookie, iDb, pParse->cookieValue[iDb]);
sqlite3VdbeAddOp3(v, OP_VerifyCookie,
iDb, pParse->cookieValue[iDb],
db->aDb[iDb].pSchema->iGeneration);
}
}
#ifndef SQLITE_OMIT_VIRTUALTABLE

View File

@ -427,7 +427,10 @@ void sqlite3SchemaFree(void *p){
sqlite3HashClear(&temp1);
sqlite3HashClear(&pSchema->fkeyHash);
pSchema->pSeqTab = 0;
pSchema->flags &= ~DB_SchemaLoaded;
if( pSchema->flags & DB_SchemaLoaded ){
pSchema->iGeneration++;
pSchema->flags &= ~DB_SchemaLoaded;
}
}
/*

View File

@ -672,6 +672,7 @@ struct Db {
*/
struct Schema {
int schema_cookie; /* Database schema version number for this file */
int iGeneration; /* Generation counter. Incremented with each change */
Hash tblHash; /* All tables indexed by name */
Hash idxHash; /* All (named) indices indexed by name */
Hash trigHash; /* All triggers indexed by name */

View File

@ -2890,10 +2890,12 @@ case OP_SetCookie: { /* in3 */
break;
}
/* Opcode: VerifyCookie P1 P2 *
/* Opcode: VerifyCookie P1 P2 P3 * *
**
** Check the value of global database parameter number 0 (the
** schema version) and make sure it is equal to P2.
** schema version) and make sure it is equal to P2 and that the
** generation counter on the local schema parse equals P3.
**
** P1 is the database number which is 0 for the main database file
** and 1 for the file holding temporary tables and some higher number
** for auxiliary databases.
@ -2908,16 +2910,19 @@ case OP_SetCookie: { /* in3 */
*/
case OP_VerifyCookie: {
int iMeta;
int iGen;
Btree *pBt;
assert( pOp->p1>=0 && pOp->p1<db->nDb );
assert( (p->btreeMask & (1<<pOp->p1))!=0 );
pBt = db->aDb[pOp->p1].pBt;
if( pBt ){
sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
iGen = db->aDb[pOp->p1].pSchema->iGeneration;
}else{
iMeta = 0;
}
if( iMeta!=pOp->p2 ){
if( iMeta!=pOp->p2 || iGen!=pOp->p3 ){
sqlite3DbFree(db, p->zErrMsg);
p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
/* If the schema-cookie from the database file matches the cookie

View File

@ -266,6 +266,7 @@ int sqlite3_blob_open(
/* Configure the OP_VerifyCookie */
sqlite3VdbeChangeP1(v, 1, iDb);
sqlite3VdbeChangeP2(v, 1, pTab->pSchema->schema_cookie);
sqlite3VdbeChangeP3(v, 1, pTab->pSchema->iGeneration);
/* Make sure a mutex is held on the table to be accessed */
sqlite3VdbeUsesBtree(v, iDb);

View File

@ -651,11 +651,11 @@ do_test capi3-6.1 {
} {SQLITE_BUSY}
do_test capi3-6.2 {
sqlite3_step $STMT
} {SQLITE_ROW}
check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
} {SQLITE_ERROR}
#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
do_test capi3-6.3 {
sqlite3_finalize $STMT
} {SQLITE_OK}
} {SQLITE_SCHEMA}
do_test capi3-6.4-misuse {
db cache flush
sqlite3_close $DB

0
test/progress.test Executable file → Normal file
View File

74
test/tkt-f7b4edec.test Normal file
View File

@ -0,0 +1,74 @@
# 2011 March 18
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to verify that ticket
# [f7b4edece25c994857dc139207f55a53c8319fae] has been fixed.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Open two database connections to the same database file in
# shared cache mode. Create update hooks that will fire on
# each connection.
#
db close
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
sqlite3 db1 test.db
sqlite3 db2 test.db
unset -nocomplain HOOKS
set HOOKS {}
proc update_hook {args} { lappend ::HOOKS $args }
db1 update_hook update_hook
db2 update_hook update_hook
# Create a prepared statement
#
do_test tkt-f7b4edec-1 {
execsql { CREATE TABLE t1(x, y); } db1
execsql { INSERT INTO t1 VALUES(1, 2) } db1
set ::HOOKS
} {{INSERT main t1 1}}
# In the second database connection cause the schema to be reparsed
# without changing the schema cookie.
#
set HOOKS {}
do_test tkt-f7b4edec-2 {
execsql {
BEGIN;
DROP TABLE t1;
CREATE TABLE t1(x, y);
ROLLBACK;
} db2
set ::HOOKS
} {}
# Rerun the prepared statement that was created prior to the
# schema reparse. Verify that the update-hook gives the correct
# output.
#
set HOOKS {}
do_test tkt-f7b4edec-3 {
execsql { INSERT INTO t1 VALUES(1, 2) } db1
set ::HOOKS
} {{INSERT main t1 2}}
# Be sure to restore the original shared-cache mode setting before
# returning.
#
db1 close
db2 close
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test

0
tool/mkopts.tcl Executable file → Normal file
View File