Re: pull-up subquery if JOIN-ON contains refs to upper-query

From: Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
Subject: Re: pull-up subquery if JOIN-ON contains refs to upper-query
Date: 2025-02-09 15:14:09
Message-ID: 975a3736-a8b5-49b3-8009-4d4e86867aa1@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi! I found another example where the transformation worked incorrectly
and reconsidered the idea.

As for conversion of exists_sublink_to_ANY, we need to get the flattened
implicit-AND list of clauses and pull out the chunks of the WHERE clause
that belong to the parent query,
since we are called halfway through the parent's preprocess_expression()
and earlier steps of preprocess_expression() wouldn't get applied to the
pulled-up stuff unless we do them here.
We also do some processing for vars depending on which side the var is
on - if it's in a subquery, we only need to lower its level (varlevel)
because subquery will be flatted, while
for other vars that belong to the parent query, we need to do
preparation to pull up the sub-select into top range table.

For those expressions that we couldn't assign to either list, we define
newWhere and apply both cases.

--
Regards,
Alena Rybakina
Postgres Professional

Attachment Content-Type Size
v3-0001-Add-appling-the-pull-up-transformation-for-expressio.patch text/x-patch 28.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhang Mingli 2025-02-09 15:14:51 Fix outdated code comments in nodeAgg.c
Previous Message Peter Eisentraut 2025-02-09 14:52:49 Re: Thread-safe nl_langinfo() and localeconv()