Re: Row pattern recognition

Started by Tatsuo Ishiialmost 3 years ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t48850
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 11:43 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t48850_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t48850_1 && git checkout t48850_1

Patchset v1 (message #1) is on t48850_1

Jump to latest
#1Tatsuo Ishii
ishii@postgresql.org

Attached is the v12 patch. Below are the summary of the changes from
previous version.

- Rebase. CFbot says v11 patch needs rebase since Nov 30, 2023.

- Apply preprocess_expression() to DEFINE clause in the planning
phase. This is necessary to simply const expressions like:

DEFINE A price < (99 + 1)
to:
DEFINE A price < 100

- Re-allow to use WinSetMarkPosition() in eval_windowaggregates().

- FYI here is the list to explain what were changed in each patch file.

0001-Row-pattern-recognition-patch-for-raw-parser.patch
- Fix conflict.

0002-Row-pattern-recognition-patch-parse-analysis.patch
- Same as before.

0003-Row-pattern-recognition-patch-planner.patch
- Call preprocess_expression() for DEFINE clause in subquery_planner().

0004-Row-pattern-recognition-patch-executor.patch
- Re-allow to use WinSetMarkPosition() in eval_windowaggregates().

0005-Row-pattern-recognition-patch-docs.patch
- Same as before.

0006-Row-pattern-recognition-patch-tests.patch
- Same as before.

0007-Allow-to-print-raw-parse-tree.patch
- Same as before.

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

Attachments:

t48850_1
v12-0001-Row-pattern-recognition-patch-for-raw-parser.patchtext/x-patch; charset=us-asciiDownload+273-15
v12-0002-Row-pattern-recognition-patch-parse-analysis.patchtext/x-patch; charset=us-asciiDownload+291-2
v12-0003-Row-pattern-recognition-patch-planner.patchtext/x-patch; charset=us-asciiDownload+67-7
v12-0004-Row-pattern-recognition-patch-executor.patchtext/x-patch; charset=us-asciiDownload+1490-15
v12-0005-Row-pattern-recognition-patch-docs.patchtext/x-patch; charset=us-asciiDownload+170-3
v12-0006-Row-pattern-recognition-patch-tests.patchtext/x-patch; charset=us-asciiDownload+1214-2
v12-0007-Allow-to-print-raw-parse-tree.patchtext/x-patch; charset=us-asciiDownload+4-1
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Tatsuo Ishii (#1)

On 04.12.23 12:40, Tatsuo Ishii wrote:

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index d631ac89a9..5a77fca17f 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -251,6 +251,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
DefElem	   *defelt;
SortBy	   *sortby;
WindowDef  *windef;
+	RPCommonSyntax	*rpcom;
+	RPSubsetItem	*rpsubset;
JoinExpr   *jexpr;
IndexElem  *ielem;
StatsElem  *selem;
@@ -278,6 +280,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
MergeWhenClause *mergewhen;
struct KeyActions *keyactions;
struct KeyAction *keyaction;
+	RPSkipTo	skipto;
}

%type <node> stmt toplevel_stmt schema_stmt routine_body_stmt

It is usually not the style to add an entry for every node type to the
%union. Otherwise, we'd have hundreds of entries in there.

@@ -866,6 +878,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%nonassoc	UNBOUNDED		/* ideally would have same precedence as IDENT */
%nonassoc	IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
SET KEYS OBJECT_P SCALAR VALUE_P WITH WITHOUT
+%nonassoc	MEASURES AFTER INITIAL SEEK PATTERN_P
%left		Op OPERATOR		/* multi-character ops and user-defined operators */
%left		'+' '-'
%left		'*' '/' '%'

It was recently discussed that these %nonassoc should ideally all have
the same precedence. Did you consider that here?