From df3c467dd3842ade113e0a6443d332dc48996af1 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Fri, 30 Apr 2021 10:39:28 +0530 Subject: [PATCH v2] compute_common_attribute --- src/backend/commands/functioncmds.c | 59 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 9548287217..3b3ebf67c4 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -492,37 +492,40 @@ compute_common_attribute(ParseState *pstate, DefElem **support_item, DefElem **parallel_item) { + bool is_duplicate_error = false; + bool is_procedure_error = false; + if (strcmp(defel->defname, "volatility") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*volatility_item) - goto duplicate_error; + is_duplicate_error = true; *volatility_item = defel; } else if (strcmp(defel->defname, "strict") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*strict_item) - goto duplicate_error; + is_duplicate_error = true; *strict_item = defel; } else if (strcmp(defel->defname, "security") == 0) { if (*security_item) - goto duplicate_error; + is_duplicate_error = true; *security_item = defel; } else if (strcmp(defel->defname, "leakproof") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*leakproof_item) - goto duplicate_error; + is_duplicate_error = true; *leakproof_item = defel; } @@ -533,58 +536,56 @@ compute_common_attribute(ParseState *pstate, else if (strcmp(defel->defname, "cost") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*cost_item) - goto duplicate_error; + is_duplicate_error = true; *cost_item = defel; } else if (strcmp(defel->defname, "rows") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*rows_item) - goto duplicate_error; + is_duplicate_error = true; *rows_item = defel; } else if (strcmp(defel->defname, "support") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*support_item) - goto duplicate_error; + is_duplicate_error = true; *support_item = defel; } else if (strcmp(defel->defname, "parallel") == 0) { if (is_procedure) - goto procedure_error; + is_procedure_error = true; if (*parallel_item) - goto duplicate_error; + is_duplicate_error = true; *parallel_item = defel; } else return false; + if (is_procedure_error) + ereport(ERROR, + (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), + errmsg("invalid attribute in procedure definition"), + parser_errposition(pstate, defel->location))); + + if (is_duplicate_error) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("option \"%s\" specified more than once", defel->defname), + parser_errposition(pstate, defel->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), - errmsg("invalid attribute in procedure definition"), - parser_errposition(pstate, defel->location))); - return false; } static char -- 2.25.1