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

Commit33215d1

Browse files
committed
file_fdw: Fix for generated columns
Since file_fdw uses COPY internally, but COPY doesn't allow listinggenerated columns in its column list, we need to make sure that wedon't add generated columns to the column lists internally generatedby file_fdw.Reported-by: Erik Rijkers <er@xs4all.nl>
1 parent6f0e190 commit33215d1

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

‎contrib/file_fdw/file_fdw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,10 @@ check_selective_binary_conversion(RelOptInfo *baserel,
922922
/* Skip dropped attributes (probably shouldn't see any here). */
923923
if (attr->attisdropped)
924924
continue;
925+
/* Skip generated columns (COPY won't accept them in the column
926+
* list) */
927+
if (attr->attgenerated)
928+
continue;
925929
*columns=lappend(*columns,makeString(pstrdup(attname)));
926930
}
927931
}

‎contrib/file_fdw/input/file_fdw.source

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ SELECT tableoid::regclass, * FROM p1;
189189
SELECT tableoid::regclass, * FROM p2;
190190
DROP TABLE pt;
191191

192+
-- generated column tests
193+
CREATE FOREIGN TABLE gft1 (a int, b text, c text GENERATED ALWAYS AS ('foo') STORED) SERVER file_server
194+
OPTIONS (format 'csv', filename '@abs_srcdir@/data/list1.csv', delimiter ',');
195+
SELECT a, c FROM gft1;
196+
DROP FOREIGN TABLE gft1;
197+
192198
-- privilege tests
193199
SET ROLE regress_file_fdw_superuser;
194200
SELECT * FROM agg_text ORDER BY a;

‎contrib/file_fdw/output/file_fdw.source

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,17 @@ SELECT tableoid::regclass, * FROM p2;
375375
(3 rows)
376376

377377
DROP TABLE pt;
378+
-- generated column tests
379+
CREATE FOREIGN TABLE gft1 (a int, b text, c text GENERATED ALWAYS AS ('foo') STORED) SERVER file_server
380+
OPTIONS (format 'csv', filename '@abs_srcdir@/data/list1.csv', delimiter ',');
381+
SELECT a, c FROM gft1;
382+
a | c
383+
---+--------
384+
1 | _null_
385+
1 | _null_
386+
(2 rows)
387+
388+
DROP FOREIGN TABLE gft1;
378389
-- privilege tests
379390
SET ROLE regress_file_fdw_superuser;
380391
SELECT * FROM agg_text ORDER BY a;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp