Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail
Date: 2019-07-23 04:28:38
Message-ID: 20190723042838.GB2059@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Jul 22, 2019 at 05:41:26PM -0400, Tom Lane wrote:
> I think the correct fix is to nuke the code in REINDEX CONCURRENTLY that
> thinks it should use any of this infrastructure to fetch the existing
> index properties, and just have it read the catalog directly instead.

Okay. Sharing a maximum the build of IndexInfo done as part of
DefineIndex is something that we should do then. Attached is a patch
that I have been working on, introducing a new makeIndexInfo() in
makefuncs.c. Still as IndexInfo is not a parse node but an exec node,
I am including execnodes.h in makefuncs.h for now (perhaps somebody
has a better idea?). This fills the index information of the new
entry directly from the catalog of the old entry for expressions and
predicates.

I have let BuildIndexInfo out of that as ii_ReadyForInserts can change
for system catalogs during bootstrap. I have also reworked the test
case to just use pg_get_indexdef() which is enough to show the
original bug as after the initial REINDEX CONCURRENTLY the collation
part goes missing when testing on HEAD. Predicates need to properly
be formatted with an implicit-AND format by the way.

Thoughts?
--
Michael

Attachment Content-Type Size
reindex-conc-predicates-v2.patch text/x-diff 12.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message 高 云龙 2019-07-23 08:07:04 A function privilege problem
Previous Message Tom Lane 2019-07-22 21:41:26 Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail