pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Empty array IS NULL?
6+ messages / 3 participants
[nested] [flat]

* Empty array IS NULL?
@ 2004-06-28 16:01 Markus Bertheau <twanger@bluetwanger.de>
  2004-06-28 16:26 ` Re: Empty array IS NULL? Joe Conway <mail@joeconway.com>
  2004-06-28 19:05 ` Re: Empty array IS NULL? Greg Stark <gsstark@mit.edu>
  0 siblings, 2 replies; 6+ messages in thread

From: Markus Bertheau @ 2004-06-28 16:01 UTC (permalink / raw)
  To: pgsql-sql

Hi,

is the empty array representable in PostgreSQL, and is it
distinguishable from NULL?

oocms=# SELECT ARRAY[1, 2];
 array
-------
 {1,2}
(1 запись)
 
oocms=# SELECT '{1, 2}'::INT[];
 int4
-------
 {1,2}
(1 запись)
 
oocms=# SELECT ARRAY[];
ERROR:  syntax error at or near "]" at character 14
oocms=# SELECT '{}'::INT[];
 int4
------
 {}
(1 запись)
 
oocms=# SELECT ARRAY(SELECT 1 UNION SELECT 2);
 ?column?
----------
 {1,2}
(1 запись)
 
oocms=# SELECT ARRAY(SELECT 1 WHERE FALSE);
 ?column?
----------
  
(1 запись)
 

-- 
Markus Bertheau <twanger@bluetwanger.de>




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Empty array IS NULL?
  2004-06-28 16:01 Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
@ 2004-06-28 16:26 ` Joe Conway <mail@joeconway.com>
  2004-06-28 17:06   ` Re: Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
  1 sibling, 1 reply; 6+ messages in thread

From: Joe Conway @ 2004-06-28 16:26 UTC (permalink / raw)
  To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql

Markus Bertheau wrote:
> is the empty array representable in PostgreSQL, and is it
> distinguishable from NULL?

Yes, and yes.

regression=# select '{}'::int[];
  int4
------
  {}
(1 row)

regression=# select NULL::int[];
  int4
------

(1 row)

Since NULL array elements are not currently supported, attempting to 
construct an array with a NULL element results in NULL, not an empty array.

Joe



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Empty array IS NULL?
  2004-06-28 16:01 Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
  2004-06-28 16:26 ` Re: Empty array IS NULL? Joe Conway <mail@joeconway.com>
@ 2004-06-28 17:06   ` Markus Bertheau <twanger@bluetwanger.de>
  2004-06-28 17:56     ` Re: Empty array IS NULL? Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Markus Bertheau @ 2004-06-28 17:06 UTC (permalink / raw)
  To: Joe Conway <mail@joeconway.com>; +Cc: pgsql-sql

В Пнд, 28.06.2004, в 18:26, Joe Conway пишет:
> Markus Bertheau wrote:
> > is the empty array representable in PostgreSQL, and is it
> > distinguishable from NULL?
> 
> Yes, and yes.
> 
> Since NULL array elements are not currently supported, attempting to 
> construct an array with a NULL element results in NULL, not an empty array.

Thanks.

How do I specify an empty array with the standard syntax?

-- 
Markus Bertheau <twanger@bluetwanger.de>




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Empty array IS NULL?
  2004-06-28 16:01 Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
  2004-06-28 16:26 ` Re: Empty array IS NULL? Joe Conway <mail@joeconway.com>
  2004-06-28 17:06   ` Re: Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
@ 2004-06-28 17:56     ` Joe Conway <mail@joeconway.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Joe Conway @ 2004-06-28 17:56 UTC (permalink / raw)
  To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql

Markus Bertheau wrote:
> How do I specify an empty array with the standard syntax?
> 

Actually, up until the 7.4 release, the array literal syntax was the 
*only* syntax (i.e. '{...}'). The newer array constructor expression 
(i.e. ARRAY[...]) does not yet support creating empty arrays -- there 
are some non-trivial technical difficulties to be solved. Unfortunately 
that won't change in the upcoming 7.5 either :( -- perhaps for 7.6.

Joe



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Empty array IS NULL?
  2004-06-28 16:01 Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
@ 2004-06-28 19:05 ` Greg Stark <gsstark@mit.edu>
  1 sibling, 0 replies; 6+ messages in thread

From: Greg Stark @ 2004-06-28 19:05 UTC (permalink / raw)
  To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql


Markus Bertheau <twanger@bluetwanger.de> writes:

> oocms=# SELECT ARRAY(SELECT 1 WHERE FALSE);
>  ?column?
> ----------
>   

This one seems strange to me. Shouldn't it result in an empty array?


-- 
greg




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Empty array IS NULL?
@ 2004-06-28 17:56 Joe Conway <mail@joeconway.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Joe Conway @ 2004-06-28 17:56 UTC (permalink / raw)
  To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql

Markus Bertheau wrote:
> How do I specify an empty array with the standard syntax?

Actually, up until the 7.4 release, the array literal syntax was the 
*only* syntax (i.e. '{...}'). The newer array constructor expression 
(i.e. ARRAY[...]) does not yet support creating empty arrays -- there 
are some non-trivial technical difficulties to be solved. Unfortunately 
that won't change in the upcoming 7.5 either :( -- perhaps for 7.6.

Joe

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2004-06-28 19:05 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-28 16:01 Empty array IS NULL? Markus Bertheau <twanger@bluetwanger.de>
2004-06-28 16:26 ` Joe Conway <mail@joeconway.com>
2004-06-28 17:06   ` Markus Bertheau <twanger@bluetwanger.de>
2004-06-28 17:56     ` Joe Conway <mail@joeconway.com>
2004-06-28 19:05 ` Greg Stark <gsstark@mit.edu>
2004-06-28 17:56 Re: Empty array IS NULL? Joe Conway <mail@joeconway.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox