Fix a shared-cache mode problem triggered when sqlite3_open16() was used to open the second or subsequent connections to a utf-8 database. (CVS 5059)

FossilOrigin-Name: 20946bf6dd704416c41edd863103e85fc7ab4ef2
This commit is contained in:
danielk1977 2008-04-28 16:19:35 +00:00
parent 394f07ef8c
commit f51bf48b32
4 changed files with 43 additions and 16 deletions

View File

@ -1,5 +1,5 @@
C Work\saround\sa\sNaN\sbug\sin\ssome\sversions\sof\sTcl.\s(CVS\s5058)
D 2008-04-28T15:23:03
C Fix\sa\sshared-cache\smode\sproblem\striggered\swhen\ssqlite3_open16()\swas\sused\sto\sopen\sthe\ssecond\sor\ssubsequent\sconnections\sto\sa\sutf-8\sdatabase.\s(CVS\s5059)
D 2008-04-28T16:19:35
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -103,7 +103,7 @@ F src/insert.c 9d59bf8eb43ce8399e6f818eaf1612a4c1dfeb2e
F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
F src/legacy.c 8267890e6a0a71f13b680794520999c642299081
F src/loadext.c 5c20a5afeb154e68d62ed6d9c634add1b21387fd
F src/main.c 3300916fb626e3e3873c25e9cd966a3b311d1c68
F src/main.c 367b5806a04e0014101fa70e2e5265e12f6a7030
F src/malloc.c 12c1ae98ef1eff34b13c9eb526e0b7b479e1e820
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a
@ -430,7 +430,7 @@ F test/select6.test 399f14b9ba37b768afe5d2cd8c12e4f340a69db8
F test/select7.test 7906735805cfbee4dddc0bed4c14e68d7f5f9c5f
F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d
F test/server1.test f5b790d4c0498179151ca8a7715a65a7802c859c
F test/shared.test f4501cfdff9236191ac1f9e84e6597a63d0d9600
F test/shared.test bff836a2c32418f01561d268b4c1d026a454e59b
F test/shared2.test 0ee9de8964d70e451936a48c41cb161d9134ccf4
F test/shared3.test 01e3e124dbb3859788aabc7cfb82f7ea04421749
F test/shared_err.test 202ce115a4bfab2b41da5d4c9431f68a474134a6
@ -630,7 +630,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 8eb2c07c520c12c2cd4610596dbec451c8275e95
R 0d20d66feeaace19e07473438052cbbe
U drh
Z 82e30186eb61b94a6ebb1cd09ee72fb5
P 7bf8213ce9f591f4c2ef6c1e19a17712e3bae9e3
R 613b7949fdaa0711be115c0f2be92a3b
U danielk1977
Z 355fdcb5723cd5025089cad5f7c888ad

View File

@ -1 +1 @@
7bf8213ce9f591f4c2ef6c1e19a17712e3bae9e3
20946bf6dd704416c41edd863103e85fc7ab4ef2

View File

@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.434 2008/04/16 00:49:12 drh Exp $
** $Id: main.c,v 1.435 2008/04/28 16:19:35 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -1248,12 +1248,8 @@ int sqlite3_open16(
rc = openDatabase(zFilename8, ppDb,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
assert( *ppDb || rc==SQLITE_NOMEM );
if( rc==SQLITE_OK ){
if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
ENC(*ppDb) = SQLITE_UTF16NATIVE;
if( rc!=SQLITE_OK ){
sqlite3_close(*ppDb);
*ppDb = 0;
}
}
}
sqlite3ValueFree(pVal);

View File

@ -9,7 +9,7 @@
#
#***********************************************************************
#
# $Id: shared.test,v 1.30 2008/02/08 18:25:48 danielk1977 Exp $
# $Id: shared.test,v 1.31 2008/04/28 16:19:35 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -636,6 +636,7 @@ ifcapable utf16 {
do_test shared-$av.8.1.2 {
string range [execsql {PRAGMA encoding;}] 0 end-2
} {UTF-16}
do_test shared-$av.8.1.3 {
sqlite3 db2 test.db
execsql {
@ -654,6 +655,7 @@ ifcapable utf16 {
PRAGMA encoding;
}
} {UTF-8}
file delete -force test2.db test2.db-journal
do_test shared-$av.8.2.1 {
execsql {
@ -670,6 +672,35 @@ ifcapable utf16 {
string range [execsql {PRAGMA encoding;} db2] 0 end-2
} {UTF-16}
catch {db close}
catch {db2 close}
file delete -force test.db test2.db
do_test shared-$av.8.3.2 {
sqlite3 db test.db
execsql { CREATE TABLE def(d, e, f) }
execsql { PRAGMA encoding }
} {UTF-8}
do_test shared-$av.8.3.3 {
set zDb16 "[encoding convertto unicode test.db]\x00\x00"
set db16 [sqlite3_open16 $zDb16 {}]
set stmt [sqlite3_prepare $db16 "SELECT sql FROM sqlite_master" -1 DUMMY]
sqlite3_step $stmt
set sql [sqlite3_column_text $stmt 0]
sqlite3_finalize $stmt
set sql
} {CREATE TABLE def(d, e, f)}
do_test shared-$av.8.3.4 {
set stmt [sqlite3_prepare $db16 "PRAGMA encoding" -1 DUMMY]
sqlite3_step $stmt
set enc [sqlite3_column_text $stmt 0]
sqlite3_finalize $stmt
set enc
} {UTF-8}
sqlite3_close $db16
# Bug #2547 is causing this to fail.
if 0 {
do_test shared-$av.8.2.3 {