On Sun, Feb 14, 2021 at 08:10:50PM -0600, Justin Pryzby wrote:
> Isn't this dead code ?

Nope, it's not dead.  Those two code paths can be hit when attempting
a reidex with a tablespace move directly on toast tables and indexes,
see:
=# create table aa (a text);
CREATE TABLE
=# select relname from pg_class where oid > 16000;
       relname
----------------------
 aa
 pg_toast_16385
 pg_toast_16385_index
(3 rows)
=# reindex (concurrently, tablespace pg_default) table
      pg_toast.pg_toast_16385;
ERROR:  0A000: cannot move system relation "pg_toast_16385"
LOCATION:  ReindexRelationConcurrently, indexcmds.c:3295
=# reindex (concurrently, tablespace pg_default) index
      pg_toast.pg_toast_16385_index;
ERROR:  0A000: cannot move system relation "pg_toast_16385_index"
LOCATION:  ReindexRelationConcurrently, indexcmds.c:3439

It is easy to save the relation name using \gset in a regression test,
but we had better keep a reference to the relation name in the error
message so this would not be really portable.  Using a PL function to
do that with a CATCH block would not work either as CONCURRENTLY
cannot be run in a transaction block.  This leaves 090_reindexdb.pl,
but I was not really convinced that this was worth the extra test
cycles (I am aware of the --tablespace option missing in reindexdb,
someone I know was trying to get that done for the next CF).
--
Michael

Attachment: signature.asc
Description: PGP signature

Reply via email to