From: | "Karsten Loesing" <karsten(dot)loesing(at)gmx(dot)net> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #5840: Updating arrays using subscripted assignment results in uninitialized values |
Date: | 2011-01-15 17:12:11 |
Message-ID: | 201101151712.p0FHCBvS019298@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 5840
Logged by: Karsten Loesing
Email address: karsten(dot)loesing(at)gmx(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | pasman pasmański | 2011-01-15 18:32:14 | Re: Problems with adding a is not null to a query. |
Previous Message | Anthony Manfredi | 2011-01-15 15:50:23 | date_trunc check constraint causes errors when restoring in a db with a different time zone |