diff options
Diffstat (limited to 'contrib/postgres_fdw/sql/postgres_fdw.sql')
-rw-r--r-- | contrib/postgres_fdw/sql/postgres_fdw.sql | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql index 74590089bd1..dcd36a9753e 100644 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@ -2355,7 +2355,6 @@ drop table loc3; -- test for TRUNCATE -- =================================================================== CREATE TABLE tru_rtable0 (id int primary key); -CREATE TABLE tru_rtable1 (id int primary key); CREATE FOREIGN TABLE tru_ftable (id int) SERVER loopback OPTIONS (table_name 'tru_rtable0'); INSERT INTO tru_rtable0 (SELECT x FROM generate_series(1,10) x); @@ -2363,6 +2362,7 @@ INSERT INTO tru_rtable0 (SELECT x FROM generate_series(1,10) x); CREATE TABLE tru_ptable (id int) PARTITION BY HASH(id); CREATE TABLE tru_ptable__p0 PARTITION OF tru_ptable FOR VALUES WITH (MODULUS 2, REMAINDER 0); +CREATE TABLE tru_rtable1 (id int primary key); CREATE FOREIGN TABLE tru_ftable__p1 PARTITION OF tru_ptable FOR VALUES WITH (MODULUS 2, REMAINDER 1) SERVER loopback OPTIONS (table_name 'tru_rtable1'); @@ -2428,6 +2428,8 @@ SELECT count(*) from tru_ftable; -- 0 SELECT count(*) from tru_pk_ftable; -- 0 -- truncate with ONLY clause +-- Since ONLY is specified, the table tru_ftable_child that inherits +-- tru_ftable_parent locally is not truncated. TRUNCATE ONLY tru_ftable_parent; SELECT sum(id) FROM tru_ftable_parent; -- 126 TRUNCATE tru_ftable_parent; @@ -2439,13 +2441,17 @@ INSERT INTO tru_rtable0 (SELECT x FROM generate_series(5,9) x); INSERT INTO tru_rtable0_child (SELECT x FROM generate_series(10,14) x); SELECT sum(id) FROM tru_ftable; -- 95 -TRUNCATE ONLY tru_ftable; -- truncate only parent portion -SELECT sum(id) FROM tru_ftable; -- 60 +-- Both parent and child tables in the foreign server are truncated +-- even though ONLY is specified because ONLY has no effect +-- when truncating a foreign table. +TRUNCATE ONLY tru_ftable; +SELECT count(*) FROM tru_ftable; -- 0 INSERT INTO tru_rtable0 (SELECT x FROM generate_series(21,25) x); -SELECT sum(id) FROM tru_ftable; -- 175 +INSERT INTO tru_rtable0_child (SELECT x FROM generate_series(26,30) x); +SELECT sum(id) FROM tru_ftable; -- 255 TRUNCATE tru_ftable; -- truncate both of parent and child -SELECT count(*) FROM tru_ftable; -- empty +SELECT count(*) FROM tru_ftable; -- 0 -- cleanup DROP FOREIGN TABLE tru_ftable_parent, tru_ftable_child, tru_pk_ftable,tru_ftable__p1,tru_ftable; |