Re: Oracle-compatible lpad/rpad behavior

From: "Jonathan Ellis" <jellis(at)advocast(dot)com>
To: <pgsql-general(at)postgreSQL(dot)org>, <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Oracle-compatible lpad/rpad behavior
Date: 2000-12-07 21:30:24
Message-ID: 008c01c06095$18a2f420$0d00a8c0@dsl.inconnect.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> 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)

-Jonathan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darrin Ladd 2000-12-07 21:40:00 Re: Trigger Problems?
Previous Message Peter Eisentraut 2000-12-07 21:18:51 Re: multi-byte support

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-07 21:35:00 Re: CRC was: Re: beta testing version
Previous Message Horst Herb 2000-12-07 21:26:31 Re: CRCs (was: beta testing version)