Thread: small doc patch for regexp_replace

small doc patch for regexp_replace

From
Joachim Wieland
Date:
Is there any reason, why regexp_replace is not included in the tables of the
string functions?

http://developer.postgresql.org/docs/postgres/functions-string.html

The appended patch adds regexp_replace() and links to the pattern matching
section for substring / regexp_replace.

I noticed that in the table the declaration of the arguments is
inconsistent, for example:

lower(string)
ascii(text)
length(string text)

also in the sgml, there is sometimes "text" and sometimes
"<type>text</type>".

I'd fix that if someone told me what the preferred (if any) form is...


Joachim

Attachment

Re: small doc patch for regexp_replace

From
Bruce Momjian
Date:
Joachim Wieland wrote:
> Is there any reason, why regexp_replace is not included in the tables of the
> string functions?
>
> http://developer.postgresql.org/docs/postgres/functions-string.html
>
> The appended patch adds regexp_replace() and links to the pattern matching
> section for substring / regexp_replace.
>
> I noticed that in the table the declaration of the arguments is
> inconsistent, for example:
>
> lower(string)
> ascii(text)
> length(string text)
>
> also in the sgml, there is sometimes "text" and sometimes
> "<type>text</type>".
>
> I'd fix that if someone told me what the preferred (if any) form is...

Seems there is some inconsistency there.  There are two types of
function listings, one with just the types, and another with param_name
and then type.  We use "string" instead of "text" because varchar() and
char() can also be used.

Anyway, applied patch attached that tries to clean it up.  Let me know
if you find others.

--
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: func.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.316
retrieving revision 1.317
diff -c -r1.316 -r1.317
*** func.sgml    30 Apr 2006 21:15:32 -0000    1.316
--- func.sgml    18 May 2006 00:50:08 -0000    1.317
***************
*** 1,4 ****
! <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.316 2006/04/30 21:15:32 tgl Exp $ -->

   <chapter id="functions">
    <title>Functions and Operators</title>
--- 1,4 ----
! <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.317 2006/05/18 00:50:08 momjian Exp $ -->

   <chapter id="functions">
    <title>Functions and Operators</title>
***************
*** 1244,1250 ****

       <tbody>
        <row>
!        <entry><literal><function>ascii</function>(<type>text</type>)</literal></entry>
         <entry><type>int</type></entry>
         <entry><acronym>ASCII</acronym> code of the first byte of the argument</entry>
         <entry><literal>ascii('x')</literal></entry>
--- 1244,1250 ----

       <tbody>
        <row>
!        <entry><literal><function>ascii</function>(<type>string</type>)</literal></entry>
         <entry><type>int</type></entry>
         <entry><acronym>ASCII</acronym> code of the first byte of the argument</entry>
         <entry><literal>ascii('x')</literal></entry>
***************
*** 1274,1281 ****

        <row>
         <entry>
!         <literal><function>convert</function>(<parameter>string</parameter>
!         <type>text</type>,
          <optional><parameter>src_encoding</parameter> <type>name</type>,</optional>
          <parameter>dest_encoding</parameter> <type>name</type>)</literal>
         </entry>
--- 1274,1280 ----

        <row>
         <entry>
!         <literal><function>convert</function>(<parameter>string</parameter> <type>text</type>,
          <optional><parameter>src_encoding</parameter> <type>name</type>,</optional>
          <parameter>dest_encoding</parameter> <type>name</type>)</literal>
         </entry>
***************
*** 1320,1326 ****
        </row>

        <row>
!        <entry><literal><function>initcap</function>(<type>text</type>)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Convert the first letter of each word to uppercase and the
--- 1319,1325 ----
        </row>

        <row>
!        <entry><literal><function>initcap</function>(<type>string</type>)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Convert the first letter of each word to uppercase and the
***************
*** 1332,1338 ****
        </row>

        <row>
!        <entry><literal><function>length</function>(<parameter>string</parameter> <type>text</type>)</literal></entry>
         <entry><type>int</type></entry>
         <entry>
          Number of characters in <parameter>string</parameter>
--- 1331,1337 ----
        </row>

        <row>
!        <entry><literal><function>length</function>(<parameter>string</parameter>)</literal></entry>
         <entry><type>int</type></entry>
         <entry>
          Number of characters in <parameter>string</parameter>
***************
*** 1375,1381 ****
        </row>

        <row>
!        <entry><literal><function>md5</function>(<parameter>string</parameter> <type>text</type>)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Calculates the MD5 hash of <parameter>string</parameter>,
--- 1374,1380 ----
        </row>

        <row>
!        <entry><literal><function>md5</function>(<parameter>string</parameter>)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Calculates the MD5 hash of <parameter>string</parameter>,
***************
*** 1396,1402 ****
        </row>

        <row>
!        <entry><literal><function>quote_ident</function>(<parameter>string</parameter> text)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as an identifier
--- 1395,1401 ----
        </row>

        <row>
!        <entry><literal><function>quote_ident</function>(<parameter>string</parameter>)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as an identifier
***************
*** 1410,1416 ****
        </row>

        <row>
!        <entry><literal><function>quote_literal</function>(<parameter>string</parameter> text)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as a string literal
--- 1409,1415 ----
        </row>

        <row>
!        <entry><literal><function>quote_literal</function>(<parameter>string</parameter>)</literal></entry>
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as a string literal
***************
*** 1511,1522 ****
        </row>

        <row>
!        <entry><literal><function>to_ascii</function>(<type>text</type>
!         <optional>, <parameter>encoding</parameter></optional>)</literal></entry>
         <entry><type>text</type></entry>

         <entry>
!        Convert <parameter>text</parameter> to <acronym>ASCII</acronym> from another encoding
         <footnote>
          <para>
           The <function>to_ascii</function> function supports conversion from
--- 1510,1521 ----
        </row>

        <row>
!        <entry><literal><function>to_ascii</function>(<parameter>string</parameter> <type>text</type>
!         <optional>, <parameter>encoding</parameter> <type>text</type></optional>)</literal></entry>
         <entry><type>text</type></entry>

         <entry>
!        Convert <parameter>string</parameter> to <acronym>ASCII</acronym> from another encoding
         <footnote>
          <para>
           The <function>to_ascii</function> function supports conversion from
***************
*** 1543,1550 ****

        <row>
         <entry>
!         <literal><function>translate</function>(<parameter>string</parameter>
!         <type>text</type>,
          <parameter>from</parameter> <type>text</type>,
          <parameter>to</parameter> <type>text</type>)</literal>
         </entry>
--- 1542,1548 ----

        <row>
         <entry>
!         <literal><function>translate</function>(<parameter>string</parameter> <type>text</type>,
          <parameter>from</parameter> <type>text</type>,
          <parameter>to</parameter> <type>text</type>)</literal>
         </entry>

Re: small doc patch for regexp_replace

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Seems there is some inconsistency there.  There are two types of
> function listings, one with just the types, and another with param_name
> and then type.  We use "string" instead of "text" because varchar() and
> char() can also be used.

Where did that come from?  The actual functions generally take "text",
relying on implicit conversions to handle the other types.  Since we do
not have any type named "string", I think the locution <type>string</>
is a contradiction in terms.

IMHO these should all go back to <type>text</>.

            regards, tom lane

Re: small doc patch for regexp_replace

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Seems there is some inconsistency there.  There are two types of
> > function listings, one with just the types, and another with param_name
> > and then type.  We use "string" instead of "text" because varchar() and
> > char() can also be used.
>
> Where did that come from?  The actual functions generally take "text",
> relying on implicit conversions to handle the other types.  Since we do
> not have any type named "string", I think the locution <type>string</>
> is a contradiction in terms.
>
> IMHO these should all go back to <type>text</>.

Well, we actually have <parameter>string</> and I got a few wrong.  I
have committed the changes.    If we want to use <type>text</> instead
of <parameter>string</>, I can make that change too.  There are quite a
few of them, like md5().  Yes?

--
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: small doc patch for regexp_replace

From
Bruce Momjian
Date:
Patch applied.  Thanks.  Your documentation changes can be viewed in
five minutes using links on the developer's page,
http://www.postgresql.org/developer/testing.


---------------------------------------------------------------------------


Joachim Wieland wrote:
> Is there any reason, why regexp_replace is not included in the tables of the
> string functions?
>
> http://developer.postgresql.org/docs/postgres/functions-string.html
>
> The appended patch adds regexp_replace() and links to the pattern matching
> section for substring / regexp_replace.
>
> I noticed that in the table the declaration of the arguments is
> inconsistent, for example:
>
> lower(string)
> ascii(text)
> length(string text)
>
> also in the sgml, there is sometimes "text" and sometimes
> "<type>text</type>".
>
> I'd fix that if someone told me what the preferred (if any) form is...
>
>
> Joachim

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

--
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +