Re: deadlock detected when inserting data

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Jenny Zhang <jenny(at)osdl(dot)org>
Cc: Ian Harding <iharding(at)tpchd(dot)org>, PostgreSQL general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: deadlock detected when inserting data
Date: 2003-12-16 00:01:42
Message-ID: 1071532901.27367.408.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)Elphick(at)lfix(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2003-12-16 00:06:32 Re: ISO 8601 "Time Intervals" of the "format with time-unit
Previous Message Kent L. Nasveschuk 2003-12-15 23:35:26 Re: FoxPro Vs. PostgreSQL