@ -77,11 +77,21 @@ COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii');
ERROR: conflicting or redundant options
ERROR: conflicting or redundant options
LINE 1: COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii...
LINE 1: COPY x from stdin (encoding 'sql_ascii', encoding 'sql_ascii...
^
^
COPY x from stdin (save_error_to none,save_error_to none);
ERROR: conflicting or redundant options
LINE 1: COPY x from stdin (save_error_to none,save_error_to none);
^
-- incorrect options
-- incorrect options
COPY x to stdin (format BINARY, delimiter ',');
COPY x to stdin (format BINARY, delimiter ',');
ERROR: cannot specify DELIMITER in BINARY mode
ERROR: cannot specify DELIMITER in BINARY mode
COPY x to stdin (format BINARY, null 'x');
COPY x to stdin (format BINARY, null 'x');
ERROR: cannot specify NULL in BINARY mode
ERROR: cannot specify NULL in BINARY mode
COPY x from stdin (format BINARY, save_error_to none);
ERROR: cannot specify SAVE_ERROR_TO in BINARY mode
COPY x to stdin (save_error_to none);
ERROR: COPY SAVE_ERROR_TO cannot be used with COPY TO
LINE 1: COPY x to stdin (save_error_to none);
^
COPY x to stdin (format TEXT, force_quote(a));
COPY x to stdin (format TEXT, force_quote(a));
ERROR: COPY FORCE_QUOTE requires CSV mode
ERROR: COPY FORCE_QUOTE requires CSV mode
COPY x from stdin (format CSV, force_quote(a));
COPY x from stdin (format CSV, force_quote(a));
@ -94,6 +104,10 @@ COPY x to stdout (format TEXT, force_null(a));
ERROR: COPY FORCE_NULL requires CSV mode
ERROR: COPY FORCE_NULL requires CSV mode
COPY x to stdin (format CSV, force_null(a));
COPY x to stdin (format CSV, force_null(a));
ERROR: COPY FORCE_NULL cannot be used with COPY TO
ERROR: COPY FORCE_NULL cannot be used with COPY TO
COPY x to stdin (format BINARY, save_error_to unsupported);
ERROR: COPY SAVE_ERROR_TO cannot be used with COPY TO
LINE 1: COPY x to stdin (format BINARY, save_error_to unsupported);
^
-- too many columns in column list: should fail
-- too many columns in column list: should fail
COPY x (a, b, c, d, e, d, c) from stdin;
COPY x (a, b, c, d, e, d, c) from stdin;
ERROR: column "d" specified more than once
ERROR: column "d" specified more than once
@ -710,6 +724,33 @@ SELECT * FROM instead_of_insert_tbl;
(2 rows)
(2 rows)
COMMIT;
COMMIT;
-- tests for SAVE_ERROR_TO option
CREATE TABLE check_ign_err (n int, m int[], k int);
COPY check_ign_err FROM STDIN WITH (save_error_to error);
ERROR: invalid input syntax for type integer: "a"
CONTEXT: COPY check_ign_err, line 2, column n: "a"
COPY check_ign_err FROM STDIN WITH (save_error_to none);
NOTICE: 4 rows were skipped due to data type incompatibility
SELECT * FROM check_ign_err;
n | m | k
---+-----+---
1 | {1} | 1
5 | {5} | 5
(2 rows)
-- test datatype error that can't be handled as soft: should fail
CREATE TABLE hard_err(foo widget);
COPY hard_err FROM STDIN WITH (save_error_to none);
ERROR: invalid input syntax for type widget: "1"
CONTEXT: COPY hard_err, line 1, column foo: "1"
-- test missing data: should fail
COPY check_ign_err FROM STDIN WITH (save_error_to none);
ERROR: missing data for column "k"
CONTEXT: COPY check_ign_err, line 1: "1 {1}"
-- test extra data: should fail
COPY check_ign_err FROM STDIN WITH (save_error_to none);
ERROR: extra data after last expected column
CONTEXT: COPY check_ign_err, line 1: "1 {1} 3 abc"
-- clean up
-- clean up
DROP TABLE forcetest;
DROP TABLE forcetest;
DROP TABLE vistest;
DROP TABLE vistest;
@ -724,6 +765,8 @@ DROP TABLE instead_of_insert_tbl;
DROP VIEW instead_of_insert_tbl_view;
DROP VIEW instead_of_insert_tbl_view;
DROP VIEW instead_of_insert_tbl_view_2;
DROP VIEW instead_of_insert_tbl_view_2;
DROP FUNCTION fun_instead_of_insert_tbl();
DROP FUNCTION fun_instead_of_insert_tbl();
DROP TABLE check_ign_err;
DROP TABLE hard_err;
--
--
-- COPY FROM ... DEFAULT
-- COPY FROM ... DEFAULT
--
--