Skip to content

Commit

Permalink
Make DatumGetInetP() unpack inet datums with a 1-byte header, and add
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hlinnaka committed Nov 8, 2011
1 parent 0e1c4b7 commit 3b81617
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/utils/adt/network.c
Expand Up @@ -907,7 +907,7 @@ convert_network_to_scalar(Datum value, Oid typid)
case INETOID:
case CIDROID:
{
inet *ip = DatumGetInetP(value);
inet *ip = DatumGetInetPP(value);
int len;
double res;
int i;
Expand Down
4 changes: 3 additions & 1 deletion src/include/utils/inet.h
Expand Up @@ -70,9 +70,11 @@ typedef struct macaddr
/*
* fmgr interface macros
*/
#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM(X))
#define DatumGetInetPP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
#define InetPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
#define PG_GETARG_INET_PP(n) DatumGetInetP(PG_GETARG_DATUM_PACKED(n))
#define PG_RETURN_INET_P(x) return InetPGetDatum(x)
/* macaddr is a fixed-length pass-by-reference datatype */
#define DatumGetMacaddrP(X) ((macaddr *) DatumGetPointer(X))
Expand Down

0 comments on commit 3b81617

Please sign in to comment.