Re: BUG #15971: Behaviour of SUBSTR function depending on itsarguments

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: BUG #15971: Behaviour of SUBSTR function depending on itsarguments
Дата
Msg-id 89fff570-c391-26ef-49d6-b1e9afd3f5db@gmx.net
обсуждение исходный текст
Ответ на BUG #15971: Behaviour of SUBSTR function depending on its arguments  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
PG Bug reporting form schrieb am 21.08.2019 um 09:02:

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

The only "other" DBMS that behaves the way you describe it, is Oracle. 

When I ran it on different systems, this is the result:

           | val1 |  val2   | val3    |
-----------|------|---------|---------|
Postgres   |  ab  |    a    | <empty> |
SQL Server |  ab  |    a    | <empty> |
SQLite     |  ab  |    a    |    f    |
MySQL      |  ab  | <empty> |    f    |
Oracle     |  ab  |   ab    |    f    |

DB2 and Firebird do not allow a starting position smaller than 1 

So SQL Server works the same as Postgres and Oracle is the only one that returns 'ab' for the second case

So clearly the claim "most other" is wrong here. 




В списке pgsql-bugs по дате отправления:

Предыдущее
От: Ashutosh Sharma
Дата:
Сообщение: Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments