Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

Benoit Lobréau <benoit.lobreau@gmail.com>

From: Benoit Lobréau <benoit.lobreau@gmail.com>
To: Shayon Mukherjee <shayonj@gmail.com>
Cc: Sami Imseih <samimseih@gmail.com>, Michail Nikolaev <michail.nikolaev@gmail.com>, David Rowley <dgrowleyml@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-01-24T15:26:23Z
Lists: pgsql-hackers

Attachments

I also noticed that \d on an index doesn't warn about the invisible state
whereas \d on a table does:

[local]:5444 postgres@postgres=# SELECT indexrelid::regclass,
indisvalid, indisvisible FROM pg_index WHERE indexrelid =
'repli_pkey'::regclass \gx
-[ RECORD 1 ]+-----------
indexrelid   | repli_pkey
indisvalid   | f
indisvisible | f

[local]:5444 postgres@postgres=# \d repli_pkey
      Index "public.repli_pkey"
 Column |  Type   | Key? | Definition
--------+---------+------+------------
 i      | integer | yes  | i
primary key, btree, for table "public.repli", invalid

[local]:5444 postgres@postgres=# \d repli
               Table "public.repli"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 i      | integer |           | not null |
 t      | text    |           |          |
Indexes:
    "repli_pkey" PRIMARY KEY, btree (i) INVISIBLE INVALID
Publications:
    "pub"

The attached patch adds the flag.

[local]:5444 postgres@postgres=# \d repli_pkey
      Index "public.repli_pkey"
 Column |  Type   | Key? | Definition
--------+---------+------+------------
 i      | integer | yes  | i
primary key, btree, for table "public.repli", invalid, invisible