Re: 7.2 crash...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: 7.2 crash...
Дата
Msg-id 28474.1016770978@sss.pgh.pa.us
обсуждение исходный текст
Ответ на 7.2 crash...  ("Rod Taylor" <rbt@zort.ca>)
Ответы Re: 7.2 crash...  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: 7.2 crash...  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-bugs
"Rod Taylor" <rbt@zort.ca> writes:
> 7.2 crashes with the below function:
> CREATE OR REPLACE FUNCTION runMaintenance()
> RETURNS BOOL AS '
>   VACUUM;
>   SELECT TRUE;
> ' LANGUAGE sql;

AFAICS there is no way that we can support VACUUM inside a function;
the forced transaction commits that VACUUM performs will recycle any
memory allocated by the function executor, leading to death and
destruction upon return from VACUUM.

Accordingly, what we really need is a way of preventing VACUUM from
executing in the above scenario.  The IsTransactionBlock() test it
already has isn't sufficient.

I have thought of something that probably would be sufficient:

    if (!MemoryContextContains(QueryContext, vacstmt))
        elog(ERROR, "VACUUM cannot be executed from a function");

This is truly, horribly ugly ... but it'd get the job done, because only
interactive queries will generate parsetrees in QueryContext.

Can someone think of a better way?

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: 7.2 crash...
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: 7.2 crash...