From c52d372680f7cad2c72f72939ace896c09fe3d25 Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Mon, 8 Jun 2026 19:02:12 +0800
Subject: [PATCH v47 2/4] v47 rpr regress tests refactoring

regress tests comments mentioning some static function seems not a  good thing,
if these static function deleted or renamed, these test comments also need to change.
---
 src/test/regress/expected/rpr_base.out    | 18 ++----------------
 src/test/regress/expected/rpr_explain.out |  4 ++--
 src/test/regress/expected/rpr_nfa.out     |  1 -
 src/test/regress/sql/rpr_base.sql         | 18 ++----------------
 src/test/regress/sql/rpr_explain.sql      |  4 ++--
 src/test/regress/sql/rpr_nfa.sql          |  1 -
 6 files changed, 8 insertions(+), 38 deletions(-)

diff --git a/src/test/regress/expected/rpr_base.out b/src/test/regress/expected/rpr_base.out
index 43683c79e3..099ed6e644 100644
--- a/src/test/regress/expected/rpr_base.out
+++ b/src/test/regress/expected/rpr_base.out
@@ -3739,7 +3739,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Consecutive VAR merge: A A+ -> a{2,}
--- Exercises the child->max == RPR_QUANTITY_INF branch in mergeConsecutiveVars,
 -- where a finite prev (A{1,1}) meets an infinite child (A+).
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
@@ -3808,8 +3807,7 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Consecutive GROUP merge: (A B){2} (A B)+ -> (a b){3,}
--- Exercises the child->max == RPR_QUANTITY_INF branch in mergeConsecutiveGroups,
--- where a finite prev ((A B){2,2}) meets an infinite child ((A B)+).
+-- Where a finite prev ((A B){2,2}) meets an infinite child ((A B)+).
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4366,7 +4364,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Consecutive GROUP merge with unbounded: (A+) (A+) -> a{2,}
--- Tests mergeConsecutiveGroups with child->max == INF
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4383,7 +4380,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Consecutive GROUP merge finite: (A{10}){20} -> a{200}
--- Tests mergeConsecutiveGroups with both finite
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4400,7 +4396,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Different GROUP prevents merge: (A B){2} (C D){3}
--- Tests mergeConsecutiveGroups flush previous
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4419,7 +4414,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Different children count prevents merge: (A B)+ (A B C)+
--- Tests rprPatternChildrenEqual length check
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4437,7 +4431,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- PREFIX only merge: A B (A B)+ -> (a b){2,}
--- Tests mergeGroupPrefixSuffix: absorb preceding elements into GROUP min
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4454,7 +4447,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- SUFFIX only merge: (A B)+ A B -> (a b){2,}
--- Tests mergeGroupPrefixSuffix: absorb following elements into GROUP min
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4471,7 +4463,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Multiple SUFFIX absorption with skipUntil: (A B)+ A B A B C
--- Tests mergeGroupPrefixSuffix: skip absorbed suffix elements
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4488,8 +4479,7 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
          ->  Seq Scan on rpr_plan
 (7 rows)
 
--- PREFIX merge with remaining prefix: A B C D (C D)+
--- Tests mergeGroupPrefixSuffix: trimmed list reconstruction
+-- PREFIX merge with remaining prefix: A B C D (C D)+  -> A B (C D) {2,}
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4508,7 +4498,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- PREFIX merge with quantifiers: A B* (A B*)+ -> (a b*){2,}
--- Tests mergeGroupPrefixSuffix: quantifier comparison in rprPatternEqual
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4526,7 +4515,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- PREFIX merge with multiple quantifiers: A+ B* C? (A+ B* C?)+ -> (a+ b* c?){2,}
--- Tests mergeGroupPrefixSuffix: complex quantifier patterns
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4544,7 +4532,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- SUFFIX merge with quantifiers: (A B*)+ A B* -> (a b*){2,}
--- Tests mergeGroupPrefixSuffix: suffix with quantifiers
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -4562,7 +4549,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
 (7 rows)
 
 -- Unwrap GROUP{1,1}: ((A | B | C)) -> (a | b | c)
--- Tests tryUnwrapGroup removing redundant outer GROUP
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
diff --git a/src/test/regress/expected/rpr_explain.out b/src/test/regress/expected/rpr_explain.out
index bcbf4f941b..cc86d0aae3 100644
--- a/src/test/regress/expected/rpr_explain.out
+++ b/src/test/regress/expected/rpr_explain.out
@@ -541,7 +541,7 @@ WINDOW w AS (
 (10 rows)
 
 -- Consecutive ALT merge followed by different ALT
--- Tests mergeConsecutiveAlts flush on ALT change: (A|B){2} (C|D)
+-- ((A | B) (A | B) (C | D)) -> (A|B){2} (C|D)
 CREATE VIEW rpr_ev_state_alt_merge_alt AS
 SELECT count(*) OVER w
 FROM generate_series(1, 40) AS s(v)
@@ -582,7 +582,7 @@ WINDOW w AS (
 (10 rows)
 
 -- Consecutive ALT merge followed by non-ALT element
--- Tests mergeConsecutiveAlts flush on non-ALT: (A|B){2} c
+-- ((A | B) (A | B) C) -> (A|B){2} C
 CREATE VIEW rpr_ev_state_alt_merge_nonalt AS
 SELECT count(*) OVER w
 FROM generate_series(1, 40) AS s(v)
diff --git a/src/test/regress/expected/rpr_nfa.out b/src/test/regress/expected/rpr_nfa.out
index d7146168f2..2ae8549079 100644
--- a/src/test/regress/expected/rpr_nfa.out
+++ b/src/test/regress/expected/rpr_nfa.out
@@ -534,7 +534,6 @@ WINDOW w AS (
 (11 rows)
 
 -- Consecutive vars merged to fixed-length: (A B B)+ -> (A B{2})+
--- mergeConsecutiveVars produces B{2}; now absorbable with fixed-length check
 WITH test_absorb_consecutive AS (
     SELECT * FROM (VALUES
         (1,  ARRAY['A']),
diff --git a/src/test/regress/sql/rpr_base.sql b/src/test/regress/sql/rpr_base.sql
index 5e95859f75..e324d77da6 100644
--- a/src/test/regress/sql/rpr_base.sql
+++ b/src/test/regress/sql/rpr_base.sql
@@ -2471,7 +2471,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN (A+ A*) DEFINE A AS val > 0);
 
 -- Consecutive VAR merge: A A+ -> a{2,}
--- Exercises the child->max == RPR_QUANTITY_INF branch in mergeConsecutiveVars,
 -- where a finite prev (A{1,1}) meets an infinite child (A+).
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
@@ -2500,8 +2499,7 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN ((A B)+ (A B)+) DEFINE A AS val <= 50, B AS val > 50);
 
 -- Consecutive GROUP merge: (A B){2} (A B)+ -> (a b){3,}
--- Exercises the child->max == RPR_QUANTITY_INF branch in mergeConsecutiveGroups,
--- where a finite prev ((A B){2,2}) meets an infinite child ((A B)+).
+-- Where a finite prev ((A B){2,2}) meets an infinite child ((A B)+).
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2722,21 +2720,18 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              DEFINE A AS val <= 20, B AS val > 20 AND val <= 70, C AS val > 70);
 
 -- Consecutive GROUP merge with unbounded: (A+) (A+) -> a{2,}
--- Tests mergeConsecutiveGroups with child->max == INF
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN ((A+) (A+)) DEFINE A AS val > 0);
 
 -- Consecutive GROUP merge finite: (A{10}){20} -> a{200}
--- Tests mergeConsecutiveGroups with both finite
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN ((A{10}){20}) DEFINE A AS val > 0);
 
 -- Different GROUP prevents merge: (A B){2} (C D){3}
--- Tests mergeConsecutiveGroups flush previous
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2745,7 +2740,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
                     C AS val > 50 AND val <= 75, D AS val > 75);
 
 -- Different children count prevents merge: (A B)+ (A B C)+
--- Tests rprPatternChildrenEqual length check
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2753,29 +2747,25 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              DEFINE A AS val <= 33, B AS val > 33 AND val <= 66, C AS val > 66);
 
 -- PREFIX only merge: A B (A B)+ -> (a b){2,}
--- Tests mergeGroupPrefixSuffix: absorb preceding elements into GROUP min
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN (A B (A B)+) DEFINE A AS val <= 50, B AS val > 50);
 
 -- SUFFIX only merge: (A B)+ A B -> (a b){2,}
--- Tests mergeGroupPrefixSuffix: absorb following elements into GROUP min
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN ((A B)+ A B) DEFINE A AS val <= 50, B AS val > 50);
 
 -- Multiple SUFFIX absorption with skipUntil: (A B)+ A B A B C
--- Tests mergeGroupPrefixSuffix: skip absorbed suffix elements
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              PATTERN ((A B)+ A B A B C)
              DEFINE A AS val <= 50, B AS val > 50 AND val <= 75, C AS val > 75);
 
--- PREFIX merge with remaining prefix: A B C D (C D)+
--- Tests mergeGroupPrefixSuffix: trimmed list reconstruction
+-- PREFIX merge with remaining prefix: A B C D (C D)+  -> A B (C D) {2,}
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2784,7 +2774,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
                     C AS val > 50 AND val <= 75, D AS val > 75);
 
 -- PREFIX merge with quantifiers: A B* (A B*)+ -> (a b*){2,}
--- Tests mergeGroupPrefixSuffix: quantifier comparison in rprPatternEqual
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2792,7 +2781,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              DEFINE A AS val <= 50, B AS val > 50);
 
 -- PREFIX merge with multiple quantifiers: A+ B* C? (A+ B* C?)+ -> (a+ b* c?){2,}
--- Tests mergeGroupPrefixSuffix: complex quantifier patterns
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2800,7 +2788,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              DEFINE A AS val <= 30, B AS val > 30 AND val <= 60, C AS val > 60);
 
 -- SUFFIX merge with quantifiers: (A B*)+ A B* -> (a b*){2,}
--- Tests mergeGroupPrefixSuffix: suffix with quantifiers
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
@@ -2808,7 +2795,6 @@ WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
              DEFINE A AS val <= 50, B AS val > 50);
 
 -- Unwrap GROUP{1,1}: ((A | B | C)) -> (a | b | c)
--- Tests tryUnwrapGroup removing redundant outer GROUP
 EXPLAIN (COSTS OFF)
 SELECT COUNT(*) OVER w FROM rpr_plan
 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
diff --git a/src/test/regress/sql/rpr_explain.sql b/src/test/regress/sql/rpr_explain.sql
index aa78ffed26..297ca78d54 100644
--- a/src/test/regress/sql/rpr_explain.sql
+++ b/src/test/regress/sql/rpr_explain.sql
@@ -365,7 +365,7 @@ WINDOW w AS (
 );');
 
 -- Consecutive ALT merge followed by different ALT
--- Tests mergeConsecutiveAlts flush on ALT change: (A|B){2} (C|D)
+-- ((A | B) (A | B) (C | D)) -> (A|B){2} (C|D)
 CREATE VIEW rpr_ev_state_alt_merge_alt AS
 SELECT count(*) OVER w
 FROM generate_series(1, 40) AS s(v)
@@ -388,7 +388,7 @@ WINDOW w AS (
 );');
 
 -- Consecutive ALT merge followed by non-ALT element
--- Tests mergeConsecutiveAlts flush on non-ALT: (A|B){2} c
+-- ((A | B) (A | B) C) -> (A|B){2} C
 CREATE VIEW rpr_ev_state_alt_merge_nonalt AS
 SELECT count(*) OVER w
 FROM generate_series(1, 40) AS s(v)
diff --git a/src/test/regress/sql/rpr_nfa.sql b/src/test/regress/sql/rpr_nfa.sql
index 8daa0a7372..a9d0078584 100644
--- a/src/test/regress/sql/rpr_nfa.sql
+++ b/src/test/regress/sql/rpr_nfa.sql
@@ -408,7 +408,6 @@ WINDOW w AS (
 );
 
 -- Consecutive vars merged to fixed-length: (A B B)+ -> (A B{2})+
--- mergeConsecutiveVars produces B{2}; now absorbable with fixed-length check
 WITH test_absorb_consecutive AS (
     SELECT * FROM (VALUES
         (1,  ARRAY['A']),
-- 
2.34.1

