Convert *GetDatum() and DatumGet*() macros to inline functions
The previous macro implementations just cast the argument to a target type but did not check whether the input type was appropriate. The function implementation can do better type checking of the input type. Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://www.postgresql.org/message-id/flat/8528fb7e-0aa2-6b54-85fb-0c0886dbd6ed%40enterprisedb.com
This commit is contained in:
parent
8cb2a22bbb
commit
595836e99b
@ -51,7 +51,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/* Oid subtype = PG_GETARG_OID(3); */
|
/* Oid subtype = PG_GETARG_OID(3); */
|
||||||
bool *recheck = (bool *) PG_GETARG_POINTER(4);
|
bool *recheck = (bool *) PG_GETARG_POINTER(4);
|
||||||
bool retval;
|
bool retval = false; /* silence compiler warning */
|
||||||
|
|
||||||
/* this is exact except for RTSameStrategyNumber */
|
/* this is exact except for RTSameStrategyNumber */
|
||||||
*recheck = (strategy == RTSameStrategyNumber);
|
*recheck = (strategy == RTSameStrategyNumber);
|
||||||
|
@ -2763,7 +2763,7 @@ c_overpaid(PG_FUNCTION_ARGS)
|
|||||||
is null. <function>GetAttributeByName</function> returns a <type>Datum</type>
|
is null. <function>GetAttributeByName</function> returns a <type>Datum</type>
|
||||||
value that you can convert to the proper data type by using the
|
value that you can convert to the proper data type by using the
|
||||||
appropriate <function>DatumGet<replaceable>XXX</replaceable>()</function>
|
appropriate <function>DatumGet<replaceable>XXX</replaceable>()</function>
|
||||||
macro. Note that the return value is meaningless if the null flag is
|
function. Note that the return value is meaningless if the null flag is
|
||||||
set; always check the null flag before trying to do anything with the
|
set; always check the null flag before trying to do anything with the
|
||||||
result.
|
result.
|
||||||
</para>
|
</para>
|
||||||
|
@ -280,7 +280,7 @@ gistMakeUnionKey(GISTSTATE *giststate, int attno,
|
|||||||
bool
|
bool
|
||||||
gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
|
gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result = false; /* silence compiler warning */
|
||||||
|
|
||||||
FunctionCall3Coll(&giststate->equalFn[attno],
|
FunctionCall3Coll(&giststate->equalFn[attno],
|
||||||
giststate->supportCollation[attno],
|
giststate->supportCollation[attno],
|
||||||
|
@ -354,7 +354,7 @@ void
|
|||||||
parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
|
parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
|
||||||
{
|
{
|
||||||
int type,
|
int type,
|
||||||
lenlemm;
|
lenlemm = 0; /* silence compiler warning */
|
||||||
char *lemm = NULL;
|
char *lemm = NULL;
|
||||||
LexizeData ldata;
|
LexizeData ldata;
|
||||||
TSLexeme *norms;
|
TSLexeme *norms;
|
||||||
@ -529,7 +529,7 @@ void
|
|||||||
hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query, char *buf, int buflen)
|
hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query, char *buf, int buflen)
|
||||||
{
|
{
|
||||||
int type,
|
int type,
|
||||||
lenlemm;
|
lenlemm = 0; /* silence compiler warning */
|
||||||
char *lemm = NULL;
|
char *lemm = NULL;
|
||||||
LexizeData ldata;
|
LexizeData ldata;
|
||||||
TSLexeme *norms;
|
TSLexeme *norms;
|
||||||
|
@ -409,8 +409,8 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
|||||||
(void) OidFunctionCall6(proc,
|
(void) OidFunctionCall6(proc,
|
||||||
Int32GetDatum(src_encoding),
|
Int32GetDatum(src_encoding),
|
||||||
Int32GetDatum(dest_encoding),
|
Int32GetDatum(dest_encoding),
|
||||||
CStringGetDatum(src),
|
CStringGetDatum((char *) src),
|
||||||
CStringGetDatum(result),
|
CStringGetDatum((char *) result),
|
||||||
Int32GetDatum(len),
|
Int32GetDatum(len),
|
||||||
BoolGetDatum(false));
|
BoolGetDatum(false));
|
||||||
|
|
||||||
@ -485,8 +485,8 @@ pg_do_encoding_conversion_buf(Oid proc,
|
|||||||
result = OidFunctionCall6(proc,
|
result = OidFunctionCall6(proc,
|
||||||
Int32GetDatum(src_encoding),
|
Int32GetDatum(src_encoding),
|
||||||
Int32GetDatum(dest_encoding),
|
Int32GetDatum(dest_encoding),
|
||||||
CStringGetDatum(src),
|
CStringGetDatum((char *) src),
|
||||||
CStringGetDatum(dest),
|
CStringGetDatum((char *) dest),
|
||||||
Int32GetDatum(srclen),
|
Int32GetDatum(srclen),
|
||||||
BoolGetDatum(noError));
|
BoolGetDatum(noError));
|
||||||
return DatumGetInt32(result);
|
return DatumGetInt32(result);
|
||||||
@ -910,8 +910,8 @@ pg_unicode_to_server(pg_wchar c, unsigned char *s)
|
|||||||
FunctionCall6(Utf8ToServerConvProc,
|
FunctionCall6(Utf8ToServerConvProc,
|
||||||
Int32GetDatum(PG_UTF8),
|
Int32GetDatum(PG_UTF8),
|
||||||
Int32GetDatum(server_encoding),
|
Int32GetDatum(server_encoding),
|
||||||
CStringGetDatum(c_as_utf8),
|
CStringGetDatum((char *) c_as_utf8),
|
||||||
CStringGetDatum(s),
|
CStringGetDatum((char *) s),
|
||||||
Int32GetDatum(c_as_utf8_len),
|
Int32GetDatum(c_as_utf8_len),
|
||||||
BoolGetDatum(false));
|
BoolGetDatum(false));
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,18 @@ typedef char GinTernaryValue;
|
|||||||
#define GIN_MAYBE 2 /* don't know if item is present / don't know
|
#define GIN_MAYBE 2 /* don't know if item is present / don't know
|
||||||
* if matches */
|
* if matches */
|
||||||
|
|
||||||
#define DatumGetGinTernaryValue(X) ((GinTernaryValue)(X))
|
static inline GinTernaryValue
|
||||||
#define GinTernaryValueGetDatum(X) ((Datum)(X))
|
DatumGetGinTernaryValue(Datum X)
|
||||||
|
{
|
||||||
|
return (GinTernaryValue) X;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
GinTernaryValueGetDatum(GinTernaryValue X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
|
#define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
|
||||||
|
|
||||||
/* GUC parameters */
|
/* GUC parameters */
|
||||||
|
@ -204,7 +204,7 @@ extern TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple);
|
|||||||
* Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple) - convert a
|
* Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple) - convert a
|
||||||
* HeapTupleHeader to a Datum.
|
* HeapTupleHeader to a Datum.
|
||||||
*
|
*
|
||||||
* Macro declarations:
|
* Inline declarations:
|
||||||
* HeapTupleGetDatum(HeapTuple tuple) - convert a HeapTuple to a Datum.
|
* HeapTupleGetDatum(HeapTuple tuple) - convert a HeapTuple to a Datum.
|
||||||
*
|
*
|
||||||
* Obsolete routines and macros:
|
* Obsolete routines and macros:
|
||||||
@ -217,10 +217,6 @@ extern TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple);
|
|||||||
*----------
|
*----------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define HeapTupleGetDatum(tuple) HeapTupleHeaderGetDatum((tuple)->t_data)
|
|
||||||
/* obsolete version of above */
|
|
||||||
#define TupleGetDatum(_slot, _tuple) HeapTupleGetDatum(_tuple)
|
|
||||||
|
|
||||||
extern TupleDesc RelationNameGetTupleDesc(const char *relname);
|
extern TupleDesc RelationNameGetTupleDesc(const char *relname);
|
||||||
extern TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases);
|
extern TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases);
|
||||||
|
|
||||||
@ -230,6 +226,14 @@ extern AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc);
|
|||||||
extern HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values);
|
extern HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values);
|
||||||
extern Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple);
|
extern Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple);
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
HeapTupleGetDatum(const HeapTupleData *tuple)
|
||||||
|
{
|
||||||
|
return HeapTupleHeaderGetDatum(tuple->t_data);
|
||||||
|
}
|
||||||
|
/* obsolete version of above */
|
||||||
|
#define TupleGetDatum(_slot, _tuple) HeapTupleGetDatum(_tuple)
|
||||||
|
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
* Support for Set Returning Functions (SRFs)
|
* Support for Set Returning Functions (SRFs)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* section description
|
* section description
|
||||||
* ------- ------------------------------------------------
|
* ------- ------------------------------------------------
|
||||||
* 1) variable-length datatypes (TOAST support)
|
* 1) variable-length datatypes (TOAST support)
|
||||||
* 2) Datum type + support macros
|
* 2) Datum type + support functions
|
||||||
* 3) miscellaneous
|
* 3) miscellaneous
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
@ -395,7 +395,7 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* Section 2: Datum type + support macros
|
* Section 2: Datum type + support functions
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ typedef struct
|
|||||||
*
|
*
|
||||||
* sizeof(Datum) == sizeof(void *) == 4 or 8
|
* sizeof(Datum) == sizeof(void *) == 4 or 8
|
||||||
*
|
*
|
||||||
* The macros below and the analogous macros for other types should be used to
|
* The functions below and the analogous functions for other types should be used to
|
||||||
* convert between a Datum and the appropriate C type.
|
* convert between a Datum and the appropriate C type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -434,8 +434,11 @@ typedef struct NullableDatum
|
|||||||
*
|
*
|
||||||
* Note: any nonzero value will be considered true.
|
* Note: any nonzero value will be considered true.
|
||||||
*/
|
*/
|
||||||
|
static inline bool
|
||||||
#define DatumGetBool(X) ((bool) ((X) != 0))
|
DatumGetBool(Datum X)
|
||||||
|
{
|
||||||
|
return (X != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BoolGetDatum
|
* BoolGetDatum
|
||||||
@ -443,162 +446,231 @@ typedef struct NullableDatum
|
|||||||
*
|
*
|
||||||
* Note: any nonzero value will be considered true.
|
* Note: any nonzero value will be considered true.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define BoolGetDatum(X) ((Datum) ((X) ? 1 : 0))
|
BoolGetDatum(bool X)
|
||||||
|
{
|
||||||
|
return (Datum) (X ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetChar
|
* DatumGetChar
|
||||||
* Returns character value of a datum.
|
* Returns character value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline char
|
||||||
#define DatumGetChar(X) ((char) (X))
|
DatumGetChar(Datum X)
|
||||||
|
{
|
||||||
|
return (char) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CharGetDatum
|
* CharGetDatum
|
||||||
* Returns datum representation for a character.
|
* Returns datum representation for a character.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define CharGetDatum(X) ((Datum) (X))
|
CharGetDatum(char X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Int8GetDatum
|
* Int8GetDatum
|
||||||
* Returns datum representation for an 8-bit integer.
|
* Returns datum representation for an 8-bit integer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define Int8GetDatum(X) ((Datum) (X))
|
Int8GetDatum(int8 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetUInt8
|
* DatumGetUInt8
|
||||||
* Returns 8-bit unsigned integer value of a datum.
|
* Returns 8-bit unsigned integer value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline uint8
|
||||||
#define DatumGetUInt8(X) ((uint8) (X))
|
DatumGetUInt8(Datum X)
|
||||||
|
{
|
||||||
|
return (uint8) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UInt8GetDatum
|
* UInt8GetDatum
|
||||||
* Returns datum representation for an 8-bit unsigned integer.
|
* Returns datum representation for an 8-bit unsigned integer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define UInt8GetDatum(X) ((Datum) (X))
|
UInt8GetDatum(uint8 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetInt16
|
* DatumGetInt16
|
||||||
* Returns 16-bit integer value of a datum.
|
* Returns 16-bit integer value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline int16
|
||||||
#define DatumGetInt16(X) ((int16) (X))
|
DatumGetInt16(Datum X)
|
||||||
|
{
|
||||||
|
return (int16) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Int16GetDatum
|
* Int16GetDatum
|
||||||
* Returns datum representation for a 16-bit integer.
|
* Returns datum representation for a 16-bit integer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define Int16GetDatum(X) ((Datum) (X))
|
Int16GetDatum(int16 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetUInt16
|
* DatumGetUInt16
|
||||||
* Returns 16-bit unsigned integer value of a datum.
|
* Returns 16-bit unsigned integer value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline uint16
|
||||||
#define DatumGetUInt16(X) ((uint16) (X))
|
DatumGetUInt16(Datum X)
|
||||||
|
{
|
||||||
|
return (uint16) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UInt16GetDatum
|
* UInt16GetDatum
|
||||||
* Returns datum representation for a 16-bit unsigned integer.
|
* Returns datum representation for a 16-bit unsigned integer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define UInt16GetDatum(X) ((Datum) (X))
|
UInt16GetDatum(uint16 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetInt32
|
* DatumGetInt32
|
||||||
* Returns 32-bit integer value of a datum.
|
* Returns 32-bit integer value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline int32
|
||||||
#define DatumGetInt32(X) ((int32) (X))
|
DatumGetInt32(Datum X)
|
||||||
|
{
|
||||||
|
return (int32) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Int32GetDatum
|
* Int32GetDatum
|
||||||
* Returns datum representation for a 32-bit integer.
|
* Returns datum representation for a 32-bit integer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define Int32GetDatum(X) ((Datum) (X))
|
Int32GetDatum(int32 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetUInt32
|
* DatumGetUInt32
|
||||||
* Returns 32-bit unsigned integer value of a datum.
|
* Returns 32-bit unsigned integer value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline uint32
|
||||||
#define DatumGetUInt32(X) ((uint32) (X))
|
DatumGetUInt32(Datum X)
|
||||||
|
{
|
||||||
|
return (uint32) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UInt32GetDatum
|
* UInt32GetDatum
|
||||||
* Returns datum representation for a 32-bit unsigned integer.
|
* Returns datum representation for a 32-bit unsigned integer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define UInt32GetDatum(X) ((Datum) (X))
|
UInt32GetDatum(uint32 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetObjectId
|
* DatumGetObjectId
|
||||||
* Returns object identifier value of a datum.
|
* Returns object identifier value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline Oid
|
||||||
#define DatumGetObjectId(X) ((Oid) (X))
|
DatumGetObjectId(Datum X)
|
||||||
|
{
|
||||||
|
return (Oid) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ObjectIdGetDatum
|
* ObjectIdGetDatum
|
||||||
* Returns datum representation for an object identifier.
|
* Returns datum representation for an object identifier.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define ObjectIdGetDatum(X) ((Datum) (X))
|
ObjectIdGetDatum(Oid X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetTransactionId
|
* DatumGetTransactionId
|
||||||
* Returns transaction identifier value of a datum.
|
* Returns transaction identifier value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline TransactionId
|
||||||
#define DatumGetTransactionId(X) ((TransactionId) (X))
|
DatumGetTransactionId(Datum X)
|
||||||
|
{
|
||||||
|
return (TransactionId) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TransactionIdGetDatum
|
* TransactionIdGetDatum
|
||||||
* Returns datum representation for a transaction identifier.
|
* Returns datum representation for a transaction identifier.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define TransactionIdGetDatum(X) ((Datum) (X))
|
TransactionIdGetDatum(TransactionId X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MultiXactIdGetDatum
|
* MultiXactIdGetDatum
|
||||||
* Returns datum representation for a multixact identifier.
|
* Returns datum representation for a multixact identifier.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define MultiXactIdGetDatum(X) ((Datum) (X))
|
MultiXactIdGetDatum(MultiXactId X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetCommandId
|
* DatumGetCommandId
|
||||||
* Returns command identifier value of a datum.
|
* Returns command identifier value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline CommandId
|
||||||
#define DatumGetCommandId(X) ((CommandId) (X))
|
DatumGetCommandId(Datum X)
|
||||||
|
{
|
||||||
|
return (CommandId) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CommandIdGetDatum
|
* CommandIdGetDatum
|
||||||
* Returns datum representation for a command identifier.
|
* Returns datum representation for a command identifier.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define CommandIdGetDatum(X) ((Datum) (X))
|
CommandIdGetDatum(CommandId X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetPointer
|
* DatumGetPointer
|
||||||
* Returns pointer value of a datum.
|
* Returns pointer value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline Pointer
|
||||||
#define DatumGetPointer(X) ((Pointer) (X))
|
DatumGetPointer(Datum X)
|
||||||
|
{
|
||||||
|
return (Pointer) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PointerGetDatum
|
* PointerGetDatum
|
||||||
* Returns datum representation for a pointer.
|
* Returns datum representation for a pointer.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define PointerGetDatum(X) ((Datum) (X))
|
PointerGetDatum(const void *X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetCString
|
* DatumGetCString
|
||||||
@ -607,8 +679,11 @@ typedef struct NullableDatum
|
|||||||
* Note: C string is not a full-fledged Postgres type at present,
|
* Note: C string is not a full-fledged Postgres type at present,
|
||||||
* but type input functions use this conversion for their inputs.
|
* but type input functions use this conversion for their inputs.
|
||||||
*/
|
*/
|
||||||
|
static inline char *
|
||||||
#define DatumGetCString(X) ((char *) DatumGetPointer(X))
|
DatumGetCString(Datum X)
|
||||||
|
{
|
||||||
|
return (char *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStringGetDatum
|
* CStringGetDatum
|
||||||
@ -619,15 +694,21 @@ typedef struct NullableDatum
|
|||||||
* Note: CString is pass-by-reference; caller must ensure the pointed-to
|
* Note: CString is pass-by-reference; caller must ensure the pointed-to
|
||||||
* value has adequate lifetime.
|
* value has adequate lifetime.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define CStringGetDatum(X) PointerGetDatum(X)
|
CStringGetDatum(const char *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetName
|
* DatumGetName
|
||||||
* Returns name value of a datum.
|
* Returns name value of a datum.
|
||||||
*/
|
*/
|
||||||
|
static inline Name
|
||||||
#define DatumGetName(X) ((Name) DatumGetPointer(X))
|
DatumGetName(Datum X)
|
||||||
|
{
|
||||||
|
return (Name) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NameGetDatum
|
* NameGetDatum
|
||||||
@ -636,21 +717,27 @@ typedef struct NullableDatum
|
|||||||
* Note: Name is pass-by-reference; caller must ensure the pointed-to
|
* Note: Name is pass-by-reference; caller must ensure the pointed-to
|
||||||
* value has adequate lifetime.
|
* value has adequate lifetime.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
#define NameGetDatum(X) CStringGetDatum(NameStr(*(X)))
|
NameGetDatum(const NameData *X)
|
||||||
|
{
|
||||||
|
return CStringGetDatum(NameStr(*X));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetInt64
|
* DatumGetInt64
|
||||||
* Returns 64-bit integer value of a datum.
|
* Returns 64-bit integer value of a datum.
|
||||||
*
|
*
|
||||||
* Note: this macro hides whether int64 is pass by value or by reference.
|
* Note: this function hides whether int64 is pass by value or by reference.
|
||||||
*/
|
*/
|
||||||
|
static inline int64
|
||||||
|
DatumGetInt64(Datum X)
|
||||||
|
{
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
#define DatumGetInt64(X) ((int64) (X))
|
return (int64) X;
|
||||||
#else
|
#else
|
||||||
#define DatumGetInt64(X) (* ((int64 *) DatumGetPointer(X)))
|
return *((int64 *) DatumGetPointer(X));
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Int64GetDatum
|
* Int64GetDatum
|
||||||
@ -659,25 +746,32 @@ typedef struct NullableDatum
|
|||||||
* Note: if int64 is pass by reference, this function returns a reference
|
* Note: if int64 is pass by reference, this function returns a reference
|
||||||
* to palloc'd space.
|
* to palloc'd space.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
#define Int64GetDatum(X) ((Datum) (X))
|
static inline Datum
|
||||||
|
Int64GetDatum(int64 X)
|
||||||
|
{
|
||||||
|
return (Datum) X;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
extern Datum Int64GetDatum(int64 X);
|
extern Datum Int64GetDatum(int64 X);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatumGetUInt64
|
* DatumGetUInt64
|
||||||
* Returns 64-bit unsigned integer value of a datum.
|
* Returns 64-bit unsigned integer value of a datum.
|
||||||
*
|
*
|
||||||
* Note: this macro hides whether int64 is pass by value or by reference.
|
* Note: this function hides whether int64 is pass by value or by reference.
|
||||||
*/
|
*/
|
||||||
|
static inline uint64
|
||||||
|
DatumGetUInt64(Datum X)
|
||||||
|
{
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
#define DatumGetUInt64(X) ((uint64) (X))
|
return (uint64) X;
|
||||||
#else
|
#else
|
||||||
#define DatumGetUInt64(X) (* ((uint64 *) DatumGetPointer(X)))
|
return *((uint64 *) DatumGetPointer(X));
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UInt64GetDatum
|
* UInt64GetDatum
|
||||||
@ -686,12 +780,15 @@ extern Datum Int64GetDatum(int64 X);
|
|||||||
* Note: if int64 is pass by reference, this function returns a reference
|
* Note: if int64 is pass by reference, this function returns a reference
|
||||||
* to palloc'd space.
|
* to palloc'd space.
|
||||||
*/
|
*/
|
||||||
|
static inline Datum
|
||||||
|
UInt64GetDatum(uint64 X)
|
||||||
|
{
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
#define UInt64GetDatum(X) ((Datum) (X))
|
return (Datum) X;
|
||||||
#else
|
#else
|
||||||
#define UInt64GetDatum(X) Int64GetDatum((int64) (X))
|
return Int64GetDatum((int64) X);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Float <-> Datum conversions
|
* Float <-> Datum conversions
|
||||||
@ -739,13 +836,12 @@ Float4GetDatum(float4 X)
|
|||||||
* DatumGetFloat8
|
* DatumGetFloat8
|
||||||
* Returns 8-byte floating point value of a datum.
|
* Returns 8-byte floating point value of a datum.
|
||||||
*
|
*
|
||||||
* Note: this macro hides whether float8 is pass by value or by reference.
|
* Note: this function hides whether float8 is pass by value or by reference.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
|
||||||
static inline float8
|
static inline float8
|
||||||
DatumGetFloat8(Datum X)
|
DatumGetFloat8(Datum X)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
int64 value;
|
int64 value;
|
||||||
@ -754,10 +850,10 @@ DatumGetFloat8(Datum X)
|
|||||||
|
|
||||||
myunion.value = DatumGetInt64(X);
|
myunion.value = DatumGetInt64(X);
|
||||||
return myunion.retval;
|
return myunion.retval;
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
#define DatumGetFloat8(X) (* ((float8 *) DatumGetPointer(X)))
|
return *((float8 *) DatumGetPointer(X));
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Float8GetDatum
|
* Float8GetDatum
|
||||||
@ -766,7 +862,6 @@ DatumGetFloat8(Datum X)
|
|||||||
* Note: if float8 is pass by reference, this function returns a reference
|
* Note: if float8 is pass by reference, this function returns a reference
|
||||||
* to palloc'd space.
|
* to palloc'd space.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
static inline Datum
|
static inline Datum
|
||||||
Float8GetDatum(float8 X)
|
Float8GetDatum(float8 X)
|
||||||
@ -789,22 +884,34 @@ extern Datum Float8GetDatum(float8 X);
|
|||||||
* Int64GetDatumFast
|
* Int64GetDatumFast
|
||||||
* Float8GetDatumFast
|
* Float8GetDatumFast
|
||||||
*
|
*
|
||||||
* These macros are intended to allow writing code that does not depend on
|
* These functions are intended to allow writing code that does not depend on
|
||||||
* whether int64 and float8 are pass-by-reference types, while not
|
* whether int64 and float8 are pass-by-reference types, while not
|
||||||
* sacrificing performance when they are. The argument must be a variable
|
* sacrificing performance when they are. The argument must be a variable
|
||||||
* that will exist and have the same value for as long as the Datum is needed.
|
* that will exist and have the same value for as long as the Datum is needed.
|
||||||
* In the pass-by-ref case, the address of the variable is taken to use as
|
* In the pass-by-ref case, the address of the variable is taken to use as
|
||||||
* the Datum. In the pass-by-val case, these will be the same as the non-Fast
|
* the Datum. In the pass-by-val case, these will be the same as the non-Fast
|
||||||
* macros.
|
* functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
Int64GetDatumFast(int64 X)
|
||||||
|
{
|
||||||
#ifdef USE_FLOAT8_BYVAL
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
#define Int64GetDatumFast(X) Int64GetDatum(X)
|
return Int64GetDatum(X);
|
||||||
#define Float8GetDatumFast(X) Float8GetDatum(X)
|
|
||||||
#else
|
#else
|
||||||
#define Int64GetDatumFast(X) PointerGetDatum(&(X))
|
return PointerGetDatum(&X);
|
||||||
#define Float8GetDatumFast(X) PointerGetDatum(&(X))
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
Float8GetDatumFast(float8 X)
|
||||||
|
{
|
||||||
|
#ifdef USE_FLOAT8_BYVAL
|
||||||
|
return Float8GetDatum(X);
|
||||||
|
#else
|
||||||
|
return PointerGetDatum(&X);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
|
@ -111,12 +111,27 @@ typedef TSVectorData *TSVector;
|
|||||||
#define POSDATAPTR(x,e) (_POSVECPTR(x,e)->pos)
|
#define POSDATAPTR(x,e) (_POSVECPTR(x,e)->pos)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fmgr interface macros
|
* fmgr interface functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DatumGetTSVector(X) ((TSVector) PG_DETOAST_DATUM(X))
|
static inline TSVector
|
||||||
#define DatumGetTSVectorCopy(X) ((TSVector) PG_DETOAST_DATUM_COPY(X))
|
DatumGetTSVector(Datum X)
|
||||||
#define TSVectorGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (TSVector) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TSVector
|
||||||
|
DatumGetTSVectorCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (TSVector) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
TSVectorGetDatum(const TSVectorData *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_TSVECTOR(n) DatumGetTSVector(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TSVECTOR(n) DatumGetTSVector(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_TSVECTOR_COPY(n) DatumGetTSVectorCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TSVECTOR_COPY(n) DatumGetTSVectorCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_TSVECTOR(x) return TSVectorGetDatum(x)
|
#define PG_RETURN_TSVECTOR(x) return TSVectorGetDatum(x)
|
||||||
@ -227,14 +242,29 @@ typedef TSQueryData *TSQuery;
|
|||||||
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((TSQuery)(x))->size * sizeof(QueryItem) )
|
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((TSQuery)(x))->size * sizeof(QueryItem) )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fmgr interface macros
|
* fmgr interface functions
|
||||||
* Note, TSQuery type marked as plain storage, so it can't be toasted
|
* Note, TSQuery type marked as plain storage, so it can't be toasted
|
||||||
* but PG_DETOAST_DATUM_COPY is used for simplicity
|
* but PG_DETOAST_DATUM_COPY is used for simplicity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DatumGetTSQuery(X) ((TSQuery) DatumGetPointer(X))
|
static inline TSQuery
|
||||||
#define DatumGetTSQueryCopy(X) ((TSQuery) PG_DETOAST_DATUM_COPY(X))
|
DatumGetTSQuery(Datum X)
|
||||||
#define TSQueryGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (TSQuery) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TSQuery
|
||||||
|
DatumGetTSQueryCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (TSQuery) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
TSQueryGetDatum(const TSQueryData *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_TSQUERY(n) DatumGetTSQuery(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TSQUERY(n) DatumGetTSQuery(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_TSQUERY_COPY(n) DatumGetTSQueryCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TSQUERY_COPY(n) DatumGetTSQueryCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_TSQUERY(x) return TSQueryGetDatum(x)
|
#define PG_RETURN_TSQUERY(x) return TSQueryGetDatum(x)
|
||||||
|
@ -243,8 +243,18 @@ typedef uint64 TSQuerySign;
|
|||||||
|
|
||||||
#define TSQS_SIGLEN (sizeof(TSQuerySign)*BITS_PER_BYTE)
|
#define TSQS_SIGLEN (sizeof(TSQuerySign)*BITS_PER_BYTE)
|
||||||
|
|
||||||
#define TSQuerySignGetDatum(X) Int64GetDatum((int64) (X))
|
static inline Datum
|
||||||
#define DatumGetTSQuerySign(X) ((TSQuerySign) DatumGetInt64(X))
|
TSQuerySignGetDatum(TSQuerySign X)
|
||||||
|
{
|
||||||
|
return Int64GetDatum((int64) X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TSQuerySign
|
||||||
|
DatumGetTSQuerySign(Datum X)
|
||||||
|
{
|
||||||
|
return (TSQuerySign) DatumGetInt64(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_RETURN_TSQUERYSIGN(X) return TSQuerySignGetDatum(X)
|
#define PG_RETURN_TSQUERYSIGN(X) return TSQuerySignGetDatum(X)
|
||||||
#define PG_GETARG_TSQUERYSIGN(n) DatumGetTSQuerySign(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TSQUERYSIGN(n) DatumGetTSQuerySign(PG_GETARG_DATUM(n))
|
||||||
|
|
||||||
|
@ -17,8 +17,18 @@
|
|||||||
typedef int64 Cash;
|
typedef int64 Cash;
|
||||||
|
|
||||||
/* Cash is pass-by-reference if and only if int64 is */
|
/* Cash is pass-by-reference if and only if int64 is */
|
||||||
#define DatumGetCash(X) ((Cash) DatumGetInt64(X))
|
static inline Cash
|
||||||
#define CashGetDatum(X) Int64GetDatum(X)
|
DatumGetCash(Datum X)
|
||||||
|
{
|
||||||
|
return DatumGetInt64(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
CashGetDatum(Cash X)
|
||||||
|
{
|
||||||
|
return Int64GetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_CASH(n) DatumGetCash(PG_GETARG_DATUM(n))
|
#define PG_GETARG_CASH(n) DatumGetCash(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_CASH(x) return CashGetDatum(x)
|
#define PG_RETURN_CASH(x) return CashGetDatum(x)
|
||||||
|
|
||||||
|
@ -45,18 +45,46 @@ typedef struct
|
|||||||
#define MAX_TIME_PRECISION 6
|
#define MAX_TIME_PRECISION 6
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros for fmgr-callable functions.
|
* Functions for fmgr-callable functions.
|
||||||
*
|
*
|
||||||
* For TimeADT, we make use of the same support routines as for int64.
|
* For TimeADT, we make use of the same support routines as for int64.
|
||||||
* Therefore TimeADT is pass-by-reference if and only if int64 is!
|
* Therefore TimeADT is pass-by-reference if and only if int64 is!
|
||||||
*/
|
*/
|
||||||
#define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X))
|
static inline DateADT
|
||||||
#define DatumGetTimeADT(X) ((TimeADT) DatumGetInt64(X))
|
DatumGetDateADT(Datum X)
|
||||||
#define DatumGetTimeTzADTP(X) ((TimeTzADT *) DatumGetPointer(X))
|
{
|
||||||
|
return (DateADT) DatumGetInt32(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define DateADTGetDatum(X) Int32GetDatum(X)
|
static inline TimeADT
|
||||||
#define TimeADTGetDatum(X) Int64GetDatum(X)
|
DatumGetTimeADT(Datum X)
|
||||||
#define TimeTzADTPGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (TimeADT) DatumGetInt64(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TimeTzADT *
|
||||||
|
DatumGetTimeTzADTP(Datum X)
|
||||||
|
{
|
||||||
|
return (TimeTzADT *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
DateADTGetDatum(DateADT X)
|
||||||
|
{
|
||||||
|
return Int32GetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
TimeADTGetDatum(TimeADT X)
|
||||||
|
{
|
||||||
|
return Int64GetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
TimeTzADTPGetDatum(const TimeTzADT *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_DATEADT(n) DatumGetDateADT(PG_GETARG_DATUM(n))
|
#define PG_GETARG_DATEADT(n) DatumGetDateADT(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_TIMEADT(n) DatumGetTimeADT(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TIMEADT(n) DatumGetTimeADT(PG_GETARG_DATUM(n))
|
||||||
|
@ -133,8 +133,17 @@ struct ExpandedObjectHeader
|
|||||||
* (More of these might be worth inlining later.)
|
* (More of these might be worth inlining later.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define EOHPGetRWDatum(eohptr) PointerGetDatum((eohptr)->eoh_rw_ptr)
|
static inline Datum
|
||||||
#define EOHPGetRODatum(eohptr) PointerGetDatum((eohptr)->eoh_ro_ptr)
|
EOHPGetRWDatum(const struct ExpandedObjectHeader *eohptr)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(eohptr->eoh_rw_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
EOHPGetRODatum(const struct ExpandedObjectHeader *eohptr)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(eohptr->eoh_ro_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Does the Datum represent a writable expanded object? */
|
/* Does the Datum represent a writable expanded object? */
|
||||||
#define DatumIsReadWriteExpandedObject(d, isnull, typlen) \
|
#define DatumIsReadWriteExpandedObject(d, isnull, typlen) \
|
||||||
|
@ -138,10 +138,20 @@ typedef struct ExpandedRecordHeader
|
|||||||
MemoryContextCallback er_mcb;
|
MemoryContextCallback er_mcb;
|
||||||
} ExpandedRecordHeader;
|
} ExpandedRecordHeader;
|
||||||
|
|
||||||
/* fmgr macros for expanded record objects */
|
/* fmgr functions and macros for expanded record objects */
|
||||||
|
static inline Datum
|
||||||
|
ExpandedRecordGetDatum(const ExpandedRecordHeader *erh)
|
||||||
|
{
|
||||||
|
return EOHPGetRWDatum(&erh->hdr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
ExpandedRecordGetRODatum(const ExpandedRecordHeader *erh)
|
||||||
|
{
|
||||||
|
return EOHPGetRODatum(&erh->hdr);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_EXPANDED_RECORD(n) DatumGetExpandedRecord(PG_GETARG_DATUM(n))
|
#define PG_GETARG_EXPANDED_RECORD(n) DatumGetExpandedRecord(PG_GETARG_DATUM(n))
|
||||||
#define ExpandedRecordGetDatum(erh) EOHPGetRWDatum(&(erh)->hdr)
|
|
||||||
#define ExpandedRecordGetRODatum(erh) EOHPGetRODatum(&(erh)->hdr)
|
|
||||||
#define PG_RETURN_EXPANDED_RECORD(x) PG_RETURN_DATUM(ExpandedRecordGetDatum(x))
|
#define PG_RETURN_EXPANDED_RECORD(x) PG_RETURN_DATUM(ExpandedRecordGetDatum(x))
|
||||||
|
|
||||||
/* assorted other macros */
|
/* assorted other macros */
|
||||||
|
@ -166,48 +166,112 @@ typedef struct
|
|||||||
} CIRCLE;
|
} CIRCLE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fmgr interface macros
|
* fmgr interface functions
|
||||||
*
|
*
|
||||||
* Path and Polygon are toastable varlena types, the others are just
|
* Path and Polygon are toastable varlena types, the others are just
|
||||||
* fixed-size pass-by-reference types.
|
* fixed-size pass-by-reference types.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DatumGetPointP(X) ((Point *) DatumGetPointer(X))
|
static inline Point *
|
||||||
#define PointPGetDatum(X) PointerGetDatum(X)
|
DatumGetPointP(Datum X)
|
||||||
|
{
|
||||||
|
return (Point *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
PointPGetDatum(const Point *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_POINT_P(n) DatumGetPointP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_POINT_P(n) DatumGetPointP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_POINT_P(x) return PointPGetDatum(x)
|
#define PG_RETURN_POINT_P(x) return PointPGetDatum(x)
|
||||||
|
|
||||||
#define DatumGetLsegP(X) ((LSEG *) DatumGetPointer(X))
|
static inline LSEG *
|
||||||
#define LsegPGetDatum(X) PointerGetDatum(X)
|
DatumGetLsegP(Datum X)
|
||||||
|
{
|
||||||
|
return (LSEG *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
LsegPGetDatum(const LSEG *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_LSEG_P(n) DatumGetLsegP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_LSEG_P(n) DatumGetLsegP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_LSEG_P(x) return LsegPGetDatum(x)
|
#define PG_RETURN_LSEG_P(x) return LsegPGetDatum(x)
|
||||||
|
|
||||||
#define DatumGetPathP(X) ((PATH *) PG_DETOAST_DATUM(X))
|
static inline PATH *
|
||||||
#define DatumGetPathPCopy(X) ((PATH *) PG_DETOAST_DATUM_COPY(X))
|
DatumGetPathP(Datum X)
|
||||||
#define PathPGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (PATH *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
static inline PATH *
|
||||||
|
DatumGetPathPCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (PATH *) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
PathPGetDatum(const PATH *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_PATH_P(n) DatumGetPathP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_PATH_P(n) DatumGetPathP(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_PATH_P_COPY(n) DatumGetPathPCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_PATH_P_COPY(n) DatumGetPathPCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_PATH_P(x) return PathPGetDatum(x)
|
#define PG_RETURN_PATH_P(x) return PathPGetDatum(x)
|
||||||
|
|
||||||
#define DatumGetLineP(X) ((LINE *) DatumGetPointer(X))
|
static inline LINE *
|
||||||
#define LinePGetDatum(X) PointerGetDatum(X)
|
DatumGetLineP(Datum X)
|
||||||
|
{
|
||||||
|
return (LINE *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
LinePGetDatum(const LINE *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_LINE_P(n) DatumGetLineP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_LINE_P(n) DatumGetLineP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_LINE_P(x) return LinePGetDatum(x)
|
#define PG_RETURN_LINE_P(x) return LinePGetDatum(x)
|
||||||
|
|
||||||
#define DatumGetBoxP(X) ((BOX *) DatumGetPointer(X))
|
static inline BOX *
|
||||||
#define BoxPGetDatum(X) PointerGetDatum(X)
|
DatumGetBoxP(Datum X)
|
||||||
|
{
|
||||||
|
return (BOX *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
BoxPGetDatum(const BOX *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_BOX_P(n) DatumGetBoxP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_BOX_P(n) DatumGetBoxP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_BOX_P(x) return BoxPGetDatum(x)
|
#define PG_RETURN_BOX_P(x) return BoxPGetDatum(x)
|
||||||
|
|
||||||
#define DatumGetPolygonP(X) ((POLYGON *) PG_DETOAST_DATUM(X))
|
static inline POLYGON *
|
||||||
#define DatumGetPolygonPCopy(X) ((POLYGON *) PG_DETOAST_DATUM_COPY(X))
|
DatumGetPolygonP(Datum X)
|
||||||
#define PolygonPGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (POLYGON *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
static inline POLYGON *
|
||||||
|
DatumGetPolygonPCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (POLYGON *) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
PolygonPGetDatum(const POLYGON *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_POLYGON_P(n) DatumGetPolygonP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_POLYGON_P(n) DatumGetPolygonP(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_POLYGON_P_COPY(n) DatumGetPolygonPCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_POLYGON_P_COPY(n) DatumGetPolygonPCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_POLYGON_P(x) return PolygonPGetDatum(x)
|
#define PG_RETURN_POLYGON_P(x) return PolygonPGetDatum(x)
|
||||||
|
|
||||||
#define DatumGetCircleP(X) ((CIRCLE *) DatumGetPointer(X))
|
static inline CIRCLE *
|
||||||
#define CirclePGetDatum(X) PointerGetDatum(X)
|
DatumGetCircleP(Datum X)
|
||||||
|
{
|
||||||
|
return (CIRCLE *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
static inline Datum
|
||||||
|
CirclePGetDatum(const CIRCLE *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_CIRCLE_P(n) DatumGetCircleP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_CIRCLE_P(n) DatumGetCircleP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_CIRCLE_P(x) return CirclePGetDatum(x)
|
#define PG_RETURN_CIRCLE_P(x) return CirclePGetDatum(x)
|
||||||
|
|
||||||
|
@ -119,23 +119,58 @@ typedef struct macaddr8
|
|||||||
/*
|
/*
|
||||||
* fmgr interface macros
|
* fmgr interface macros
|
||||||
*/
|
*/
|
||||||
#define DatumGetInetPP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
|
static inline inet *
|
||||||
#define InetPGetDatum(X) PointerGetDatum(X)
|
DatumGetInetPP(Datum X)
|
||||||
|
{
|
||||||
|
return (inet *) PG_DETOAST_DATUM_PACKED(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
InetPGetDatum(const inet *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_INET_PP(n) DatumGetInetPP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_INET_PP(n) DatumGetInetPP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_INET_P(x) return InetPGetDatum(x)
|
#define PG_RETURN_INET_P(x) return InetPGetDatum(x)
|
||||||
|
|
||||||
/* obsolescent variants */
|
/* obsolescent variants */
|
||||||
#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM(X))
|
static inline inet *
|
||||||
|
DatumGetInetP(Datum X)
|
||||||
|
{
|
||||||
|
return (inet *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
|
||||||
|
|
||||||
/* macaddr is a fixed-length pass-by-reference datatype */
|
/* macaddr is a fixed-length pass-by-reference datatype */
|
||||||
#define DatumGetMacaddrP(X) ((macaddr *) DatumGetPointer(X))
|
static inline macaddr *
|
||||||
#define MacaddrPGetDatum(X) PointerGetDatum(X)
|
DatumGetMacaddrP(Datum X)
|
||||||
|
{
|
||||||
|
return (macaddr *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
MacaddrPGetDatum(const macaddr *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
|
#define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
|
||||||
|
|
||||||
/* macaddr8 is a fixed-length pass-by-reference datatype */
|
/* macaddr8 is a fixed-length pass-by-reference datatype */
|
||||||
#define DatumGetMacaddr8P(X) ((macaddr8 *) DatumGetPointer(X))
|
static inline macaddr8 *
|
||||||
#define Macaddr8PGetDatum(X) PointerGetDatum(X)
|
DatumGetMacaddr8P(Datum X)
|
||||||
|
{
|
||||||
|
return (macaddr8 *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
Macaddr8PGetDatum(const macaddr8 *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_MACADDR8_P(n) DatumGetMacaddr8P(PG_GETARG_DATUM(n))
|
#define PG_GETARG_MACADDR8_P(n) DatumGetMacaddr8P(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_MACADDR8_P(x) return Macaddr8PGetDatum(x)
|
#define PG_RETURN_MACADDR8_P(x) return Macaddr8PGetDatum(x)
|
||||||
|
|
||||||
|
@ -67,14 +67,6 @@ typedef enum
|
|||||||
#define JGINFLAG_HASHED 0x10 /* OR'd into flag if value was hashed */
|
#define JGINFLAG_HASHED 0x10 /* OR'd into flag if value was hashed */
|
||||||
#define JGIN_MAXLENGTH 125 /* max length of text part before hashing */
|
#define JGIN_MAXLENGTH 125 /* max length of text part before hashing */
|
||||||
|
|
||||||
/* Convenience macros */
|
|
||||||
#define DatumGetJsonbP(d) ((Jsonb *) PG_DETOAST_DATUM(d))
|
|
||||||
#define DatumGetJsonbPCopy(d) ((Jsonb *) PG_DETOAST_DATUM_COPY(d))
|
|
||||||
#define JsonbPGetDatum(p) PointerGetDatum(p)
|
|
||||||
#define PG_GETARG_JSONB_P(x) DatumGetJsonbP(PG_GETARG_DATUM(x))
|
|
||||||
#define PG_GETARG_JSONB_P_COPY(x) DatumGetJsonbPCopy(PG_GETARG_DATUM(x))
|
|
||||||
#define PG_RETURN_JSONB_P(x) PG_RETURN_POINTER(x)
|
|
||||||
|
|
||||||
typedef struct JsonbPair JsonbPair;
|
typedef struct JsonbPair JsonbPair;
|
||||||
typedef struct JsonbValue JsonbValue;
|
typedef struct JsonbValue JsonbValue;
|
||||||
|
|
||||||
@ -375,6 +367,29 @@ typedef struct JsonbIterator
|
|||||||
} JsonbIterator;
|
} JsonbIterator;
|
||||||
|
|
||||||
|
|
||||||
|
/* Convenience macros */
|
||||||
|
static inline Jsonb *
|
||||||
|
DatumGetJsonbP(Datum d)
|
||||||
|
{
|
||||||
|
return (Jsonb *) PG_DETOAST_DATUM(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Jsonb *
|
||||||
|
DatumGetJsonbPCopy(Datum d)
|
||||||
|
{
|
||||||
|
return (Jsonb *) PG_DETOAST_DATUM_COPY(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
JsonbPGetDatum(const Jsonb *p)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PG_GETARG_JSONB_P(x) DatumGetJsonbP(PG_GETARG_DATUM(x))
|
||||||
|
#define PG_GETARG_JSONB_P_COPY(x) DatumGetJsonbPCopy(PG_GETARG_DATUM(x))
|
||||||
|
#define PG_RETURN_JSONB_P(x) PG_RETURN_POINTER(x)
|
||||||
|
|
||||||
/* Support functions */
|
/* Support functions */
|
||||||
extern uint32 getJsonbOffset(const JsonbContainer *jc, int index);
|
extern uint32 getJsonbOffset(const JsonbContainer *jc, int index);
|
||||||
extern uint32 getJsonbLength(const JsonbContainer *jc, int index);
|
extern uint32 getJsonbLength(const JsonbContainer *jc, int index);
|
||||||
|
@ -29,8 +29,18 @@ typedef struct
|
|||||||
#define JSONPATH_LAX (0x80000000)
|
#define JSONPATH_LAX (0x80000000)
|
||||||
#define JSONPATH_HDRSZ (offsetof(JsonPath, data))
|
#define JSONPATH_HDRSZ (offsetof(JsonPath, data))
|
||||||
|
|
||||||
#define DatumGetJsonPathP(d) ((JsonPath *) DatumGetPointer(PG_DETOAST_DATUM(d)))
|
static inline JsonPath *
|
||||||
#define DatumGetJsonPathPCopy(d) ((JsonPath *) DatumGetPointer(PG_DETOAST_DATUM_COPY(d)))
|
DatumGetJsonPathP(Datum d)
|
||||||
|
{
|
||||||
|
return (JsonPath *) PG_DETOAST_DATUM(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline JsonPath *
|
||||||
|
DatumGetJsonPathPCopy(Datum d)
|
||||||
|
{
|
||||||
|
return (JsonPath *) PG_DETOAST_DATUM_COPY(d);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_JSONPATH_P(x) DatumGetJsonPathP(PG_GETARG_DATUM(x))
|
#define PG_GETARG_JSONPATH_P(x) DatumGetJsonPathP(PG_GETARG_DATUM(x))
|
||||||
#define PG_GETARG_JSONPATH_P_COPY(x) DatumGetJsonPathPCopy(PG_GETARG_DATUM(x))
|
#define PG_GETARG_JSONPATH_P_COPY(x) DatumGetJsonPathPCopy(PG_GETARG_DATUM(x))
|
||||||
#define PG_RETURN_JSONPATH_P(p) PG_RETURN_POINTER(p)
|
#define PG_RETURN_JSONPATH_P(p) PG_RETURN_POINTER(p)
|
||||||
|
@ -42,11 +42,26 @@ typedef struct
|
|||||||
#define MultirangeIsEmpty(mr) ((mr)->rangeCount == 0)
|
#define MultirangeIsEmpty(mr) ((mr)->rangeCount == 0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fmgr macros for multirange type objects
|
* fmgr functions for multirange type objects
|
||||||
*/
|
*/
|
||||||
#define DatumGetMultirangeTypeP(X) ((MultirangeType *) PG_DETOAST_DATUM(X))
|
static inline MultirangeType *
|
||||||
#define DatumGetMultirangeTypePCopy(X) ((MultirangeType *) PG_DETOAST_DATUM_COPY(X))
|
DatumGetMultirangeTypeP(Datum X)
|
||||||
#define MultirangeTypePGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (MultirangeType *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline MultirangeType *
|
||||||
|
DatumGetMultirangeTypePCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (MultirangeType *) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
MultirangeTypePGetDatum(const MultirangeType *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_MULTIRANGE_P(n) DatumGetMultirangeTypeP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_MULTIRANGE_P(n) DatumGetMultirangeTypeP(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_MULTIRANGE_P_COPY(n) DatumGetMultirangeTypePCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_MULTIRANGE_P_COPY(n) DatumGetMultirangeTypePCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_MULTIRANGE_P(x) return MultirangeTypePGetDatum(x)
|
#define PG_RETURN_MULTIRANGE_P(x) return MultirangeTypePGetDatum(x)
|
||||||
|
@ -56,9 +56,24 @@ typedef struct NumericData *Numeric;
|
|||||||
* fmgr interface macros
|
* fmgr interface macros
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DatumGetNumeric(X) ((Numeric) PG_DETOAST_DATUM(X))
|
static inline Numeric
|
||||||
#define DatumGetNumericCopy(X) ((Numeric) PG_DETOAST_DATUM_COPY(X))
|
DatumGetNumeric(Datum X)
|
||||||
#define NumericGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (Numeric) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Numeric
|
||||||
|
DatumGetNumericCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (Numeric) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
NumericGetDatum(Numeric X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
|
#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
|
#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
|
||||||
|
@ -18,8 +18,17 @@
|
|||||||
#include "access/xlogdefs.h"
|
#include "access/xlogdefs.h"
|
||||||
#include "fmgr.h"
|
#include "fmgr.h"
|
||||||
|
|
||||||
#define DatumGetLSN(X) ((XLogRecPtr) DatumGetInt64(X))
|
static inline XLogRecPtr
|
||||||
#define LSNGetDatum(X) (Int64GetDatum((int64) (X)))
|
DatumGetLSN(Datum X)
|
||||||
|
{
|
||||||
|
return (XLogRecPtr) DatumGetInt64(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
LSNGetDatum(XLogRecPtr X)
|
||||||
|
{
|
||||||
|
return Int64GetDatum((int64) X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_LSN(n) DatumGetLSN(PG_GETARG_DATUM(n))
|
#define PG_GETARG_LSN(n) DatumGetLSN(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_LSN(x) return LSNGetDatum(x)
|
#define PG_RETURN_LSN(x) return LSNGetDatum(x)
|
||||||
|
@ -68,11 +68,26 @@ typedef struct
|
|||||||
} RangeBound;
|
} RangeBound;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fmgr macros for range type objects
|
* fmgr functions for range type objects
|
||||||
*/
|
*/
|
||||||
#define DatumGetRangeTypeP(X) ((RangeType *) PG_DETOAST_DATUM(X))
|
static inline RangeType *
|
||||||
#define DatumGetRangeTypePCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X))
|
DatumGetRangeTypeP(Datum X)
|
||||||
#define RangeTypePGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (RangeType *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline RangeType *
|
||||||
|
DatumGetRangeTypePCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (RangeType *) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
RangeTypePGetDatum(const RangeType *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_RANGE_P(n) DatumGetRangeTypeP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_RANGE_P(n) DatumGetRangeTypeP(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_RANGE_P_COPY(n) DatumGetRangeTypePCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_RANGE_P_COPY(n) DatumGetRangeTypePCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_RANGE_P(x) return RangeTypePGetDatum(x)
|
#define PG_RETURN_RANGE_P(x) return RangeTypePGetDatum(x)
|
||||||
|
@ -19,18 +19,46 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros for fmgr-callable functions.
|
* Functions for fmgr-callable functions.
|
||||||
*
|
*
|
||||||
* For Timestamp, we make use of the same support routines as for int64.
|
* For Timestamp, we make use of the same support routines as for int64.
|
||||||
* Therefore Timestamp is pass-by-reference if and only if int64 is!
|
* Therefore Timestamp is pass-by-reference if and only if int64 is!
|
||||||
*/
|
*/
|
||||||
#define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X))
|
static inline Timestamp
|
||||||
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X))
|
DatumGetTimestamp(Datum X)
|
||||||
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
|
{
|
||||||
|
return (Timestamp) DatumGetInt64(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define TimestampGetDatum(X) Int64GetDatum(X)
|
static inline TimestampTz
|
||||||
#define TimestampTzGetDatum(X) Int64GetDatum(X)
|
DatumGetTimestampTz(Datum X)
|
||||||
#define IntervalPGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (TimestampTz) DatumGetInt64(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Interval *
|
||||||
|
DatumGetIntervalP(Datum X)
|
||||||
|
{
|
||||||
|
return (Interval *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
TimestampGetDatum(Timestamp X)
|
||||||
|
{
|
||||||
|
return Int64GetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
TimestampTzGetDatum(TimestampTz X)
|
||||||
|
{
|
||||||
|
return Int64GetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
IntervalPGetDatum(const Interval *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n))
|
#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n))
|
||||||
|
@ -23,9 +23,20 @@ typedef struct pg_uuid_t
|
|||||||
} pg_uuid_t;
|
} pg_uuid_t;
|
||||||
|
|
||||||
/* fmgr interface macros */
|
/* fmgr interface macros */
|
||||||
#define UUIDPGetDatum(X) PointerGetDatum(X)
|
static inline Datum
|
||||||
|
UUIDPGetDatum(const pg_uuid_t *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_RETURN_UUID_P(X) return UUIDPGetDatum(X)
|
#define PG_RETURN_UUID_P(X) return UUIDPGetDatum(X)
|
||||||
#define DatumGetUUIDP(X) ((pg_uuid_t *) DatumGetPointer(X))
|
|
||||||
|
static inline pg_uuid_t *
|
||||||
|
DatumGetUUIDP(Datum X)
|
||||||
|
{
|
||||||
|
return (pg_uuid_t *) DatumGetPointer(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_UUID_P(X) DatumGetUUIDP(PG_GETARG_DATUM(X))
|
#define PG_GETARG_UUID_P(X) DatumGetUUIDP(PG_GETARG_DATUM(X))
|
||||||
|
|
||||||
#endif /* UUID_H */
|
#endif /* UUID_H */
|
||||||
|
@ -41,9 +41,24 @@ typedef struct
|
|||||||
* BIT and BIT VARYING are toastable varlena types. They are the same
|
* BIT and BIT VARYING are toastable varlena types. They are the same
|
||||||
* as far as representation goes, so we just have one set of macros.
|
* as far as representation goes, so we just have one set of macros.
|
||||||
*/
|
*/
|
||||||
#define DatumGetVarBitP(X) ((VarBit *) PG_DETOAST_DATUM(X))
|
static inline VarBit *
|
||||||
#define DatumGetVarBitPCopy(X) ((VarBit *) PG_DETOAST_DATUM_COPY(X))
|
DatumGetVarBitP(Datum X)
|
||||||
#define VarBitPGetDatum(X) PointerGetDatum(X)
|
{
|
||||||
|
return (VarBit *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline VarBit *
|
||||||
|
DatumGetVarBitPCopy(Datum X)
|
||||||
|
{
|
||||||
|
return (VarBit *) PG_DETOAST_DATUM_COPY(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
VarBitPGetDatum(const VarBit *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_VARBIT_P(n) DatumGetVarBitP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_VARBIT_P(n) DatumGetVarBitP(PG_GETARG_DATUM(n))
|
||||||
#define PG_GETARG_VARBIT_P_COPY(n) DatumGetVarBitPCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_VARBIT_P_COPY(n) DatumGetVarBitPCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_VARBIT_P(x) return VarBitPGetDatum(x)
|
#define PG_RETURN_VARBIT_P(x) return VarBitPGetDatum(x)
|
||||||
|
@ -14,8 +14,18 @@
|
|||||||
|
|
||||||
#include "access/transam.h"
|
#include "access/transam.h"
|
||||||
|
|
||||||
#define DatumGetFullTransactionId(X) (FullTransactionIdFromU64(DatumGetUInt64(X)))
|
static inline FullTransactionId
|
||||||
#define FullTransactionIdGetDatum(X) (UInt64GetDatum(U64FromFullTransactionId(X)))
|
DatumGetFullTransactionId(Datum X)
|
||||||
|
{
|
||||||
|
return FullTransactionIdFromU64(DatumGetUInt64(X));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
FullTransactionIdGetDatum(FullTransactionId X)
|
||||||
|
{
|
||||||
|
return UInt64GetDatum(U64FromFullTransactionId(X));
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_FULLTRANSACTIONID(X) DatumGetFullTransactionId(PG_GETARG_DATUM(X))
|
#define PG_GETARG_FULLTRANSACTIONID(X) DatumGetFullTransactionId(PG_GETARG_DATUM(X))
|
||||||
#define PG_RETURN_FULLTRANSACTIONID(X) return FullTransactionIdGetDatum(X)
|
#define PG_RETURN_FULLTRANSACTIONID(X) return FullTransactionIdGetDatum(X)
|
||||||
|
|
||||||
|
@ -47,8 +47,17 @@ typedef enum
|
|||||||
/* struct PgXmlErrorContext is private to xml.c */
|
/* struct PgXmlErrorContext is private to xml.c */
|
||||||
typedef struct PgXmlErrorContext PgXmlErrorContext;
|
typedef struct PgXmlErrorContext PgXmlErrorContext;
|
||||||
|
|
||||||
#define DatumGetXmlP(X) ((xmltype *) PG_DETOAST_DATUM(X))
|
static inline xmltype *
|
||||||
#define XmlPGetDatum(X) PointerGetDatum(X)
|
DatumGetXmlP(Datum X)
|
||||||
|
{
|
||||||
|
return (xmltype *) PG_DETOAST_DATUM(X);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Datum
|
||||||
|
XmlPGetDatum(const xmltype *X)
|
||||||
|
{
|
||||||
|
return PointerGetDatum(X);
|
||||||
|
}
|
||||||
|
|
||||||
#define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
|
#define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
|
#define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user