Re: example of really weird caching (or whatever) problem - Mailing list pgsql-general

From Brandon Metcalf
Subject Re: example of really weird caching (or whatever) problem
Date
Msg-id Pine.LNX.4.58L.0811200934090.13425@cash.us.nortel.com
Whole thread Raw
In response to Re: example of really weird caching (or whatever) problem  ("Brandon Metcalf" <bmetcalf@nortel.com>)
List pgsql-general
b == bmetcalf@cash.us.nortel.com writes:

 b> d == dev@archonet.com writes:

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

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


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

That should read it's _not_ in the Perl code.


 b> different DELETEs which cause two different invocations of the same
 b> trigger.


 b>  d> #!/usr/bin/perl

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

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

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

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

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





--
Brandon

pgsql-general by date:

Previous
From: "Brandon Metcalf"
Date:
Subject: Re: example of really weird caching (or whatever) problem
Next
From: "Jean-Christophe Arnu"
Date:
Subject: Re: lesslog "incorrect resource manager data checksum."