Re: Querying one partition in a function takes locks on all partitions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Renan Alves Fonseca <renanfonseca(at)gmail(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, Evgeny Morozov <postgresql4(at)realityexists(dot)net>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Querying one partition in a function takes locks on all partitions
Date: 2025-03-31 17:21:07
Message-ID: 4115257.1743441667@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Renan Alves Fonseca <renanfonseca(at)gmail(dot)com> writes:
> There is a Note that says: "The entire body of an SQL function is
> parsed before any of it is executed. While an SQL function can contain
> commands that alter ..."

Yup.

> If I understood well [2], then both notes may be discarded together in
> the next version.

No, that aspect is not changed in the currently-proposed patch:
we still do parse analysis of all the queries at the beginning.
I'd like to make it work differently eventually, but with feature
freeze so close I do not think that'll happen for v18.

Thinking a bit more about that, if the initial parse analysis succeeds
then the patched code will in fact re-parse before execution if any
DDL changes have occurred. So you get at least some of the desired
behavioral change. But the example given in the docs would still
fail, so I don't feel a need to change the docs yet.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eden Aharoni 2025-03-31 17:32:15 Re: [EXTERNAL] Re: RDS IO Read time
Previous Message David G. Johnston 2025-03-31 17:16:01 Re: Querying one partition in a function takes locks on all partitions