From 956d0d13c5705a5c445d9df71117d2a6f4b1904f Mon Sep 17 00:00:00 2001 From: jian he Date: Fri, 12 Jun 2026 11:30:25 +0800 Subject: [PATCH v47 1/6] replace some AST to clause --- src/backend/executor/README.rpr | 4 ++-- src/backend/parser/parse_rpr.c | 5 ++--- src/include/nodes/parsenodes.h | 9 ++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/backend/executor/README.rpr b/src/backend/executor/README.rpr index 00af86681b..e913e192b2 100644 --- a/src/backend/executor/README.rpr +++ b/src/backend/executor/README.rpr @@ -98,10 +98,10 @@ RPR processing is divided into three phases: +------------------------------------------------------------+ | 1. Parsing (Parser) | - | SQL text -> PATTERN AST + DEFINE expression tree | + | SQL text -> PATTERN clause + DEFINE expression tree | | | | 2. Compilation (Optimizer/Planner) | - | PATTERN AST -> optimization -> flat NFA element array | + | PATTERN clause -> optimization -> flat NFA element array | | | | 3. Execution (Executor) | | Row-by-row matching via NFA simulation | diff --git a/src/backend/parser/parse_rpr.c b/src/backend/parser/parse_rpr.c index 3eaea2be75..a21aadae73 100644 --- a/src/backend/parser/parse_rpr.c +++ b/src/backend/parser/parse_rpr.c @@ -8,7 +8,7 @@ * - Validates frame options (must start at CURRENT ROW, no EXCLUDE) * - Validates PATTERN variable count (max RPR_VARID_MAX + 1) * - Transforms DEFINE clause - * - Stores the PATTERN AST and the SKIP TO/INITIAL flags + * - Stores the PATTERN clause and the SKIP TO/INITIAL flags * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California @@ -67,7 +67,7 @@ static bool define_walker(Node *node, void *context); * - Set AFTER MATCH SKIP TO flag * - Set SEEK/INITIAL flag * - Transforms DEFINE clause into TargetEntry list - * - Stores PATTERN AST for deparsing (optimization happens in planner) + * - Stores PATTERN clause * * Returns early if windef has no rpCommonSyntax (non-RPR window). */ @@ -180,7 +180,6 @@ transformRPR(ParseState *pstate, WindowClause *wc, WindowDef *windef, /* Transform DEFINE clause into list of TargetEntry's */ wc->defineClause = transformDefineClause(pstate, wc, windef, targetlist); - /* Store PATTERN AST for deparsing */ wc->rpPattern = windef->rpCommonSyntax->rpPattern; } diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 3266c11a71..f210ee08ed 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -619,7 +619,7 @@ typedef enum RPRPatternNodeType } RPRPatternNodeType; /* - * RPRPatternNode - Row Pattern Recognition pattern AST node + * RPRPatternNode - Row Pattern Recognition PATTER clause */ typedef struct RPRPatternNode { @@ -650,7 +650,7 @@ typedef struct RPCommonSyntax RPSkipTo rpSkipTo; /* Row Pattern AFTER MATCH SKIP type */ bool initial; /* true if is * initial */ - RPRPatternNode *rpPattern; /* PATTERN clause AST */ + RPRPatternNode *rpPattern; /* PATTERN clause */ List *rpDefs; /* row pattern definitions clause (list of * ResTarget) */ ParseLoc location; /* PATTERN keyword location, or -1 */ @@ -1728,8 +1728,7 @@ typedef struct GroupingSet * * "defineClause" is Row Pattern Recognition DEFINE clause (list of * TargetEntry). TargetEntry.resname represents row pattern definition - * variable name. "rpPattern" represents PATTERN clause as an AST tree - * (RPRPatternNode). + * variable name. "rpPattern" represents the PATTERN clause. * * The information relevant for the query jumbling is the partition clause * type and its bounds. @@ -1766,7 +1765,7 @@ typedef struct WindowClause * initial */ /* Row Pattern DEFINE clause (list of TargetEntry) */ List *defineClause; - /* Row Pattern PATTERN clause AST */ + /* Row Pattern PATTERN clause */ RPRPatternNode *rpPattern; } WindowClause; -- 2.34.1