From c3dc38316266bddc6d0d17aff47235bcfc79b303 Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Tue, 7 Apr 2026 11:15:12 +0900 Subject: [PATCH] Fix RPR error message style: hint format, terminology, capitalization Remove colon in errhint "Use: ROWS instead" -> "Use ROWS instead." and add missing trailing period. Shorten "row pattern definition variable name" to "DEFINE variable" for consistency with other error messages. Capitalize navigation function names in stub error messages (prev -> PREV, etc.) to match SQL standard keyword style used elsewhere in the parser. --- src/backend/parser/parse_rpr.c | 6 +++--- src/backend/utils/adt/windowfuncs.c | 16 ++++++++-------- src/test/regress/expected/rpr_base.out | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/backend/parser/parse_rpr.c b/src/backend/parser/parse_rpr.c index 05070cb04bb..8fbe12e1518 100644 --- a/src/backend/parser/parse_rpr.c +++ b/src/backend/parser/parse_rpr.c @@ -78,7 +78,7 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("FRAME option GROUPS is not permitted when row pattern recognition is used"), - errhint("Use: ROWS instead"), + errhint("Use ROWS instead."), parser_errposition(pstate, windef->frameLocation >= 0 ? windef->frameLocation : windef->location))); @@ -86,7 +86,7 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("FRAME option RANGE is not permitted when row pattern recognition is used"), - errhint("Use: ROWS instead"), + errhint("Use ROWS instead."), parser_errposition(pstate, windef->frameLocation >= 0 ? windef->frameLocation : windef->location))); @@ -329,7 +329,7 @@ transformDefineClause(ParseState *pstate, WindowClause *wc, WindowDef *windef, if (!strcmp(n, name)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("row pattern definition variable name \"%s\" appears more than once in DEFINE clause", + errmsg("DEFINE variable \"%s\" appears more than once", name), parser_errposition(pstate, exprLocation((Node *) r)))); } diff --git a/src/backend/utils/adt/windowfuncs.c b/src/backend/utils/adt/windowfuncs.c index 420a4962395..fb966cae43c 100644 --- a/src/backend/utils/adt/windowfuncs.c +++ b/src/backend/utils/adt/windowfuncs.c @@ -740,7 +740,7 @@ window_prev(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("prev() can only be used in a DEFINE clause"))); + errmsg("PREV() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -754,7 +754,7 @@ window_next(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("next() can only be used in a DEFINE clause"))); + errmsg("NEXT() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -768,7 +768,7 @@ window_prev_offset(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("prev() can only be used in a DEFINE clause"))); + errmsg("PREV() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -782,7 +782,7 @@ window_next_offset(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("next() can only be used in a DEFINE clause"))); + errmsg("NEXT() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -796,7 +796,7 @@ window_first(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("first() can only be used in a DEFINE clause"))); + errmsg("FIRST() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -810,7 +810,7 @@ window_last(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("last() can only be used in a DEFINE clause"))); + errmsg("LAST() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -824,7 +824,7 @@ window_first_offset(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("first() can only be used in a DEFINE clause"))); + errmsg("FIRST() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } @@ -838,6 +838,6 @@ window_last_offset(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("last() can only be used in a DEFINE clause"))); + errmsg("LAST() can only be used in a DEFINE clause"))); PG_RETURN_NULL(); /* not reached */ } diff --git a/src/test/regress/expected/rpr_base.out b/src/test/regress/expected/rpr_base.out index 0845316965e..912bd7b7c77 100644 --- a/src/test/regress/expected/rpr_base.out +++ b/src/test/regress/expected/rpr_base.out @@ -232,7 +232,7 @@ WINDOW w AS ( PATTERN (A+) DEFINE A AS id > 0, A AS id < 10 ); -ERROR: row pattern definition variable name "a" appears more than once in DEFINE clause +ERROR: DEFINE variable "a" appears more than once LINE 7: DEFINE A AS id > 0, A AS id < 10 ^ -- Expected: ERROR: row pattern definition variable name "a" appears more than once in DEFINE clause @@ -469,7 +469,7 @@ WINDOW w AS ( ERROR: FRAME option RANGE is not permitted when row pattern recognition is used LINE 5: RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWIN... ^ -HINT: Use: ROWS instead +HINT: Use ROWS instead. -- Expected: ERROR: FRAME option RANGE is not permitted when row pattern recognition is used -- GROUPS frame not starting at CURRENT ROW SELECT COUNT(*) OVER w @@ -483,7 +483,7 @@ WINDOW w AS ( ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used LINE 5: GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWI... ^ -HINT: Use: ROWS instead +HINT: Use ROWS instead. -- Expected: ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used -- Starting with N PRECEDING SELECT COUNT(*) OVER w @@ -640,7 +640,7 @@ ORDER BY id; ERROR: FRAME option RANGE is not permitted when row pattern recognition is used LINE 5: RANGE BETWEEN CURRENT ROW AND 10 FOLLOWING ^ -HINT: Use: ROWS instead +HINT: Use ROWS instead. -- Expected: ERROR: FRAME option RANGE is not permitted when row pattern recognition is used -- GROUPS frame with RPR (not permitted) SELECT id, val, COUNT(*) OVER w as cnt @@ -656,7 +656,7 @@ ORDER BY id; ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used LINE 5: GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ^ -HINT: Use: ROWS instead +HINT: Use ROWS instead. -- Expected: ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used DROP TABLE rpr_frame; -- ============================================================ @@ -705,7 +705,7 @@ ORDER BY id; ERROR: FRAME option RANGE is not permitted when row pattern recognition is used LINE 6: RANGE BETWEEN CURRENT ROW AND 10 FOLLOWING ^ -HINT: Use: ROWS instead +HINT: Use ROWS instead. -- Expected: ERROR: FRAME option RANGE is not permitted when row pattern recognition is used DROP TABLE rpr_partition; -- ============================================================ -- 2.50.1 (Apple Git-155)