mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -3220,7 +3220,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Splits <parameter>string</parameter> using a POSIX regular
|
||||
expression as the delimiter; see
|
||||
expression as the delimiter, producing an array of results; see
|
||||
<xref linkend="functions-posix-regexp"/>.
|
||||
</para>
|
||||
<para>
|
||||
@@ -3239,7 +3239,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Splits <parameter>string</parameter> using a POSIX regular
|
||||
expression as the delimiter; see
|
||||
expression as the delimiter, producing a set of results; see
|
||||
<xref linkend="functions-posix-regexp"/>.
|
||||
</para>
|
||||
<para>
|
||||
@@ -3460,6 +3460,65 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>string_to_array</primary>
|
||||
</indexterm>
|
||||
<function>string_to_array</function> ( <parameter>string</parameter> <type>text</type>, <parameter>delimiter</parameter> <type>text</type> <optional>, <parameter>null_string</parameter> <type>text</type> </optional> )
|
||||
<returnvalue>text[]</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Splits the <parameter>string</parameter> at occurrences
|
||||
of <parameter>delimiter</parameter> and forms the resulting fields
|
||||
into a <type>text</type> array.
|
||||
If <parameter>delimiter</parameter> is <literal>NULL</literal>,
|
||||
each character in the <parameter>string</parameter> will become a
|
||||
separate element in the array.
|
||||
If <parameter>delimiter</parameter> is an empty string, then
|
||||
the <parameter>string</parameter> is treated as a single field.
|
||||
If <parameter>null_string</parameter> is supplied and is
|
||||
not <literal>NULL</literal>, fields matching that string are
|
||||
replaced by <literal>NULL</literal>.
|
||||
</para>
|
||||
<para>
|
||||
<literal>string_to_array('xx~~yy~~zz', '~~', 'yy')</literal>
|
||||
<returnvalue>{xx,NULL,zz}</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>string_to_table</primary>
|
||||
</indexterm>
|
||||
<function>string_to_table</function> ( <parameter>string</parameter> <type>text</type>, <parameter>delimiter</parameter> <type>text</type> <optional>, <parameter>null_string</parameter> <type>text</type> </optional> )
|
||||
<returnvalue>setof text</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Splits the <parameter>string</parameter> at occurrences
|
||||
of <parameter>delimiter</parameter> and returns the resulting fields
|
||||
as a set of <type>text</type> rows.
|
||||
If <parameter>delimiter</parameter> is <literal>NULL</literal>,
|
||||
each character in the <parameter>string</parameter> will become a
|
||||
separate row of the result.
|
||||
If <parameter>delimiter</parameter> is an empty string, then
|
||||
the <parameter>string</parameter> is treated as a single field.
|
||||
If <parameter>null_string</parameter> is supplied and is
|
||||
not <literal>NULL</literal>, fields matching that string are
|
||||
replaced by <literal>NULL</literal>.
|
||||
</para>
|
||||
<para>
|
||||
<literal>string_to_table('xx~^~yy~^~zz', '~^~', 'yy')</literal>
|
||||
<returnvalue></returnvalue>
|
||||
<programlisting>
|
||||
xx
|
||||
NULL
|
||||
zz
|
||||
</programlisting>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
@@ -17819,33 +17878,6 @@ SELECT NULLIF(value, '(none)') ...
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>string_to_array</primary>
|
||||
</indexterm>
|
||||
<function>string_to_array</function> ( <parameter>string</parameter> <type>text</type>, <parameter>delimiter</parameter> <type>text</type> <optional>, <parameter>null_string</parameter> <type>text</type> </optional> )
|
||||
<returnvalue>text[]</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Splits the <parameter>string</parameter> at occurrences
|
||||
of <parameter>delimiter</parameter> and forms the remaining data
|
||||
into a <type>text</type> array.
|
||||
If <parameter>delimiter</parameter> is <literal>NULL</literal>,
|
||||
each character in the <parameter>string</parameter> will become a
|
||||
separate element in the array.
|
||||
If <parameter>delimiter</parameter> is an empty string, then
|
||||
the <parameter>string</parameter> is treated as a single field.
|
||||
If <parameter>null_string</parameter> is supplied and is
|
||||
not <literal>NULL</literal>, fields matching that string are converted
|
||||
to <literal>NULL</literal> entries.
|
||||
</para>
|
||||
<para>
|
||||
<literal>string_to_array('xx~~yy~~zz', '~~', 'yy')</literal>
|
||||
<returnvalue>{xx,NULL,zz}</returnvalue>
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
|
Reference in New Issue
Block a user