mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Results of WL#1856 "Conversion of client_test.c tests cases to mysqltest
if possible" - many new test cases - more and improved comments New files: t/ps_7ndb.test test suite for NDB tables r/ps_7ndb.result expected results include/ps_conv.inc conversion test cases + review comments and fixes. mysql-test/include/ps_create.inc: Rename of t_many_col_types -> t9 mysql-test/include/ps_modify.inc: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Rename: t_many_col_types -> t9 Cleanups and comments. New test cases (derived from client_test.c) mysql-test/include/ps_modify1.inc: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Rename: t_many_col_types -> t9 Cleanups and comments. New test cases (derived from client_test.c) mysql-test/include/ps_query.inc: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Rename: t_many_col_types -> t9 Cleanups and comments. New test cases (derived from client_test.c) mysql-test/include/ps_renew.inc: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Rename: t_many_col_types -> t9 mysql-test/r/ps_1general.result: Results updated. mysql-test/r/ps_2myisam.result: Resutls updated. mysql-test/r/ps_3innodb.result: Results updated. mysql-test/r/ps_4heap.result: Results updated. mysql-test/r/ps_5merge.result: Results updated. mysql-test/r/ps_6bdb.result: Results updated. mysql-test/t/ps_1general.test: WL#1856 "Conversion of client_test.c tests cases to mysqltest if possible": new test cases added. mysql-test/t/ps_2myisam.test: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Call of file include/ps_conv.inc (with new test cases) and fulltext test case added. mysql-test/t/ps_3innodb.test: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Call of file include/ps_conv.inc (with new test cases) added. mysql-test/t/ps_4heap.test: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Call of file include/ps_conv.inc (with new test cases) added. mysql-test/t/ps_5merge.test: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible Call of file include/ps_conv.inc (with new test cases) added. mysql-test/t/ps_6bdb.test: WL#1856 Conversion of client_test.c tests cases to mysqltest if possible. Call of file include/ps_conv.inc (with new test cases) added.
This commit is contained in:
@ -14,13 +14,13 @@ select '------ basic tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
|
||||
let $type= 'MYISAM' ;
|
||||
# create the tables (t1 and t_many_col_types) used in many tests
|
||||
# create the tables (t1 and t9) used in many tests
|
||||
--source include/ps_create.inc
|
||||
# insert data into these tables
|
||||
--source include/ps_renew.inc
|
||||
|
||||
|
||||
##### The basic functions ####
|
||||
################ The basic functions ################
|
||||
|
||||
# 1. PREPARE stmt_name FROM <preparable statement>;
|
||||
# <preparable statement> ::=
|
||||
@ -54,7 +54,7 @@ select * from t1 where a = @var ;
|
||||
# The server will reply with "Query Ok" or an error message.
|
||||
DEALLOCATE PREPARE stmt ;
|
||||
|
||||
## prepare
|
||||
################ PREPARE ################
|
||||
# prepare without parameter
|
||||
prepare stmt1 from ' select 1 as my_col ' ;
|
||||
# prepare with parameter
|
||||
@ -91,9 +91,15 @@ set @arg00=NULL;
|
||||
prepare stmt1 from @arg01;
|
||||
|
||||
prepare stmt1 from ' select * from t1 where a <= 2 ' ;
|
||||
# prepare must fail (column does not exist)
|
||||
# prepare must fail (column x does not exist)
|
||||
--error 1054
|
||||
prepare stmt1 from ' select * from t1 where x <= 2 ' ;
|
||||
# cases derived from client_test.c: test_null()
|
||||
# prepare must fail (column x does not exist)
|
||||
--error 1054
|
||||
prepare stmt1 from ' insert into t1(a,x) values(?,?) ' ;
|
||||
--error 1054
|
||||
prepare stmt1 from ' insert into t1(x,a) values(?,?) ' ;
|
||||
--disable_warnings
|
||||
drop table if exists not_exist ;
|
||||
--enable_warnings
|
||||
@ -109,7 +115,7 @@ prepare stmt1 from ' insert into t1 values(? ' ;
|
||||
prepare stmt1 from ' select a, b from t1
|
||||
where a=? and where ' ;
|
||||
|
||||
## execute
|
||||
################ EXECUTE ################
|
||||
# execute must fail (statement never_prepared never prepared)
|
||||
--error 1243
|
||||
execute never_prepared ;
|
||||
@ -122,89 +128,89 @@ prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
|
||||
execute stmt1 ;
|
||||
|
||||
# drop the table between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a int primary key,
|
||||
b char(30),
|
||||
c int
|
||||
);
|
||||
insert into to_be_dropped( a, b, c) values( 1, 'original table', 1);
|
||||
prepare stmt2 from ' select * from to_be_dropped ' ;
|
||||
insert into t5( a, b, c) values( 1, 'original table', 1);
|
||||
prepare stmt2 from ' select * from t5 ' ;
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
# execute must fail (table was dropped after prepare)
|
||||
--error 1146
|
||||
execute stmt2 ;
|
||||
# cases derived from client_test.c: test_select_prepare()
|
||||
# 1. drop + create table (same column names/types/order)
|
||||
# between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a int primary key,
|
||||
b char(30),
|
||||
c int
|
||||
);
|
||||
insert into to_be_dropped( a, b, c) values( 9, 'recreated table', 9);
|
||||
insert into t5( a, b, c) values( 9, 'recreated table', 9);
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
# 2. drop + create table (same column names/types but different order)
|
||||
# between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a int primary key,
|
||||
c int,
|
||||
b char(30)
|
||||
);
|
||||
insert into to_be_dropped( a, b, c) values( 9, 'recreated table', 9);
|
||||
insert into t5( a, b, c) values( 9, 'recreated table', 9);
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
# 3. drop + create table (same column names/types/order+extra column)
|
||||
# between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a int primary key,
|
||||
b char(30),
|
||||
c int,
|
||||
d timestamp default current_timestamp
|
||||
);
|
||||
insert into to_be_dropped( a, b, c) values( 9, 'recreated table', 9);
|
||||
insert into t5( a, b, c) values( 9, 'recreated table', 9);
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
# 4. drop + create table (same column names/types, different order +
|
||||
# additional column) between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a int primary key,
|
||||
d timestamp default current_timestamp,
|
||||
b char(30),
|
||||
c int
|
||||
);
|
||||
insert into to_be_dropped( a, b, c) values( 9, 'recreated table', 9);
|
||||
insert into t5( a, b, c) values( 9, 'recreated table', 9);
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
# 5. drop + create table (same column names/order, different types)
|
||||
# between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a timestamp default '2004-02-29 18:01:59',
|
||||
b char(30),
|
||||
c int
|
||||
);
|
||||
insert into to_be_dropped( b, c) values( 'recreated table', 9);
|
||||
insert into t5( b, c) values( 'recreated table', 9);
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
# 6. drop + create table (same column types/order, different names)
|
||||
# between prepare and execute
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
f1 int primary key,
|
||||
f2 char(30),
|
||||
f3 int
|
||||
);
|
||||
insert into to_be_dropped( f1, f2, f3) values( 9, 'recreated table', 9);
|
||||
insert into t5( f1, f2, f3) values( 9, 'recreated table', 9);
|
||||
--error 1054
|
||||
execute stmt2 ;
|
||||
drop table to_be_dropped ;
|
||||
drop table t5 ;
|
||||
|
||||
# execute without parameter
|
||||
prepare stmt1 from ' select * from t1 where a <= 2 ' ;
|
||||
@ -223,8 +229,8 @@ execute stmt1 using @arg00, @arg01;
|
||||
# execute must fail (parameter is not set)
|
||||
execute stmt1 using @not_set;
|
||||
|
||||
## deallocate
|
||||
# deallocate must fail (never_prepared was never prepared)
|
||||
################ DEALLOCATE ################
|
||||
# deallocate must fail (the statement 'never_prepared' was never prepared)
|
||||
--error 1243
|
||||
deallocate prepare never_prepared ;
|
||||
# deallocate must fail (prepare stmt1 just failed,
|
||||
@ -234,13 +240,13 @@ prepare stmt1 from ' select * from t1 where a <= 2 ' ;
|
||||
prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
|
||||
--error 1243
|
||||
deallocate prepare stmt1;
|
||||
create table to_be_dropped
|
||||
create table t5
|
||||
(
|
||||
a int primary key,
|
||||
b char(10)
|
||||
);
|
||||
prepare stmt2 from ' select a,b from to_be_dropped where a <= 2 ' ;
|
||||
drop table to_be_dropped ;
|
||||
prepare stmt2 from ' select a,b from t5 where a <= 2 ' ;
|
||||
drop table t5 ;
|
||||
# deallocate prepared statement where the table was dropped after prepare
|
||||
deallocate prepare stmt2;
|
||||
|
||||
@ -271,7 +277,7 @@ create table t2
|
||||
a int primary key, b char(10)
|
||||
);
|
||||
|
||||
###### SHOW COMMANDS
|
||||
################ SHOW COMMANDS ################
|
||||
prepare stmt4 from ' show databases ';
|
||||
execute stmt4;
|
||||
prepare stmt4 from ' show tables from test like ''t2%'' ';
|
||||
@ -287,7 +293,7 @@ prepare stmt4 from ' show table status from test like ''t2%'' ';
|
||||
# Bug#4288 : prepared statement 'show table status ..', wrong output on execute
|
||||
execute stmt4;
|
||||
# try the same with the big table
|
||||
prepare stmt4 from ' show table status from test like ''t_many_col_types%'' ';
|
||||
prepare stmt4 from ' show table status from test like ''t9%'' ';
|
||||
# egalize date and time values
|
||||
--replace_column 12 # 13 # 14 #
|
||||
# Bug#4288
|
||||
@ -324,18 +330,68 @@ prepare stmt4 from ' show storage engines ';
|
||||
--replace_column 2 YES/NO
|
||||
execute stmt4;
|
||||
|
||||
###### MISC STUFF
|
||||
################ MISC STUFF ################
|
||||
## get a warning and an error
|
||||
# cases derived from client_test.c: test_warnings(), test_errors()
|
||||
--disable_warnings
|
||||
drop table if exists tx;
|
||||
drop table if exists t5;
|
||||
--enable_warnings
|
||||
prepare stmt1 from ' drop table if exists tx ' ;
|
||||
prepare stmt1 from ' drop table if exists t5 ' ;
|
||||
execute stmt1 ;
|
||||
prepare stmt1 from ' drop table tx ' ;
|
||||
prepare stmt1 from ' drop table t5 ' ;
|
||||
--error 1051
|
||||
execute stmt1 ;
|
||||
|
||||
## SELECT @@version
|
||||
# cases derived from client_test.c: test_select_version()
|
||||
--enable_metadata
|
||||
prepare stmt1 from ' SELECT @@version ' ;
|
||||
# egalize the version
|
||||
--replace_column 1 <version>
|
||||
execute stmt1 ;
|
||||
--disable_metadata
|
||||
|
||||
## do @var:= and set @var=
|
||||
# cases derived from client_test.c: test_do_set()
|
||||
prepare stmt_do from ' do @var:= (1 in (select a from t1)) ' ;
|
||||
prepare stmt_set from ' set @var= (1 in (select a from t1)) ' ;
|
||||
let $1= 3 ;
|
||||
while ($1)
|
||||
{
|
||||
execute stmt_do ;
|
||||
--disable_query_log
|
||||
select @var as 'content of @var is:' ;
|
||||
--enable_query_log
|
||||
execute stmt_set ;
|
||||
--disable_query_log
|
||||
select @var as 'content of @var is:' ;
|
||||
--enable_query_log
|
||||
dec $1 ;
|
||||
}
|
||||
# the same test with a table containing one column and 'select *'
|
||||
--disable_warnings
|
||||
drop table if exists t5 ;
|
||||
--enable_warnings
|
||||
create table t5 (a int) ;
|
||||
prepare stmt_do from ' do @var:= (1 in (select a from t5)) ' ;
|
||||
prepare stmt_set from ' set @var= (1 in (select a from t5)) ' ;
|
||||
let $1= 3 ;
|
||||
while ($1)
|
||||
{
|
||||
execute stmt_do ;
|
||||
--disable_query_log
|
||||
select @var as 'content of @var is:' ;
|
||||
--enable_query_log
|
||||
execute stmt_set ;
|
||||
--disable_query_log
|
||||
select @var as 'content of @var is:' ;
|
||||
--enable_query_log
|
||||
dec $1 ;
|
||||
}
|
||||
drop table t5 ;
|
||||
deallocate prepare stmt_do ;
|
||||
deallocate prepare stmt_set ;
|
||||
|
||||
## nonsense like prepare of prepare,execute or deallocate
|
||||
--error 1064
|
||||
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
|
||||
@ -447,6 +503,34 @@ prepare stmt1 from ' explain select a from t1 where a > ? order by b ';
|
||||
execute stmt1 using @arg00;
|
||||
--disable_metadata
|
||||
|
||||
## parameters with probably problematic characters (quote, double quote)
|
||||
# cases derived from client_test.c: test_logs()
|
||||
# try if
|
||||
--disable_warnings
|
||||
drop table if exists t2;
|
||||
--enable_warnings
|
||||
create table t2 (id smallint, name varchar(20)) ;
|
||||
prepare stmt1 from ' insert into t2 values(?, ?) ' ;
|
||||
set @id= 9876 ;
|
||||
set @arg00= 'MySQL - Open Source Database' ;
|
||||
set @arg01= "'" ;
|
||||
set @arg02= '"' ;
|
||||
set @arg03= "my'sql'" ;
|
||||
set @arg04= 'my"sql"' ;
|
||||
insert into t2 values ( @id , @arg00 );
|
||||
insert into t2 values ( @id , @arg01 );
|
||||
insert into t2 values ( @id , @arg02 );
|
||||
insert into t2 values ( @id , @arg03 );
|
||||
insert into t2 values ( @id , @arg04 );
|
||||
prepare stmt1 from ' select * from t2 where id= ? and name= ? ';
|
||||
execute stmt1 using @id, @arg00 ;
|
||||
execute stmt1 using @id, @arg01 ;
|
||||
execute stmt1 using @id, @arg02 ;
|
||||
execute stmt1 using @id, @arg03 ;
|
||||
execute stmt1 using @id, @arg04 ;
|
||||
drop table t2;
|
||||
|
||||
################ CREATE/DROP/ALTER/RENAME TESTS ################
|
||||
--disable_query_log
|
||||
select '------ create/drop/alter/rename tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
@ -455,11 +539,13 @@ select '------ create/drop/alter/rename tests ------' as test_sequence ;
|
||||
drop table if exists t2, t3;
|
||||
--enable_warnings
|
||||
|
||||
## DROP TABLE
|
||||
prepare stmt_drop from ' drop table if exists t2 ' ;
|
||||
--disable_warnings
|
||||
execute stmt_drop;
|
||||
--enable_warnings
|
||||
|
||||
## CREATE TABLE
|
||||
prepare stmt_create from ' create table t2 (
|
||||
a int primary key, b char(10)) ';
|
||||
execute stmt_create;
|
||||
@ -467,6 +553,7 @@ prepare stmt3 from ' create table t3 like t2 ';
|
||||
execute stmt3;
|
||||
drop table t3;
|
||||
|
||||
## CREATE TABLE .. SELECT
|
||||
set @arg00=1;
|
||||
prepare stmt3 from ' create table t3 (m int) select ? as m ' ;
|
||||
# Bug#4280 server hangs, prepared "create table .. as select ? .."
|
||||
@ -480,6 +567,8 @@ prepare stmt3 from ' create index t2_idx on t2(b) ';
|
||||
prepare stmt3 from ' drop index t2_idx on t2 ' ;
|
||||
--error 1295
|
||||
prepare stmt3 from ' alter table t2 drop primary key ';
|
||||
|
||||
## RENAME TABLE
|
||||
--disable_warnings
|
||||
drop table if exists new_t2;
|
||||
--enable_warnings
|
||||
@ -489,15 +578,41 @@ execute stmt3;
|
||||
execute stmt3;
|
||||
rename table new_t2 to t2;
|
||||
drop table t2;
|
||||
## RENAME more than on TABLE within one statement
|
||||
# cases derived from client_test.c: test_rename()
|
||||
--disable_warnings
|
||||
drop table if exists t5, t6, t7, t8 ;
|
||||
--enable_warnings
|
||||
prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ;
|
||||
create table t5 (a int) ;
|
||||
# rename must fail, tc does not exist
|
||||
--error 1017
|
||||
execute stmt1 ;
|
||||
create table t7 (a int) ;
|
||||
# rename, t5 -> t6 and t7 -> t8
|
||||
execute stmt1 ;
|
||||
# rename must fail, t5 and t7 does not exist t6 and t8 already exist
|
||||
--error 1050
|
||||
execute stmt1 ;
|
||||
rename table t6 to t5, t8 to t7 ;
|
||||
# rename, t5 -> t6 and t7 -> t8
|
||||
execute stmt1 ;
|
||||
drop table t6, t8 ;
|
||||
|
||||
|
||||
################ BIG STATEMENT TESTS ################
|
||||
--disable_query_log
|
||||
select '------ big statement tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
# The following tests use huge numbers of lines, characters or parameters
|
||||
# per prepared statement.
|
||||
# I assume the server and also the client (mysqltest) are stressed.
|
||||
#
|
||||
# Attention: The limits used are NOT derived from the manual
|
||||
# or other sources.
|
||||
|
||||
## many lines ( 50 )
|
||||
select 'ABC' as my_const_col from t1 where
|
||||
let $my_stmt= select 'ABC' as my_const_col from t1 where
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
@ -547,62 +662,14 @@ select 'ABC' as my_const_col from t1 where
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 ;
|
||||
prepare stmt1 from ' select ''ABC'' as my_const_col FROM t1 WHERE
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 AND
|
||||
1 = 1 ' ;
|
||||
eval ($my_stmt) ;
|
||||
eval prepare stmt1 from "$my_stmt" ;
|
||||
execute stmt1 ;
|
||||
execute stmt1 ;
|
||||
|
||||
## many characters ( about 1400 )
|
||||
|
||||
select 'ABC' as my_const_col FROM t1 WHERE
|
||||
let $my_stmt= select 'ABC' as my_const_col FROM t1 WHERE
|
||||
'1234567890123456789012345678901234567890123456789012345678901234567890'
|
||||
= '1234567890123456789012345678901234567890123456789012345678901234567890' AND
|
||||
'1234567890123456789012345678901234567890123456789012345678901234567890'
|
||||
@ -621,30 +688,14 @@ select 'ABC' as my_const_col FROM t1 WHERE
|
||||
= '1234567890123456789012345678901234567890123456789012345678901234567890' AND
|
||||
'1234567890123456789012345678901234567890123456789012345678901234567890'
|
||||
= '1234567890123456789012345678901234567890123456789012345678901234567890' ;
|
||||
prepare stmt1 from ' select ''ABC'' as my_const_col FROM t1 WHERE
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' AND
|
||||
''1234567890123456789012345678901234567890123456789012345678901234567890''
|
||||
= ''1234567890123456789012345678901234567890123456789012345678901234567890'' ';
|
||||
eval ($my_stmt) ;
|
||||
eval prepare stmt1 from "$my_stmt" ;
|
||||
execute stmt1 ;
|
||||
execute stmt1 ;
|
||||
|
||||
|
||||
## many parameters ( 50 )
|
||||
--disable_query_log
|
||||
set @arg00= 1;
|
||||
set @arg01= 1;
|
||||
set @arg02= 1;
|
||||
@ -695,6 +746,7 @@ set @arg56= 1;
|
||||
set @arg57= 1;
|
||||
set @arg60= 1;
|
||||
set @arg61= 1;
|
||||
--enable_query_log
|
||||
|
||||
select 'ABC' as my_const_col FROM t1 WHERE
|
||||
@arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
|
||||
@ -729,8 +781,156 @@ execute stmt1 using
|
||||
@arg50, @arg51, @arg52, @arg53, @arg54, @arg55, @arg56, @arg57,
|
||||
@arg60, @arg61 ;
|
||||
|
||||
# cases derived from client_test.c: test_mem_overun()
|
||||
--disable_warnings
|
||||
drop table if exists t5 ;
|
||||
--enable_warnings
|
||||
|
||||
set @col_num= 1000 ;
|
||||
|
||||
--disable_query_log
|
||||
set @string= 'create table t5( ' ;
|
||||
let $1=`select @col_num - 1` ;
|
||||
while ($1)
|
||||
{
|
||||
eval set @string= concat(@string, 'c$1 int,') ;
|
||||
dec $1 ;
|
||||
}
|
||||
set @string= concat(@string, 'c0 int)' );
|
||||
--enable_query_log
|
||||
select @string as "" ;
|
||||
prepare stmt1 from @string ;
|
||||
execute stmt1 ;
|
||||
|
||||
--disable_query_log
|
||||
set @string= 'insert into t5 values(' ;
|
||||
let $1=`select @col_num - 1` ;
|
||||
while ($1)
|
||||
{
|
||||
eval set @string= concat(@string, '1 ,') ;
|
||||
dec $1 ;
|
||||
}
|
||||
eval set @string= concat(@string, '1 )') ;
|
||||
--enable_query_log
|
||||
select @string as "" ;
|
||||
prepare stmt1 from @string ;
|
||||
execute stmt1 ;
|
||||
|
||||
prepare stmt1 from ' select * from t5 ' ;
|
||||
--enable_metadata
|
||||
# prevent too long lines
|
||||
--vertical_results
|
||||
--disable_result_log
|
||||
execute stmt1 ;
|
||||
--enable_result_log
|
||||
--disable_metadata
|
||||
--horizontal_results
|
||||
|
||||
drop table t5 ;
|
||||
|
||||
|
||||
################ GRANT/REVOKE/DROP affecting a parallel session ################
|
||||
--disable_query_log
|
||||
select '------ grant/revoke/drop affects a parallel session test ------'
|
||||
as test_sequence ;
|
||||
--enable_query_log
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# Here we test that:
|
||||
# 1. A new GRANT will be visible within another sessions. #
|
||||
# #
|
||||
# Let's assume there is a parallel session with an already prepared #
|
||||
# statement for a table. #
|
||||
# A DROP TABLE will affect the EXECUTE properties. #
|
||||
# A REVOKE will affect the EXECUTE properties. #
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
# Who am I ?
|
||||
# this is different across different systems:
|
||||
# select current_user(), user() ;
|
||||
|
||||
#### create a new user account ####
|
||||
## There should be no grants for that non existing user
|
||||
--error 1141
|
||||
show grants for second_user@localhost ;
|
||||
## create a new user account by using GRANT statements on t9
|
||||
grant usage on test.* to second_user@localhost
|
||||
identified by 'looser' ;
|
||||
grant select on test.t9 to second_user@localhost
|
||||
identified by 'looser' ;
|
||||
show grants for second_user@localhost ;
|
||||
|
||||
|
||||
#### establish a second session to the new user account
|
||||
connect (con3,localhost,second_user,looser,test);
|
||||
## switch to the second session
|
||||
connection con3;
|
||||
# Who am I ?
|
||||
select current_user();
|
||||
## check the access rights
|
||||
show grants for current_user();
|
||||
prepare s_t9 from 'select c1 as my_col
|
||||
from t9 where c1= 1' ;
|
||||
execute s_t9 ;
|
||||
# check that we cannot do a SELECT on the table t1;
|
||||
--error 1142
|
||||
select a as my_col from t1;
|
||||
|
||||
|
||||
#### give access rights to t1 and drop table t9
|
||||
## switch back to the first session
|
||||
connection default;
|
||||
grant select on test.t1 to second_user@localhost
|
||||
identified by 'looser' ;
|
||||
show grants for second_user@localhost ;
|
||||
drop table t9 ;
|
||||
show grants for second_user@localhost ;
|
||||
|
||||
|
||||
#### check the access as new user
|
||||
## switch to the second session
|
||||
connection con3;
|
||||
######## Question 1: The table t1 should be now accessible. ########
|
||||
show grants for second_user@localhost ;
|
||||
prepare s_t1 from 'select a as my_col from t1' ;
|
||||
execute s_t1 ;
|
||||
######## Question 2: The table t9 does not exist. ########
|
||||
--error 1146
|
||||
execute s_t9 ;
|
||||
|
||||
|
||||
#### revoke the access rights to t1
|
||||
## switch back to the first session
|
||||
connection default;
|
||||
revoke all privileges on test.t1 from second_user@localhost
|
||||
identified by 'looser' ;
|
||||
show grants for second_user@localhost ;
|
||||
|
||||
#### check the access as new user
|
||||
## switch to the second session
|
||||
connection con3;
|
||||
show grants for second_user@localhost ;
|
||||
######## Question 2: The table t1 should be now not accessible. ########
|
||||
--error 1142
|
||||
execute s_t1 ;
|
||||
|
||||
## cleanup
|
||||
## switch back to the first session
|
||||
connection default;
|
||||
## disconnect the second session
|
||||
disconnect con3 ;
|
||||
## remove all rights of second_user@localhost
|
||||
revoke all privileges, grant option from second_user@localhost ;
|
||||
show grants for second_user@localhost ;
|
||||
drop user second_user@localhost ;
|
||||
commit ;
|
||||
--error 1141
|
||||
show grants for second_user@localhost ;
|
||||
|
||||
|
||||
drop table t1 ;
|
||||
|
||||
|
||||
##### RULES OF THUMB TO PRESERVE THE SYSTEMATICS OF THE PS TEST CASES #####
|
||||
#
|
||||
# 0. You don't have the time to
|
||||
@ -749,7 +949,7 @@ drop table t1 ;
|
||||
# NO --> alter t/ps_1general.test (Example: Command with syntax error)
|
||||
# If you need a table, please try to use
|
||||
# t1 - very simple table
|
||||
# t_many_col_types - table with nearly all available column types
|
||||
# t9 - table with nearly all available column types
|
||||
# whenever possible.
|
||||
#
|
||||
# The structure and the content of these tables can be found in
|
||||
@ -804,11 +1004,11 @@ drop table t1 ;
|
||||
# include/ps_query.inc test cases with SELECT/...
|
||||
# These test cases should not modify the content or
|
||||
# the structure (DROP/ALTER..) of the tables
|
||||
# 't1' and 't_many_col_types'.
|
||||
# 't1' and 't9'.
|
||||
# include/ps_modify.inc test cases with INSERT/UPDATE/...
|
||||
# These test cases should not modify the structure
|
||||
# (DROP/ALTER..) of the tables
|
||||
# 't1' and 't_many_col_types'.
|
||||
# 't1' and 't9'.
|
||||
# These two test sequences will be applied to all table types .
|
||||
#
|
||||
# include/ps_modify1.inc test cases with INSERT/UPDATE/...
|
||||
@ -816,7 +1016,7 @@ drop table t1 ;
|
||||
# except MERGE tables.
|
||||
#
|
||||
# include/ps_create.inc DROP and CREATE of the tables
|
||||
# 't1' and 't_many_col_types' .
|
||||
# 't1' and 't9' .
|
||||
# include/ps_renew.inc DELETE all rows and INSERT some rows, that means
|
||||
# recreate the original content of these tables.
|
||||
# Please do not alter the commands concerning these two tables.
|
||||
|
Reference in New Issue
Block a user