summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/compat/oracle/t/sp-package-concurrent-dml.inc
blob: 8ee96d1ee6a16b9dead8ffe0a34cf31386c7f50d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--echo #
--echo # Start of sp-package-concurrent-dml.inc
--echo #

--source include/count_sessions.inc

let $object_type= `SELECT @object_type`;

SET sql_mode=ORACLE;
DELIMITER $$;
CREATE PACKAGE pkg1 AS
  PROCEDURE p1;
END;
$$
CREATE PACKAGE BODY pkg1 AS
  PROCEDURE p2 AS
  BEGIN
    SELECT 'This is p2' AS msg;
  END;
  PROCEDURE p1 AS
  BEGIN
    SELECT 'This is p1' AS msg;
    DO GET_LOCK('mdev15070',120);
    CALL p2();
    DO RELEASE_LOCK('mdev15070');
  END;
END;
$$
DELIMITER ;$$

connect (con2,localhost,root);
connection con2;
DO GET_LOCK('mdev15070', 120);

connection default;
send CALL pkg1.p1;

connection con2;
let $wait_condition=
  SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
  WHERE state = "User lock" AND info LIKE "%GET_LOCK%mdev15070%";
--source include/wait_condition.inc


if ($object_type==view)
{
  CREATE VIEW v1 AS SELECT 1 AS c;
  DROP VIEW v1;
}


if ($object_type==package_replace_pkg1)
{
  SET sql_mode=ORACLE;
  DELIMITER $$;
  CREATE OR REPLACE PACKAGE pkg1 AS
    PROCEDURE p1;
  END;
  $$
  DELIMITER ;$$
  DROP PACKAGE pkg1;
}


if ($object_type==package_body_replace_pkg1)
{
  SET sql_mode=ORACLE;
  DELIMITER $$;
  CREATE OR REPLACE PACKAGE BODY pkg1 AS
    PROCEDURE p1 AS
    BEGIN
      SELECT 'This is p1 version 2' AS msg;
    END;
  END;
  $$
  DELIMITER ;$$
  DROP PACKAGE pkg1;
}


if ($object_type==trigger)
{
  CREATE TABLE t1 (a INT);
  CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a=1;
  DROP TRIGGER tr1;
  DROP TABLE t1;
}


if ($object_type=='db')
{
  CREATE DATABASE test1;
  CREATE FUNCTION test1.f1() RETURNS INT RETURN 10;
  DROP DATABASE test1;
}


DO RELEASE_LOCK('mdev15070');

disconnect con2;

connection default;
reap;

DROP PACKAGE IF EXISTS pkg1;

--source include/wait_until_count_sessions.inc