From 37cb8a6e9d36ac98b7cd10bb81a9a4f70720d016 Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Tue, 5 May 2026 17:27:51 +0900 Subject: [PATCH 07/11] Remove optional outer parentheses from ereport() calls in RPR files Per project coding style, the outer parentheses wrapping errcode/ errmsg/etc. arguments in ereport() are optional and should be omitted. Applies to parse_rpr.c, optimizer/plan/rpr.c, and gram.y. --- src/backend/optimizer/plan/rpr.c | 16 ++-- src/backend/parser/gram.y | 72 ++++++++-------- src/backend/parser/parse_rpr.c | 140 +++++++++++++++---------------- 3 files changed, 114 insertions(+), 114 deletions(-) diff --git a/src/backend/optimizer/plan/rpr.c b/src/backend/optimizer/plan/rpr.c index a817eb4a63f..ed8b6c3414c 100644 --- a/src/backend/optimizer/plan/rpr.c +++ b/src/backend/optimizer/plan/rpr.c @@ -1027,10 +1027,10 @@ scanRPRPatternRecursive(RPRPatternNode *node, char **varNames, int *numVars, /* Check recursion depth limit before overflow occurs */ if (depth >= RPR_DEPTH_MAX) ereport(ERROR, - (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("pattern nesting too deep"), - errdetail("Pattern nesting depth %d exceeds maximum %d.", - depth, RPR_DEPTH_MAX - 1))); + errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("pattern nesting too deep"), + errdetail("Pattern nesting depth %d exceeds maximum %d.", + depth, RPR_DEPTH_MAX - 1)); /* Track maximum depth */ if (depth > *maxDepth) @@ -1120,10 +1120,10 @@ scanRPRPattern(RPRPatternNode *node, char **varNames, int *numVars, if (*numElements > RPR_ELEMIDX_MAX) ereport(ERROR, - (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("pattern too complex"), - errdetail("Pattern has %d elements, maximum is %d.", - *numElements, RPR_ELEMIDX_MAX))); + errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("pattern too complex"), + errdetail("Pattern has %d elements, maximum is %d.", + *numElements, RPR_ELEMIDX_MAX)); } /* diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index f3cedfbbb18..aa587e6aced 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -17610,10 +17610,10 @@ opt_row_pattern_initial_or_seek: | SEEK { ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SEEK is not supported"), - errhint("Use INITIAL instead."), - parser_errposition(@1))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SEEK is not supported"), + errhint("Use INITIAL instead."), + parser_errposition(@1)); } | /*EMPTY*/ { $$ = true; } ; @@ -17740,40 +17740,40 @@ row_pattern_quantifier_opt: $$ = (Node *) makeRPRQuantifier(0, 1, @1 + 1, @1, yyscanner); else ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("unsupported quantifier \"%s\"", $1), - errhint("Valid quantifiers are: *, +, ?, *?, +?, ??, {n}, {n,}, {,m}, {n,m} and their reluctant versions."), - parser_errposition(@1))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("unsupported quantifier \"%s\"", $1), + errhint("Valid quantifiers are: *, +, ?, *?, +?, ??, {n}, {n,}, {,m}, {n,m} and their reluctant versions."), + parser_errposition(@1)); } /* RELUCTANT quantifiers (when lexer separates tokens) */ | '*' Op { if (strcmp($2, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid token after \"*\" quantifier"), - errhint("Did you mean \"*?\" for reluctant quantifier?"), - parser_errposition(@2))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid token after \"*\" quantifier"), + errhint("Did you mean \"*?\" for reluctant quantifier?"), + parser_errposition(@2)); $$ = (Node *) makeRPRQuantifier(0, INT_MAX, @2, @1, yyscanner); } | '+' Op { if (strcmp($2, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid token after \"+\" quantifier"), - errhint("Did you mean \"+?\" for reluctant quantifier?"), - parser_errposition(@2))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid token after \"+\" quantifier"), + errhint("Did you mean \"+?\" for reluctant quantifier?"), + parser_errposition(@2)); $$ = (Node *) makeRPRQuantifier(1, INT_MAX, @2, @1, yyscanner); } | Op Op { if (strcmp($1, "?") != 0 || strcmp($2, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid quantifier combination"), - errhint("Did you mean \"??\" for reluctant quantifier?"), - parser_errposition(@1))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid quantifier combination"), + errhint("Did you mean \"??\" for reluctant quantifier?"), + parser_errposition(@1)); $$ = (Node *) makeRPRQuantifier(0, 1, @2, @1, yyscanner); } /* {n}, {n,}, {,m}, {n,m} quantifiers */ @@ -17823,10 +17823,10 @@ row_pattern_quantifier_opt: { if (strcmp($4, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid token after range quantifier"), - errhint("Only \"?\" is allowed after {n} to make it reluctant."), - parser_errposition(@4))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid token after range quantifier"), + errhint("Only \"?\" is allowed after {n} to make it reluctant."), + parser_errposition(@4)); if ($2 <= 0 || $2 >= INT_MAX) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), @@ -17838,10 +17838,10 @@ row_pattern_quantifier_opt: { if (strcmp($5, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid token after range quantifier"), - errhint("Only \"?\" is allowed after {n,} or {,m} to make it reluctant."), - parser_errposition(@5))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid token after range quantifier"), + errhint("Only \"?\" is allowed after {n,} or {,m} to make it reluctant."), + parser_errposition(@5)); if ($2 < 0 || $2 >= INT_MAX) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), @@ -17853,10 +17853,10 @@ row_pattern_quantifier_opt: { if (strcmp($5, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid token after range quantifier"), - errhint("Only \"?\" is allowed after {n,} or {,m} to make it reluctant."), - parser_errposition(@5))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid token after range quantifier"), + errhint("Only \"?\" is allowed after {n,} or {,m} to make it reluctant."), + parser_errposition(@5)); if ($3 <= 0 || $3 >= INT_MAX) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), @@ -17868,10 +17868,10 @@ row_pattern_quantifier_opt: { if (strcmp($6, "?") != 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid token after range quantifier"), - errhint("Only \"?\" is allowed after {n,m} to make it reluctant."), - parser_errposition(@6))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid token after range quantifier"), + errhint("Only \"?\" is allowed after {n,m} to make it reluctant."), + parser_errposition(@6)); if ($2 < 0 || $4 <= 0 || $2 >= INT_MAX || $4 >= INT_MAX) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/backend/parser/parse_rpr.c b/src/backend/parser/parse_rpr.c index 2c6fccebd47..bba887f17ce 100644 --- a/src/backend/parser/parse_rpr.c +++ b/src/backend/parser/parse_rpr.c @@ -95,20 +95,20 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, /* Frame type must be "ROW" */ if (wc->frameOptions & FRAMEOPTION_GROUPS) ereport(ERROR, - (errcode(ERRCODE_WINDOWING_ERROR), - errmsg("cannot use FRAME option GROUPS with row pattern recognition"), - errhint("Use ROWS instead."), - parser_errposition(pstate, - windef->frameLocation >= 0 ? - windef->frameLocation : windef->location))); + errcode(ERRCODE_WINDOWING_ERROR), + errmsg("cannot use FRAME option GROUPS with row pattern recognition"), + errhint("Use ROWS instead."), + parser_errposition(pstate, + windef->frameLocation >= 0 ? + windef->frameLocation : windef->location)); if (wc->frameOptions & FRAMEOPTION_RANGE) ereport(ERROR, - (errcode(ERRCODE_WINDOWING_ERROR), - errmsg("cannot use FRAME option RANGE with row pattern recognition"), - errhint("Use ROWS instead."), - parser_errposition(pstate, - windef->frameLocation >= 0 ? - windef->frameLocation : windef->location))); + errcode(ERRCODE_WINDOWING_ERROR), + errmsg("cannot use FRAME option RANGE with row pattern recognition"), + errhint("Use ROWS instead."), + parser_errposition(pstate, + windef->frameLocation >= 0 ? + windef->frameLocation : windef->location)); /* Frame must start at current row */ if ((wc->frameOptions & FRAMEOPTION_START_CURRENT_ROW) == 0) @@ -130,11 +130,11 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, (wc->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING)); ereport(ERROR, - (errcode(ERRCODE_WINDOWING_ERROR), - errmsg("FRAME must start at CURRENT ROW when using row pattern recognition"), - errdetail("Current frame starts with %s.", startBound), - errhint("Use: %s BETWEEN CURRENT ROW AND ...", frameType), - parser_errposition(pstate, windef->frameLocation >= 0 ? windef->frameLocation : windef->location))); + errcode(ERRCODE_WINDOWING_ERROR), + errmsg("FRAME must start at CURRENT ROW when using row pattern recognition"), + errdetail("Current frame starts with %s.", startBound), + errhint("Use: %s BETWEEN CURRENT ROW AND ...", frameType), + parser_errposition(pstate, windef->frameLocation >= 0 ? windef->frameLocation : windef->location)); } /* EXCLUDE options are not permitted */ @@ -156,11 +156,11 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, (wc->frameOptions & FRAMEOPTION_EXCLUDE_TIES)); ereport(ERROR, - (errcode(ERRCODE_WINDOWING_ERROR), - errmsg("cannot use EXCLUDE options with row pattern recognition"), - errdetail("Frame definition includes %s.", excludeType), - errhint("Remove the EXCLUDE clause from the window definition."), - parser_errposition(pstate, windef->excludeLocation >= 0 ? windef->excludeLocation : windef->location))); + errcode(ERRCODE_WINDOWING_ERROR), + errmsg("cannot use EXCLUDE options with row pattern recognition"), + errdetail("Frame definition includes %s.", excludeType), + errhint("Remove the EXCLUDE clause from the window definition."), + parser_errposition(pstate, windef->excludeLocation >= 0 ? windef->excludeLocation : windef->location)); } /* Transform AFTER MATCH SKIP TO clause */ @@ -220,11 +220,11 @@ validateRPRPatternVarCount(ParseState *pstate, RPRPatternNode *node, /* Check against RPR_VARID_MAX before adding */ if (list_length(*varNames) >= RPR_VARID_MAX) ereport(ERROR, - (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("too many pattern variables"), - errdetail("Maximum is %d.", RPR_VARID_MAX), - parser_errposition(pstate, - exprLocation((Node *) node)))); + errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("too many pattern variables"), + errdetail("Maximum is %d.", RPR_VARID_MAX), + parser_errposition(pstate, + exprLocation((Node *) node))); *varNames = lappend(*varNames, makeString(pstrdup(node->varName))); } @@ -267,10 +267,10 @@ validateRPRPatternVarCount(ParseState *pstate, RPRPatternNode *node, } if (!found) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("DEFINE variable \"%s\" is not used in PATTERN", - rt->name), - parser_errposition(pstate, rt->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("DEFINE variable \"%s\" is not used in PATTERN", + rt->name), + parser_errposition(pstate, rt->location)); } } } @@ -347,10 +347,10 @@ transformDefineClause(ParseState *pstate, WindowClause *wc, WindowDef *windef, if (!strcmp(n, name)) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("DEFINE variable \"%s\" appears more than once", - name), - parser_errposition(pstate, exprLocation((Node *) r)))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("DEFINE variable \"%s\" appears more than once", + name), + parser_errposition(pstate, exprLocation((Node *) r))); } restargets = lappend(restargets, restarget); @@ -529,14 +529,14 @@ define_walker(Node *node, void *context) */ if (check_functions_in_node(node, nav_volatile_func_checker, NULL)) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("volatile functions are not allowed in DEFINE clause"), - parser_errposition(ctx->pstate, exprLocation(node)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("volatile functions are not allowed in DEFINE clause"), + parser_errposition(ctx->pstate, exprLocation(node))); if (IsA(node, NextValueExpr)) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("sequence operations are not allowed in DEFINE clause"), - parser_errposition(ctx->pstate, exprLocation(node)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("sequence operations are not allowed in DEFINE clause"), + parser_errposition(ctx->pstate, exprLocation(node))); /* Var sighting feeds the column-ref rule for the enclosing nav scope. */ if (IsA(node, Var) && @@ -600,17 +600,17 @@ define_walker(Node *node, void *context) /* Reject triple-or-deeper nesting */ if (ctx->nav_count > 1) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot nest row pattern navigation more than two levels deep"), - errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), - parser_errposition(ctx->pstate, nav->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot nest row pattern navigation more than two levels deep"), + errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), + parser_errposition(ctx->pstate, nav->location)); if (!IsA(nav->arg, RPRNavExpr)) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("row pattern navigation operation must be a direct argument of the outer navigation"), - errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), - parser_errposition(ctx->pstate, nav->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("row pattern navigation operation must be a direct argument of the outer navigation"), + errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), + parser_errposition(ctx->pstate, nav->location)); inner = (RPRNavExpr *) nav->arg; @@ -630,29 +630,29 @@ define_walker(Node *node, void *context) } else if (!outer_phys && inner_phys) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("FIRST and LAST cannot contain PREV or NEXT"), - errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), - parser_errposition(ctx->pstate, nav->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("FIRST and LAST cannot contain PREV or NEXT"), + errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), + parser_errposition(ctx->pstate, nav->location)); else if (outer_phys && inner_phys) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("PREV and NEXT cannot contain PREV or NEXT"), - errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), - parser_errposition(ctx->pstate, nav->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("PREV and NEXT cannot contain PREV or NEXT"), + errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), + parser_errposition(ctx->pstate, nav->location)); else ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("FIRST and LAST cannot contain FIRST or LAST"), - errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), - parser_errposition(ctx->pstate, nav->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("FIRST and LAST cannot contain FIRST or LAST"), + errhint("Only PREV(FIRST()), PREV(LAST()), NEXT(FIRST()), and NEXT(LAST()) compound forms are allowed."), + parser_errposition(ctx->pstate, nav->location)); } else if (!ctx->has_column_ref) { ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("argument of row pattern navigation operation must include at least one column reference"), - parser_errposition(ctx->pstate, nav->location))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("argument of row pattern navigation operation must include at least one column reference"), + parser_errposition(ctx->pstate, nav->location)); } /* @@ -673,9 +673,9 @@ define_walker(Node *node, void *context) (void) define_walker((Node *) nav->offset_arg, ctx); if (ctx->has_column_ref) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("row pattern navigation offset must be a run-time constant"), - parser_errposition(ctx->pstate, exprLocation((Node *) nav->offset_arg)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("row pattern navigation offset must be a run-time constant"), + parser_errposition(ctx->pstate, exprLocation((Node *) nav->offset_arg))); } if (flattened && nav->compound_offset_arg != NULL) { @@ -683,9 +683,9 @@ define_walker(Node *node, void *context) (void) define_walker((Node *) nav->compound_offset_arg, ctx); if (ctx->has_column_ref) ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("row pattern navigation offset must be a run-time constant"), - parser_errposition(ctx->pstate, exprLocation((Node *) nav->compound_offset_arg)))); + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("row pattern navigation offset must be a run-time constant"), + parser_errposition(ctx->pstate, exprLocation((Node *) nav->compound_offset_arg))); } *ctx = saved; -- 2.50.1 (Apple Git-155)