Re: [PATCH] reindexdb: Fix schema name lookup in parallel mode

From: Takeshi Ideriha <iderihatakeshi(at)gmail(dot)com>
To: "Koshi Shibagaki (Fujitsu)" <shibagaki(dot)koshi(at)fujitsu(dot)com>, "'pgsql-hackers(at)lists(dot)postgresql(dot)org'" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] reindexdb: Fix schema name lookup in parallel mode
Date: 2026-10-21 06:52:40
Message-ID: 663a3ad5-4d2c-498d-b97e-3eb3fba5b95b@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026/10/13 22:07, Koshi Shibagaki (Fujitsu) wrote:
> reindexdb currently interprets --schema differently with -j 2 than
> without it.
>
> For example, in a database testdb containing:
>
> CREATE SCHEMA testschema;
> CREATE TABLE testschema.t (id integer PRIMARY KEY);
>
> these commands behave differently:
>
> reindexdb -d testdb -S TESTSCHEMA
> reindexdb -d testdb -S TESTSCHEMA -j 2
>
> Without -j, TESTSCHEMA is folded to testschema and its index is reindexed.
> With -j 2, the command succeeds without reindexing anything. The same
> problem occurs with -S '"testschema"' (with double-quotes). Also, a nonexistent
> schema causes an error in serial mode but is silently ignored in parallel mode.
>
> Serial mode sends REINDEX SCHEMA to the server. Parallel mode instead
> lists tables by comparing the supplied strings directly with
> pg_namespace.nspname.
>
> The attached v1 patch resolves schema names through regnamespace and
> filters by namespace OID, as vacuumdb does. This handles case folding and
> quoted names, and reports an error for a missing schema. Existing empty
> schemas still succeed. TAP coverage checks case folding, quoted names,
> and a missing schema specified alongside an empty one.
>
> The regnamespace input syntax also differs from REINDEX SCHEMA: it accepts numeric
> OIDs and '-', but does not recognize SQL comments or U&-quoted identifiers. vacuumdb
> uses regnamaspace in both serial and parallel modes. Would this approach be acceptable for
> reindexdb, or should its parallel mode follow REINDEX SCHEMA's input syntax more closely?

+1 for using regnamespace. The fix looks good to me.

I believe accepting schema OID and '-' is not harmful. '-' just matches
nothing and nothing happens. Vacuumdb and the vacuum command have
different syntax. Vacuumdb also accepts numeric schema OIDs but the
vacuum command does not even have a schema option. Even if there is a
schema named "16384", we need to specify it as -S '"16384"' regardless
of the -j option for the new reindexdb.

Regards,
Takeshi Ideriha

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-10-21 07:15:34 Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY
Previous Message Keyerror Smart 2026-10-21 06:43:04 Re: [PATCH]Fix planner's strictness check for JsonExpr