From: | Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Amit Langote <amitlangote09(at)gmail(dot)com> |
Subject: | Re: A bug in mapping attributes in ATExecAttachPartition() |
Date: | 2017-08-03 05:04:49 |
Message-ID: | 56179301-42c2-31c2-94ff-536c3ba1d56b@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2017/08/02 20:35, Robert Haas wrote:
> On Tue, Aug 1, 2017 at 9:44 PM, Amit Langote
> <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>> I too dislike the shape of attachRel. How about we rename attachRel to
>> attachrel? So, attachrel_children, attachrel_constr, etc. It's still
>> long though... :)
>
> OK, I can live with that, I guess.
Alright, attached updated 0001 does that.
About the other hunk, it seems we will have to go with the following
structure after all;
if (a)
if (b)
c();
d();
Note that we were missing that there is a d(), which executes if a is
true. c() executes *only* if b is true. So I left that hunk unchanged,
viz. the following:
/*
- * Skip if it's a partitioned table. Only RELKIND_RELATION
- * relations (ie, leaf partitions) need to be scanned.
+ * Skip if the partition is itself a partitioned table. We can
+ * only ever scan RELKIND_RELATION relations.
*/
- if (part_rel != attachRel &&
- part_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
+ if (part_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
- heap_close(part_rel, NoLock);
+ if (part_rel != attachrel)
+ heap_close(part_rel, NoLock);
continue;
}
You might ask why the earlier code worked if there was this kind of
logical bug - accident; even if we failed skipping attachRel, the AT
rewrite phase which is in charge of actually scanning the table knows to
skip the partitioned tables, so no harm would be done.
Thanks,
Amit
Attachment | Content-Type | Size |
---|---|---|
0001-Cosmetic-fixes-for-code-in-ATExecAttachPartition.patch | text/plain | 12.9 KB |
0002-Fix-lock-upgrade-deadlock-hazard-in-ATExecAttachPart.patch | text/plain | 2.8 KB |
0003-Cope-with-differing-attnos-in-ATExecAttachPartition-.patch | text/plain | 7.9 KB |
0004-Teach-ATExecAttachPartition-to-skip-validation-in-mo.patch | text/plain | 11.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2017-08-03 05:10:26 | Re: Unused variable scanned_tuples in LVRelStats |
Previous Message | Amit Khandekar | 2017-08-03 04:54:27 | Re: map_partition_varattnos() and whole-row vars |