Thread: string function -- replace needs a clear doc

string function -- replace needs a clear doc

From
"Jie Liang"
Date:
urldb=# select replace('whateveritis','a','A');
   replace
--------------
 whAteveritis
(1 row)

urldb=# select replace('whateveritis','e','E');
   replace
--------------
 whatEvEritis
(1 row)

urldb=# select replace('whatever%20itis','e','E');
             replace
---------------------------------
 whatEvEr                   1tis
(1 row)

urldb=# select replace('whatever%%20itis','e','E');
     replace
-----------------
 whatEvEr%20itis
(1 row)

urldb=# select replace('whatever%%20sitis','e','E');
     replace
------------------
 whatEvEr%20sitis
(1 row)

urldb=# select replace('whatever%20sitis','e','E');
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!#
> psql urldb
Welcome to psql 7.3.2, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

urldb=# select replace('whatever%20sitis','si','SI');
    replace
---------------
 whateverSItis
(1 row)

1. No doc said % should escape by %%, and
select replace('whatever%20sites','%20','%%20') won't work also.
2. v7.3.2 haven't resolved this problem yet, I am not sure the later version.


Jie Liang

Re: string function -- replace needs a clear doc

From
Stephan Szabo
Date:
On Mon, 11 Aug 2003, Jie Liang wrote:

> 1. No doc said % should escape by %%, and
> select replace('whatever%20sites','%20','%%20') won't work also.
> 2. v7.3.2 haven't resolved this problem yet, I am not sure the later version.

I seem to get the expected results on my 7.3.4 system.


Re: string function -- replace needs a clear doc

From
Tom Lane
Date:
"Jie Liang" <jie@stbernard.com> writes:
> 1. No doc said % should escape by %%, and
> select replace('whatever%20sites','%20','%%20') won't work also.
> 2. v7.3.2 haven't resolved this problem yet, I am not sure the later version.

In 7.3.3 release notes:

    *  Fix misbehavior of replace() on strings containing '%'


            regards, tom lane