From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
Cc: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row |
Date: | 2024-12-13 03:15:02 |
Message-ID: | CACJufxEKq25CvQj4rYxcvHC_0MZQxzfwEKVWo9i-bKKxbVw3BA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
+ /*
+ * Here we end processing of current COPY row.
+ * Update copy state counter for number of erroneous rows.
+ */
+ cstate->num_errors++;
+ cstate->escontext->error_occurred = true;
+
+ /* Only print this NOTICE message, if it will not be followed by ERROR */
+ if (cstate->opts.log_verbosity == COPY_LOG_VERBOSITY_VERBOSE &&
+ (
+ (cstate->opts.on_error == COPY_ON_ERROR_NULL &&
cstate->opts.reject_limit > 0 && cstate->num_errors <=
cstate->opts.reject_limit) ||
+ (cstate->opts.on_error == COPY_ON_ERROR_IGNORE &&
(cstate->opts.reject_limit == 0 || cstate->num_errors <=
cstate->opts.reject_limit))
+ ))
{
this is kind of hard to comprehend.
so attached is a simple version of it based on v8.
for copy (on_error set_to_null)
1. not allow specifying reject_limit option
2. ereport ERROR for not-null constraint violation for domain type.
for example:
CREATE DOMAIN d_int_not_null AS INT NOT NULL CHECK(value > 0);
CREATE TABLE t1 (a d_int_not_null);
COPY t1 FROM STDIN WITH (on_error set_to_null);
these 3 values: \N a -1
will error out, the error message will be:
ERROR: domain d_int_not_null does not allow null values
Attachment | Content-Type | Size |
---|---|---|
v9-0001-new-COPY-on_error-option-set_to_null.patch | text/x-patch | 19.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-12-13 03:17:15 | Re: Add Postgres module info |
Previous Message | Michael Paquier | 2024-12-13 03:03:45 | Re: confusing / inefficient "need_transcoding" handling in copy |