本文整理汇总了C++中PG_GETARG_INT16函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_INT16函数的具体用法?C++ PG_GETARG_INT16怎么用?C++ PG_GETARG_INT16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_INT16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: btint28cmp
Datum
btint28cmp(PG_FUNCTION_ARGS)
{
int16 a = PG_GETARG_INT16(0);
int64 b = PG_GETARG_INT64(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
示例2: btint42cmp
Datum
btint42cmp(PG_FUNCTION_ARGS)
{
int32 a = PG_GETARG_INT32(0);
int16 b = PG_GETARG_INT16(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
示例3: 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);
}
示例4: int2abs
Datum
int2abs(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int16 result;
result = (arg1 < 0) ? -arg1 : arg1;
/* overflow check (needed for SHRT_MIN) */
if (result < 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16(result);
}
示例5: int2um
Datum
int2um(PG_FUNCTION_ARGS)
{
int16 arg = PG_GETARG_INT16(0);
int16 result;
result = -arg;
/* overflow check (needed for SHRT_MIN) */
if (arg != 0 && SAMESIGN(result, arg))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
PG_RETURN_INT16(result);
}
示例6: cube_ur_coord
/* Return a specific normalized UR coordinate */
Datum
cube_ur_coord(PG_FUNCTION_ARGS)
{
NDBOX *c = PG_GETARG_NDBOX(0);
int n = PG_GETARG_INT16(1);
double result;
if (c->dim >= n && n > 0)
result = Max(c->x[n - 1], c->x[c->dim + n - 1]);
else
result = 0;
PG_FREE_IF_COPY(c, 0);
PG_RETURN_FLOAT8(result);
}
示例7: set_sphere_output_precision
Datum
set_sphere_output_precision(PG_FUNCTION_ARGS)
{
short int c = PG_GETARG_INT16(0);
char *buf = (char *) palloc(20);
if (c > DBL_DIG)
c = DBL_DIG;
if (c < 1)
c = DBL_DIG;
sphere_output_precision = c;
sprintf(buf, "SET %d", c);
PG_RETURN_CSTRING(buf);
}
示例8: cash_div_int2
/* cash_div_int2()
* Divide cash by int2.
*
* XXX Don't know if rounding or truncating is correct behavior.
* Round for now. - tgl 97/04/15
*/
Datum
cash_div_int2(PG_FUNCTION_ARGS)
{
Cash c = PG_GETARG_CASH(0);
int16 s = PG_GETARG_INT16(1);
Cash result;
if (s == 0)
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = rint(c / s);
PG_RETURN_CASH(result);
}
示例9: linterp_int16
Datum
linterp_int16(PG_FUNCTION_ARGS)
{
float8 y0;
float8 y1;
float8 p;
float8 r;
int16 result;
bool eq_bounds = false;
bool eq_abscissas = false;
/* Common */
p = linterp_abscissa(fcinfo, &eq_bounds, &eq_abscissas);
/* Ordinate type specific code*/
y0 = (float8)PG_GETARG_INT16(2);
y1 = (float8)PG_GETARG_INT16(4);
if ( eq_bounds )
{
if ( eq_abscissas && y0 == y1 )
r = y0;
else
PG_RETURN_NULL();
}
else
{
r = round(y0+p*(y1-y0));
if ( r < SHRT_MIN || r > SHRT_MAX )
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%f\" is out of range for type smallint", r)));
}
result = (int16)r;
PG_RETURN_INT16(result);
}
示例10: cube_ur_coord
/* Return a specific normalized UR coordinate */
Datum
cube_ur_coord(PG_FUNCTION_ARGS)
{
NDBOX *c = PG_GETARG_NDBOX(0);
int n = PG_GETARG_INT16(1);
double result;
if (DIM(c) >= n && n > 0)
result = Max(LL_COORD(c, n - 1), UR_COORD(c, n - 1));
else
result = 0;
PG_FREE_IF_COPY(c, 0);
PG_RETURN_FLOAT8(result);
}
示例11: gbt_int2_distance
Datum
gbt_int2_distance(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
int16 query = PG_GETARG_INT16(1);
/* Oid subtype = PG_GETARG_OID(3); */
int16KEY *kkk = (int16KEY *) DatumGetPointer(entry->key);
GBT_NUMKEY_R key;
key.lower = (GBT_NUMKEY *) &kkk->lower;
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
示例12: int24div
Datum
int24div(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int32 arg2 = PG_GETARG_INT32(1);
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();
}
/* No overflow is possible */
PG_RETURN_INT32((int32) arg1 / arg2);
}
示例13: HASHAPI_Hash_2_Text_Text
Datum HASHAPI_Hash_2_Text_Text(PG_FUNCTION_ARGS)
{
int32 num_segs; /* number of segments */
text *val1; /* text value1 */
text *val2; /* text value2 */
unsigned int targetbucket; /* 0-based */
int16 algorithm; /* hashing algorithm */
Datum d1,d2;
Oid oid;
/* Get number of segments */
num_segs = PG_GETARG_INT32(0);
/* Get hashing algoriithm */
algorithm = PG_GETARG_INT16(1);
/* Get the value to hash */
val1 = PG_GETARG_TEXT_P(2);
val2 = PG_GETARG_TEXT_P(3);
d1 = PointerGetDatum(val1);
d2 = PointerGetDatum(val2);
/* create a CdbHash for this hash test. */
h = makeCdbHash(num_segs, algorithm);
/* init cdb hash */
cdbhashinit(h);
oid = TEXTOID;
cdbhash(h, d1, oid);
cdbhash(h, d2, oid);
/* reduce the result hash value */
targetbucket = cdbhashreduce(h);
/* Avoid leaking memory for toasted inputs */
PG_FREE_IF_COPY(val1, 1);
PG_FREE_IF_COPY(val2, 2);
PG_RETURN_INT32(targetbucket); /* return target bucket (segID) */
}
示例14: gp_remove_segment
/*
* Remove knowledge of a segment from the master.
*
* gp_remove_segment(order)
*
* Args:
* order - order of registration
*
* Returns:
* true on success, otherwise error.
*/
Datum
gp_remove_segment(PG_FUNCTION_ARGS)
{
int16 order;
if (PG_ARGISNULL(0))
elog(ERROR, "Registration id cannot be NULL");
order = PG_GETARG_INT16(0);
mirroring_sanity_check(MASTER_ONLY | SUPERUSER | UTILITY_MODE,
"gp_remove_segment");
if (order == MASTER_ORDER_ID || order == STANDBY_ORDER_ID)
elog(ERROR, "Cannot remove master or standby");
remove_segment(order);
PG_RETURN_BOOL(true);
}
示例15: int24pl
Datum
int24pl(PG_FUNCTION_ARGS)
{
int16 arg1 = PG_GETARG_INT16(0);
int32 arg2 = PG_GETARG_INT32(1);
int32 result;
result = arg1 + arg2;
/*
* Overflow check. If the inputs are of different signs then their sum
* cannot overflow. If the inputs are of the same sign, their sum had
* better be that sign too.
*/
if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("integer out of range")));
PG_RETURN_INT32(result);
}