check_recovery_target_lsn() does a PG_CATCH without a throw - Mailing list pgsql-hackers

From Andres Freund
Subject check_recovery_target_lsn() does a PG_CATCH without a throw
Date
Msg-id 20190611061115.njjwkagvxp4qujhp@alap3.anarazel.de
Whole thread Raw
Responses Re: check_recovery_target_lsn() does a PG_CATCH without a throw
Re: check_recovery_target_lsn() does a PG_CATCH without a throw
List pgsql-hackers
Hi,

While working on fixing [1] I noticed that 2dedf4d9a899 "Integrate
recovery.conf into postgresql.conf" added two non-rethrowing PG_CATCH
uses. That's not OK. See

https://www.postgresql.org/message-id/1676.1548726280%40sss.pgh.pa.us
https://postgr.es/m/20190206160958.GA22304%40alvherre.pgsql
etc.

static bool
check_recovery_target_time(char **newval, void **extra, GucSource source)
{
    if (strcmp(*newval, "") != 0)
    {
        TimestampTz time;
        TimestampTz *myextra;
        MemoryContext oldcontext = CurrentMemoryContext;

        /* reject some special values */
        if (strcmp(*newval, "epoch") == 0 ||
            strcmp(*newval, "infinity") == 0 ||
            strcmp(*newval, "-infinity") == 0 ||
            strcmp(*newval, "now") == 0 ||
            strcmp(*newval, "today") == 0 ||
            strcmp(*newval, "tomorrow") == 0 ||
            strcmp(*newval, "yesterday") == 0)
        {
            return false;
        }

        PG_TRY();
        {
            time = DatumGetTimestampTz(DirectFunctionCall3(timestamptz_in,
                                                           CStringGetDatum(*newval),
                                                           ObjectIdGetDatum(InvalidOid),
                                                           Int32GetDatum(-1)));
        }
        PG_CATCH();
        {
            ErrorData  *edata;

            /* Save error info */
            MemoryContextSwitchTo(oldcontext);
            edata = CopyErrorData();
            FlushErrorState();

            /* Pass the error message */
            GUC_check_errdetail("%s", edata->message);
            FreeErrorData(edata);
            return false;
        }
        PG_END_TRY();

same in check_recovery_target_lsn.

I'll add an open item.

Greetings,

Andres Freund

[1] CALDaNm1KXK9gbZfY-p_peRFm_XrBh1OwQO1Kk6Gig0c0fVZ2uw@mail.gmail.com



pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: Multivariate MCV stats can leak data to unprivileged users
Next
From: "kuroda.hayato@fujitsu.com"
Date:
Subject: RE: [PATCH] memory leak in ecpglib