From: | Guillaume Lelarge <guillaume(at)lelarge(dot)info> |
---|---|
To: | Martijn van Oosterhout <kleptog(at)svana(dot)org>, andrew(at)dunslane(dot)net |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: NULL in arrays |
Date: | 2006-11-05 22:47:32 |
Message-ID: | 454E6A04.8090302@lelarge.info |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Martijn van Oosterhout a écrit :
> On Sun, Nov 05, 2006 at 08:23:59PM +0100, Guillaume Lelarge wrote:
>> Setting a NULL value seems to work.
>>
>> amarok=# SELECT ARRAY['a',"NULL",'c'];
>> ERROR: column "NULL" does not exist
>> LINE 1: SELECT ARRAY['a',"NULL",'c'];
>> ^
>>
>> Using double quotes throws an error.
>
> This is because double-quotes remove the "specialness" of the word
> null, double-quotes is what you'd need if you had a column called
> "NULL". That's why it's complaining about unknown columns.
>
> Note that the constructs:
>
> ARRAY['a',"NULL",'c']
>
> and
>
> '{a,"NULL",c}'
>
> are *completely* different. The first is a special array constructor
> and all its parameters are normal SQL expressions, so you can reference
> columns and use NULL directly without quotes. The latter is the string
> value of the array, which is specially decoded. Thats why the latter
> treats the double quotes differently.
>
OK, thanks to both of you for your answer. I did not even think of the
'{ items }' construct. You're right. It works that way and your
explanation makes sense.
Thanks again, Andrew and Martijn. It will help me to write this document
on PostgreSQL 8.2.
--
Guillaume.
<!-- http://abs.traduc.org/
http://lfs.traduc.org/
http://traduc.postgresqlfr.org/ -->
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-11-05 23:42:27 | Re: Writing WAL for relcache invalidation:pg_internal.init |
Previous Message | Andrew Dunstan | 2006-11-05 22:25:49 | Re: WIP 2 interpreters for plperl |