check_recovery_target_lsn() does a PG_CATCH without a throw

Поиск
Список
Период
Сортировка
От Andres Freund
Тема check_recovery_target_lsn() does a PG_CATCH without a throw
Дата
Msg-id 20190611061115.njjwkagvxp4qujhp@alap3.anarazel.de
обсуждение исходный текст
Ответы Re: check_recovery_target_lsn() does a PG_CATCH without a throw  (Sergei Kornilov <sk@zsrv.org>)
Re: check_recovery_target_lsn() does a PG_CATCH without a throw  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Список 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 по дате отправления:

Предыдущее
От: John Naylor
Дата:
Сообщение: Re: Multivariate MCV stats can leak data to unprivileged users
Следующее
От: "kuroda.hayato@fujitsu.com"
Дата:
Сообщение: RE: [PATCH] memory leak in ecpglib