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

Commit451d116

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

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎src/test/regress/expected/copy2.out‎

Lines changed: 17 additions & 0 deletions
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‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ COPY x from stdin (force_null (a), force_null (b));
6767
COPY xfrom stdin (convert_selectively (a), convert_selectively (b));
6868
COPY xfrom 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 (formatTEXT, force_quote(a));
74+
COPY xfrom stdin (format CSV, force_quote(a));
75+
COPY x to stdout (formatTEXT, force_not_null(a));
76+
COPY x to stdin (format CSV, force_not_null(a));
77+
COPY x to stdout (formatTEXT, 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)

[8]ページ先頭

©2009-2025 Movatter.jp