From 4f02cbcb6839553c595efa3a2eb1c2a09557ef79 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 22 Jan 2022 15:44:51 -0500 Subject: [PATCH] Doc: add cross-references between array_to_string and string_to_array. These functions aren't exact inverses, but they're closely related; yet we document them in two different sections. Add cross-ref s to improve that situation. While here, move the strpos and substr entries to re-alphabetize Table 9.10. Also, drop an ancient compatibility note about string_to_array, which wasn't even on the right page, so probably few people ever saw it. Discussion: https://postgr.es/m/164287017550.704.5840412183184961677@wrigleys.postgresql.org --- doc/src/sgml/func.sgml | 170 +++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 90 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 90169a0ce7..034fecc3a1 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -3508,6 +3508,84 @@ repeat('Pg', 4) PgPgPgPg + + + + starts_with + + starts_with ( string text, prefix text ) + boolean + + + Returns true if string starts + with prefix. + + + starts_with('alphabet', 'alph') + t + + + + + + + string_to_array + + string_to_array ( string text, delimiter text , null_string text ) + text[] + + + Splits the string at occurrences + of delimiter and forms the resulting fields + into a text array. + If delimiter is NULL, + each character in the string will become a + separate element in the array. + If delimiter is an empty string, then + the string is treated as a single field. + If null_string is supplied and is + not NULL, fields matching that string are + replaced by NULL. + See also array_to_string. + + + string_to_array('xx~~yy~~zz', '~~', 'yy') + {xx,NULL,zz} + + + + + + + string_to_table + + string_to_table ( string text, delimiter text , null_string text ) + setof text + + + Splits the string at occurrences + of delimiter and returns the resulting fields + as a set of text rows. + If delimiter is NULL, + each character in the string will become a + separate row of the result. + If delimiter is an empty string, then + the string is treated as a single field. + If null_string is supplied and is + not NULL, fields matching that string are + replaced by NULL. + + + string_to_table('xx~^~yy~^~zz', '~^~', 'yy') + + + xx + NULL + zz + + + + @@ -3556,83 +3634,6 @@ repeat('Pg', 4) PgPgPgPg - - - - starts_with - - starts_with ( string text, prefix text ) - boolean - - - Returns true if string starts - with prefix. - - - starts_with('alphabet', 'alph') - t - - - - - - - string_to_array - - string_to_array ( string text, delimiter text , null_string text ) - text[] - - - Splits the string at occurrences - of delimiter and forms the resulting fields - into a text array. - If delimiter is NULL, - each character in the string will become a - separate element in the array. - If delimiter is an empty string, then - the string is treated as a single field. - If null_string is supplied and is - not NULL, fields matching that string are - replaced by NULL. - - - string_to_array('xx~~yy~~zz', '~~', 'yy') - {xx,NULL,zz} - - - - - - - string_to_table - - string_to_table ( string text, delimiter text , null_string text ) - setof text - - - Splits the string at occurrences - of delimiter and returns the resulting fields - as a set of text rows. - If delimiter is NULL, - each character in the string will become a - separate row of the result. - If delimiter is an empty string, then - the string is treated as a single field. - If null_string is supplied and is - not NULL, fields matching that string are - replaced by NULL. - - - string_to_table('xx~^~yy~^~zz', '~^~', 'yy') - - - xx - NULL - zz - - - - @@ -18452,7 +18453,7 @@ SELECT NULLIF(value, '(none)') ... - + array_to_string array_to_string ( array anyarray, delimiter text , null_string text ) @@ -18465,6 +18466,7 @@ SELECT NULLIF(value, '(none)') ... If null_string is given and is not NULL, then NULL array entries are represented by that string; otherwise, they are omitted. + See also string_to_array. array_to_string(ARRAY[1, 2, 3, NULL, 5], ',', '*') @@ -18584,18 +18586,6 @@ SELECT NULLIF(value, '(none)') ... - - - There are two differences in the behavior of string_to_array - from pre-9.1 versions of PostgreSQL. - First, it will return an empty (zero-element) array rather - than NULL when the input string is of zero length. - Second, if the delimiter string is NULL, the function - splits the input into individual characters, rather than - returning NULL as before. - - - See also about the aggregate function array_agg for use with arrays.