pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: ALTER tbl rewrite loses CLUSTER ON index
Date: Thu, 2 Apr 2020 04:38:36 -0300
Message-ID: <20200402073836.GA17269@alvherre.pgsql> (raw)
In-Reply-To: <20200402061421.GA112468@paquier.xyz>

On 2020-Apr-02, Michael Paquier wrote:

> Now, regarding patch 0002, note that you have a problem for this part:
> -            tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
> -            if (!HeapTupleIsValid(tuple))    /* probably can't happen */
> -            {
> -                relation_close(OldHeap, AccessExclusiveLock);
> -                pgstat_progress_end_command();
> -                return;
> -            }
> -            indexForm = (Form_pg_index) GETSTRUCT(tuple);
> -            if (!indexForm->indisclustered)
> +            if (!get_index_isclustered(indexOid))
>              {
> -                ReleaseSysCache(tuple);
>                  relation_close(OldHeap, AccessExclusiveLock);
>                  pgstat_progress_end_command();
>                  return;
>              }
> -            ReleaseSysCache(tuple);
> 
> On an invalid tuple for pg_index, the new code would issue an error,
> while the old code would just return.

I don't think we need to worry about that problem, because we already
checked that the pg_class tuple for the index is there two lines above.
The pg_index tuple cannot have gone away on its own; and the index can't
be deleted either, because cluster_rel holds AEL on the table.  There
isn't "probably" about the can't-happen condition, is there?

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





view thread (33+ messages)  latest in thread

Message-ID: <20200402073836.GA17269@alvherre.pgsql>
Permalink:  ../20200402073836.GA17269@alvherre.pgsql/
Also on:    postgresql.org/message-id/20200402073836.GA17269@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, michael@paquier.xyz, pryzby@telsasoft.com, amitlangote09@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: ALTER tbl rewrite loses CLUSTER ON index
  In-Reply-To: <20200402073836.GA17269@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox