mirror of
https://github.com/MariaDB/server.git
synced 2025-11-15 09:02:33 +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.
|
||||
|
||||
@@ -15,7 +15,28 @@ let $type= 'MYISAM' ;
|
||||
-- source include/ps_renew.inc
|
||||
|
||||
-- source include/ps_query.inc
|
||||
|
||||
# parameter in SELECT ... MATCH/AGAINST
|
||||
# case derived from client_test.c: test_bug1500()
|
||||
--disable_warnings
|
||||
drop table if exists t2 ;
|
||||
--enable_warnings
|
||||
eval create table t2 (s varchar(25), fulltext(s))
|
||||
ENGINE = $type ;
|
||||
insert into t2 values ('Gravedigger'), ('Greed'),('Hollow Dogs') ;
|
||||
commit ;
|
||||
|
||||
prepare stmt1 from ' select s from t2 where match (s) against (?) ' ;
|
||||
set @arg00='Dogs' ;
|
||||
execute stmt1 using @arg00 ;
|
||||
prepare stmt1 from ' SELECT s FROM t2
|
||||
where match (s) against (concat(?,''digger'')) ';
|
||||
set @arg00='Grave' ;
|
||||
execute stmt1 using @arg00 ;
|
||||
drop table t2 ;
|
||||
|
||||
-- source include/ps_modify.inc
|
||||
-- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
drop table t1, t_many_col_types;
|
||||
drop table t1, t9;
|
||||
|
||||
@@ -19,5 +19,6 @@ let $type= 'InnoDB' ;
|
||||
-- source include/ps_query.inc
|
||||
-- source include/ps_modify.inc
|
||||
-- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
drop table t1, t_many_col_types;
|
||||
drop table t1, t9;
|
||||
|
||||
@@ -12,7 +12,7 @@ use test;
|
||||
|
||||
let $type= 'HEAP' ;
|
||||
--disable_warnings
|
||||
drop table if exists t1, t_many_col_types ;
|
||||
drop table if exists t1, t9 ;
|
||||
--enable_warnings
|
||||
eval create table t1
|
||||
(
|
||||
@@ -21,12 +21,12 @@ eval create table t1
|
||||
) engine = $type ;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t_many_col_types;
|
||||
drop table if exists t9;
|
||||
--enable_warnings
|
||||
# The used table type doesn't support BLOB/TEXT columns.
|
||||
# (The server would send error 1163 .)
|
||||
# So we use char(100) instead.
|
||||
eval create table t_many_col_types
|
||||
eval create table t9
|
||||
(
|
||||
c1 tinyint, c2 smallint, c3 mediumint, c4 int,
|
||||
c5 integer, c6 bigint, c7 float, c8 double,
|
||||
@@ -44,5 +44,6 @@ eval create table t_many_col_types
|
||||
-- source include/ps_query.inc
|
||||
-- source include/ps_modify.inc
|
||||
-- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
drop table t1, t_many_col_types;
|
||||
drop table t1, t9;
|
||||
|
||||
@@ -12,13 +12,13 @@ use test;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t1_1, t1_2,
|
||||
t_many_col_types, t_many_col_types_1, t_many_col_types_2;
|
||||
t9, t9_1, t9_2;
|
||||
--enable_warnings
|
||||
let $type= 'MYISAM' ;
|
||||
-- source include/ps_create.inc
|
||||
rename table t1 to t1_1, t_many_col_types to t_many_col_types_1 ;
|
||||
rename table t1 to t1_1, t9 to t9_1 ;
|
||||
-- source include/ps_create.inc
|
||||
rename table t1 to t1_2, t_many_col_types to t_many_col_types_2 ;
|
||||
rename table t1 to t1_2, t9 to t9_2 ;
|
||||
|
||||
create table t1
|
||||
(
|
||||
@@ -26,7 +26,7 @@ create table t1
|
||||
primary key(a)
|
||||
) ENGINE = MERGE UNION=(t1_1,t1_2)
|
||||
INSERT_METHOD=FIRST;
|
||||
create table t_many_col_types
|
||||
create table t9
|
||||
(
|
||||
c1 tinyint, c2 smallint, c3 mediumint, c4 int,
|
||||
c5 integer, c6 bigint, c7 float, c8 double,
|
||||
@@ -38,7 +38,7 @@ create table t_many_col_types
|
||||
c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'),
|
||||
c32 set('monday', 'tuesday', 'wednesday'),
|
||||
primary key(c1)
|
||||
) ENGINE = MERGE UNION=(t_many_col_types_1,t_many_col_types_2)
|
||||
) ENGINE = MERGE UNION=(t9_1,t9_2)
|
||||
INSERT_METHOD=FIRST;
|
||||
-- source include/ps_renew.inc
|
||||
|
||||
@@ -47,16 +47,17 @@ INSERT_METHOD=FIRST;
|
||||
# no test of ps_modify1, because insert .. select
|
||||
# is not allowed on MERGE tables
|
||||
# -- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
# Lets's try the same tests with INSERT_METHOD=LAST
|
||||
drop table t1, t_many_col_types ;
|
||||
drop table t1, t9 ;
|
||||
create table t1
|
||||
(
|
||||
a int, b varchar(30),
|
||||
primary key(a)
|
||||
) ENGINE = MERGE UNION=(t1_1,t1_2)
|
||||
INSERT_METHOD=LAST;
|
||||
create table t_many_col_types
|
||||
create table t9
|
||||
(
|
||||
c1 tinyint, c2 smallint, c3 mediumint, c4 int,
|
||||
c5 integer, c6 bigint, c7 float, c8 double,
|
||||
@@ -68,7 +69,7 @@ create table t_many_col_types
|
||||
c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'),
|
||||
c32 set('monday', 'tuesday', 'wednesday'),
|
||||
primary key(c1)
|
||||
) ENGINE = MERGE UNION=(t_many_col_types_1,t_many_col_types_2)
|
||||
) ENGINE = MERGE UNION=(t9_1,t9_2)
|
||||
INSERT_METHOD=LAST;
|
||||
-- source include/ps_renew.inc
|
||||
|
||||
@@ -77,6 +78,7 @@ INSERT_METHOD=LAST;
|
||||
# no test of ps_modify1, because insert .. select
|
||||
# is not allowed on MERGE tables
|
||||
# -- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
drop table t1, t1_1, t1_2,
|
||||
t_many_col_types_1, t_many_col_types_2, t_many_col_types;
|
||||
t9_1, t9_2, t9;
|
||||
|
||||
@@ -18,5 +18,6 @@ let $type= 'BDB' ;
|
||||
-- source include/ps_query.inc
|
||||
-- source include/ps_modify.inc
|
||||
-- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
drop table t1, t_many_col_types;
|
||||
drop table t1, t9;
|
||||
|
||||
377
mysql-test/t/ps_7ndb.test
Normal file
377
mysql-test/t/ps_7ndb.test
Normal file
@@ -0,0 +1,377 @@
|
||||
###############################################
|
||||
# #
|
||||
# Prepared Statements test on NDB tables #
|
||||
# #
|
||||
###############################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE SEE ps_1general.test (bottom)
|
||||
# BEFORE ADDING NEW TEST CASES HERE !!!
|
||||
|
||||
use test;
|
||||
|
||||
-- source include/have_ndb.inc
|
||||
let $type= 'NDB' ;
|
||||
--disable_warnings
|
||||
drop table if exists t1, t9 ;
|
||||
--enable_warnings
|
||||
eval create table t1
|
||||
(
|
||||
a int not null, b varchar(30),
|
||||
primary key(a)
|
||||
) engine = $type ;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t9;
|
||||
--enable_warnings
|
||||
# The used table type doesn't support BLOB/TEXT columns.
|
||||
# (The server would send error 1163 .)
|
||||
# So we use char(100) instead.
|
||||
eval create table t9
|
||||
(
|
||||
c1 tinyint not null, c2 smallint, c3 mediumint, c4 int,
|
||||
c5 integer, c6 bigint, c7 float, c8 double,
|
||||
c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4),
|
||||
c13 date, c14 datetime, c15 timestamp(14), c16 time,
|
||||
c17 year, c18 bit, c19 bool, c20 char,
|
||||
c21 char(10), c22 varchar(30), c23 char(100), c24 char(100),
|
||||
c25 char(100), c26 char(100), c27 char(100), c28 char(100),
|
||||
c29 char(100), c30 char(100), c31 enum('one', 'two', 'three'),
|
||||
c32 set('monday', 'tuesday', 'wednesday'),
|
||||
primary key(c1)
|
||||
) engine = $type ;
|
||||
-- source include/ps_renew.inc
|
||||
|
||||
-- source include/ps_query.inc
|
||||
# The following line is deactivated, because the ndb storage engine is not able
|
||||
# to do primary key column updates .
|
||||
#-- source include/ps_modify.inc
|
||||
# let's include all statements which will work
|
||||
--disable_query_log
|
||||
select '------ delete tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
--source include/ps_renew.inc
|
||||
|
||||
## delete without parameter
|
||||
prepare stmt1 from 'delete from t1 where a=2' ;
|
||||
execute stmt1;
|
||||
select a,b from t1 where a=2;
|
||||
# delete with row not found
|
||||
execute stmt1;
|
||||
|
||||
## delete with one parameter in the where clause
|
||||
insert into t1 values(0,NULL);
|
||||
set @arg00=NULL;
|
||||
prepare stmt1 from 'delete from t1 where b=?' ;
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where b is NULL ;
|
||||
set @arg00='one';
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where b=@arg00;
|
||||
|
||||
## truncate a table
|
||||
--error 1295
|
||||
prepare stmt1 from 'truncate table t1' ;
|
||||
|
||||
|
||||
--disable_query_log
|
||||
select '------ update tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
--source include/ps_renew.inc
|
||||
|
||||
## update without parameter
|
||||
prepare stmt1 from 'update t1 set b=''a=two'' where a=2' ;
|
||||
execute stmt1;
|
||||
select a,b from t1 where a=2;
|
||||
# dummy update
|
||||
execute stmt1;
|
||||
select a,b from t1 where a=2;
|
||||
|
||||
## update with one parameter in the set clause
|
||||
set @arg00=NULL;
|
||||
prepare stmt1 from 'update t1 set b=? where a=2' ;
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where a=2;
|
||||
set @arg00='two';
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where a=2;
|
||||
|
||||
## update with one parameter in the where cause
|
||||
set @arg00=2;
|
||||
prepare stmt1 from 'update t1 set b=NULL where a=?' ;
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where a=@arg00;
|
||||
update t1 set b='two' where a=@arg00;
|
||||
# row not found in update
|
||||
set @arg00=2000;
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where a=@arg00;
|
||||
|
||||
## update on primary key column (two parameters)
|
||||
set @arg00=2;
|
||||
set @arg01=22;
|
||||
prepare stmt1 from 'update t1 set a=? where a=?' ;
|
||||
# dummy update
|
||||
execute stmt1 using @arg00, @arg00;
|
||||
select a,b from t1 where a=@arg00;
|
||||
# deactivated primary key column update
|
||||
# execute stmt1 using @arg01, @arg00;
|
||||
select a,b from t1 where a=@arg01;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
select a,b from t1 where a=@arg00;
|
||||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
# deactivated primary key column update
|
||||
# execute stmt1 using @arg00, @arg01;
|
||||
select a,b from t1 order by a;
|
||||
set @arg00=0;
|
||||
execute stmt1 using @arg01, @arg00;
|
||||
select a,b from t1 order by a;
|
||||
|
||||
## update with subquery and several parameters
|
||||
set @arg00=23;
|
||||
set @arg01='two';
|
||||
set @arg02=2;
|
||||
set @arg03='two';
|
||||
set @arg04=2;
|
||||
--disable_warnings
|
||||
drop table if exists t2;
|
||||
--enable_warnings
|
||||
# t2 will be of table type 'MYISAM'
|
||||
create table t2 as select a,b from t1 ;
|
||||
prepare stmt1 from 'update t1 set a=? where b=?
|
||||
and a in (select ? from t2
|
||||
where b = ? or a = ?)';
|
||||
--enable_info
|
||||
# deactivated primary key column update
|
||||
# execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ;
|
||||
--disable_info
|
||||
select a,b from t1 where a = @arg00 ;
|
||||
prepare stmt1 from 'update t1 set a=? where b=?
|
||||
and a not in (select ? from t2
|
||||
where b = ? or a = ?)';
|
||||
--enable_info
|
||||
execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ;
|
||||
--disable_info
|
||||
select a,b from t1 order by a;
|
||||
drop table t2 ;
|
||||
# t2 is now of table type '$type'
|
||||
# The test battery for table type 'MERGE' gets here only a 'MYISAM' table
|
||||
eval create table t2
|
||||
(
|
||||
a int not null, b varchar(30),
|
||||
primary key(a)
|
||||
) engine = $type ;
|
||||
insert into t2(a,b) select a, b from t1 ;
|
||||
prepare stmt1 from 'update t1 set a=? where b=?
|
||||
and a in (select ? from t2
|
||||
where b = ? or a = ?)';
|
||||
--enable_info
|
||||
# deactivated primary key column update
|
||||
# execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ;
|
||||
--disable_info
|
||||
select a,b from t1 where a = @arg00 ;
|
||||
prepare stmt1 from 'update t1 set a=? where b=?
|
||||
and a not in (select ? from t2
|
||||
where b = ? or a = ?)';
|
||||
--enable_info
|
||||
execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ;
|
||||
--disable_info
|
||||
select a,b from t1 order by a;
|
||||
drop table t2 ;
|
||||
|
||||
## update with parameters in limit
|
||||
set @arg00=1;
|
||||
prepare stmt1 from 'update t1 set b=''bla''
|
||||
where a=2
|
||||
limit 1';
|
||||
execute stmt1 ;
|
||||
select a,b from t1 where b = 'bla' ;
|
||||
# currently (May 2004, Version 4.1) it is impossible
|
||||
-- error 1064
|
||||
prepare stmt1 from 'update t1 set b=''bla''
|
||||
where a=2
|
||||
limit ?';
|
||||
|
||||
--disable_query_log
|
||||
select '------ insert tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
--source include/ps_renew.inc
|
||||
|
||||
## insert without parameter
|
||||
prepare stmt1 from 'insert into t1 values(5, ''five'' )';
|
||||
execute stmt1;
|
||||
select a,b from t1 where a = 5;
|
||||
|
||||
## insert with one parameter in values part
|
||||
set @arg00='six' ;
|
||||
prepare stmt1 from 'insert into t1 values(6, ? )';
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where b = @arg00;
|
||||
# the second insert fails, because the first column is primary key
|
||||
--error 1062
|
||||
execute stmt1 using @arg00;
|
||||
set @arg00=NULL ;
|
||||
prepare stmt1 from 'insert into t1 values(0, ? )';
|
||||
execute stmt1 using @arg00;
|
||||
select a,b from t1 where b is NULL;
|
||||
|
||||
## insert with two parameter in values part
|
||||
set @arg00=8 ;
|
||||
set @arg01='eight' ;
|
||||
prepare stmt1 from 'insert into t1 values(?, ? )';
|
||||
execute stmt1 using @arg00, @arg01 ;
|
||||
select a,b from t1 where b = @arg01;
|
||||
# cases derived from client_test.c: test_null()
|
||||
set @NULL= null ;
|
||||
set @arg00= 'abc' ;
|
||||
# execute must fail, because first column is primary key (-> not null)
|
||||
--error 1048
|
||||
execute stmt1 using @NULL, @NULL ;
|
||||
--error 1048
|
||||
execute stmt1 using @NULL, @NULL ;
|
||||
--error 1048
|
||||
execute stmt1 using @NULL, @arg00 ;
|
||||
--error 1048
|
||||
execute stmt1 using @NULL, @arg00 ;
|
||||
let $1 = 2;
|
||||
while ($1)
|
||||
{
|
||||
eval set @arg01= 10000 + $1 ;
|
||||
execute stmt1 using @arg01, @arg00 ;
|
||||
dec $1;
|
||||
}
|
||||
select * from t1 where a > 10000 order by a ;
|
||||
delete from t1 where a > 10000 ;
|
||||
let $1 = 2;
|
||||
while ($1)
|
||||
{
|
||||
eval set @arg01= 10000 + $1 ;
|
||||
execute stmt1 using @arg01, @NULL ;
|
||||
dec $1;
|
||||
}
|
||||
select * from t1 where a > 10000 order by a ;
|
||||
delete from t1 where a > 10000 ;
|
||||
let $1 = 10;
|
||||
while ($1)
|
||||
{
|
||||
eval set @arg01= 10000 + $1 ;
|
||||
execute stmt1 using @arg01, @arg01 ;
|
||||
dec $1;
|
||||
}
|
||||
select * from t1 where a > 10000 order by a ;
|
||||
delete from t1 where a > 10000 ;
|
||||
|
||||
|
||||
## insert with two rows in values part
|
||||
set @arg00=81 ;
|
||||
set @arg01='8-1' ;
|
||||
set @arg02=82 ;
|
||||
set @arg03='8-2' ;
|
||||
prepare stmt1 from 'insert into t1 values(?,?),(?,?)';
|
||||
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
|
||||
select a,b from t1 where a in (@arg00,@arg02) ;
|
||||
|
||||
## insert with two parameter in the set part
|
||||
set @arg00=9 ;
|
||||
set @arg01='nine' ;
|
||||
prepare stmt1 from 'insert into t1 set a=?, b=? ';
|
||||
execute stmt1 using @arg00, @arg01 ;
|
||||
select a,b from t1 where a = @arg00 ;
|
||||
|
||||
## insert with parameters in the ON DUPLICATE KEY part
|
||||
set @arg00=6 ;
|
||||
set @arg01=1 ;
|
||||
prepare stmt1 from 'insert into t1 set a=?, b=''sechs''
|
||||
on duplicate key update a=a + ?, b=concat(b,''modified'') ';
|
||||
# There is no primary key collision, so there will be no key column update
|
||||
# If a key column update would be necessary occurs BUG#4312
|
||||
# deactivated, activate when BUG#4312: is solved
|
||||
# execute stmt1 using @arg00, @arg01;
|
||||
select * from t1 order by a;
|
||||
set @arg00=81 ;
|
||||
set @arg01=1 ;
|
||||
# deactivated, activate when BUG#4312: is solved
|
||||
# execute stmt1 using @arg00, @arg01;
|
||||
|
||||
## insert, autoincrement column and ' SELECT LAST_INSERT_ID() '
|
||||
# cases derived from client_test.c: test_bug3117()
|
||||
--disable_warnings
|
||||
drop table if exists t2 ;
|
||||
--enable_warnings
|
||||
# The test battery for table type 'MERGE' gets here only a 'MYISAM' table
|
||||
eval create table t2 (id int auto_increment primary key)
|
||||
ENGINE= $type ;
|
||||
prepare stmt1 from ' select last_insert_id() ' ;
|
||||
insert into t2 values (NULL) ;
|
||||
execute stmt1 ;
|
||||
insert into t2 values (NULL) ;
|
||||
execute stmt1 ;
|
||||
drop table t2 ;
|
||||
|
||||
## many parameters
|
||||
set @1000=1000 ;
|
||||
set @x1000_2="x1000_2" ;
|
||||
set @x1000_3="x1000_3" ;
|
||||
|
||||
set @x1000="x1000" ;
|
||||
set @1100=1100 ;
|
||||
set @x1100="x1100" ;
|
||||
set @100=100 ;
|
||||
set @updated="updated" ;
|
||||
insert into t1 values(1000,'x1000_1') ;
|
||||
# deactivated, activate when BUG#4312: is solved
|
||||
# insert into t1 values(@1000,@x1000_2),(@1000,@x1000_3)
|
||||
# on duplicate key update a = a + @100, b = concat(b,@updated) ;
|
||||
select a,b from t1 where a >= 1000 order by a ;
|
||||
delete from t1 where a >= 1000 ;
|
||||
insert into t1 values(1000,'x1000_1') ;
|
||||
prepare stmt1 from ' insert into t1 values(?,?),(?,?)
|
||||
on duplicate key update a = a + ?, b = concat(b,?) ';
|
||||
# deactivated, activate when BUG#4312: is solved
|
||||
# execute stmt1 using @1000, @x1000_2, @1000, @x1000_3, @100, @updated ;
|
||||
select a,b from t1 where a >= 1000 order by a ;
|
||||
delete from t1 where a >= 1000 ;
|
||||
insert into t1 values(1000,'x1000_1') ;
|
||||
# deactivated, activate when BUG#4312: is solved
|
||||
# execute stmt1 using @1000, @x1000_2, @1100, @x1000_3, @100, @updated ;
|
||||
select a,b from t1 where a >= 1000 order by a ;
|
||||
delete from t1 where a >= 1000 ;
|
||||
|
||||
## replace
|
||||
--error 1295
|
||||
prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' ';
|
||||
|
||||
## multi table statements
|
||||
--disable_query_log
|
||||
select '------ multi table tests ------' as test_sequence ;
|
||||
--enable_query_log
|
||||
# cases derived from client_test.c: test_multi
|
||||
delete from t1 ;
|
||||
delete from t9 ;
|
||||
insert into t1(a,b) values (1, 'one'), (2, 'two'), (3, 'three') ;
|
||||
insert into t9 (c1,c21)
|
||||
values (1, 'one'), (2, 'two'), (3, 'three') ;
|
||||
prepare stmt_delete from " delete t1, t9
|
||||
from t1, t9 where t1.a=t9.c1 and t1.b='updated' ";
|
||||
prepare stmt_update from " update t1, t9
|
||||
set t1.b='updated', t9.c21='updated'
|
||||
where t1.a=t9.c1 and t1.a=? ";
|
||||
prepare stmt_select1 from " select a, b from t1 order by a" ;
|
||||
prepare stmt_select2 from " select c1, c21 from t9 order by c1" ;
|
||||
set @arg00= 1 ;
|
||||
let $1= 3 ;
|
||||
while ($1)
|
||||
{
|
||||
execute stmt_update using @arg00 ;
|
||||
execute stmt_delete ;
|
||||
execute stmt_select1 ;
|
||||
execute stmt_select2 ;
|
||||
set @arg00= @arg00 + 1 ;
|
||||
dec $1 ;
|
||||
}
|
||||
|
||||
-- source include/ps_modify1.inc
|
||||
-- source include/ps_conv.inc
|
||||
|
||||
drop table t1, t9;
|
||||
Reference in New Issue
Block a user