Re: [HACKERS] replace GrantObjectType with ObjectType - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [HACKERS] replace GrantObjectType with ObjectType
Date
Msg-id 20171220153712.ql7akj6wpbfyzunp@alvherre.pgsql
Whole thread Raw
In response to Re: [HACKERS] replace GrantObjectType with ObjectType  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: [HACKERS] replace GrantObjectType with ObjectType
List pgsql-hackers
Peter Eisentraut wrote:
> On 12/19/17 19:56, Michael Paquier wrote:
> > -stringify_adefprivs_objtype(GrantObjectType objtype)
> > +stringify_adefprivs_objtype(ObjectType objtype)
> > [...]
> > +        default:
> > +            elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
> > +            return "???";                /* keep compiler quiet */
> >      }
> > -
> > -    elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
> > -    return "???";                /* keep compiler quiet */
> > Still this portion in 0001 is something that we try to avoid as much
> > as possible, no? I would have thought that all object types should be
> > listed directly so as nothing is missed in the future.
> 
> But we don't really know what such future GRANT commands would actually
> look like.  What would the GRANT syntax corresponding to OBJECT_CAST or
> OBJECT_STATISTIC_EXT be?  I think that's best filled in when we know.

I think Michael's point is that instead of a "default:" clause, this
switch should list all the known values of the enum and throw an
"unsupported object type" error for them.  So whenever somebody adds a
new object type, the compiler will complain that this switch doesn't
handle it and the developer will have to think about this function.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pltcl valgrind output
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] static assertions in C++