Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit401a695

Browse files
Disallow COPY FREEZE on foreign tables.
This didn't actually work: the COPY succeeds, but the FREEZEoptimization isn't applied. There doesn't seem to be an easy wayto support FREEZE on foreign tables, so let's follow the precedentestablished by commit5c9a551 by raising an error early. Thisis arguably a bug fix, but due to the lack of reports, the minimaldiscussion on the mailing list, and the potential to break existingscripts, I am not back-patching it for now.Author: Sami Imseih <samimseih@gmail.com>Reviewed-by: Zhang Mingli <zmlpostgres@gmail.com>Discussion:https://postgr.es/m/CAA5RZ0ujeNgKpE3OrLtR%3DeJGa5LkGMekFzQTwjgw%3DrzaLufQLQ%40mail.gmail.com
1 parenta99a32e commit401a695

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

‎doc/src/sgml/ref/copy.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
237237
or truncated in the current subtransaction, there are no cursors
238238
open and there are no older snapshots held by this transaction. It is
239239
currently not possible to perform a <command>COPY FREEZE</command> on
240-
a partitioned table.
240+
a partitioned table or foreign table.
241241
This option is only allowed in <command>COPY FROM</command>.
242242
</para>
243243
<para>

‎src/backend/commands/copyfrom.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,12 @@ CopyFrom(CopyFromState cstate)
740740
errmsg("cannot perform COPY FREEZE on a partitioned table")));
741741
}
742742

743+
/* There's currently no support for COPY FREEZE on foreign tables. */
744+
if (cstate->rel->rd_rel->relkind==RELKIND_FOREIGN_TABLE)
745+
ereport(ERROR,
746+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
747+
errmsg("cannot perform COPY FREEZE on a foreign table")));
748+
743749
/*
744750
* Tolerate one registration for the benefit of FirstXactSnapshot.
745751
* Scan-bearing queries generally create at least two registrations,

‎src/test/regress/expected/copy.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,11 @@ SELECT tableoid::regclass, id % 2 = 0 is_even, count(*) from parted_si GROUP BY
325325
(2 rows)
326326

327327
DROP TABLE parted_si;
328+
-- ensure COPY FREEZE errors for foreign tables
329+
begin;
330+
create foreign data wrapper copytest_wrapper;
331+
create server copytest_server foreign data wrapper copytest_wrapper;
332+
create foreign table copytest_foreign_table (a int) server copytest_server;
333+
copy copytest_foreign_table from stdin (freeze);
334+
ERROR: cannot perform COPY FREEZE on a foreign table
335+
rollback;

‎src/test/regress/sql/copy.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,13 @@ COPY parted_si(id, data) FROM :'filename';
348348
SELECT tableoid::regclass, id %2=0 is_even,count(*)from parted_siGROUP BY1,2ORDER BY1;
349349

350350
DROPTABLE parted_si;
351+
352+
-- ensure COPY FREEZE errors for foreign tables
353+
begin;
354+
create foreign data wrapper copytest_wrapper;
355+
create server copytest_server foreign data wrapper copytest_wrapper;
356+
create foreign table copytest_foreign_table (aint) server copytest_server;
357+
copy copytest_foreign_tablefrom stdin (freeze);
358+
1
359+
\.
360+
rollback;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp