Re: Eliminating SPI from RI triggers - take 2 - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Eliminating SPI from RI triggers - take 2
Date
Msg-id CA+Tgmoa7WnSmnAn7n2826tKMaUZM79jtJdMTPmmAyjQH0hZYUw@mail.gmail.com
Whole thread Raw
In response to Re: Eliminating SPI from RI triggers - take 2  (Amit Langote <amitlangote09@gmail.com>)
Responses Re: Eliminating SPI from RI triggers - take 2  (Amit Langote <amitlangote09@gmail.com>)
List pgsql-hackers
On Thu, Sep 29, 2022 at 12:47 AM Amit Langote <amitlangote09@gmail.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

pgsql-hackers by date:

Previous
From: Zhihong Yu
Date:
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Next
From: Nathan Bossart
Date:
Subject: Re: use has_privs_of_role() for pg_hba.conf