Commit a2a196c0 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10709 Expressions as parameters to Dynamic SQL

Adding Oracle-specific tests for stored functions as EXECUTE..USING parameters.
parent 417c8c9d
......@@ -43,6 +43,24 @@ EXECUTE stmt USING @a, @b;
# MDEV-10709 Expressions as parameters to Dynamic SQL
#
#
# Testing disallowed expressions in USING
#
PREPARE stmt FROM 'SELECT :1 FROM DUAL';
EXECUTE stmt USING (SELECT 1);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1)' at line 1
DEALLOCATE PREPARE stmt;
CREATE FUNCTION f1() RETURN VARCHAR
AS
BEGIN
RETURN 'test';
END;
$$
PREPARE stmt FROM 'SELECT ? FROM DUAL';
EXECUTE stmt USING f1();
ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
DEALLOCATE PREPARE stmt;
DROP FUNCTION f1;
#
# Using a user variable as a EXECUTE..USING out parameter
#
CREATE PROCEDURE p1(a OUT INT)
......@@ -133,6 +151,23 @@ DROP TABLE t1;
#
# MDEV-10585 EXECUTE IMMEDIATE statement
#
#
# Testing disallowed expressions in USING
#
EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING (SELECT 1);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1)' at line 1
CREATE FUNCTION f1() RETURN VARCHAR
AS
BEGIN
RETURN 'test';
END;
$$
EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING f1();
ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
DROP FUNCTION f1;
#
# Testing simple expressions
#
EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING 10;
:1
10
......@@ -28,6 +28,29 @@ EXECUTE stmt USING @a, @b;
--echo # MDEV-10709 Expressions as parameters to Dynamic SQL
--echo #
--echo #
--echo # Testing disallowed expressions in USING
--echo #
PREPARE stmt FROM 'SELECT :1 FROM DUAL';
--error ER_PARSE_ERROR
EXECUTE stmt USING (SELECT 1);
DEALLOCATE PREPARE stmt;
DELIMITER $$;
CREATE FUNCTION f1() RETURN VARCHAR
AS
BEGIN
RETURN 'test';
END;
$$
DELIMITER ;$$
PREPARE stmt FROM 'SELECT ? FROM DUAL';
--error ER_SUBQUERIES_NOT_SUPPORTED
EXECUTE stmt USING f1();
DEALLOCATE PREPARE stmt;
DROP FUNCTION f1;
--echo #
--echo # Using a user variable as a EXECUTE..USING out parameter
--echo #
......@@ -125,4 +148,29 @@ DROP TABLE t1;
--echo #
--echo # MDEV-10585 EXECUTE IMMEDIATE statement
--echo #
--echo #
--echo # Testing disallowed expressions in USING
--echo #
--error ER_PARSE_ERROR
EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING (SELECT 1);
DELIMITER $$;
CREATE FUNCTION f1() RETURN VARCHAR
AS
BEGIN
RETURN 'test';
END;
$$
DELIMITER ;$$
--error ER_SUBQUERIES_NOT_SUPPORTED
EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING f1();
DROP FUNCTION f1;
--echo #
--echo # Testing simple expressions
--echo #
EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING 10;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment