1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Add scale(numeric)

Author: Marko Tiikkaja
This commit is contained in:
Alvaro Herrera
2016-01-05 19:02:13 -03:00
parent 419400c5da
commit abb1733922
7 changed files with 105 additions and 1 deletions

View File

@ -2825,6 +2825,23 @@ numeric_power(PG_FUNCTION_ARGS)
PG_RETURN_NUMERIC(res);
}
/*
* numeric_scale() -
*
* Returns the scale, i.e. the count of decimal digits in the fractional part
*/
Datum
numeric_scale(PG_FUNCTION_ARGS)
{
Numeric num = PG_GETARG_NUMERIC(0);
if (NUMERIC_IS_NAN(num))
PG_RETURN_NULL();
PG_RETURN_INT32(NUMERIC_DSCALE(num));
}
/* ----------------------------------------------------------------------
*