"select myfunc(fields) from my table" inside plpgslq proc - Mailing list pgsql-general

From Jeff Anto
Subject "select myfunc(fields) from my table" inside plpgslq proc
Date
Msg-id 20020307122628.43429.qmail@web20903.mail.yahoo.com
Whole thread Raw
Responses Re: "select myfunc(fields) from my table" inside plpgslq proc  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: "select myfunc(fields) from my table" inside plpgslq  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
Hi all,
the following is very surprising to me.
It seems that semantic of
select INTO var myfunc(...) from ... are different in
plpgsql program than pure sql
select myfunc(...) from ...
should the former take into account only one rows
while the latter take into account all rows ?
I am sure that in past version (7.1.2 ?) both were
equivalent...

DROP   function print(int4);
CREATE function print(int4) returns bool AS'
BEGIN
  RAISE NOTICE ''print arg: %'',$1;
  RETURN true;
END;
' language 'plpgsql';

drop   table mytable;
create table mytable(num int4);

insert into mytable VALUES ('1');
insert into mytable VALUES ('2');

-- this is OK of course:
SELECT print(num) FROM mytable;

DROP   FUNCTION test();
CREATE FUNCTION test() RETURNS OPAQUE AS '
DECLARE
    lost          bool;

BEGIN
  SELECT into lost print(num) FROM mytable;

  RETURN NEW;
END;
' language 'plpgsql';

DROP   TABLE test;
CREATE TABLE test(foo int4);

CREATE TRIGGER test AFTER INSERT ON test
  FOR EACH ROW EXECUTE PROCEDURE test()
;

-- the following is surprising, comparing to
-- the previous pure SQL select:

INSERT INTO test VALUES ('1');


___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: Have problems with 7.1 -> 7.2 upgrade
Next
From: "news.apexsc.com"
Date:
Subject: VACUUM query