From: David Rowley <david.rowley@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Clarify use of temporary tables within partition trees
Date: Tue, 3 Jul 2018 12:59:33 +1200
Message-ID: <CAKJS1f9bFnkWX3iDC0DgCdwDSaAMYjWbENmek23FGQx9FkLREw@mail.gmail.com> (raw)
In-Reply-To: <20180702221650.GA2159@paquier.xyz>
References: <E1fVSJT-0000Lw-Mu@gemulon.postgresql.org>
<CAKJS1f_HyV1txn_4XSdH5EOhBMYaCwsXyAj6bHXk9gOu4JKsbw@mail.gmail.com>
<CA+TgmoY5EOxJSJCxH09rL1bpFHojpcAKyRym1Y=FiCpOv151mw@mail.gmail.com>
<20180702221650.GA2159@paquier.xyz>
On 3 July 2018 at 10:16, Michael Paquier <michael@paquier.xyz> wrote:
> On Mon, Jul 02, 2018 at 02:07:37PM -0400, Robert Haas wrote:
>> I'd rather keep an elog(ERROR) than completely remove the check.
>
> +1.
Attached
>> Also, for the record, I think the subject line of Michael's commit
>> message was pretty unclear about what it was actually doing.
>
> How would you formulate it? Perhaps the error message did not emphasize
> enough on the fast that it actually blocked a behavior, say "Block mix
> of temporary and permanent relations in partition trees" or such?
For me, reading the subject line of the commit I'd have expected a doc
change, or improved/new code comments.
This is really more "Disallow mixed temp/permanent partitioned hierarchies".
"Clarify" does not really involve a change of behaviour. It's an
explanation of what the behaviour is.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:remove_dead_code_from_expand_partitioned_rtentry_v2.patch (application/octet-stream, 2.0K) downloaddiff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.cindex 2d470240d5..cc0014c2d6 100644--- a/src/backend/optimizer/prep/prepunion.c+++ b/src/backend/optimizer/prep/prepunion.c@@ -1681,7 +1681,6 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
int i;
RangeTblEntry *childrte;
Index childRTindex;
- bool has_child = false;
PartitionDesc partdesc = RelationGetPartitionDesc(parentrel);
check_stack_depth();
@@ -1707,6 +1706,13 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
top_parentrc, parentrel,
appinfos, &childrte, &childRTindex);
+ /* if there are no partitions then treat this as non-inheritance case. */+ if (partdesc->nparts == 0)+ {+ parentrte->inh = false;+ return;+ }+
for (i = 0; i < partdesc->nparts; i++)
{
Oid childOID = partdesc->oids[i];
@@ -1714,16 +1720,12 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
/* Open rel; we already have required locks */
childrel = heap_open(childOID, NoLock);
-- /* As in expand_inherited_rtentry, skip non-local temp tables */+ /*+ * Temp partitions belonging to other sessions should have been+ * disallowed, but for paranoia's sake, let's double check.+ */
if (RELATION_IS_OTHER_TEMP(childrel))
- {- heap_close(childrel, lockmode);- continue;- }-- /* We have a real partition. */- has_child = true;+ elog(ERROR, "temporary partition found belonging to another session");
expand_single_inheritance_child(root, parentrte, parentRTindex,
parentrel, top_parentrc, childrel,
@@ -1738,14 +1740,6 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
/* Close child relation, but keep locks */
heap_close(childrel, NoLock);
}
-- /*- * If the partitioned table has no partitions or all the partitions are- * temporary tables from other backends, treat this as non-inheritance- * case.- */- if (!has_child)- parentrte->inh = false;
}
/*
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: david.rowley@2ndquadrant.com, michael@paquier.xyz, robertmhaas@gmail.com
Subject: Re: pgsql: Clarify use of temporary tables within partition trees
In-Reply-To: <CAKJS1f9bFnkWX3iDC0DgCdwDSaAMYjWbENmek23FGQx9FkLREw@mail.gmail.com>
References: <E1fVSJT-0000Lw-Mu@gemulon.postgresql.org> <CAKJS1f_HyV1txn_4XSdH5EOhBMYaCwsXyAj6bHXk9gOu4JKsbw@mail.gmail.com> <CA+TgmoY5EOxJSJCxH09rL1bpFHojpcAKyRym1Y=FiCpOv151mw@mail.gmail.com> <20180702221650.GA2159@paquier.xyz> <CAKJS1f9bFnkWX3iDC0DgCdwDSaAMYjWbENmek23FGQx9FkLREw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox