Rewrite some regression queries for option checks with COPY
authorMichael Paquier <[email protected]>
Wed, 16 Oct 2024 22:21:43 +0000 (07:21 +0900)
committerMichael Paquier <[email protected]>
Wed, 16 Oct 2024 22:21:43 +0000 (07:21 +0900)
Some queries in copy2 are there to check various option combinations,
and used "stdin" or "stdout" incompatible with the COPY TO or FROM
clauses combined with them, which was confusing.  This commit rewrites
these queries to use a compatible grammar.

The coverage of the tests is unchanged.  Like the original commit
451d1164b9d0, backpatch down to 16 where these have been introduced.  A
follow-up commit will rely on this area of the tests for a bug fix.

Author: Joel Jacobson
Reviewed-by: Zhang Mingli
Discussion: https://postgr.es/m/65030d1d-5f90-4fa4-92eb-f5f50389858e@app.fastmail.com
Backpatch-through: 16

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

index faf1a4d1b0c6044340db3b5eaf20f98c22eab519..9a74820ee8557fa90bf770cad5ac02c4b995ce76 100644 (file)
@@ -78,21 +78,21 @@ 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 ',');
+COPY x from stdin (format BINARY, delimiter ',');
 ERROR:  cannot specify DELIMITER in BINARY mode
-COPY x to stdin (format BINARY, null 'x');
+COPY x from stdin (format BINARY, null 'x');
 ERROR:  cannot specify NULL in BINARY mode
-COPY x to stdin (format TEXT, force_quote(a));
+COPY x from 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));
+COPY x from stdin (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));
+COPY x to stdout (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));
+COPY x from stdin (format TEXT, force_null(a));
 ERROR:  COPY force null available only in CSV mode
-COPY x to stdin (format CSV, force_null(a));
+COPY x to stdout (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;
index d759635068c1c5d7afa8bc8a85b19f9f0a996732..cf3828c16e605b3efd94bb452f9aae7794b797c9 100644 (file)
@@ -68,14 +68,14 @@ 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 BINARY, delimiter ',');
+COPY x from stdin (format BINARY, null 'x');
+COPY x from 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));
+COPY x from stdin (format TEXT, force_not_null(a));
+COPY x to stdout (format CSV, force_not_null(a));
+COPY x from stdin (format TEXT, force_null(a));
+COPY x to stdout (format CSV, force_null(a));
 
 -- too many columns in column list: should fail
 COPY x (a, b, c, d, e, d, c) from stdin;