pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Romain Billon-Grand <romainbillongrand@yahoo.fr>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #8335: trim() un-document behaviour
Date: Sun, 11 Aug 2013 23:01:44 -0700 (PDT)
Message-ID: <1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com> (raw)
In-Reply-To: <20130809162359.GA3353@momjian.us>
References: <E1V2XgU-0003tb-Ii@wrigleys.postgresql.org>
	<20130807161953.GZ11189@momjian.us>
	<19166.1376060775@sss.pgh.pa.us>
	<20130809162359.GA3353@momjian.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Finally could make it using
regexp_replace (my_field_to_trim, '.+my_triming_string' , '') for the "leading" case

regexp_replace (my_field_to_trim, 'my_triming_string(.+)' , '') for the "trailing" case

And both of them in this order a for the "both" one.
I don't know why, but  could not use '*?'
Since in no instance my_triming_string was at the extremlity of the sting, I did not need it, but I guess something like '(|.+)my_triming_string'could have worked



________________________________
 De : Bruce Momjian [via PostgreSQL] <ml-node+s1045698n5766983h79@n5.nabble.com>
À : Romain Billon-Grand <romainbillongrand@yahoo.fr> 
Envoyé le : Vendredi 9 août 2013 18h24
Objet : Re: BUG #8335: trim() un-document behaviour
 


On Fri, Aug  9, 2013 at 11:06:15AM -0400, Tom Lane wrote: 

> Bruce Momjian <[hidden email]> writes: 
> > The attached patch swaps the arguments in the parser, and allows your 
> > expected behavior: 
> 
> This patch is completely unsafe.  It will break stored rules, which may 
> contain calls using the existing argument order (which will be dumped 
> without any of the SQL-spec syntactic sugar).  To say nothing of existing 
> applications that may be relying on calling the underlying functions with 
> their existing argument order. 
> 
> The inconsistency in argument order is unfortunate but we're long since 
> stuck with it, I'm afraid. 
Yes, I have thought about this some more and another problem is that 
rtrim/btrim/ltrim() use the source string first, so having trim() have 
the source string second when using a comma is very confusing, e.g.: 

        -- with patch 
        SELECT trim('x', 'xabcx'); 
         btrim 
        ------- 
         abc 

        -- btrim 
        SELECT btrim('xabcx', 'x'); 
         btrim 
        ------- 
         abc 

I think we can either document what we have, or remove the ability to 
use comma with trim().  If we go with documentation, it is going to look 
confusing as the optional modifier is going to be on the source string, 
e.g.: 

        SELECT trim(both 'xabcx', 'x'); 
         btrim 
        ------- 
         abc 

We could modify the grammar to force the modifier on the second 
argument, but that is more parser states for limited value. 

-- 
  Bruce Momjian  <[hidden email]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. + 


-- 
Sent via pgsql-bugs mailing list ([hidden email]) 
To make changes to your subscription: 
http://www.postgresql.org/mailpref/pgsql-bugs


________________________________
 
If you reply to this email, your message will be added to the discussion below:http://postgresql.1045698.n5.nabble.com/BUG-8335-trim-un-document-behaviour-tp5765221p5766983.html 
To unsubscribe from BUG #8335: trim() un-document behaviour, click here.
NAML



--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-8335-trim-un-document-behaviour-tp5765221p5767148.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

view thread (16+ messages)  latest in thread

Message-ID: <1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com>
Permalink:  ../1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com/
Also on:    postgresql.org/message-id/1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: romainbillongrand@yahoo.fr
  Subject: Re: BUG #8335: trim() un-document behaviour
  In-Reply-To: <1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com>
  References: <E1V2XgU-0003tb-Ii@wrigleys.postgresql.org> <20130807161953.GZ11189@momjian.us> <19166.1376060775@sss.pgh.pa.us> <20130809162359.GA3353@momjian.us> <1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com>

* 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