OLD | NEW |
1 # 2009 September 15 | 1 # 2009 September 15 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'} | 1055 catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'} |
1056 } {1 {Cannot add a REFERENCES column with non-NULL default value}} | 1056 } {1 {Cannot add a REFERENCES column with non-NULL default value}} |
1057 do_test fkey2-14.1tmp.5 { | 1057 do_test fkey2-14.1tmp.5 { |
1058 catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 } | 1058 catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 } |
1059 } {1 {Cannot add a REFERENCES column with non-NULL default value}} | 1059 } {1 {Cannot add a REFERENCES column with non-NULL default value}} |
1060 do_test fkey2-14.1tmp.6 { | 1060 do_test fkey2-14.1tmp.6 { |
1061 execsql { | 1061 execsql { |
1062 PRAGMA foreign_keys = off; | 1062 PRAGMA foreign_keys = off; |
1063 ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1; | 1063 ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1; |
1064 PRAGMA foreign_keys = on; | 1064 PRAGMA foreign_keys = on; |
1065 SELECT sql FROM sqlite_temp_master WHERE name='t2'; | 1065 SELECT sql FROM temp.sqlite_master WHERE name='t2'; |
1066 } | 1066 } |
1067 } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REF
ERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}} | 1067 } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REF
ERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}} |
1068 | 1068 |
1069 do_test fkey2-14.2tmp.1.1 { | 1069 do_test fkey2-14.2tmp.1.1 { |
1070 test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3 | 1070 test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3 |
1071 } {{CREATE TABLE t1(a REFERENCES "t3")}} | 1071 } {{CREATE TABLE t1(a REFERENCES "t3")}} |
1072 do_test fkey2-14.2tmp.1.2 { | 1072 do_test fkey2-14.2tmp.1.2 { |
1073 test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3 | 1073 test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3 |
1074 } {{CREATE TABLE t1(a REFERENCES t2)}} | 1074 } {{CREATE TABLE t1(a REFERENCES t2)}} |
1075 do_test fkey2-14.2tmp.1.3 { | 1075 do_test fkey2-14.2tmp.1.3 { |
(...skipping 10 matching lines...) Expand all Loading... |
1086 CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1); | 1086 CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1); |
1087 } | 1087 } |
1088 execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'} | 1088 execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'} |
1089 } [list \ | 1089 } [list \ |
1090 {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \ | 1090 {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)} \ |
1091 {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \ | 1091 {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)} \ |
1092 {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \ | 1092 {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \ |
1093 ] | 1093 ] |
1094 do_test fkey2-14.2tmp.2.2 { | 1094 do_test fkey2-14.2tmp.2.2 { |
1095 execsql { ALTER TABLE t1 RENAME TO t4 } | 1095 execsql { ALTER TABLE t1 RENAME TO t4 } |
1096 execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'} | 1096 execsql { SELECT sql FROM temp.sqlite_master WHERE type = 'table'} |
1097 } [list \ | 1097 } [list \ |
1098 {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \ | 1098 {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")} \ |
1099 {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \ | 1099 {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)} \ |
1100 {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \ | 1100 {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \ |
1101 ] | 1101 ] |
1102 do_test fkey2-14.2tmp.2.3 { | 1102 do_test fkey2-14.2tmp.2.3 { |
1103 catchsql { INSERT INTO t3 VALUES(1, 2, 3) } | 1103 catchsql { INSERT INTO t3 VALUES(1, 2, 3) } |
1104 } {1 {FOREIGN KEY constraint failed}} | 1104 } {1 {FOREIGN KEY constraint failed}} |
1105 do_test fkey2-14.2tmp.2.4 { | 1105 do_test fkey2-14.2tmp.2.4 { |
1106 execsql { INSERT INTO t4 VALUES(1, NULL) } | 1106 execsql { INSERT INTO t4 VALUES(1, NULL) } |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 catchsql { | 2027 catchsql { |
2028 PRAGMA foreign_keys=1; | 2028 PRAGMA foreign_keys=1; |
2029 CREATE TABLE t1(x PRIMARY KEY); | 2029 CREATE TABLE t1(x PRIMARY KEY); |
2030 CREATE TABLE t(y REFERENCES t0(x)ON DELETE SET DEFAULT); | 2030 CREATE TABLE t(y REFERENCES t0(x)ON DELETE SET DEFAULT); |
2031 CREATE TABLE t0(y REFERENCES t1 ON DELETE SET NULL); | 2031 CREATE TABLE t0(y REFERENCES t1 ON DELETE SET NULL); |
2032 REPLACE INTO t1 SELECT(0);CREATE TABLE t2(x);CREATE TABLE t3; | 2032 REPLACE INTO t1 SELECT(0);CREATE TABLE t2(x);CREATE TABLE t3; |
2033 } | 2033 } |
2034 } {1 {foreign key mismatch - "t" referencing "t0"}} | 2034 } {1 {foreign key mismatch - "t" referencing "t0"}} |
2035 | 2035 |
2036 finish_test | 2036 finish_test |
OLD | NEW |