rtrim giving weird result

From: "G(dot) Anthony Reina" <reina(at)nsi(dot)edu>
To: "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: rtrim giving weird result
Date: 2001-03-15 02:14:12
Message-ID: 3AB02573.41BD00F8@nsi.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm running Postgres 7.0.3 on a RedHat Linux 6.1. For some reason, rtrim
is giving me an incorrect result:

db01=# SELECT tablename FROM pg_tables WHERE tablename LIKE '%_opto' AND

tablename NOT LIKE 'pg%' ORDER BY tablename ASC ;
tablename
-----------------
center_out_opto
circles_opto
ellipse_opto
ex_ellipse_opto
figure8_opto
ro_ellipse_opto
(6 rows)

Now I want to return the same thing only with the trailing '_opto'
removed:

db01=# SELECT rtrim(tablename, '_opto') FROM pg_tables WHERE tablename
LIKE '%_opto' AND tablename NOT LIKE 'pg%' ORDER BY tablename ASC ;
rtrim
------------
center_ou <=======================
NOTE: the trailing 't' is missing
circles
ellipse
ex_ellipse
figure8
ro_ellipse
(6 rows)

However, as you can see, the 'center_out' table is missing the last 't'.
If I exclude the '_':

db01=# SELECT rtrim(tablename, 'opto') FROM pg_tables WHERE tablename
LIKE '%_opto' AND tablename NOT LIKE 'pg%' ORDER BY tablename ASC ;
rtrim
-------------
center_out_
<======================= 't' shows up again
circles_
ellipse_
ex_ellipse_
figure8_
ro_ellipse_
(6 rows)

The 't' is back.

Is there something that I'm doing wrong with my query here?

Thanks.
-Tony

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ken Hirsch 2001-03-15 03:36:29 Re: rtrim giving weird result
Previous Message Tom Lane 2001-03-15 00:10:43 Re: Re: Small bug in pg_dump