Re: A bug in mapping attributes in ATExecAttachPartition()
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>,
Amit Langote <amitlangote09@gmail.com>
Date: 2017-08-03T05:04:49Z
Lists: pgsql-hackers
Attachments
- 0001-Cosmetic-fixes-for-code-in-ATExecAttachPartition.patch (text/plain) patch 0001
- 0002-Fix-lock-upgrade-deadlock-hazard-in-ATExecAttachPart.patch (text/plain) patch 0002
- 0003-Cope-with-differing-attnos-in-ATExecAttachPartition-.patch (text/plain) patch 0003
- 0004-Teach-ATExecAttachPartition-to-skip-validation-in-mo.patch (text/plain) patch 0004
On 2017/08/02 20:35, Robert Haas wrote:
> On Tue, Aug 1, 2017 at 9:44 PM, Amit Langote
> <Langote_Amit_f8@lab.ntt.co.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
Commits
-
Fix inconsistent capitalization.
- 29f021160ea7 10.0 landed
- 42651bdd68a1 11.0 landed
-
Fix bug in deciding whether to scan newly-attached partition.
- f85f88bcc270 10.0 landed
-
Fix lock upgrade hazard in ATExecAttachPartition.
- 972b6ec20bf0 10.0 landed
-
Code beautification for ATExecAttachPartition.
- 583df3b5c562 10.0 landed
-
Teach predtest.c about CHECK clauses to fix partitioning bugs.
- b08df9cab777 10.0 landed
-
Don't explicitly mark range partitioning columns NOT NULL.
- 3ec76ff1f2cf 10.0 cited