From dfe4c27444ccbba9b05b853c04981c3971ba86c4 Mon Sep 17 00:00:00 2001 From: Joel Jacobson Date: Tue, 15 Oct 2024 02:44:22 +0200 Subject: [PATCH 15/16] Separate REJECT_LIMIT option validation into its own section. For clarity, explicitly check `on_error != COPY_ON_ERROR_IGNORE` instead of `!on_error`. Also update comment for the section of code at the end, that now is dedicated to additional checks for interdependent options. --- src/backend/commands/copy.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index e631a70577..cde46bbe2b 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -934,9 +934,20 @@ ProcessCopyOptions(ParseState *pstate, errmsg("only ON_ERROR STOP is allowed in BINARY mode"))); } + /* --- REJECT_LIMIT option --- */ + if (opts_out->reject_limit) + { + if (opts_out->on_error != COPY_ON_ERROR_IGNORE) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + /*- translator: first and second %s are the names of COPY option, e.g. + * ON_ERROR, third is the value of the COPY option, e.g. IGNORE */ + errmsg("COPY %s requires %s to be set to %s", + "REJECT_LIMIT", "ON_ERROR", "IGNORE"))); + } + /* - * Check for incompatible options (must do these three before inserting - * defaults) + * Additional checks for interdependent options */ /* Checks specific to the CSV and TEXT formats */ @@ -977,14 +988,6 @@ ProcessCopyOptions(ParseState *pstate, errmsg("CSV quote character must not appear in the %s specification", "NULL"))); } - - if (opts_out->reject_limit && !opts_out->on_error) - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - /*- translator: first and second %s are the names of COPY option, e.g. - * ON_ERROR, third is the value of the COPY option, e.g. IGNORE */ - errmsg("COPY %s requires %s to be set to %s", - "REJECT_LIMIT", "ON_ERROR", "IGNORE"))); } /* -- 2.45.1