1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

Be pickier about converting between Name and Datum.

We were misapplying NameGetDatum() to plain C strings in some places.
This worked, because it was just a pointer cast anyway, but it's a type
cheat in some sense.  Use CStringGetDatum instead, and modify the
NameGetDatum macro so it won't compile if applied to something that's
not a pointer to NameData.  This should result in no changes to
generated code, but it is logically cleaner.

Mark Dilger, tweaked a bit by me

Discussion: <EFD8AC94-4C1F-40C1-A5EA-304080089C1B@gmail.com>
This commit is contained in:
Tom Lane
2016-09-13 17:17:48 -04:00
parent fdc79e1909
commit 55c3391d1e
4 changed files with 7 additions and 7 deletions

View File

@ -600,7 +600,7 @@ typedef Datum *DatumPtr;
* value has adequate lifetime.
*/
#define NameGetDatum(X) PointerGetDatum(X)
#define NameGetDatum(X) CStringGetDatum(NameStr(*(X)))
/*
* DatumGetInt64