Re: Eliminating SPI from RI triggers - take 2

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Eliminating SPI from RI triggers - take 2
Date: 2022-10-11 17:27:06
Message-ID: CA+Tgmoa7WnSmnAn7n2826tKMaUZM79jtJdMTPmmAyjQH0hZYUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 29, 2022 at 12:47 AM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> [ patches ]

While looking over this thread I came across this code:

/* For data reading, executor always omits detached partitions */
if (estate->es_partition_directory == NULL)
estate->es_partition_directory =
CreatePartitionDirectory(estate->es_query_cxt, false);

But CreatePartitionDirectory is declared like this:

extern PartitionDirectory CreatePartitionDirectory(MemoryContext mcxt,
bool omit_detached);

So the comment seems to say the opposite of what the code does. The
code seems to match the explanation in the commit message for
71f4c8c6f74ba021e55d35b1128d22fb8c6e1629, so I am guessing that
perhaps s/always/never/ is needed here.

I also noticed that ExecCreatePartitionPruneState no longer exists in
the code but is still referenced in
src/test/modules/delay_execution/specs/partition-addition.spec

Regarding 0003, it seems unfortunate that
find_inheritance_children_extended() will now have 6 arguments 4 of
which have to do with detached partition handling. That is a lot of
detached partition handling, and it's hard to reason about. I don't
see an obvious way of simplifying things very much, but I wonder if we
could at least have the new omit_detached_snapshot snapshot replace
the existing bool omit_detached flag. Something like the attached
incremental patch.

Probably we need to go further than the attached, though. I don't
think that PartitionDirectoryLookup() should be getting any new
arguments. The whole point of that function is that it's supposed to
ensure that the returned value is stable, and the comments say so. But
with these changes it isn't any more, because it depends on the
snapshot you pass. It seems fine to specify when you create the
partition directory that you want it to show a different, still-stable
view of the world, but as written, it seems to me to undermine the
idea that the return value is expected to be stable at all. Is there a
way we can avoid that?

--
Robert Haas
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
fewer-arguments.txt text/plain 6.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2022-10-11 17:40:59 Re: use has_privs_of_role() for pg_hba.conf
Previous Message Zhihong Yu 2022-10-11 17:15:05 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands