PL/SQL parser (MDEV-10142)

[MDEV-13919] sql_mode=ORACLE: Derive length of VARCHAR SP parameters with no length from actual parameters Created: 2017-09-27  Updated: 2018-08-31  Resolved: 2017-09-28

Status: Closed
Project: MariaDB Server
Component/s: Parser, Stored routines
Affects Version/s: 10.3
Fix Version/s: 10.3.2

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

Sprint: 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

 Description   

In sql_mode=oracle, when an SP parameter of the VARCHAR data type is defined without length,
the length should be inherited from the actual argument at call time. This is how Oracle works.

This script works fine in Oracle:

CREATE OR REPLACE PROCEDURE p1(p OUT VARCHAR)
AS
BEGIN
  p:='0123456789';
END;
/
declare w varchar(10);
begin
  p1(w);
end;
/

This script:

declare w varchar(8);
begin
  p1(w);
end;
/

fails with an error:

ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small

Furthermore, since Oracle 9, VARCHAR datatype in PL/SQL is not limited to 4000 char but to 32k.
It's the size of varchar column in a table that is limited to 4000 (until Oracle 12C which allow 32k when MAX_STRING_SIZE=EXTENDED).



 Comments   
Comment by Alexander Barkov [ 2017-09-28 ]

Pushed to bb-10.2-ext and 10.3

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