Re: trim() spec

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: SAKAIDA Masaaki <sakaida(at)psn(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: trim() spec
Date: 2000-06-13 01:35:57
Message-ID: 39458FFD.167D0CB9@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

In response to

  • trim() spec at 2000-06-03 03:28:56 from SAKAIDA Masaaki

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2000-06-13 01:49:28 Re: Variable formatting of datetime with DateStyle=ISO
Previous Message Vince Vielhaber 2000-06-13 01:05:07 Re: [ANNOUNCE] Delphi's components for direct access to PostgreSQL