本文整理汇总了C++中DatumGetBool函数的典型用法代码示例。如果您正苦于以下问题:C++ DatumGetBool函数的具体用法?C++ DatumGetBool怎么用?C++ DatumGetBool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DatumGetBool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gbt_dategt
static bool
gbt_dategt(const void *a, const void *b)
{
return DatumGetBool(
DirectFunctionCall2(date_gt, DateADTGetDatum(*((DateADT *) a)), DateADTGetDatum(*((DateADT *) b)))
);
}
示例2: type_is_domain
bool type_is_domain(char *type_name, Oid *base_type) {
bool rc;
StringInfo query;
SPI_connect();
query = makeStringInfo();
appendStringInfo(query, "SELECT typtype = 'd', typbasetype FROM pg_type WHERE typname = %s", TextDatumGetCString(DirectFunctionCall1(quote_literal, CStringGetTextDatum(type_name))));
if (SPI_execute(query->data, true, 1) != SPI_OK_SELECT)
elog(ERROR, "Problem determing if %s is a domain with query: %s", type_name, query->data);
if (SPI_processed == 0) {
rc = false;
} else {
bool isnull;
Datum d;
d = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull);
rc = isnull || DatumGetBool(d);
d = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 2, &isnull);
*base_type = isnull ? InvalidOid : DatumGetObjectId(d);
}
SPI_finish();
return rc;
}
示例3: array_iterator
static bool
array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree **found)
{
int num = ArrayGetNItems(ARR_NDIM(la), ARR_DIMS(la));
ltree *item = (ltree *) ARR_DATA_PTR(la);
if (ARR_NDIM(la) > 1)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("array must be one-dimensional")));
if (array_contains_nulls(la))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("array must not contain nulls")));
if (found)
*found = NULL;
while (num > 0)
{
if (DatumGetBool(DirectFunctionCall2(callback,
PointerGetDatum(item), PointerGetDatum(param))))
{
if (found)
*found = item;
return true;
}
num--;
item = NEXTVAL(item);
}
return false;
}
示例4: gbt_bitlt
static bool
gbt_bitlt(const void *a, const void *b, Oid collation)
{
return DatumGetBool(DirectFunctionCall2(bitlt,
PointerGetDatum(a),
PointerGetDatum(b)));
}
示例5: execTuplesMatch
/*
* execTuplesMatch
* Return true if two tuples match in all the indicated fields.
*
* This actually implements SQL's notion of "not distinct". Two nulls
* match, a null and a not-null don't match.
*
* slot1, slot2: the tuples to compare (must have same columns!)
* numCols: the number of attributes to be examined
* matchColIdx: array of attribute column numbers
* eqFunctions: array of fmgr lookup info for the equality functions to use
* evalContext: short-term memory context for executing the functions
*
* NB: evalContext is reset each time!
*/
bool
execTuplesMatch(TupleTableSlot *slot1,
TupleTableSlot *slot2,
int numCols,
AttrNumber *matchColIdx,
FmgrInfo *eqfunctions,
MemoryContext evalContext)
{
MemoryContext oldContext;
bool result;
int i;
/* Reset and switch into the temp context. */
MemoryContextReset(evalContext);
oldContext = MemoryContextSwitchTo(evalContext);
/*
* We cannot report a match without checking all the fields, but we can
* report a non-match as soon as we find unequal fields. So, start
* comparing at the last field (least significant sort key). That's the
* most likely to be different if we are dealing with sorted input.
*/
result = true;
for (i = numCols; --i >= 0;)
{
AttrNumber att = matchColIdx[i];
Datum attr1,
attr2;
bool isNull1,
isNull2;
attr1 = slot_getattr(slot1, att, &isNull1);
attr2 = slot_getattr(slot2, att, &isNull2);
if (isNull1 != isNull2)
{
result = false; /* one null and one not; they aren't equal */
break;
}
if (isNull1)
continue; /* both are null, treat as equal */
/* Apply the type-specific equality function */
if (!DatumGetBool(FunctionCall2(&eqfunctions[i],
attr1, attr2)))
{
result = false; /* they aren't equal */
break;
}
}
MemoryContextSwitchTo(oldContext);
return result;
}
示例6: tintervalov
/*
* tintervalov - returns true iff tinterval i1 (partially) overlaps i2
*/
Datum
tintervalov(PG_FUNCTION_ARGS)
{
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
if (DatumGetBool(DirectFunctionCall2(abstimelt,
AbsoluteTimeGetDatum(i1->data[1]),
AbsoluteTimeGetDatum(i2->data[0]))) ||
DatumGetBool(DirectFunctionCall2(abstimegt,
AbsoluteTimeGetDatum(i1->data[0]),
AbsoluteTimeGetDatum(i2->data[1]))))
PG_RETURN_BOOL(false);
PG_RETURN_BOOL(true);
}
示例7: gbt_textlt
static bool
gbt_textlt(const void *a, const void *b)
{
return DatumGetBool(DirectFunctionCall2Coll(text_lt,
DEFAULT_COLLATION_OID,
PointerGetDatum(a),
PointerGetDatum(b)));
}
示例8: gbt_textle
static bool
gbt_textle(const void *a, const void *b, Oid collation)
{
return DatumGetBool(DirectFunctionCall2Coll(text_le,
collation,
PointerGetDatum(a),
PointerGetDatum(b)));
}
示例9: GpPersistentRelationNode_GetValues
void GpPersistentRelationNode_GetValues(
Datum *values,
Oid *tablespaceOid,
Oid *databaseOid,
Oid *relfilenodeOid,
int32 *segmentFileNum,
PersistentFileSysRelStorageMgr *relationStorageManager,
PersistentFileSysState *persistentState,
int64 *createMirrorDataLossTrackingSessionNum,
MirroredObjectExistenceState *mirrorExistenceState,
MirroredRelDataSynchronizationState *mirrorDataSynchronizationState,
bool *mirrorBufpoolMarkedForScanIncrementalResync,
int64 *mirrorBufpoolResyncChangedPageCount,
XLogRecPtr *mirrorBufpoolResyncCkptLoc,
BlockNumber *mirrorBufpoolResyncCkptBlockNum,
int64 *mirrorAppendOnlyLossEof,
int64 *mirrorAppendOnlyNewEof,
PersistentFileSysRelBufpoolKind *relBufpoolKind,
TransactionId *parentXid,
int64 *persistentSerialNum)
{
*tablespaceOid = DatumGetObjectId(values[Anum_gp_persistent_relation_node_tablespace_oid - 1]);
*databaseOid = DatumGetObjectId(values[Anum_gp_persistent_relation_node_database_oid - 1]);
*relfilenodeOid = DatumGetObjectId(values[Anum_gp_persistent_relation_node_relfilenode_oid - 1]);
*segmentFileNum = DatumGetInt32(values[Anum_gp_persistent_relation_node_segment_file_num - 1]);
*relationStorageManager = (PersistentFileSysRelStorageMgr)DatumGetInt16(values[Anum_gp_persistent_relation_node_relation_storage_manager - 1]);
*persistentState = (PersistentFileSysState)DatumGetInt16(values[Anum_gp_persistent_relation_node_persistent_state - 1]);
*createMirrorDataLossTrackingSessionNum = DatumGetInt64(values[Anum_gp_persistent_relation_node_create_mirror_data_loss_tracking_session_num - 1]);
*mirrorExistenceState = (MirroredObjectExistenceState)DatumGetInt16(values[Anum_gp_persistent_relation_node_mirror_existence_state - 1]);
*mirrorDataSynchronizationState = (MirroredRelDataSynchronizationState)DatumGetInt16(values[Anum_gp_persistent_relation_node_mirror_data_synchronization_state - 1]);
*mirrorBufpoolMarkedForScanIncrementalResync = DatumGetBool(values[Anum_gp_persistent_relation_node_mirror_bufpool_marked_for_scan_incremental_resync - 1]);
*mirrorBufpoolResyncChangedPageCount = DatumGetInt64(values[Anum_gp_persistent_relation_node_mirror_bufpool_resync_changed_page_count - 1]);
*mirrorBufpoolResyncCkptLoc = *((XLogRecPtr*) DatumGetPointer(values[Anum_gp_persistent_relation_node_mirror_bufpool_resync_ckpt_loc - 1]));
*mirrorBufpoolResyncCkptBlockNum = (BlockNumber)DatumGetInt32(values[Anum_gp_persistent_relation_node_mirror_bufpool_resync_ckpt_block_num - 1]);
*mirrorAppendOnlyLossEof = DatumGetInt64(values[Anum_gp_persistent_relation_node_mirror_append_only_loss_eof - 1]);
*mirrorAppendOnlyNewEof = DatumGetInt64(values[Anum_gp_persistent_relation_node_mirror_append_only_new_eof - 1]);
*relBufpoolKind = (PersistentFileSysRelBufpoolKind)DatumGetInt32(values[Anum_gp_persistent_relation_node_relation_bufpool_kind - 1]);
*parentXid = (TransactionId)DatumGetInt32(values[Anum_gp_persistent_relation_node_parent_xid - 1]);
*persistentSerialNum = DatumGetInt64(values[Anum_gp_persistent_relation_node_persistent_serial_num - 1]);
}
示例10: intinterval
/*
* intinterval - returns true iff absolute date is in the tinterval
*/
Datum
intinterval(PG_FUNCTION_ARGS)
{
AbsoluteTime t = PG_GETARG_ABSOLUTETIME(0);
TimeInterval tinterval = PG_GETARG_TIMEINTERVAL(1);
if (tinterval->status == T_INTERVAL_VALID && t != INVALID_ABSTIME)
{
if (DatumGetBool(DirectFunctionCall2(abstimege,
AbsoluteTimeGetDatum(t),
AbsoluteTimeGetDatum(tinterval->data[0]))) &&
DatumGetBool(DirectFunctionCall2(abstimele,
AbsoluteTimeGetDatum(t),
AbsoluteTimeGetDatum(tinterval->data[1]))))
PG_RETURN_BOOL(true);
}
PG_RETURN_BOOL(false);
}
示例11: DatumGetHeapTupleHeader
/**
* Convert postgres Datum into a ConcreteValue object.
*/
AbstractValueSPtr AbstractPGValue::DatumToValue(bool inMemoryIsWritable,
Oid inTypeID, Datum inDatum) const {
// First check if datum is rowtype
if (type_is_rowtype(inTypeID)) {
HeapTupleHeader pgTuple = DatumGetHeapTupleHeader(inDatum);
return AbstractValueSPtr(new PGValue<HeapTupleHeader>(pgTuple));
} else if (type_is_array(inTypeID)) {
ArrayType *pgArray = DatumGetArrayTypeP(inDatum);
if (ARR_NDIM(pgArray) != 1)
throw std::invalid_argument("Multidimensional arrays not yet supported");
if (ARR_HASNULL(pgArray))
throw std::invalid_argument("Arrays with NULLs not yet supported");
switch (ARR_ELEMTYPE(pgArray)) {
case FLOAT8OID: {
MemHandleSPtr memoryHandle(new PGArrayHandle(pgArray));
if (inMemoryIsWritable) {
return AbstractValueSPtr(
new ConcreteValue<Array<double> >(
Array<double>(memoryHandle,
boost::extents[ ARR_DIMS(pgArray)[0] ])
)
);
} else {
return AbstractValueSPtr(
new ConcreteValue<Array_const<double> >(
Array_const<double>(memoryHandle,
boost::extents[ ARR_DIMS(pgArray)[0] ])
)
);
}
}
}
}
switch (inTypeID) {
case BOOLOID: return AbstractValueSPtr(
new ConcreteValue<bool>( DatumGetBool(inDatum) ));
case INT2OID: return AbstractValueSPtr(
new ConcreteValue<int16_t>( DatumGetInt16(inDatum) ));
case INT4OID: return AbstractValueSPtr(
new ConcreteValue<int32_t>( DatumGetInt32(inDatum) ));
case INT8OID: return AbstractValueSPtr(
new ConcreteValue<int64_t>( DatumGetInt64(inDatum) ));
case FLOAT4OID: return AbstractValueSPtr(
new ConcreteValue<float>( DatumGetFloat4(inDatum) ));
case FLOAT8OID: return AbstractValueSPtr(
new ConcreteValue<double>( DatumGetFloat8(inDatum) ));
}
return AbstractValueSPtr();
}
示例12: gbt_tsle
static bool
gbt_tsle(const void *a, const void *b, FmgrInfo *flinfo)
{
const Timestamp *aa = (const Timestamp *) a;
const Timestamp *bb = (const Timestamp *) b;
return DatumGetBool(DirectFunctionCall2(timestamp_le,
TimestampGetDatumFast(*aa),
TimestampGetDatumFast(*bb)));
}
示例13: gbt_timelt
static bool
gbt_timelt(const void *a, const void *b)
{
const TimeADT *aa = (const TimeADT *) a;
const TimeADT *bb = (const TimeADT *) b;
return DatumGetBool(DirectFunctionCall2(time_lt,
TimeADTGetDatumFast(*aa),
TimeADTGetDatumFast(*bb)));
}
示例14: gbt_tslt
static bool
gbt_tslt(const void *a, const void *b)
{
const Timestamp *aa = (const Timestamp *) a;
const Timestamp *bb = (const Timestamp *) b;
return DatumGetBool(DirectFunctionCall2(timestamp_lt,
TimestampGetDatumFast(*aa),
TimestampGetDatumFast(*bb)));
}
示例15: ipaddr_comparison_bool
static inline
bool
ipaddr_comparison_bool(Datum d1, Datum d2,
bool mismatch_af1, bool mismatch_af2,
PGFunction ip4func, PGFunction ip6func)
{
IP_P ipp1 = DatumGetIP_P(d1);
IP_P ipp2 = DatumGetIP_P(d2);
IP ip1;
IP ip2;
int af1 = ip_unpack(ipp1, &ip1);
int af2 = ip_unpack(ipp2, &ip2);
bool retval;
if (af1 != af2)
{
retval = (af1 > af2) ? mismatch_af1 : mismatch_af2;
}
else
{
switch (af1)
{
case PGSQL_AF_INET:
retval = DatumGetBool(DirectFunctionCall2(ip4func, IP4GetDatum(ip1.ip4), IP4GetDatum(ip2.ip4)));
break;
case PGSQL_AF_INET6:
retval = DatumGetBool(DirectFunctionCall2(ip6func, IP6PGetDatum(&ip1.ip6), IP6PGetDatum(&ip2.ip6)));
break;
default:
ipaddr_internal_error();
}
}
if ((Pointer)ipp1 != DatumGetPointer(d1))
pfree(ipp1);
if ((Pointer)ipp2 != DatumGetPointer(d2))
pfree(ipp2);
return retval;
}