From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pradeep singh <lets_begin_with_me(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: after insert trigger hangs |
Date: | 2006-03-17 14:56:32 |
Message-ID: | 28727.1142607392@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
pradeep singh <lets_begin_with_me(at)yahoo(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2006-03-17 15:29:11 | Re: Encountering NULLS in plpgsql |
Previous Message | Tom Lane | 2006-03-17 14:50:11 | Re: Slow trigger on identical DB but different machine |