Arrays: missing/skipped elements

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Arrays: missing/skipped elements
Date: 2002-12-02 19:13:13
Message-ID: 20021202191314.42E5E103C7@polaris.pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I know from the docs that array elements can't have a null value. It appears,
therefore, that Postgres fills in missing elements with zero-length strings,
the int or numeric value zero, etc. appropriate to the data type. Is my
interpretation correct and is this documented/likely to continue in future
versions?

My test (extraneous lines removed):

create table foo (bar text[]);
insert into foo values ('{"a","b","c"}');
insert into foo values ('{,,,"4"}');

select * from foo;
{a,b,c}
{"","","",4}

select '-' || bar[1] || '-' from foo;
-a-
--

select count(*) from foo where bar[1] = '';
1

Cheers,
Steve

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hunter Hillegas 2002-12-02 19:26:00 7.3 on OS X HOWTO
Previous Message Nicolai Tufar 2002-12-02 18:54:02 Re: timing queries?