本文整理匯總了C++中DatumGetInt32函數的典型用法代碼示例。如果您正苦於以下問題:C++ DatumGetInt32函數的具體用法?C++ DatumGetInt32怎麽用?C++ DatumGetInt32使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DatumGetInt32函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: leadlag_common
/*
* leadlag_common
* common operation of lead() and lag()
* For lead() forward is true, whereas for lag() it is false.
* withoffset indicates we have an offset second argument.
* withdefault indicates we have a default third argument.
*/
static Datum
leadlag_common(FunctionCallInfo fcinfo,
bool forward, bool withoffset, bool withdefault)
{
WindowObject winobj = PG_WINDOW_OBJECT();
int32 offset;
bool const_offset;
Datum result;
bool isnull;
bool isout;
if (withoffset)
{
offset = DatumGetInt32(WinGetFuncArgCurrent(winobj, 1, &isnull));
if (isnull)
PG_RETURN_NULL();
const_offset = get_fn_expr_arg_stable(fcinfo->flinfo, 1);
}
else
{
offset = 1;
const_offset = true;
}
result = WinGetFuncArgInPartition(winobj, 0,
(forward ? offset : -offset),
WINDOW_SEEK_CURRENT,
const_offset,
&isnull, &isout);
if (isout)
{
/*
* target row is out of the partition; supply default value if
* provided. otherwise it'll stay NULL
*/
if (withdefault)
result = WinGetFuncArgCurrent(winobj, 2, &isnull);
}
if (isnull)
PG_RETURN_NULL();
PG_RETURN_DATUM(result);
}
示例2: c_overpaid
Datum
c_overpaid(PG_FUNCTION_ARGS)
{
HeapTupleHeader t = PG_GETARG_HEAPTUPLEHEADER(0);
int32 limit = PG_GETARG_INT32(1);
bool isnull;
int32 salary;
salary = DatumGetInt32(GetAttributeByName(t, "salary", &isnull));
if (isnull)
PG_RETURN_BOOL(false);
/*
* Alternatively, we might prefer to do PG_RETURN_NULL() for null salary
*/
PG_RETURN_BOOL(salary > limit);
}
示例3: ginCompareEntries
/*
* Compare two keys of the same index column
*/
int
ginCompareEntries(GinState *ginstate, OffsetNumber attnum,
Datum a, GinNullCategory categorya,
Datum b, GinNullCategory categoryb)
{
/* if not of same null category, sort by that first */
if (categorya != categoryb)
return (categorya < categoryb) ? -1 : 1;
/* all null items in same category are equal */
if (categorya != GIN_CAT_NORM_KEY)
return 0;
/* both not null, so safe to call the compareFn */
return DatumGetInt32(FunctionCall2Coll(&ginstate->compareFn[attnum - 1],
ginstate->supportCollation[attnum - 1],
a, b));
}
示例4: on_partitions_updated
Datum
on_partitions_updated(PG_FUNCTION_ARGS)
{
Oid relid;
PartRelationInfo *prel;
/* Parent relation oid */
relid = DatumGetInt32(PG_GETARG_DATUM(0));
prel = get_pathman_relation_info(relid, NULL);
if (prel != NULL)
{
LWLockAcquire(pmstate->load_config_lock, LW_EXCLUSIVE);
remove_relation_info(relid);
load_relations_hashtable(false);
LWLockRelease(pmstate->load_config_lock);
}
PG_RETURN_NULL();
}
示例5: CompareShardIntervals
/*
* CompareShardIntervals acts as a helper function to compare two shard intervals
* by their minimum values, using the value's type comparison function.
*
* If a shard interval does not have min/max value, it's treated as being greater
* than the other.
*/
int
CompareShardIntervals(const void *leftElement, const void *rightElement,
FmgrInfo *typeCompareFunction)
{
ShardInterval *leftShardInterval = *((ShardInterval **) leftElement);
ShardInterval *rightShardInterval = *((ShardInterval **) rightElement);
Datum leftDatum = 0;
Datum rightDatum = 0;
Datum comparisonDatum = 0;
int comparisonResult = 0;
Assert(typeCompareFunction != NULL);
/*
* Left element should be treated as the greater element in case it doesn't
* have min or max values.
*/
if (!leftShardInterval->minValueExists || !leftShardInterval->maxValueExists)
{
comparisonResult = 1;
return comparisonResult;
}
/*
* Right element should be treated as the greater element in case it doesn't
* have min or max values.
*/
if (!rightShardInterval->minValueExists || !rightShardInterval->maxValueExists)
{
comparisonResult = -1;
return comparisonResult;
}
/* if both shard interval have min/max values, calculate the comparison result */
leftDatum = leftShardInterval->minValue;
rightDatum = rightShardInterval->minValue;
comparisonDatum = CompareCall2(typeCompareFunction, leftDatum, rightDatum);
comparisonResult = DatumGetInt32(comparisonDatum);
return comparisonResult;
}
示例6: GpRelationNode_GetValues
void GpRelationNode_GetValues(
Datum *values,
Oid *relfilenodeOid,
int32 *segmentFileNum,
int64 *createMirrorDataLossTrackingSessionNum,
ItemPointer persistentTid,
int64 *persistentSerialNum)
{
*relfilenodeOid = DatumGetObjectId(values[Anum_gp_relation_node_relfilenode_oid - 1]);
*segmentFileNum = DatumGetInt32(values[Anum_gp_relation_node_segment_file_num - 1]);
*createMirrorDataLossTrackingSessionNum = DatumGetInt64(values[Anum_gp_relation_node_create_mirror_data_loss_tracking_session_num - 1]);
*persistentTid = *((ItemPointer) DatumGetPointer(values[Anum_gp_relation_node_persistent_tid - 1]));
*persistentSerialNum = DatumGetInt64(values[Anum_gp_relation_node_persistent_serial_num - 1]);
}
示例7: hashMeth2
//cs3223 fnv1 32bit
void hashMeth2(uint32 keyval, HashJoinTable hashtable) {
uint32 hashkey = 8192*bitvector_size;
long keyV;
unsigned int hash = OFFSET32;
int i=0;
//printf("size of keyval: %d\n", sizeof(keyval));
int numOctal = sizeof(keyval);
if (numOctal < 8)
keyV = DatumGetInt32(keyval);
else
keyV = DatumGetInt64(keyval);
for (i=0;i<numOctal;i++){
hash = hash ^ (keyV & 0x000000ff);
hash = hash * PRIME32;
keyV = keyV >> 8;
}
// Mapping method
hash = hash % hashkey;
setKbit(hashtable->bitvector, hash);
}
示例8: HdfsFreeFileInfo
int HdfsFreeFileInfo(FsysName protocol, hdfsFileInfo * info, int numEntries)
{
FunctionCallInfoData fcinfo;
FileSystemUdfData fsysUdf;
FmgrInfo *fsysFunc = FsysInterfaceGetFunc(protocol, FSYS_FUNC_FREEFILEINFO);
fsysUdf.type = T_FileSystemFunctionData;
fsysUdf.fsys_fileinfo = info;
fsysUdf.fsys_fileinfonum = numEntries;
InitFunctionCallInfoData(/* FunctionCallInfoData */ fcinfo,
/* FmgrInfo */ fsysFunc,
/* nArgs */ 0,
/* Call Context */ (Node *) (&fsysUdf),
/* ResultSetInfo */ NULL);
Datum d = FunctionCallInvoke(&fcinfo);
return DatumGetInt32(d);
}
示例9: check_overlap
/*
* Checks if range overlaps with existing partitions.
* Returns TRUE if overlaps and FALSE otherwise.
*/
Datum
check_overlap(PG_FUNCTION_ARGS)
{
int parent_oid = DatumGetInt32(PG_GETARG_DATUM(0));
Datum p1 = PG_GETARG_DATUM(1);
Oid p1_type = get_fn_expr_argtype(fcinfo->flinfo, 1);
Datum p2 = PG_GETARG_DATUM(2);
Oid p2_type = get_fn_expr_argtype(fcinfo->flinfo, 2);
PartRelationInfo *prel;
RangeRelation *rangerel;
RangeEntry *ranges;
FmgrInfo cmp_func_1;
FmgrInfo cmp_func_2;
int i;
bool byVal;
prel = get_pathman_relation_info(parent_oid, NULL);
rangerel = get_pathman_range_relation(parent_oid, NULL);
if (!prel || !rangerel || prel->parttype != PT_RANGE)
PG_RETURN_NULL();
/* comparison functions */
cmp_func_1 = *get_cmp_func(p1_type, prel->atttype);
cmp_func_2 = *get_cmp_func(p2_type, prel->atttype);
byVal = rangerel->by_val;
ranges = (RangeEntry *) dsm_array_get_pointer(&rangerel->ranges);
for (i=0; i<rangerel->ranges.length; i++)
{
int c1 = FunctionCall2(&cmp_func_1, p1,
PATHMAN_GET_DATUM(ranges[i].max, byVal));
int c2 = FunctionCall2(&cmp_func_2, p2,
PATHMAN_GET_DATUM(ranges[i].min, byVal));
if (c1 < 0 && c2 > 0)
PG_RETURN_BOOL(true);
}
PG_RETURN_BOOL(false);
}
示例10: getDocumentCount
long getDocumentCount()
{
int spiResultCode;
Datum countDatum;
bool isNull;
long count;
SPI_connect();
spiResultCode = SPI_execute("SELECT COUNT(*)::integer FROM CardVectors", 1, 1);
if(spiResultCode == SPI_OK_SELECT)
{
countDatum = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isNull);
count = DatumGetInt32(countDatum);
} else {
ereport(ERROR, (errmsg("Unable to query CardVectors table. Does it exist?")));
count = -1;
}
SPI_finish();
return count;
}
示例11: AuxiliaryProcKill
/*
* AuxiliaryProcKill() -- Cut-down version of ProcKill for auxiliary
* processes (bgwriter, etc). The PGPROC and sema are not released, only
* marked as not-in-use.
*/
static void
AuxiliaryProcKill(int code, Datum arg)
{
int proctype = DatumGetInt32(arg);
PGPROC *auxproc;
Assert(proctype >= 0 && proctype < NUM_AUXILIARY_PROCS);
auxproc = &AuxiliaryProcs[proctype];
Assert(MyProc == auxproc);
/* Release any LW locks I am holding (see notes above) */
LWLockReleaseAll();
/* Update shared estimate of spins_per_delay */
update_spins_per_delay();
if (code == 0 || code == 1)
{
MyProc->postmasterResetRequired = false;
}
/*
* If the parent process of this auxiliary process does not exist,
* we want to set the proc array entry free here. The postmaster may
* not own this process, so that it can't set the entry free. This
* could happen to the filerep subprocesses when the filerep main
* process dies unexpectedly.
*/
if (!ParentProcIsAlive())
{
MyProc->pid = 0;
MyProc->postmasterResetRequired = true;
}
/* PGPROC struct isn't mine anymore */
MyProc = NULL;
lockHolderProcPtr = NULL;
}
示例12: append_datum
size_t append_datum(char* buf, Datum val, bool isnull, Oid typeoid)
{
HeapTuple typeTup;
Form_pg_type typeStruct;
FmgrInfo tmp_flinfo;
char *str;
size_t len;
typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(typeoid), 0, 0, 0);
if (!HeapTupleIsValid(typeTup)) {
elog(ERROR, "Cache lookup failed for %u", typeoid);
}
typeStruct = (Form_pg_type)GETSTRUCT(typeTup);
if (typeStruct->typtype != 'b') {
// Non-basic type
elog(ERROR, "Don't support non-basic types (%s)",
format_type_be(typeoid));
}
fmgr_info_cxt(typeStruct->typoutput, &tmp_flinfo, CurTransactionContext);
ReleaseSysCache(typeTup);
if (!isnull) {
if (typeoid == INT4OID) {
*((int*)buf) = DatumGetInt32(val);
return 4;
}
SPI_push();
str = OutputFunctionCall(&tmp_flinfo, val);
SPI_pop();
len = strlen(str);
strncpy(buf, str, len);
return len;
}
return 0;
}
示例13: ParquetFetchSegFileInfo
void
ParquetFetchSegFileInfo(AppendOnlyEntry *aoEntry, List *segfileinfos, Snapshot parquetMetaDataSnapshot)
{
Relation pg_parquetseg_rel;
TupleDesc pg_parquetseg_dsc;
HeapTuple tuple;
SysScanDesc parquetscan;
/*
* Since this function is called for insert operation,
* here we use RowExclusiveLock.
*/
pg_parquetseg_rel = heap_open(aoEntry->segrelid, RowExclusiveLock);
pg_parquetseg_dsc = RelationGetDescr(pg_parquetseg_rel);
parquetscan = systable_beginscan(pg_parquetseg_rel, InvalidOid, FALSE,
parquetMetaDataSnapshot, 0, NULL);
while (HeapTupleIsValid(tuple = systable_getnext(parquetscan)))
{
ListCell *lc;
int segno = DatumGetInt32(fastgetattr(tuple, Anum_pg_parquetseg_segno, pg_parquetseg_dsc, NULL));
foreach (lc, segfileinfos)
{
ResultRelSegFileInfo *segfileinfo = (ResultRelSegFileInfo *)lfirst(lc);
Assert(segfileinfo != NULL);
if (segfileinfo->segno == segno)
{
segfileinfo->numfiles = 1;
segfileinfo->tupcount = (int64)DatumGetFloat8(fastgetattr(tuple, Anum_pg_parquetseg_tupcount, pg_parquetseg_dsc, NULL));
segfileinfo->varblock = 0;
segfileinfo->eof = (int64 *)palloc(sizeof(int64));
segfileinfo->eof[0] = (int64)DatumGetFloat8(fastgetattr(tuple, Anum_pg_parquetseg_eof, pg_parquetseg_dsc, NULL));
segfileinfo->uncompressed_eof = (int64 *)palloc(sizeof(int64));
segfileinfo->uncompressed_eof[0] = (int64)DatumGetFloat8(fastgetattr(tuple, Anum_pg_parquetseg_eofuncompressed, pg_parquetseg_dsc, NULL));
break;
}
}
}
示例14: CleanupProcSignalState
/*
* CleanupProcSignalState
* Remove current process from ProcSignalSlots
*
* This function is called via on_shmem_exit() during backend shutdown.
*/
static void
CleanupProcSignalState(int status, Datum arg)
{
int pss_idx = DatumGetInt32(arg);
volatile ProcSignalSlot *slot;
slot = &ProcSignalSlots[pss_idx - 1];
Assert(slot == MyProcSignalSlot);
/* sanity check */
if (slot->pss_pid != MyProcPid)
{
/*
* don't ERROR here. We're exiting anyway, and don't want to get into
* infinite loop trying to exit
*/
elog(LOG, "process %d releasing ProcSignal slot %d, but it contains %d",
MyProcPid, pss_idx, (int) slot->pss_pid);
return; /* XXX better to zero the slot anyway? */
}
slot->pss_pid = 0;
}
示例15: AuxiliaryProcKill
/*
* AuxiliaryProcKill() -- Cut-down version of ProcKill for auxiliary
* processes (bgwriter, etc). The PGPROC and sema are not released, only
* marked as not-in-use.
*/
static void
AuxiliaryProcKill(int code, Datum arg)
{
int proctype = DatumGetInt32(arg);
PGPROC *auxproc PG_USED_FOR_ASSERTS_ONLY;
PGPROC *proc;
Assert(proctype >= 0 && proctype < NUM_AUXILIARY_PROCS);
auxproc = &AuxiliaryProcs[proctype];
Assert(MyProc == auxproc);
/* Release any LW locks I am holding (see notes above) */
LWLockReleaseAll();
/*
* Reset MyLatch to the process local one. This is so that signal
* handlers et al can continue using the latch after the shared latch
* isn't ours anymore. After that clear MyProc and disown the shared
* latch.
*/
SwitchBackToLocalLatch();
proc = MyProc;
MyProc = NULL;
DisownLatch(&proc->procLatch);
SpinLockAcquire(ProcStructLock);
/* Mark auxiliary proc no longer in use */
proc->pid = 0;
/* Update shared estimate of spins_per_delay */
ProcGlobal->spins_per_delay = update_spins_per_delay(ProcGlobal->spins_per_delay);
SpinLockRelease(ProcStructLock);
}