Plperl and my() lexical variables bug?
От | Philippe Lang |
---|---|
Тема | Plperl and my() lexical variables bug? |
Дата | |
Msg-id | 6C0CF58A187DA5479245E0830AF84F421D0E5C@poweredge.attiksystem.ch обсуждение исходный текст |
Ответы |
Re: Plperl and my() lexical variables bug?
|
Список | pgsql-general |
Hi, I have something strange here, with Postgresql 8.1.4 under Linux ES 4, installed from the PG Group binaries: If I run this script: ---------------- CREATE OR REPLACE FUNCTION foo() RETURNS void AS $$ my $val; sub init { $val = @_[0]; elog(NOTICE, "1: @_[0]\n"); } &init(12); elog(NOTICE, "2: $val\n"); $$ LANGUAGE 'plperl'; select * from foo(); ---------------- I get in return something correct: ---------------- NOTICE: 1: 12 NOTICE: 2: 12 Total query runtime: 63 ms. Data retrieval runtime: 62 ms. 1 rows retrieved. ---------------- But then, if I simply call the function, with: ---------------- select * from foo(); ---------------- I get: ---------------- NOTICE: 1: 12 NOTICE: 2: Total query runtime: 63 ms. Data retrieval runtime: 62 ms. 1 rows retrieved. ---------------- $val variable is missing. Even more strange: if I replace "my $val;" with "$val;", this does not happen at all: ---------------- CREATE OR REPLACE FUNCTION foo() RETURNS void AS $$ $val; sub init { $val = @_[0]; elog(NOTICE, "1: @_[0]\n"); } &init(12); elog(NOTICE, "2: $val\n"); $$ LANGUAGE 'plperl'; ---------------- Now I can call the function with ---------------- select * from foo(); ---------------- it works as expected: ---------------- NOTICE: 1: 12 NOTICE: 2: 12 Total query runtime: 390 ms. Data retrieval runtime: 797 ms. 1 rows retrieved. ---------------- Am I missing something maybe? It sounds like a bug with lexical variables to me... Cheers, ---------------------------------- Philippe Lang, Ing. Dipl. EPFL Attik System rte de la Fonderie 2 1700 Fribourg Switzerland http://www.attiksystem.ch Tel: +41 (26) 422 13 75 Fax: +41 (26) 422 13 76
Вложения
В списке pgsql-general по дате отправления: