Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 08C3A1337B80 for ; Sat, 15 Jan 2011 13:12:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 94119-01 for ; Sat, 15 Jan 2011 17:12:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 504C81337B7A for ; Sat, 15 Jan 2011 13:12:12 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p0FHCBjM019299 for ; Sat, 15 Jan 2011 17:12:11 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p0FHCBvS019298; Sat, 15 Jan 2011 17:12:11 GMT (envelope-from www) Date: Sat, 15 Jan 2011 17:12:11 GMT Message-Id: <201101151712.p0FHCBvS019298@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #5840: Updating arrays using subscripted assignment results in uninitialized values From: "Karsten Loesing" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201101/113 X-Sequence-Number: 29135 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.