PG 7.4 BETA 3: Bug in NULL arrays updating

From: Bertrand Petit <pgsql(at)phoe(dot)frmug(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: PG 7.4 BETA 3: Bug in NULL arrays updating
Date: 2003-09-23 00:03:38
Message-ID: 20030923020338.A37721@memo.frmug.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Theodore Petrosky 2003-09-23 01:24:22 Fwd: Re: 3412624: can not 'make' postgresql
Previous Message Stephan Szabo 2003-09-22 21:02:03 Re: Table alias fun == incorrectly adding tables to join...