Issue Details (XML | Word | Printable)

Key: CORE-2745
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Karol Bieniaszewski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Build in function LPAD result is wrong if argument is longer then length to padd parameter

Created: 11/Nov/09 09:56 AM   Updated: 11/Nov/09 11:59 AM
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: None


 Description  « Hide
select LPAD('123', 4, '0') FROM RDB$DATABASE
result '0123' ok

select LPAD('1234', 4, '0') FROM RDB$DATABASE
result '1234' ok

select LPAD('12345', 4, '0') FROM RDB$DATABASE
result is 1234 - this is wrong

result in this situation should be '12345'

lpad should not change string if length is longer then length parameter


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Lester Caine added a comment - 11/Nov/09 10:16 AM
http://www.firebirdsql.org/refdocs/langrefupd20-udf-lpad.html
If endlength is less than str's length, str is truncated to endlength. If endlength is negative, the result is NULL.
This is exactly the same as oracle, postgresql and mysql

Karol Bieniaszewski added a comment - 11/Nov/09 11:05 AM - edited
if this is as designed
then change description of this function because now is in README.builtin_functions.txt:


Function:
    LPAD(string1, length, string2) appends string2 to the beginning of
    string1 until length of the result string becomes equal to length.

Format:
    LPAD( <string>, <number> [, <string> ] )

Notes:
    1) If the second string is omitted the default value is one space.
    2) The second string is truncated when the result string will
become larger than length.

Example:
    select lpad(x, 10) from y;


add in this description position:
3) If first string parameter is larger then number parameter then will be truncated

//############################################

and then i add new issue/new feature request to add some function like lpad and rpad without this limitation