From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Dilger <hornschnorter@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: inappropriate use of NameGetDatum macro
Date: Mon, 12 Sep 2016 15:55:34 -0400
Message-ID: <13677.1473710134@sss.pgh.pa.us> (raw)
In-Reply-To: <EFD8AC94-4C1F-40C1-A5EA-304080089C1B@gmail.com>
References: <EFD8AC94-4C1F-40C1-A5EA-304080089C1B@gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Mark Dilger <hornschnorter@gmail.com> writes:
> there are several places in the code where variables defined as
> (char *) or as (const char *) are passed to the NameGetDatum()
> macro. I believe it would be better form to use CStringGetDatum()
> in these locations. I am aware that these two macros are internally
> the same.
Hm, I agree, this feels wrong. I suppose you could argue that the
called functions are expecting Name pointers not CString pointers,
but that type cheat is happening anyway. It would be better form
to explicitly pass a CString datum if that's what we're passing.
I'm tempted to propose that we redefine NameGetDatum as
#define NameGetDatum(X) CStringGetDatum(NameStr(*(X)))
which should do the same thing at runtime, but would result in a
compile error if what's passed isn't declared as Name (or NameData*).
This would be asymmetrical with the way DatumGetName looks, though.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, hornschnorter@gmail.com
Subject: Re: inappropriate use of NameGetDatum macro
In-Reply-To: <13677.1473710134@sss.pgh.pa.us>
References: <EFD8AC94-4C1F-40C1-A5EA-304080089C1B@gmail.com> <13677.1473710134@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox