Doc: add cross-references between array_to_string and string_to_array.
authorTom Lane
Sat, 22 Jan 2022 20:44:51 +0000 (15:44 -0500)
committerTom Lane
Sat, 22 Jan 2022 20:44:51 +0000 (15:44 -0500)
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

index 90169a0ce72cc581b9a3a0b7c9b848f78e7b7418..034fecc3a1913d843344cda27ec015603dcf91d2 100644 (file)
@@ -3508,54 +3508,6 @@ repeat('Pg', 4) PgPgPgPg
        
       
 
-      
-       
-        
-         strpos
-        
-        strpos ( string textsubstring text )
-        integer
-       
-       
-        Returns first starting index of the specified substring
-        within string, or zero if it's not present.
-        (Same as position(substring in
-        string), but note the reversed
-        argument order.)
-       
-       
-        strpos('high', 'ig')
-        2
-       
-      
-
-      
-       
-        
-         substr
-        
-        substr ( string textstart integer count integer  )
-        text
-       
-       
-        Extracts the substring of string starting at
-        the start'th character,
-        and extending for count characters if that is
-        specified.  (Same
-        as substring(string
-        from start
-        for count).)
-       
-       
-        substr('alphabet', 3)
-        phabet
-       
-       
-        substr('alphabet', 3, 2)
-        ph
-       
-      
-
       
        
         
@@ -3576,7 +3528,7 @@ repeat('Pg', 4) PgPgPgPg
 
       
        
-        
+         id="function-string-to-array">
          string_to_array
         
         string_to_array ( string textdelimiter text null_string text  )
@@ -3594,6 +3546,7 @@ repeat('Pg', 4) PgPgPgPg
         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')
@@ -3633,6 +3586,54 @@ repeat('Pg', 4) PgPgPgPg
        
       
 
+      
+       
+        
+         strpos
+        
+        strpos ( string textsubstring text )
+        integer
+       
+       
+        Returns first starting index of the specified substring
+        within string, or zero if it's not present.
+        (Same as position(substring in
+        string), but note the reversed
+        argument order.)
+       
+       
+        strpos('high', 'ig')
+        2
+       
+      
+
+      
+       
+        
+         substr
+        
+        substr ( string textstart integer count integer  )
+        text
+       
+       
+        Extracts the substring of string starting at
+        the start'th character,
+        and extending for count characters if that is
+        specified.  (Same
+        as substring(string
+        from start
+        for count).)
+       
+       
+        substr('alphabet', 3)
+        phabet
+       
+       
+        substr('alphabet', 3, 2)
+        ph
+       
+      
+
       
        
         
@@ -18452,7 +18453,7 @@ SELECT NULLIF(value, '(none)') ...
 
       
        
-        
+         id="function-array-to-string">
          array_to_string
         
         array_to_string ( array anyarraydelimiter 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.