Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: bvimalvictor(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments
Date: 2019-08-21 10:44:31
Message-ID: CAFj8pRBuSU_kUfEhv+85vMHgF4TR86d_9dkz7P6xVL2UUu0YhA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

st 21. 8. 2019 v 9:03 odesílatel PG Bug reporting form <
noreply(at)postgresql(dot)org> napsal:

> The following bug has been logged on the website:
>
> Bug reference: 15971
> Logged by: VIMAL VICTOR B
> Email address: bvimalvictor(at)gmail(dot)com
> PostgreSQL version: 10.4
> Operating system: Linux
> Description:
>
> Hi,
>
> select substr('abcdef',1,2) val1, substr('abcdef',0,2) val2,
> substr('abcdef',-1,2) val3;
>
> The above query in Postgres returns expected result for val1 ('ab') but for
> val2 and val3, it returns 'a' and '' respectively. Oracle and most of other
> RDBMS systems would return 'ab' for val1 and val2. When the start position
> is -ve, then the start position will be considered from end of input
> string.
> The start position can be considered either as 0 or 1 and substring from
> that position can be returned by considering the max length of the input
> string, which is logically correct. But when -ve value given for start
> position and returning empty string '', which does not seem logically
> correct. Kindly consider this case and let me know your thoughts.
>

Orafce support substr function with Oracle behave

https://github.com/orafce/orafce

Regards

Pavel

>
> Regards,
> Vimal
>
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sandeep Thakkar 2019-08-21 10:46:34 Re: Postgres 11.5.1 failed installation
Previous Message Thomas Kellerer 2019-08-21 10:26:30 Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments