From: Michael Paquier <michael@paquier.xyz>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Postgres hackers <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: Clarify use of temporary tables within partition trees
Date: Tue, 3 Jul 2018 13:55:02 +0900
Message-ID: <20180703045502.GA26236@paquier.xyz> (raw)
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>
On Tue, Jul 03, 2018 at 12:59:33PM +1200, David Rowley wrote:
> 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
Okay, the patch looks logically correct to me, I just tweaked the
comments as per the attached. I would also back-patch that down to v11
to keep the code consistent with HEAD.. What do you think?
--
Michael
Attachments:remove_dead_code_from_expand_partitioned_rtentry_v3.patch (text/x-diff, 2.1K) downloaddiff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.cindex 2d470240d5..71e256f8fd 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,16 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte,
top_parentrc, parentrel,
appinfos, &childrte, &childRTindex);
+ /*+ * If the partitioned table has no partitions, treat this as the+ * non-inheritance case.+ */+ if (partdesc->nparts == 0)+ {+ parentrte->inh = false;+ return;+ }+
for (i = 0; i < partdesc->nparts; i++)
{
Oid childOID = partdesc->oids[i];
@@ -1715,15 +1724,13 @@ 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 */+ /*+ * Temporation partitions belonging to other sessions should have been+ * disallowed at definition, 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 relation from another session found as partition");
expand_single_inheritance_child(root, parentrte, parentRTindex,
parentrel, top_parentrc, childrel,
@@ -1738,14 +1745,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;
}
/*
signature.asc (application/pgp-signature, 832B) download
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: michael@paquier.xyz, david.rowley@2ndquadrant.com, robertmhaas@gmail.com, pgsql-hackers@postgresql.org
Subject: Re: pgsql: Clarify use of temporary tables within partition trees
In-Reply-To: <20180703045502.GA26236@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> <CAKJS1f9bFnkWX3iDC0DgCdwDSaAMYjWbENmek23FGQx9FkLREw@mail.gmail.com> <20180703045502.GA26236@paquier.xyz>
* 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