Re: after insert trigger hangs

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: after insert trigger hangs
Дата
Msg-id 28727.1142607392@sss.pgh.pa.us
обсуждение исходный текст
Ответ на after insert trigger hangs  (pradeep singh <lets_begin_with_me@yahoo.com>)
Список pgsql-general
pradeep singh <lets_begin_with_me@yahoo.com> writes:
> CREATE OR REPLACE FUNCTION recalc_add_bitset()
> RETURNS trigger AS $$

>     use DBI;
>     my $dbname = 'database_name';
>     my $dbh = DBI->connect("dbi:Pg:dbname='$dbname'",
> "postgres_user_id", "password", {AutoCommit => 0,
> RaiseError=>1});

That (using DBI in a trigger) is a really bad idea in most cases.
The DBI connection is a separate transaction that (a) can't see
the uncommitted results of your transaction and (b) can have lock
conflicts against your transaction.  I suspect (b) explains the
hang, though the part of the problem you've shown us doesn't make
it clear exactly why there's a conflict.

plperl has a database access protocol, learn to use it.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Slow trigger on identical DB but different machine
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Encountering NULLS in plpgsql