dbTalk Databases Forums  

[BUGS] wrong inicializied array in plpgsql

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] wrong inicializied array in plpgsql in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pavel Stehule
 
Posts: n/a

Default [BUGS] wrong inicializied array in plpgsql - 09-14-2003 , 12:13 PM






Hello

I am testing long array values. I tryed write simple function in plpgsql
for this. I found maybe a bug. Array in plpgsql without explicit init
(empty array) don't work;

CREATE OR REPLACE FUNCTION foo1() RETURNS FLOAT AS '
DECLARE f FLOAT [];
BEGIN
f[1] := 10.0;
RETURN f[1];
END' LANGUAGE plpgsql;

cyril=> select foo1();
foo1
------


(1 row)

CREATE OR REPLACE FUNCTION foo2() RETURNS FLOAT AS '
DECLARE f FLOAT [] DEFAULT ''{}'';
BEGIN
f[1] := 10.0;
RETURN f[1];
END' LANGUAGE plpgsql;

cyril=> select foo2();
foo2
------
10
(1 row)


regards
Pavel Stehule



---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] wrong inicializied array in plpgsql - 09-14-2003 , 12:42 PM






Pavel Stehule <stehule (AT) kix (DOT) fsv.cvut.cz> writes:
Quote:
I am testing long array values. I tryed write simple function in plpgsql
for this. I found maybe a bug. Array in plpgsql without explicit init
(empty array) don't work;
This isn't a bug; or at least, it's not plpgsql's fault. The array
variable is initially NULL, same as any other plpgsql variable you
didn't explicitly initialize. And assigning to an element of a NULL
array yields another NULL array.

Perhaps that behavior should be changed, but I think it would require
making unsupported assumptions about what the user wants...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.