Re: trim() spec

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: SAKAIDA Masaaki <sakaida(at)psn(dot)co(dot)jp>
Cc: Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: trim() spec
Date: 2000-06-13 13:32:21
Message-ID: 394637E5.8192AFF0@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2000-06-13 13:39:43 Re: ODBC configure
Previous Message Peter Eisentraut 2000-06-13 13:25:29 Re: Adding time to DATE type