Unix Technical Forum

Assigning null to an array element in plpgsql

This is a discussion on Assigning null to an array element in plpgsql within the pgsql Bugs forums, part of the PostgreSQL category; --> Hi all, I believe this is a bug. The following function returns 'foo' instead of null: --------------- create or ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:27 AM
Eugene Chow
 
Posts: n/a
Default Assigning null to an array element in plpgsql

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:27 AM
Tom Lane
 
Posts: n/a
Default Re: Assigning null to an array element in plpgsql

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:29 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com