1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

This adds unary plus capability. No grammar changes, per Tom's request.

Marko Kreen
This commit is contained in:
Bruce Momjian
2001-06-07 00:09:32 +00:00
parent a6697b3614
commit ba17165f55
10 changed files with 102 additions and 13 deletions

View File

@@ -8,16 +8,16 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.73 2001/06/02 20:18:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.74 2001/06/07 00:09:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*----------
* OLD COMMENTS
* Basic float4 ops:
* float4in, float4out, float4abs, float4um
* float4in, float4out, float4abs, float4um, float4up
* Basic float8 ops:
* float8in, float8out, float8abs, float8um
* float8in, float8out, float8abs, float8um, float8up
* Arithmetic operators:
* float4pl, float4mi, float4mul, float4div
* float8pl, float8mi, float8mul, float8div
@@ -340,6 +340,13 @@ float4um(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT4((float4) -arg1);
}
Datum
float4up(PG_FUNCTION_ARGS)
{
float4 arg = PG_GETARG_FLOAT4(0);
PG_RETURN_FLOAT4(arg);
}
Datum
float4larger(PG_FUNCTION_ARGS)
{
@@ -399,6 +406,13 @@ float8um(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(result);
}
Datum
float8up(PG_FUNCTION_ARGS)
{
float8 arg = PG_GETARG_FLOAT8(0);
PG_RETURN_FLOAT8(arg);
}
Datum
float8larger(PG_FUNCTION_ARGS)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.46 2001/03/22 03:59:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.47 2001/06/07 00:09:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -563,6 +563,14 @@ int4um(PG_FUNCTION_ARGS)
PG_RETURN_INT32(-arg);
}
Datum
int4up(PG_FUNCTION_ARGS)
{
int32 arg = PG_GETARG_INT32(0);
PG_RETURN_INT32(arg);
}
Datum
int4pl(PG_FUNCTION_ARGS)
{
@@ -615,6 +623,14 @@ int2um(PG_FUNCTION_ARGS)
PG_RETURN_INT16(-arg);
}
Datum
int2up(PG_FUNCTION_ARGS)
{
int16 arg = PG_GETARG_INT16(0);
PG_RETURN_INT16(arg);
}
Datum
int2pl(PG_FUNCTION_ARGS)
{

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.29 2001/03/22 03:59:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.30 2001/06/07 00:09:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -412,6 +412,14 @@ int8um(PG_FUNCTION_ARGS)
PG_RETURN_INT64(-val);
}
Datum
int8up(PG_FUNCTION_ARGS)
{
int64 val = PG_GETARG_INT64(0);
PG_RETURN_INT64(val);
}
Datum
int8pl(PG_FUNCTION_ARGS)
{

View File

@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.41 2001/05/03 19:00:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.42 2001/06/07 00:09:29 momjian Exp $
*
* ----------
*/
@@ -405,6 +405,19 @@ numeric_uminus(PG_FUNCTION_ARGS)
}
Datum
numeric_uplus(PG_FUNCTION_ARGS)
{
Numeric num = PG_GETARG_NUMERIC(0);
Numeric res;
res = (Numeric) palloc(num->varlen);
memcpy(res, num, num->varlen);
PG_RETURN_NUMERIC(res);
}
Datum
numeric_sign(PG_FUNCTION_ARGS)
{