Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c2c45c55
Commit
c2c45c55
authored
Sep 20, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-10709 Expressions as parameters to Dynamic SQL
Adding Oracle specific tests
parent
c8822d71
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
0 deletions
+189
-0
mysql-test/suite/compat/oracle/r/ps.result
mysql-test/suite/compat/oracle/r/ps.result
+91
-0
mysql-test/suite/compat/oracle/t/ps.test
mysql-test/suite/compat/oracle/t/ps.test
+98
-0
No files found.
mysql-test/suite/compat/oracle/r/ps.result
View file @
c2c45c55
...
...
@@ -39,3 +39,94 @@ PREPARE stmt FROM 'SELECT :65535,:0';
EXECUTE stmt USING @a, @b;
:65535 :0
10 20
#
# MDEV-10709 Expressions as parameters to Dynamic SQL
#
#
# Using a user variable as a EXECUTE..USING out parameter
#
CREATE PROCEDURE p1(a OUT INT)
AS
BEGIN
a:= 10;
END;
/
SET @a=1;
CALL p1(@a);
SELECT @a;
@a
10
SET @a=2;
PREPARE stmt FROM 'CALL p1(?)';
EXECUTE stmt USING @a;
SELECT @a;
@a
10
DROP PROCEDURE p1;
#
# Using an SP variable as a EXECUTE..USING out parameter
#
CREATE PROCEDURE p1 (a OUT INT)
AS
BEGIN
a:=10;
END;
/
CREATE PROCEDURE p2 (a OUT INT)
AS
BEGIN
PREPARE stmt FROM 'CALL p1(?)';
EXECUTE stmt USING a;
END;
/
SET @a= 1;
CALL p2(@a);
SELECT @a;
@a
10
DROP PROCEDURE p2;
DROP PROCEDURE p1;
#
# Using a trigger field as a EXECUTE..USING out parameter
#
CREATE PROCEDURE p1 (a OUT INT)
AS
BEGIN
a:= 10;
END;
/
CREATE TABLE t1 (a INT);
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1(:NEW.a);
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
a
10
DROP TABLE t1;
DROP PROCEDURE p1;
#
# Testing re-prepare on a table metadata update between PREPARE and EXECUTE
#
CREATE TABLE t1 (a INT);
CREATE PROCEDURE p1(a IN INT)
AS
BEGIN
INSERT INTO t1 VALUES (a);
END;
/
PREPARE stmt FROM 'CALL p1(?)';
EXECUTE stmt USING 10;
SELECT * FROM t1;
a
10
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW NEW.a:=NEW.a+1;
EXECUTE stmt USING 20;
SELECT * FROM t1;
a
10
21
DEALLOCATE PREPARE stmt;
DROP PROCEDURE p1;
DROP TABLE t1;
#
# End of MDEV-10709 Expressions as parameters to Dynamic SQL
#
mysql-test/suite/compat/oracle/t/ps.test
View file @
c2c45c55
...
...
@@ -23,3 +23,101 @@ PREPARE stmt FROM 'SELECT :0,:65535';
EXECUTE
stmt
USING
@
a
,
@
b
;
PREPARE
stmt
FROM
'SELECT :65535,:0'
;
EXECUTE
stmt
USING
@
a
,
@
b
;
--
echo
#
--
echo
# MDEV-10709 Expressions as parameters to Dynamic SQL
--
echo
#
--
echo
#
--
echo
# Using a user variable as a EXECUTE..USING out parameter
--
echo
#
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
a
OUT
INT
)
AS
BEGIN
a
:=
10
;
END
;
/
DELIMITER
;
/
SET
@
a
=
1
;
CALL
p1
(
@
a
);
SELECT
@
a
;
SET
@
a
=
2
;
PREPARE
stmt
FROM
'CALL p1(?)'
;
EXECUTE
stmt
USING
@
a
;
SELECT
@
a
;
DROP
PROCEDURE
p1
;
--
echo
#
--
echo
# Using an SP variable as a EXECUTE..USING out parameter
--
echo
#
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
a
OUT
INT
)
AS
BEGIN
a
:=
10
;
END
;
/
CREATE
PROCEDURE
p2
(
a
OUT
INT
)
AS
BEGIN
PREPARE
stmt
FROM
'CALL p1(?)'
;
EXECUTE
stmt
USING
a
;
END
;
/
DELIMITER
;
/
SET
@
a
=
1
;
CALL
p2
(
@
a
);
SELECT
@
a
;
DROP
PROCEDURE
p2
;
DROP
PROCEDURE
p1
;
--
echo
#
--
echo
# Using a trigger field as a EXECUTE..USING out parameter
--
echo
#
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
a
OUT
INT
)
AS
BEGIN
a
:=
10
;
END
;
/
DELIMITER
;
/
CREATE
TABLE
t1
(
a
INT
);
CREATE
TRIGGER
tr1
BEFORE
INSERT
ON
t1
FOR
EACH
ROW
CALL
p1
(
:
NEW
.
a
);
INSERT
INTO
t1
VALUES
(
1
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
DROP
PROCEDURE
p1
;
--
echo
#
--
echo
# Testing re-prepare on a table metadata update between PREPARE and EXECUTE
--
echo
#
CREATE
TABLE
t1
(
a
INT
);
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
a
IN
INT
)
AS
BEGIN
INSERT
INTO
t1
VALUES
(
a
);
END
;
/
DELIMITER
;
/
PREPARE
stmt
FROM
'CALL p1(?)'
;
EXECUTE
stmt
USING
10
;
SELECT
*
FROM
t1
;
CREATE
TRIGGER
tr1
BEFORE
INSERT
ON
t1
FOR
EACH
ROW
NEW
.
a
:=
NEW
.
a
+
1
;
EXECUTE
stmt
USING
20
;
SELECT
*
FROM
t1
;
DEALLOCATE
PREPARE
stmt
;
DROP
PROCEDURE
p1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of MDEV-10709 Expressions as parameters to Dynamic SQL
--
echo
#
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment