From d6b8d29419df0efad57f95c80b871745d1b55da6 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 28 Apr 2021 15:44:35 -0400 Subject: Allow a partdesc-omitting-partitions to be cached Makes partition descriptor acquisition faster during the transient period in which a partition is in the process of being detached. This also adds the restriction that only one partition can be in pending-detach state for a partitioned table. While at it, return find_inheritance_children() API to what it was before 71f4c8c6f74b, and create a separate find_inheritance_children_extended() that returns detailed info about detached partitions. (This incidentally fixes a bug in 8aba9322511 whereby a memory context holding a transient partdesc is reparented to a NULL PortalContext, leading to permanent leak of that memory. The fix is to no longer rely on reparenting contexts to PortalContext. Reported by Amit Langote.) Per gripe from Amit Langote Discussion: https://postgr.es/m/CA+HiwqFgpP1LxJZOBYGt9rpvTjXXkg5qG2+Xch2Z1Q7KrqZR1A@mail.gmail.com --- src/include/utils/rel.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/include/utils') diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 34e25eb5978..07ae2c70a96 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -129,6 +129,21 @@ typedef struct RelationData PartitionDesc rd_partdesc; /* partition descriptor, or NULL */ MemoryContext rd_pdcxt; /* private context for rd_partdesc, if any */ + /* Same as above, for partdescs that omit detached partitions */ + PartitionDesc rd_partdesc_nodetached; /* partdesc w/o detached parts */ + MemoryContext rd_pddcxt; /* for rd_partdesc_nodetached, if any */ + + /* + * pg_inherits.xmin of the partition that was excluded in + * rd_partdesc_nodetached. This informs a future user of that partdesc: + * if this value is not in progress for the active snapshot, then the + * partdesc can be used, otherwise they have to build a new one. (This + * matches what find_inheritance_children_extended would do). In the rare + * case where the pg_inherits tuple has been frozen, this will be + * InvalidXid; behave as if the partdesc is unusable in that case. + */ + TransactionId rd_partdesc_nodetached_xmin; + /* data managed by RelationGetPartitionQual: */ List *rd_partcheck; /* partition CHECK quals */ bool rd_partcheckvalid; /* true if list has been computed */ -- cgit v1.2.3