Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub8pL-0006Bs-29 for pgsql-bugs@arkaria.postgresql.org; Sat, 11 May 2013 12:23:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ub8pK-00062e-Bp for pgsql-bugs@arkaria.postgresql.org; Sat, 11 May 2013 12:23:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub8pI-00062W-Il for pgsql-bugs@postgresql.org; Sat, 11 May 2013 12:23:00 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub8pD-0003cM-J3 for pgsql-bugs@postgresql.org; Sat, 11 May 2013 12:23:00 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub8pC-0002tm-7X for pgsql-bugs@postgresql.org; Sat, 11 May 2013 12:22:54 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1Ub8p6-0006NC-Ja for pgsql-bugs@postgresql.org; Sat, 11 May 2013 12:22:48 +0000 Date: Sat, 11 May 2013 12:22:48 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8150: NULL emements lost when casting result of unnest() To: pgsql-bugs@postgresql.org From: brandstetter@falter.at X-Pg-Spam-Score: -3.4 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8150 Logged by: Erwin Brandstetter Email address: brandstetter@falter.at PostgreSQL version: 9.2.4 Operating system: Multiple Description:=20=20=20=20=20=20=20=20 PostgreSQL allows to cast the result of unnest() directly. However, I found inconsistent results with NULL elements in the array. With some array types NULL element are lost, while they are retained with others: SELECT unnest('{4,NULL,1}'::int[])::text; i --- 4 (null) 1 SELECT unnest('{1,NULL,4}'::int[])::int8; i --- 1 4 The NULL element is lost in the second case, which is unwarranted as far as I can tell. Tested with the latest PostgreSQL 9.1.9 and 9.2.4. Identical results. I presented the case with more details in this question on Stackoverflow: http://stackoverflow.com/questions/16452501/null-emements-lost-when-casting= -result-of-unnest Accompanied by this demo on SQLfiddle: http://www.sqlfiddle.com/#!12/d41d8/930 As advised by Pavel, I am reporting this as possible bug now. Regards Erwin --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs