aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-11-02 09:57:54 +0900
committerMichael Paquier <michael@paquier.xyz>2022-11-02 09:57:54 +0900
commit451d1164b9d0cce6acd0b3d0790f09db4c56be0a (patch)
treeb706f8ab74b7d8693c79b74ba9d2957de6ccbc31
parente7c7605a760bf4422654ae842281d53e2d7b9e88 (diff)
downloadpostgresql-451d1164b9d0cce6acd0b3d0790f09db4c56be0a.tar.gz
postgresql-451d1164b9d0cce6acd0b3d0790f09db4c56be0a.zip
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
-rw-r--r--src/test/regress/expected/copy2.out17
-rw-r--r--src/test/regress/sql/copy2.sql10
2 files changed, 27 insertions, 0 deletions
diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out
index 5f3685e9efe..090ef6c7a8c 100644
--- a/src/test/regress/expected/copy2.out
+++ b/src/test/regress/expected/copy2.out
@@ -77,6 +77,23 @@ COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii');
ERROR: conflicting or redundant options
LINE 1: COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii...
^
+-- incorrect options
+COPY x to stdin (format BINARY, delimiter ',');
+ERROR: cannot specify DELIMITER in BINARY mode
+COPY x to stdin (format BINARY, null 'x');
+ERROR: cannot specify NULL in BINARY mode
+COPY x to stdin (format TEXT, force_quote(a));
+ERROR: COPY force quote available only in CSV mode
+COPY x from stdin (format CSV, force_quote(a));
+ERROR: COPY force quote only available using COPY TO
+COPY x to stdout (format TEXT, force_not_null(a));
+ERROR: COPY force not null available only in CSV mode
+COPY x to stdin (format CSV, force_not_null(a));
+ERROR: COPY force not null only available using COPY FROM
+COPY x to stdout (format TEXT, force_null(a));
+ERROR: COPY force null available only in CSV mode
+COPY x to stdin (format CSV, force_null(a));
+ERROR: COPY force null only available using COPY FROM
-- too many columns in column list: should fail
COPY x (a, b, c, d, e, d, c) from stdin;
ERROR: column "d" specified more than once
diff --git a/src/test/regress/sql/copy2.sql b/src/test/regress/sql/copy2.sql
index b3c16af48ee..b0de82c3aa9 100644
--- a/src/test/regress/sql/copy2.sql
+++ b/src/test/regress/sql/copy2.sql
@@ -67,6 +67,16 @@ COPY x from stdin (force_null (a), force_null (b));
COPY x from stdin (convert_selectively (a), convert_selectively (b));
COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii');
+-- incorrect options
+COPY x to stdin (format BINARY, delimiter ',');
+COPY x to stdin (format BINARY, null 'x');
+COPY x to stdin (format TEXT, force_quote(a));
+COPY x from stdin (format CSV, force_quote(a));
+COPY x to stdout (format TEXT, force_not_null(a));
+COPY x to stdin (format CSV, force_not_null(a));
+COPY x to stdout (format TEXT, force_null(a));
+COPY x to stdin (format CSV, force_null(a));
+
-- too many columns in column list: should fail
COPY x (a, b, c, d, e, d, c) from stdin;