From 9abc7a58b48d389e279d1a3676351f36b9ebc6c3 Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Thu, 19 Mar 2026 16:40:35 +0900 Subject: [PATCH] Fix RPR error codes and GROUPS typo in frame validation Frame validation errors in transformRPR() were reported with ERRCODE_SYNTAX_ERROR. These are semantic errors detected after parsing, so ERRCODE_WINDOWING_ERROR is the correct code per SQL standard. Also fix a typo in the error message: "FRAME option GROUP" -> "FRAME option GROUPS" to match the actual SQL keyword. --- src/backend/parser/parse_rpr.c | 10 +++++----- src/test/regress/expected/rpr_base.out | 8 ++++---- src/test/regress/sql/rpr_base.sql | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/backend/parser/parse_rpr.c b/src/backend/parser/parse_rpr.c index e574b69d9b5..66252cd185e 100644 --- a/src/backend/parser/parse_rpr.c +++ b/src/backend/parser/parse_rpr.c @@ -72,15 +72,15 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, /* Frame type must be "ROW" */ if (wc->frameOptions & FRAMEOPTION_GROUPS) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("FRAME option GROUP is not permitted when row pattern recognition is used"), + (errcode(ERRCODE_WINDOWING_ERROR), + errmsg("FRAME option GROUPS is not permitted when row pattern recognition is used"), errhint("Use: ROWS instead"), parser_errposition(pstate, windef->frameLocation >= 0 ? windef->frameLocation : windef->location))); if (wc->frameOptions & FRAMEOPTION_RANGE) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), + (errcode(ERRCODE_WINDOWING_ERROR), errmsg("FRAME option RANGE is not permitted when row pattern recognition is used"), errhint("Use: ROWS instead"), parser_errposition(pstate, @@ -107,7 +107,7 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, (wc->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING)); ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), + (errcode(ERRCODE_WINDOWING_ERROR), errmsg("FRAME must start at CURRENT ROW when row pattern recognition is used"), errdetail("Current frame starts with %s.", startBound), errhint("Use: %s BETWEEN CURRENT ROW AND ...", frameType), @@ -133,7 +133,7 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, (wc->frameOptions & FRAMEOPTION_EXCLUDE_TIES)); ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), + (errcode(ERRCODE_WINDOWING_ERROR), errmsg("EXCLUDE options are not permitted when row pattern recognition is used"), errdetail("Frame definition includes %s.", excludeType), errhint("Remove the EXCLUDE clause from the window definition."), diff --git a/src/test/regress/expected/rpr_base.out b/src/test/regress/expected/rpr_base.out index 7931ad07d7d..50a9e7daea9 100644 --- a/src/test/regress/expected/rpr_base.out +++ b/src/test/regress/expected/rpr_base.out @@ -483,11 +483,11 @@ WINDOW w AS ( PATTERN (A+) DEFINE A AS val > 0 ); -ERROR: FRAME option GROUP is not permitted when row pattern recognition is used +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 --- Expected: ERROR: FRAME option GROUP is not permitted when row pattern recognition is used +-- Expected: ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used -- Starting with N PRECEDING SELECT COUNT(*) OVER w FROM rpr_frame @@ -656,11 +656,11 @@ WINDOW w AS ( DEFINE A AS val >= 0, B AS val >= 0 ) ORDER BY id; -ERROR: FRAME option GROUP is not permitted when row pattern recognition is used +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 --- Expected: ERROR: FRAME option GROUP is not permitted when row pattern recognition is used +-- Expected: ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used DROP TABLE rpr_frame; -- ============================================================ -- PARTITION BY + FRAME Tests diff --git a/src/test/regress/sql/rpr_base.sql b/src/test/regress/sql/rpr_base.sql index f8815c7376a..e54d54e400a 100644 --- a/src/test/regress/sql/rpr_base.sql +++ b/src/test/regress/sql/rpr_base.sql @@ -397,7 +397,7 @@ WINDOW w AS ( PATTERN (A+) DEFINE A AS val > 0 ); --- Expected: ERROR: FRAME option GROUP is not permitted when row pattern recognition is used +-- Expected: ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used -- Starting with N PRECEDING SELECT COUNT(*) OVER w @@ -517,7 +517,7 @@ WINDOW w AS ( DEFINE A AS val >= 0, B AS val >= 0 ) ORDER BY id; --- Expected: ERROR: FRAME option GROUP is not permitted when row pattern recognition is used +-- Expected: ERROR: FRAME option GROUPS is not permitted when row pattern recognition is used DROP TABLE rpr_frame; -- 2.50.1 (Apple Git-155)