Re: plgpsql and transactions

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: plgpsql and transactions
Date: 2006-04-07 23:36:55
Message-ID: 200604071936.55286.terry@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> >
> > 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.

Understanding is good. You need to read the documentation on transactions:
http://www.postgresql.org/docs/7.4/interactive/tutorial-transactions.html

and Concurrency control:
http://www.postgresql.org/docs/7.4/interactive/mvcc.html

>
> 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?

At the end of the transaction.

>
> 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.

Again, reading the docs on concurrency control and transactions will answer
these questions.

>
>
>
> --
> Bill Moseley
> moseley(at)hank(dot)org
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2006-04-07 23:38:35 Re: Allow linking against OpenSSL? (Was Re: Debian package
Previous Message Leif B. Kristensen 2006-04-07 23:35:59 Re: Debian package for freeradius_postgresql module