Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSDn4-0004Hx-NM for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Jul 2016 01:37:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bSDn4-0005AV-1k for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Jul 2016 01:37:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bSDn3-0005A8-GA for pgsql-bugs@postgresql.org; Wed, 27 Jul 2016 01:37:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bSDn1-0004LL-20 for pgsql-bugs@postgresql.org; Wed, 27 Jul 2016 01:37:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u6R1bbBb004241; Tue, 26 Jul 2016 21:37:37 -0400 From: Tom Lane To: Andrew Gierth cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7808: unnest doesn't handle nulls in array of composite typescorrectly In-reply-to: <87eg6koste.fsf@news-spur.riddles.org.uk> References: <87wpkcpyud.fsf@news-spur.riddles.org.uk> <18501.1469285358@sss.pgh.pa.us> <87eg6koste.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Sun, 24 Jul 2016 00:47:51 +0100" Date: Tue, 26 Jul 2016 21:37:37 -0400 Message-ID: <4240.1469583457@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) 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 Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> I think the theory behind the existing code here is that if the > Tom> SRF wants its output to be interpreted as an all-nulls row, it can > Tom> perfectly well return an all-nulls row. I wonder whether we > Tom> should address this by adjusting unnest's behavior instead. > One problem with changing unnest() is that it makes the operation > array(select unnest(a)) return an array that's not equal to the original > one (and which takes up a lot more space if there are many nulls). Fair point. I didn't much like the "initial_nulls" counter in your patch, but actually there's no reason we can't just push an all-nulls row into the tuplestore immediately on seeing a null, the same way as happens in the last-ditch case at the bottom of ExecMakeTableFunctionResult. I whacked that around a bit and pushed it. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs