diff options
| author | Tom Lane | 2006-06-29 16:07:29 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-06-29 16:07:29 +0000 |
| commit | cd4609e2a4674d81f9a6d993636d47ab853ec660 (patch) | |
| tree | 1202d91e8c0a2755bed53646bc81f6dde566dbc6 /src/test | |
| parent | bc9b6c22d5b1f96054349466a7ab650ebb10a119 (diff) | |
Change TRUNCATE's method for searching for foreign-key references so that
the order in which it visits tables is not dependent on the physical order
of pg_constraint entries, and neither are the error messages it gives.
This should correct recently-noticed instability in regression tests.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/temp.out | 2 | ||||
| -rw-r--r-- | src/test/regress/expected/truncate.out | 36 | ||||
| -rw-r--r-- | src/test/regress/sql/truncate.sql | 8 |
3 files changed, 23 insertions, 23 deletions
diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out index c9a14fc435b..3ba19b55a81 100644 --- a/src/test/regress/expected/temp.out +++ b/src/test/regress/expected/temp.out @@ -136,4 +136,4 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "temptest3_pkey" CREATE TEMP TABLE temptest4(col int REFERENCES temptest3); COMMIT; ERROR: unsupported ON COMMIT and foreign key combination -DETAIL: Table "temptest4" references "temptest3" via foreign key constraint "temptest4_col_fkey", but they do not have the same ON COMMIT setting. +DETAIL: Table "temptest4" references "temptest3", but they do not have the same ON COMMIT setting. diff --git a/src/test/regress/expected/truncate.out b/src/test/regress/expected/truncate.out index 263c5c8e083..95aa3737954 100644 --- a/src/test/regress/expected/truncate.out +++ b/src/test/regress/expected/truncate.out @@ -39,34 +39,34 @@ CREATE TABLE trunc_d (a int REFERENCES trunc_c); CREATE TABLE trunc_e (a int REFERENCES truncate_a, b int REFERENCES trunc_c); TRUNCATE TABLE truncate_a; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_b" references "truncate_a" via foreign key constraint "trunc_b_a_fkey". +DETAIL: Table "trunc_b" references "truncate_a". HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE truncate_a,trunc_b; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_e" references "truncate_a" via foreign key constraint "trunc_e_a_fkey". +DETAIL: Table "trunc_e" references "truncate_a". HINT: Truncate table "trunc_e" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE truncate_a,trunc_b,trunc_e; -- ok TRUNCATE TABLE truncate_a,trunc_e; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_b" references "truncate_a" via foreign key constraint "trunc_b_a_fkey". +DETAIL: Table "trunc_b" references "truncate_a". HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE trunc_c; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_d" references "trunc_c" via foreign key constraint "trunc_d_a_fkey". +DETAIL: Table "trunc_d" references "trunc_c". HINT: Truncate table "trunc_d" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE trunc_c,trunc_d; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_e" references "trunc_c" via foreign key constraint "trunc_e_b_fkey". +DETAIL: Table "trunc_e" references "trunc_c". HINT: Truncate table "trunc_e" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE trunc_c,trunc_d,trunc_e; -- ok TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_b" references "truncate_a" via foreign key constraint "trunc_b_a_fkey". +DETAIL: Table "trunc_b" references "truncate_a". HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b; -- ok TRUNCATE TABLE truncate_a RESTRICT; -- fail ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_b" references "truncate_a" via foreign key constraint "trunc_b_a_fkey". +DETAIL: Table "trunc_b" references "truncate_a". HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. TRUNCATE TABLE truncate_a CASCADE; -- ok NOTICE: truncate cascades to table "trunc_b" @@ -81,21 +81,21 @@ INSERT INTO trunc_d VALUES (1); INSERT INTO trunc_e VALUES (1,1); TRUNCATE TABLE trunc_c; ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_d" references "trunc_c" via foreign key constraint "trunc_d_a_fkey". +DETAIL: Table "truncate_a" references "trunc_c". +HINT: Truncate table "truncate_a" at the same time, or use TRUNCATE ... CASCADE. +TRUNCATE TABLE trunc_c,truncate_a; +ERROR: cannot truncate a table referenced in a foreign key constraint +DETAIL: Table "trunc_d" references "trunc_c". HINT: Truncate table "trunc_d" at the same time, or use TRUNCATE ... CASCADE. -TRUNCATE TABLE trunc_c,trunc_d; +TRUNCATE TABLE trunc_c,truncate_a,trunc_d; ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_e" references "trunc_c" via foreign key constraint "trunc_e_b_fkey". +DETAIL: Table "trunc_e" references "trunc_c". HINT: Truncate table "trunc_e" at the same time, or use TRUNCATE ... CASCADE. -TRUNCATE TABLE trunc_c,trunc_d,trunc_e; -ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "truncate_a" references "trunc_c" via foreign key constraint "truncate_a_col1_fkey". -HINT: Truncate table "truncate_a" at the same time, or use TRUNCATE ... CASCADE. -TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a; +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e; ERROR: cannot truncate a table referenced in a foreign key constraint -DETAIL: Table "trunc_b" references "truncate_a" via foreign key constraint "trunc_b_a_fkey". +DETAIL: Table "trunc_b" references "truncate_a". HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE. -TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b; +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e,trunc_b; -- Verify that truncating did actually work SELECT * FROM truncate_a UNION ALL @@ -120,9 +120,9 @@ INSERT INTO trunc_b VALUES (1); INSERT INTO trunc_d VALUES (1); INSERT INTO trunc_e VALUES (1,1); TRUNCATE TABLE trunc_c CASCADE; -- ok +NOTICE: truncate cascades to table "truncate_a" NOTICE: truncate cascades to table "trunc_d" NOTICE: truncate cascades to table "trunc_e" -NOTICE: truncate cascades to table "truncate_a" NOTICE: truncate cascades to table "trunc_b" SELECT * FROM truncate_a UNION ALL diff --git a/src/test/regress/sql/truncate.sql b/src/test/regress/sql/truncate.sql index a4d27d01e1f..9f8420b1844 100644 --- a/src/test/regress/sql/truncate.sql +++ b/src/test/regress/sql/truncate.sql @@ -43,10 +43,10 @@ INSERT INTO trunc_b VALUES (1); INSERT INTO trunc_d VALUES (1); INSERT INTO trunc_e VALUES (1,1); TRUNCATE TABLE trunc_c; -TRUNCATE TABLE trunc_c,trunc_d; -TRUNCATE TABLE trunc_c,trunc_d,trunc_e; -TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a; -TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b; +TRUNCATE TABLE trunc_c,truncate_a; +TRUNCATE TABLE trunc_c,truncate_a,trunc_d; +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e; +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e,trunc_b; -- Verify that truncating did actually work SELECT * FROM truncate_a |
