@@ -25,7 +25,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
25
25
SELECT * FROM truncate_a;
26
26
col1
27
27
------
28
- @@ -32,42 +34,27 @@
28
+ @@ -32,42 +34,34 @@
29
29
-- Test foreign-key checks
30
30
CREATE TABLE trunc_b (a int REFERENCES truncate_a);
31
31
CREATE TABLE trunc_c (a serial PRIMARY KEY);
@@ -37,72 +37,83 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
37
37
-DETAIL: Table "trunc_b" references "truncate_a".
38
38
-HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE.
39
39
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
40
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
40
41
TRUNCATE TABLE truncate_a,trunc_b; -- fail
41
42
-ERROR: cannot truncate a table referenced in a foreign key constraint
42
43
-DETAIL: Table "trunc_e" references "truncate_a".
43
44
-HINT: Truncate table "trunc_e" at the same time, or use TRUNCATE ... CASCADE.
44
45
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_e"
46
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
45
47
TRUNCATE TABLE truncate_a,trunc_b,trunc_e; -- ok
46
48
TRUNCATE TABLE truncate_a,trunc_e; -- fail
47
49
-ERROR: cannot truncate a table referenced in a foreign key constraint
48
50
-DETAIL: Table "trunc_b" references "truncate_a".
49
51
-HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE.
50
52
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
53
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
51
54
TRUNCATE TABLE trunc_c; -- fail
52
55
-ERROR: cannot truncate a table referenced in a foreign key constraint
53
56
-DETAIL: Table "trunc_d" references "trunc_c".
54
57
-HINT: Truncate table "trunc_d" at the same time, or use TRUNCATE ... CASCADE.
55
58
+ERROR: "trunc_c" is referenced by foreign key from table "trunc_d"
59
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
56
60
TRUNCATE TABLE trunc_c,trunc_d; -- fail
57
61
-ERROR: cannot truncate a table referenced in a foreign key constraint
58
62
-DETAIL: Table "trunc_e" references "trunc_c".
59
63
-HINT: Truncate table "trunc_e" at the same time, or use TRUNCATE ... CASCADE.
60
64
+ERROR: "trunc_c" is referenced by foreign key from table "trunc_e"
65
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
61
66
TRUNCATE TABLE trunc_c,trunc_d,trunc_e; -- ok
62
67
TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a; -- fail
63
68
-ERROR: cannot truncate a table referenced in a foreign key constraint
64
69
-DETAIL: Table "trunc_b" references "truncate_a".
65
70
-HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE.
66
71
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
72
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
67
73
TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b; -- ok
68
74
TRUNCATE TABLE truncate_a RESTRICT; -- fail
69
75
-ERROR: cannot truncate a table referenced in a foreign key constraint
70
76
-DETAIL: Table "trunc_b" references "truncate_a".
71
77
-HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE.
72
78
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
79
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
73
80
TRUNCATE TABLE truncate_a CASCADE; -- ok
74
81
-NOTICE: truncate cascades to table "trunc_b"
75
82
-NOTICE: truncate cascades to table "trunc_e"
76
83
-- circular references
77
84
ALTER TABLE truncate_a ADD FOREIGN KEY (col1) REFERENCES trunc_c;
78
85
-- Add some data to verify that truncating actually works ...
79
- @@ -77,21 +64,13 @@
86
+ @@ -77,21 +71,17 @@
80
87
INSERT INTO trunc_d VALUES (1);
81
88
INSERT INTO trunc_e VALUES (1,1);
82
89
TRUNCATE TABLE trunc_c;
83
90
-ERROR: cannot truncate a table referenced in a foreign key constraint
84
91
-DETAIL: Table "truncate_a" references "trunc_c".
85
92
-HINT: Truncate table "truncate_a" at the same time, or use TRUNCATE ... CASCADE.
86
93
+ERROR: "trunc_c" is referenced by foreign key from table "truncate_a"
94
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
87
95
TRUNCATE TABLE trunc_c,truncate_a;
88
96
-ERROR: cannot truncate a table referenced in a foreign key constraint
89
97
-DETAIL: Table "trunc_d" references "trunc_c".
90
98
-HINT: Truncate table "trunc_d" at the same time, or use TRUNCATE ... CASCADE.
91
99
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
100
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
92
101
TRUNCATE TABLE trunc_c,truncate_a,trunc_d;
93
102
-ERROR: cannot truncate a table referenced in a foreign key constraint
94
103
-DETAIL: Table "trunc_e" references "trunc_c".
95
104
-HINT: Truncate table "trunc_e" at the same time, or use TRUNCATE ... CASCADE.
96
105
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
106
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
97
107
TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e;
98
108
-ERROR: cannot truncate a table referenced in a foreign key constraint
99
109
-DETAIL: Table "trunc_b" references "truncate_a".
100
110
-HINT: Truncate table "trunc_b" at the same time, or use TRUNCATE ... CASCADE.
101
111
+ERROR: "truncate_a" is referenced by foreign key from table "trunc_b"
112
+ +HINT: truncate dependent tables at the same time or specify the CASCADE option
102
113
TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e,trunc_b;
103
114
-- Verify that truncating did actually work
104
115
SELECT * FROM truncate_a
105
- @@ -117,10 +96 ,6 @@
116
+ @@ -117,10 +107 ,6 @@
106
117
INSERT INTO trunc_d VALUES (1);
107
118
INSERT INTO trunc_e VALUES (1,1);
108
119
TRUNCATE TABLE trunc_c CASCADE; -- ok
@@ -113,7 +124,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
113
124
SELECT * FROM truncate_a
114
125
UNION ALL
115
126
SELECT * FROM trunc_c
116
- @@ -143,144 +118 ,103 @@
127
+ @@ -143,144 +129 ,103 @@
117
128
INSERT INTO trunc_f VALUES (1);
118
129
INSERT INTO trunc_f VALUES (2);
119
130
CREATE TABLE trunc_fa (col2a text) INHERITS (trunc_f);
@@ -300,7 +311,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
300
311
-- Test ON TRUNCATE triggers
301
312
CREATE TABLE trunc_trigger_test (f1 int, f2 text, f3 text);
302
313
CREATE TABLE trunc_trigger_log (tgop text, tglevel text, tgwhen text,
303
- @@ -294,12 +228 ,26 @@
314
+ @@ -294,12 +239 ,26 @@
304
315
return null;
305
316
end;
306
317
$$ LANGUAGE plpgsql;
@@ -327,7 +338,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
327
338
SELECT count(*) as "Row count in test table" FROM trunc_trigger_test;
328
339
Row count in test table
329
340
-------------------------
330
- @@ -319,12 +267 ,12 @@
341
+ @@ -319,12 +278 ,12 @@
331
342
(1 row)
332
343
333
344
SELECT * FROM trunc_trigger_log;
@@ -344,15 +355,15 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
344
355
truncate trunc_trigger_log;
345
356
-- same test with an after trigger
346
357
INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux');
347
- @@ -332,6 +280 ,7 @@
358
+ @@ -332,6 +291 ,7 @@
348
359
AFTER TRUNCATE ON trunc_trigger_test
349
360
FOR EACH STATEMENT
350
361
EXECUTE PROCEDURE trunctrigger('after trigger truncate');
351
362
+ERROR: unknown function: trunctrigger()
352
363
SELECT count(*) as "Row count in test table" FROM trunc_trigger_test;
353
364
Row count in test table
354
365
-------------------------
355
- @@ -351,17 +300 ,18 @@
366
+ @@ -351,17 +311 ,18 @@
356
367
(1 row)
357
368
358
369
SELECT * FROM trunc_trigger_log;
@@ -376,7 +387,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
376
387
id1 integer default nextval('truncate_a_id1'));
377
388
ALTER SEQUENCE truncate_a_id1 OWNED BY truncate_a.id1;
378
389
INSERT INTO truncate_a DEFAULT VALUES;
379
- @@ -384,14 +334 ,20 @@
390
+ @@ -384,14 +345 ,20 @@
380
391
(2 rows)
381
392
382
393
TRUNCATE truncate_a RESTART IDENTITY;
@@ -400,7 +411,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
400
411
401
412
CREATE TABLE truncate_b (id int GENERATED ALWAYS AS IDENTITY (START WITH 44));
402
413
INSERT INTO truncate_b DEFAULT VALUES;
403
- @@ -414,56 +370 ,74 @@
414
+ @@ -414,56 +381 ,74 @@
404
415
(2 rows)
405
416
406
417
TRUNCATE truncate_b RESTART IDENTITY;
@@ -492,15 +503,15 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/truncate.out --la
492
503
-- foreign key on partitioned table: partition key is referencing column.
493
504
-- Make sure truncate did execute on all tables
494
505
CREATE FUNCTION tp_ins_data() RETURNS void LANGUAGE plpgsql AS $$
495
- @@ -472,6 +446 ,7 @@
506
+ @@ -472,6 +457 ,7 @@
496
507
INSERT INTO truncpart VALUES (1), (100), (150);
497
508
END
498
509
$$;
499
510
+ERROR: relation "truncprim" does not exist
500
511
CREATE FUNCTION tp_chk_data(OUT pktb regclass, OUT pkval int, OUT fktb regclass, OUT fkval int)
501
512
RETURNS SETOF record LANGUAGE plpgsql AS $$
502
513
BEGIN
503
- @@ -481,114 +456 ,158 @@
514
+ @@ -481,114 +467 ,158 @@
504
515
ORDER BY 2, 4;
505
516
END
506
517
$$;
0 commit comments