aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/t/001_basic.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/t/001_basic.pl')
-rw-r--r--src/bin/psql/t/001_basic.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl
index 0167cb58a2e..0f394420b26 100644
--- a/src/bin/psql/t/001_basic.pl
+++ b/src/bin/psql/t/001_basic.pl
@@ -325,4 +325,29 @@ is($row_count, '10',
'client-side error commits transaction, no ON_ERROR_STOP and multiple -c switches'
);
+# Test \copy from with DEFAULT option
+$node->safe_psql(
+ 'postgres',
+ "CREATE TABLE copy_default (
+ id integer PRIMARY KEY,
+ text_value text NOT NULL DEFAULT 'test',
+ ts_value timestamp without time zone NOT NULL DEFAULT '2022-07-05'
+ )"
+);
+
+my $copy_default_sql_file = "$tempdir/copy_default.csv";
+append_to_file($copy_default_sql_file, "1,value,2022-07-04\n");
+append_to_file($copy_default_sql_file, "2,placeholder,2022-07-03\n");
+append_to_file($copy_default_sql_file, "3,placeholder,placeholder\n");
+
+psql_like(
+ $node,
+ "\\copy copy_default from $copy_default_sql_file with (format 'csv', default 'placeholder');
+ SELECT * FROM copy_default",
+ qr/1\|value\|2022-07-04 00:00:00
+2|test|2022-07-03 00:00:00
+3|test|2022-07-05 00:00:00/,
+ '\copy from with DEFAULT'
+);
+
done_testing();