From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: unmesh.joshi126@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17407: trim trims more than expected
Date: Wed, 16 Feb 2022 12:12:38 -0300
Message-ID: <202202161512.tsbczybuwa3i@alvherre.pgsql> (raw)
In-Reply-To: <17407-d39ff77fdea57c42@postgresql.org>
On 2022-Feb-16, PG Bug reporting form wrote:
> Unexpected output
>
> demo=# select trim ('nextval(''' from
> substring('nextval(''auth_table_id_seq''::regclass)' from '%#"%_id_seq#"%'
> for '#' ));
> btrim
> ------------------
> uth_table_id_seq
Not a bug. trim() receives a *set* of characters to remove, not a
*substring* to remove, so the 'a' in 'auth' is matched to the 'a' in
'nextval(' and gets removed.
You can probably achieve what you want by combining substring() with
position() and char_length(), or by using a regular expression in
regexp_replace().
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"La conclusión que podemos sacar de esos estudios es que
no podemos sacar ninguna conclusión de ellos" (Tanenbaum)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: alvherre@alvh.no-ip.org, unmesh.joshi126@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17407: trim trims more than expected
In-Reply-To: <202202161512.tsbczybuwa3i@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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