select unnest(), unnest()

From: Jasmin Dizdarevic <jasmin(dot)dizdarevic(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: select unnest(), unnest()
Date: 2018-04-01 19:38:48
Message-ID: CAOveQuP6xqLzopbp+pMp8sbbSvKwHj2z6BXM_jEq9onqXwo+uQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, we have some queries that use unnest() function.

create table configuration (

id int,

advisor text,

branch text,

primary key(id)

);

insert into configuration values

(1,'a','00,01'),

(2,'a','00'),

(3,'b','02,03'),

(4,'c','05'),

(5,'d,e','00,01');

select id, unnest(string_to_array(advisor,',')), unnest
(string_to_array(branch,','))

from configuration;

PG9.6:

id | unnest | unnest

----+--------+--------

1 | a | 00

1 | a | 01

2 | a | 00

3 | b | 02

3 | b | 03

4 | c | 05

5 | d | 00

5 | e | 01

PG10:

id | unnest | unnest

----+--------+--------

1 | a | 00

1 | | 01

2 | a | 00

3 | b | 02

3 | | 03

4 | c | 05

5 | d | 00

5 | e | 01

- Is this wanted in PG10 or a bug?
- Is there a way to change the behaviour of pgsql to produce output like
9.6?
- A smooth sql-workaround?

Thank you very much!

Regards, Jasmin

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2018-04-01 19:49:21 Re: select unnest(), unnest()
Previous Message Samed YILDIRIM 2018-03-29 11:29:50 Re: when transaction is committed in postgres