mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add a DEFAULT option to COPY FROM
This allows for a string which if an input field matches causes the column's default value to be inserted. The advantage of this is that the default can be inserted in some rows and not others, for which non-default data is available. The file_fdw extension is also modified to take allow use of this option. Israel Barth Rubio Discussion: https://postgr.es/m/CAO_rXXAcqesk6DsvioOZ5zmeEmpUN5ktZf-9=9yu+DTr0Xr8Uw@mail.gmail.com
This commit is contained in:
@ -233,6 +233,17 @@ OPTIONS (format 'csv', filename :'filename', delimiter ',');
|
||||
SELECT a, c FROM gft1;
|
||||
DROP FOREIGN TABLE gft1;
|
||||
|
||||
-- copy default tests
|
||||
\set filename :abs_srcdir '/data/copy_default.csv'
|
||||
CREATE FOREIGN TABLE copy_default (
|
||||
id integer,
|
||||
text_value text not null default 'test',
|
||||
ts_value timestamp without time zone not null default '2022-07-05'
|
||||
) SERVER file_server
|
||||
OPTIONS (format 'csv', filename :'filename', default '\D');
|
||||
SELECT id, text_value, ts_value FROM copy_default;
|
||||
DROP FOREIGN TABLE copy_default;
|
||||
|
||||
-- privilege tests
|
||||
SET ROLE regress_file_fdw_superuser;
|
||||
SELECT * FROM agg_text ORDER BY a;
|
||||
|
Reference in New Issue
Block a user