BUG #16959: Unnesting null from string_to_array silently removes whole rows from result

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: posuch(at)gmail(dot)com
Subject: BUG #16959: Unnesting null from string_to_array silently removes whole rows from result
Date: 2021-04-11 23:50:01
Message-ID: 16959-4c11c2e812e2b52c@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16959
Logged by: Pete O&#39;Such
Email address: posuch(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-04-12 00:46:37 Re: BUG #16959: Unnesting null from string_to_array silently removes whole rows from result
Previous Message Fujii Masao 2021-04-11 15:09:45 Re: BUG #16931: source code problem about commit_ts