Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8lCT-0006v6-29 for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Aug 2013 06:01:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V8lCR-00042T-WD for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Aug 2013 06:01:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8lCR-00042K-Bf for pgsql-bugs@postgresql.org; Mon, 12 Aug 2013 06:01:51 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8lCN-0003bM-2N for pgsql-bugs@postgresql.org; Mon, 12 Aug 2013 06:01:50 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1V8lCK-000136-8n for pgsql-bugs@postgresql.org; Sun, 11 Aug 2013 23:01:44 -0700 Date: Sun, 11 Aug 2013 23:01:44 -0700 (PDT) From: Romain Billon-Grand To: pgsql-bugs@postgresql.org Message-ID: <1376287291.96629.YahooMailNeo@web172406.mail.ir2.yahoo.com> In-Reply-To: <20130809162359.GA3353@momjian.us> References: <20130807161953.GZ11189@momjian.us> <19166.1376060775@sss.pgh.pa.us> <20130809162359.GA3353@momjian.us> Subject: Re: BUG #8335: trim() un-document behaviour MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_104374_3512995.1376287304267" X-Pg-Spam-Score: 0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org ------=_Part_104374_3512995.1376287304267 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Finally could make it using regexp_replace (my_field_to_trim, '.+my_triming_string' , '') for the "lead= ing" case regexp_replace (my_field_to_trim, 'my_triming_string(.+)' , '') for the "tr= ailing" case And both of them in this order a for the "both" one. I don't know why, but=C2=A0 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=C2=A0: Bruce Momjian [via PostgreSQL] =C3=80=C2=A0: Romain Billon-Grand =20 Envoy=C3=A9 le : Vendredi 9 ao=C3=BBt 2013 18h24 Objet=C2=A0: Re: BUG #8335: trim() un-document behaviour =20 On Fri, Aug =C2=A09, 2013 at 11:06:15AM -0400, Tom Lane wrote:=20 > Bruce Momjian <[hidden email]> writes:=20 > > The attached patch swaps the arguments in the parser, and allows your= =20 > > expected behavior:=20 >=20 > This patch is completely unsafe. =C2=A0It will break stored rules, which = may=20 > contain calls using the existing argument order (which will be dumped=20 > without any of the SQL-spec syntactic sugar). =C2=A0To say nothing of exi= sting=20 > applications that may be relying on calling the underlying functions with= =20 > their existing argument order.=20 >=20 > The inconsistency in argument order is unfortunate but we're long since= =20 > stuck with it, I'm afraid.=20 Yes, I have thought about this some more and another problem is that=20 rtrim/btrim/ltrim() use the source string first, so having trim() have=20 the source string second when using a comma is very confusing, e.g.:=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- with patch=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SELECT trim('x', 'xabcx');=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0btrim=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -------=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0abc=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- btrim=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SELECT btrim('xabcx', 'x');=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0btrim=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -------=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0abc=20 I think we can either document what we have, or remove the ability to=20 use comma with trim(). =C2=A0If we go with documentation, it is going to lo= ok=20 confusing as the optional modifier is going to be on the source string,=20 e.g.:=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SELECT trim(both 'xabcx', 'x');=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0btrim=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -------=20 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0abc=20 We could modify the grammar to force the modifier on the second=20 argument, but that is more parser states for limited value.=20 --=20 =C2=A0 Bruce Momjian =C2=A0<[hidden email]> =C2=A0 =C2=A0 =C2=A0 =C2=A0http= ://momjian.us =C2=A0 EnterpriseDB =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://enterprisedb.com =C2=A0 + It's impossible for everything to be true. +=20 --=20 Sent via pgsql-bugs mailing list ([hidden email])=20 To make changes to your subscription:=20 http://www.postgresql.org/mailpref/pgsql-bugs ________________________________ =20 If you reply to this email, your message will be added to the discussion be= low:http://postgresql.1045698.n5.nabble.com/BUG-8335-trim-un-document-behav= iour-tp5765221p5766983.html=20 To unsubscribe from BUG #8335: trim() un-document behaviour, click here. NAML -- View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-8= 335-trim-un-document-behaviour-tp5765221p5767148.html Sent from the PostgreSQL - bugs mailing list archive at Nabble.com. ------=_Part_104374_3512995.1376287304267 Content-Type: text/html; charset=UTF8 Content-Transfer-Encoding: quoted-printable
Finally could make it using
re= gexp_replace (my_field_to_trim, '.+my_triming_string' , '') for the "leadin= g" 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 wor= ked


De : Bruce Momjian [via PostgreSQL] <[hidden email]>
=C3=80 : Romain Billon-= Grand <[hidden email]> <= br> Envoy=C3=A9 le : Vendr= edi 9 ao=C3=BBt 2013 18h24
Objet&= nbsp;: Re: BUG #8335: trim() un-document behaviour
<= /div>

=09On 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 all= ows your
> > expected behavior:
>=20
> This patch is completely unsafe.  It will break stored rules,= which may
> contain calls using the existing argument order (which will be dum= ped
> without any of the SQL-spec syntactic sugar).  To say nothing= of existing
> applications that may be relying on calling the underlying functio= ns with
> their existing argument order.
>=20
> 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 t= o 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.

--=20
  Bruce Momjian  <[hidden email]>        <= a rel=3D"nofollow" target=3D"_blank" href=3D"http://momjian.us/" link=3D"ex= ternal">http://momjian.us
  EnterpriseDB       &= nbsp;                    = http://enterprisedb.com

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


--=20
Sent via pgsql-bugs mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/= pgsql-bugs
=09 =09 =09 =09
=09
=09
=09
=09=09
If you reply to this email, your mes= sage will be added to the discussion below:
=09=09http://postgresql.1045698.n5.nabble.com/BUG-8335-trim-u= n-document-behaviour-tp5765221p5766983.html =09
=09
=09=09 =09=09To unsubscribe from BUG #8335: trim() un-document behaviour, click here.=
=09=09NAML =09


=09 =09 =09

View this message in context: Re: BUG #= 8335: trim() un-document behaviour
Sent from the PostgreSQL - bugs mailing list archive at Nabble.c= om.
------=_Part_104374_3512995.1376287304267--