Re: rtrim giving weird result

From: "Ken Hirsch" <kenhirsch(at)myself(dot)com>
To: "G(dot) Anthony Reina" <reina(at)nsi(dot)edu>, "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: rtrim giving weird result
Date: 2001-03-15 03:36:29
Message-ID: 009901c0ad01$25418f80$88873dd0@computer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The second parameter to "rtrim" is interpreted as a set of characters and
rtrim:
"Returns string with final characters removed after the last character not
in set"

So rtrim("center_out_opto", "_opto") returns
"center_ou"
because "u" is not in the set {o, p, t, _} but all the characters after it
are.
rtrim("center_out_opto", "pot_") will produce the same thing.

----- Original Message -----
From: "G. Anthony Reina" <reina(at)nsi(dot)edu>
To: "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Sent: Wednesday, March 14, 2001 9:14 PM
Subject: [HACKERS] rtrim giving weird result

> 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
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-03-15 04:10:56 Re: rtrim giving weird result
Previous Message G. Anthony Reina 2001-03-15 02:14:12 rtrim giving weird result