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
This commit is contained in:
parent
58cf2e120e
commit
a6d0fa5ef8
|
@ -392,7 +392,7 @@ defGetCopyHeaderChoice(DefElem *def, bool is_from)
|
||||||
static CopyOnErrorChoice
|
static CopyOnErrorChoice
|
||||||
defGetCopyOnErrorChoice(DefElem *def, ParseState *pstate, bool is_from)
|
defGetCopyOnErrorChoice(DefElem *def, ParseState *pstate, bool is_from)
|
||||||
{
|
{
|
||||||
char *sval;
|
char *sval = defGetString(def);
|
||||||
|
|
||||||
if (!is_from)
|
if (!is_from)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
@ -400,16 +400,9 @@ defGetCopyOnErrorChoice(DefElem *def, ParseState *pstate, bool is_from)
|
||||||
errmsg("COPY ON_ERROR cannot be used with COPY TO"),
|
errmsg("COPY ON_ERROR cannot be used with COPY TO"),
|
||||||
parser_errposition(pstate, def->location)));
|
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.
|
* Allow "stop", or "ignore" values.
|
||||||
*/
|
*/
|
||||||
sval = defGetString(def);
|
|
||||||
if (pg_strcasecmp(sval, "stop") == 0)
|
if (pg_strcasecmp(sval, "stop") == 0)
|
||||||
return COPY_ON_ERROR_STOP;
|
return COPY_ON_ERROR_STOP;
|
||||||
if (pg_strcasecmp(sval, "ignore") == 0)
|
if (pg_strcasecmp(sval, "ignore") == 0)
|
||||||
|
|
Loading…
Reference in New Issue