AW: Oracle-compatible lpad/rpad behavior

From: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: AW: Oracle-compatible lpad/rpad behavior
Date: 2000-12-11 08:41:10
Message-ID: 11C1E6749A55D411A9670001FA68796336816D@sdexcsrv1.f000.d0188.sd.spardat.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


> >> Perhaps they *should* truncate if the specified length is less than
> >> the original string length. Does Oracle do that?
>
> > Yes, it truncates, same as Informix.
>
> I went to fix this and then realized I still don't have an adequate spec
> of how Oracle defines these functions. It would seem logical, for
> example, that lpad might truncate on the left instead of the right,
> ie lpad('abcd', 3, 'whatever') might yield 'bcd' not 'abc'. Would
> someone check?

returns 'abc' on Oracle and Informix.

>
> Also, what happens if the specified length is less than zero? Error,
> or is it treated as zero?

Returns NULL in both if length <= 0. I would see the < 0 case as proper,
but the == 0 case sure looks weird to me.

Very good catch, Tom !! :-)
Andreas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Berndtsson 2000-12-11 10:48:39 Re: Simple Question: Case sensitivity
Previous Message Elmar Haneke 2000-12-11 07:52:10 Re: Why PostgreSQL is not that popular as MySQL?

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB 2000-12-11 10:54:03 AW: Using Threads?
Previous Message Thomas Lockhart 2000-12-11 07:48:15 Re: Re: CRC