Re: deparsing utility commands

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: deparsing utility commands
Date: 2015-02-21 12:22:22
Message-ID: 20150221122222.GB10608@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-02-19 14:39:27 -0300, Alvaro Herrera wrote:
> diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
> index d899dd7..2bbc15d 100644
> --- a/src/backend/catalog/objectaddress.c
> +++ b/src/backend/catalog/objectaddress.c
> @@ -531,6 +531,12 @@ ObjectTypeMap[] =
> { "policy", OBJECT_POLICY }
> };
>
> +ObjectAddress InvalidObjectAddress =
> +{
> + InvalidOid,
> + InvalidOid,
> + 0
> +};

Maybe mark it as a constant? Then it can live in some readonly section.

> +extern ObjectAddress InvalidObjectAddress;
> +
> +#define initObjectAddress(addr, class_id, object_id) \
> + do { \
> + (addr).classId = (class_id); \
> + (addr).objectId = (object_id); \
> + (addr).objectSubId = 0; \
> + } while (0)
> +
> +#define initObjectAddressSub(addr, class_id, object_id, object_sub_id) \
> + do { \
> + (addr).classId = (class_id); \
> + (addr).objectId = (object_id); \
> + (addr).objectSubId = (object_sub_id); \
> + } while (0)
> +

Maybe, based on some precedent, make those ObjectAddressSet(Sub)?() -
the init bit in initObjectAddress sounds to me like like it does more
than setting a couple member variables.

I'd also be inclined to make initObjectAddress use initObjectAddressSub,
but that's reaching the realm of pedantism ;)

To me the change sounds like a good idea - drop/rename are already
handled somewhat generically, and expanding that to the return value for
renames sounds like a natural progression to me.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-02-21 12:29:45 Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1]
Previous Message Andres Freund 2015-02-21 12:13:21 Re: deparsing utility commands