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

From Richard Huxton
Subject Re: example of really weird caching (or whatever) problem
Date
Msg-id 4925785D.1060306@archonet.com
Whole thread Raw
In response to example of really weird caching (or whatever) problem  ("Brandon Metcalf" <bmetcalf@nortel.com>)
Responses Re: example of really weird caching (or whatever) problem
List pgsql-general
Brandon Metcalf wrote:
> Here is an example of the caching problem I described yesterday in a
> post.  I have the following tables:

> And here is the SQL for the function and trigger definitions:
>
>   CREATE OR REPLACE FUNCTION bmetcalf.foo_func()
>   RETURNS TRIGGER
>   LANGUAGE plperlu
>   AS $$
>   require 5.8.0;
>
>   my $table = $_TD->{relname};
>   warn "table name is $table";
>   warn "BWM before call: table name is $table";
>
>   do_delete();
>
>   return 'SKIP';
>
>   sub do_delete {
>       warn "BWM in call: table name is $table";
>   }
>
>   $$;

Umm - you've got a named closure inside your funciton here - "sub
do_delete".

It's warning isn't using the "my $table" variable, it's using a
localised copy of that variable. That gets defined when the sub is
defined, which will be on the first call (my $table=foo2) and still
exists, unchanged on the second call (my $table=foo1).

Warning - can't remember if I'm using the right terminology on the
above, although I think it's the right diagnosis.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: "Brandon Metcalf"
Date:
Subject: example of really weird caching (or whatever) problem
Next
From: Peter Eisentraut
Date:
Subject: Re: start/stop error message