pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedsmall doc patch for regexp_replace
8+ messages / 3 participants
[nested] [flat]
* small doc patch for regexp_replace
@ 2006-05-18 00:01 Joachim Wieland <joe@mcknight.de>
0 siblings, 2 replies; 8+ messages in thread
From: Joachim Wieland @ 2006-05-18 00:01 UTC (permalink / raw)
To: pgsql-patches@postgresql.org
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
Attachments:
regexp_replace-doc.diff (text/plain, 3.3K) download
diff -cr cvs/pgsql/doc/src/sgml/func.sgml cvs.build/pgsql/doc/src/sgml/func.sgml
*** cvs/pgsql/doc/src/sgml/func.sgml 2006-05-15 22:59:38.000000000 +0200
--- cvs.build/pgsql/doc/src/sgml/func.sgml 2006-05-18 01:34:26.000000000 +0200
***************
*** 1112,1118 ****
<entry><literal><function>substring</function>(<parameter>string</parameter> from <replaceable>pattern</replaceable>)</literal></entry>
<entry><type>text</type></entry>
<entry>
! Extract substring matching POSIX regular expression
</entry>
<entry><literal>substring('Thomas' from '...$')</literal></entry>
<entry><literal>mas</literal></entry>
--- 1112,1120 ----
<entry><literal><function>substring</function>(<parameter>string</parameter> from <replaceable>pattern</replaceable>)</literal></entry>
<entry><type>text</type></entry>
<entry>
! Extract substring matching POSIX regular expression. See
! <xref linkend="functions-matching"> for more information on pattern
! matching.
</entry>
<entry><literal>substring('Thomas' from '...$')</literal></entry>
<entry><literal>mas</literal></entry>
***************
*** 1122,1129 ****
<entry><literal><function>substring</function>(<parameter>string</parameter> from <replaceable>pattern</replaceable> for <replaceable>escape</replaceable>)</literal></entry>
<entry><type>text</type></entry>
<entry>
! Extract substring matching <acronym>SQL</acronym> regular
! expression
</entry>
<entry><literal>substring('Thomas' from '%#"o_a#"_' for '#')</literal></entry>
<entry><literal>oma</literal></entry>
--- 1124,1132 ----
<entry><literal><function>substring</function>(<parameter>string</parameter> from <replaceable>pattern</replaceable> for <replaceable>escape</replaceable>)</literal></entry>
<entry><type>text</type></entry>
<entry>
! Extract substring matching <acronym>SQL</acronym> regular expression.
! See <xref linkend="functions-matching"> for more information on
! pattern matching.
</entry>
<entry><literal>substring('Thomas' from '%#"o_a#"_' for '#')</literal></entry>
<entry><literal>oma</literal></entry>
***************
*** 1422,1427 ****
--- 1425,1442 ----
</row>
<row>
+ <entry><literal><function>regexp_replace</function>(<parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type>, <parameter>replacement</parameter> <type>text</type> [,<parameter>flags</parameter> <type>text</type>])</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>
+ Replace substring matching POSIX regular expression. See
+ <xref linkend="functions-matching"> for more information on pattern
+ matching.
+ </entry>
+ <entry><literal>regexp_replace('Thomas', '.[mN]a.', 'M')</literal></entry>
+ <entry><literal>ThM</literal></entry>
+ </row>
+
+ <row>
<entry><literal><function>repeat</function>(<parameter>string</parameter> <type>text</type>, <parameter>number</parameter> <type>int</type>)</literal></entry>
<entry><type>text</type></entry>
<entry>Repeat <parameter>string</parameter> the specified
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: small doc patch for regexp_replace
@ 2006-05-18 00:54 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Joachim Wieland <joe@mcknight.de>
1 sibling, 1 reply; 8+ messages in thread
From: Bruce Momjian @ 2006-05-18 00:54 UTC (permalink / raw)
To: Joachim Wieland <joe@mcknight.de>; +Cc: pgsql-patches@postgresql.org
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. +
Attachments:
/rtmp/diff (text/x-diff, 6.5K) download
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>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: small doc patch for regexp_replace
@ 2006-05-18 02:59 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 8+ messages in thread
From: Tom Lane @ 2006-05-18 02:59 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Joachim Wieland <joe@mcknight.de>; pgsql-patches@postgresql.org
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
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: small doc patch for regexp_replace
@ 2006-05-18 03:20 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 8+ messages in thread
From: Bruce Momjian @ 2006-05-18 03:20 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Joachim Wieland <joe@mcknight.de>; pgsql-patches@postgresql.org
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. +
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [PATCHES] small doc patch for regexp_replace
@ 2006-05-18 16:43 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 8+ messages in thread
From: Bruce Momjian @ 2006-05-18 16:43 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Joachim Wieland <joe@mcknight.de>; pgsql-docs
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.
There are many mentions of <parameter>string</> used a function
arguments in func.sgml. Should those be changed to <type>text</>?
--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [PATCHES] small doc patch for regexp_replace
@ 2006-05-18 17:47 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 8+ messages in thread
From: Tom Lane @ 2006-05-18 17:47 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Joachim Wieland <joe@mcknight.de>; pgsql-docs
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> There are many mentions of <parameter>string</> used a function
> arguments in func.sgml. Should those be changed to <type>text</>?
<parameter>string</> is fine, especially if the function actually has a
separate variant for bpchar. I was just unhappy with <type>string</>,
which is a lie.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [PATCHES] small doc patch for regexp_replace
@ 2006-05-18 17:51 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Bruce Momjian @ 2006-05-18 17:51 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Joachim Wieland <joe@mcknight.de>; pgsql-docs
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > There are many mentions of <parameter>string</> used a function
> > arguments in func.sgml. Should those be changed to <type>text</>?
>
> <parameter>string</> is fine, especially if the function actually has a
> separate variant for bpchar. I was just unhappy with <type>string</>,
FYI, in most cases, they don't have bpchar variants.
--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: small doc patch for regexp_replace
@ 2006-05-30 11:55 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Joachim Wieland <joe@mcknight.de>
1 sibling, 0 replies; 8+ messages in thread
From: Bruce Momjian @ 2006-05-30 11:55 UTC (permalink / raw)
To: Joachim Wieland <joe@mcknight.de>; +Cc: pgsql-patches@postgresql.org
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. +
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2006-05-30 11:55 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-18 00:01 small doc patch for regexp_replace Joachim Wieland <joe@mcknight.de>
2006-05-18 00:54 ` Bruce Momjian <pgman@candle.pha.pa.us>
2006-05-18 02:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-05-18 03:20 ` Bruce Momjian <pgman@candle.pha.pa.us>
2006-05-18 16:43 ` Bruce Momjian <pgman@candle.pha.pa.us>
2006-05-18 17:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-05-18 17:51 ` Bruce Momjian <pgman@candle.pha.pa.us>
2006-05-30 11:55 ` Bruce Momjian <pgman@candle.pha.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox