From 4817be41a812df933f0a461609c6d38f35179aa4 Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Mon, 1 Jun 2026 12:08:50 +0900 Subject: [PATCH 31/68] Rename the AST-level prefix/suffix rewrite from "absorption" to "merging" "absorption" now refers only to the runtime context-equivalence collapse. The Phase-1 AST rewrite in mergeGroupPrefixSuffix is renamed "prefix/suffix merging" to match the sibling "consecutive variable / group / ALT merging" rewrites. Per the naming discussion with Tatsuo Ishii. --- src/backend/executor/README.rpr | 2 +- src/backend/optimizer/plan/rpr.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/backend/executor/README.rpr b/src/backend/executor/README.rpr index 26c1a1ea236..449bf051153 100644 --- a/src/backend/executor/README.rpr +++ b/src/backend/executor/README.rpr @@ -221,7 +221,7 @@ applied: (d) Consecutive ALT merging: Merge repeated identical ALT nodes (A | B) (A | B) (A | B) -> (A | B){3} - (e) Prefix/suffix absorption: Absorb identical sequences before/after + (e) Prefix/suffix merging: Merge identical sequences before/after a group A B (A B)+ -> (A B){2,INF} diff --git a/src/backend/optimizer/plan/rpr.c b/src/backend/optimizer/plan/rpr.c index c65681463b3..2a1d665c7ee 100644 --- a/src/backend/optimizer/plan/rpr.c +++ b/src/backend/optimizer/plan/rpr.c @@ -480,7 +480,7 @@ mergeConsecutiveAlts(List *children) * Merge sequence prefix/suffix into GROUP with matching children. * * When a GROUP's children appear as a prefix before and/or suffix after - * the GROUP in a SEQ, absorb them by incrementing the GROUP's quantifier. + * the GROUP in a SEQ, merge them by incrementing the GROUP's quantifier. * This runs iteratively: A B A B (A B)+ A B -> (A B){5,}. * * Algorithm: @@ -503,15 +503,15 @@ mergeGroupPrefixSuffix(List *children) List *result = NIL; int numChildren = list_length(children); int i; - int skipUntil = -1; /* skip suffix elements already absorbed */ + int skipUntil = -1; /* skip suffix elements already merged */ for (i = 0; i < numChildren; i++) { RPRPatternNode *child = (RPRPatternNode *) list_nth(children, i); /* - * The suffix absorption logic below adjusts i to skip absorbed - * elements, ensuring we never revisit them. Verify this invariant. + * The suffix merge logic below adjusts i to skip merged elements, + * ensuring we never revisit them. Verify this invariant. */ Assert(i >= skipUntil); @@ -543,7 +543,7 @@ mergeGroupPrefixSuffix(List *children) groupChildCount = list_length(groupContent); /* - * PREFIX MERGE: Check if preceding elements match. Keep absorbing + * PREFIX MERGE: Check if preceding elements match. Keep merging * as long as we have matching prefixes. */ while (prefixLen >= groupChildCount && groupChildCount > 0) @@ -592,7 +592,7 @@ mergeGroupPrefixSuffix(List *children) } /* - * SUFFIX MERGE: Check if following elements match. Keep absorbing + * SUFFIX MERGE: Check if following elements match. Keep merging * as long as we have matching suffixes. */ while (i + groupChildCount < numChildren && groupChildCount > 0) @@ -623,7 +623,7 @@ mergeGroupPrefixSuffix(List *children) child->max < RPR_QUANTITY_INF - 1)) { /* - * Match! Absorb suffix by incrementing quantifier and + * Match! Merge suffix by incrementing quantifier and * skipping. */ child->min += 1; @@ -632,8 +632,7 @@ mergeGroupPrefixSuffix(List *children) skipUntil = suffixStart + groupChildCount; /* - * Update i to continue suffix check after absorbed - * elements + * Update i to continue suffix check after merged elements */ i = skipUntil - 1; } -- 2.50.1 (Apple Git-155)