Re: Refactoring: Use soft error reporting for *_opt_error functions
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Amul Sul <sulamul@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-03T07:34:45Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix two comments in numeric.c
- 0c7f10302820 19 (unreleased) landed
-
Switch some numeric-related functions to use soft error reporting
- 4246a977bad6 19 (unreleased) landed
-
Change pg_lsn_in_internal() to use soft error reporting
- ae453120085f 19 (unreleased) landed
On Wed, 3 Sept 2025 at 07:47, Michael Paquier <michael@paquier.xyz> wrote:
>
> The same error message is repeated twice. How about using some gotos
> and one single ereport instead of two? The same can be said for
> numeric_div_safe() and numeric_mod_safe(), for the division-by-0
> messages.
In numeric_div_safe() and numeric_mod_safe():
- * If "have_error" is provided, check for division by zero here
+ * If "escontext" is provided, raise division by zero soft error here
*/
- if (have_error && (arg2.ndigits == 0 || arg2.digits[0] == 0))
- {
- *have_error = true;
- return NULL;
- }
+ if (escontext && (arg2.ndigits == 0 || arg2.digits[0] == 0))
+ ereturn(escontext, NULL,
+ errcode(ERRCODE_DIVISION_BY_ZERO),
+ errmsg("division by zero"));
This might as well now be made to check for division-by-zero even if
escontext is NULL.
Regards,
Dean