pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #5840: Updating arrays using subscripted assignment results in uninitialized values
2+ messages / 2 participants
[nested] [flat]
* BUG #5840: Updating arrays using subscripted assignment results in uninitialized values
@ 2011-01-15 17:12 Karsten Loesing <karsten.loesing@gmx.net>
0 siblings, 1 reply; 2+ messages in thread
From: Karsten Loesing @ 2011-01-15 17:12 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 5840
Logged by: Karsten Loesing
Email address: karsten.loesing@gmx.net
PostgreSQL version: 8.4.5
Operating system: Mac OS X 10.6 and Debian Lenny
Description: Updating arrays using subscripted assignment results in
uninitialized values
Details:
Modifying an array as described in
http://www.postgresql.org/docs/8.4/static/arrays.html#ARRAYS-MODIFYING
sometimes leads to uninitialized values. See the following example:
CREATE TABLE test_array (my_array BIGINT[]);
INSERT INTO test_array (my_array) VALUES ('[40:41]={40,41}');
UPDATE test_array SET my_array[1:2]='{1,2}';
SELECT * FROM test_array;
The result might be:
{16383,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N
ULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NU
LL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,40,41}
Running the update a second time leads to the expected result:
UPDATE test_array SET my_array[1:2]='{1,2}';
SELECT * FROM test_array;
{1,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N
ULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,40,41}
The problem only occurs with a sufficiently large "hole" between the first
and second array part.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #5840: Updating arrays using subscripted assignment results in uninitialized values
@ 2011-01-17 18:17 Tom Lane <tgl@sss.pgh.pa.us>
parent: Karsten Loesing <karsten.loesing@gmx.net>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2011-01-17 18:17 UTC (permalink / raw)
To: Karsten Loesing <karsten.loesing@gmx.net>; +Cc: pgsql-bugs
"Karsten Loesing" <karsten.loesing@gmx.net> writes:
> Modifying an array as described in
> http://www.postgresql.org/docs/8.4/static/arrays.html#ARRAYS-MODIFYING
> sometimes leads to uninitialized values. See the following example:
> CREATE TABLE test_array (my_array BIGINT[]);
> INSERT INTO test_array (my_array) VALUES ('[40:41]={40,41}');
> UPDATE test_array SET my_array[1:2]='{1,2}';
> SELECT * FROM test_array;
They're not actually "uninitialized"; the correct values are inserted,
but then overwritten with garbage. This seems to have been broken since
8.2 :-(. Fix committed:
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=f43c4d9ec4d46e4d664af4c1a2a6345921a...
Thanks for the report!
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-01-17 18:17 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-01-15 17:12 BUG #5840: Updating arrays using subscripted assignment results in uninitialized values Karsten Loesing <karsten.loesing@gmx.net>
2011-01-17 18:17 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox