Re: trim() spec - Mailing list pgsql-hackers

From Thomas Lockhart
Subject Re: trim() spec
Date
Msg-id 394637E5.8192AFF0@alumni.caltech.edu
Whole thread Raw
In response to trim() spec  (SAKAIDA Masaaki <sakaida@psn.co.jp>)
List pgsql-hackers
> > Can you tell me trim() spec, please ? (This problem has been
> > discussed in pgsql-jp ML. )
> > In trim(trailing 'abc' from '123cbabc') function, 'abc' means
> > ~'[abc]'.
> > If trim(trailing 'abc' from '123cbabc') returns "123cb", current
> > trim() spec is broken. However, the spec that 'abc' means ~'[abc]'
> > is ugly. It seems that this ugly spec isn't used for any kind of
> > functions argument and SQL expression except for trim().
> > How do you think about the trim() spec ?
> 
> afaict, the SQL92 spec for trim() requires a single character as the
> first argument; allowing a character string is a Postgres extension. 
> On the surface, istm that this extension is in the spirit of the SQL92
> spec, in that it allows trimming several possible characters.
> 
> I'm not sure if SQL3/SQL99 has anything extra to say on this.
> 
> position() and substring() seem to be able to do what you want;
> 
>  select substring('123ab' for position('ab' in '123ab')-1);
> 
> gives '123', while
> 
>  select substring('123ab' for position('d' in '123ab')-1);
> 
> gives '123ab', which seems to be the behavior you might be suggesting
> for trim().
> 
>                         - Tom


pgsql-hackers by date:

Previous
From: Peter Mount
Date:
Subject: RE: Integrating Sendmail with PostgreSQL
Next
From: Thomas Lockhart
Date:
Subject: Re: ODBC configure