pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16507: RTRIM function doesnt behave as expected for certain scenario
2+ messages / 2 participants
[nested] [flat]
* BUG #16507: RTRIM function doesnt behave as expected for certain scenario
@ 2020-06-22 17:47 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2020-06-22 17:47 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: chetan.burande7@gmail.com
The following bug has been logged on the website:
Bug reference: 16507
Logged by: Chetan Burande
Email address: chetan.burande7@gmail.com
PostgreSQL version: Unsupported/Unknown
Operating system: Linux
Description:
Hi Team,
I am trying to use RTIM function on a String (Column data) to remove some
character/string from the right end.
Example -
select column_name, RTRIM(column_name, '-1') from table_name;
column_name | rtrim
-----------------------------------------+---------------------------------------
test-2020_03_01-2020_03_31-1 | test-2020_03_01-2020_03_3
test-2019_02_01-2019_02_28-1 | test-2019_02_01-2019_02_28
test-2019_04_01-2019_04_30-1 | test-2019_04_01-2019_04_30
In case of the first string, RTRIM is removing "1-1" instead of "-1".
I expect it to remove "-1" as it did in other strings.
Please let me know if you need any further information.
Thanks,
Chetan
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #16507: RTRIM function doesnt behave as expected for certain scenario
@ 2020-06-22 18:18 Tom Lane <tgl@sss.pgh.pa.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2020-06-22 18:18 UTC (permalink / raw)
To: chetan.burande7@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org
PG Bug reporting form <noreply@postgresql.org> writes:
> I am trying to use RTIM function on a String (Column data) to remove some
> character/string from the right end.
> Example -
> select column_name, RTRIM(column_name, '-1') from table_name;
> In case of the first string, RTRIM is removing "1-1" instead of "-1".
> I expect it to remove "-1" as it did in other strings.
Your expectation is wrong, per the function's documentation:
Removes the longest string containing only characters in
'characters' (a space by default) from the end of 'string'.
The example is pretty explicit about this, too:
rtrim('testxxzx', 'xyz') → test
You could do what you want with regexp_replace() or the pattern-matching
variant of substring().
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-06-22 18:18 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 17:47 BUG #16507: RTRIM function doesnt behave as expected for certain scenario PG Bug reporting form <noreply@postgresql.org>
2020-06-22 18:18 ` Tom Lane <tgl@sss.pgh.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