Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features)
Alena Rybakina <lena.ribackina@yandex.ru>
From: Alena Rybakina <lena.ribackina@yandex.ru>
To: Damir Belyalov <dam.bel07@gmail.com>
Cc: andres@anarazel.de, tgl@sss.pgh.pa.us, daniel@yesql.se,
pgsql-hackers@postgresql.org, anisimow.d@gmail.com, HukuToc@gmail.com,
Andrey Lepikhov <a.lepikhov@postgrespro.ru>
Date: 2023-05-06T20:05:04Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
doc: Fix COPY ON_ERROR option syntax synopsis.
- f6f8ac8e75c9 17.0 landed
-
Disallow specifying ON_ERROR option without value.
- a6d0fa5ef840 17.0 landed
-
Rename COPY option from SAVE_ERROR_TO to ON_ERROR
- b725b7eec431 17.0 landed
-
Fix spelling in notice
- 58fbbc9d683c 17.0 landed
-
Add new COPY option SAVE_ERROR_TO
- 9e2d8701194f 17.0 landed
Hi! Thank you, Damir, for your patch. It is very interesting to review it! It seemed to me that the names of variables are not the same everywhere. I noticed that you used /ignore_datatype_errors_specified/ variable in /copy.c/ , but guc has a short name /ignore_datatype_errors/. Also you used the short variable name in /CopyFormatOptions/ structure. Name used /ignore_datatype_errors_specified /is seemed very long to me, may be use a short version of it (/ignore_datatype_errors/) in /copy.c/ too? Besides, I noticed that you used /ignored_errors/ variable in /CopyFromStateData/ structure and it's name is strikingly similar to name (/ignore_datatype_error//s/), but they have different meanings. Maybe it will be better to rename it as /ignored_errors_counter/? I tested last version /v5-0001-Add-new-COPY-option-IGNORE_DATATYPE_ERRORS.patch/ with /bytea/ data type and transaction cases. Eventually, I didn't find any problem there. I described my steps in more detail, if I missed something. *First of all, I ran copy function with IGNORE_DATATYPE_ERRORS parameter being in transaction block.* / //File t2.csv exists:/ |id,b 769,\ 1,\6e 2,\x5 5,\x| /Test:/ CREATE TABLE t (id INT , b BYTEA) ; postgres=# BEGIN; copy t FROM '/home/alena/postgres/t2.csv' WITH (format 'csv', IGNORE_DATATYPE_ERRORS, delimiter ',', HEADER); SAVEPOINT my_savepoint; BEGIN WARNING: invalid input syntax for type bytea WARNING: invalid input syntax for type bytea WARNING: invalid hexadecimal data: odd number of digits WARNING: 3 rows were skipped due to data type incompatibility COPY 1 SAVEPOINT postgres=*# copy t FROM '/home/alena/postgres/t2.csv' WITH (format 'csv', IGNORE_DATATYPE_ERRORS, delimiter ',', HEADER); WARNING: invalid input syntax for type bytea WARNING: invalid input syntax for type bytea WARNING: invalid hexadecimal data: odd number of digits WARNING: 3 rows were skipped due to data type incompatibility COPY 1 postgres=*# ROLLBACK TO my_savepoint; ROLLBACK postgres=*# select * from t; id | b ----+---- 5 | \x (1 row) postgres=*# copy t FROM '/home/alena/postgres/t2.csv' WITH (format 'csv', IGNORE_DATATYPE_ERRORS, delimiter ',', HEADER); WARNING: invalid input syntax for type bytea WARNING: invalid input syntax for type bytea WARNING: invalid hexadecimal data: odd number of digits WARNING: 3 rows were skipped due to data type incompatibility COPY 1 postgres=*# select * from t; id | b ----+---- 5 | \x 5 | \x (2 rows) postgres=*# commit; COMMIT *I tried to use the similar test and moved transaction block in function:* CREATE FUNCTION public.log2() RETURNS void LANGUAGE plpgsql SECURITY DEFINER AS $function$ BEGIN; copy t FROM '/home/alena/postgres/t2.csv' WITH (format 'csv', IGNORE_DATATYPE_ERRORS, delimiter ',', HEADER); SAVEPOINT my_savepoint; END; $function$; postgres=# delete from t; postgres=# select 1 as t from log2(); WARNING: invalid input syntax for type bytea WARNING: invalid input syntax for type bytea WARNING: invalid hexadecimal data: odd number of digits WARNING: 3 rows were skipped due to data type incompatibility t --- 1 (1 row) *Secondly I checked function copy with bytea datatype. * /t1.csv consists:/ id,b 769,\x2d 1,\x6e 2,\x5c 5,\x /And I ran it:/ postgres=# delete from t; DELETE 4 postgres=# copy t FROM '/home/alena/postgres/t2.csv' WITH (format 'csv', IGNORE_DATATYPE_ERRORS, delimiter ',', HEADER); WARNING: invalid input syntax for type bytea WARNING: invalid input syntax for type bytea WARNING: invalid hexadecimal data: odd number of digits WARNING: 3 rows were skipped due to data type incompatibility COPY 1 postgres=# select * from t; id | b ----+---- 5 | \x (1 row) -- --- Alena Rybakina Postgres Professional