PL/SQL parser (MDEV-10142)

[MDEV-10801] sql_mode=ORACLE: Dynamic SQL placeholders Created: 2016-09-13  Updated: 2020-08-27  Resolved: 2016-09-14

Status: Closed
Project: MariaDB Server
Component/s: Parser, Prepared Statements
Affects Version/s: 10.2
Fix Version/s: 10.3.0

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

Issue Links:
Relates
relates to MDEV-10585 EXECUTE IMMEDIATE statement Closed
relates to MDEV-10709 Expressions as parameters to Dynamic 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, the parser should understand Oracle style placeholders in EXECUTE IMMEDIATE and in PREPARE.

Placeholders are designated as a colon followed by a regular identifier, a delimited identifier, or an integer unsigned number in the range 0..65535:

EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:x,:y) FROM DUAL' USING 10,20;
EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:"x",:"y") FROM DUAL' USING 10,20;
EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:1,:2) FROM DUAL' USING 10,20;
EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:2,:1) FROM DUAL' USING 10,20;
EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:x,:1) FROM DUAL' USING 10,20;

Placeholders in individual statements are associated by position, not by name. All the above queries insert values 10 and 20 into exactly the same columns of the table t1.

Placeholders can have duplicate names. In this case, every placeholder must have a bind value in the USING clause.

EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:x,:x) FROM DUAL' USING 10,20;
EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:1,:1) FROM DUAL' USING 10,20;
EXECUTE IMMEDIATE 'INSERT INTO t1 SELECT (:2,:2) FROM DUAL' USING 10,20;

Unlike individual statements, rules in blocks are different. Only each unique placeholder must have an unique value. Blocks are out of scope of this task.


Generated at Thu Feb 08 07:45:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.