From: | Steve Crawford <scrawford(at)pinpointresearch(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Arrays: null values beyond end of array |
Date: | 2002-12-03 21:01:36 |
Message-ID: | 20021203210136.B13CD103C2@polaris.pinpointresearch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The docs say that arrays don't contain SQL nulls. This appears to be true
_within_ the array. Selecting an element beyond the end of the array,
however, does return null and generates no error.
Is the ability to query an array element beyond the end documented somewhere
as legal and is this behavior likely to continue?
This behavior works well for me but I don't want to build an app around it
unless I know it is legal and not just an accidental discovery. My tests:
The data:
steve=# select * from foo;
id | bar
----+-----------------
1 | {one}
2 | {one,two}
3 | {one,two,three}
4 | {"","",""}
(4 rows)
Looking for nulls:
steve=# select id, case when bar[3] is null then 'I am null' else bar[3] end
as bar3 from foo;
id | bar3
----+-----------
1 | I am null
2 | I am null
3 | three
4 |
(4 rows)
Cheers,
Steve
From | Date | Subject | |
---|---|---|---|
Next Message | Felipe Schnack | 2002-12-03 21:09:01 | Re: Postgresql -- initial impressions and comments |
Previous Message | wsheldah | 2002-12-03 21:01:26 | Re: Postgresql -- initial impressions and comments |