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

From: Richard Huxton <dev(at)archonet(dot)com>
To: Brandon Metcalf <bmetcalf(at)nortel(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: example of really weird caching (or whatever) problem
Date: 2008-11-20 14:46:53
Message-ID: 4925785D.1060306@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2008-11-20 14:52:58 Re: start/stop error message
Previous Message Brandon Metcalf 2008-11-20 14:31:24 example of really weird caching (or whatever) problem