From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Mark Dilger <hornschnorter(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: inappropriate use of NameGetDatum macro |
Date: | 2016-09-12 19:55:34 |
Message-ID: | 13677.1473710134@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Mark Dilger <hornschnorter(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Petr Jelinek | 2016-09-12 19:57:39 | Re: Logical Replication WIP |
Previous Message | Andres Freund | 2016-09-12 19:54:13 | Re: Logical Replication WIP |