Re: plgpsql and transactions

Поиск
Список
Период
Сортировка
От Bill Moseley
Тема Re: plgpsql and transactions
Дата
Msg-id 20060407232507.GA10428@hank.org
обсуждение исходный текст
Ответ на Re: plgpsql and transactions  (Terry Lee Tucker <terry@esc1.com>)
Ответы Re: plgpsql and transactions  (Terry Lee Tucker <terry@esc1.com>)
Список pgsql-general
On Thu, Apr 06, 2006 at 03:48:15PM -0500, Terry Lee Tucker wrote:
> >
> >     -- fires a trigger that updates more than one table
> >     insert into semething (default);
> >
> > and:
> >
> >     begin;
> >     -- fires a trigger that updates more than one table
> >     insert into somthing (default);
> >     commit;
> >
>
> In the latter, you have expanded the scope of the transaction; which,
> sometimes you might want to do.

Yes, I might.  But, I'd like to understand it so I do know when I might
or might not want to do it.

Say I have a BEFORE INSERT trigger that does a table lock.  When
is that lock released?  At the end of the trigger?  Or after the
INSERT has completed?

For example, say I want to set a column on the row I'm inserting based
on what's already in the table.  So I lock the table in the trigger
and check the current status of the table and set the column based on
that current status.

I want to make sure that between the time the trigger completes and
when the insert finally happens that another session can't also do an
insert and see the same table state.



--
Bill Moseley
moseley@hank.org


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

Предыдущее
От: Tyler MacDonald
Дата:
Сообщение: Re: Debian package for freeradius_postgresql module
Следующее
От: "Leif B. Kristensen"
Дата:
Сообщение: Re: Debian package for freeradius_postgresql module