Home > Archive > PostgreSQL Bugs > November 2005 > Assigning null to an array element in plpgsql









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Assigning null to an array element in plpgsql
Eugene Chow

2005-11-16, 7:25 am

Hi all,

I believe this is a bug. The following function returns 'foo' instead
of null:
---------------
create or replace function test() returns varchar as '
declare
s varchar[] := ''{}'';
begin
s[1] := ''foo'';
s[1] := null;

return s[1];
end;
' language 'plpgsql';
----------------

If s is not initialized to an empty set in the declaration, the
function works as expected. I'm running 7.4.9 on FreeBSD 5.4.

Gene


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly

Tom Lane

2005-11-16, 9:24 am

Eugene Chow <gene@paragonam.com> writes:
> I believe this is a bug. The following function returns 'foo' instead
> of null:


NULLs in arrays aren't supported; the system interprets an attempt to
store a NULL into an array element as a no-op. Perhaps it should have
raised an error instead, but it's been that way for a long time and
we're not likely to change the behavior of existing releases.

(I'm actually right in the middle of adding support for null array
elements, but it won't appear until 8.2.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com