Re: BUG #7808: unnest doesn't handle nulls in array of composite typescorrectly - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #7808: unnest doesn't handle nulls in array of composite typescorrectly
Date
Msg-id 4240.1469583457@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #7808: unnest doesn't handle nulls in array of composite typescorrectly  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: BUG #7808: unnest doesn't handle nulls in array of composite typescorrectly
List pgsql-bugs
Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> 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

pgsql-bugs by date:

Previous
From: ganuri@gmail.com
Date:
Subject: BUG #14265: inserting multiple rows via array notation gives error
Next
From: Tom Lane
Date:
Subject: Re: BUG #14226: pg_upgrade for 8.4 to 9.4 failed