From b5f1d7cf8e48b7007e05e5cf6207644430ad810c Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Fri, 30 Apr 2021 07:57:36 +0530 Subject: [PATCH v1] compute_common_attribute --- src/backend/commands/functioncmds.c | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 9548287217..e43044dba7 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -492,12 +492,14 @@ compute_common_attribute(ParseState *pstate, DefElem **support_item, DefElem **parallel_item) { + DefElem *duplicate_item = NULL; + if (strcmp(defel->defname, "volatility") == 0) { if (is_procedure) goto procedure_error; if (*volatility_item) - goto duplicate_error; + duplicate_item = defel; *volatility_item = defel; } @@ -506,14 +508,14 @@ compute_common_attribute(ParseState *pstate, if (is_procedure) goto procedure_error; if (*strict_item) - goto duplicate_error; + duplicate_item = defel; *strict_item = defel; } else if (strcmp(defel->defname, "security") == 0) { if (*security_item) - goto duplicate_error; + duplicate_item = defel; *security_item = defel; } @@ -522,7 +524,7 @@ compute_common_attribute(ParseState *pstate, if (is_procedure) goto procedure_error; if (*leakproof_item) - goto duplicate_error; + duplicate_item = defel; *leakproof_item = defel; } @@ -535,7 +537,7 @@ compute_common_attribute(ParseState *pstate, if (is_procedure) goto procedure_error; if (*cost_item) - goto duplicate_error; + duplicate_item = defel; *cost_item = defel; } @@ -544,7 +546,7 @@ compute_common_attribute(ParseState *pstate, if (is_procedure) goto procedure_error; if (*rows_item) - goto duplicate_error; + duplicate_item = defel; *rows_item = defel; } @@ -553,7 +555,7 @@ compute_common_attribute(ParseState *pstate, if (is_procedure) goto procedure_error; if (*support_item) - goto duplicate_error; + duplicate_item = defel; *support_item = defel; } @@ -562,23 +564,22 @@ compute_common_attribute(ParseState *pstate, if (is_procedure) goto procedure_error; if (*parallel_item) - goto duplicate_error; + duplicate_item = defel; *parallel_item = defel; } else return false; + if (duplicate_item) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("option \"%s\" specified more than once", duplicate_item->defname), + parser_errposition(pstate, duplicate_item->location))); + /* Recognized an option */ 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: ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), -- 2.25.1