Re: Row pattern recognition

Tatsuo Ishii <ishii@sraoss.co.jp>

From: Tatsuo Ishii <ishii@sraoss.co.jp>
To: champion.p@gmail.com
Cc: er@xs4all.nl, vik@postgresfriends.org, pgsql-hackers@postgresql.org
Date: 2023-11-08T07:37:05Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add temporal FOREIGN KEY contraints

  2. Remove obsolete executor cleanup code

Attachments

>> It would be nicer if it
>> could be implemented without using recursion.
> 
> Yeah. If for some reason we end up going with a bespoke
> implementation, I assume we'd just convert the algorithm to an
> iterative one and optimize it heavily. But I didn't want to do that
> too early, since it'd probably make it harder to add new features...
> and anyway my goal is still to try to reuse src/backend/regex
> eventually.

Ok.

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

- rebase.

- Reduce memory allocation in pattern matching (search_str_set()). But
  still Champion's second stress test gives OOM killer.
    
  - While keeping an old set to next round, move the StringInfo to
    new_str_set, rather than copying from old_str_set. This allows to
    run pgbench.sql against up to 60k rows on my laptop (previously
    20k).
    
  - Use enlargeStringInfo to set the buffer size, rather than
    incrementally enlarge the buffer. This does not seem to give big
    enhancement but it should theoretically an enhancement.

- Fix "variable not found in subplan target list" error if WITH is
  used.
    
  - To fix this apply pullup_replace_vars() against DEFINE clause in
    planning phase (perform_pullup_replace_vars()).  Also add
    regression test cases for WITH that caused the error in the
    previous version.

- Fix the case when no greedy quantifiers ('+' or '*') are included in
  PATTERN.
    
  - Previously update_reduced_frame() did not consider the case and
    produced wrong results. Add another code path which is dedicated
    to none greedy PATTERN (at this point, it means there's no
    quantifier case). Also add a test case for this.

- Remove unnecessary check in transformPatternClause().

  - Previously it checked if all pattern variables are defined in
    DEFINE clause. But currently RPR allows to "auto define" such
    variables as "varname AS TRUE". So the check was not necessary.

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

0001-Row-pattern-recognition-patch-for-raw-parser.patch
- same

0002-Row-pattern-recognition-patch-parse-analysis.patch
- Add markTargetListOrigins() to transformFrameOffset().
- Change transformPatternClause().

0003-Row-pattern-recognition-patch-planner.patch
- Fix perform_pullup_replace_vars()

0004-Row-pattern-recognition-patch-executor.patch
- Fix update_reduced_frame()
- Fix search_str_set()

0005-Row-pattern-recognition-patch-docs.patch
- same

0006-Row-pattern-recognition-patch-tests.patch
- Add test case for non-greedy and WITH cases

0007-Allow-to-print-raw-parse-tree.patch
- same

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