PG 7.4 BETA 3: Bug in NULL arrays updating - Mailing list pgsql-bugs

From Bertrand Petit
Subject PG 7.4 BETA 3: Bug in NULL arrays updating
Date
Msg-id 20030923020338.A37721@memo.frmug.org
Whole thread Raw
Responses Re: PG 7.4 BETA 3: Bug in NULL arrays updating  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Theodore Petrosky
Date:
Subject: Fwd: Re: 3412624: can not 'make' postgresql
Next
From: Tom Lane
Date:
Subject: Re: PG 7.4 BETA 3: Bug in NULL arrays updating