Re: Re: [GENERAL] Oracle-compatible lpad/rpad behavior - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Re: [GENERAL] Oracle-compatible lpad/rpad behavior
Date
Msg-id 3A3675D7.A80234AF@tm.ee
Whole thread Raw
In response to AW: Re: [GENERAL] is it a bug?  (Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>)
List pgsql-hackers
Jonathan Ellis wrote:
>
> > 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?
>
> SQL> select lpad('abcd', 3, 'foobar') from dual;
>
> LPA
> ---
> abc
>
> > Also, what happens if the specified length is less than zero?  Error,
> > or is it treated as zero?
>
> SQL> select ':' || lpad('abcd', -1, 'foobar') || ':' from dual;
>
> ':
> --
> ::
>
> (colons added so it's obvious that it's a zero-length string)

AFAIK Oracle is unable to distinguish NULL and zero-length string ;(

--------------
Hannu

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: shared libs on sco how?
Next
From: Stephan Szabo
Date:
Subject: Re: Fwd: Re: HELP! foreign eys & inheritance