public some pl cases and fix a rpm building bug

This commit is contained in:
LINxiansheng
2022-12-13 04:18:53 +00:00
committed by ob-robot
parent 34271aace8
commit 3635038539
19 changed files with 32003 additions and 1 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,358 @@
drop table if exists a,t;
drop procedure if exists p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE CONTINUE HANDLER FOR sqlexception insert into a values(0);
DECLARE EXIT HANDLER FOR SQLSTATE '23000' insert into a values(1);
insert into t values(1);
insert into a values(2);
end//
call p(0);
select * from a;
a1
1
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE CONTINUE HANDLER FOR sqlexception insert into a values(0);
begin
DECLARE EXIT HANDLER FOR aaa insert into a values(4);
insert into t values(1);
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
0
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE CONTINUE HANDLER FOR sqlwarning insert into a values(0);
begin
DECLARE CONTINUE HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
0
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR aaa insert into a values(0);
begin
DECLARE EXIT HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE CONTINUE HANDLER FOR aaa insert into a values(0);
begin
DECLARE CONTINUE HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR aaa insert into a values(0);
begin
DECLARE CONTINUE HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR sqlwarning insert into a values(0);
begin
DECLARE CONTINUE HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
0
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE CONTINUE HANDLER FOR sqlwarning insert into a values(5);
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR aaa insert into a values(0);
begin
DECLARE CONTINUE HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end;
end//
call p(0);
select * from a;
a1
5
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE CONTINUE HANDLER FOR sqlexception insert into a values(5);
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR aaa insert into a values(0);
begin
DECLARE CONTINUE HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end;
end//
call p(0);
select * from a;
a1
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR aaa insert into a values(0);
begin
DECLARE exit HANDLER FOR aaa insert into a values(4);
signal SQLSTATE '01000';
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
select * from a;
a1
2
3
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR aaa insert into a values(0);
begin
DECLARE exit HANDLER FOR aaa insert into a values(4);
insert into t values(1);
insert into a values(2);
end;
insert into a values(3);
end//
call p(0);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
select * from a;
a1
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE EXIT HANDLER FOR sqlexception insert into a values(0);
begin
DECLARE exit HANDLER FOR aaa insert into a values(4);
insert into t values(1);
insert into a values(2);
end;
insert into a values(3);
end;
insert into a values(5);
end//
call p(0);
select * from a;
a1
0
5
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE continue HANDLER FOR sqlexception insert into a values(-1);
begin
DECLARE aaa CONDITION FOR SQLSTATE '42S02';
DECLARE continue HANDLER FOR sqlexception
begin
insert into a values(0);
insert into t values(1);
insert into a values(6);
end;
begin
DECLARE exit HANDLER FOR aaa insert into a values(4);
insert into t values(1);
insert into a values(2);
end;
insert into a values(3);
end;
insert into a values(5);
end//
call p(0);
select * from a;
a1
0
-1
6
2
3
5
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE EXIT HANDLER FOR sqlexception insert into a values(0);
DECLARE EXIT HANDLER FOR SQLSTATE '23000' insert into a values(1);
insert into t values(1);
insert into a values(2);
end//
call p(0);
select * from a;
a1
1
drop table a;
drop table t;
drop procedure p;
create table t(a int primary key);
insert into t values(1);
create table a(a1 int);
create procedure p(x int)
begin
DECLARE EXIT HANDLER FOR SQLSTATE '23000' insert into a values(1);
DECLARE EXIT HANDLER FOR sqlexception insert into a values(0);
insert into t values(1);
insert into a values(2);
end//
call p(0);
select * from a;
a1
1
drop table a;
drop table t;
drop procedure p;
create table t(col int primary key);
insert into t values(1);
create procedure p()
begin
declare x condition for sqlstate '23000';
declare exit handler for x
begin
rollback;
resignal;
end;
insert into t values(1);
end;
//
call p();
//
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
drop procedure p;
drop table t;

View File

@ -0,0 +1,253 @@
result_format: 4
#
# Bug #47412: Valgrind warnings / user can read uninitalized memory
# using SP variables
#
DROP SCHEMA IF EXISTS testdb;
CREATE SCHEMA testdb;
USE testdb;
CREATE FUNCTION f2 () RETURNS INTEGER
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
RETURN f_not_exists () ;
END|
CREATE PROCEDURE p3 ( arg1 VARCHAR(32) )
BEGIN
CALL p_not_exists();
END|
# should not return valgrind warnings
### TODO : --error 1305
CALL p3(f2());
ERROR 2F005: FUNCTION ended without RETURN
DROP SCHEMA testdb;
CREATE SCHEMA testdb;
USE testdb;
CREATE FUNCTION f2() RETURNS INTEGER
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
RETURN f_not_exists();
END|
CREATE PROCEDURE p3(arg2 INTEGER)
BEGIN
CALL p_not_exists();
END|
# should not return valgrind warnings
### TODO : --error 1305
CALL p3(f2());
ERROR 2F005: FUNCTION ended without RETURN
DROP SCHEMA testdb;
CREATE SCHEMA testdb;
USE testdb;
CREATE FUNCTION f2 () RETURNS INTEGER
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
RETURN f_not_exists () ;
END|
# should not return valgrind warnings
### TODO : --error 1305
SELECT f2();
ERROR 2F005: FUNCTION ended without RETURN
DROP SCHEMA testdb;
USE test;
#
# Bug#50423: Crash on second call of a procedure dropping a trigger
#
## coeanbase not support trigger yet !
##
## DROP TABLE IF EXISTS t1;
## DROP TRIGGER IF EXISTS tr1;
## DROP PROCEDURE IF EXISTS p1;
## --enable_warnings
##
## CREATE TABLE t1 (f1 INTEGER);
## CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
## CREATE PROCEDURE p1 () DROP TRIGGER tr1;
##
## CALL p1 ();
## --error ER_TRG_DOES_NOT_EXIST
## CALL p1 ();
##
## DROP TABLE t1;
## DROP PROCEDURE p1;
##
## --echo #
## --echo # Bug#50423: Crash on second call of a procedure dropping a trigger
## --echo #
##
## --disable_warnings
## DROP TABLE IF EXISTS t1;
## DROP TRIGGER IF EXISTS tr1;
## DROP PROCEDURE IF EXISTS p1;
## --enable_warnings
##
## CREATE TABLE t1 (f1 INTEGER);
## CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
## CREATE PROCEDURE p1 () DROP TRIGGER tr1;
##
## CALL p1 ();
## --error ER_TRG_DOES_NOT_EXIST
## CALL p1 ();
##
## DROP TABLE t1;
## DROP PROCEDURE p1;
#
# Bug#54375: Error in stored procedure leaves connection
# in different default schema
#
SET @SQL_MODE_SAVE = @@SQL_MODE;
SET @@SQL_MODE = 'STRICT_ALL_TABLES';
DROP DATABASE IF EXISTS db1;
CREATE DATABASE db1;
USE db1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 int NOT NULL PRIMARY KEY);
INSERT INTO t1 VALUES (1);
CREATE FUNCTION f1 (
some_value int
)
RETURNS smallint
DETERMINISTIC
BEGIN
INSERT INTO t1 SET c1 = some_value;
RETURN(LAST_INSERT_ID());
END$$
DROP DATABASE IF EXISTS db2;
CREATE DATABASE db2;
USE db2;
SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| db2 |
+------------+
SELECT db1.f1(1);
Got one of the listed errors
SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| db2 |
+------------+
USE test;
DROP FUNCTION db1.f1;
DROP TABLE db1.t1;
DROP DATABASE db1;
DROP DATABASE db2;
#
# Bug#13105873:valgrind warning:possible crash in foreign
# key handling on subsequent create table if not exists
#
## oceanbase not support foreign key yet!
## --disable_warnings
## DROP DATABASE IF EXISTS testdb;
## --enable_warnings
## CREATE DATABASE testdb;
## USE testdb;
## CREATE TABLE t1 (id1 INT PRIMARY KEY);
## DELIMITER $;
## CREATE PROCEDURE `p1`()
## BEGIN
## CREATE TABLE IF NOT EXISTS t2(id INT PRIMARY KEY,
## CONSTRAINT FK FOREIGN KEY (id) REFERENCES t1( id1 ));
## END$
## DELIMITER ;$
## CALL p1();
## --echo # below stmt should not return valgrind warnings
## CALL p1();
## DROP DATABASE testdb;
## USE test;
End of 5.1 tests
#
# BUG#13489996 valgrind:conditional jump or move depends on
# uninitialised values-field_blob
#
## oceanbase not support BLOB yet!
## CREATE FUNCTION sf() RETURNS BLOB RETURN "";
## SELECT sf();
## DROP FUNCTION sf;
#
# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
#
SET @@SQL_MODE = '';
CREATE FUNCTION testf_bug11763507() RETURNS INT
BEGIN
RETURN 0;
END
$
CREATE PROCEDURE testp_bug11763507()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END
$
SELECT testf_bug11763507();
+---------------------+
| testf_bug11763507() |
+---------------------+
| 0 |
+---------------------+
SELECT TESTF_bug11763507();
+---------------------+
| TESTF_bug11763507() |
+---------------------+
| 0 |
+---------------------+
CALL testp_bug11763507();
+-----------------------------+
| PROCEDURE testp_bug11763507 |
+-----------------------------+
| PROCEDURE testp_bug11763507 |
+-----------------------------+
CALL TESTP_bug11763507();
+-----------------------------+
| PROCEDURE testp_bug11763507 |
+-----------------------------+
| PROCEDURE testp_bug11763507 |
+-----------------------------+
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
+-------------------+
| specific_name |
+-------------------+
| testf_bug11763507 |
+-------------------+
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
+-------------------+
| specific_name |
+-------------------+
| testf_bug11763507 |
+-------------------+
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
+-------------------+
| specific_name |
+-------------------+
| testf_bug11763507 |
+-------------------+
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
+-------------------+
| specific_name |
+-------------------+
| testf_bug11763507 |
+-------------------+
DROP PROCEDURE testp_bug11763507;
DROP FUNCTION testf_bug11763507;
SET @@SQL_MODE = @SQL_MODE_SAVE;
#END OF BUG#11763507 test.

View File

@ -0,0 +1,44 @@
result_format: 4
drop table if exists t3;
create table t3 ( f bigint unsigned not null );
drop procedure if exists fib;
create procedure fib(n int unsigned)
begin
if n > 1 then
begin
declare x, y bigint unsigned;
declare c cursor for select f from t3 order by f desc limit 2;
open c;
fetch c into y;
fetch c into x;
insert into t3 values (x+y);
call fib(n-1);
## Close the cursor AFTER the recursion to ensure that the stack
## frame is somewhat intact.
close c;
end;
end if;
end|
set @@max_sp_recursion_depth= 20|
insert into t3 values (0), (1)|
call fib(4)|
select * from t3 order by f asc|
+---+
| f |
+---+
| 0 |
| 1 |
| 1 |
| 2 |
| 3 |
+---+
drop table t3|
drop procedure fib|
set @@max_sp_recursion_depth= 0|

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff