mirror of https://github.com/postgres/postgres
constraints The issue with finding and removing foreign key constraints is no longer an issue, so please apply the attached. It does NOT check for rules or on delete triggers (old style foreign keys) as those are difficult to deal with (remove, truncate, re-add). Rod TaylorREL7_3_STABLE
parent
dac22ee43c
commit
47b37a6bfa
@ -0,0 +1,38 @@ |
||||
-- Test basic TRUNCATE functionality. |
||||
CREATE TABLE truncate_a (col1 integer primary key); |
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'truncate_a_pkey' for table 'truncate_a' |
||||
INSERT INTO truncate_a VALUES (1); |
||||
INSERT INTO truncate_a VALUES (2); |
||||
SELECT * FROM truncate_a; |
||||
col1 |
||||
------ |
||||
1 |
||||
2 |
||||
(2 rows) |
||||
|
||||
TRUNCATE truncate_a; |
||||
SELECT * FROM truncate_a; |
||||
col1 |
||||
------ |
||||
(0 rows) |
||||
|
||||
-- Test foreign constraint check |
||||
CREATE TABLE truncate_b(col1 integer references truncate_a); |
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) |
||||
INSERT INTO truncate_a VALUES (1); |
||||
SELECT * FROM truncate_a; |
||||
col1 |
||||
------ |
||||
1 |
||||
(1 row) |
||||
|
||||
TRUNCATE truncate_a; |
||||
ERROR: TRUNCATE cannot be used as other tables reference this one via foreign key constraint $1 |
||||
SELECT * FROM truncate_a; |
||||
col1 |
||||
------ |
||||
1 |
||||
(1 row) |
||||
|
||||
DROP TABLE truncate_b; |
||||
DROP TABLE truncate_a; |
||||
@ -0,0 +1,17 @@ |
||||
-- Test basic TRUNCATE functionality. |
||||
CREATE TABLE truncate_a (col1 integer primary key); |
||||
INSERT INTO truncate_a VALUES (1); |
||||
INSERT INTO truncate_a VALUES (2); |
||||
SELECT * FROM truncate_a; |
||||
TRUNCATE truncate_a; |
||||
SELECT * FROM truncate_a; |
||||
|
||||
-- Test foreign constraint check |
||||
CREATE TABLE truncate_b(col1 integer references truncate_a); |
||||
INSERT INTO truncate_a VALUES (1); |
||||
SELECT * FROM truncate_a; |
||||
TRUNCATE truncate_a; |
||||
SELECT * FROM truncate_a; |
||||
|
||||
DROP TABLE truncate_b; |
||||
DROP TABLE truncate_a; |
||||
Loading…
Reference in new issue