On Fri, May 10, 2019 at 05:58:03PM +0200, Julien Rouhaud wrote: > On Fri, May 10, 2019 at 5:33 PM Alvaro Herrera <alvhe...@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
signature.asc
Description: PGP signature