When updating a NULL cell which is an array of something,
setting an adressed member of a non existent array, the value of the
cell is not changed.
> CREATE TABLE dummy (foo INT, bar VARCHAR[]);
CREATE TABLE
> INSERT INTO dummy (foo) VALUES (1);
INSERT 43266442 1
> SELECT bar IS NULL AS is_null FROM dummy;
is_null
---------
t
(1 row)
> UPDATE dummy SET bar[0]='Blah';
UPDATE 1
> SELECT * FROM dummy;
foo | bar
-----+-----
1 |
(1 row)
> SELECT bar IS NULL AS is_null FROM dummy;
is_null
---------
t
(1 row)
> SELECT version();
version
------------------------------------------------------------------------
PostgreSQL 7.4beta3 on i386-unknown-freebsd4.5, compiled by GCC 2.95.3
(1 row)
I expected that the bar column be set to {"Blah"}. After a few
seconds of thought, I pictured the updating as setting the first
member of the NULL array (NULL[0] := 'Blah'). Ouch that looks like a
"null pointer". So maybe the non updating of bar is correct. But in
this case an error or a warning should be raised.
--
%!PS
297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100
180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180
0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont
240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage