From: Masahiko Sawada Date: Wed, 17 Apr 2024 02:31:27 +0000 (+0900) Subject: Disallow specifying ON_ERROR option without value. X-Git-Tag: REL_17_BETA1~230 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6d0fa5ef840bc98e14cb34ecf672e6e2e245517;p=thirdparty%2Fpostgresql.git Disallow specifying ON_ERROR option without value. The ON_ERROR option of the COPY command previously allowed omitting its value, which was inconsistent with the syntax synopsis in the documentation and the behavior of other non-boolean COPY options. This change enforces providing a value for the ON_ERROR option, ensuring consistency across other non-boolean options and aligning with the documented syntax. Author: Atsushi Torikoshi Reviewed-by: Masahiko Sawada Discussion: https://postgr.es/m/a9770bf57646d90dedc3d54cf32634b2%40oss.nttdata.com --- diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index f75e1d700d9..df7a4a21c94 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -392,7 +392,7 @@ defGetCopyHeaderChoice(DefElem *def, bool is_from) static CopyOnErrorChoice defGetCopyOnErrorChoice(DefElem *def, ParseState *pstate, bool is_from) { - char *sval; + char *sval = defGetString(def); if (!is_from) ereport(ERROR, @@ -400,16 +400,9 @@ defGetCopyOnErrorChoice(DefElem *def, ParseState *pstate, bool is_from) errmsg("COPY ON_ERROR cannot be used with COPY TO"), parser_errposition(pstate, def->location))); - /* - * If no parameter value given, assume the default value. - */ - if (def->arg == NULL) - return COPY_ON_ERROR_STOP; - /* * Allow "stop", or "ignore" values. */ - sval = defGetString(def); if (pg_strcasecmp(sval, "stop") == 0) return COPY_ON_ERROR_STOP; if (pg_strcasecmp(sval, "ignore") == 0)