1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-24 10:47:04 +03:00

Improve reporting of "conflicting or redundant options" errors.

When reporting "conflicting or redundant options" errors, try to
ensure that errposition() is used, to help the user identify the
offending option.

Formerly, errposition() was invoked in less than 60% of cases. This
patch raises that to over 90%, but there remain a few places where the
ParseState is not readily available. Using errdetail() might improve
the error in such cases, but that is left as a task for the future.

Additionally, since this error is thrown from over 100 places in the
codebase, introduce a dedicated function to throw it, reducing code
duplication.

Extracted from a slightly larger patch by Vignesh C. Reviewed by
Bharath Rupireddy, Alvaro Herrera, Dilip Kumar, Hou Zhijie, Peter
Smith, Daniel Gustafsson, Julien Rouhaud and me.

Discussion: https://postgr.es/m/CALDaNm33FFSS5tVyvmkoK2cCMuDVxcui=gFrjti9ROfynqSAGA@mail.gmail.com
This commit is contained in:
Dean Rasheed 2021-07-15 08:49:45 +01:00
parent ffc9ddaea3
commit 2bfb50b3df
22 changed files with 180 additions and 395 deletions

View File

@ -59,6 +59,7 @@
#include "catalog/pg_ts_template.h" #include "catalog/pg_ts_template.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h" #include "commands/event_trigger.h"
#include "commands/extension.h" #include "commands/extension.h"
#include "commands/proclang.h" #include "commands/proclang.h"
@ -921,19 +922,13 @@ ExecAlterDefaultPrivilegesStmt(ParseState *pstate, AlterDefaultPrivilegesStmt *s
if (strcmp(defel->defname, "schemas") == 0) if (strcmp(defel->defname, "schemas") == 0)
{ {
if (dnspnames) if (dnspnames)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dnspnames = defel; dnspnames = defel;
} }
else if (strcmp(defel->defname, "roles") == 0) else if (strcmp(defel->defname, "roles") == 0)
{ {
if (drolespecs) if (drolespecs)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
drolespecs = defel; drolespecs = defel;
} }
else else

View File

@ -357,10 +357,7 @@ ProcessCopyOptions(ParseState *pstate,
char *fmt = defGetString(defel); char *fmt = defGetString(defel);
if (format_specified) if (format_specified)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
format_specified = true; format_specified = true;
if (strcmp(fmt, "text") == 0) if (strcmp(fmt, "text") == 0)
/* default format */ ; /* default format */ ;
@ -377,66 +374,45 @@ ProcessCopyOptions(ParseState *pstate,
else if (strcmp(defel->defname, "freeze") == 0) else if (strcmp(defel->defname, "freeze") == 0)
{ {
if (freeze_specified) if (freeze_specified)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
freeze_specified = true; freeze_specified = true;
opts_out->freeze = defGetBoolean(defel); opts_out->freeze = defGetBoolean(defel);
} }
else if (strcmp(defel->defname, "delimiter") == 0) else if (strcmp(defel->defname, "delimiter") == 0)
{ {
if (opts_out->delim) if (opts_out->delim)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
opts_out->delim = defGetString(defel); opts_out->delim = defGetString(defel);
} }
else if (strcmp(defel->defname, "null") == 0) else if (strcmp(defel->defname, "null") == 0)
{ {
if (opts_out->null_print) if (opts_out->null_print)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
opts_out->null_print = defGetString(defel); opts_out->null_print = defGetString(defel);
} }
else if (strcmp(defel->defname, "header") == 0) else if (strcmp(defel->defname, "header") == 0)
{ {
if (header_specified) if (header_specified)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
header_specified = true; header_specified = true;
opts_out->header_line = defGetBoolean(defel); opts_out->header_line = defGetBoolean(defel);
} }
else if (strcmp(defel->defname, "quote") == 0) else if (strcmp(defel->defname, "quote") == 0)
{ {
if (opts_out->quote) if (opts_out->quote)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
opts_out->quote = defGetString(defel); opts_out->quote = defGetString(defel);
} }
else if (strcmp(defel->defname, "escape") == 0) else if (strcmp(defel->defname, "escape") == 0)
{ {
if (opts_out->escape) if (opts_out->escape)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
opts_out->escape = defGetString(defel); opts_out->escape = defGetString(defel);
} }
else if (strcmp(defel->defname, "force_quote") == 0) else if (strcmp(defel->defname, "force_quote") == 0)
{ {
if (opts_out->force_quote || opts_out->force_quote_all) if (opts_out->force_quote || opts_out->force_quote_all)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
if (defel->arg && IsA(defel->arg, A_Star)) if (defel->arg && IsA(defel->arg, A_Star))
opts_out->force_quote_all = true; opts_out->force_quote_all = true;
else if (defel->arg && IsA(defel->arg, List)) else if (defel->arg && IsA(defel->arg, List))
@ -451,10 +427,7 @@ ProcessCopyOptions(ParseState *pstate,
else if (strcmp(defel->defname, "force_not_null") == 0) else if (strcmp(defel->defname, "force_not_null") == 0)
{ {
if (opts_out->force_notnull) if (opts_out->force_notnull)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
if (defel->arg && IsA(defel->arg, List)) if (defel->arg && IsA(defel->arg, List))
opts_out->force_notnull = castNode(List, defel->arg); opts_out->force_notnull = castNode(List, defel->arg);
else else
@ -467,9 +440,7 @@ ProcessCopyOptions(ParseState *pstate,
else if (strcmp(defel->defname, "force_null") == 0) else if (strcmp(defel->defname, "force_null") == 0)
{ {
if (opts_out->force_null) if (opts_out->force_null)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
if (defel->arg && IsA(defel->arg, List)) if (defel->arg && IsA(defel->arg, List))
opts_out->force_null = castNode(List, defel->arg); opts_out->force_null = castNode(List, defel->arg);
else else
@ -487,10 +458,7 @@ ProcessCopyOptions(ParseState *pstate,
* allowed for the column list to be NIL. * allowed for the column list to be NIL.
*/ */
if (opts_out->convert_selectively) if (opts_out->convert_selectively)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
opts_out->convert_selectively = true; opts_out->convert_selectively = true;
if (defel->arg == NULL || IsA(defel->arg, List)) if (defel->arg == NULL || IsA(defel->arg, List))
opts_out->convert_select = castNode(List, defel->arg); opts_out->convert_select = castNode(List, defel->arg);
@ -504,10 +472,7 @@ ProcessCopyOptions(ParseState *pstate,
else if (strcmp(defel->defname, "encoding") == 0) else if (strcmp(defel->defname, "encoding") == 0)
{ {
if (opts_out->file_encoding >= 0) if (opts_out->file_encoding >= 0)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
opts_out->file_encoding = pg_char_to_encoding(defGetString(defel)); opts_out->file_encoding = pg_char_to_encoding(defGetString(defel));
if (opts_out->file_encoding < 0) if (opts_out->file_encoding < 0)
ereport(ERROR, ereport(ERROR,

View File

@ -152,91 +152,61 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
if (strcmp(defel->defname, "tablespace") == 0) if (strcmp(defel->defname, "tablespace") == 0)
{ {
if (dtablespacename) if (dtablespacename)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dtablespacename = defel; dtablespacename = defel;
} }
else if (strcmp(defel->defname, "owner") == 0) else if (strcmp(defel->defname, "owner") == 0)
{ {
if (downer) if (downer)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
downer = defel; downer = defel;
} }
else if (strcmp(defel->defname, "template") == 0) else if (strcmp(defel->defname, "template") == 0)
{ {
if (dtemplate) if (dtemplate)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dtemplate = defel; dtemplate = defel;
} }
else if (strcmp(defel->defname, "encoding") == 0) else if (strcmp(defel->defname, "encoding") == 0)
{ {
if (dencoding) if (dencoding)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dencoding = defel; dencoding = defel;
} }
else if (strcmp(defel->defname, "locale") == 0) else if (strcmp(defel->defname, "locale") == 0)
{ {
if (dlocale) if (dlocale)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dlocale = defel; dlocale = defel;
} }
else if (strcmp(defel->defname, "lc_collate") == 0) else if (strcmp(defel->defname, "lc_collate") == 0)
{ {
if (dcollate) if (dcollate)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcollate = defel; dcollate = defel;
} }
else if (strcmp(defel->defname, "lc_ctype") == 0) else if (strcmp(defel->defname, "lc_ctype") == 0)
{ {
if (dctype) if (dctype)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dctype = defel; dctype = defel;
} }
else if (strcmp(defel->defname, "is_template") == 0) else if (strcmp(defel->defname, "is_template") == 0)
{ {
if (distemplate) if (distemplate)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
distemplate = defel; distemplate = defel;
} }
else if (strcmp(defel->defname, "allow_connections") == 0) else if (strcmp(defel->defname, "allow_connections") == 0)
{ {
if (dallowconnections) if (dallowconnections)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dallowconnections = defel; dallowconnections = defel;
} }
else if (strcmp(defel->defname, "connection_limit") == 0) else if (strcmp(defel->defname, "connection_limit") == 0)
{ {
if (dconnlimit) if (dconnlimit)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "location") == 0) else if (strcmp(defel->defname, "location") == 0)
@ -1497,37 +1467,25 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
if (strcmp(defel->defname, "is_template") == 0) if (strcmp(defel->defname, "is_template") == 0)
{ {
if (distemplate) if (distemplate)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
distemplate = defel; distemplate = defel;
} }
else if (strcmp(defel->defname, "allow_connections") == 0) else if (strcmp(defel->defname, "allow_connections") == 0)
{ {
if (dallowconnections) if (dallowconnections)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dallowconnections = defel; dallowconnections = defel;
} }
else if (strcmp(defel->defname, "connection_limit") == 0) else if (strcmp(defel->defname, "connection_limit") == 0)
{ {
if (dconnlimit) if (dconnlimit)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "tablespace") == 0) else if (strcmp(defel->defname, "tablespace") == 0)
{ {
if (dtablespace) if (dtablespace)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dtablespace = defel; dtablespace = defel;
} }
else else

View File

@ -347,3 +347,15 @@ defGetStringList(DefElem *def)
return (List *) def->arg; return (List *) def->arg;
} }
/*
* Raise an error about a conflicting DefElem.
*/
void
errorConflictingDefElem(DefElem *defel, ParseState *pstate)
{
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location));
}

View File

@ -1731,30 +1731,21 @@ CreateExtension(ParseState *pstate, CreateExtensionStmt *stmt)
if (strcmp(defel->defname, "schema") == 0) if (strcmp(defel->defname, "schema") == 0)
{ {
if (d_schema) if (d_schema)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_schema = defel; d_schema = defel;
schemaName = defGetString(d_schema); schemaName = defGetString(d_schema);
} }
else if (strcmp(defel->defname, "new_version") == 0) else if (strcmp(defel->defname, "new_version") == 0)
{ {
if (d_new_version) if (d_new_version)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_new_version = defel; d_new_version = defel;
versionName = defGetString(d_new_version); versionName = defGetString(d_new_version);
} }
else if (strcmp(defel->defname, "cascade") == 0) else if (strcmp(defel->defname, "cascade") == 0)
{ {
if (d_cascade) if (d_cascade)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_cascade = defel; d_cascade = defel;
cascade = defGetBoolean(d_cascade); cascade = defGetBoolean(d_cascade);
} }
@ -3051,10 +3042,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
if (strcmp(defel->defname, "new_version") == 0) if (strcmp(defel->defname, "new_version") == 0)
{ {
if (d_new_version) if (d_new_version)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
d_new_version = defel; d_new_version = defel;
} }
else else

View File

@ -515,7 +515,7 @@ lookup_fdw_validator_func(DefElem *validator)
* Process function options of CREATE/ALTER FDW * Process function options of CREATE/ALTER FDW
*/ */
static void static void
parse_func_options(List *func_options, parse_func_options(ParseState *pstate, List *func_options,
bool *handler_given, Oid *fdwhandler, bool *handler_given, Oid *fdwhandler,
bool *validator_given, Oid *fdwvalidator) bool *validator_given, Oid *fdwvalidator)
{ {
@ -534,18 +534,14 @@ parse_func_options(List *func_options,
if (strcmp(def->defname, "handler") == 0) if (strcmp(def->defname, "handler") == 0)
{ {
if (*handler_given) if (*handler_given)
ereport(ERROR, errorConflictingDefElem(def, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
*handler_given = true; *handler_given = true;
*fdwhandler = lookup_fdw_handler_func(def); *fdwhandler = lookup_fdw_handler_func(def);
} }
else if (strcmp(def->defname, "validator") == 0) else if (strcmp(def->defname, "validator") == 0)
{ {
if (*validator_given) if (*validator_given)
ereport(ERROR, errorConflictingDefElem(def, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
*validator_given = true; *validator_given = true;
*fdwvalidator = lookup_fdw_validator_func(def); *fdwvalidator = lookup_fdw_validator_func(def);
} }
@ -559,7 +555,7 @@ parse_func_options(List *func_options,
* Create a foreign-data wrapper * Create a foreign-data wrapper
*/ */
ObjectAddress ObjectAddress
CreateForeignDataWrapper(CreateFdwStmt *stmt) CreateForeignDataWrapper(ParseState *pstate, CreateFdwStmt *stmt)
{ {
Relation rel; Relation rel;
Datum values[Natts_pg_foreign_data_wrapper]; Datum values[Natts_pg_foreign_data_wrapper];
@ -611,7 +607,7 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
values[Anum_pg_foreign_data_wrapper_fdwowner - 1] = ObjectIdGetDatum(ownerId); values[Anum_pg_foreign_data_wrapper_fdwowner - 1] = ObjectIdGetDatum(ownerId);
/* Lookup handler and validator functions, if given */ /* Lookup handler and validator functions, if given */
parse_func_options(stmt->func_options, parse_func_options(pstate, stmt->func_options,
&handler_given, &fdwhandler, &handler_given, &fdwhandler,
&validator_given, &fdwvalidator); &validator_given, &fdwvalidator);
@ -675,7 +671,7 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
* Alter foreign-data wrapper * Alter foreign-data wrapper
*/ */
ObjectAddress ObjectAddress
AlterForeignDataWrapper(AlterFdwStmt *stmt) AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt)
{ {
Relation rel; Relation rel;
HeapTuple tp; HeapTuple tp;
@ -717,7 +713,7 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
memset(repl_null, false, sizeof(repl_null)); memset(repl_null, false, sizeof(repl_null));
memset(repl_repl, false, sizeof(repl_repl)); memset(repl_repl, false, sizeof(repl_repl));
parse_func_options(stmt->func_options, parse_func_options(pstate, stmt->func_options,
&handler_given, &fdwhandler, &handler_given, &fdwhandler,
&validator_given, &fdwvalidator); &validator_given, &fdwvalidator);

View File

@ -523,7 +523,7 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*volatility_item) if (*volatility_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*volatility_item = defel; *volatility_item = defel;
} }
@ -532,14 +532,14 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*strict_item) if (*strict_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*strict_item = defel; *strict_item = defel;
} }
else if (strcmp(defel->defname, "security") == 0) else if (strcmp(defel->defname, "security") == 0)
{ {
if (*security_item) if (*security_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*security_item = defel; *security_item = defel;
} }
@ -548,7 +548,7 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*leakproof_item) if (*leakproof_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*leakproof_item = defel; *leakproof_item = defel;
} }
@ -561,7 +561,7 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*cost_item) if (*cost_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*cost_item = defel; *cost_item = defel;
} }
@ -570,7 +570,7 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*rows_item) if (*rows_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*rows_item = defel; *rows_item = defel;
} }
@ -579,7 +579,7 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*support_item) if (*support_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*support_item = defel; *support_item = defel;
} }
@ -588,7 +588,7 @@ compute_common_attribute(ParseState *pstate,
if (is_procedure) if (is_procedure)
goto procedure_error; goto procedure_error;
if (*parallel_item) if (*parallel_item)
goto duplicate_error; errorConflictingDefElem(defel, pstate);
*parallel_item = defel; *parallel_item = defel;
} }
@ -598,13 +598,6 @@ compute_common_attribute(ParseState *pstate,
/* Recognized an option */ /* Recognized an option */
return true; return true;
duplicate_error:
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
return false; /* keep compiler quiet */
procedure_error: procedure_error:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
@ -765,37 +758,25 @@ compute_function_attributes(ParseState *pstate,
if (strcmp(defel->defname, "as") == 0) if (strcmp(defel->defname, "as") == 0)
{ {
if (as_item) if (as_item)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
as_item = defel; as_item = defel;
} }
else if (strcmp(defel->defname, "language") == 0) else if (strcmp(defel->defname, "language") == 0)
{ {
if (language_item) if (language_item)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
language_item = defel; language_item = defel;
} }
else if (strcmp(defel->defname, "transform") == 0) else if (strcmp(defel->defname, "transform") == 0)
{ {
if (transform_item) if (transform_item)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
transform_item = defel; transform_item = defel;
} }
else if (strcmp(defel->defname, "window") == 0) else if (strcmp(defel->defname, "window") == 0)
{ {
if (windowfunc_item) if (windowfunc_item)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
if (is_procedure) if (is_procedure)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
@ -2070,7 +2051,7 @@ IsThereFunctionInNamespace(const char *proname, int pronargs,
* See at ExecuteCallStmt() about the atomic argument. * See at ExecuteCallStmt() about the atomic argument.
*/ */
void void
ExecuteDoStmt(DoStmt *stmt, bool atomic) ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic)
{ {
InlineCodeBlock *codeblock = makeNode(InlineCodeBlock); InlineCodeBlock *codeblock = makeNode(InlineCodeBlock);
ListCell *arg; ListCell *arg;
@ -2089,17 +2070,13 @@ ExecuteDoStmt(DoStmt *stmt, bool atomic)
if (strcmp(defel->defname, "as") == 0) if (strcmp(defel->defname, "as") == 0)
{ {
if (as_item) if (as_item)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
as_item = defel; as_item = defel;
} }
else if (strcmp(defel->defname, "language") == 0) else if (strcmp(defel->defname, "language") == 0)
{ {
if (language_item) if (language_item)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
language_item = defel; language_item = defel;
} }
else else

View File

@ -55,7 +55,8 @@ static void PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok); static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok);
static void static void
parse_publication_options(List *options, parse_publication_options(ParseState *pstate,
List *options,
bool *publish_given, bool *publish_given,
PublicationActions *pubactions, PublicationActions *pubactions,
bool *publish_via_partition_root_given, bool *publish_via_partition_root_given,
@ -85,9 +86,7 @@ parse_publication_options(List *options,
ListCell *lc; ListCell *lc;
if (*publish_given) if (*publish_given)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
/* /*
* If publish option was given only the explicitly listed actions * If publish option was given only the explicitly listed actions
@ -128,9 +127,7 @@ parse_publication_options(List *options,
else if (strcmp(defel->defname, "publish_via_partition_root") == 0) else if (strcmp(defel->defname, "publish_via_partition_root") == 0)
{ {
if (*publish_via_partition_root_given) if (*publish_via_partition_root_given)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
*publish_via_partition_root_given = true; *publish_via_partition_root_given = true;
*publish_via_partition_root = defGetBoolean(defel); *publish_via_partition_root = defGetBoolean(defel);
} }
@ -145,7 +142,7 @@ parse_publication_options(List *options,
* Create new publication. * Create new publication.
*/ */
ObjectAddress ObjectAddress
CreatePublication(CreatePublicationStmt *stmt) CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
{ {
Relation rel; Relation rel;
ObjectAddress myself; ObjectAddress myself;
@ -192,7 +189,8 @@ CreatePublication(CreatePublicationStmt *stmt)
DirectFunctionCall1(namein, CStringGetDatum(stmt->pubname)); DirectFunctionCall1(namein, CStringGetDatum(stmt->pubname));
values[Anum_pg_publication_pubowner - 1] = ObjectIdGetDatum(GetUserId()); values[Anum_pg_publication_pubowner - 1] = ObjectIdGetDatum(GetUserId());
parse_publication_options(stmt->options, parse_publication_options(pstate,
stmt->options,
&publish_given, &pubactions, &publish_given, &pubactions,
&publish_via_partition_root_given, &publish_via_partition_root_given,
&publish_via_partition_root); &publish_via_partition_root);
@ -256,8 +254,8 @@ CreatePublication(CreatePublicationStmt *stmt)
* Change options of a publication. * Change options of a publication.
*/ */
static void static void
AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel, AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
HeapTuple tup) Relation rel, HeapTuple tup)
{ {
bool nulls[Natts_pg_publication]; bool nulls[Natts_pg_publication];
bool replaces[Natts_pg_publication]; bool replaces[Natts_pg_publication];
@ -269,7 +267,8 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
ObjectAddress obj; ObjectAddress obj;
Form_pg_publication pubform; Form_pg_publication pubform;
parse_publication_options(stmt->options, parse_publication_options(pstate,
stmt->options,
&publish_given, &pubactions, &publish_given, &pubactions,
&publish_via_partition_root_given, &publish_via_partition_root_given,
&publish_via_partition_root); &publish_via_partition_root);
@ -434,7 +433,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
* AlterPublicationTables. * AlterPublicationTables.
*/ */
void void
AlterPublication(AlterPublicationStmt *stmt) AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt)
{ {
Relation rel; Relation rel;
HeapTuple tup; HeapTuple tup;
@ -459,7 +458,7 @@ AlterPublication(AlterPublicationStmt *stmt)
stmt->pubname); stmt->pubname);
if (stmt->options) if (stmt->options)
AlterPublicationOptions(stmt, rel, tup); AlterPublicationOptions(pstate, stmt, rel, tup);
else else
AlterPublicationTables(stmt, rel, tup); AlterPublicationTables(stmt, rel, tup);

View File

@ -1261,90 +1261,63 @@ init_params(ParseState *pstate, List *options, bool for_identity,
if (strcmp(defel->defname, "as") == 0) if (strcmp(defel->defname, "as") == 0)
{ {
if (as_type) if (as_type)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
as_type = defel; as_type = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "increment") == 0) else if (strcmp(defel->defname, "increment") == 0)
{ {
if (increment_by) if (increment_by)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
increment_by = defel; increment_by = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "start") == 0) else if (strcmp(defel->defname, "start") == 0)
{ {
if (start_value) if (start_value)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
start_value = defel; start_value = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "restart") == 0) else if (strcmp(defel->defname, "restart") == 0)
{ {
if (restart_value) if (restart_value)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
restart_value = defel; restart_value = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "maxvalue") == 0) else if (strcmp(defel->defname, "maxvalue") == 0)
{ {
if (max_value) if (max_value)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
max_value = defel; max_value = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "minvalue") == 0) else if (strcmp(defel->defname, "minvalue") == 0)
{ {
if (min_value) if (min_value)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
min_value = defel; min_value = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "cache") == 0) else if (strcmp(defel->defname, "cache") == 0)
{ {
if (cache_value) if (cache_value)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
cache_value = defel; cache_value = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "cycle") == 0) else if (strcmp(defel->defname, "cycle") == 0)
{ {
if (is_cycled) if (is_cycled)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
is_cycled = defel; is_cycled = defel;
*need_seq_rewrite = true; *need_seq_rewrite = true;
} }
else if (strcmp(defel->defname, "owned_by") == 0) else if (strcmp(defel->defname, "owned_by") == 0)
{ {
if (*owned_by) if (*owned_by)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
*owned_by = defGetQualifiedName(defel); *owned_by = defGetQualifiedName(defel);
} }
else if (strcmp(defel->defname, "sequence_name") == 0) else if (strcmp(defel->defname, "sequence_name") == 0)

View File

@ -98,7 +98,8 @@ static void ReportSlotConnectionError(List *rstates, Oid subid, char *slotname,
* Caller is expected to have cleared 'opts'. * Caller is expected to have cleared 'opts'.
*/ */
static void static void
parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *opts) parse_subscription_options(ParseState *pstate, List *stmt_options,
bits32 supported_opts, SubOpts *opts)
{ {
ListCell *lc; ListCell *lc;
@ -137,9 +138,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "connect") == 0) strcmp(defel->defname, "connect") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_CONNECT)) if (IsSet(opts->specified_opts, SUBOPT_CONNECT))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_CONNECT; opts->specified_opts |= SUBOPT_CONNECT;
opts->connect = defGetBoolean(defel); opts->connect = defGetBoolean(defel);
@ -148,9 +147,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "enabled") == 0) strcmp(defel->defname, "enabled") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_ENABLED)) if (IsSet(opts->specified_opts, SUBOPT_ENABLED))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_ENABLED; opts->specified_opts |= SUBOPT_ENABLED;
opts->enabled = defGetBoolean(defel); opts->enabled = defGetBoolean(defel);
@ -159,9 +156,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "create_slot") == 0) strcmp(defel->defname, "create_slot") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_CREATE_SLOT)) if (IsSet(opts->specified_opts, SUBOPT_CREATE_SLOT))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_CREATE_SLOT; opts->specified_opts |= SUBOPT_CREATE_SLOT;
opts->create_slot = defGetBoolean(defel); opts->create_slot = defGetBoolean(defel);
@ -170,9 +165,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "slot_name") == 0) strcmp(defel->defname, "slot_name") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_SLOT_NAME)) if (IsSet(opts->specified_opts, SUBOPT_SLOT_NAME))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_SLOT_NAME; opts->specified_opts |= SUBOPT_SLOT_NAME;
opts->slot_name = defGetString(defel); opts->slot_name = defGetString(defel);
@ -185,9 +178,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "copy_data") == 0) strcmp(defel->defname, "copy_data") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_COPY_DATA)) if (IsSet(opts->specified_opts, SUBOPT_COPY_DATA))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_COPY_DATA; opts->specified_opts |= SUBOPT_COPY_DATA;
opts->copy_data = defGetBoolean(defel); opts->copy_data = defGetBoolean(defel);
@ -196,9 +187,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "synchronous_commit") == 0) strcmp(defel->defname, "synchronous_commit") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_SYNCHRONOUS_COMMIT)) if (IsSet(opts->specified_opts, SUBOPT_SYNCHRONOUS_COMMIT))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_SYNCHRONOUS_COMMIT; opts->specified_opts |= SUBOPT_SYNCHRONOUS_COMMIT;
opts->synchronous_commit = defGetString(defel); opts->synchronous_commit = defGetString(defel);
@ -212,9 +201,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "refresh") == 0) strcmp(defel->defname, "refresh") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_REFRESH)) if (IsSet(opts->specified_opts, SUBOPT_REFRESH))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_REFRESH; opts->specified_opts |= SUBOPT_REFRESH;
opts->refresh = defGetBoolean(defel); opts->refresh = defGetBoolean(defel);
@ -223,9 +210,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "binary") == 0) strcmp(defel->defname, "binary") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_BINARY)) if (IsSet(opts->specified_opts, SUBOPT_BINARY))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_BINARY; opts->specified_opts |= SUBOPT_BINARY;
opts->binary = defGetBoolean(defel); opts->binary = defGetBoolean(defel);
@ -234,9 +219,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
strcmp(defel->defname, "streaming") == 0) strcmp(defel->defname, "streaming") == 0)
{ {
if (IsSet(opts->specified_opts, SUBOPT_STREAMING)) if (IsSet(opts->specified_opts, SUBOPT_STREAMING))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_STREAMING; opts->specified_opts |= SUBOPT_STREAMING;
opts->streaming = defGetBoolean(defel); opts->streaming = defGetBoolean(defel);
@ -257,9 +240,7 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
errmsg("unrecognized subscription parameter: \"%s\"", defel->defname))); errmsg("unrecognized subscription parameter: \"%s\"", defel->defname)));
if (IsSet(opts->specified_opts, SUBOPT_TWOPHASE_COMMIT)) if (IsSet(opts->specified_opts, SUBOPT_TWOPHASE_COMMIT))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
opts->specified_opts |= SUBOPT_TWOPHASE_COMMIT; opts->specified_opts |= SUBOPT_TWOPHASE_COMMIT;
opts->twophase = defGetBoolean(defel); opts->twophase = defGetBoolean(defel);
@ -408,7 +389,8 @@ publicationListToArray(List *publist)
* Create new subscription. * Create new subscription.
*/ */
ObjectAddress ObjectAddress
CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
bool isTopLevel)
{ {
Relation rel; Relation rel;
ObjectAddress myself; ObjectAddress myself;
@ -432,7 +414,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
SUBOPT_SLOT_NAME | SUBOPT_COPY_DATA | SUBOPT_SLOT_NAME | SUBOPT_COPY_DATA |
SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY |
SUBOPT_STREAMING | SUBOPT_TWOPHASE_COMMIT); SUBOPT_STREAMING | SUBOPT_TWOPHASE_COMMIT);
parse_subscription_options(stmt->options, supported_opts, &opts); parse_subscription_options(pstate, stmt->options, supported_opts, &opts);
/* /*
* Since creating a replication slot is not transactional, rolling back * Since creating a replication slot is not transactional, rolling back
@ -853,7 +835,8 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
* Alter the existing subscription. * Alter the existing subscription.
*/ */
ObjectAddress ObjectAddress
AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel) AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
bool isTopLevel)
{ {
Relation rel; Relation rel;
ObjectAddress myself; ObjectAddress myself;
@ -906,7 +889,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY |
SUBOPT_STREAMING); SUBOPT_STREAMING);
parse_subscription_options(stmt->options, supported_opts, &opts); parse_subscription_options(pstate, stmt->options,
supported_opts, &opts);
if (IsSet(opts.specified_opts, SUBOPT_SLOT_NAME)) if (IsSet(opts.specified_opts, SUBOPT_SLOT_NAME))
{ {
@ -957,7 +941,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
case ALTER_SUBSCRIPTION_ENABLED: case ALTER_SUBSCRIPTION_ENABLED:
{ {
parse_subscription_options(stmt->options, SUBOPT_ENABLED, &opts); parse_subscription_options(pstate, stmt->options,
SUBOPT_ENABLED, &opts);
Assert(IsSet(opts.specified_opts, SUBOPT_ENABLED)); Assert(IsSet(opts.specified_opts, SUBOPT_ENABLED));
if (!sub->slotname && opts.enabled) if (!sub->slotname && opts.enabled)
@ -991,7 +976,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
case ALTER_SUBSCRIPTION_SET_PUBLICATION: case ALTER_SUBSCRIPTION_SET_PUBLICATION:
{ {
supported_opts = SUBOPT_COPY_DATA | SUBOPT_REFRESH; supported_opts = SUBOPT_COPY_DATA | SUBOPT_REFRESH;
parse_subscription_options(stmt->options, supported_opts, &opts); parse_subscription_options(pstate, stmt->options,
supported_opts, &opts);
values[Anum_pg_subscription_subpublications - 1] = values[Anum_pg_subscription_subpublications - 1] =
publicationListToArray(stmt->publication); publicationListToArray(stmt->publication);
@ -1040,7 +1026,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
if (isadd) if (isadd)
supported_opts |= SUBOPT_COPY_DATA; supported_opts |= SUBOPT_COPY_DATA;
parse_subscription_options(stmt->options, supported_opts, &opts); parse_subscription_options(pstate, stmt->options,
supported_opts, &opts);
publist = merge_publications(sub->publications, stmt->publication, isadd, stmt->subname); publist = merge_publications(sub->publications, stmt->publication, isadd, stmt->subname);
values[Anum_pg_subscription_subpublications - 1] = values[Anum_pg_subscription_subpublications - 1] =
@ -1087,7 +1074,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("ALTER SUBSCRIPTION ... REFRESH is not allowed for disabled subscriptions"))); errmsg("ALTER SUBSCRIPTION ... REFRESH is not allowed for disabled subscriptions")));
parse_subscription_options(stmt->options, SUBOPT_COPY_DATA, &opts); parse_subscription_options(pstate, stmt->options,
SUBOPT_COPY_DATA, &opts);
/* /*
* The subscription option "two_phase" requires that * The subscription option "two_phase" requires that

View File

@ -330,10 +330,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
continue; continue;
} }
if (*defelp != NULL) if (*defelp != NULL)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
*defelp = defel; *defelp = defel;
} }
@ -1336,7 +1333,7 @@ checkEnumOwner(HeapTuple tup)
* and users might have queries with that same assumption. * and users might have queries with that same assumption.
*/ */
ObjectAddress ObjectAddress
DefineRange(CreateRangeStmt *stmt) DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
{ {
char *typeName; char *typeName;
Oid typeNamespace; Oid typeNamespace;
@ -1411,50 +1408,38 @@ DefineRange(CreateRangeStmt *stmt)
if (strcmp(defel->defname, "subtype") == 0) if (strcmp(defel->defname, "subtype") == 0)
{ {
if (OidIsValid(rangeSubtype)) if (OidIsValid(rangeSubtype))
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
/* we can look up the subtype name immediately */ /* we can look up the subtype name immediately */
rangeSubtype = typenameTypeId(NULL, defGetTypeName(defel)); rangeSubtype = typenameTypeId(NULL, defGetTypeName(defel));
} }
else if (strcmp(defel->defname, "subtype_opclass") == 0) else if (strcmp(defel->defname, "subtype_opclass") == 0)
{ {
if (rangeSubOpclassName != NIL) if (rangeSubOpclassName != NIL)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
rangeSubOpclassName = defGetQualifiedName(defel); rangeSubOpclassName = defGetQualifiedName(defel);
} }
else if (strcmp(defel->defname, "collation") == 0) else if (strcmp(defel->defname, "collation") == 0)
{ {
if (rangeCollationName != NIL) if (rangeCollationName != NIL)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
rangeCollationName = defGetQualifiedName(defel); rangeCollationName = defGetQualifiedName(defel);
} }
else if (strcmp(defel->defname, "canonical") == 0) else if (strcmp(defel->defname, "canonical") == 0)
{ {
if (rangeCanonicalName != NIL) if (rangeCanonicalName != NIL)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
rangeCanonicalName = defGetQualifiedName(defel); rangeCanonicalName = defGetQualifiedName(defel);
} }
else if (strcmp(defel->defname, "subtype_diff") == 0) else if (strcmp(defel->defname, "subtype_diff") == 0)
{ {
if (rangeSubtypeDiffName != NIL) if (rangeSubtypeDiffName != NIL)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
rangeSubtypeDiffName = defGetQualifiedName(defel); rangeSubtypeDiffName = defGetQualifiedName(defel);
} }
else if (strcmp(defel->defname, "multirange_type_name") == 0) else if (strcmp(defel->defname, "multirange_type_name") == 0)
{ {
if (multirangeTypeName != NULL) if (multirangeTypeName != NULL)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
/* we can look up the subtype name immediately */ /* we can look up the subtype name immediately */
multirangeNamespace = QualifiedNameGetCreationNamespace(defGetQualifiedName(defel), multirangeNamespace = QualifiedNameGetCreationNamespace(defGetQualifiedName(defel),
&multirangeTypeName); &multirangeTypeName);

View File

@ -27,6 +27,7 @@
#include "catalog/pg_db_role_setting.h" #include "catalog/pg_db_role_setting.h"
#include "commands/comment.h" #include "commands/comment.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/seclabel.h" #include "commands/seclabel.h"
#include "commands/user.h" #include "commands/user.h"
#include "libpq/crypt.h" #include "libpq/crypt.h"
@ -128,10 +129,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
if (strcmp(defel->defname, "password") == 0) if (strcmp(defel->defname, "password") == 0)
{ {
if (dpassword) if (dpassword)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dpassword = defel; dpassword = defel;
} }
else if (strcmp(defel->defname, "sysid") == 0) else if (strcmp(defel->defname, "sysid") == 0)
@ -142,109 +140,73 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
else if (strcmp(defel->defname, "superuser") == 0) else if (strcmp(defel->defname, "superuser") == 0)
{ {
if (dissuper) if (dissuper)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dissuper = defel; dissuper = defel;
} }
else if (strcmp(defel->defname, "inherit") == 0) else if (strcmp(defel->defname, "inherit") == 0)
{ {
if (dinherit) if (dinherit)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dinherit = defel; dinherit = defel;
} }
else if (strcmp(defel->defname, "createrole") == 0) else if (strcmp(defel->defname, "createrole") == 0)
{ {
if (dcreaterole) if (dcreaterole)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcreaterole = defel; dcreaterole = defel;
} }
else if (strcmp(defel->defname, "createdb") == 0) else if (strcmp(defel->defname, "createdb") == 0)
{ {
if (dcreatedb) if (dcreatedb)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcreatedb = defel; dcreatedb = defel;
} }
else if (strcmp(defel->defname, "canlogin") == 0) else if (strcmp(defel->defname, "canlogin") == 0)
{ {
if (dcanlogin) if (dcanlogin)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dcanlogin = defel; dcanlogin = defel;
} }
else if (strcmp(defel->defname, "isreplication") == 0) else if (strcmp(defel->defname, "isreplication") == 0)
{ {
if (disreplication) if (disreplication)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
disreplication = defel; disreplication = defel;
} }
else if (strcmp(defel->defname, "connectionlimit") == 0) else if (strcmp(defel->defname, "connectionlimit") == 0)
{ {
if (dconnlimit) if (dconnlimit)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "addroleto") == 0) else if (strcmp(defel->defname, "addroleto") == 0)
{ {
if (daddroleto) if (daddroleto)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
daddroleto = defel; daddroleto = defel;
} }
else if (strcmp(defel->defname, "rolemembers") == 0) else if (strcmp(defel->defname, "rolemembers") == 0)
{ {
if (drolemembers) if (drolemembers)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
drolemembers = defel; drolemembers = defel;
} }
else if (strcmp(defel->defname, "adminmembers") == 0) else if (strcmp(defel->defname, "adminmembers") == 0)
{ {
if (dadminmembers) if (dadminmembers)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dadminmembers = defel; dadminmembers = defel;
} }
else if (strcmp(defel->defname, "validUntil") == 0) else if (strcmp(defel->defname, "validUntil") == 0)
{ {
if (dvalidUntil) if (dvalidUntil)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dvalidUntil = defel; dvalidUntil = defel;
} }
else if (strcmp(defel->defname, "bypassrls") == 0) else if (strcmp(defel->defname, "bypassrls") == 0)
{ {
if (dbypassRLS) if (dbypassRLS)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
dbypassRLS = defel; dbypassRLS = defel;
} }
else else
@ -528,7 +490,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
* "ALTER ROLE role ROLE rolenames", we don't document it. * "ALTER ROLE role ROLE rolenames", we don't document it.
*/ */
Oid Oid
AlterRole(AlterRoleStmt *stmt) AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
{ {
Datum new_record[Natts_pg_authid]; Datum new_record[Natts_pg_authid];
bool new_record_nulls[Natts_pg_authid]; bool new_record_nulls[Natts_pg_authid];
@ -577,90 +539,68 @@ AlterRole(AlterRoleStmt *stmt)
if (strcmp(defel->defname, "password") == 0) if (strcmp(defel->defname, "password") == 0)
{ {
if (dpassword) if (dpassword)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dpassword = defel; dpassword = defel;
} }
else if (strcmp(defel->defname, "superuser") == 0) else if (strcmp(defel->defname, "superuser") == 0)
{ {
if (dissuper) if (dissuper)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dissuper = defel; dissuper = defel;
} }
else if (strcmp(defel->defname, "inherit") == 0) else if (strcmp(defel->defname, "inherit") == 0)
{ {
if (dinherit) if (dinherit)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dinherit = defel; dinherit = defel;
} }
else if (strcmp(defel->defname, "createrole") == 0) else if (strcmp(defel->defname, "createrole") == 0)
{ {
if (dcreaterole) if (dcreaterole)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dcreaterole = defel; dcreaterole = defel;
} }
else if (strcmp(defel->defname, "createdb") == 0) else if (strcmp(defel->defname, "createdb") == 0)
{ {
if (dcreatedb) if (dcreatedb)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dcreatedb = defel; dcreatedb = defel;
} }
else if (strcmp(defel->defname, "canlogin") == 0) else if (strcmp(defel->defname, "canlogin") == 0)
{ {
if (dcanlogin) if (dcanlogin)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dcanlogin = defel; dcanlogin = defel;
} }
else if (strcmp(defel->defname, "isreplication") == 0) else if (strcmp(defel->defname, "isreplication") == 0)
{ {
if (disreplication) if (disreplication)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
disreplication = defel; disreplication = defel;
} }
else if (strcmp(defel->defname, "connectionlimit") == 0) else if (strcmp(defel->defname, "connectionlimit") == 0)
{ {
if (dconnlimit) if (dconnlimit)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dconnlimit = defel; dconnlimit = defel;
} }
else if (strcmp(defel->defname, "rolemembers") == 0 && else if (strcmp(defel->defname, "rolemembers") == 0 &&
stmt->action != 0) stmt->action != 0)
{ {
if (drolemembers) if (drolemembers)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
drolemembers = defel; drolemembers = defel;
} }
else if (strcmp(defel->defname, "validUntil") == 0) else if (strcmp(defel->defname, "validUntil") == 0)
{ {
if (dvalidUntil) if (dvalidUntil)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dvalidUntil = defel; dvalidUntil = defel;
} }
else if (strcmp(defel->defname, "bypassrls") == 0) else if (strcmp(defel->defname, "bypassrls") == 0)
{ {
if (dbypassRLS) if (dbypassRLS)
ereport(ERROR, errorConflictingDefElem(defel, pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
dbypassRLS = defel; dbypassRLS = defel;
} }
else else

View File

@ -392,9 +392,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
if (strcmp(defel->defname, "sequence_name") == 0) if (strcmp(defel->defname, "sequence_name") == 0)
{ {
if (nameEl) if (nameEl)
ereport(ERROR, errorConflictingDefElem(defel, cxt->pstate);
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
nameEl = defel; nameEl = defel;
nameEl_idx = foreach_current_index(option); nameEl_idx = foreach_current_index(option);
} }

View File

@ -708,7 +708,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
break; break;
case T_DoStmt: case T_DoStmt:
ExecuteDoStmt((DoStmt *) parsetree, isAtomicContext); ExecuteDoStmt(pstate, (DoStmt *) parsetree, isAtomicContext);
break; break;
case T_CreateTableSpaceStmt: case T_CreateTableSpaceStmt:
@ -888,7 +888,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
case T_AlterRoleStmt: case T_AlterRoleStmt:
/* no event triggers for global objects */ /* no event triggers for global objects */
AlterRole((AlterRoleStmt *) parsetree); AlterRole(pstate, (AlterRoleStmt *) parsetree);
break; break;
case T_AlterRoleSetStmt: case T_AlterRoleSetStmt:
@ -1552,11 +1552,11 @@ ProcessUtilitySlow(ParseState *pstate,
break; break;
case T_CreateFdwStmt: case T_CreateFdwStmt:
address = CreateForeignDataWrapper((CreateFdwStmt *) parsetree); address = CreateForeignDataWrapper(pstate, (CreateFdwStmt *) parsetree);
break; break;
case T_AlterFdwStmt: case T_AlterFdwStmt:
address = AlterForeignDataWrapper((AlterFdwStmt *) parsetree); address = AlterForeignDataWrapper(pstate, (AlterFdwStmt *) parsetree);
break; break;
case T_CreateForeignServerStmt: case T_CreateForeignServerStmt:
@ -1601,7 +1601,7 @@ ProcessUtilitySlow(ParseState *pstate,
break; break;
case T_CreateRangeStmt: /* CREATE TYPE AS RANGE */ case T_CreateRangeStmt: /* CREATE TYPE AS RANGE */
address = DefineRange((CreateRangeStmt *) parsetree); address = DefineRange(pstate, (CreateRangeStmt *) parsetree);
break; break;
case T_AlterEnumStmt: /* ALTER TYPE (enum) */ case T_AlterEnumStmt: /* ALTER TYPE (enum) */
@ -1802,11 +1802,11 @@ ProcessUtilitySlow(ParseState *pstate,
break; break;
case T_CreatePublicationStmt: case T_CreatePublicationStmt:
address = CreatePublication((CreatePublicationStmt *) parsetree); address = CreatePublication(pstate, (CreatePublicationStmt *) parsetree);
break; break;
case T_AlterPublicationStmt: case T_AlterPublicationStmt:
AlterPublication((AlterPublicationStmt *) parsetree); AlterPublication(pstate, (AlterPublicationStmt *) parsetree);
/* /*
* AlterPublication calls EventTriggerCollectSimpleCommand * AlterPublication calls EventTriggerCollectSimpleCommand
@ -1816,12 +1816,14 @@ ProcessUtilitySlow(ParseState *pstate,
break; break;
case T_CreateSubscriptionStmt: case T_CreateSubscriptionStmt:
address = CreateSubscription((CreateSubscriptionStmt *) parsetree, address = CreateSubscription(pstate,
(CreateSubscriptionStmt *) parsetree,
isTopLevel); isTopLevel);
break; break;
case T_AlterSubscriptionStmt: case T_AlterSubscriptionStmt:
address = AlterSubscription((AlterSubscriptionStmt *) parsetree, address = AlterSubscription(pstate,
(AlterSubscriptionStmt *) parsetree,
isTopLevel); isTopLevel);
break; break;

View File

@ -56,7 +56,7 @@ extern ObjectAddress CreateCast(CreateCastStmt *stmt);
extern ObjectAddress CreateTransform(CreateTransformStmt *stmt); extern ObjectAddress CreateTransform(CreateTransformStmt *stmt);
extern void IsThereFunctionInNamespace(const char *proname, int pronargs, extern void IsThereFunctionInNamespace(const char *proname, int pronargs,
oidvector *proargtypes, Oid nspOid); oidvector *proargtypes, Oid nspOid);
extern void ExecuteDoStmt(DoStmt *stmt, bool atomic); extern void ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic);
extern void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest); extern void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest);
extern TupleDesc CallStmtResultDesc(CallStmt *stmt); extern TupleDesc CallStmtResultDesc(CallStmt *stmt);
extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok); extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok);
@ -121,8 +121,8 @@ extern ObjectAddress AlterForeignServerOwner(const char *name, Oid newOwnerId);
extern void AlterForeignServerOwner_oid(Oid, Oid newOwnerId); extern void AlterForeignServerOwner_oid(Oid, Oid newOwnerId);
extern ObjectAddress AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId); extern ObjectAddress AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId);
extern void AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId); extern void AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId);
extern ObjectAddress CreateForeignDataWrapper(CreateFdwStmt *stmt); extern ObjectAddress CreateForeignDataWrapper(ParseState *pstate, CreateFdwStmt *stmt);
extern ObjectAddress AlterForeignDataWrapper(AlterFdwStmt *stmt); extern ObjectAddress AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt);
extern ObjectAddress CreateForeignServer(CreateForeignServerStmt *stmt); extern ObjectAddress CreateForeignServer(CreateForeignServerStmt *stmt);
extern ObjectAddress AlterForeignServer(AlterForeignServerStmt *stmt); extern ObjectAddress AlterForeignServer(AlterForeignServerStmt *stmt);
extern ObjectAddress CreateUserMapping(CreateUserMappingStmt *stmt); extern ObjectAddress CreateUserMapping(CreateUserMappingStmt *stmt);
@ -153,5 +153,6 @@ extern List *defGetQualifiedName(DefElem *def);
extern TypeName *defGetTypeName(DefElem *def); extern TypeName *defGetTypeName(DefElem *def);
extern int defGetTypeLength(DefElem *def); extern int defGetTypeLength(DefElem *def);
extern List *defGetStringList(DefElem *def); extern List *defGetStringList(DefElem *def);
extern void errorConflictingDefElem(DefElem *defel, ParseState *pstate) pg_attribute_noreturn();
#endif /* DEFREM_H */ #endif /* DEFREM_H */

View File

@ -18,8 +18,8 @@
#include "catalog/objectaddress.h" #include "catalog/objectaddress.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
extern ObjectAddress CreatePublication(CreatePublicationStmt *stmt); extern ObjectAddress CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt);
extern void AlterPublication(AlterPublicationStmt *stmt); extern void AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt);
extern void RemovePublicationRelById(Oid proid); extern void RemovePublicationRelById(Oid proid);
extern ObjectAddress AlterPublicationOwner(const char *name, Oid newOwnerId); extern ObjectAddress AlterPublicationOwner(const char *name, Oid newOwnerId);

View File

@ -18,9 +18,9 @@
#include "catalog/objectaddress.h" #include "catalog/objectaddress.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
extern ObjectAddress CreateSubscription(CreateSubscriptionStmt *stmt, extern ObjectAddress CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
bool isTopLevel); bool isTopLevel);
extern ObjectAddress AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel); extern ObjectAddress AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, bool isTopLevel);
extern void DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel); extern void DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel);
extern ObjectAddress AlterSubscriptionOwner(const char *name, Oid newOwnerId); extern ObjectAddress AlterSubscriptionOwner(const char *name, Oid newOwnerId);

View File

@ -25,7 +25,7 @@ extern ObjectAddress DefineType(ParseState *pstate, List *names, List *parameter
extern void RemoveTypeById(Oid typeOid); extern void RemoveTypeById(Oid typeOid);
extern ObjectAddress DefineDomain(CreateDomainStmt *stmt); extern ObjectAddress DefineDomain(CreateDomainStmt *stmt);
extern ObjectAddress DefineEnum(CreateEnumStmt *stmt); extern ObjectAddress DefineEnum(CreateEnumStmt *stmt);
extern ObjectAddress DefineRange(CreateRangeStmt *stmt); extern ObjectAddress DefineRange(ParseState *pstate, CreateRangeStmt *stmt);
extern ObjectAddress AlterEnum(AlterEnumStmt *stmt); extern ObjectAddress AlterEnum(AlterEnumStmt *stmt);
extern ObjectAddress DefineCompositeType(RangeVar *typevar, List *coldeflist); extern ObjectAddress DefineCompositeType(RangeVar *typevar, List *coldeflist);
extern Oid AssignTypeArrayOid(void); extern Oid AssignTypeArrayOid(void);

View File

@ -25,7 +25,7 @@ typedef void (*check_password_hook_type) (const char *username, const char *shad
extern PGDLLIMPORT check_password_hook_type check_password_hook; extern PGDLLIMPORT check_password_hook_type check_password_hook;
extern Oid CreateRole(ParseState *pstate, CreateRoleStmt *stmt); extern Oid CreateRole(ParseState *pstate, CreateRoleStmt *stmt);
extern Oid AlterRole(AlterRoleStmt *stmt); extern Oid AlterRole(ParseState *pstate, AlterRoleStmt *stmt);
extern Oid AlterRoleSet(AlterRoleSetStmt *stmt); extern Oid AlterRoleSet(AlterRoleSetStmt *stmt);
extern void DropRole(DropRoleStmt *stmt); extern void DropRole(DropRoleStmt *stmt);
extern void GrantRole(GrantRoleStmt *stmt); extern void GrantRole(GrantRoleStmt *stmt);

View File

@ -67,6 +67,8 @@ LINE 1: COPY x from stdin (force_not_null (a), force_not_null (b));
^ ^
COPY x from stdin (force_null (a), force_null (b)); COPY x from stdin (force_null (a), force_null (b));
ERROR: conflicting or redundant options ERROR: conflicting or redundant options
LINE 1: COPY x from stdin (force_null (a), force_null (b));
^
COPY x from stdin (convert_selectively (a), convert_selectively (b)); COPY x from stdin (convert_selectively (a), convert_selectively (b));
ERROR: conflicting or redundant options ERROR: conflicting or redundant options
LINE 1: COPY x from stdin (convert_selectively (a), convert_selectiv... LINE 1: COPY x from stdin (convert_selectively (a), convert_selectiv...

View File

@ -95,6 +95,8 @@ CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
ERROR: function invalid_fdw_handler must return type fdw_handler ERROR: function invalid_fdw_handler must return type fdw_handler
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
ERROR: conflicting or redundant options ERROR: conflicting or redundant options
LINE 1: ...GN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER in...
^
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler; CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler;
DROP FOREIGN DATA WRAPPER test_fdw; DROP FOREIGN DATA WRAPPER test_fdw;
-- ALTER FOREIGN DATA WRAPPER -- ALTER FOREIGN DATA WRAPPER
@ -201,6 +203,8 @@ ALTER FOREIGN DATA WRAPPER foo HANDLER invalid_fdw_handler; -- ERROR
ERROR: function invalid_fdw_handler must return type fdw_handler ERROR: function invalid_fdw_handler must return type fdw_handler
ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything; -- ERROR ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything; -- ERROR
ERROR: conflicting or redundant options ERROR: conflicting or redundant options
LINE 1: ...FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER an...
^
ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler; ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler;
WARNING: changing the foreign-data wrapper handler can change behavior of existing foreign tables WARNING: changing the foreign-data wrapper handler can change behavior of existing foreign tables
DROP FUNCTION invalid_fdw_handler(); DROP FUNCTION invalid_fdw_handler();

View File

@ -27,6 +27,8 @@ CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
ERROR: unrecognized "publish" value: "cluster" ERROR: unrecognized "publish" value: "cluster"
CREATE PUBLICATION testpub_xxx WITH (publish_via_partition_root = 'true', publish_via_partition_root = '0'); CREATE PUBLICATION testpub_xxx WITH (publish_via_partition_root = 'true', publish_via_partition_root = '0');
ERROR: conflicting or redundant options ERROR: conflicting or redundant options
LINE 1: ...ub_xxx WITH (publish_via_partition_root = 'true', publish_vi...
^
\dRp \dRp
List of publications List of publications
Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root