Re: Row pattern recognition

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: assam258(at)gmail(dot)com
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, zsolt(dot)parragi(at)percona(dot)com, sjjang112233(at)gmail(dot)com, vik(at)postgresfriends(dot)org, er(at)xs4all(dot)nl, jacob(dot)champion(at)enterprisedb(dot)com, david(dot)g(dot)johnston(at)gmail(dot)com, peter(at)eisentraut(dot)org, li(dot)evan(dot)chao(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-06-15 06:32:01
Message-ID: CACJufxFAQhbOD9EVCTAy-VwDbG4446N10GsxCcgdpFnjHO1Efw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

More review based on https://github.com/assam258-5892/postgres/commits/RPR

remove_unused_subquery_outputs
``````
if (dvar->varno == var->varno &&
dvar->varattno == var->varattno &&
dvar->varlevelsup == var->varlevelsup)
{
needed_by_define = true;
break;
}
``````
dvar, var both can be whole-row Vars, but this seems to work for whole-row vars.
We need some simple regress tests for cases where both are whole-row
vars or one of them is a whole-row var.

I've attached a patch with some refactoring. The below is detailed
commit message.
--------------------------------------------------------------------
RPRNavExpr->resulttype should also marked as pg_node_attr(query_jumble_ignore)

collectPatternVariables is not needed.
The parser already ensures every DEFINE variable appears in PATTERN,
so there is nothing to filter.
Also, we don't really do anything special (like make a dummy Const) regarding
PATTERN variables that not appearing in the DEFINE clause.
See nfa_evaluate_row the for loop break.

buildDefineVariableList is trivial. No need to export it as an
external function.

Rename WindowAggState.defineClauseList to defineClauseExprs
Minor refactoring of regress test comments.
Flatten a needlessly nested block in show_window_def().
Replace a post-loop ListCell NULL check in
remove_unused_subquery_outputs() with a boolean flag.
Reduce the number of arguments in make_windowagg.
--------------------------------------------------------------------

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v48-0001-v48-misc-refactoring.nocfbot application/octet-stream 27.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-06-15 06:36:33 Re: PSQL - prevent describe listing tables that are already in listed schemas
Previous Message cca5507 2026-06-15 06:29:57 Re: Handle concurrent drop when doing whole database vacuum