Re: Problem compiling function with BEGIN WORK; COMMIT WORK;

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Problem compiling function with BEGIN WORK; COMMIT WORK;
Дата
Msg-id 4BD3ABC7.9010206@postnewspapers.com.au
обсуждение исходный текст
Ответ на Problem compiling function with BEGIN WORK; COMMIT WORK;  (Andre Lopes <lopes80andre@gmail.com>)
Список pgsql-general
On 25/04/2010 9:07 AM, Andre Lopes wrote:
> Hi,
>
> I need to use the BEGIN WORK; and COMMIT WORK; to lock a table when I'am
> doing a SELECT and UPDATE operation.

PostgreSQL's server-side functions do *not* support transaction
management. They're functions that're used inside an existing transaction.

However, if you do not explcitly BEGIN a transaction before calling your
function, the statement your function runs in will start and stop its
own transaction. In other words, these two things are equivalent:

BEGIN;
SELECT my_function();
COMMIT;

and

SELECT my_function();

(outside an existing transaction)



Because your function is *always* inside a transaction, it can always
acquire locks and the like. It doesn't need to explicitly start a
transaction first.

--
Craig Ringer


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: how to set CACHEDEBUG ?
Следующее
От: John Gage
Дата:
Сообщение: Re: ISP provider with postgres and perl dbi