Re: deadlock detected when inserting data - Mailing list pgsql-general

From Oliver Elphick
Subject Re: deadlock detected when inserting data
Date
Msg-id 1071532901.27367.408.camel@linda.lfix.co.uk
Whole thread Raw
In response to Re: deadlock detected when inserting data  (Jenny Zhang <jenny@osdl.org>)
List pgsql-general
On Mon, 2003-12-15 at 22:43, Jenny Zhang wrote:
> Another question is, I've read that "Each PL/pgSQL function is
> automatically treated as a single transaction
> by Postgres" at http://www.geocrawler.com/archives/3/6/2002/6/0/9050299/
> is it still true?  Even though the shopping_cart function calls A and A
> has BEGIN and COMMIT in it, pgsql won't commit till all the shopping_cart is done?

It is true.  If no transaction is already in progress, each statement is
a transaction in itself (or begins a transaction if autocommit is off).
Therefore any function must necessarily execute inside a transaction.

You cannot use BEGIN in a PL/pgSQL function to begin a transaction,
since a transaction is already in progress.  In PL/pgSQL, BEGIN marks
the start of the executed code (and follows any declarations).

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "The fear of the LORD is the instruction of wisdom, and
      before honour is humility."      Proverbs 15:33



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Relational data model dead?
Next
From: Peter Eisentraut
Date:
Subject: Re: [NOVICE] PostgreSQL Training