Re: example of really weird caching (or whatever) problem

From: "Brandon Metcalf" <bmetcalf(at)nortel(dot)com>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: example of really weird caching (or whatever) problem
Date: 2008-11-20 15:32:17
Message-ID: Pine.LNX.4.58L.0811200929110.13425@cash.us.nortel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

d == dev(at)archonet(dot)com writes:

d> Brandon Metcalf wrote:
d> > Yep, it seems that's the problem. If I pass in $table and use a
d> > lexical variable defined inside do_delete(), the problem goes away.
d> > So, this is where my understanding of how triggers work lacks. For a
d> > given session, each execution of a trigger isn't completely
d> > independent?

d> Nothing to do with triggers - it's all to do with your Perl code.

I respectfully disagree because if I don't execute a DELETE on foo2 as
shown in my original email, the problem doesn't occur. Somewhere in
the trigger execution it's remembering the first table on which the
trigger fired. So, the information about foo2 is coming from
somewhere and it's in the Perl code. In other words, I performing two
different DELETEs which cause two different invocations of the same
trigger.

d> #!/usr/bin/perl

d> sub foo {
d> my $x = shift;
d> print "foo x = $x\n";
d> bar();
d> return;

d> sub bar {
d> print "bar x = $x\n";
d> }
d> }

d> foo(1);
d> foo(2);
d> exit;

d> $ ./perl_example.pl
d> foo x = 1
d> bar x = 1
d> foo x = 2
d> bar x = 1

d> If you use warnings it'll tell you about it too with this example.

--
Brandon

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brandon Metcalf 2008-11-20 15:34:25 Re: example of really weird caching (or whatever) problem
Previous Message Richard Huxton 2008-11-20 15:20:05 Re: example of really weird caching (or whatever) problem