本文整理匯總了C++中DatumGetInt64函數的典型用法代碼示例。如果您正苦於以下問題:C++ DatumGetInt64函數的具體用法?C++ DatumGetInt64怎麽用?C++ DatumGetInt64使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DatumGetInt64函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GpPersistentTablespaceNode_GetValues
void GpPersistentTablespaceNode_GetValues(
Datum *values,
Oid *filespaceOid,
Oid *tablespaceOid,
PersistentFileSysState *persistentState,
int64 *createMirrorDataLossTrackingSessionNum,
MirroredObjectExistenceState *mirrorExistenceState,
int32 *reserved,
TransactionId *parentXid,
int64 *persistentSerialNum)
{
*filespaceOid = DatumGetObjectId(values[Anum_gp_persistent_tablespace_node_filespace_oid - 1]);
*tablespaceOid = DatumGetObjectId(values[Anum_gp_persistent_tablespace_node_tablespace_oid - 1]);
*persistentState = DatumGetInt16(values[Anum_gp_persistent_tablespace_node_persistent_state - 1]);
*createMirrorDataLossTrackingSessionNum = DatumGetInt64(values[Anum_gp_persistent_tablespace_node_create_mirror_data_loss_tracking_session_num - 1]);
*mirrorExistenceState = DatumGetInt16(values[Anum_gp_persistent_tablespace_node_mirror_existence_state - 1]);
*reserved = DatumGetInt32(values[Anum_gp_persistent_tablespace_node_reserved - 1]);
*parentXid = (TransactionId)DatumGetInt32(values[Anum_gp_persistent_tablespace_node_parent_xid - 1]);
*persistentSerialNum = DatumGetInt64(values[Anum_gp_persistent_tablespace_node_persistent_serial_num - 1]);
}
示例2: recompute_limits
/*
* Evaluate the limit/offset expressions --- done at start of each scan.
*
* This is also a handy place to reset the current-position state info.
*/
static void
recompute_limits(LimitState *node)
{
ExprContext *econtext = node->ps.ps_ExprContext;
Datum val;
bool isNull;
if (node->limitOffset)
{
val = ExecEvalExprSwitchContext(node->limitOffset,
econtext,
&isNull,
NULL);
/* Interpret NULL offset as no offset */
if (isNull)
node->offset = 0;
else
{
node->offset = DatumGetInt64(val);
if (node->offset < 0)
node->offset = 0;
}
}
else
{
/* No OFFSET supplied */
node->offset = 0;
}
if (node->limitCount)
{
val = ExecEvalExprSwitchContext(node->limitCount,
econtext,
&isNull,
NULL);
/* Interpret NULL count as no count (LIMIT ALL) */
if (isNull)
{
node->count = 0;
node->noCount = true;
}
else
{
node->count = DatumGetInt64(val);
if (node->count < 0)
node->count = 0;
node->noCount = false;
}
}
else
{
/* No COUNT supplied */
node->count = 0;
node->noCount = true;
}
/* Reset position to start-of-scan */
node->position = 0;
node->subSlot = NULL;
}
示例3: 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]);
}
示例4: PLyLong_FromInt64
static PyObject *
PLyLong_FromInt64(PLyDatumToOb *arg, Datum d)
{
/* on 32 bit platforms "long" may be too small */
if (sizeof(int64) > sizeof(long))
return PyLong_FromLongLong(DatumGetInt64(d));
else
return PyLong_FromLong(DatumGetInt64(d));
}
示例5: GetFastSequences
/*
* GetFastSequences
*
* Get a list of consecutive sequence numbers. The starting sequence
* number is the maximal value between 'lastsequence' + 1 and minSequence.
* The length of the list is given.
*
* If there is not such an entry for objid in the table, create
* one here.
*
* The existing entry for objid in the table is updated with a new
* lastsequence value.
*/
int64 GetFastSequences(Oid objid, int64 objmod,
int64 minSequence, int64 numSequences)
{
Relation gp_fastsequence_rel;
TupleDesc tupleDesc;
HeapTuple tuple;
cqContext cqc;
int64 firstSequence = minSequence;
Datum lastSequenceDatum;
int64 newLastSequence;
gp_fastsequence_rel = heap_open(FastSequenceRelationId, RowExclusiveLock);
tupleDesc = RelationGetDescr(gp_fastsequence_rel);
tuple = caql_getfirst(
caql_addrel(cqclr(&cqc), gp_fastsequence_rel),
cql("SELECT * FROM gp_fastsequence "
" WHERE objid = :1 "
" AND objmod = :2 "
" FOR UPDATE ",
ObjectIdGetDatum(objid),
Int64GetDatum(objmod)));
if (!HeapTupleIsValid(tuple))
{
newLastSequence = firstSequence + numSequences - 1;
}
else
{
bool isNull;
lastSequenceDatum = heap_getattr(tuple, Anum_gp_fastsequence_last_sequence,
tupleDesc, &isNull);
if (isNull)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("got an invalid lastsequence number: NULL")));
if (DatumGetInt64(lastSequenceDatum) + 1 > firstSequence)
firstSequence = DatumGetInt64(lastSequenceDatum) + 1;
newLastSequence = firstSequence + numSequences - 1;
}
update_fastsequence(gp_fastsequence_rel, tuple, tupleDesc,
objid, objmod, newLastSequence);
if (HeapTupleIsValid(tuple))
{
heap_freetuple(tuple);
}
/* Refer to the comment at the end of InsertFastSequenceEntry. */
heap_close(gp_fastsequence_rel, RowExclusiveLock);
return firstSequence;
}
示例6: GpPersistentFilespaceNode_GetValues
void GpPersistentFilespaceNode_GetValues(
Datum *values,
Oid *filespaceOid,
int16 *dbId1,
char locationBlankPadded1[FilespaceLocationBlankPaddedWithNullTermLen],
int16 *dbId2,
char locationBlankPadded2[FilespaceLocationBlankPaddedWithNullTermLen],
PersistentFileSysState *persistentState,
int64 *createMirrorDataLossTrackingSessionNum,
MirroredObjectExistenceState *mirrorExistenceState,
int32 *reserved,
TransactionId *parentXid,
int64 *persistentSerialNum)
{
char *locationPtr;
int locationLen;
*filespaceOid = DatumGetObjectId(values[Anum_gp_persistent_filespace_node_filespace_oid - 1]);
*dbId1 = DatumGetInt16(values[Anum_gp_persistent_filespace_node_db_id_1 - 1]);
locationPtr = TextDatumGetCString(values[Anum_gp_persistent_filespace_node_location_1 - 1]);;
locationLen = strlen(locationPtr);
if (locationLen != FilespaceLocationBlankPaddedWithNullTermLen - 1)
elog(ERROR, "Expected filespace location 1 to be %d characters and found %d",
FilespaceLocationBlankPaddedWithNullTermLen - 1,
locationLen);
memcpy(locationBlankPadded1, locationPtr, FilespaceLocationBlankPaddedWithNullTermLen);
*dbId2 = DatumGetInt16(values[Anum_gp_persistent_filespace_node_db_id_2 - 1]);
locationPtr = TextDatumGetCString(values[Anum_gp_persistent_filespace_node_location_2 - 1]);
locationLen = strlen(locationPtr);
if (locationLen != FilespaceLocationBlankPaddedWithNullTermLen - 1)
elog(ERROR, "Expected filespace location 2 to be %d characters and found %d",
FilespaceLocationBlankPaddedWithNullTermLen - 1,
locationLen);
memcpy(locationBlankPadded2, locationPtr, FilespaceLocationBlankPaddedWithNullTermLen);
*persistentState = DatumGetInt16(values[Anum_gp_persistent_filespace_node_persistent_state - 1]);
*createMirrorDataLossTrackingSessionNum = DatumGetInt64(values[Anum_gp_persistent_filespace_node_create_mirror_data_loss_tracking_session_num - 1]);
*mirrorExistenceState = DatumGetInt16(values[Anum_gp_persistent_filespace_node_mirror_existence_state - 1]);
*reserved = DatumGetInt32(values[Anum_gp_persistent_filespace_node_reserved - 1]);
*parentXid = (TransactionId)DatumGetInt32(values[Anum_gp_persistent_filespace_node_parent_xid - 1]);
*persistentSerialNum = DatumGetInt64(values[Anum_gp_persistent_filespace_node_persistent_serial_num - 1]);
}
示例7: load_consumer_offsets
/*
* load_consumer_offsets
*
* Load all offsets for all of this consumer's partitions
*/
static void
load_consumer_offsets(KafkaConsumer *consumer, struct rd_kafka_metadata_topic *meta, int64_t offset)
{
MemoryContext old;
ScanKeyData skey[1];
HeapTuple tup = NULL;
HeapScanDesc scan;
Relation offsets = open_pipeline_kafka_offsets();
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(offsets));
int i;
ScanKeyInit(&skey[0], OFFSETS_ATTR_CONSUMER, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(consumer->id));
scan = heap_beginscan(offsets, GetTransactionSnapshot(), 1, skey);
old = MemoryContextSwitchTo(CacheMemoryContext);
consumer->offsets = palloc0(meta->partition_cnt * sizeof(int64_t));
MemoryContextSwitchTo(old);
/* by default, begin consuming from the end of a stream */
for (i = 0; i < meta->partition_cnt; i++)
consumer->offsets[i] = offset;
consumer->num_partitions = meta->partition_cnt;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Datum d;
bool isnull;
int partition;
ExecStoreTuple(tup, slot, InvalidBuffer, false);
d = slot_getattr(slot, OFFSETS_ATTR_PARTITION, &isnull);
partition = DatumGetInt32(d);
if(partition > consumer->num_partitions)
elog(ERROR, "invalid partition id: %d", partition);
if (offset == RD_KAFKA_OFFSET_NULL)
{
d = slot_getattr(slot, OFFSETS_ATTR_OFFSET, &isnull);
if (isnull)
offset = RD_KAFKA_OFFSET_END;
else
offset = DatumGetInt64(d);
}
consumer->offsets[partition] = DatumGetInt64(offset);
}
ExecDropSingleTupleTableSlot(slot);
heap_endscan(scan);
heap_close(offsets, RowExclusiveLock);
}
示例8: btint8fastcmp
static int
btint8fastcmp(Datum x, Datum y, SortSupport ssup)
{
int64 a = DatumGetInt64(x);
int64 b = DatumGetInt64(y);
if (a > b)
return 1;
else if (a == b)
return 0;
else
return -1;
}
示例9: btint8fastcmp
static int
btint8fastcmp(Datum x, Datum y, SortSupport ssup)
{
int64 a = DatumGetInt64(x);
int64 b = DatumGetInt64(y);
if (a > b)
return A_GREATER_THAN_B;
else if (a == b)
return 0;
else
return A_LESS_THAN_B;
}
示例10: int8_cash
/* int8_cash()
* Convert int8 (bigint) to cash
*/
Datum
int8_cash(PG_FUNCTION_ARGS)
{
int64 amount = PG_GETARG_INT64(0);
Cash result;
int fpoint;
int64 scale;
int i;
struct lconv *lconvert = PGLC_localeconv();
/* see comments about frac_digits in cash_in() */
fpoint = lconvert->frac_digits;
if (fpoint < 0 || fpoint > 10)
fpoint = 2;
/* compute required scale factor */
scale = 1;
for (i = 0; i < fpoint; i++)
scale *= 10;
/* compute amount * scale, checking for overflow */
result = DatumGetInt64(DirectFunctionCall2(int8mul, Int64GetDatum(amount),
Int64GetDatum(scale)));
PG_RETURN_CASH(result);
}
示例11: numeric_cash
/* numeric_cash()
* Convert numeric to cash.
*/
Datum
numeric_cash(PG_FUNCTION_ARGS)
{
Datum amount = PG_GETARG_DATUM(0);
Cash result;
int fpoint;
int64 scale;
int i;
Datum numeric_scale;
struct lconv *lconvert = PGLC_localeconv();
/* see comments about frac_digits in cash_in() */
fpoint = lconvert->frac_digits;
if (fpoint < 0 || fpoint > 10)
fpoint = 2;
/* compute required scale factor */
scale = 1;
for (i = 0; i < fpoint; i++)
scale *= 10;
/* multiply the input amount by scale factor */
numeric_scale = DirectFunctionCall1(int8_numeric, Int64GetDatum(scale));
amount = DirectFunctionCall2(numeric_mul, amount, numeric_scale);
/* note that numeric_int8 will round to nearest integer for us */
result = DatumGetInt64(DirectFunctionCall1(numeric_int8, amount));
PG_RETURN_CASH(result);
}
示例12: PersistentStore_ExtractOurTupleData
static void PersistentStore_ExtractOurTupleData(
PersistentStoreData *storeData,
Datum *values,
int64 *persistentSerialNum)
{
*persistentSerialNum = DatumGetInt64(values[storeData->attNumPersistentSerialNum - 1]);
}
示例13: GpPersistentTablespaceNode_GetValues
void GpPersistentTablespaceNode_GetValues(
Datum *values,
Oid *filespaceOid,
Oid *tablespaceOid,
PersistentFileSysState *persistentState,
int32 *reserved,
TransactionId *parentXid,
int64 *persistentSerialNum,
ItemPointerData *previousFreeTid,
bool *sharedStorage)
{
*filespaceOid = DatumGetObjectId(values[Anum_gp_persistent_tablespace_node_filespace_oid - 1]);
*tablespaceOid = DatumGetObjectId(values[Anum_gp_persistent_tablespace_node_tablespace_oid - 1]);
*persistentState = DatumGetInt16(values[Anum_gp_persistent_tablespace_node_persistent_state - 1]);
*reserved = DatumGetInt32(values[Anum_gp_persistent_tablespace_node_reserved - 1]);
*parentXid = (TransactionId)DatumGetInt32(values[Anum_gp_persistent_tablespace_node_parent_xid - 1]);
*persistentSerialNum = DatumGetInt64(values[Anum_gp_persistent_tablespace_node_persistent_serial_num - 1]);
*previousFreeTid = *((ItemPointer) DatumGetPointer(values[Anum_gp_persistent_tablespace_node_previous_free_tid - 1]));
*sharedStorage = true;
}
示例14: system_rows_beginsamplescan
/*
* Examine parameters and prepare for a sample scan.
*/
static void
system_rows_beginsamplescan(SampleScanState *node,
Datum *params,
int nparams,
uint32 seed)
{
SystemRowsSamplerData *sampler = (SystemRowsSamplerData *) node->tsm_state;
int64 ntuples = DatumGetInt64(params[0]);
if (ntuples < 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLESAMPLE_ARGUMENT),
errmsg("sample size must not be negative")));
sampler->seed = seed;
sampler->ntuples = ntuples;
sampler->donetuples = 0;
sampler->lt = InvalidOffsetNumber;
sampler->doneblocks = 0;
/* lb will be initialized during first NextSampleBlock call */
/* we intentionally do not change nblocks/firstblock/step here */
/*
* We *must* use pagemode visibility checking in this module, so force
* that even though it's currently default.
*/
node->use_pagemode = true;
}
示例15: all_referenced_files
long long * all_referenced_files(int * countOut)
{
char query[128];
snprintf(query, 128, "SELECT file_id FROM "WDB_SCHEMA".file_blob");
SPI_connect();
int result = SPI_execute(query, true, 0);
if ( SPI_OK_SELECT != result )
ereport(ERROR, (errcode( ERRCODE_RAISE_EXCEPTION ), errmsg("Error when reading from file_blob")));
* countOut = SPI_processed;
long long * ret = (long long *) SPI_palloc(sizeof(long long) * (* countOut));
int i;
for ( i = 0; i < * countOut; ++ i )
{
bool isNull; // unused
Datum d = SPI_getbinval(SPI_tuptable->vals[i], SPI_tuptable->tupdesc, 1, & isNull);
ret[i] = DatumGetInt64(d);
}
SPI_finish();
return ret;
}