• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PG_GETARG_CASH函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PG_GETARG_CASH函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_CASH函数的具体用法?C++ PG_GETARG_CASH怎么用?C++ PG_GETARG_CASH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PG_GETARG_CASH函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cashsmaller

/* cashsmaller()
 * Return smaller of two cash values.
 */
Datum
cashsmaller(PG_FUNCTION_ARGS)
{
	Cash		c1 = PG_GETARG_CASH(0);
	Cash		c2 = PG_GETARG_CASH(1);
	Cash		result;

	result = (c1 < c2) ? c1 : c2;

	PG_RETURN_CASH(result);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:14,代码来源:cash.c


示例2: cash_mi

/* cash_mi()
 * Subtract two cash values.
 */
Datum
cash_mi(PG_FUNCTION_ARGS)
{
	Cash		c1 = PG_GETARG_CASH(0);
	Cash		c2 = PG_GETARG_CASH(1);
	Cash		result;

	result = c1 - c2;

	PG_RETURN_CASH(result);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:14,代码来源:cash.c


示例3: cash_cmp

Datum
cash_cmp(PG_FUNCTION_ARGS)
{
    Cash		c1 = PG_GETARG_CASH(0);
    Cash		c2 = PG_GETARG_CASH(1);

    if (c1 > c2)
        PG_RETURN_INT32(1);
    else if (c1 == c2)
        PG_RETURN_INT32(0);
    else
        PG_RETURN_INT32(-1);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例4: cash_div_cash

/* cash_div_cash()
 * Divide cash by cash, returning float8.
 */
Datum
cash_div_cash(PG_FUNCTION_ARGS)
{
	Cash		dividend = PG_GETARG_CASH(0);
	Cash		divisor = PG_GETARG_CASH(1);
	float8		quotient;

	if (divisor == 0)
		ereport(ERROR,
				(errcode(ERRCODE_DIVISION_BY_ZERO),
				 errmsg("division by zero")));

	quotient = (float8) dividend / (float8) divisor;
	PG_RETURN_FLOAT8(quotient);
}
开发者ID:AmiGanguli,项目名称:postgres,代码行数:18,代码来源:cash.c


示例5: cash_numeric

/* cash_numeric()
 * Convert cash to numeric.
 */
Datum
cash_numeric(PG_FUNCTION_ARGS)
{
	Cash		money = PG_GETARG_CASH(0);
	Numeric		result;
	int			fpoint;
	int64		scale;
	int			i;
	Datum		amount;
	Datum		numeric_scale;
	Datum		quotient;
	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;

	/* form the result as money / scale */
	amount = DirectFunctionCall1(int8_numeric, Int64GetDatum(money));
	numeric_scale = DirectFunctionCall1(int8_numeric, Int64GetDatum(scale));
	quotient = DirectFunctionCall2(numeric_div, amount, numeric_scale);

	/* forcibly round to exactly the intended number of digits */
	result = DatumGetNumeric(DirectFunctionCall2(numeric_round,
												 quotient,
												 Int32GetDatum(fpoint)));

	PG_RETURN_NUMERIC(result);
}
开发者ID:AmiGanguli,项目名称:postgres,代码行数:38,代码来源:cash.c


示例6: flt8_mul_cash

/* flt8_mul_cash()
 * Multiply float8 by cash.
 */
Datum
flt8_mul_cash(PG_FUNCTION_ARGS)
{
	float8		f = PG_GETARG_FLOAT8(0);
	Cash		c = PG_GETARG_CASH(1);
	Cash		result;

	result = rint(f * c);
	PG_RETURN_CASH(result);
}
开发者ID:AmiGanguli,项目名称:postgres,代码行数:13,代码来源:cash.c


示例7: cash_send

/*
 *		cash_send			- converts cash to binary format
 */
Datum
cash_send(PG_FUNCTION_ARGS)
{
    Cash		arg1 = PG_GETARG_CASH(0);
    StringInfoData buf;

    pq_begintypsend(&buf);
    pq_sendint(&buf, arg1, sizeof(Cash));
    PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例8: cash_dist

Datum
cash_dist(PG_FUNCTION_ARGS)
{
	Cash		a = PG_GETARG_CASH(0);
	Cash		b = PG_GETARG_CASH(1);
	Cash		r;
	Cash		ra;

	r = a - b;
	ra = Abs(r);

	/* Overflow check. */
	if (ra < 0 || (!SAMESIGN(a, b) && !SAMESIGN(r, a)))
		ereport(ERROR,
				(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
				 errmsg("money out of range")));

	PG_RETURN_CASH(ra);
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:19,代码来源:btree_cash.c


示例9: cash_mul_int2

/* cash_mul_int2()
 * Multiply cash by int2.
 */
Datum
cash_mul_int2(PG_FUNCTION_ARGS)
{
    Cash		c = PG_GETARG_CASH(0);
    int16		s = PG_GETARG_INT16(1);
    Cash		result;

    result = c * s;
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例10: int2_mul_cash

/* int2_mul_cash()
 * Multiply int2 by cash.
 */
Datum
int2_mul_cash(PG_FUNCTION_ARGS)
{
    int16		s = PG_GETARG_INT16(0);
    Cash		c = PG_GETARG_CASH(1);
    Cash		result;

    result = s * c;
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例11: cash_mul_int4

/* cash_mul_int4()
 * Multiply cash by int4.
 */
Datum
cash_mul_int4(PG_FUNCTION_ARGS)
{
    Cash		c = PG_GETARG_CASH(0);
    int32		i = PG_GETARG_INT32(1);
    Cash		result;

    result = c * i;
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例12: int4_mul_cash

/* int4_mul_cash()
 * Multiply int4 by cash.
 */
Datum
int4_mul_cash(PG_FUNCTION_ARGS)
{
    int32		i = PG_GETARG_INT32(0);
    Cash		c = PG_GETARG_CASH(1);
    Cash		result;

    result = i * c;
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例13: flt4_mul_cash

/* flt4_mul_cash()
 * Multiply float4 by cash.
 */
Datum
flt4_mul_cash(PG_FUNCTION_ARGS)
{
    float4		f = PG_GETARG_FLOAT4(0);
    Cash		c = PG_GETARG_CASH(1);
    Cash		result;

    result = f * c;
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例14: cash_mul_flt8

/* cash_mul_flt8()
 * Multiply cash by float8.
 */
Datum
cash_mul_flt8(PG_FUNCTION_ARGS)
{
	Cash		c = PG_GETARG_CASH(0);
	float8		f = PG_GETARG_FLOAT8(1);
	Cash		result;

	result = rint(c * f);
	PG_RETURN_CASH(result);
}
开发者ID:AmiGanguli,项目名称:postgres,代码行数:13,代码来源:cash.c


示例15: cash_mul_flt4

/* cash_mul_flt4()
 * Multiply cash by float4.
 */
Datum
cash_mul_flt4(PG_FUNCTION_ARGS)
{
    Cash		c = PG_GETARG_CASH(0);
    float4		f = PG_GETARG_FLOAT4(1);
    Cash		result;

    result = c * f;
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:13,代码来源:cash.c


示例16: 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


示例17: cash_div_flt4

/* cash_div_flt4()
 * Divide cash by float4.
 *
 * XXX Don't know if rounding or truncating is correct behavior.
 * Round for now. - tgl 97/04/15
 */
Datum
cash_div_flt4(PG_FUNCTION_ARGS)
{
    Cash		c = PG_GETARG_CASH(0);
    float4		f = PG_GETARG_FLOAT4(1);
    Cash		result;

    if (f == 0.0)
        ereport(ERROR,
                (errcode(ERRCODE_DIVISION_BY_ZERO),
                 errmsg("division by zero")));

    result = rint(c / f);
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:21,代码来源:cash.c


示例18: cash_div_int4

/* cash_div_int4()
 * Divide cash by 4-byte integer.
 *
 */
Datum
cash_div_int4(PG_FUNCTION_ARGS)
{
	Cash		c = PG_GETARG_CASH(0);
	int32		i = PG_GETARG_INT32(1);
	Cash		result;

	if (i == 0)
		ereport(ERROR,
				(errcode(ERRCODE_DIVISION_BY_ZERO),
				 errmsg("division by zero")));

	result = c / i;

	PG_RETURN_CASH(result);
}
开发者ID:AmiGanguli,项目名称:postgres,代码行数:20,代码来源:cash.c


示例19: gbt_cash_distance

Datum
gbt_cash_distance(PG_FUNCTION_ARGS)
{
	GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
	Cash		query = PG_GETARG_CASH(1);

	/* Oid		subtype = PG_GETARG_OID(3); */
	cashKEY    *kkk = (cashKEY *) 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:0x0FFF,项目名称:postgres,代码行数:17,代码来源:btree_cash.c


示例20: gbt_cash_consistent

Datum
gbt_cash_consistent(PG_FUNCTION_ARGS)
{
	GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
	Cash		query = PG_GETARG_CASH(1);
	StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);

	/* Oid		subtype = PG_GETARG_OID(3); */
	bool	   *recheck = (bool *) PG_GETARG_POINTER(4);
	cashKEY    *kkk = (cashKEY *) DatumGetPointer(entry->key);
	GBT_NUMKEY_R key;

	/* All cases served by this function are exact */
	*recheck = false;

	key.lower = (GBT_NUMKEY *) &kkk->lower;
	key.upper = (GBT_NUMKEY *) &kkk->upper;

	PG_RETURN_BOOL(
				   gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
		);
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:22,代码来源:btree_cash.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PG_GETARG_CSTRING函数代码示例发布时间:2022-05-30
下一篇:
C++ PG_GETARG_BYTEA_P函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap