Re: Bug in reindexdb's error reporting
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-05-11T00:42:00Z
Lists: pgsql-hackers
On Fri, May 10, 2019 at 05:58:03PM +0200, Julien Rouhaud wrote:
> On Fri, May 10, 2019 at 5:33 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>> I did have the same thought. It seem clear now that we should do it :-)
>> ISTM that the way to fix that problem is to use the proposed enum
>> everywhere and turn it into a string when generating the SQL command,
>> not before.
>
> ok :) Patch v2 attached.
The refactoring bits are fine for HEAD. For back-branches I would
suggest using the simplest patch of upthread.
> +typedef enum ReindexType {
> + DATABASE,
> + SCHEMA,
> + TABLE,
> + INDEX
> +} ReindexType;
That's perhaps too much generic when it comes to grep in the source
code, why not appending REINDEX_ to each element?
> + switch(type)
> + {
> + case DATABASE:
> + appendPQExpBufferStr(&sql, "DATABASE");
> + break;
> + case SCHEMA:
> + appendPQExpBufferStr(&sql, "SCHEMA");
> + break;
> + case TABLE:
> + appendPQExpBufferStr(&sql, "TABLE");
> + break;
> + case INDEX:
> + appendPQExpBufferStr(&sql, "INDEX");
> + break;
> + default:
> + pg_log_error("Unrecognized reindex type %d", type);
> + exit(1);
> + break;
> + }
We could actually remove this default part, so as we get compiler
warning when introducing a new element.
--
Michael
Commits
-
Fix error reporting in reindexdb
- 82ed20e15e52 9.4.23 landed
- e17fba8d8f13 9.5.18 landed
- 0c132d4581c2 9.6.14 landed
- c6354e94304c 10.9 landed
- e16ab408f3db 11.4 landed
- e51bad8fb4c3 12.0 landed