aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/numeric.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/numeric.c')
-rw-r--r--src/backend/utils/adt/numeric.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index ea79b48a8f6..07b264572d9 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -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));
+}
+
+
/* ----------------------------------------------------------------------
*