Add test file e_resolve.test.
FossilOrigin-Name: 6858df9c72b1e9fb6c1a0050035b11822f87a5a7
This commit is contained in:
parent
271065704c
commit
798b0072eb
11
manifest
11
manifest
@ -1,5 +1,5 @@
|
||||
C Avoid\srecursive\scalls\sto\ssqlite3VdbeMemRelease()\swhen\sdeleting\sVM\sframes\sused\sby\strigger\sprograms.
|
||||
D 2010-12-01T08:04:48
|
||||
C Add\stest\sfile\se_resolve.test.
|
||||
D 2010-12-01T11:46:53
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 4547616ad2286053af6ccccefa242dc925e49bf0
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -361,6 +361,7 @@ F test/e_fkey.test 38039b840ab19331000b0f0eb1d82baa7208a67a
|
||||
F test/e_fts3.test 75bb0aee26384ef586165e21018a17f7cd843469
|
||||
F test/e_insert.test 7390c2da39f16a134dc9a439144768c727757d2c
|
||||
F test/e_reindex.test a064f0878b8f848fbca38f1f61f82f15a3000c64
|
||||
F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6
|
||||
F test/e_select.test bf385ae3aa0f014c4933ae66fd3e1302138493eb
|
||||
F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92
|
||||
F test/e_update.test 963d6876064e65f318d1c93aaed36a02b9b389bf
|
||||
@ -891,7 +892,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 6197822cc8310fd7e1d7151683833e8b39fe631a
|
||||
R 1616ff1293fc577a7a9463bdfe77090f
|
||||
P 119ffe955eb1e8016cb8131a63bd17557f395f3f
|
||||
R 09a5e077c7ee06fdb8b9a9294977b8ce
|
||||
U dan
|
||||
Z 6b55fe83d9e16cee919cd05f710b1461
|
||||
Z abca49276b61190e4651e737a362dec8
|
||||
|
@ -1 +1 @@
|
||||
119ffe955eb1e8016cb8131a63bd17557f395f3f
|
||||
6858df9c72b1e9fb6c1a0050035b11822f87a5a7
|
135
test/e_resolve.test
Normal file
135
test/e_resolve.test
Normal file
@ -0,0 +1,135 @@
|
||||
# 2010 November 30
|
||||
#
|
||||
# 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 tests to verify that the "testable statements" in
|
||||
# the lang_naming.html document are correct.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix e_resolve
|
||||
|
||||
# An example database schema for testing name resolution:
|
||||
#
|
||||
set schema {
|
||||
ATTACH 'test.db2' AS at1;
|
||||
ATTACH 'test.db3' AS at2;
|
||||
|
||||
CREATE TABLE temp.n1(x, y); INSERT INTO temp.n1 VALUES('temp', 'n1');
|
||||
CREATE TRIGGER temp.n3 AFTER INSERT ON n1 BEGIN SELECT 1; END;
|
||||
CREATE INDEX temp.n4 ON n1(x, y);
|
||||
|
||||
CREATE TABLE main.n1(x, y); INSERT INTO main.n1 VALUES('main', 'n1');
|
||||
CREATE TABLE main.n2(x, y); INSERT INTO main.n2 VALUES('main', 'n2');
|
||||
CREATE INDEX main.n3 ON n2(y, x);
|
||||
CREATE TRIGGER main.n4 BEFORE INSERT ON n2 BEGIN SELECT 1; END;
|
||||
|
||||
CREATE TABLE at1.n1(x, y); INSERT INTO at1.n1 VALUES('at1', 'n1');
|
||||
CREATE TABLE at1.n2(x, y); INSERT INTO at1.n2 VALUES('at1', 'n2');
|
||||
CREATE TABLE at1.n3(x, y); INSERT INTO at1.n3 VALUES('at1', 'n3');
|
||||
|
||||
CREATE TABLE at2.n1(x, y); INSERT INTO at2.n1 VALUES('at2', 'n1');
|
||||
CREATE TABLE at2.n2(x, y); INSERT INTO at2.n2 VALUES('at2', 'n2');
|
||||
CREATE TABLE at2.n3(x, y); INSERT INTO at2.n3 VALUES('at2', 'n3');
|
||||
CREATE TABLE at2.n4(x, y); INSERT INTO at2.n4 VALUES('at2', 'n4');
|
||||
CREATE TRIGGER at2.n4 BEFORE INSERT ON n4 BEGIN SELECT 1; END;
|
||||
}
|
||||
|
||||
proc resolve_reopen_db {} {
|
||||
db close
|
||||
forcedelete test.db test.db2 test.db3
|
||||
sqlite3 db test.db
|
||||
db eval $::schema
|
||||
}
|
||||
|
||||
|
||||
|
||||
# EVIDENCE-OF: R-33528-20612 If no database is specified as part of the
|
||||
# object reference, then SQLite searches the main, temp and all attached
|
||||
# databases for an object with a matching name. The temp database is
|
||||
# searched first, followed by the main database, followed all attached
|
||||
# databases in the order that they were attached. The reference resolves
|
||||
# to the first match found.
|
||||
#
|
||||
resolve_reopen_db
|
||||
do_execsql_test 1.1 { SELECT * FROM n1 } {temp n1}
|
||||
do_execsql_test 1.2 { SELECT * FROM n2 } {main n2}
|
||||
do_execsql_test 1.3 { SELECT * FROM n3 } {at1 n3}
|
||||
do_execsql_test 1.4 { SELECT * FROM n4 } {at2 n4}
|
||||
|
||||
# EVIDENCE-OF: R-54577-28142 If a database name is specified as part of
|
||||
# an object reference, it must be either "main", or "temp" or the name
|
||||
# of an attached database.
|
||||
#
|
||||
# Or else it is a "no such table: xxx" error.
|
||||
#
|
||||
resolve_reopen_db
|
||||
do_execsql_test 2.1.1 { SELECT * FROM main.n1 } {main n1}
|
||||
do_execsql_test 2.1.2 { SELECT * FROM temp.n1 } {temp n1}
|
||||
do_execsql_test 2.1.3 { SELECT * FROM at1.n1 } {at1 n1}
|
||||
do_execsql_test 2.1.4 { SELECT * FROM at2.n1 } {at2 n1}
|
||||
|
||||
do_catchsql_test 2.2 { SELECT * FROM xxx.n1 } {1 {no such table: xxx.n1}}
|
||||
|
||||
# EVIDENCE-OF: R-26223-47623 Like other SQL identifiers, database names
|
||||
# are case-insensitive.
|
||||
#
|
||||
resolve_reopen_db
|
||||
do_execsql_test 3.1 { SELECT * FROM MAIN.n1 } {main n1}
|
||||
do_execsql_test 3.2 { SELECT * FROM tEmP.n1 } {temp n1}
|
||||
do_execsql_test 3.3 { SELECT * FROM aT1.n1 } {at1 n1}
|
||||
do_execsql_test 3.4 { SELECT * FROM At2.n1 } {at2 n1}
|
||||
|
||||
# EVIDENCE-OF: R-15639-28392 If a database name is specified, then only
|
||||
# the named database is searched for the named object.
|
||||
#
|
||||
do_catchsql_test 4.1 { SELECT * FROM temp.n2 } {1 {no such table: temp.n2}}
|
||||
do_catchsql_test 4.2 { SELECT * FROM main.n2 } {0 {main n2}}
|
||||
do_catchsql_test 4.3 { SELECT * FROM at1.n2 } {0 {at1 n2}}
|
||||
do_catchsql_test 4.4 { SELECT * FROM at2.n2 } {0 {at2 n2}}
|
||||
|
||||
# EVIDENCE-OF: R-08951-19801 When searching database schemas for a named
|
||||
# object, objects of types that cannot be used in the context of the
|
||||
# reference are always ignored.
|
||||
#
|
||||
# In this case, "types that cannot be used" are triggers and indexes.
|
||||
# The temp and main databases both contain triggers and indexes named
|
||||
# "n3" and "n4". Database "at2" contains a trigger called "n4". And yet:
|
||||
#
|
||||
do_execsql_test 5.1 { SELECT * FROM n3 } {at1 n3}
|
||||
do_execsql_test 5.2 { SELECT * FROM n4 } {at2 n4}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# EVIDENCE-OF: R-37286-42536
|
||||
#
|
||||
db close
|
||||
forcedelete test.db file.db
|
||||
sqlite3 db test.db
|
||||
do_execsql_test 6.1 {
|
||||
ATTACH 'file.db' AS aux;
|
||||
CREATE TABLE t1(x, y);
|
||||
CREATE TEMP TABLE t1(x, y);
|
||||
CREATE TABLE aux.t1(x, y);
|
||||
}
|
||||
|
||||
do_execsql_test 6.2.0 { DROP TABLE t1 }
|
||||
do_catchsql_test 6.2.1 { SELECT * FROM temp.t1 } {1 {no such table: temp.t1}}
|
||||
do_catchsql_test 6.2.2 { SELECT * FROM main.t1 } {0 {}}
|
||||
do_catchsql_test 6.2.3 { SELECT * FROM aux.t1 } {0 {}}
|
||||
|
||||
do_execsql_test 6.3.0 { DROP TABLE t1 }
|
||||
do_catchsql_test 6.3.1 { SELECT * FROM main.t1 } {1 {no such table: main.t1}}
|
||||
do_catchsql_test 6.3.3 { SELECT * FROM aux.t1 } {0 {}}
|
||||
|
||||
do_execsql_test 6.4.0 { DROP TABLE t1 }
|
||||
do_catchsql_test 6.4.1 { SELECT * FROM aux.t1 } {1 {no such table: aux.t1}}
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user