Re: Fix for pg_upgrade and invalid indexes

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Fix for pg_upgrade and invalid indexes
Date: 2013-03-29 22:40:28
Message-ID: 20130329224028.GB26976@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2013-03-29 16:57:06 -0400, Bruce Momjian wrote:
> On Thu, Mar 28, 2013 at 05:27:28PM -0400, Tom Lane wrote:
> > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > Should I just patch pg_upgrade to remove the "indisvalid", skip
> > > "indisvalid" indexes, and backpatch it? Users should be using the
> > > version of pg_upgrade to match new pg_dump. Is there any case where
> > > they don't match? Do I still need to check for "indisready"?
> >
> > Yeah, if you can just ignore !indisvalid indexes that should work fine.
> > I see no need to look at indisready if you're doing that.
>
> Attached is a patch that implements the suggested pg_upgrade changes of
> not copying invalid indexes now that pg_dump doesn't dump them. This
> should be backpatched back to 8.4 to match pg_dump. It might require
> release note updates; not sure. Previously pg_upgrade threw an error
> if invalid indexes exist, but only since February, when we released the
> pg_upgrade fix to do this. You can see the majority of this patch is
> removing that check.

> + "RIGHT OUTER JOIN pg_catalog.pg_index i "
> + " ON (c.oid = i.indexrelid) "
> "WHERE relkind IN ('r', 'm', 'i'%s) AND "
> + /* pg_dump only dumps valid indexes; testing indisready is
> + * necessary in 9.2, and harmless in earlier/later versions. */
> + " i.indisvalid IS DISTINCT FROM false AND "
> + " i.indisready IS DISTINCT FROM false AND "
> /* exclude possible orphaned temp tables */
> " ((n.nspname !~ '^pg_temp_' AND "
> " n.nspname !~ '^pg_toast_temp_' AND "

Those columns cannot be NULL, so using IS DISTINCT FROM seems a bit
clumsy.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-03-29 23:03:05 Re: Fix for pg_upgrade and invalid indexes
Previous Message Tom Lane 2013-03-29 22:35:08 Re: Fix for pg_upgrade and invalid indexes

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-03-29 23:03:05 Re: Fix for pg_upgrade and invalid indexes
Previous Message Tom Lane 2013-03-29 22:35:08 Re: Fix for pg_upgrade and invalid indexes