Skip to content

Commit 3b81617

Browse files
committed
Make DatumGetInetP() unpack inet datums with a 1-byte header, and add
a new macro, DatumGetInetPP(), that does not. This brings these macros in line with other DatumGet*P() macros. Backpatch to 8.3, where 1-byte header varlenas were introduced.
1 parent 0e1c4b7 commit 3b81617

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/backend/utils/adt/network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ convert_network_to_scalar(Datum value, Oid typid)
907907
case INETOID:
908908
case CIDROID:
909909
{
910-
inet *ip = DatumGetInetP(value);
910+
inet *ip = DatumGetInetPP(value);
911911
int len;
912912
double res;
913913
int i;

src/include/utils/inet.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ typedef struct macaddr
7070
/*
7171
* fmgr interface macros
7272
*/
73-
#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
73+
#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM(X))
74+
#define DatumGetInetPP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
7475
#define InetPGetDatum(X) PointerGetDatum(X)
7576
#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
77+
#define PG_GETARG_INET_PP(n) DatumGetInetP(PG_GETARG_DATUM_PACKED(n))
7678
#define PG_RETURN_INET_P(x) return InetPGetDatum(x)
7779
/* macaddr is a fixed-length pass-by-reference datatype */
7880
#define DatumGetMacaddrP(X) ((macaddr *) DatumGetPointer(X))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy