Strange bahaviour

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Strange bahaviour
Date: 2002-08-12 13:26:03
Message-ID: 20020812132603.GA32484@feivel.credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I just got the following example:

DROP TABLE foo;
CREATE TABLE foo (login varchar(100));
INSERT INTO foo values ('abc');

DROP FUNCTION footest1(varchar(100));
CREATE FUNCTION footest1(varchar(100)) RETURNS varchar(100) AS '
DECLARE
login varchar(100);
BEGIN
SELECT INTO login login FROM foo LIMIT 1;
RETURN login;
END;
' LANGUAGE 'plpgsql';

DROP FUNCTION footest2(varchar(100));
CREATE FUNCTION footest2(varchar(100)) RETURNS varchar(100) AS '
DECLARE
fieldname varchar(100);
BEGIN
SELECT INTO fieldname login FROM foo LIMIT 1;
RETURN fieldname;
END;
' LANGUAGE 'plpgsql';

SELECT footest1('foobar');
SELECT footest2('foobar');

The first select returns NULL while the second correctly returns 'abc'.
I just wonder why it is that way. The only difference seems to be the
name of the variable which in footest1 equals the attribute name.

Now I can guess what happens but I wonder if this is the desired
behaviour.

Michael
--
Michael Meskes
Michael(at)Fam-Meskes(dot)De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-08-12 13:40:12 Re: Strange bahaviour
Previous Message Greg Copeland 2002-08-12 13:24:16 Re: [SECURITY] DoS attack on backend possible (was: Re: