当前位置: 首页>>代码示例>>C++>>正文


C++ PG_GETARG_INT16函数代码示例

本文整理汇总了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);
}
开发者ID:Khalefa,项目名称:postgres,代码行数:13,代码来源:nbtcompare.c

示例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);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:13,代码来源:nbtcompare.c

示例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);
}
开发者ID:adunstan,项目名称:postgresql-dev,代码行数:39,代码来源:int.c

示例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);
}
开发者ID:rtzassociates,项目名称:postgresql-8.2.23,代码行数:14,代码来源:int.c

示例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);
}
开发者ID:rtzassociates,项目名称:postgresql-8.2.23,代码行数:14,代码来源:int.c

示例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);
}
开发者ID:DBInsight,项目名称:postgres-x2,代码行数:16,代码来源:cube.c

示例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);
}
开发者ID:yuejiesong1900,项目名称:pgsphere,代码行数:15,代码来源:output.c

示例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);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:21,代码来源:cash.c

示例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);
}
开发者ID:hsyuan,项目名称:gpdb,代码行数:36,代码来源:interpolate.c

示例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);
}
开发者ID:adam8157,项目名称:gpdb,代码行数:16,代码来源:cube.c

示例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)
		);
}
开发者ID:ASchurman,项目名称:BufStrat,代码行数:17,代码来源:btree_int2.c

示例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);
}
开发者ID:CadillacBupt,项目名称:recdb-postgresql,代码行数:18,代码来源:int.c

示例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) */
}
开发者ID:PivotalBigData,项目名称:incubator-hawq,代码行数:42,代码来源:hashapi_access.c

示例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);
}
开发者ID:PivotalBigData,项目名称:incubator-hawq,代码行数:31,代码来源:segadmin.c

示例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);
}
开发者ID:rtzassociates,项目名称:postgresql-8.2.23,代码行数:20,代码来源:int.c


注:本文中的PG_GETARG_INT16函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。