本文整理汇总了C++中PG_RETURN_INT16函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_RETURN_INT16函数的具体用法?C++ PG_RETURN_INT16怎么用?C++ PG_RETURN_INT16使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_RETURN_INT16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int2up
Datum
int2up(PG_FUNCTION_ARGS)
{
int16 arg = PG_GETARG_INT16(0);
PG_RETURN_INT16(arg);
}
示例2: int2not
Datum
int2not(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
PG_RETURN_INT16(~arg1);
}
示例3: int2in
/*
* int2in - converts "num" to short
*/
Datum
int2in(PG_FUNCTION_ARGS)
{
char *num = PG_GETARG_CSTRING(0);
PG_RETURN_INT16(pg_atoi(num, sizeof(int16), '\0'));
}
示例4: int2div
Datum
int2div(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 arg2 = PG_GETARG_INT16(1);
int16 result;
if (arg2 == 0)
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = arg1 / arg2;
/*
* Overflow check. The only possible overflow case is for arg1 =
* SHRT_MIN, arg2 = -1, where the correct result is -SHRT_MIN, which can't
* be represented on a two's-complement machine. Most machines produce
* SHRT_MIN but it seems some produce zero.
*/
if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16(result);
}
示例5: int2recv
/*
* int2recv - converts external binary format to int2
*/
Datum
int2recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
PG_RETURN_INT16((int16) pq_getmsgint(buf, sizeof(int16)));
}
示例6: int2shl
Datum
int2shl(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int32 arg2 = PG_GETARG_INT32(1);
PG_RETURN_INT16(arg1 << arg2);
}
示例7: int2xor
Datum
int2xor(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 arg2 = PG_GETARG_INT16(1);
PG_RETURN_INT16(arg1 ^ arg2);
}
示例8: int2smaller
Datum
int2smaller(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 arg2 = PG_GETARG_INT16(1);
PG_RETURN_INT16((arg1 < arg2) ? arg1 : arg2);
}
示例9: gp_add_master_standby
/*
* Add a master standby.
*
* gp_add_master_standby(hostname, address)
*
* Args:
* hostname - as above
* address - as above
*
* Returns:
* dbid of the new standby
*/
Datum
gp_add_master_standby(PG_FUNCTION_ARGS)
{
CdbComponentDatabaseInfo *master = NULL;
Relation gprel;
Datum values[Natts_gp_segment_configuration];
bool nulls[Natts_gp_segment_configuration];
HeapTuple tuple;
cqContext cqc;
cqContext *pcqCtx = NULL;
if (PG_ARGISNULL(0))
elog(ERROR, "host name cannot be NULL");
if (PG_ARGISNULL(1))
elog(ERROR, "address cannot be NULL");
mirroring_sanity_check(MASTER_ONLY | UTILITY_MODE,
"gp_add_master_standby");
if (standby_exists())
elog(ERROR, "only a single master standby may be defined");
/* master */
master = registration_order_get_dbinfo(MASTER_ORDER_ID);
/* Lock exclusively to avoid concurrent changes */
gprel = heap_open(GpSegmentConfigRelationId, AccessExclusiveLock);
pcqCtx = caql_beginscan(
caql_addrel(cqclr(&cqc), gprel),
cql("INSERT INTO gp_segment_configuration ", NULL));
MemSet(nulls, false, sizeof(nulls));
values[Anum_gp_segment_configuration_registration_order - 1] = Int32GetDatum(STANDBY_ORDER_ID);
values[Anum_gp_segment_configuration_role - 1] = CharGetDatum(SEGMENT_ROLE_STANDBY_CONFIG);
values[Anum_gp_segment_configuration_status - 1] = CharGetDatum('u');
values[Anum_gp_segment_configuration_port - 1] = Int32GetDatum(master->port);
values[Anum_gp_segment_configuration_hostname - 1] = PG_GETARG_DATUM(0);
values[Anum_gp_segment_configuration_address - 1] = PG_GETARG_DATUM(1);
nulls[Anum_gp_segment_configuration_description - 1] = true;
tuple = caql_form_tuple(pcqCtx, values, nulls);
/* insert a new tuple */
caql_insert(pcqCtx, tuple); /* implicit update of index as well */
caql_endscan(pcqCtx);
if(master)
pfree(master);
heap_close(gprel, NoLock);
PG_RETURN_INT16(1);
}
示例10: int2um
Datum
int2um(PG_FUNCTION_ARGS)
{
int16 arg = PG_GETARG_INT16(0);
if (unlikely(arg == PG_INT16_MIN))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16(-arg);
}
示例11: i4toi2
Datum
i4toi2(PG_FUNCTION_ARGS)
{
int32 arg1 = PG_GETARG_INT32(0);
if (arg1 < SHRT_MIN || arg1 > SHRT_MAX)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16((int16) arg1);
}
示例12: int2mi
Datum
int2mi(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 arg2 = PG_GETARG_INT16(1);
int16 result;
if (unlikely(pg_sub_s16_overflow(arg1, arg2, &result)))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16(result);
}
示例13: int2abs
Datum
int2abs(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 result;
if (unlikely(arg1 == PG_INT16_MIN))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
result = (arg1 < 0) ? -arg1 : arg1;
PG_RETURN_INT16(result);
}
示例14: int2div
Datum
int2div(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 arg2 = PG_GETARG_INT16(1);
int16 result;
if (arg2 == 0)
{
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
/* ensure compiler realizes we mustn't reach the division (gcc bug) */
PG_RETURN_NULL();
}
/*
* SHRT_MIN / -1 is problematic, since the result can't be represented on
* a two's-complement machine. Some machines produce SHRT_MIN, some
* produce zero, some throw an exception. We can dodge the problem by
* recognizing that division by -1 is the same as negation.
*/
if (arg2 == -1)
{
result = -arg1;
/* overflow check (needed for SHRT_MIN) */
if (arg1 != 0 && SAMESIGN(result, arg1))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16(result);
}
/* No overflow is possible */
result = arg1 / arg2;
PG_RETURN_INT16(result);
}
示例15: int2mod
Datum
int2mod(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 arg2 = PG_GETARG_INT16(1);
if (arg2 == 0)
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
/* No overflow is possible */
PG_RETURN_INT16(arg1 % arg2);
}