Hello,

During checking regression tests of TRUNCATE on foreign
tables for other patch [1], I found that there is no test
for foreign tables that don't support TRUNCATE. 

When a foreign table has handler but doesn't support TRUNCATE,
an error "cannot truncate foreign table xxx" occurs. So, what
about adding a test this message output? We can add this test
for file_fdw because it is one of the such foreign data wrappers.

I attached a patch.

[1] https://postgr.es/m/20220527172543.0a2fdb469cf048b81c096...@sraoss.co.jp

-- 
Yugo NAGATA <nag...@sraoss.co.jp>
diff --git a/contrib/file_fdw/expected/file_fdw.out b/contrib/file_fdw/expected/file_fdw.out
index 0029f36b35..261af1a8b5 100644
--- a/contrib/file_fdw/expected/file_fdw.out
+++ b/contrib/file_fdw/expected/file_fdw.out
@@ -246,6 +246,8 @@ UPDATE agg_csv SET a = 1;
 ERROR:  cannot update foreign table "agg_csv"
 DELETE FROM agg_csv WHERE a = 100;
 ERROR:  cannot delete from foreign table "agg_csv"
+TRUNCATE agg_csv;
+ERROR:  cannot truncate foreign table "agg_csv"
 -- but this should be allowed
 SELECT * FROM agg_csv FOR UPDATE;
   a  |    b    
diff --git a/contrib/file_fdw/sql/file_fdw.sql b/contrib/file_fdw/sql/file_fdw.sql
index 563d824ccc..46670397ca 100644
--- a/contrib/file_fdw/sql/file_fdw.sql
+++ b/contrib/file_fdw/sql/file_fdw.sql
@@ -166,6 +166,7 @@ SELECT tableoid::regclass, b FROM agg_csv;
 INSERT INTO agg_csv VALUES(1,2.0);
 UPDATE agg_csv SET a = 1;
 DELETE FROM agg_csv WHERE a = 100;
+TRUNCATE agg_csv;
 -- but this should be allowed
 SELECT * FROM agg_csv FOR UPDATE;
 

Reply via email to