pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix a few issues with REINDEX grammar
Date: Tue, 26 Jul 2022 01:16:52 +0000
Message-ID: <E1oG9Br-001Gb5-9V@gemulon.postgresql.org> (raw)

Fix a few issues with REINDEX grammar

This addresses a couple of bugs in the REINDEX grammar, introduced by
83011ce:
- A name was never specified for DATABASE/SYSTEM, even if the query
included one.  This caused such REINDEX queries to always work with any
object name, but we should complain if the object name specified does
not match the name of the database we are connected to.  A test is added
for this case in the main regression test suite, provided by Álvaro.
- REINDEX SYSTEM CONCURRENTLY [name] was getting rejected in the
parser.  Concurrent rebuilds are not supported for catalogs but the
error provided at execution time is more helpful for the user, and
allowing this flavor results in a simplification of the parsing logic.
- REINDEX DATABASE CONCURRENTLY was rebuilding the index in a
non-concurrent way, as the option was not being appended correctly in
the list of DefElems in ReindexStmt (REINDEX (CONCURRENTLY) DATABASE was
working fine.  A test is added in the TAP tests of reindexdb for this
case, where we already have a REINDEX DATABASE CONCURRENTLY query
running on a small-ish instance.  This relies on the work done in
2cbc3c1 for SYSTEM, but here we check if the OIDs of the index relations
match or not after the concurrent rebuild.  Note that in order to get
this part to work, I had to tweak the tests so as the index OID and
names are saved separately.  This change not affect the reliability or
of the coverage of the existing tests.

While on it, I have implemented a tweak in the grammar to reduce the
parsing by one branch, simplifying things even more.

Author: Michael Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/YttqI6O64wDxGn0K@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0a5f06b84de76939cf9805e4266d47c2e8bf66df

Modified Files
--------------
doc/src/sgml/ref/reindex.sgml              |  3 +--
src/backend/parser/gram.y                  | 36 ++++++++++++++---------------
src/bin/scripts/t/090_reindexdb.pl         | 37 ++++++++++++++++++++----------
src/test/regress/expected/create_index.out |  7 +++---
src/test/regress/sql/create_index.sql      |  2 ++
5 files changed, 49 insertions(+), 36 deletions(-)



Message-ID: <E1oG9Br-001Gb5-9V@gemulon.postgresql.org>
Permalink:  ../E1oG9Br-001Gb5-9V@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oG9Br-001Gb5-9V@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Fix a few issues with REINDEX grammar
  In-Reply-To: <E1oG9Br-001Gb5-9V@gemulon.postgresql.org>
  References: <E1oG9Br-001Gb5-9V@gemulon.postgresql.org>

* 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