When parsing CREATE INDEX statements from the sqlite_master table, do not search the temp database schema for the corresponding table. Only consider the database for which the schema is being parsed. Ticket #2817. (CVS 4587)

FossilOrigin-Name: e6f02aa5ae6da0befdf98fdd5884345f3cb7f5ea
This commit is contained in:
danielk1977 2007-12-02 11:46:34 +00:00
parent 0c1cddbe86
commit fe91033907
4 changed files with 90 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Another\sfix\sto\sMakefile.in\sfor\smingw.\s(CVS\s4586)
D 2007-12-01T19:25:17
C When\sparsing\sCREATE\sINDEX\sstatements\sfrom\sthe\ssqlite_master\stable,\sdo\snot\ssearch\sthe\stemp\sdatabase\sschema\sfor\sthe\scorresponding\stable.\sOnly\sconsider\sthe\sdatabase\sfor\swhich\sthe\sschema\sis\sbeing\sparsed.\sTicket\s#2817.\s(CVS\s4587)
D 2007-12-02T11:46:35
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -86,7 +86,7 @@ F src/btmutex.c 442be6f068d77ca9ffd69899cf0a3943c244548c
F src/btree.c c5844bb4bbe997a7c8400a714fcf304d91855383
F src/btree.h d0736ebca4b6eafbdd823c46a8de574cea078211
F src/btreeInt.h 4330c19b8314545fdb209cc77e2a57f6a5290e9c
F src/build.c b58dd7c7a763a228196022ec0d51781ed6995cde
F src/build.c 04e0783a105d4d65c1850815adfdfe7403dcb592
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6
@ -476,6 +476,7 @@ F test/tkt2640.test c513e7992a602a87ef3a2cc9ca1cba4146924e9b
F test/tkt2643.test 3f3ebb743da00d4fed4fcf6daed92a0e18e57813
F test/tkt2686.test 8815c3eeae7c8363bd7c2889349ec39e8bc8000d
F test/tkt2767.test 6b02308d553d194f329a469bf5c157fe724738d4
F test/tkt2817.test 709a2201a5590bf56cb97f6fb168a62282203fd1
F test/trace.test 75ffc1b992c780d054748a656e3e7fd674f18567
F test/trans.test b73289992b46d38d9479ecc4fdc03d8edb2413dc
F test/trigger1.test 7c13f39ca36f529bf856e05c7d004fc0531d48b4
@ -595,7 +596,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 2ea78d2cbd86edda6f998fbb364800d3ecf76479
R 808f25179a2f4966fb39356145e52393
U drh
Z 7c18109dc26100992632a8107a593428
P cfaeb02554ab86fffbfb8eb2a78c7d8a59a9cba5
R 5cda7c44dd11110e2cde6ba16b60c752
U danielk1977
Z 91a21dbc4e72424cd2223f173c611bb3

View File

@ -1 +1 @@
cfaeb02554ab86fffbfb8eb2a78c7d8a59a9cba5
e6f02aa5ae6da0befdf98fdd5884345f3cb7f5ea

View File

@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.448 2007/11/12 09:50:26 danielk1977 Exp $
** $Id: build.c,v 1.449 2007/12/02 11:46:35 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -2320,11 +2320,14 @@ void sqlite3CreateIndex(
#ifndef SQLITE_OMIT_TEMPDB
/* If the index name was unqualified, check if the the table
** is a temp table. If so, set the database to 1.
** is a temp table. If so, set the database to 1. Do not do this
** if initialising a database schema.
*/
pTab = sqlite3SrcListLookup(pParse, pTblName);
if( pName2 && pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
iDb = 1;
if( !db->init.busy ){
pTab = sqlite3SrcListLookup(pParse, pTblName);
if( pName2 && pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
iDb = 1;
}
}
#endif

73
test/tkt2817.test Normal file
View File

@ -0,0 +1,73 @@
# 2007 December 02
#
# 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.
#
# Specifically, it tests that bug 2817 is fixed.
#
# $Id: tkt2817.test,v 1.1 2007/12/02 11:46:35 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test tkt2817-1.0 {
execsql {
CREATE TEMP TABLE tbl(a, b, c);
-- INSERT INTO tbl VALUES(1, 'abc', 'def');
-- INSERT INTO tbl VALUES(2, 'ghi', 'jkl');
}
} {}
do_test tkt2817-1.1 {
execsql {
CREATE TABLE main.tbl(a, b, c);
CREATE INDEX main.tbli ON tbl(a, b, c);
INSERT INTO main.tbl SELECT a, b, c FROM temp.tbl;
}
} {}
# When bug #2817 existed, this test was failing.
#
integrity_check tkt2817-1.2
# So was this one.
#
db close
sqlite3 db test.db
integrity_check tkt2817-1.3
# These tests - tkt2817-2.* - are the same as the previous block, except
# for the fact that the temp-table and the main table do not share the
# same name. #2817 did not cause a problem with these tests.
#
db close
file delete -force test.db
sqlite3 db test.db
do_test tkt2817-2.0 {
execsql {
CREATE TEMP TABLE tmp(a, b, c);
INSERT INTO tmp VALUES(1, 'abc', 'def');
INSERT INTO tmp VALUES(2, 'ghi', 'jkl');
}
} {}
do_test tkt2817-2.1 {
execsql {
CREATE TABLE main.tbl(a, b, c);
CREATE INDEX main.tbli ON tbl(a, b, c);
INSERT INTO main.tbl SELECT a, b, c FROM temp.tmp;
}
} {}
integrity_check tkt2817-2.2
db close
sqlite3 db test.db
integrity_check tkt2817-2.3
finish_test