PL/SQL parser (MDEV-10142)

[MDEV-14012] sql_mode=Oracle: substr(): treat position 0 as position 1 Created: 2017-10-05  Updated: 2018-08-31  Resolved: 2017-10-19

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.3
Fix Version/s: 10.3.3

Type: Technical task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: Compatibility

Issue Links:
Blocks
blocks MDEV-10342 Providing compatibility for basic SQL... Closed
Sprint: 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

 Description   

When running with sql_mode=ORACLE, MariaDB should treat the second argument (the position) to "substr" in Oracle way: If position is 0, then it is treated as 1.

Currently MariaDB returns an empty string in case when the position is 0:

select substr('abc',0,3);
+-------------------+
| substr('abc',0,3) |
+-------------------+
|                   |
+-------------------+

This screenshot from an Oracle session demonstrates that 0 is translated to 1:

SQL> select substr('abc',0,3) from dual;
 
SUB
---
abc


Generated at Thu Feb 08 08:10:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.