Re: ALTER TABLE ... NOREWRITE option

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: ALTER TABLE ... NOREWRITE option
Дата
Msg-id m2txryudgt.fsf@2ndQuadrant.fr
обсуждение исходный текст
Ответ на Re: ALTER TABLE ... NOREWRITE option  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: ALTER TABLE ... NOREWRITE option
Список pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
> On 2012-12-06 18:42:22 +0000, Simon Riggs wrote:
>> "in-between state" means what? And what danger do you see?
>
> For example during table rewrites we have a temporary pg_class entry
> thats a full copy of the table, with a separate oid, relfilenode and
> everything. That gets dropped rather unceremonially, without the usual
> safety checks. If the user did anything referencing that table we would
> possibly have a corrupt catalog or even a segfault at our hands.
>
> For normal triggers the code takes quite some care to avoid such
> dangers.

I think we need to be solving that problem when we implement new firing
points for event trigger. The 'table_rewrite' event needs to fire at a
time when the code can cope with it. That's the main difficulty in
adding events in that system, asserting their code location safety.

> Event triggers get called *during* the ALTER TABLE. So if were not
> careful they see something thats not easy to handle.

They need to fire before catalogs are modified, or after, not in
between, I agree with that. I don't see other ways of implementing that
than carefully placing the call to user code in the backend's code.

> I am for example not sure what would happen if we had a "rewrite" event
> trigger which inserts a log entry into a logtable. Not a stupid idea,
> right?
> Now imagine we had a deferred unique key on that logtable and the
> logtable is the one that gets rewritten...

The log insert needs to happen either before or after the rewrite, in
terms of catalog state. I don't see any magic bullet here.

-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support



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

Предыдущее
От: Dimitri Fontaine
Дата:
Сообщение: Re: in-catalog Extension Scripts and Control parameters (templates?)
Следующее
От: Asif Rehman
Дата:
Сообщение: Re: why can't plpgsql return a row-expression?