mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Add string_to_table() function.
This splits a string at occurrences of a delimiter. It is exactly like string_to_array() except for producing a set of values instead of an array of values. Thus, the relationship of these two functions is the same as between regexp_split_to_table() and regexp_split_to_array(). Although the same results could be had from unnest(string_to_array()), this is somewhat faster than that, and anyway it seems reasonable to have it for symmetry with the regexp functions. Pavel Stehule, reviewed by Peter Smith Discussion: https://postgr.es/m/CAFj8pRD8HOpjq2TqeTBhSo_QkzjLOhXzGCpKJ4nCs7Y9SQkuPw@mail.gmail.com
This commit is contained in:
@@ -544,6 +544,21 @@ select string_to_array('1,2,3,4,,6', ',');
|
||||
select string_to_array('1,2,3,4,,6', ',', '');
|
||||
select string_to_array('1,2,3,4,*,6', ',', '*');
|
||||
|
||||
select v, v is null as "is null" from string_to_table('1|2|3', '|') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1|2|3|', '|') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1||2|3||', '||') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1|2|3', '') g(v);
|
||||
select v, v is null as "is null" from string_to_table('', '|') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1|2|3', NULL) g(v);
|
||||
select v, v is null as "is null" from string_to_table(NULL, '|') g(v);
|
||||
select v, v is null as "is null" from string_to_table('abc', '') g(v);
|
||||
select v, v is null as "is null" from string_to_table('abc', '', 'abc') g(v);
|
||||
select v, v is null as "is null" from string_to_table('abc', ',') g(v);
|
||||
select v, v is null as "is null" from string_to_table('abc', ',', 'abc') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',', '') g(v);
|
||||
select v, v is null as "is null" from string_to_table('1,2,3,4,*,6', ',', '*') g(v);
|
||||
|
||||
select array_to_string(NULL::int4[], ',') IS NULL;
|
||||
select array_to_string('{}'::int4[], ',');
|
||||
select array_to_string(array[1,2,3,4,NULL,6], ',');
|
||||
|
Reference in New Issue
Block a user