Skip to content

Commit 451d116

Browse files
committed
Add more tests for COPY with incorrect option combinations
Based on the existing coverage report, some combinations were not checked at all, so add some tests to do so. Spotted while looking at the area. Discussion: https://postgr.es/m/Y2DNm9u7hzIxCXHn@paquier.xyz
1 parent e7c7605 commit 451d116

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/test/regress/expected/copy2.out

+17
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii');
7777
ERROR: conflicting or redundant options
7878
LINE 1: COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii...
7979
^
80+
-- incorrect options
81+
COPY x to stdin (format BINARY, delimiter ',');
82+
ERROR: cannot specify DELIMITER in BINARY mode
83+
COPY x to stdin (format BINARY, null 'x');
84+
ERROR: cannot specify NULL in BINARY mode
85+
COPY x to stdin (format TEXT, force_quote(a));
86+
ERROR: COPY force quote available only in CSV mode
87+
COPY x from stdin (format CSV, force_quote(a));
88+
ERROR: COPY force quote only available using COPY TO
89+
COPY x to stdout (format TEXT, force_not_null(a));
90+
ERROR: COPY force not null available only in CSV mode
91+
COPY x to stdin (format CSV, force_not_null(a));
92+
ERROR: COPY force not null only available using COPY FROM
93+
COPY x to stdout (format TEXT, force_null(a));
94+
ERROR: COPY force null available only in CSV mode
95+
COPY x to stdin (format CSV, force_null(a));
96+
ERROR: COPY force null only available using COPY FROM
8097
-- too many columns in column list: should fail
8198
COPY x (a, b, c, d, e, d, c) from stdin;
8299
ERROR: column "d" specified more than once

src/test/regress/sql/copy2.sql

+10
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ COPY x from stdin (force_null (a), force_null (b));
6767
COPY x from stdin (convert_selectively (a), convert_selectively (b));
6868
COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii');
6969

70+
-- incorrect options
71+
COPY x to stdin (format BINARY, delimiter ',');
72+
COPY x to stdin (format BINARY, null 'x');
73+
COPY x to stdin (format TEXT, force_quote(a));
74+
COPY x from stdin (format CSV, force_quote(a));
75+
COPY x to stdout (format TEXT, force_not_null(a));
76+
COPY x to stdin (format CSV, force_not_null(a));
77+
COPY x to stdout (format TEXT, force_null(a));
78+
COPY x to stdin (format CSV, force_null(a));
79+
7080
-- too many columns in column list: should fail
7181
COPY x (a, b, c, d, e, d, c) from stdin;
7282

0 commit comments

Comments
 (0)