mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
copy from test-extra-5.1 to main tree
BitKeeper/etc/ignore: Added mysql-test/suite/funcs_1/r/innodb_views.warnings mysql-test/suite/funcs_1/r/memory_trig_03e.warnings mysql-test/suite/funcs_1/r/memory_views.warnings mysql-test/suite/funcs_1/r/myisam_trig_03e.warnings mysql-test/suite/funcs_1/r/myisam_views.warnings mysql-test/suite/funcs_1/r/ndb_trig_03e.warnings mysql-test/suite/funcs_1/r/ndb_views.warnings mysql-test/suite/partitions/r/diff mysql-test/suite/partitions/r/partition_bit_ndb.warnings mysql-test/suite/partitions/r/partition_special_innodb.warnings mysql-test/suite/partitions/r/partition_special_myisam.warnings storage/archive/archive_reader mysql-test/suite/funcs_1/r/innodb_trig_03e.warnings to the ignore list mysql-test/suite/funcs_2/include/check_charset.inc: inserted newline at the end of file. mysql-test/suite/objects/include/drop_all.inc: inserted newline at the end of file. mysql-test/suite/partitions/include/partition_key_32col.inc: inserted newline at the end of file. mysql-test/suite/rpl/data/rpl_mixed.dat: inserted newline at the end of file. mysql-test/suite/rpl/include/rpl_mixed_check_event.inc: inserted newline at the end of file. mysql-test/suite/rpl/include/rpl_mixed_check_select.inc: inserted newline at the end of file. mysql-test/suite/rpl/include/rpl_mixed_check_user.inc: inserted newline at the end of file. mysql-test/suite/rpl/include/rpl_mixed_check_view.inc: inserted newline at the end of file.
This commit is contained in:
9
mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc
Normal file
9
mysql-test/suite/funcs_1/storedproc/cleanup_sp_tb.inc
Normal file
@ -0,0 +1,9 @@
|
||||
let $message= --source suite/funcs_1/storedproc/cleanup_sp_tb.inc;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
# called both to cleanup possibly existing data before and after the SP tests
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS db_storedproc;
|
||||
DROP DATABASE IF EXISTS db_storedproc_1;
|
||||
--enable_warnings
|
68
mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc
Normal file
68
mysql-test/suite/funcs_1/storedproc/load_sp_tb.inc
Normal file
@ -0,0 +1,68 @@
|
||||
let $message= --source suite/funcs_1/storedproc/load_sp_tb.inc;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
# ==============================================================================
|
||||
#
|
||||
# this load script can be called multiple times inside a test script because it
|
||||
# first cleans up all objects that will be created.
|
||||
# therefore the same script is used as it will be used at the end of a test.
|
||||
#
|
||||
# ==============================================================================
|
||||
|
||||
--disable_abort_on_error
|
||||
--enable_query_log
|
||||
|
||||
SET @@global.max_heap_table_size=4294967295;
|
||||
SET @@session.max_heap_table_size=4294967295;
|
||||
|
||||
# use the same .inc to cleanup before and after the test
|
||||
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
|
||||
|
||||
CREATE DATABASE db_storedproc;
|
||||
CREATE DATABASE db_storedproc_1;
|
||||
|
||||
USE db_storedproc;
|
||||
|
||||
eval create table t1(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t1;
|
||||
|
||||
eval create table t2(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t2;
|
||||
|
||||
eval create table t3(f1 char(20),f2 char(20),f3 integer) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t3.txt' into table t3;
|
||||
|
||||
eval create table t4(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t4;
|
||||
|
||||
USE db_storedproc_1;
|
||||
|
||||
eval create table t6(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t6;
|
||||
|
||||
USE db_storedproc;
|
||||
|
||||
eval create table t7 (f1 char(20), f2 char(25), f3 date, f4 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t7.txt' into table t7;
|
||||
|
||||
eval create table t8 (f1 char(20), f2 char(25), f3 date, f4 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t7.txt' into table t8;
|
||||
|
||||
eval create table t9(f1 int, f2 char(25), f3 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t9.txt' into table t9;
|
||||
|
||||
eval create table t10(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t10;
|
||||
|
||||
eval create table t11(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) engine = $engine_type;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data infile '$MYSQL_TEST_DIR/suite/funcs_1/data/t4.txt' into table t11;
|
1536
mysql-test/suite/funcs_1/storedproc/storedproc_02.inc
Normal file
1536
mysql-test/suite/funcs_1/storedproc/storedproc_02.inc
Normal file
File diff suppressed because it is too large
Load Diff
464
mysql-test/suite/funcs_1/storedproc/storedproc_03.inc
Normal file
464
mysql-test/suite/funcs_1/storedproc/storedproc_03.inc
Normal file
@ -0,0 +1,464 @@
|
||||
#### suite/funcs_1/storedproc/storedproc_03.inc
|
||||
#
|
||||
--source suite/funcs_1/storedproc/load_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
# (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00)
|
||||
#
|
||||
# 3.1.3 Syntax checks for the stored procedure-specific flow control statements IF, CASE, LOOP, LEAVE, ITERATE, REPEAT, WHILE:
|
||||
#
|
||||
#- 1. Ensure that all subclauses that should be supported are supported.
|
||||
#- 2. Ensure that all subclauses that should not be supported are disallowed with an appropriate error message.
|
||||
#- 3. Ensure that all supported subclauses are supported only in the correct order.
|
||||
#- 4. Ensure that an appropriate error message is returned if a subclause is out-of-order in a stored procedure definition.
|
||||
#- 5. Ensure that all subclauses that are defined to be mandatory are indeed required to be mandatory by the MySQL server and tools.
|
||||
#- 6. Ensure that any subclauses that are defined to be optional are indeed treated as optional by the MySQL server and tools.
|
||||
## 7. Ensure that the IF statement acts correctly for all variants, including cases where statements are nested.
|
||||
## 8. Ensure that the CASE statement acts correctly for all variants, including cases where statements are nested.
|
||||
## 9. Ensure that the LOOP statement acts correctly for all variants, including cases where statements are nested.
|
||||
#- 10. Ensure that the labels enclosing each LOOP statement must match.
|
||||
#- 11. Ensure that it is possible to put a beginning label at the start of a LOOP statement without also requiring an ending label at the end of the same statement.
|
||||
#- 12. Ensure that it is not possible to put an ending label at the end of a LOOP statement without also requiring a matching beginning label at the start of the same statement.
|
||||
#- 13. Ensure that every beginning label must end with a colon (:).
|
||||
#- 14. Ensure that every beginning label with the same scope must be unique.
|
||||
## 15. Ensure that the LEAVE statement acts correctly for all variants, including cases where statements are nested.
|
||||
## 16. Ensure that the ITERATE statement acts correctly for all variants, including cases where statements are nested.
|
||||
#- 17. Ensure that the ITERATE statement fails, with an appropriate error message, if it appears in any context other than within LOOP, REPEAT, or WHILE statements.
|
||||
## 18. Ensure that the REPEAT statement acts correctly for all variants, including cases where statements are nested.
|
||||
#- 19. Ensure that the labels enclosing each REPEAT statement must match.
|
||||
#- 20. Ensure that it is possible to put a beginning label at the start of a REPEAT statement without also requiring an ending label at the end of the same statement.
|
||||
#- 21. Ensure that it is not possible to put an ending label at the end of a REPEAT statement without also requiring a matching beginning label at the start of the same statement.
|
||||
#- 22. Ensure that every beginning label must end with a colon (:).
|
||||
#- 23. Ensure that every beginning label with the same scope must be unique.
|
||||
## 24. Ensure that the WHILE statement acts correctly for all variants, including cases where statements are nested.
|
||||
#- 25. Ensure that the labels enclosing each WHILE statement must match.
|
||||
#- 26. Ensure that it is possible to put a beginning label at the start of a WHILE statement without also requiring an ending label at the end of the same statement.
|
||||
#- 27. Ensure that it is not possible to put an ending label at the end of a WHILE statement without also requiring a matching beginning label at the start of the same statement.
|
||||
#- 28. Ensure that every beginning label must end with a colon (:).
|
||||
#- 29. Ensure that every beginning label with the same scope must be unique.
|
||||
## 30. Ensure that multiple cases of all possible combinations of the control flow statements, nested within multiple compound statements within a stored procedure, always act correctly and return the expected result.
|
||||
#
|
||||
# ==============================================================================
|
||||
let $message= Section 3.1.3 - Syntax checks for the stored procedure-specific flow
|
||||
control statements IF, CASE, LOOP, LEAVE, ITERATE, REPEAT, WHILE:;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
#FIXME # 3.1.3: enhance syntax checks with very complicated checks
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.7:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the IF statement acts correctly for all variants, including cases
|
||||
where statements are nested.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
DROP PROCEDURE IF EXISTS sp9;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 CHAR(20), f2 VARCHAR(20), f3 SMALLINT);
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp9( action char(20), subaction char(20) )
|
||||
BEGIN
|
||||
if action = 'action' then
|
||||
if subaction = 'subaction' then
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'subaction' , 1);
|
||||
else
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'none' , 2);
|
||||
END if;
|
||||
else
|
||||
if subaction = 'subaction'
|
||||
then
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'subaction' , 3);
|
||||
elseif subaction = 'subaction1'
|
||||
then
|
||||
BEGIN
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values ('none', 'subaction1', 4);
|
||||
END;
|
||||
else
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'none' , 5);
|
||||
END if;
|
||||
END if;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
CALL sp9( 'action', 'subaction' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=1;
|
||||
|
||||
CALL sp9( 'temp', 'subaction' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=3;
|
||||
|
||||
CALL sp9( 'temp', 'subaction1' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=4;
|
||||
|
||||
CALL sp9( 'action', 'temp' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=2;
|
||||
|
||||
CALL sp9( 'temp', 'temp' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742 where f3=5;
|
||||
|
||||
# cleanup 3.1.3.7
|
||||
DROP PROCEDURE sp9;
|
||||
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.8.:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the CASE statement acts correctly for all variants, including cases
|
||||
where statements are nested.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
DROP PROCEDURE IF EXISTS sp10;
|
||||
--enable_warnings
|
||||
|
||||
create table res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 char(20), f2 varchar(20), f3 smallint);
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp10( action char(20), subaction char(20) )
|
||||
BEGIN
|
||||
case action
|
||||
when 'action' then
|
||||
case
|
||||
when subaction = 'subaction_1' then
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'subaction_2' , 1);
|
||||
when subaction = 'subaction_2' then
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'subaction_2' , 2);
|
||||
else
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'action', 'none' , 3);
|
||||
END case;
|
||||
else
|
||||
case
|
||||
when subaction = 'subaction_1' then
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'subaction_1' , 4);
|
||||
when subaction = 'subaction_2' then
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'subaction_2' , 5);
|
||||
else
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'none', 'none' , 6);
|
||||
END case;
|
||||
END case;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
CALL sp10( 'action', 'subaction_1' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
CALL sp10( 'action', 'subaction_2' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
CALL sp10( 'temp', 'subaction_1' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
CALL sp10( 'temp', 'subaction_2' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
CALL sp10( 'action', 'temp' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
delete from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
CALL sp10( 'temp', 'temp' );
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
# cleanup 3.1.3.8
|
||||
DROP PROCEDURE sp10;
|
||||
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.9 + 3.1.3.15:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
09. Ensure that the LOOP statement acts correctly for all variants, including
|
||||
. cases where statements are nested.
|
||||
15. Ensure that the LEAVE statement acts correctly for all variants, including
|
||||
. cases where statements are nested.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
DROP PROCEDURE IF EXISTS sp11;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 CHAR(20), f2 VARCHAR(20), f3 SMALLINT);
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp11( )
|
||||
BEGIN
|
||||
declare count1 integer default 1;
|
||||
declare count2 integer default 1;
|
||||
label1: loop
|
||||
if count2 > 3 then leave label1;
|
||||
END if;
|
||||
set count1 = 1;
|
||||
label2: loop
|
||||
if count1 > 4 then leave label2;
|
||||
END if;
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'xyz' , 'pqr', count1);
|
||||
set count1 = count1 + 1;
|
||||
iterate label2;
|
||||
END loop label2;
|
||||
set count2 = count2 + 1;
|
||||
iterate label1;
|
||||
END loop label1;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
CALL sp11();
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
# cleanup 3.1.3.9
|
||||
DROP PROCEDURE sp11;
|
||||
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.16:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the ITERATE statement acts correctly for all variants, including
|
||||
cases where statements are nested.
|
||||
(tests for this testcase are also included in other testcases);
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp31316;
|
||||
--enable_warnings
|
||||
|
||||
delimiter //;
|
||||
|
||||
# wrong label at iterate
|
||||
#Error: 1308 SQLSTATE: 42000 (ER_SP_LILABEL_MISMATCH) Message: %s with no matching label: %s
|
||||
--error 1308
|
||||
CREATE PROCEDURE sp31316( )
|
||||
BEGIN
|
||||
declare count1 integer default 1;
|
||||
declare count2 integer default 1;
|
||||
label1: loop
|
||||
if count2 > 3 then leave label1;
|
||||
END if;
|
||||
set count1 = 1;
|
||||
label2: loop
|
||||
if count1 > 4 then leave label2;
|
||||
END if;
|
||||
insert into temp values( count1, count2);
|
||||
set count1 = count1 + 1;
|
||||
iterate label3;
|
||||
END loop label2;
|
||||
set count2 = count2 + 1;
|
||||
iterate label1;
|
||||
END loop label1;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
# cleanup 3.1.3.16
|
||||
#DROP PROCEDURE sp31316;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.18:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the REPEAT statement acts correctly for all variants, including
|
||||
cases where statements are nested.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp17;
|
||||
DROP TABLE IF EXISTS res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742( f1 CHAR(20), f2 VARCHAR(20), f3 SMALLINT);
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp17( )
|
||||
BEGIN
|
||||
declare count1 integer default 1;
|
||||
declare count2 integer default 1;
|
||||
repeat
|
||||
set count1 = count1 + 1;
|
||||
set count2 = 1;
|
||||
label1: repeat
|
||||
set count2 = count2 + 1;
|
||||
insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'xyz' , 'pqr', count1);
|
||||
until count2 > 3
|
||||
END repeat label1;
|
||||
until count1 > 3
|
||||
END repeat;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
CALL sp17();
|
||||
SELECT * from res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
# cleanup 3.1.3.18
|
||||
DROP PROCEDURE sp17;
|
||||
DROP TABLE res_t3_itisalongname_1381742_itsaverylongname_1381742;
|
||||
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.24:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the WHILE statement acts correctly for all variants, including cases
|
||||
where statements are nested.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table IF EXISTS res_t21;
|
||||
DROP PROCEDURE IF EXISTS sp21;
|
||||
--enable_warnings
|
||||
|
||||
create table res_t21(name text(10), surname blob(20), age_averylongfieldname_averylongname_1234569 smallint);
|
||||
insert into res_t21 values('ashwin', 'mokadam', 25);
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp21( )
|
||||
BEGIN
|
||||
declare count1 integer default 0;
|
||||
declare count2 integer default 0;
|
||||
while count1 < 3 do
|
||||
BEGIN
|
||||
declare ithisissamevariablename int default 100;
|
||||
SELECT ithisissamevariablename;
|
||||
BEGIN
|
||||
declare ithisissamevariablename int default 200;
|
||||
SELECT ithisissamevariablename;
|
||||
END;
|
||||
set count2 = 0;
|
||||
label1: while count2 < 3 do
|
||||
BEGIN
|
||||
declare count1 integer default 7;
|
||||
set count2 = count2 + 1;
|
||||
insert into res_t21 values( 'xyz' , 'pqr', count2);
|
||||
label2: while count1 < 10 do
|
||||
set count1 = count1 + 1;
|
||||
insert into res_t21 values( 'xyz' , 'pqr', count1);
|
||||
END while label2;
|
||||
END;
|
||||
END while label1;
|
||||
set count1 = count1 + 1;
|
||||
END;
|
||||
END while;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
CALL sp21();
|
||||
SELECT * from res_t21;
|
||||
|
||||
# cleanup 3.1.3.
|
||||
DROP PROCEDURE sp21;
|
||||
drop table res_t21;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.3.30:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that multiple cases of all possible combinations of the control flow
|
||||
statements, nested within multiple compound statements within a stored
|
||||
procedure, always act correctly and return the expected result.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS res_tbl;
|
||||
DROP PROCEDURE IF EXISTS sp31330;
|
||||
--enable_warnings
|
||||
|
||||
create table res_tbl (f1 int, f2 text, f3 blob, f4 date,
|
||||
f5 set('one', 'two', 'three', 'four', 'five') default 'one');
|
||||
|
||||
delimiter //;
|
||||
#FIXME: can be enhanced more and more ...
|
||||
CREATE PROCEDURE sp31330 (path int)
|
||||
BEGIN
|
||||
declare count int default 1;
|
||||
declare var1 text;
|
||||
declare var2 blob;
|
||||
declare var3 date;
|
||||
declare var4 set('one', 'two', 'three', 'four', 'five') DEFAULT 'five';
|
||||
case
|
||||
when path=1 then
|
||||
set var3 = '2000-11-09';
|
||||
set var1 = 'flowing through case 1';
|
||||
label1: loop
|
||||
if count > 5 then
|
||||
if var4=1000 then
|
||||
set var2 = 'exiting out of case 1 - invalid SET';
|
||||
END if;
|
||||
if var4='two' then
|
||||
set var2 = 'exiting out of case 1';
|
||||
END if;
|
||||
insert into res_tbl values (1, var1, var2, var3, (count-2));
|
||||
leave label1;
|
||||
elseif count = 5 then
|
||||
set count= count + 2;
|
||||
set var4='two';
|
||||
iterate label1;
|
||||
else
|
||||
set count= count + 1;
|
||||
END if;
|
||||
set var4='one';
|
||||
END loop label1;
|
||||
when path=2 then
|
||||
set var3 = '1989-11-09';
|
||||
set var1 = 'flowing through case 2';
|
||||
set @count3=0;
|
||||
label2: repeat
|
||||
set count=count + 1;
|
||||
set @count2=1;
|
||||
while @count2 <= 5 do
|
||||
set @count2 = @count2 + 1;
|
||||
END while;
|
||||
SELECT @count2;
|
||||
set @count3=@count3 + @count2;
|
||||
until count > 5
|
||||
END repeat label2;
|
||||
set var2 = 'exiting out of case 2';
|
||||
set var4 = count-3;
|
||||
SELECT @count3;
|
||||
insert into res_tbl values (2, var1, var2, var3, var4);
|
||||
ELSE BEGIN
|
||||
set @error_opt='undefined path specified';
|
||||
SELECT @error_opt;
|
||||
END;
|
||||
END case;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
#Error: 1318 SQLSTATE: 42000 (ER_SP_WRONG_NO_OF_ARGS) Message: Incorrect number of arguments for %s %s; expected %u, got %u
|
||||
--error 1318
|
||||
CALL sp31330();
|
||||
|
||||
CALL sp31330(1);
|
||||
SELECT * from res_tbl;
|
||||
|
||||
CALL sp31330(2);
|
||||
SELECT * from res_tbl;
|
||||
|
||||
CALL sp31330(4);
|
||||
|
||||
# cleanup 3.1.3.30
|
||||
DROP PROCEDURE sp31330;
|
||||
drop table res_tbl;
|
||||
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# USE the same .inc to cleanup before and after the test
|
||||
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
let $message= . +++ END OF SCRIPT +++;
|
||||
--source include/show_msg80.inc
|
||||
# ==============================================================================
|
452
mysql-test/suite/funcs_1/storedproc/storedproc_06.inc
Normal file
452
mysql-test/suite/funcs_1/storedproc/storedproc_06.inc
Normal file
@ -0,0 +1,452 @@
|
||||
#### suite/funcs_1/storedproc/storedproc_06.inc
|
||||
#
|
||||
--source suite/funcs_1/storedproc/load_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
# (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00)
|
||||
#
|
||||
# 3.1.6 Privilege checks:
|
||||
#
|
||||
# 1. Ensure that no user may create a stored procedure without the GRANT CREATE ROUTINE privilege.
|
||||
# 2. Ensure that root always has the GRANT CREATE ROUTINE privilege.
|
||||
# 3. Ensure that a user with the GRANT CREATE ROUTINE privilege can always create both a procedure and a function, on any appropriate database.
|
||||
# 4. Ensure that the default security provision of a stored procedure is SQL SECURITY DEFINER.
|
||||
# 5. Ensure that a stored procedure defined with SQL SECURITY DEFINER can be called/executed by any user, using only the privileges (including database access privileges) associated with the user who created the stored procedure.
|
||||
# 6. Ensure that a stored procedure defined with SQL SECURITY INVOKER can be called/executed by any user, using only the privileges (including database access privileges) associated with the user executing the stored procedure.
|
||||
#
|
||||
# ==============================================================================
|
||||
let $message= Section 3.1.6 - Privilege Checks:;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
USE db_storedproc_1;
|
||||
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.6.1:
|
||||
-----------------
|
||||
Ensure that no user may create a stored procedure without the GRANT CREATE
|
||||
ROUTINE privilege.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
create user 'user_1'@'localhost';
|
||||
|
||||
grant all on db_storedproc_1.* to 'user_1'@'localhost';
|
||||
revoke create routine on db_storedproc_1.* from 'user_1'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp1;
|
||||
--enable_warnings
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user1a, localhost, user_1, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
USE db_storedproc_1;
|
||||
|
||||
delimiter //;
|
||||
--error 1044
|
||||
CREATE PROCEDURE sp1(v1 char(20))
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
disconnect user1a;
|
||||
|
||||
# add privilege again and check
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
GRANT CREATE ROUTINE ON db_storedproc_1.* TO 'user_1'@'localhost';
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user1b, localhost, user_1, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
USE db_storedproc_1;
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp1(v1 char(20))
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
|
||||
END//
|
||||
delimiter ;//
|
||||
disconnect user1b;
|
||||
|
||||
# cleanup
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
DROP USER 'user_1'@'localhost';
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.6.2:
|
||||
-----------------
|
||||
Ensure that root always has the GRANT CREATE ROUTINE privilege.
|
||||
(checked by other testscases);
|
||||
--source include/show_msg80.inc
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.6.3:
|
||||
-----------------
|
||||
Ensure that a user with the GRANT CREATE ROUTINE privilege can always create
|
||||
both a procedure and a function, on any appropriate database.
|
||||
--source include/show_msg80.inc
|
||||
|
||||
|
||||
create user 'user_1'@'localhost';
|
||||
|
||||
grant create routine on db_storedproc_1.* to 'user_1'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
# disconnect default;
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user2, localhost, user_1, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp3;
|
||||
DROP FUNCTION IF EXISTS fn1;
|
||||
--enable_warnings
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp3(v1 char(20))
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
delimiter //;
|
||||
CREATE FUNCTION fn1(v1 int) returns int
|
||||
BEGIN
|
||||
return v1;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
disconnect user2;
|
||||
|
||||
# cleanup
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
drop user 'user_1'@'localhost';
|
||||
DROP PROCEDURE sp3;
|
||||
DROP FUNCTION fn1;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.6.4:
|
||||
-----------------
|
||||
Ensure that the default security provision of a stored procedure is SQL SECURITY
|
||||
DEFINER.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
CREATE USER 'user_1'@'localhost';
|
||||
|
||||
grant update on db_storedproc_1.t6 to 'user_1'@'localhost';
|
||||
grant execute on db_storedproc_1.* to 'user_1'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
USE db_storedproc_1;
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp4;
|
||||
--enable_warnings
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp4(v1 char(20))
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t6 where t6.f2= 'xyz';
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
#disconnect default;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user3, localhost, user_1, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
USE db_storedproc_1;
|
||||
CALL sp4('a');
|
||||
|
||||
--vertical_results
|
||||
SELECT SPECIFIC_NAME, ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE,
|
||||
ROUTINE_BODY, ROUTINE_DEFINITION, IS_DETERMINISTIC,
|
||||
SQL_DATA_ACCESS, SECURITY_TYPE, SQL_MODE, ROUTINE_COMMENT
|
||||
FROM information_schema.routines
|
||||
WHERE routine_schema LIKE 'db_sto%';
|
||||
--horizontal_results
|
||||
|
||||
disconnect user3;
|
||||
|
||||
# cleanup
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
DROP PROCEDURE sp4;
|
||||
DROP USER 'user_1'@'localhost';
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.6.5:
|
||||
-----------------
|
||||
Ensure that a stored procedure defined with SQL SECURITY DEFINER can be
|
||||
called/executed by any user, using only the privileges (including database
|
||||
access privileges) associated with the user who created the stored procedure.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
USE db_storedproc_1;
|
||||
CREATE TABLE t3165 ( c1 char(20), c2 char(20), c3 date);
|
||||
INSERT INTO t3165 VALUES ('inserted', 'outside of SP', NULL);
|
||||
|
||||
# creates procedures
|
||||
create user 'user_1'@'localhost';
|
||||
|
||||
#executes procedure
|
||||
create user 'user_2'@'localhost';
|
||||
|
||||
grant create routine on db_storedproc_1.* to 'user_1'@'localhost';
|
||||
grant SELECT on db_storedproc_1.* to 'user_2'@'localhost';
|
||||
grant execute on db_storedproc_1.* to 'user_2'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user5_1, localhost, user_1, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp5_s_i () sql security definer
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t3165;
|
||||
insert into db_storedproc_1.t3165 values ('inserted', 'from sp5_s_i', 1000);
|
||||
END//
|
||||
|
||||
CREATE PROCEDURE sp5_sel () sql security definer
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t3165;
|
||||
END//
|
||||
|
||||
CREATE PROCEDURE sp5_ins () sql security definer
|
||||
BEGIN
|
||||
insert into db_storedproc_1.t3165 values ('inserted', 'from sp5_ins', 1000);
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
disconnect user5_1;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user5_2, localhost, user_2, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
--error 1142
|
||||
CALL sp5_s_i();
|
||||
--error 1142
|
||||
CALL sp5_ins();
|
||||
--error 1142
|
||||
CALL sp5_sel();
|
||||
|
||||
# now 'add' INSERT to DEFINER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1142
|
||||
CALL sp5_sel();
|
||||
grant insert on db_storedproc_1.* to 'user_1'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
connection user5_2;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1142
|
||||
CALL sp5_s_i();
|
||||
CALL sp5_ins();
|
||||
--error 1142
|
||||
CALL sp5_sel();
|
||||
|
||||
# now 'add' SELECT to DEFINER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1142
|
||||
CALL sp5_sel();
|
||||
grant SELECT on db_storedproc_1.* to 'user_1'@'localhost';
|
||||
#grant execute on db_storedproc_1.* to 'user_2'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
connection user5_2;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
CALL sp5_s_i();
|
||||
CALL sp5_ins();
|
||||
CALL sp5_sel();
|
||||
|
||||
# now revoke INSERT FROM DEFINER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
REVOKE INSERT on db_storedproc_1.* from 'user_1'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
connection user5_2;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1142
|
||||
CALL sp5_s_i();
|
||||
--error 1142
|
||||
CALL sp5_ins();
|
||||
CALL sp5_sel();
|
||||
|
||||
# now revoke SELECT FROM DEFINER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
REVOKE SELECT on db_storedproc_1.* from 'user_1'@'localhost';
|
||||
flush privileges;
|
||||
|
||||
connection user5_2;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1142
|
||||
CALL sp5_s_i();
|
||||
--error 1142
|
||||
CALL sp5_ins();
|
||||
--error 1142
|
||||
CALL sp5_sel();
|
||||
|
||||
# cleanup
|
||||
disconnect user5_2;
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
DROP PROCEDURE sp5_s_i;
|
||||
DROP PROCEDURE sp5_sel;
|
||||
DROP PROCEDURE sp5_ins;
|
||||
DROP TABLE t3165;
|
||||
DROP USER 'user_1'@'localhost';
|
||||
DROP USER 'user_2'@'localhost';
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.6.6:
|
||||
-----------------
|
||||
Ensure that a stored procedure defined with SQL SECURITY INVOKER can be
|
||||
called/executed by any user, using only the privileges (including database
|
||||
access privileges) associated with the user executing the stored procedure.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
USE db_storedproc_1;
|
||||
CREATE TABLE t3166 ( c1 char(30) );
|
||||
INSERT INTO db_storedproc_1.t3166 VALUES ('inserted outside SP');
|
||||
|
||||
# DEFINER
|
||||
create user 'user_1'@'localhost';
|
||||
|
||||
# INVOKER
|
||||
create user 'user_2'@'localhost';
|
||||
|
||||
GRANT CREATE ROUTINE ON db_storedproc_1.* TO 'user_1'@'localhost';
|
||||
GRANT SELECT ON db_storedproc_1.* TO 'user_2'@'localhost';
|
||||
GRANT EXECUTE ON db_storedproc_1.* TO 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user6_1, localhost, user_1, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp3166_s_i () SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t3166;
|
||||
insert into db_storedproc_1.t3166 values ('inserted from sp3166_s_i');
|
||||
END//
|
||||
|
||||
CREATE PROCEDURE sp3166_sel () SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
SELECT * from db_storedproc_1.t3166;
|
||||
END//
|
||||
|
||||
CREATE PROCEDURE sp3166_ins () SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
insert into db_storedproc_1.t3166 values ('inserted from sp3166_ins');
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
disconnect user6_1;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user6_2, localhost, user_2, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
--error 1142
|
||||
CALL sp3166_s_i();
|
||||
--error 1142
|
||||
CALL sp3166_ins();
|
||||
CALL sp3166_sel();
|
||||
|
||||
# now 'add' INSERT to INVOKER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
CALL sp3166_sel();
|
||||
GRANT INSERT ON db_storedproc_1.* TO 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
disconnect user6_2;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user6_3, localhost, user_2, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
CALL sp3166_s_i();
|
||||
CALL sp3166_ins();
|
||||
CALL sp3166_sel();
|
||||
disconnect user6_3;
|
||||
|
||||
# now 'remove' SELECT from INVOKER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
CALL sp3166_sel();
|
||||
REVOKE SELECT ON db_storedproc_1.* FROM 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user6_4, localhost, user_2, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1142
|
||||
CALL sp3166_s_i();
|
||||
CALL sp3166_ins();
|
||||
--error 1142
|
||||
CALL sp3166_sel();
|
||||
disconnect user6_4;
|
||||
|
||||
# now 'remove' EXECUTE FROM INVOKER
|
||||
connection default;
|
||||
CALL sp3166_s_i();
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
REVOKE EXECUTE on db_storedproc_1.* FROM 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user6_5, localhost, user_2, , db_storedproc_1);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
--error 1370
|
||||
CALL sp3166_s_i();
|
||||
--error 1370
|
||||
CALL sp3166_ins();
|
||||
--error 1370
|
||||
CALL sp3166_sel();
|
||||
disconnect user6_5;
|
||||
|
||||
# cleanup
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
DROP PROCEDURE sp3166_s_i;
|
||||
DROP PROCEDURE sp3166_sel;
|
||||
DROP PROCEDURE sp3166_ins;
|
||||
DROP TABLE t3166;
|
||||
DROP USER 'user_1'@'localhost';
|
||||
DROP USER 'user_2'@'localhost';
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# USE the same .inc to cleanup before and after the test
|
||||
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
let $message= . +++ END OF SCRIPT +++;
|
||||
--source include/show_msg80.inc
|
||||
# ==============================================================================
|
118
mysql-test/suite/funcs_1/storedproc/storedproc_07.inc
Normal file
118
mysql-test/suite/funcs_1/storedproc/storedproc_07.inc
Normal file
@ -0,0 +1,118 @@
|
||||
#### suite/funcs_1/storedproc/storedproc_07.inc
|
||||
#
|
||||
--source suite/funcs_1/storedproc/load_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
# (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00)
|
||||
#
|
||||
# 3.1.7 SQL mode checks:
|
||||
#
|
||||
# 1. Ensure that the sql_mode setting in effect at the time a stored procedure is created is the same setting under which the stored procedure runs when it is called/executed.
|
||||
# 2. Ensure that if the sql_mode setting is changed when a stored procedure is run, that the original setting is restored as soon as the stored procedure execution is complete.
|
||||
#
|
||||
# ==============================================================================
|
||||
let $message= Section 3.1.7 - SQL mode checks:;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
USE db_storedproc;
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.7.1:
|
||||
-----------------
|
||||
Ensure that the sql_mode setting in effect at the time a stored procedure is
|
||||
created is the same setting under which the stored procedure runs when it is
|
||||
called/executed.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp1;
|
||||
DROP TABLE IF EXISTS temp_tbl;
|
||||
DROP TABLE IF EXISTS result;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE temp_tbl (f1 tinyint);
|
||||
CREATE TABLE result (f1 text(200), f2 char(20));
|
||||
|
||||
set @@sql_mode='traditional';
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp1()
|
||||
BEGIN
|
||||
declare a tinyint;
|
||||
declare count_ int default 1;
|
||||
declare continue handler for sqlstate '22003' set count_=1000;
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
SELECT @@sql_mode into @cur_val_sql_mode;
|
||||
insert into temp_tbl values (1000);
|
||||
if count_ = 1000 THEN
|
||||
INSERT INTO result VALUES (@cur_val_sql_mode, 'value restored');
|
||||
ELSE
|
||||
INSERT INTO result VALUES (@cur_val_sql_mode, 'value not restored');
|
||||
END if;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
SHOW CREATE PROCEDURE sp1;
|
||||
|
||||
set @@sql_mode='';
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
|
||||
CALL sp1();
|
||||
SELECT * from result;
|
||||
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
SELECT @@sql_mode;
|
||||
|
||||
# cleanup
|
||||
SET @@sql_mode='TRADITIONAL';
|
||||
DROP PROCEDURE sp1;
|
||||
DROP TABLE temp_tbl;
|
||||
DROP TABLE result;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.7.2:
|
||||
-----------------
|
||||
Ensure that if the sql_mode setting is changed when a stored procedure is run,
|
||||
that the original setting is restored as soon as the stored procedure execution
|
||||
is complete.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp2;
|
||||
--enable_warnings
|
||||
|
||||
--echo ... show initial value
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp2()
|
||||
BEGIN
|
||||
SET @@sql_mode='MAXDB';
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
SHOW CREATE PROCEDURE sp2;
|
||||
--echo ... show value prior calling procedure
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
|
||||
--echo ... call procedure that changes sql_mode
|
||||
CALL sp2();
|
||||
|
||||
--echo ... check whether old value is re-set
|
||||
SHOW VARIABLES LIKE 'sql_mode';
|
||||
|
||||
# cleanup
|
||||
DROP PROCEDURE sp2;
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# USE the same .inc to cleanup before and after the test
|
||||
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
let $message= . +++ END OF SCRIPT +++;
|
||||
--source include/show_msg80.inc
|
||||
# ==============================================================================
|
118
mysql-test/suite/funcs_1/storedproc/storedproc_08.inc
Normal file
118
mysql-test/suite/funcs_1/storedproc/storedproc_08.inc
Normal file
@ -0,0 +1,118 @@
|
||||
#### suite/funcs_1/storedproc/storedproc_08.inc
|
||||
#
|
||||
--source suite/funcs_1/storedproc/load_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
# (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00)
|
||||
#
|
||||
# 3.1.8 SHOW statement checks:
|
||||
#
|
||||
#- 1. Ensure that the definition of a procedure is properly recorded and displayed when a SHOW CREATE PROCEDURE or SHOW CREATE PROCEDURE STATUS statement is executed.
|
||||
#- 2. Ensure that the definition of a procedure is not displayed when a SHOW CREATE FUNCTION or SHOW CREATE FUNCTION STATUS statement is executed.
|
||||
#- 3. Ensure that an attempt to execute SHOW CREATE PROCEDURE or SHOW CREATE PROCEDURE STATUS, with the name of a non-existent procedure, fails with an appropriate error message.
|
||||
#- 4. Ensure that an attempt to execute SHOW CREATE PROCEDURE or SHOW CREATE PROCEDURE STATUS, with the name of a function, fails with an appropriate error message.
|
||||
#- 5. Ensure that the definition of a function is properly recorded and displayed when a SHOW CREATE FUNCTION or SHOW CREATE FUNCTION STATUS statement is executed.
|
||||
#- 6. Ensure that the definition of a function is not displayed when a SHOW CREATE PROCEDURE or SHOW CREATE PROCEDURE STATUS statement is executed.
|
||||
#- 7. Ensure that an attempt to execute SHOW CREATE FUNCTION or SHOW CREATE FUNCTION STATUS, with the name of a non-existent function, fails with an appropriate error message.
|
||||
#- 8. Ensure that an attempt to execute SHOW CREATE FUNCTION or SHOW CREATE FUNCTION STATUS, with the name of a procedure, fails with an appropriate error message.
|
||||
## 9. Ensure that all stored procedure changes made with ALTER PROCEDURE or ALTER FUNCTION are properly recorded and displayed when a SHOW CREATE PROCEDURE or SHOW CREATE PROCEDURE STATUS statement, or a SHOW CREATE FUNCTION or SHOW CREATE FUNCTION STATUS statement (respectively) is executed.
|
||||
#- 10. Ensure that, when a stored procedure is dropped, its definition no longer appears when a SHOW CREATE PROCEDURE or SHOW CREATE PROCEDURE STATUS statement, or a SHOW CREATE FUNCTION or SHOW CREATE FUNCTION STATUS statement (respectively) is executed.
|
||||
#
|
||||
# ==============================================================================
|
||||
let $message= Section 3.1.8 - SHOW statement checks:;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.8.9:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that all stored procedure changes made with ALTER PROCEDURE or ALTER
|
||||
FUNCTION are properly recorded and displayed when a SHOW CREATE PROCEDURE or
|
||||
SHOW CREATE PROCEDURE STATUS statement, or a SHOW CREATE FUNCTION or SHOW CREATE
|
||||
FUNCTION STATUS statement (respectively) is executed.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP FUNCTION IF EXISTS fn_1;
|
||||
DROP FUNCTION IF EXISTS fn_2;
|
||||
DROP PROCEDURE IF EXISTS sp_1;
|
||||
DROP PROCEDURE IF EXISTS sp_2;
|
||||
--enable_warnings
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp_1 (i1 int)
|
||||
BEGIN
|
||||
set @x=i1;
|
||||
END//
|
||||
|
||||
CREATE PROCEDURE sp_2 (i1 int) SQL SECURITY INVOKER COMMENT 'created with INVOKER'
|
||||
BEGIN
|
||||
set @x=i1;
|
||||
END//
|
||||
|
||||
CREATE FUNCTION fn_1 (i1 longtext, i2 mediumint , i3 longblob, i4 year, i5 real) returns year
|
||||
BEGIN
|
||||
set @x=i1;
|
||||
set @y=@x;
|
||||
return i4;
|
||||
END//
|
||||
|
||||
CREATE FUNCTION fn_2 (i1 longtext, i2 mediumint , i3 longblob, i4 year, i5 real)
|
||||
RETURNS YEAR
|
||||
SQL SECURITY INVOKER
|
||||
COMMENT 'created with INVOKER'
|
||||
BEGIN
|
||||
set @x=i1;
|
||||
set @y=@x;
|
||||
return i4;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
--source suite/funcs_1/storedproc/storedproc_08_show.inc
|
||||
|
||||
let $message= ... now change some stuff:;
|
||||
--source include/show_msg.inc
|
||||
# some of the changes might be 'strange' here, but they are used here ONLY to
|
||||
# check that the changes are recorded / showd correct
|
||||
ALTER PROCEDURE sp_1 SQL SECURITY INVOKER;
|
||||
ALTER PROCEDURE sp_1 COMMENT 'new comment, SP changed to INVOKER';
|
||||
|
||||
ALTER PROCEDURE sp_2 SQL SECURITY DEFINER;
|
||||
ALTER PROCEDURE sp_2 DROP COMMENT;
|
||||
ALTER PROCEDURE sp_2 COMMENT 'SP changed to DEFINER';
|
||||
ALTER PROCEDURE sp_2 READS SQL DATA;
|
||||
|
||||
ALTER FUNCTION fn_1 SQL SECURITY INVOKER;
|
||||
ALTER FUNCTION fn_1 COMMENT 'new comment, FN changed to INVOKER';
|
||||
ALTER FUNCTION fn_1 NO SQL;
|
||||
|
||||
ALTER FUNCTION fn_2 SQL SECURITY DEFINER;
|
||||
ALTER FUNCTION fn_2 COMMENT 'FN changed to DEFINER';
|
||||
ALTER FUNCTION fn_2 MODIFIES SQL DATA;
|
||||
|
||||
--source suite/funcs_1/storedproc/storedproc_08_show.inc
|
||||
|
||||
|
||||
let $message= ... change back to default and check result:;
|
||||
--source include/show_msg.inc
|
||||
ALTER FUNCTION fn_2 CONTAINS SQL;
|
||||
--source suite/funcs_1/storedproc/storedproc_08_show.inc
|
||||
|
||||
|
||||
# cleanup 3.1.8.9
|
||||
let $message= ... cleanup;
|
||||
--source include/show_msg.inc
|
||||
DROP FUNCTION fn_1;
|
||||
DROP FUNCTION fn_2;
|
||||
DROP PROCEDURE sp_1;
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# USE the same .inc to cleanup before and after the test
|
||||
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
let $message= . +++ END OF SCRIPT +++;
|
||||
--source include/show_msg80.inc
|
||||
# ==============================================================================
|
30
mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc
Normal file
30
mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc
Normal file
@ -0,0 +1,30 @@
|
||||
#### suite/funcs_1/storedproc/storedproc_08_show.inc
|
||||
#
|
||||
# used from .../storedproc_08.inc to show all created / altered routines
|
||||
|
||||
let $message= ... now check what is stored:;
|
||||
--source include/show_msg.inc
|
||||
|
||||
--vertical_results
|
||||
|
||||
#--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
|
||||
|
||||
--replace_column 16 <modified> 17 <created>
|
||||
SELECT * FROM information_schema.routines;
|
||||
|
||||
|
||||
SHOW CREATE FUNCTION fn_1;
|
||||
SHOW CREATE FUNCTION fn_2;
|
||||
#SHOW CREATE FUNCTION fn_2b;
|
||||
|
||||
SHOW CREATE PROCEDURE sp_1;
|
||||
SHOW CREATE PROCEDURE sp_2;
|
||||
|
||||
|
||||
--replace_column 5 <modified> 6 <created>
|
||||
SHOW FUNCTION STATUS LIKE 'fn_%';
|
||||
|
||||
--replace_column 5 <modified> 6 <created>
|
||||
SHOW PROCEDURE STATUS LIKE 'sp_%';
|
||||
|
||||
--horizontal_results
|
288
mysql-test/suite/funcs_1/storedproc/storedproc_10.inc
Normal file
288
mysql-test/suite/funcs_1/storedproc/storedproc_10.inc
Normal file
@ -0,0 +1,288 @@
|
||||
#### suite/funcs_1/storedproc/storedproc_10.inc
|
||||
#
|
||||
--source suite/funcs_1/storedproc/load_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
# (numbering from requirement document TP v1.0, Last updated: 25 Jan 2005 01:00)
|
||||
#
|
||||
# 3.1.10 CALL checks:
|
||||
#
|
||||
## 1. Ensure that a properly defined procedure can always be called, assuming the appropriate privileges exist.
|
||||
#- 2. Ensure that a procedure cannot be called if the appropriate privileges do not exist.
|
||||
## 3. Ensure that a function can never be called.
|
||||
## 4. Ensure that a properly defined function can always be executed, assuming the appropriate privileges exist.
|
||||
#- 5. Ensure that a function cannot be executed if the appropriate privileges do not exist.
|
||||
## 6. Ensure that a procedure can never be executed.
|
||||
## 7. Ensure that the ROW_COUNT() SQL function always returns the correct number of rows affected by the execution of a stored procedure.
|
||||
## 8. Ensure that the mysql_affected_rows() C API function always returns the correct number of rows affected by the execution of a stored procedure.
|
||||
#
|
||||
# ==============================================================================
|
||||
let $message= Section 3.1.10 - CALL checks:;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
|
||||
USE db_storedproc;
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.10.2 + 3.1.10.5:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
2. Ensure that a procedure cannot be called if the appropriate privileges do not
|
||||
exist.
|
||||
5. Ensure that a function cannot be executed if the appropriate privileges do
|
||||
not exist.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp31102;
|
||||
DROP FUNCTION IF EXISTS fn31105;
|
||||
--enable_warnings
|
||||
|
||||
# DEFINER
|
||||
create user 'user_1'@'localhost';
|
||||
# INVOKER
|
||||
create user 'user_2'@'localhost';
|
||||
|
||||
GRANT CREATE ROUTINE ON db_storedproc.* TO 'user_1'@'localhost';
|
||||
GRANT SELECT ON db_storedproc.* TO 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user2_1, localhost, user_1, , db_storedproc);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp31102 () SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
SELECT * FROM db_storedproc.t1 WHERE f4=-5000 LIMIT 1;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
delimiter //;
|
||||
CREATE FUNCTION fn31105(n INT) RETURNS INT
|
||||
BEGIN
|
||||
DECLARE res INT;
|
||||
SET res = n * n;
|
||||
RETURN res;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
disconnect user2_1;
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user2_2, localhost, user_2, , db_storedproc);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
|
||||
# no privileges exist
|
||||
--error 1370
|
||||
CALL sp31102();
|
||||
SELECT fn31105( 9 );
|
||||
|
||||
# now 'add' EXECUTE to INVOKER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
# root can execute ...
|
||||
CALL sp31102();
|
||||
SELECT fn31105( 9 );
|
||||
GRANT EXECUTE ON db_storedproc.* TO 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
disconnect user2_2;
|
||||
|
||||
# new connection
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user2_3, localhost, user_2, , db_storedproc);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
CALL sp31102();
|
||||
SELECT fn31105( 9 );
|
||||
disconnect user2_3;
|
||||
|
||||
# now 'remove' SELECT from INVOKER
|
||||
connection default;
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
REVOKE EXECUTE ON db_storedproc.* FROM 'user_2'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
# root can still execute
|
||||
CALL sp31102();
|
||||
SELECT fn31105( 9 );
|
||||
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (user2_4, localhost, user_2, , db_storedproc);
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
CALL sp31102();
|
||||
SELECT fn31105( 9 );
|
||||
disconnect user2_4;
|
||||
|
||||
# cleanup
|
||||
connection default;
|
||||
|
||||
--source suite/funcs_1/include/show_connection.inc
|
||||
DROP PROCEDURE sp31102;
|
||||
DROP FUNCTION fn31105;
|
||||
DROP USER 'user_1'@'localhost';
|
||||
DROP USER 'user_2'@'localhost';
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.10.3:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that a function can never be called.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP FUNCTION IF EXISTS fn1;
|
||||
--enable_warnings
|
||||
|
||||
delimiter //;
|
||||
CREATE FUNCTION fn1(a int) returns int
|
||||
BEGIN
|
||||
set @b = 0.9 * a;
|
||||
return @b;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
--error 1305
|
||||
CALL fn1();
|
||||
|
||||
# cleanup
|
||||
DROP FUNCTION fn1;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.10.6:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that a procedure can never be executed.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp1;
|
||||
DROP FUNCTION IF EXISTS sp1;
|
||||
--enable_warnings
|
||||
|
||||
delimiter //;
|
||||
CREATE PROCEDURE sp1()
|
||||
BEGIN
|
||||
SELECT * from t10;
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
--error 1305
|
||||
SELECT sp1();
|
||||
|
||||
# cleanup
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.10.7:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the ROW_COUNT() SQL function always returns the correct number of
|
||||
rows affected by the execution of a stored procedure.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS sp_ins_1;
|
||||
DROP PROCEDURE IF EXISTS sp_ins_3;
|
||||
DROP PROCEDURE IF EXISTS sp_upd;
|
||||
DROP PROCEDURE IF EXISTS sp_ins_upd;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE temp(f1 CHAR(20),f2 CHAR(25),f3 DATE,f4 INT,f5 CHAR(25),f6 INT);
|
||||
INSERT INTO temp SELECT * FROM t10;
|
||||
|
||||
delimiter //;
|
||||
#FIXME: add to proc: SELECT row_count() 'ins';
|
||||
CREATE PROCEDURE sp_ins_1()
|
||||
BEGIN
|
||||
INSERT INTO temp VALUES ('abc', 'abc', '20051003', 100, 'uvw', 1000);
|
||||
END//
|
||||
|
||||
|
||||
#FIXME: add to proc: SELECT row_count() 'ins_3';
|
||||
CREATE PROCEDURE sp_ins_3()
|
||||
BEGIN
|
||||
INSERT INTO temp VALUES ('abc', 'xyz', '19490523', 100, 'uvw', 1000);
|
||||
INSERT INTO temp VALUES ('abc', 'xyz', '1989-11-09', 100, 'uvw', 1000);
|
||||
INSERT INTO temp VALUES ('abc', 'xyz', '2005-10-24', 100, 'uvw', 1000);
|
||||
END//
|
||||
|
||||
# FIXME: add to proc: SELECT row_count() AS 'updated';
|
||||
CREATE PROCEDURE sp_upd()
|
||||
BEGIN
|
||||
UPDATE temp SET temp.f1 = 'updated' WHERE temp.f1 ='abc';
|
||||
END//
|
||||
|
||||
# FIXME: use commented proc
|
||||
# CREATE PROCEDURE sp_ins_upd()
|
||||
# BEGIN
|
||||
# BEGIN
|
||||
# INSERT INTO temp VALUES ('qwe', 'abc', '1989-11-09', 100, 'uvw', 1000);
|
||||
# INSERT INTO temp VALUES ('qwe', 'xyz', '1998-03-26', 100, 'uvw', 1000);
|
||||
# INSERT INTO temp VALUES ('qwe', 'abc', '2000-11-09', 100, 'uvw', 1000);
|
||||
# INSERT INTO temp VALUES ('qwe', 'abc', '2005-11-07', 100, 'uvw', 1000);
|
||||
# END;
|
||||
# SELECT row_count() AS 'insert "qwe"';
|
||||
# SELECT COUNT( f1 ), f1 FROM temp GROUP BY f1;
|
||||
# UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f1 ='qwe' AND temp.f2 = 'abc';
|
||||
# SELECT row_count() AS 'update "qwe" AND "abc"';
|
||||
# END//
|
||||
CREATE PROCEDURE sp_ins_upd()
|
||||
BEGIN
|
||||
BEGIN
|
||||
INSERT INTO temp VALUES ('qwe', 'abc', '1989-11-09', 100, 'uvw', 1000);
|
||||
INSERT INTO temp VALUES ('qwe', 'xyz', '1998-03-26', 100, 'uvw', 1000);
|
||||
INSERT INTO temp VALUES ('qwe', 'abc', '2000-11-09', 100, 'uvw', 1000);
|
||||
INSERT INTO temp VALUES ('qwe', 'abc', '2005-11-07', 100, 'uvw', 1000);
|
||||
END;
|
||||
SELECT COUNT( f1 ), f1 FROM temp GROUP BY f1;
|
||||
UPDATE temp SET temp.f1 = 'updated_2' WHERE temp.f1 ='qwe' AND temp.f2 = 'abc';
|
||||
END//
|
||||
delimiter ;//
|
||||
|
||||
CALL sp_ins_1();
|
||||
SELECT row_count();
|
||||
SELECT * FROM temp ORDER BY f4;
|
||||
|
||||
CALL sp_ins_3();
|
||||
#FIXME: check is 1 correct here? I expect 3 for 3 inserted rows inside the procedure
|
||||
SELECT row_count();
|
||||
SELECT * FROM temp ORDER BY f4;
|
||||
|
||||
CALL sp_upd();
|
||||
SELECT row_count();
|
||||
SELECT * FROM temp ORDER BY f4;
|
||||
|
||||
#FIXME: check is 3 correct here? I expect 7 for 4 inserted and then 3 updated rows inside the procedure
|
||||
CALL sp_ins_upd();
|
||||
SELECT row_count();
|
||||
SELECT * FROM temp ORDER BY f4;
|
||||
|
||||
# cleanup
|
||||
DROP PROCEDURE sp_ins_1;
|
||||
DROP PROCEDURE sp_ins_3;
|
||||
DROP PROCEDURE sp_upd;
|
||||
DROP PROCEDURE sp_ins_upd;
|
||||
DROP TABLE temp;
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
let $message= Testcase 3.1.10.8:;
|
||||
--source include/show_msg.inc
|
||||
let $message=
|
||||
Ensure that the mysql_affected_rows() C API function always returns the correct
|
||||
number of rows affected by the execution of a stored procedure.;
|
||||
--source include/show_msg80.inc
|
||||
|
||||
#FIXME: 3.1.10.8: to be added later.
|
||||
|
||||
# ==============================================================================
|
||||
# USE the same .inc to cleanup before and after the test
|
||||
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc
|
||||
|
||||
# ==============================================================================
|
||||
let $message= . +++ END OF SCRIPT +++;
|
||||
--source include/show_msg80.inc
|
||||
# ==============================================================================
|
29343
mysql-test/suite/funcs_1/storedproc/storedproc_master.inc
Normal file
29343
mysql-test/suite/funcs_1/storedproc/storedproc_master.inc
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user