Re: Bug in reindexdb's error reporting

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bug in reindexdb's error reporting
Date: 2019-05-11 00:42:00
Message-ID: 20190511004200.GA2274@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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(at)2ndquadrant(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2019-05-11 01:02:41 Re: pg12 release notes
Previous Message Bruce Momjian 2019-05-11 00:32:31 Re: pg12 release notes