Oracle-compatible lpad/rpad behavior

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Oracle-compatible lpad/rpad behavior
Date: 2000-12-07 19:51:30
Message-ID: 13946.976218690@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at> writes:
>> lpad and rpad never truncate, they only pad.
>>
>> 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?

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

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Travis Bauer 2000-12-07 19:58:13 Sql query with partial matching
Previous Message Neil Conway 2000-12-07 17:26:58 Re: little question

Browse pgsql-hackers by date

  From Date Subject
Next Message Mikheev, Vadim 2000-12-07 19:52:13 RE: beta testing version
Previous Message The Hermit Hacker 2000-12-07 19:48:25 v7.1 beta 1 ...packaged, finally ...