mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Have the dbstat module dequote any argument passed to the CREATE VIRTUAL TABLE statement before attempting to match it against the names of attached databases.
FossilOrigin-Name: e60461e984b8df09256bb0d733dbfae52568a145
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix stat
|
||||
|
||||
ifcapable !vtab||!compound {
|
||||
finish_test
|
||||
@ -184,4 +185,69 @@ do_catchsql_test stat-6.1 {
|
||||
CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx);
|
||||
} {1 {no such database: mainx}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that the argument passed to the dbstat constructor is dequoted
|
||||
# before it is matched against the names of attached databases.
|
||||
#
|
||||
forcedelete test.db2
|
||||
do_execsql_test 7.1 {
|
||||
ATTACH 'test.db2' AS '123';
|
||||
CREATE TABLE "123".x1(a, b);
|
||||
INSERT INTO x1 VALUES(1, 2);
|
||||
}
|
||||
|
||||
do_execsql_test 7.1.1 {
|
||||
SELECT * FROM dbstat('123');
|
||||
} {
|
||||
sqlite_master / 1 leaf 1 37 875 37 0 1024
|
||||
x1 / 2 leaf 1 4 1008 4 1024 1024
|
||||
}
|
||||
do_execsql_test 7.1.2 {
|
||||
SELECT * FROM dbstat(123);
|
||||
} {
|
||||
sqlite_master / 1 leaf 1 37 875 37 0 1024
|
||||
x1 / 2 leaf 1 4 1008 4 1024 1024
|
||||
}
|
||||
do_execsql_test 7.1.3 {
|
||||
CREATE VIRTUAL TABLE x2 USING dbstat('123');
|
||||
SELECT * FROM x2;
|
||||
} {
|
||||
sqlite_master / 1 leaf 1 37 875 37 0 1024
|
||||
x1 / 2 leaf 1 4 1008 4 1024 1024
|
||||
}
|
||||
do_execsql_test 7.1.4 {
|
||||
CREATE VIRTUAL TABLE x3 USING dbstat(123);
|
||||
SELECT * FROM x3;
|
||||
} {
|
||||
sqlite_master / 1 leaf 1 37 875 37 0 1024
|
||||
x1 / 2 leaf 1 4 1008 4 1024 1024
|
||||
}
|
||||
|
||||
do_execsql_test 7.2 {
|
||||
DETACH 123;
|
||||
DROP TABLE x2;
|
||||
DROP TABLE x3;
|
||||
ATTACH 'test.db2' AS '123corp';
|
||||
}
|
||||
do_execsql_test 7.2.1 {
|
||||
SELECT * FROM dbstat('123corp');
|
||||
} {
|
||||
sqlite_master / 1 leaf 1 37 875 37 0 1024
|
||||
x1 / 2 leaf 1 4 1008 4 1024 1024
|
||||
}
|
||||
do_catchsql_test 7.2.2 {
|
||||
SELECT * FROM dbstat(123corp);
|
||||
} {1 {unrecognized token: "123corp"}}
|
||||
do_execsql_test 7.2.3 {
|
||||
CREATE VIRTUAL TABLE x2 USING dbstat('123corp');
|
||||
SELECT * FROM x2;
|
||||
} {
|
||||
sqlite_master / 1 leaf 1 37 875 37 0 1024
|
||||
x1 / 2 leaf 1 4 1008 4 1024 1024
|
||||
}
|
||||
do_catchsql_test 7.2.4 {
|
||||
CREATE VIRTUAL TABLE x3 USING dbstat(123corp);
|
||||
SELECT * FROM x3;
|
||||
} {1 {unrecognized token: "123corp"}}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user