Remove useless tests about TRUNCATE on foreign table

Started by Yugo NAGATAover 3 years ago4 messages
#1Yugo NAGATA
nagata@sraoss.co.jp
1 attachment(s)

Hello,

I found that tests for TRUNCATE on foreign tables are left
in the foreign_data regression test. Now TRUNCATE on foreign
tables are allowed, so I think the tests should be removed.

Currently, the results of the test is
"ERROR: foreign-data wrapper "dummy" has no handler",
but it is just because the foreign table has no handler,
not due to TRUNCATE.

The patch is attached.

Regards,
Yugo Nagata

--
Yugo NAGATA <nagata@sraoss.co.jp>

Attachments:

fix_foreign_data_test.patchtext/x-diff; name=fix_foreign_data_test.patchDownload
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index 5bf03680d2..33505352cc 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -1822,11 +1822,6 @@ Server: s0
 FDW options: (delimiter ',', quote '"', "be quoted" 'value')
 Inherits: fd_pt1
 
--- TRUNCATE doesn't work on foreign tables, either directly or recursively
-TRUNCATE ft2;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
-TRUNCATE fd_pt1;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
 DROP TABLE fd_pt1 CASCADE;
 NOTICE:  drop cascades to foreign table ft2
 -- IMPORT FOREIGN SCHEMA
@@ -2047,11 +2042,6 @@ ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);       -- ERROR
 ERROR:  child table is missing constraint "fd_pt2chk1"
 ALTER FOREIGN TABLE fd_pt2_1 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0);
 ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
--- TRUNCATE doesn't work on foreign tables, either directly or recursively
-TRUNCATE fd_pt2_1;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
-TRUNCATE fd_pt2;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
 DROP FOREIGN TABLE fd_pt2_1;
 DROP TABLE fd_pt2;
 -- foreign table cannot be part of partition tree made of temporary
diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql
index 9dfff66f54..eefb860adc 100644
--- a/src/test/regress/sql/foreign_data.sql
+++ b/src/test/regress/sql/foreign_data.sql
@@ -746,10 +746,6 @@ ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check;
 \d+ fd_pt1
 \d+ ft2
 
--- TRUNCATE doesn't work on foreign tables, either directly or recursively
-TRUNCATE ft2;  -- ERROR
-TRUNCATE fd_pt1;  -- ERROR
-
 DROP TABLE fd_pt1 CASCADE;
 
 -- IMPORT FOREIGN SCHEMA
@@ -833,10 +829,6 @@ ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);       -- ERROR
 ALTER FOREIGN TABLE fd_pt2_1 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0);
 ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
 
--- TRUNCATE doesn't work on foreign tables, either directly or recursively
-TRUNCATE fd_pt2_1;  -- ERROR
-TRUNCATE fd_pt2;  -- ERROR
-
 DROP FOREIGN TABLE fd_pt2_1;
 DROP TABLE fd_pt2;
 
#2Michael Paquier
michael@paquier.xyz
In reply to: Yugo NAGATA (#1)
Re: Remove useless tests about TRUNCATE on foreign table

On Fri, May 27, 2022 at 05:25:43PM +0900, Yugo NAGATA wrote:

--- TRUNCATE doesn't work on foreign tables, either directly or recursively
-TRUNCATE ft2;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
-TRUNCATE fd_pt1;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
DROP TABLE fd_pt1 CASCADE;

In the case of this test, fd_pt1 is a normal table that ft2 inherits,
so this TRUNCATE command somewhat checks that the TRUNCATE falls back
to the foreign table in this case. However, this happens to be tested
in postgres_fdw (see around tru_ftable_parent),

--- TRUNCATE doesn't work on foreign tables, either directly or recursively
-TRUNCATE fd_pt2_1;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler
-TRUNCATE fd_pt2;  -- ERROR
-ERROR:  foreign-data wrapper "dummy" has no handler

Partitions have also some coverage as far as I can see, so I agree
that it makes little sense to keep the tests you are removing here.
--
Michael

#3Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#2)
Re: Remove useless tests about TRUNCATE on foreign table

On Mon, May 30, 2022 at 05:08:10PM +0900, Michael Paquier wrote:

Partitions have also some coverage as far as I can see, so I agree
that it makes little sense to keep the tests you are removing here.

And done as of 0efa513.
--
Michael

#4Yugo NAGATA
nagata@sraoss.co.jp
In reply to: Michael Paquier (#3)
Re: Remove useless tests about TRUNCATE on foreign table

On Tue, 31 May 2022 09:49:40 +0900
Michael Paquier <michael@paquier.xyz> wrote:

On Mon, May 30, 2022 at 05:08:10PM +0900, Michael Paquier wrote:

Partitions have also some coverage as far as I can see, so I agree
that it makes little sense to keep the tests you are removing here.

And done as of 0efa513.

Thank you!

--
Yugo NAGATA <nagata@sraoss.co.jp>