mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix the pragma_foreign_key_check virtual table so that it accepts arguments.
FossilOrigin-Name: 07f849dee3d245ecf80ba3c3ce8dfc630e71ddb1e9c0bcc1f08cee22001fcb07
This commit is contained in:
@ -450,5 +450,39 @@ do_execsql_test 12.1 {
|
||||
PRAGMA foreign_key_check=t1;
|
||||
} {t1 9 t2 0}
|
||||
|
||||
# 2020-07-03: the pragma_foreign_key_check virtual table should
|
||||
# accept arguments for the table name and/or schema name.
|
||||
#
|
||||
do_execsql_test 13.0 {
|
||||
SELECT *, 'x' FROM pragma_foreign_key_check('t1');
|
||||
} {t1 9 t2 0 x}
|
||||
do_catchsql_test 13.1 {
|
||||
SELECT *, 'x' FROM pragma_foreign_key_check('t1','main');
|
||||
} {1 {no such table: main.t1}}
|
||||
do_execsql_test 13.2 {
|
||||
SELECT *, 'x' FROM pragma_foreign_key_check('t1','aux');
|
||||
} {t1 9 t2 0 x}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 13.10 {
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT REFERENCES t2);
|
||||
CREATE TABLE t2(x TEXT PRIMARY KEY, y INT);
|
||||
CREATE TABLE t3(w TEXT, z INT REFERENCES t1);
|
||||
INSERT INTO t2 VALUES('abc',11),('def',22),('xyz',99);
|
||||
INSERT INTO t1 VALUES(5,'abc'),(7,'xyz'),(9,'oops');
|
||||
INSERT INTO t3 VALUES(11,7),(22,19);
|
||||
} {}
|
||||
do_execsql_test 13.11 {
|
||||
SELECT x.*, '|'
|
||||
FROM sqlite_schema, pragma_foreign_key_check(name) AS x
|
||||
WHERE type='table'
|
||||
ORDER BY x."table";
|
||||
} {t1 9 t2 0 | t3 2 t1 0 |}
|
||||
do_execsql_test 13.12 {
|
||||
SELECT *, '|'
|
||||
FROM pragma_foreign_key_check AS x
|
||||
ORDER BY x."table";
|
||||
} {t1 9 t2 0 | t3 2 t1 0 |}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user