Re: locks in CREATE TRIGGER, ADD FK

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: locks in CREATE TRIGGER, ADD FK
Дата
Msg-id 1385.1111550616@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: locks in CREATE TRIGGER, ADD FK  (Neil Conway <neilc@samurai.com>)
Ответы Re: locks in CREATE TRIGGER, ADD FK  (Neil Conway <neilc@samurai.com>)
Список pgsql-hackers
Neil Conway <neilc@samurai.com> writes:
>> AndrewSN pointed out on IRC that ALTER TABLE ... ADD FOREIGN KEY and 
>> CREATE TRIGGER both acquire AccessExclusiveLocks on the table they are 
>> adding triggers to (the PK table, in the case of ALTER TABLE). Is this 
>> necessary? I don't see why we can't allow SELECT queries on the table to 
>> proceed while the trigger is being added.

> Attached is a patch that changes both to use ShareRowExclusiveLock, and 
> updates the documentation accordingly. I'll apply this later today, 
> barring any objections.

I don't think this has been adequately thought through at all ... but
at least make it ExclusiveLock.  What is the use-case for allowing
SELECT FOR UPDATE in parallel with this?  One may suppose that someone
doing SELECT FOR UPDATE intends an UPDATE.  (No, don't tell me about
foreign keys.  Alvaro is going to fix that.)

As Chris suggests nearby, this is really only the tip of the iceberg.
I would prefer to see someone do a survey of all our DDL commands and
put forward a coherent proposal for minimum required locks for all of
them.
        regards, tom lane


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

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: locks in CREATE TRIGGER, ADD FK
Следующее
От: Tom Lane
Дата:
Сообщение: Re: locks in CREATE TRIGGER, ADD FK