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: jian he <jian.universality@gmail.com>, Amul Sul <sulamul@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-04T09:50:38Z
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 →
  1. Fix two comments in numeric.c

  2. Switch some numeric-related functions to use soft error reporting

  3. Change pg_lsn_in_internal() to use soft error reporting

On Thu, 4 Sept 2025 at 01:18, Michael Paquier <michael@paquier.xyz> wrote:
>
> I'd be pretty much OK with this version of the patch, plus a few
> tweaks.

Agreed.

In numeric_div_safe():

+div_error:
+    ereturn(escontext, NULL,
+            errcode(ERRCODE_DIVISION_BY_ZERO),
+            errmsg("division by zero"));

I would make that label something more specific like "division_by_zero".

> Dean, you have commented on this patch before me and the numeric code
> is something you have touched more than me lately (the LSN part is
> tainted with my fingerprints, but it's minimal here).  Would you
> prefer handle this patch yourself?  I'm OK to perform a final lookup
> of it for commit, just won't get in your way if you have been looking
> at it seriously.

I don't mind. I haven't looked at it too closely, but I'm broadly
happy with it. I think any issues are probably now minor cosmetic
things, so if you've been looking in more detail and are happy to
commit it, then go ahead. Otherwise, I can take it if you prefer.

Regards,
Dean