summaryrefslogtreecommitdiff
path: root/src/include/utils/numeric.h
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-09-05 13:53:47 +0900
committerMichael Paquier <michael@paquier.xyz>2025-09-05 13:53:47 +0900
commit4246a977bad6e76c4276a0d52def8a3dced154bb (patch)
treef2d74a842b71a40112366fb948cabe3b5b47b8d3 /src/include/utils/numeric.h
parentae453120085f7da8f4082bb912e9668410cdccab (diff)
Switch some numeric-related functions to use soft error reporting
This commit changes some functions related to the data type numeric to use the soft error reporting rather than a custom boolean flag (called "have_error") that callers of these functions could rely on to bypass the generation of ERROR reports, letting the callers do their own error handling (timestamp, jsonpath and numeric_to_char() require them). This results in the removal of some boilerplate code that was required to handle both the ereport() and the "have_error" code paths bypassing ereport(), unifying everything under the soft error reporting facility. While on it, some duplicated error messages are removed. The function upgraded in this commit were suffixed with "_opt_error" in their names. They are renamed to "_safe" instead. This change relies on d9f7f5d32f20, that has introduced the soft error reporting infrastructure. Author: Amul Sul <sulamul@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/CAAJ_b96No5h5tRuR+KhcC44YcYUCw8WAHuLoqqyyop8_k3+JDQ@mail.gmail.com
Diffstat (limited to 'src/include/utils/numeric.h')
-rw-r--r--src/include/utils/numeric.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h
index 9e79fc376cb..215f1ea4f53 100644
--- a/src/include/utils/numeric.h
+++ b/src/include/utils/numeric.h
@@ -17,6 +17,9 @@
#include "common/pg_prng.h"
#include "fmgr.h"
+/* forward declaration to avoid node.h include */
+typedef struct Node Node;
+
/*
* Limits on the precision and scale specifiable in a NUMERIC typmod. The
* precision is strictly positive, but the scale may be positive or negative.
@@ -91,18 +94,13 @@ extern char *numeric_normalize(Numeric num);
extern Numeric int64_to_numeric(int64 val);
extern Numeric int64_div_fast_to_numeric(int64 val1, int log10val2);
-extern Numeric numeric_add_opt_error(Numeric num1, Numeric num2,
- bool *have_error);
-extern Numeric numeric_sub_opt_error(Numeric num1, Numeric num2,
- bool *have_error);
-extern Numeric numeric_mul_opt_error(Numeric num1, Numeric num2,
- bool *have_error);
-extern Numeric numeric_div_opt_error(Numeric num1, Numeric num2,
- bool *have_error);
-extern Numeric numeric_mod_opt_error(Numeric num1, Numeric num2,
- bool *have_error);
-extern int32 numeric_int4_opt_error(Numeric num, bool *have_error);
-extern int64 numeric_int8_opt_error(Numeric num, bool *have_error);
+extern Numeric numeric_add_safe(Numeric num1, Numeric num2, Node *escontext);
+extern Numeric numeric_sub_safe(Numeric num1, Numeric num2, Node *escontext);
+extern Numeric numeric_mul_safe(Numeric num1, Numeric num2, Node *escontext);
+extern Numeric numeric_div_safe(Numeric num1, Numeric num2, Node *escontext);
+extern Numeric numeric_mod_safe(Numeric num1, Numeric num2, Node *escontext);
+extern int32 numeric_int4_safe(Numeric num, Node *escontext);
+extern int64 numeric_int8_safe(Numeric num, Node *escontext);
extern Numeric random_numeric(pg_prng_state *state,
Numeric rmin, Numeric rmax);