From 1c5d2a431ca85a5e74b4448aacb8c8cc1da0dd0c Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Sat, 2 May 2026 00:59:10 +0900 Subject: [PATCH 37/40] Replace non-ASCII characters in RPR code and tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RPR patches accumulated a few Unicode characters (arrows, the not-equal sign, plus-minus, em dash, section sign) in regression test comments and a handful of source-code comments. The PostgreSQL project conventionally keeps source and regression test files in plain ASCII. Replace these with their ASCII equivalents: -> for U+2192 RIGHTWARDS ARROW != for U+2260 NOT EQUAL TO +/- for U+00B1 PLUS-MINUS SIGN -- for U+2014 EM DASH SQL standard for "§" references (matching the existing "SQL standard 5.6.4" idiom in parse_rpr.c) Affected: createplan.c, execRPR.c, parse_func.c (comments), and the rpr / rpr_base / rpr_nfa regression test files (sql + expected). Two short comment line breaks in createplan.c are reflowed by pgindent as a mechanical consequence of the slightly longer ASCII replacements. Documentation/comment-only change; no functional effect. --- src/backend/executor/execRPR.c | 2 +- src/backend/optimizer/plan/createplan.c | 8 ++--- src/backend/parser/parse_func.c | 2 +- src/test/regress/expected/rpr.out | 30 ++++++++-------- src/test/regress/expected/rpr_base.out | 6 ++-- src/test/regress/expected/rpr_nfa.out | 48 ++++++++++++------------- src/test/regress/sql/rpr.sql | 30 ++++++++-------- src/test/regress/sql/rpr_base.sql | 6 ++-- src/test/regress/sql/rpr_nfa.sql | 48 ++++++++++++------------- 9 files changed, 90 insertions(+), 90 deletions(-) diff --git a/src/backend/executor/execRPR.c b/src/backend/executor/execRPR.c index 84f09093b4b..15e439daaae 100644 --- a/src/backend/executor/execRPR.c +++ b/src/backend/executor/execRPR.c @@ -631,7 +631,7 @@ * with a compound kind (RPR_NAV_PREV_FIRST, etc.). The executor * computes the target position in two steps: first the inner reference * point (match_start + N or currentpos - N) with match-range validation, - * then the outer adjustment (± M) with partition-range validation. + * then the outer adjustment (+/- M) with partition-range validation. * If either step is out of range, the result is NULL. * * nav_slot caches the last fetched position (nav_slot_pos) to avoid diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index d7adf17a242..a1643e40be4 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -2578,8 +2578,8 @@ nav_offset_walker(Node *node, void *ctx) /* * Compound PREV_LAST / NEXT_LAST: base = currentpos. PREV_LAST(v, N, - * M): target = currentpos - N - M → lookback = N + M NEXT_LAST(v, - * N, M): target = currentpos - N + M → lookback = max(N - M, 0) + * M): target = currentpos - N - M -> lookback = N + M NEXT_LAST(v, N, + * M): target = currentpos - N + M -> lookback = max(N - M, 0) */ if (nav->kind == RPR_NAV_PREV_LAST || nav->kind == RPR_NAV_NEXT_LAST) @@ -2614,8 +2614,8 @@ nav_offset_walker(Node *node, void *ctx) /* * Compound PREV_FIRST / NEXT_FIRST: base = match_start. PREV_FIRST(v, * N, M): target = match_start + N - M NEXT_FIRST(v, N, M): target = - * match_start + N + M The combined offset (N±M) from match_start can - * be negative, meaning rows before match_start are needed. + * match_start + N + M The combined offset (N+/-M) from match_start + * can be negative, meaning rows before match_start are needed. */ if (nav->kind == RPR_NAV_PREV_FIRST || nav->kind == RPR_NAV_NEXT_FIRST) diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 07bf11965b8..07eccd6de32 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -787,7 +787,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, return projection; } - /* Not a column projection — report error */ + /* Not a column projection -- report error */ ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("cannot use %s outside a DEFINE clause", diff --git a/src/test/regress/expected/rpr.out b/src/test/regress/expected/rpr.out index 3520c5c5d76..85384f6b096 100644 --- a/src/test/regress/expected/rpr.out +++ b/src/test/regress/expected/rpr.out @@ -1723,9 +1723,9 @@ WINDOW w AS ( CREATE TEMP TABLE rpr_nav (id int, val int); INSERT INTO rpr_nav VALUES (1,10),(2,20),(3,30),(4,10),(5,50),(6,10); -- FIRST(val) = constant: B matches when match_start has val=10 --- match_start=1(10): A=id1, B=id2, FIRST(val)=10 → match {1,2} --- match_start=3(30): A=id3, B=id4, FIRST(val)=30≠10 → no match --- match_start=4(10): A=id4, B=id5, FIRST(val)=10 → match {4,5} +-- match_start=1(10): A=id1, B=id2, FIRST(val)=10 -> match {1,2} +-- match_start=3(30): A=id3, B=id4, FIRST(val)=30!=10 -> no match +-- match_start=4(10): A=id4, B=id5, FIRST(val)=10 -> match {4,5} SELECT id, val, first_value(id) OVER w AS mf, last_value(id) OVER w AS ml FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1767,8 +1767,8 @@ FROM rpr_nav WINDOW w AS ( -- Reluctant A+? with FIRST(val) = LAST(val): find shortest match where -- first and last rows have the same val. -- match_start=1(10): reluctant tries B early: --- id2(20≠10), id3(30≠10), id4(10=10) → match {1,2,3,4} --- match_start=5(50): id6(10≠50) → no match +-- id2(20!=10), id3(30!=10), id4(10=10) -> match {1,2,3,4} +-- match_start=5(50): id6(10!=50) -> no match SELECT id, val, first_value(id) OVER w AS mf, last_value(id) OVER w AS ml FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1790,7 +1790,7 @@ FROM rpr_nav WINDOW w AS ( -- Greedy A+ with FIRST(val) = LAST(val): find longest match where -- first and last rows have the same val. -- match_start=1(10): greedy A eats all, B tries last: --- id6(10=10) → match {1,2,3,4,5,6} +-- id6(10=10) -> match {1,2,3,4,5,6} SELECT id, val, first_value(id) OVER w AS mf, last_value(id) OVER w AS ml FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1851,8 +1851,8 @@ FROM rpr_nav WINDOW w AS ( (6 rows) -- FIRST(val, 1): match_start + 1 row (second row of match) --- match_start=1(10): FIRST(val,1)=20, B needs val=20 → id2(20) match, id3(30) no --- match_start=3(30): FIRST(val,1)=10, B needs val=10 → id4(10) match +-- match_start=1(10): FIRST(val,1)=20, B needs val=20 -> id2(20) match, id3(30) no +-- match_start=3(30): FIRST(val,1)=10, B needs val=10 -> id4(10) match SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1871,7 +1871,7 @@ FROM rpr_nav WINDOW w AS ( 6 | 10 | | 0 (6 rows) --- FIRST(val, 99): offset beyond match range → NULL, no match +-- FIRST(val, 99): offset beyond match range -> NULL, no match SELECT id, val, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1930,7 +1930,7 @@ FROM rpr_nav WINDOW w AS ( 6 | 10 | | 0 (6 rows) --- LAST(val, 99): offset before match_start → NULL +-- LAST(val, 99): offset before match_start -> NULL SELECT id, val, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1991,8 +1991,8 @@ DROP TABLE rpr_names; -- Compound navigation: PREV(FIRST(val), M) -- rpr_nav: (1,10),(2,20),(3,30),(4,10),(5,50),(6,10) -- PREV(FIRST(val), 1): target = match_start + 0 - 1 = match_start - 1 --- At match_start=1: target=0 → out of range → NULL --- At match_start=3: target=2(val=20) → 20 > 0 → true +-- At match_start=1: target=0 -> out of range -> NULL +-- At match_start=3: target=2(val=20) -> 20 > 0 -> true SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -2012,7 +2012,7 @@ FROM rpr_nav WINDOW w AS ( (6 rows) -- NEXT(FIRST(val, 1), 1): target = match_start + 1 + 1 = match_start + 2 --- At match_start=1, B on id2: target=1+1+1=3(val=30), 30>0 → true +-- At match_start=1, B on id2: target=1+1+1=3(val=30), 30>0 -> true SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -2160,7 +2160,7 @@ SELECT id, val, count(*) OVER w FROM rpr_nav WINDOW w AS ( ); ERROR: row pattern navigation offset must not be negative -- Compound: default offsets on both sides --- PREV(FIRST(val)): inner=0 (match_start), outer=1 → target = match_start - 1 +-- PREV(FIRST(val)): inner=0 (match_start), outer=1 -> target = match_start - 1 SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -2179,7 +2179,7 @@ FROM rpr_nav WINDOW w AS ( 6 | 10 | | 0 (6 rows) --- NEXT(LAST(val)): inner=0 (currentpos), outer=1 → target = currentpos + 1 +-- NEXT(LAST(val)): inner=0 (currentpos), outer=1 -> target = currentpos + 1 SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id diff --git a/src/test/regress/expected/rpr_base.out b/src/test/regress/expected/rpr_base.out index 3637a5c8002..a63211ff364 100644 --- a/src/test/regress/expected/rpr_base.out +++ b/src/test/regress/expected/rpr_base.out @@ -3065,7 +3065,7 @@ LINE 6: DEFINE A AS val > 0 ^ -- Expected: Syntax error -- Qualified column references (NOT SUPPORTED) --- Pattern variable qualified name: not supported (valid per §4.16, not yet implemented) +-- Pattern variable qualified name: not supported (valid per SQL standard 4.16, not yet implemented) SELECT COUNT(*) OVER w FROM rpr_err WINDOW w AS ( @@ -3104,7 +3104,7 @@ ERROR: DEFINE variable "b" is not used in PATTERN LINE 7: DEFINE A AS val > 0, B AS B.val > 0 ^ -- Expected: ERROR: pattern variable qualified column reference "b.val" is not supported --- FROM-clause range variable qualified name: not allowed (prohibited by §6.5) +-- FROM-clause range variable qualified name: not allowed (prohibited by SQL standard 6.5) SELECT COUNT(*) OVER w FROM rpr_err WINDOW w AS ( @@ -5821,7 +5821,7 @@ CREATE TABLE rpr_sort (id INT, category VARCHAR(10), val INT); INSERT INTO rpr_sort VALUES (1, 'A', 30), (2, 'B', 20), (3, 'A', 10), (4, 'B', 40), (5, 'A', 50), (6, 'B', 60); --- RPR with GROUP BY (aggregate in DEFINE → ERROR before GROUP BY interaction) +-- RPR with GROUP BY (aggregate in DEFINE -> ERROR before GROUP BY interaction) -- Expected: ERROR: aggregate functions are not allowed in DEFINE SELECT category, COUNT(*) as group_cnt, diff --git a/src/test/regress/expected/rpr_nfa.out b/src/test/regress/expected/rpr_nfa.out index 250f7f131b1..a19b26c3b94 100644 --- a/src/test/regress/expected/rpr_nfa.out +++ b/src/test/regress/expected/rpr_nfa.out @@ -1151,7 +1151,7 @@ WINDOW w AS ( -- Optional reluctant group: (A B)?? C -- nfa_advance_begin: reluctant tries skip first, but skip path needs C --- at row 1 which is A → skip fails. Enter path succeeds: A(1) B(2) C(3). +-- at row 1 which is A -> skip fails. Enter path succeeds: A(1) B(2) C(3). WITH test_optional_reluctant AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -2961,8 +2961,8 @@ WINDOW w AS ( 9 | {_} | | (9 rows) --- Nested END→END max reached --- Inner group (A B){2} reaches max=2 → exits to outer END +-- Nested END->END max reached +-- Inner group (A B){2} reaches max=2 -> exits to outer END WITH test_end_nested_max AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -3002,8 +3002,8 @@ WINDOW w AS ( 9 | {_} | | (9 rows) --- Nested END→END between min/max --- Inner group (A B){1,3} exits between min/max → outer END count++ +-- Nested END->END between min/max +-- Inner group (A B){1,3} exits between min/max -> outer END count++ WITH test_end_nested_mid AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -3884,9 +3884,9 @@ WINDOW w AS ( -- Coverage failure: older can't cover newer's states -- Pattern A+ | B+ with SKIP PAST LAST ROW. --- Row 1: only A → Ctx1 takes A branch only (B fails). --- Row 2: A and B → Ctx2 takes both branches. --- Absorption: Ctx1 has A but no B → can't cover Ctx2's B state → fails. +-- Row 1: only A -> Ctx1 takes A branch only (B fails). +-- Row 2: A and B -> Ctx2 takes both branches. +-- Absorption: Ctx1 has A but no B -> can't cover Ctx2's B state -> fails. WITH test_coverage_fail AS ( SELECT * FROM (VALUES (1, ARRAY['A', '_']), @@ -3920,8 +3920,8 @@ WINDOW w AS ( -- Absorb skips completed context (older->states==NULL) -- Pattern A+ | B+ with SKIP PAST LAST ROW. --- Row 1: A only → Ctx1 takes A branch. Row 2: B only → Ctx1 A fails (completed). --- Ctx2 takes B branch. Absorption: Ctx1 states==NULL → skip. +-- Row 1: A only -> Ctx1 takes A branch. Row 2: B only -> Ctx1 A fails (completed). +-- Ctx2 takes B branch. Absorption: Ctx1 states==NULL -> skip. WITH test_older_completed AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -3953,9 +3953,9 @@ WINDOW w AS ( -- Absorb skips non-absorbable context (!hasAbsorbableState) -- Pattern A+ | B C with SKIP PAST LAST ROW (only A+ branch absorbable). --- Row 1: B only → Ctx1 takes B branch (non-absorbable), advances to C. --- Row 2: C,A → Ctx1 C matches (hasAbsorbableState=false). Ctx2 takes A (absorbable). --- Absorption: Ctx1 !hasAbsorbableState → skip. +-- Row 1: B only -> Ctx1 takes B branch (non-absorbable), advances to C. +-- Row 2: C,A -> Ctx1 C matches (hasAbsorbableState=false). Ctx2 takes A (absorbable). +-- Absorption: Ctx1 !hasAbsorbableState -> skip. WITH test_older_non_absorbable AS ( SELECT * FROM (VALUES (1, ARRAY['B', '_']), @@ -4397,7 +4397,7 @@ WINDOW w AS ( -- (A?){0,3}: min=0, nullable inner. -- A never matches. A? matches empty, min=0 satisfied immediately. -- Per standard: empty match expected for every row. --- XXX: visited bitmap blocks empty iteration → no match (same as {2,3}) +-- XXX: visited bitmap blocks empty iteration -> no match (same as {2,3}) WITH test_728_min0 AS ( SELECT * FROM (VALUES (1, ARRAY['B']), @@ -4427,7 +4427,7 @@ WINDOW w AS ( -- (A?){1,3}: min=1, nullable inner. -- A never matches. Need 1 empty iteration to satisfy min=1. -- Per standard: empty match expected for every row. --- XXX: visited bitmap blocks empty iteration → no match (same as {2,3}) +-- XXX: visited bitmap blocks empty iteration -> no match (same as {2,3}) WITH test_728_min1 AS ( SELECT * FROM (VALUES (1, ARRAY['B']), @@ -4458,7 +4458,7 @@ WINDOW w AS ( -- A never matches. Need 2 empty iterations to satisfy min=2. -- Per standard: STR06=(STRE STRE) is valid for min=2. -- Expected: empty match for every row --- XXX: visited bitmap blocks second empty iteration → match failure +-- XXX: visited bitmap blocks second empty iteration -> match failure WITH test_728_min2 AS ( SELECT * FROM (VALUES (1, ARRAY['B']), @@ -4486,10 +4486,10 @@ WINDOW w AS ( (3 rows) -- (A?){2,3} mixed: some rows match A, some don't --- Rows 1-2: A matches, greedy takes 2 → min satisfied +-- Rows 1-2: A matches, greedy takes 2 -> min satisfied -- Row 3: A doesn't match, needs 2 empty iterations for min=2 -- XXX: Row 3 fails due to visited bitmap (same as pure empty {2,3}) --- Row 4: A matches 1 real iter + 1 ff empty exit → match 4-4 +-- Row 4: A matches 1 real iter + 1 ff empty exit -> match 4-4 WITH test_728_min2_mixed AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -4524,8 +4524,8 @@ WINDOW w AS ( -- fires as a parallel exit path (EXIT ONLY, no greedy/reluctant loop). -- Data: alternating A, B rows (6 rows) -- Greedy: each row gets the longest match from its starting position. --- Row 1: 3 iters (A@1,B@2)(A@3,B@4)(A@5,B@6) → 1-6 --- Row 5: 1 real iter + 1 ff empty exit → 5-6 +-- Row 1: 3 iters (A@1,B@2)(A@3,B@4)(A@5,B@6) -> 1-6 +-- Row 5: 1 real iter + 1 ff empty exit -> 5-6 WITH test_728_multi_body AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -4590,9 +4590,9 @@ WINDOW w AS ( (3 rows) -- (A? B?){2,3}: mixed real and empty iterations --- Row 1: iter1 real (A@1,B@2), iter2 at row 3 empty → ff exit, match 1-2 --- Row 3: C doesn't match A or B → NULL --- Row 4: iter1 real (A@4,B@5), iter2 at end empty → ff exit, match 4-5 +-- Row 1: iter1 real (A@1,B@2), iter2 at row 3 empty -> ff exit, match 1-2 +-- Row 3: C doesn't match A or B -> NULL +-- Row 4: iter1 real (A@4,B@5), iter2 at end empty -> ff exit, match 4-5 WITH test_728_multi_mixed AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -4629,7 +4629,7 @@ WINDOW w AS ( -- ------------------------------------------------------------ -- Standard's worked example: A? B+ with specific data -- Preferment order: (A)(BBB), (A)(BB), (A)(B), ()(BBB), ()(BB), ()(B) --- Row 1: A condition (price>100) is false → A fails +-- Row 1: A condition (price>100) is false -> A fails -- Backtrack: empty A?, then B+ from row 1 -- Expected: rows 1-3 match as B (A? takes empty match) WITH test_73_example AS ( diff --git a/src/test/regress/sql/rpr.sql b/src/test/regress/sql/rpr.sql index 724d460b2da..5563e062cde 100644 --- a/src/test/regress/sql/rpr.sql +++ b/src/test/regress/sql/rpr.sql @@ -820,9 +820,9 @@ CREATE TEMP TABLE rpr_nav (id int, val int); INSERT INTO rpr_nav VALUES (1,10),(2,20),(3,30),(4,10),(5,50),(6,10); -- FIRST(val) = constant: B matches when match_start has val=10 --- match_start=1(10): A=id1, B=id2, FIRST(val)=10 → match {1,2} --- match_start=3(30): A=id3, B=id4, FIRST(val)=30≠10 → no match --- match_start=4(10): A=id4, B=id5, FIRST(val)=10 → match {4,5} +-- match_start=1(10): A=id1, B=id2, FIRST(val)=10 -> match {1,2} +-- match_start=3(30): A=id3, B=id4, FIRST(val)=30!=10 -> no match +-- match_start=4(10): A=id4, B=id5, FIRST(val)=10 -> match {4,5} SELECT id, val, first_value(id) OVER w AS mf, last_value(id) OVER w AS ml FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -846,8 +846,8 @@ FROM rpr_nav WINDOW w AS ( -- Reluctant A+? with FIRST(val) = LAST(val): find shortest match where -- first and last rows have the same val. -- match_start=1(10): reluctant tries B early: --- id2(20≠10), id3(30≠10), id4(10=10) → match {1,2,3,4} --- match_start=5(50): id6(10≠50) → no match +-- id2(20!=10), id3(30!=10), id4(10=10) -> match {1,2,3,4} +-- match_start=5(50): id6(10!=50) -> no match SELECT id, val, first_value(id) OVER w AS mf, last_value(id) OVER w AS ml FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -860,7 +860,7 @@ FROM rpr_nav WINDOW w AS ( -- Greedy A+ with FIRST(val) = LAST(val): find longest match where -- first and last rows have the same val. -- match_start=1(10): greedy A eats all, B tries last: --- id6(10=10) → match {1,2,3,4,5,6} +-- id6(10=10) -> match {1,2,3,4,5,6} SELECT id, val, first_value(id) OVER w AS mf, last_value(id) OVER w AS ml FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -894,8 +894,8 @@ FROM rpr_nav WINDOW w AS ( ); -- FIRST(val, 1): match_start + 1 row (second row of match) --- match_start=1(10): FIRST(val,1)=20, B needs val=20 → id2(20) match, id3(30) no --- match_start=3(30): FIRST(val,1)=10, B needs val=10 → id4(10) match +-- match_start=1(10): FIRST(val,1)=20, B needs val=20 -> id2(20) match, id3(30) no +-- match_start=3(30): FIRST(val,1)=10, B needs val=10 -> id4(10) match SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -905,7 +905,7 @@ FROM rpr_nav WINDOW w AS ( DEFINE A AS TRUE, B AS val = FIRST(val, 1) ); --- FIRST(val, 99): offset beyond match range → NULL, no match +-- FIRST(val, 99): offset beyond match range -> NULL, no match SELECT id, val, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -937,7 +937,7 @@ FROM rpr_nav WINDOW w AS ( DEFINE A AS TRUE, B AS LAST(val, 1) < 30 ); --- LAST(val, 99): offset before match_start → NULL +-- LAST(val, 99): offset before match_start -> NULL SELECT id, val, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -977,8 +977,8 @@ DROP TABLE rpr_names; -- Compound navigation: PREV(FIRST(val), M) -- rpr_nav: (1,10),(2,20),(3,30),(4,10),(5,50),(6,10) -- PREV(FIRST(val), 1): target = match_start + 0 - 1 = match_start - 1 --- At match_start=1: target=0 → out of range → NULL --- At match_start=3: target=2(val=20) → 20 > 0 → true +-- At match_start=1: target=0 -> out of range -> NULL +-- At match_start=3: target=2(val=20) -> 20 > 0 -> true SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -989,7 +989,7 @@ FROM rpr_nav WINDOW w AS ( ); -- NEXT(FIRST(val, 1), 1): target = match_start + 1 + 1 = match_start + 2 --- At match_start=1, B on id2: target=1+1+1=3(val=30), 30>0 → true +-- At match_start=1, B on id2: target=1+1+1=3(val=30), 30>0 -> true SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1074,7 +1074,7 @@ SELECT id, val, count(*) OVER w FROM rpr_nav WINDOW w AS ( ); -- Compound: default offsets on both sides --- PREV(FIRST(val)): inner=0 (match_start), outer=1 → target = match_start - 1 +-- PREV(FIRST(val)): inner=0 (match_start), outer=1 -> target = match_start - 1 SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id @@ -1084,7 +1084,7 @@ FROM rpr_nav WINDOW w AS ( DEFINE A AS TRUE, B AS PREV(FIRST(val)) IS NOT NULL ); --- NEXT(LAST(val)): inner=0 (currentpos), outer=1 → target = currentpos + 1 +-- NEXT(LAST(val)): inner=0 (currentpos), outer=1 -> target = currentpos + 1 SELECT id, val, first_value(id) OVER w AS mf, count(*) OVER w AS cnt FROM rpr_nav WINDOW w AS ( ORDER BY id diff --git a/src/test/regress/sql/rpr_base.sql b/src/test/regress/sql/rpr_base.sql index 90b1ae96a0e..86ed06fec68 100644 --- a/src/test/regress/sql/rpr_base.sql +++ b/src/test/regress/sql/rpr_base.sql @@ -2083,7 +2083,7 @@ WINDOW w AS ( -- Qualified column references (NOT SUPPORTED) --- Pattern variable qualified name: not supported (valid per §4.16, not yet implemented) +-- Pattern variable qualified name: not supported (valid per SQL standard 4.16, not yet implemented) SELECT COUNT(*) OVER w FROM rpr_err WINDOW w AS ( @@ -2116,7 +2116,7 @@ WINDOW w AS ( ); -- Expected: ERROR: pattern variable qualified column reference "b.val" is not supported --- FROM-clause range variable qualified name: not allowed (prohibited by §6.5) +-- FROM-clause range variable qualified name: not allowed (prohibited by SQL standard 6.5) SELECT COUNT(*) OVER w FROM rpr_err WINDOW w AS ( @@ -3611,7 +3611,7 @@ INSERT INTO rpr_sort VALUES (1, 'A', 30), (2, 'B', 20), (3, 'A', 10), (4, 'B', 40), (5, 'A', 50), (6, 'B', 60); --- RPR with GROUP BY (aggregate in DEFINE → ERROR before GROUP BY interaction) +-- RPR with GROUP BY (aggregate in DEFINE -> ERROR before GROUP BY interaction) -- Expected: ERROR: aggregate functions are not allowed in DEFINE SELECT category, diff --git a/src/test/regress/sql/rpr_nfa.sql b/src/test/regress/sql/rpr_nfa.sql index aaa7b44f789..1d27e0dc09e 100644 --- a/src/test/regress/sql/rpr_nfa.sql +++ b/src/test/regress/sql/rpr_nfa.sql @@ -806,7 +806,7 @@ WINDOW w AS ( -- Optional reluctant group: (A B)?? C -- nfa_advance_begin: reluctant tries skip first, but skip path needs C --- at row 1 which is A → skip fails. Enter path succeeds: A(1) B(2) C(3). +-- at row 1 which is A -> skip fails. Enter path succeeds: A(1) B(2) C(3). WITH test_optional_reluctant AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -2102,8 +2102,8 @@ WINDOW w AS ( D AS 'D' = ANY(flags) ); --- Nested END→END max reached --- Inner group (A B){2} reaches max=2 → exits to outer END +-- Nested END->END max reached +-- Inner group (A B){2} reaches max=2 -> exits to outer END WITH test_end_nested_max AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -2131,8 +2131,8 @@ WINDOW w AS ( B AS 'B' = ANY(flags) ); --- Nested END→END between min/max --- Inner group (A B){1,3} exits between min/max → outer END count++ +-- Nested END->END between min/max +-- Inner group (A B){1,3} exits between min/max -> outer END count++ WITH test_end_nested_mid AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -2820,9 +2820,9 @@ WINDOW w AS ( -- Coverage failure: older can't cover newer's states -- Pattern A+ | B+ with SKIP PAST LAST ROW. --- Row 1: only A → Ctx1 takes A branch only (B fails). --- Row 2: A and B → Ctx2 takes both branches. --- Absorption: Ctx1 has A but no B → can't cover Ctx2's B state → fails. +-- Row 1: only A -> Ctx1 takes A branch only (B fails). +-- Row 2: A and B -> Ctx2 takes both branches. +-- Absorption: Ctx1 has A but no B -> can't cover Ctx2's B state -> fails. WITH test_coverage_fail AS ( SELECT * FROM (VALUES (1, ARRAY['A', '_']), @@ -2848,8 +2848,8 @@ WINDOW w AS ( -- Absorb skips completed context (older->states==NULL) -- Pattern A+ | B+ with SKIP PAST LAST ROW. --- Row 1: A only → Ctx1 takes A branch. Row 2: B only → Ctx1 A fails (completed). --- Ctx2 takes B branch. Absorption: Ctx1 states==NULL → skip. +-- Row 1: A only -> Ctx1 takes A branch. Row 2: B only -> Ctx1 A fails (completed). +-- Ctx2 takes B branch. Absorption: Ctx1 states==NULL -> skip. WITH test_older_completed AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -2874,9 +2874,9 @@ WINDOW w AS ( -- Absorb skips non-absorbable context (!hasAbsorbableState) -- Pattern A+ | B C with SKIP PAST LAST ROW (only A+ branch absorbable). --- Row 1: B only → Ctx1 takes B branch (non-absorbable), advances to C. --- Row 2: C,A → Ctx1 C matches (hasAbsorbableState=false). Ctx2 takes A (absorbable). --- Absorption: Ctx1 !hasAbsorbableState → skip. +-- Row 1: B only -> Ctx1 takes B branch (non-absorbable), advances to C. +-- Row 2: C,A -> Ctx1 C matches (hasAbsorbableState=false). Ctx2 takes A (absorbable). +-- Absorption: Ctx1 !hasAbsorbableState -> skip. WITH test_older_non_absorbable AS ( SELECT * FROM (VALUES (1, ARRAY['B', '_']), @@ -3236,7 +3236,7 @@ WINDOW w AS ( -- (A?){0,3}: min=0, nullable inner. -- A never matches. A? matches empty, min=0 satisfied immediately. -- Per standard: empty match expected for every row. --- XXX: visited bitmap blocks empty iteration → no match (same as {2,3}) +-- XXX: visited bitmap blocks empty iteration -> no match (same as {2,3}) WITH test_728_min0 AS ( SELECT * FROM (VALUES (1, ARRAY['B']), @@ -3260,7 +3260,7 @@ WINDOW w AS ( -- (A?){1,3}: min=1, nullable inner. -- A never matches. Need 1 empty iteration to satisfy min=1. -- Per standard: empty match expected for every row. --- XXX: visited bitmap blocks empty iteration → no match (same as {2,3}) +-- XXX: visited bitmap blocks empty iteration -> no match (same as {2,3}) WITH test_728_min1 AS ( SELECT * FROM (VALUES (1, ARRAY['B']), @@ -3285,7 +3285,7 @@ WINDOW w AS ( -- A never matches. Need 2 empty iterations to satisfy min=2. -- Per standard: STR06=(STRE STRE) is valid for min=2. -- Expected: empty match for every row --- XXX: visited bitmap blocks second empty iteration → match failure +-- XXX: visited bitmap blocks second empty iteration -> match failure WITH test_728_min2 AS ( SELECT * FROM (VALUES (1, ARRAY['B']), @@ -3307,10 +3307,10 @@ WINDOW w AS ( ); -- (A?){2,3} mixed: some rows match A, some don't --- Rows 1-2: A matches, greedy takes 2 → min satisfied +-- Rows 1-2: A matches, greedy takes 2 -> min satisfied -- Row 3: A doesn't match, needs 2 empty iterations for min=2 -- XXX: Row 3 fails due to visited bitmap (same as pure empty {2,3}) --- Row 4: A matches 1 real iter + 1 ff empty exit → match 4-4 +-- Row 4: A matches 1 real iter + 1 ff empty exit -> match 4-4 WITH test_728_min2_mixed AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -3338,8 +3338,8 @@ WINDOW w AS ( -- fires as a parallel exit path (EXIT ONLY, no greedy/reluctant loop). -- Data: alternating A, B rows (6 rows) -- Greedy: each row gets the longest match from its starting position. --- Row 1: 3 iters (A@1,B@2)(A@3,B@4)(A@5,B@6) → 1-6 --- Row 5: 1 real iter + 1 ff empty exit → 5-6 +-- Row 1: 3 iters (A@1,B@2)(A@3,B@4)(A@5,B@6) -> 1-6 +-- Row 5: 1 real iter + 1 ff empty exit -> 5-6 WITH test_728_multi_body AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -3389,9 +3389,9 @@ WINDOW w AS ( ); -- (A? B?){2,3}: mixed real and empty iterations --- Row 1: iter1 real (A@1,B@2), iter2 at row 3 empty → ff exit, match 1-2 --- Row 3: C doesn't match A or B → NULL --- Row 4: iter1 real (A@4,B@5), iter2 at end empty → ff exit, match 4-5 +-- Row 1: iter1 real (A@1,B@2), iter2 at row 3 empty -> ff exit, match 1-2 +-- Row 3: C doesn't match A or B -> NULL +-- Row 4: iter1 real (A@4,B@5), iter2 at end empty -> ff exit, match 4-5 WITH test_728_multi_mixed AS ( SELECT * FROM (VALUES (1, ARRAY['A']), @@ -3421,7 +3421,7 @@ WINDOW w AS ( -- Standard's worked example: A? B+ with specific data -- Preferment order: (A)(BBB), (A)(BB), (A)(B), ()(BBB), ()(BB), ()(B) --- Row 1: A condition (price>100) is false → A fails +-- Row 1: A condition (price>100) is false -> A fails -- Backtrack: empty A?, then B+ from row 1 -- Expected: rows 1-3 match as B (A? takes empty match) WITH test_73_example AS ( -- 2.50.1 (Apple Git-155)