Re: Row pattern recognition

From: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
To: vik(at)postgresfriends(dot)org, jchampion(at)timescale(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2023-08-09 08:41:12
Message-ID: 20230809.174112.1806434641666895071.t-ishii@sranhm.sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Attached is the v4 patch. Differences from previous patch include:

> - PERMUTE is still misspelled as PREMUTE

Fixed.

> - PATTERN variables do not have to exist in the DEFINE clause. They are
> - considered TRUE if not present.

Fixed. Moreover new regression test case is added.

- It was possible that tle nodes in DEFINE clause do not appear in the
plan's target list. This makes impossible to evaluate expressions in
the DEFINE because it does not appear in the outer plan's target
list. To fix this, call findTargetlistEntrySQL99 (with resjunk is
true) so that the missing TargetEntry is added to the outer plan
later on.

- I eliminated some hacks in handling the Var node in DEFINE
clause. Previously I replaced varattno of Var node in a plan tree by
hand so that it refers to correct varattno in the outer plan
node. In this patch I modified set_upper_references so that it calls
fix_upper_expr for those Var nodes in the DEFINE clause. See v4-0003
patch for more details.

- I found a bug with pattern matching code. It creates a string for
subsequent regular expression matching. It uses the initial letter
of each define variable name. For example, if the varname is "foo",
then "f" is used. Obviously this makes trouble if we have two or
more variables starting with same "f" (e.g. "food"). To fix this, I
assign [a-z] to each variable instead of its initial letter. However
this way limits us not to have more than 26 variables. I hope 26 is
enough for most use cases.

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

Attachment Content-Type Size
v4-0001-Row-pattern-recognition-patch-for-raw-parser.patch text/x-patch 20.7 KB
v4-0002-Row-pattern-recognition-patch-parse-analysis.patch text/x-patch 11.6 KB
v4-0003-Row-pattern-recognition-patch-planner.patch text/x-patch 4.8 KB
v4-0004-Row-pattern-recognition-patch-executor.patch text/x-patch 30.5 KB
v4-0005-Row-pattern-recognition-patch-docs.patch text/x-patch 8.2 KB
v4-0006-Row-pattern-recognition-patch-tests.patch text/x-patch 26.8 KB
v4-0007-Allow-to-print-raw-parse-tree.patch text/x-patch 748 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2023-08-09 08:44:43 Re: Avoid stack frame setup in performance critical routines using tail calls
Previous Message Anthonin Bonnefoy 2023-08-09 08:34:41 Re: POC: Extension for adding distributed tracing - pg_tracing