Re: reindexdb: Change quoting rule of --schema?

From: Noah Misch <noah(at)leadboat(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Re: reindexdb: Change quoting rule of --schema?
Date: 2026-11-14 18:34:54
Message-ID: 20261114183454.95.noahmisch@microsoft.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 14, 2026 at 11:25:18AM +0900, Michael Paquier wrote:
> reindexdb --schema has the idea of not quoting the schema given in
> input of the command line. For example, if a schema uses upper-case
> characters, the command could fail. Perhaps a fmtIdEnc() should be
> applied, in the same fashion as --tablespace? This point has come
> from Alvaro, during a recent review for a separate patch.
>
> Here is the suggested change:
> case REINDEX_SCHEMA:
> - appendPQExpBufferStr(sql, name);
> + appendPQExpBufferStr(sql, fmtIdEnc(name, PQclientEncoding(conn)));
>
> There may be a point in treating that as a bug, but that's also a
> backward-incompatible change so perhaps that could just be left as-is.
> The new quoting behavior feels upgraded to me, though, but perhaps I'm
> just biased.

I think the change is mildly positive on balance. The rule would then be that
possibly-schema-qualified options like --table need interior quoting, but
single-name options don't. So a shell invocation would use
--table='"Embedded""QuoteNSP"."T"' but would use
--schema='Embedded"QuoteNSP'. I wouldn't back-patch it, though.

> --- a/doc/src/sgml/ref/reindexdb.sgml
> +++ b/doc/src/sgml/ref/reindexdb.sgml
> @@ -210,6 +210,7 @@ PostgreSQL documentation
> <listitem>
> <para>
> Reindex <replaceable class="parameter">schema</replaceable> only.
> + (This name is processed as a double-quoted identifier.)

While this wording is copied from --tablespace, I think it unhelpfully implies
that "" inside the name will reduce to ", which is not the case. It would be
more precise to say that the argument is treated as a literal schema name, not
as an SQL identifier that needs parsing. (Passing the value through the shell
may still require quoting at that level.) Something like that.
Alternatively, perhaps say nothing. If someone passes a quoted name here,
they'll tend to get a clean error.

The --table and --index options have more acute need for docs, since their
parsing is more complex.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2026-11-14 20:35:52 Re: Hash index: stop registering pin-only bucket pages in WAL (remove REGBUF_NO_CHANGE)
Previous Message Andres Freund 2026-11-14 18:25:41 Re: {heap,minimal}_expand_tuple() are unused