Re: Partitioned index can be not dumped

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Partitioned index can be not dumped
Date: 2021-06-30 19:26:20
Message-ID: CALNJ-vS1R3Qoe5t4tbzxrkpBtzRbPq1dDcW4RmA_a+oqweF30w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 30, 2021 at 11:54 AM Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
wrote:

> On 2021-Jun-30, Alexander Pyhalov wrote:
>
> > I've seen the following effect on PostgreSQL 14 stable branch.
> > Index, created on partitioned table, disappears from pg_dump or psql \d
> > output.
> > This seems to begin after analyze. Partitoned relation relhasindex
> pg_class
> > field suddenly becomes false.
>
> Yeah, that seems correct.
>
> I didn't verify your test case, but after looking at the code I thought
> there was a bit too much churn and the new conditions looked quite messy
> and unexplained. It seems simpler to be explicit at the start about
> what we're doing, and keep nindexes=0 for partitioned tables; with that,
> the code works unchanged because the "for" loops do nothing without
> having to check for anything. My proposal is attached.
>
> I did run the tests and they do pass, but I didn't look very closely at
> what the tests are actually doing.
>
> I noticed that part of that comment seems to be a leftover from ... I
> don't know when: "We do not analyze index columns if there was an
> explicit column list in the ANALYZE command, however." I suppose this
> is about some code that was removed, but I didn't dig into it.
>
> --
> Álvaro Herrera Valdivia, Chile
> "How strange it is to find the words "Perl" and "saner" in such close
> proximity, with no apparent sense of irony. I doubt that Larry himself
> could have managed it." (ncm, http://lwn.net/Articles/174769/)

Hi,
nit:
- if (hasindex)
+ if (nindexes > 0)

It seems hasindex is no longer needed since nindexes is checked.

Cheers

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ibrar Ahmed 2021-06-30 19:26:55 Re: Commit fest manager
Previous Message Álvaro Herrera 2021-06-30 18:54:09 Re: Partitioned index can be not dumped