Merge mysql.com:/home/bk/mysql-4.1

into mysql.com:/users/kboortz/daily/work/mysql-4.1-vax
This commit is contained in:
unknown 2004-09-26 09:18:43 +02:00
commit 6337cd1c87
23 changed files with 17649 additions and 824 deletions

View file

@ -46,7 +46,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
ctype-win1250ch.lo ctype-utf8.lo ctype-extra.lo \
ctype-ucs2.lo ctype-gb2312.lo ctype-gbk.lo \
ctype-sjis.lo ctype-tis620.lo ctype-ujis.lo \
ctype-uca.lo xml.lo
ctype-uca.lo xml.lo my_strtoll10.lo
mystringsextra= strto.c
dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo

View file

@ -145,7 +145,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION ||
(mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION &&
host && strcmp(host,LOCAL_HOST)))
host && *host && strcmp(host,LOCAL_HOST)))
DBUG_RETURN(cli_mysql_real_connect(mysql, host, user,
passwd, db, port,
unix_socket, client_flag));

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@
#---- Please do not alter the following table definitions -------#
--disable_warnings
drop table if exists t1, t_many_col_types ;
drop table if exists t1, t9 ;
--enable_warnings
eval create table t1
@ -28,7 +28,7 @@ eval create table t1
primary key(a)
) engine = $type ;
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,

View file

@ -14,12 +14,12 @@
# several test cases.
#
# Please do not modify the structure (DROP/ALTER..) of the tables
# 't1' and 't_many_col_types'.
# 't1' and 't9'.
#
# But you are encouraged to use these two tables within your statements
# whenever possible.
# t1 - very simple table
# t_many_col_types - table with nearly all available column types
# (DELETE/UPDATE/...) whenever possible.
# t1 - very simple table
# t9 - table with nearly all available column types
#
# The structure and the content of these tables can be found in
# include/ps_create.inc CREATE TABLE ...
@ -124,17 +124,48 @@ 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
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 ;
select a,b from t1 order by a;
--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
#
# Test UPDATE with SUBQUERY in prepared mode
#
eval create table t2
(
a int, 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
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
@ -179,6 +210,46 @@ 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 ;
@ -208,6 +279,22 @@ set @arg01=1 ;
--error 1062
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) ;
# bug#3117
execute stmt1 ;
drop table t2 ;
## many parameters
set @1000=1000 ;
set @x1000_2="x1000_2" ;
@ -237,3 +324,34 @@ 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 ;
}

View file

@ -20,12 +20,12 @@
# several test cases.
#
# Please do not modify the structure (DROP/ALTER..) of the tables
# 't1' and 't_many_col_types'.
# 't1' and 't9'.
#
# But you are encouraged to use these two tables within your statements
# (DELETE/UPDATE/...) whenever possible.
# t1 - very simple table
# t_many_col_types - table with nearly all available column types
# t1 - very simple table
# t9 - table with nearly all available column types
#
# The structure and the content of these tables can be found in
# include/ps_create.inc CREATE TABLE ...
@ -41,6 +41,11 @@
#-------- Please be very carefull when editing behind this line ----------#
--source include/ps_renew.inc
#
# add a NULL row to t1: this row is used only in this test
insert into t1 values(0,NULL) ;
## big insert select statements
set @duplicate='duplicate ' ;
set @1000=1000 ;

View file

@ -15,13 +15,13 @@
#
# Please do not modify (INSERT/UPDATE/DELETE) the content or the
# structure (DROP/ALTER..) of the tables
# 't1' and 't_many_col_types'.
# 't1' and 't9'.
# Such tests should be done in include/ps_modify.inc .
#
# But you are encouraged to use these two tables within your SELECT statements
# whenever possible.
# t1 - very simple table
# t_many_col_types - table with nearly all available column types
# t1 - very simple table
# t9 - table with nearly all available column types
#
# The structure and the content of these tables can be found in
# include/ps_create.inc CREATE TABLE ...
@ -38,10 +38,18 @@
#-------- Please be very carefull when editing behind this line ----------#
################ simple select tests ################
--disable_query_log
select '------ simple select tests ------' as test_sequence ;
--enable_query_log
##### many column types, but no parameter
# heavy modified case derived from client_test.c: test_func_fields()
prepare stmt1 from ' select * from t9 ' ;
--enable_metadata
execute stmt1;
--disable_metadata
##### parameter used for keyword like SELECT (must fail)
set @arg00='SELECT' ;
# mysqltest gives no output for the next statement, Why ??
@ -70,6 +78,17 @@ set @arg00=1 ;
select b, a - @arg00 from t1 where a=1 ;
prepare stmt1 from ' select b, a - ? from t1 where a=1 ' ;
execute stmt1 using @arg00 ;
# case derived from client_test.c: test_ps_null_param()
set @arg00=null ;
select @arg00 as my_col ;
prepare stmt1 from ' select ? as my_col';
execute stmt1 using @arg00 ;
select @arg00 + 1 as my_col ;
prepare stmt1 from ' select ? + 1 as my_col';
execute stmt1 using @arg00 ;
select 1 + @arg00 as my_col ;
prepare stmt1 from ' select 1 + ? as my_col';
execute stmt1 using @arg00 ;
## parameter is within a function
# variations on 'substr'
set @arg00='MySQL' ;
@ -86,7 +105,7 @@ execute stmt1 using @arg00 ;
# variations on 'concat'
set @arg00='MySQL' ;
select a , concat(@arg00,b) from t1 ;
# BUG#3796
# BUG#3796 Prepared statement, select concat(<parameter>,<column>),wrong result
prepare stmt1 from ' select a , concat(?,b) from t1 ' ;
execute stmt1 using @arg00;
#
@ -122,25 +141,25 @@ execute stmt1 using @arg02, @arg02 ;
# case derived from client_test.c: test_ps_conj_select()
# for BUG#3420: select returned all rows of the table
--disable_warnings
drop table if exists new_tab ;
drop table if exists t5 ;
--enable_warnings
create table new_tab (id1 int(11) not null default '0',
create table t5 (id1 int(11) not null default '0',
value2 varchar(100), value1 varchar(100)) ;
insert into new_tab values (1,'hh','hh'),(2,'hh','hh'),
insert into t5 values (1,'hh','hh'),(2,'hh','hh'),
(1,'ii','ii'),(2,'ii','ii') ;
prepare stmt1 from ' select id1,value1 from new_tab where id1=? or value1=? ' ;
prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? ' ;
set @arg00=1 ;
set @arg01='hh' ;
execute stmt1 using @arg00, @arg01 ;
drop table new_tab ;
drop table t5 ;
# case derived from client_test.c: test_bug1180()
# for BUG#1180 optimized away part of WHERE clause
--disable_warnings
drop table if exists new_tab ;
drop table if exists t5 ;
--enable_warnings
create table new_tab(session_id char(9) not null) ;
insert into new_tab values ('abc') ;
prepare stmt1 from ' select * from new_tab
create table t5(session_id char(9) not null) ;
insert into t5 values ('abc') ;
prepare stmt1 from ' select * from t5
where ?=''1111'' and session_id = ''abc'' ' ;
set @arg00='abc' ;
execute stmt1 using @arg00 ;
@ -148,7 +167,7 @@ set @arg00='1111' ;
execute stmt1 using @arg00 ;
set @arg00='abc' ;
execute stmt1 using @arg00 ;
drop table new_tab ;
drop table t5 ;
##### parameter used for keyword FROM (must fail)
@ -200,6 +219,12 @@ set @arg01=3 ;
select a FROM t1 where a in (@arg00,@arg01);
prepare stmt1 from ' select a FROM t1 where a in (?,?) ';
execute stmt1 using @arg00, @arg01;
# case derived from client_test.c: test_bug1500()
set @arg00= 'one' ;
set @arg01= 'two' ;
set @arg02= 'five' ;
prepare stmt1 from ' select b FROM t1 where b in (?,?,?) ' ;
execute stmt1 using @arg00, @arg01, @arg02 ;
# parameter in LIKE
prepare stmt1 from ' select b FROM t1 where b like ? ';
set @arg00='two' ;
@ -208,6 +233,24 @@ set @arg00='tw%' ;
execute stmt1 using @arg00 ;
set @arg00='%wo' ;
execute stmt1 using @arg00 ;
# case derived from client_test.c: test_ps_null_param():
# second part, comparisions with NULL placeholders in prepared
# mode
set @arg00=null ;
insert into t9 set c1= 0, c5 = NULL ;
select c5 from t9 where c5 > NULL ;
prepare stmt1 from ' select c5 from t9 where c5 > ? ';
execute stmt1 using @arg00 ;
select c5 from t9 where c5 < NULL ;
prepare stmt1 from ' select c5 from t9 where c5 < ? ';
execute stmt1 using @arg00 ;
select c5 from t9 where c5 = NULL ;
prepare stmt1 from ' select c5 from t9 where c5 = ? ';
execute stmt1 using @arg00 ;
select c5 from t9 where c5 <=> NULL ;
prepare stmt1 from ' select c5 from t9 where c5 <=> ? ';
execute stmt1 using @arg00 ;
delete from t9 where c1= 0 ;
##### parameter used for operator in WHERE clause (must fail)
set @arg00='>' ;
@ -276,6 +319,7 @@ having sum(a) <> ? ';
execute stmt1 using @arg00, @arg01, @arg02, @arg03;
################ join tests ################
--disable_query_log
select '------ join tests ------' as test_sequence ;
--enable_query_log
@ -301,8 +345,39 @@ prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second
order by second.a, first.a';
execute stmt1 using @arg00, @arg01, @arg02;
# test case derived from client_test.c: test_join()
--disable_warnings
drop table if exists t2 ;
--enable_warnings
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) ' ;
set @query2= 'SELECT * FROM t2 natural join t1 ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) ' ;
let $1= 9 ;
while ($1)
{
--disable_query_log
eval select @query$1 as 'the join statement is:' ;
--enable_query_log
eval prepare stmt1 from @query$1 ;
let $2= 3 ;
while ($2)
{
execute stmt1 ;
dec $2 ;
}
dec $1 ;
}
drop table t2 ;
################ subquery tests ################
--disable_query_log
select '------ subquery tests ------' as test_sequence ;
--enable_query_log
@ -350,8 +425,20 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
# no parameter
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) ';
# also Bug#4000 (only BDB tables) ??
# also Bug#4000 (only BDB tables)
# Bug#4106 : ndb table, query with correlated subquery, wrong result
execute stmt1 ;
# test case derived from client_test.c: test_subqueries_ref
let $1= 3 ;
while ($1)
{
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
execute stmt1 ;
deallocate prepare stmt1 ;
dec $1 ;
}
###### parameter in the outer part
set @arg00='two' ;
@ -360,7 +447,7 @@ select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) and b=@arg00 ;
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b) and b=? ';
# also Bug#4000 (only BDB tables) ??
# also Bug#4000 (only BDB tables)
execute stmt1 using @arg00;
###### parameter in the inner part
@ -390,7 +477,7 @@ select a, @arg00, b FROM t1 outer_table where
prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
b=? and a = (select ? from t1 where outer_table.b = ?
and outer_table.a=a ) ' ;
# also Bug#4000 (only BDB tables) ??
# also Bug#4000 (only BDB tables)
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
###### subquery after from
@ -404,43 +491,76 @@ prepare stmt1 from ' select a, ?
where a=? ';
execute stmt1 using @arg00, @arg00, @arg00, @arg01 ;
###### heavy modified case derived from client_test.c: test_distinct()
## no parameters
###### subquery in select list
# test case derived from client_test.c: test_create_drop
--disable_warnings
drop table if exists t2 ;
--enable_warnings
create table t2 as select * from t_many_col_types;
#insert into t2 select * from t_many_col_types;
create table t2 as select * from t1;
prepare stmt1 from ' select a in (select a from t2) from t1 ' ;
execute stmt1 ;
# test case derived from client_test.c: test_selecttmp()
--disable_warnings
drop table if exists t5, t6, t7 ;
--enable_warnings
create table t5 (a int , b int) ;
create table t6 like t5 ;
create table t7 like t5 ;
insert into t5 values (0, 100), (1, 2), (1, 3), (2, 2), (2, 7),
(2, -1), (3, 10) ;
insert into t6 values (0, 0), (1, 1), (2, 1), (3, 1), (4, 1) ;
insert into t7 values (3, 3), (2, 2), (1, 1) ;
prepare stmt1 from ' select a, (select count(distinct t5.b) as sum from t5, t6
where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b
group by t5.a order by sum limit 1) from t7 ' ;
let $1= 3 ;
while ($1)
{
execute stmt1 ;
dec $1 ;
}
drop table t5, t6, t7 ;
###### heavy modified case derived from client_test.c: test_distinct()
--disable_warnings
drop table if exists t2 ;
--enable_warnings
create table t2 as select * from t9;
## unusual and complex SELECT without parameters
set @stmt= ' SELECT
(SELECT SUM(c1 + c12 + 0.0) FROM t2
where (t_many_col_types.c2 - 0e-3) = t2.c2
GROUP BY t_many_col_types.c15 LIMIT 1) as scalar_s,
where (t9.c2 - 0e-3) = t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
exists (select 1.0e+0 from t2
where t2.c3 * 9.0000000000 = t_many_col_types.c4) as exists_s,
where t2.c3 * 9.0000000000 = t9.c4) as exists_s,
c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s,
(c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s
FROM t_many_col_types,
FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
--enable_metadata
prepare stmt1 from @stmt ;
execute stmt1 ;
--disable_metadata
execute stmt1 ;
## now expand the terrible SELECT to EXPLAIN SELECT
set @stmt= concat('explain ',@stmt);
--enable_metadata
prepare stmt1 from @stmt ;
execute stmt1 ;
--disable_metadata
# Bug#4271 prepared explain complex select, second executes crashes the server
execute stmt1 ;
## many parameters
## replace the constants of the complex SELECT with parameters
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t_many_col_types.c2-?)=t2.c2
GROUP BY t_many_col_types.c15 LIMIT 1) as scalar_s,
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
exists (select ? from t2
where t2.c3*?=t_many_col_types.c4) as exists_s,
where t2.c3*?=t9.c4) as exists_s,
c5*? in (select c6+? from t2) as in_s,
(c7-?, c8-?) in (select c9+?, c10+? from t2) as in_row_s
FROM t_many_col_types,
FROM t9,
(select c25 x, c32 y from t2) tt WHERE x =c25 ' ;
set @arg00= 0.0 ;
set @arg01= 0e-3 ;
@ -459,6 +579,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
--disable_metadata
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
## now expand the terrible SELECT to EXPLAIN SELECT
set @stmt= concat('explain ',@stmt);
--enable_metadata
prepare stmt1 from @stmt ;
@ -470,6 +591,17 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
drop table t2 ;
##### test case derived from client_test.c: test_bug4079()
--error 1242
select 1 < (select a from t1) ;
prepare stmt1 from ' select 1 < (select a from t1) ' ;
--error 1242
execute stmt1 ;
# Bug#5066 embedded server, select after failed subquery provides wrong result
# (two additional records, all column values NULL)
select 1 as my_col ;
################ union tests ################
--disable_query_log
select '------ union tests ------' as test_sequence ;
--enable_query_log
@ -485,6 +617,16 @@ prepare stmt1 from ' select a FROM t1 where a=1
union all
select a FROM t1 where a=1 ';
execute stmt1 ;
# test case derived from client_test.c: test_bad_union()
--error 1222
prepare stmt1 from ' SELECT 1, 2 union SELECT 1 ' ;
--error 1222
prepare stmt1 from ' SELECT 1 union SELECT 1, 2 ' ;
--error 1222
prepare stmt1 from ' SELECT * from t1 union SELECT 1 ' ;
--error 1222
prepare stmt1 from ' SELECT 1 union SELECT * from t1 ' ;
##### everything in the first table
# one parameter as constant in the first table
@ -612,10 +754,13 @@ prepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1
execute stmt1 using @Oporto, @1, @2, @Lisboa, @2, @3;
################ explain select tests ################
--disable_query_log
select '------ explain select tests ------' as test_sequence ;
--enable_query_log
prepare stmt1 from ' select * from t_many_col_types ' ;
--disable_metadata
# table with many column types
prepare stmt1 from ' explain select * from t9 ' ;
--enable_metadata
execute stmt1;
--disable_metadata

View file

@ -1,6 +1,6 @@
################ include/ps_renew.inc #################
# #
# renew the content of t1 and t_many_col_types #
# renew the content of t1 and t9 #
# #
#######################################################
@ -13,8 +13,8 @@ insert into t1 values (3,'three');
insert into t1 values (4,'four');
commit ;
delete from t_many_col_types ;
insert into t_many_col_types
delete from t9 ;
insert into t9
set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1,
c10= 1, c11= 1, c12 = 1,
c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11',
@ -23,7 +23,7 @@ set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1,
c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext',
c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext',
c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday';
insert into t_many_col_types
insert into t9
set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9,
c10= 9, c11= 9, c12 = 9,
c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11',
@ -32,3 +32,4 @@ set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9,
c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext',
c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext',
c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday';
commit ;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

3170
mysql-test/r/ps_7ndb.result Normal file

File diff suppressed because it is too large Load diff

View file

@ -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.

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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
View 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;

View file

@ -1286,7 +1286,7 @@ static my_bool my_coll_init_simple(CHARSET_INFO *cs,
longlong my_strtoll10_8bit(CHARSET_INFO *cs __attribute__((unused)),
const char *nptr, char **endptr, int *error)
{
return 0; /* my_strtoll10(nptr, endptr, error); */
return my_strtoll10(nptr, endptr, error);
}