Re: pgsql: Fix partitioned index creation with foreign partitions

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Fix partitioned index creation with foreign partitions
Date: 2019-06-27 02:32:27
Message-ID: CA+HiwqGV=k_Eh4jBiQw66ivvdG+EUkrEYeHTYL1SvDj_YOYV0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Thu, Jun 27, 2019 at 8:04 AM Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
>
> On 2019-Jun-26, Alvaro Herrera wrote:
>
> > Fix partitioned index creation with foreign partitions
>
> Hmm, so this causes prion to fail, because -DFORCE_RELCACHE_RELEASE: it
> reports the immediate parent of the would-be-partition rather than the
> topmost ancestor. I'm not sure I understand why, since relcache release
> shouldn't affect recursion order (maybe that's another bug). I'll
> investigate more tomorrow.

I see this diff:

ALTER TABLE lt1 ADD PRIMARY KEY (a);
-ERROR: cannot create unique index on partitioned table "lt1_part1"
-DETAIL: Table "lt1_part1" contains partitions that are foreign tables.
+ERROR: cannot create unique index on partitioned table "ft_part_1_1"
+DETAIL: Table "ft_part_1_1" contains partitions that are foreign tables.

The table name reported here is that of the foreign table leaf
partition, not of the immediate parent. Also, what's expected is not
the topmost ancestor, but the immediate parent, which seems OK,
because that's the best that the code in question can manage.

Anyway, the problem seems to use-after-close of a Relation pointer,
which the attached patch fixes.

Thanks,
Amit

Attachment Content-Type Size
DefineIndex-fix-use-after-relation-close.patch application/octet-stream 769 bytes

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2019-06-27 08:12:22 Re: pgsql: Drop test user when done with it.
Previous Message Stephen Frost 2019-06-26 23:43:10 Re: UCT (Re: pgsql: Update time zone data files to tzdata release 2019a.)