BUG #16959: Unnesting null from string_to_array silently removes whole rows from result - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16959: Unnesting null from string_to_array silently removes whole rows from result
Date
Msg-id 16959-4c11c2e812e2b52c@postgresql.org
Whole thread Raw
Responses Re: BUG #16959: Unnesting null from string_to_array silently removes whole rows from result  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16959
Logged by:          Pete O'Such
Email address:      posuch@gmail.com
PostgreSQL version: 11.7
Operating system:   Ubuntu (and also Red Hat)
Description:

Applying unnest() to the output of string_to_array() operating on a null
silently drops the entire row from the query results.  I'm agnostic
regarding what would be a proper resulting value within the column, but the
silent omission of the whole row from the result is a problem to me.

Sample data:

create table test_rows as 
SELECT * FROM (VALUES (1, null), (2, 'second')) AS t (num,letter);
SELECT 2


Query with the unexpected result (I expected 2 rows):

select num, unnest(string_to_array(letter, ',')) from test_rows;
num | unnest 
----+--------
  2 | second
(1 row)


Correct or expected behavior from a similar operation:

select num, unnest(array[letter]) from test_rows;
num | unnest 
----+--------
  1 | 
  2 | second
(2 rows)

Thanks,
Pete O'Such


pgsql-bugs by date:

Previous
From: Fujii Masao
Date:
Subject: Re: BUG #16931: source code problem about commit_ts
Next
From: Tom Lane
Date:
Subject: Re: BUG #16959: Unnesting null from string_to_array silently removes whole rows from result