1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Change pg_lsn_in_internal() to use soft error reporting

pg_lsn includes pg_lsn_in_internal() for the purpose of parsing a LSN
position for the GUC recovery_target_lsn (21f428ebde).  It relies on a
boolean called "have_error" that would be set when the LSN parsing
fails, then let its callers handle any errors.

d9f7f5d32f has added support for soft error reporting.  This commit
removes some boilerplate code and switches the routine to use soft error
reporting directly, giving to the callers of pg_lsn_in_internal()
the possibility to be fed the error message generated on failure.

pg_lsn_in_internal() routine is renamed to pg_lsn_in_safe(), for
consistency with other similar routines that are given an escontext.

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
This commit is contained in:
Michael Paquier
2025-09-05 12:59:29 +09:00
parent d814d7fc3d
commit ae45312008
3 changed files with 21 additions and 23 deletions

View File

@@ -4834,10 +4834,10 @@ check_recovery_target_lsn(char **newval, void **extra, GucSource source)
{
XLogRecPtr lsn;
XLogRecPtr *myextra;
bool have_error = false;
ErrorSaveContext escontext = {T_ErrorSaveContext};
lsn = pg_lsn_in_internal(*newval, &have_error);
if (have_error)
lsn = pg_lsn_in_safe(*newval, (Node *) &escontext);
if (escontext.error_occurred)
return false;
myextra = (XLogRecPtr *) guc_malloc(LOG, sizeof(XLogRecPtr));