PL/SQL parser (MDEV-10142)

[MDEV-10709] Expressions as parameters to Dynamic SQL Created: 2016-08-31  Updated: 2018-08-31  Resolved: 2016-09-20

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

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

Issue Links:
Blocks
blocks MDEV-10585 EXECUTE IMMEDIATE statement Closed
is blocked by MDEV-10702 Crash in SET STATEMENT FOR EXECUTE Closed
is blocked by MDEV-10772 Introduce Item_param::CONVERSION_INFO Closed
Relates
relates to MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter Closed
relates to MDEV-10801 sql_mode=ORACLE: Dynamic SQL placehol... Closed
relates to MDEV-11781 sql_mode=ORACLE: IN, OUT, IN OUT mode... Open
relates to MDEV-14270 Dynamic CREATE TABLE does not preserv... Open
relates to MDEV-14271 Dynamic SQL: TIMESTAMP parameter valu... Open
Sprint: 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

 Description   

MariaDB allows to use only user variables in EXECUTE..USING:

EXECUTE stmt USING @a;

Under terms of this task, we'll allow passing expressions as parameters to Dynamic SQL:

PREPARE stmt FROM 'SELECT ? FROM t1';
EXECUTE stmt USING 1+2;

Note, these expression types should work as output parameters (in addition to user variables):

  • SP variables
  • Trigger NEW and OLD fields

Note, stored functions and subselects as parameters will not be supported under terms of this task. Using stored functions and subselects would require some additional changes in table locking, SP cache and transaction handling (for the same reason, SET STATEMENT disallows stored functions and subselects as variable values). So the following scripts will return errors:

PREPARE stmt FROM 'SELECT ? FROM DUAL';
EXECUTE stmt USING (SELECT 1);

CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test';
PREPARE stmt FROM 'SELECT ? FROM DUAL';
EXECUTE stmt USING f1();

Support for stored functions and subselects as parameters (as well as in SET STATEMENT variable values) will be added under terms of a separate task.


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