Merge quad.:/mnt/raid/alik/MySQL/devel/5.1

into  quad.:/mnt/raid/alik/MySQL/devel/5.1-rt-merged


client/mysqltest.c:
  Auto merged
mysql-test/r/view.result:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster_binlog.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_connect.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
tests/mysql_client_test.c:
  Auto merged
mysql-test/suite/rpl_ndb/t/disabled.def:
  Manually merged.
mysql-test/t/disabled.def:
  Manually merged.
This commit is contained in:
unknown 2008-02-26 19:34:02 +03:00
commit 336f2c7e51
142 changed files with 5096 additions and 1196 deletions

View File

@ -6333,6 +6333,8 @@ int util_query(MYSQL* org_mysql, const char* query){
if (!(mysql= mysql_init(mysql))) if (!(mysql= mysql_init(mysql)))
die("Failed in mysql_init()"); die("Failed in mysql_init()");
/* enable local infile, in non-binary builds often disabled by default */
mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0);
safe_connect(mysql, "util", org_mysql->host, org_mysql->user, safe_connect(mysql, "util", org_mysql->host, org_mysql->user,
org_mysql->passwd, org_mysql->db, org_mysql->port, org_mysql->passwd, org_mysql->db, org_mysql->port,
org_mysql->unix_socket); org_mysql->unix_socket);

View File

@ -412,15 +412,11 @@ void _db_process_(const char *name)
cs->process= name; cs->process= name;
} }
/* /*
* FUNCTION * FUNCTION
* *
* _db_set_ set current debugger settings * DbugParse parse control string and set current debugger setting
*
* SYNOPSIS
*
* VOID _db_set_(control)
* char *control;
* *
* DESCRIPTION * DESCRIPTION
* *
@ -444,7 +440,7 @@ void _db_process_(const char *name)
* *
*/ */
void _db_set_(CODE_STATE *cs, const char *control) static void DbugParse(CODE_STATE *cs, const char *control)
{ {
const char *end; const char *end;
int rel=0; int rel=0;
@ -671,6 +667,35 @@ void _db_set_(CODE_STATE *cs, const char *control)
} }
/*
* FUNCTION
*
* _db_set_ set current debugger settings
*
* SYNOPSIS
*
* VOID _db_set_(control)
* char *control;
*
* DESCRIPTION
*
* Given pointer to a debug control string in "control",
* parses the control string, and sets up a current debug
* settings. Pushes a new debug settings if the current is
* set to the initial debugger settings.
*/
void _db_set_(CODE_STATE *cs, const char *control)
{
get_code_state_or_return;
if (cs->stack == &init_settings)
PushState(cs);
DbugParse(cs, control);
}
/* /*
* FUNCTION * FUNCTION
* *
@ -685,7 +710,7 @@ void _db_set_(CODE_STATE *cs, const char *control)
* *
* Given pointer to a debug control string in "control", pushes * Given pointer to a debug control string in "control", pushes
* the current debug settings, parses the control string, and sets * the current debug settings, parses the control string, and sets
* up a new debug settings with _db_set_() * up a new debug settings with DbugParse()
* *
*/ */
@ -694,7 +719,7 @@ void _db_push_(const char *control)
CODE_STATE *cs=0; CODE_STATE *cs=0;
get_code_state_or_return; get_code_state_or_return;
PushState(cs); PushState(cs);
_db_set_(cs, control); DbugParse(cs, control);
} }
/* /*
@ -717,7 +742,7 @@ void _db_set_init_(const char *control)
CODE_STATE tmp_cs; CODE_STATE tmp_cs;
bzero((uchar*) &tmp_cs, sizeof(tmp_cs)); bzero((uchar*) &tmp_cs, sizeof(tmp_cs));
tmp_cs.stack= &init_settings; tmp_cs.stack= &init_settings;
_db_set_(&tmp_cs, control); DbugParse(&tmp_cs, control);
} }
/* /*

View File

@ -730,8 +730,9 @@ warning will be given. The DBUG_POP macro has no arguments.
EX:\ \fCDBUG_POP\ ();\fR EX:\ \fCDBUG_POP\ ();\fR
.SP 1 .SP 1
.LI DBUG_SET\ .LI DBUG_SET\
Modifies the current debugger state on top of the stack using the Modifies the current debugger state on top of the stack or pushes
debug control string passed as the macro argument. Unless a new state if the current is set to the initial settings, using
the debug control string passed as the macro argument. Unless
.I incremental .I incremental
control string is used (see below), it's equivalent to a combination of control string is used (see below), it's equivalent to a combination of
DBUG_POP and DBUG_PUSH. DBUG_POP and DBUG_PUSH.

View File

@ -0,0 +1,742 @@
## Bug#12713 (Error in a stored function called from a SELECT doesn't cause
## ROLLBACK of statem)
##
## Pre-Requisites :
## - $engine_type should be set
##
set sql_mode=no_engine_substitution;
eval set storage_engine = $engine_type;
set autocommit=1;
--disable_warnings
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop function if exists f2;
drop procedure if exists bug12713_call;
drop procedure if exists bug12713_dump_spvars;
drop procedure if exists dummy;
--enable_warnings
create table t1 (a int);
create table t2 (a int unique);
create table t3 (a int);
# a workaround for Bug#32633: Can not create any routine if
# SQL_MODE=no_engine_substitution
set sql_mode=default;
insert into t1 (a) values (1), (2);
insert into t3 (a) values (1), (2);
delimiter |;
## Cause a failure every time
create function f2(x int) returns int
begin
insert into t2 (a) values (x);
insert into t2 (a) values (x);
return x;
end|
delimiter ;|
set autocommit=0;
flush status;
##============================================================================
## Design notes
##
## In each case, statement rollback is expected.
## for transactional engines, the rollback should be properly executed
## for non transactional engines, the rollback may cause warnings.
##
## The test pattern is as follows
## - insert 1000+N
## - statement with a side effect, that fails to insert N twice
## - a statement rollback is expected (expecting 1 row 1000+N only) in t2
## - a rollback is performed
## - expecting a clean table t2.
##============================================================================
insert into t2 (a) values (1001);
--error ER_DUP_ENTRY
insert into t1 (a) values (f2(1));
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1002);
--error ER_DUP_ENTRY
insert into t3 (a) select f2(2) from t1;
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1003);
--error ER_DUP_ENTRY
update t1 set a= a + f2(3);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1004);
--error ER_DUP_ENTRY
update t1, t3 set t1.a = 0, t3.a = 0 where (f2(4) = 4) and (t1.a = t3.a);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1005);
--error ER_DUP_ENTRY
delete from t1 where (a = f2(5));
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1006);
--error ER_DUP_ENTRY
delete from t1, t3 using t1, t3 where (f2(6) = 6) ;
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1007);
--error ER_DUP_ENTRY
replace t1 values (f2(7));
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1008);
--error ER_DUP_ENTRY
replace into t3 (a) select f2(8) from t1;
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1009);
--error ER_DUP_ENTRY
select f2(9) from t1 ;
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1010);
--error ER_DUP_ENTRY
show databases where (f2(10) = 10);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1011);
--error ER_DUP_ENTRY
show tables where (f2(11) = 11);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1012);
--error ER_DUP_ENTRY
show triggers where (f2(12) = 12);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1013);
--error ER_DUP_ENTRY
show table status where (f2(13) = 13);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1014);
--error ER_DUP_ENTRY
show open tables where (f2(14) = 14);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1015);
--error ER_DUP_ENTRY
show columns in mysql.proc where (f2(15) = 15);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1016);
--error ER_DUP_ENTRY
show status where (f2(16) = 16);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1017);
--error ER_DUP_ENTRY
show variables where (f2(17) = 17);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1018);
--error ER_DUP_ENTRY
show charset where (f2(18) = 18);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1019);
--error ER_DUP_ENTRY
show collation where (f2(19) = 19);
select * from t2;
rollback;
select * from t2;
--echo # We need at least one procedure to make sure the WHERE clause is
--echo # evaluated
create procedure dummy() begin end;
insert into t2 (a) values (1020);
--error ER_DUP_ENTRY
show procedure status where (f2(20) = 20);
select * from t2;
rollback;
select * from t2;
drop procedure dummy;
insert into t2 (a) values (1021);
--error ER_DUP_ENTRY
show function status where (f2(21) = 21);
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1022);
prepare stmt from "insert into t1 (a) values (f2(22))";
--error ER_DUP_ENTRY
execute stmt;
select * from t2;
rollback;
select * from t2;
insert into t2 (a) values (1023);
do (f2(23));
select * from t2;
rollback;
select * from t2;
## Please note :
## This will insert a record 1024 in t1 (statement commit)
## This will insert a record 24 in t1 (statement commit)
## then will rollback the second insert only (24) (statement rollback)
## then will rollback the complete transaction (transaction rollback)
delimiter |;
create procedure bug12713_call ()
begin
insert into t2 (a) values (24);
insert into t2 (a) values (24);
end|
delimiter ;|
insert into t2 (a) values (1024);
--error ER_DUP_ENTRY
call bug12713_call();
select * from t2;
rollback;
select * from t2;
--echo =======================================================================
--echo Testing select_to_file
--echo =======================================================================
insert into t2 (a) values (1025);
--replace_result $MYSQLTEST_VARDIR ..
--error ER_DUP_ENTRY
eval select f2(25) into outfile "$MYSQLTEST_VARDIR/tmp/dml.out" from t1;
select * from t2;
rollback;
select * from t2;
--remove_file $MYSQLTEST_VARDIR/tmp/dml.out
insert into t2 (a) values (1026);
--replace_result $MYSQLTEST_VARDIR ..
--error ER_DUP_ENTRY
eval load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=f2(26);
select * from t2;
rollback;
select * from t2;
--echo =======================================================================
--echo Testing select_dumpvar
--echo =======================================================================
insert into t2 (a) values (1027);
--error ER_DUP_ENTRY
select f2(27) into @foo;
select * from t2;
rollback;
select * from t2;
--echo =======================================================================
--echo Testing Select_fetch_into_spvars
--echo =======================================================================
delimiter |;
create procedure bug12713_dump_spvars ()
begin
declare foo int;
declare continue handler for sqlexception
begin
select "Exception trapped";
end;
select f2(28) into foo;
select * from t2;
end|
delimiter ;|
insert into t2 (a) values (1028);
call bug12713_dump_spvars ();
rollback;
select * from t2;
--echo =======================================================================
--echo Cleanup
--echo =======================================================================
set autocommit=default;
drop table t1;
drop table t2;
drop table t3;
drop function f2;
drop procedure bug12713_call;
drop procedure bug12713_dump_spvars;
--echo #
--echo # Bug#12713 Error in a stored function called from a SELECT doesn't
--echo # cause ROLLBACK of statem
--echo #
--echo # Verify that two-phase commit is not issued for read-only
--echo # transactions.
--echo #
--echo # Verify that two-phase commit is issued for read-write transactions,
--echo # even if the change is done inside a stored function called from
--echo # SELECT or SHOW statement.
--echo #
set autocommit=0;
--disable_warnings
drop table if exists t1;
drop table if exists t2;
drop function if exists f1;
drop procedure if exists p_verify_status_increment;
--enable_warnings
set sql_mode=no_engine_substitution;
create table t1 (a int unique);
create table t2 (a int) engine=myisam;
set sql_mode=default;
--echo #
--echo # An auxiliary procedure to track Handler_prepare and Handler_commit
--echo # statistics.
--echo #
delimiter |;
create procedure
p_verify_status_increment(commit_inc_mixed int, prepare_inc_mixed int,
commit_inc_row int, prepare_inc_row int)
begin
declare commit_inc int;
declare prepare_inc int;
declare old_commit_count int default ifnull(@commit_count, 0);
declare old_prepare_count int default ifnull(@prepare_count, 0);
declare c_res int;
# Use a cursor to have just one access to I_S instead of 2, it is very slow
# and amounts for over 90% of test CPU time
declare c cursor for
select variable_value
from information_schema.session_status
where variable_name='Handler_commit' or variable_name='Handler_prepare'
order by variable_name;
if @@global.binlog_format = 'ROW' then
set commit_inc= commit_inc_row;
set prepare_inc= prepare_inc_row;
else
set commit_inc= commit_inc_mixed;
set prepare_inc= prepare_inc_mixed;
end if;
open c;
fetch c into c_res;
set @commit_count=c_res;
fetch c into c_res;
set @prepare_count=c_res;
close c;
if old_commit_count + commit_inc <> @commit_count then
select concat("Expected commit increment: ", commit_inc,
" actual: ", @commit_count - old_commit_count)
as 'ERROR';
elseif old_prepare_count + prepare_inc <> @prepare_count then
select concat("Expected prepare increment: ", prepare_inc,
" actual: ", @prepare_count - old_prepare_count)
as 'ERROR';
else
select '' as 'SUCCESS';
end if;
end|
delimiter ;|
--echo # Reset Handler_commit and Handler_prepare counters
flush status;
--echo #
--echo # 1. Read-only statement: SELECT
--echo #
select * from t1;
call p_verify_status_increment(1, 0, 1, 0);
commit;
call p_verify_status_increment(1, 0, 1, 0);
--echo # 2. Read-write statement: INSERT, insert 1 row.
--echo #
insert into t1 (a) values (1);
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 3. Read-write statement: UPDATE, update 1 row.
--echo #
update t1 set a=2;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 4. Read-write statement: UPDATE, update 0 rows, 1 row matches WHERE
--echo #
--echo # Note the wrong Handler_prepare/Handler_commit count is due to
--echo # Bug#29157 "UPDATE, changed rows incorrect" and
--echo # Bug#Bug #33846 UPDATE word:Wrong 'Changed rows' if InnoDB, unique
--echo # key and no rows qualify WHERE
--echo #
update t1 set a=2;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 5. Read-write statement: UPDATE, update 0 rows, 0 rows match WHERE
--echo #
--echo # In mixed replication mode, there is a read-only transaction
--echo # in InnoDB and also the statement is written to the binary log.
--echo # So we have two commits but no 2pc, since the first engine's
--echo # transaction is read-only.
--echo # In the row level replication mode, we only have the read-only
--echo # transaction in InnoDB and nothing is written to the binary log.
--echo #
update t1 set a=3 where a=1;
call p_verify_status_increment(2, 0, 1, 0);
commit;
call p_verify_status_increment(2, 0, 1, 0);
--echo # 6. Read-write statement: DELETE, delete 0 rows.
--echo #
delete from t1 where a=1;
call p_verify_status_increment(2, 0, 1, 0);
commit;
call p_verify_status_increment(2, 0, 1, 0);
--echo # 7. Read-write statement: DELETE, delete 1 row.
--echo #
delete from t1 where a=2;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 8. Read-write statement: unqualified DELETE
--echo #
--echo # In statement or mixed replication mode, we call
--echo # handler::ha_delete_all_rows() and write statement text
--echo # to the binary log. This results in two read-write transactions.
--echo # In row level replication mode, we do not call
--echo # handler::ha_delete_all_rows(), but delete rows one by one.
--echo # Since there are no rows, nothing is written to the binary log.
--echo # Thus we have just one read-only transaction in InnoDB.
delete from t1;
call p_verify_status_increment(2, 2, 1, 0);
commit;
call p_verify_status_increment(2, 2, 1, 0);
--echo # 9. Read-write statement: REPLACE, change 1 row.
--echo #
replace t1 set a=1;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 10. Read-write statement: REPLACE, change 0 rows.
--echo #
replace t1 set a=1;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 11. Read-write statement: IODKU, change 1 row.
--echo #
insert t1 set a=1 on duplicate key update a=a+1;
call p_verify_status_increment(2, 2, 2, 2);
select * from t1;
call p_verify_status_increment(1, 0, 1, 0);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 12. Read-write statement: IODKU, change 0 rows.
--echo #
insert t1 set a=2 on duplicate key update a=2;
call p_verify_status_increment(1, 0, 1, 0);
commit;
call p_verify_status_increment(1, 0, 1, 0);
--echo # 13. Read-write statement: INSERT IGNORE, change 0 rows.
--echo #
insert ignore t1 set a=2;
call p_verify_status_increment(1, 0, 1, 0);
commit;
call p_verify_status_increment(1, 0, 1, 0);
--echo # 14. Read-write statement: INSERT IGNORE, change 1 row.
--echo #
insert ignore t1 set a=1;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 15. Read-write statement: UPDATE IGNORE, change 0 rows.
--echo #
update ignore t1 set a=2 where a=1;
call p_verify_status_increment(2, 2, 1, 0);
commit;
call p_verify_status_increment(2, 2, 1, 0);
--echo #
--echo # Create a stored function that modifies a
--echo # non-transactional table. Demonstrate that changes in
--echo # non-transactional tables do not affect the two phase commit
--echo # algorithm.
--echo #
delimiter |;
create function f1() returns int
begin
insert t2 set a=2;
return 2;
end|
delimiter ;|
call p_verify_status_increment(0, 0, 0, 0);
--echo # 16. A function changes non-trans-table.
--echo #
select f1();
call p_verify_status_increment(0, 0, 0, 0);
commit;
call p_verify_status_increment(0, 0, 0, 0);
--echo # 17. Read-only statement, a function changes non-trans-table.
--echo #
select f1() from t1;
call p_verify_status_increment(1, 0, 1, 0);
commit;
call p_verify_status_increment(1, 0, 1, 0);
--echo # 18. Read-write statement: UPDATE, change 0 (transactional) rows.
--echo #
select count(*) from t2;
update t1 set a=2 where a=f1()+10;
select count(*) from t2;
call p_verify_status_increment(2, 0, 2, 0);
commit;
call p_verify_status_increment(2, 0, 2, 0);
--echo #
--echo # Replace the non-transactional table with a temporary
--echo # transactional table. Demonstrate that a change to a temporary
--echo # transactional table does not provoke 2-phase commit, although
--echo # does trigger a commit and a binlog write (in statement mode).
--echo #
drop table t2;
set sql_mode=no_engine_substitution;
create temporary table t2 (a int);
call p_verify_status_increment(0, 0, 0, 0);
set sql_mode=default;
--echo # 19. A function changes temp-trans-table.
--echo #
select f1();
--echo # Two commits because a binary log record is written
call p_verify_status_increment(2, 0, 1, 0);
commit;
call p_verify_status_increment(2, 0, 1, 0);
--echo # 20. Read-only statement, a function changes non-trans-table.
--echo #
select f1() from t1;
--echo # Two commits because a binary log record is written
call p_verify_status_increment(2, 0, 1, 0);
commit;
call p_verify_status_increment(2, 0, 1, 0);
--echo # 21. Read-write statement: UPDATE, change 0 (transactional) rows.
--echo #
update t1 set a=2 where a=f1()+10;
call p_verify_status_increment(2, 0, 1, 0);
commit;
call p_verify_status_increment(2, 0, 1, 0);
--echo # 22. DDL: ALTER TEMPORARY TABLE, should not cause a 2pc
--echo #
alter table t2 add column b int default 5;
--echo # A commit is done internally by ALTER.
call p_verify_status_increment(2, 0, 2, 0);
commit;
--echo # There is nothing left to commit
call p_verify_status_increment(0, 0, 0, 0);
--echo # 23. DDL: RENAME TEMPORARY TABLE, does not start a transaction
--echo
--echo # No test because of Bug#8729 "rename table fails on temporary table"
--echo # 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction
--echo
truncate table t2;
call p_verify_status_increment(2, 0, 2, 0);
commit;
--echo # There is nothing left to commit
call p_verify_status_increment(0, 0, 0, 0);
--echo # 25. Read-write statement: unqualified DELETE
--echo
delete from t2;
call p_verify_status_increment(2, 0, 1, 0);
commit;
--echo # There is nothing left to commit
call p_verify_status_increment(2, 0, 1, 0);
--echo # 25. DDL: DROP TEMPORARY TABLE, does not start a transaction
--echo #
drop temporary table t2;
call p_verify_status_increment(0, 0, 0, 0);
commit;
call p_verify_status_increment(0, 0, 0, 0);
--echo # 26. Verify that SET AUTOCOMMIT issues an implicit commit
--echo #
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
set autocommit=1;
call p_verify_status_increment(2, 2, 2, 2);
rollback;
select a from t1 where a=3;
call p_verify_status_increment(1, 0, 1, 0);
delete from t1 where a=3;
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(0, 0, 0, 0);
set autocommit=0;
call p_verify_status_increment(0, 0, 0, 0);
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
--echo # Sic: not actually changing the value of autocommit
set autocommit=0;
call p_verify_status_increment(0, 0, 0, 0);
rollback;
select a from t1 where a=3;
call p_verify_status_increment(1, 0, 1, 0);
--echo # 27. Savepoint management
--echo #
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
savepoint a;
call p_verify_status_increment(0, 0, 0, 0);
insert t1 set a=4;
--echo # Sic: a bug. Binlog did not register itself this time.
call p_verify_status_increment(1, 0, 1, 0);
release savepoint a;
rollback;
call p_verify_status_increment(0, 0, 0, 0);
select a from t1 where a=3;
call p_verify_status_increment(1, 0, 1, 0);
commit;
call p_verify_status_increment(1, 0, 1, 0);
--echo # 28. Read-write statement: DO
--echo #
create table t2 (a int);
call p_verify_status_increment(0, 0, 0, 0);
do (select f1() from t1 where a=2);
call p_verify_status_increment(2, 2, 2, 2);
commit;
call p_verify_status_increment(2, 2, 2, 2);
--echo # 29. Read-write statement: MULTI-DELETE
--echo #
delete t1, t2 from t1 join t2 on (t1.a=t2.a) where t1.a=2;
commit;
call p_verify_status_increment(4, 4, 4, 4);
--echo # 30. Read-write statement: INSERT-SELECT, MULTI-UPDATE, REPLACE-SELECT
--echo #
insert into t2 select a from t1;
commit;
replace into t2 select a from t1;
commit;
call p_verify_status_increment(8, 8, 8, 8);
#
# Multi-update is one of the few remaining statements that still
# locks the tables at prepare step (and hence starts the transaction.
# Disable the PS protocol, since in this protocol we get a different
# number of commmits (there is an extra commit after prepare
#
--disable_ps_protocol
update t1, t2 set t1.a=4, t2.a=8 where t1.a=t2.a and t1.a=1;
--enable_ps_protocol
commit;
call p_verify_status_increment(4, 4, 4, 4);
--echo # 31. DDL: various DDL with transactional tables
--echo #
--echo # Sic: no table is created.
create table if not exists t2 (a int) select 6 union select 7;
--echo # Sic: first commits the statement, and then the transaction.
call p_verify_status_increment(4, 4, 4, 4);
create table t3 select a from t2;
call p_verify_status_increment(4, 4, 4, 4);
alter table t3 add column (b int);
call p_verify_status_increment(2, 0, 2, 0);
alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0);
rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0);
truncate table t3;
call p_verify_status_increment(2, 2, 2, 2);
create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0);
check table t1;
call p_verify_status_increment(3, 0, 3, 0);
--echo # Sic: after this bug is fixed, CHECK leaves no pending transaction
commit;
call p_verify_status_increment(0, 0, 0, 0);
check table t1, t2, t3;
call p_verify_status_increment(6, 0, 6, 0);
commit;
call p_verify_status_increment(0, 0, 0, 0);
drop view v1;
call p_verify_status_increment(0, 0, 0, 0);
--echo #
--echo # Cleanup
--echo #
drop table t1;
drop procedure p_verify_status_increment;
drop function f1;

View File

@ -9,6 +9,10 @@ SHOW CREATE VIEW v1|
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
--echo
SHOW CREATE VIEW v3|
# - Check INFORMATION_SCHEMA; # - Check INFORMATION_SCHEMA;
--echo --echo
@ -20,6 +24,10 @@ SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
--echo
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
# - Execute the views; # - Execute the views;
--echo --echo
@ -30,3 +38,7 @@ SELECT COLLATION(c1), COLLATION(c2) FROM v1|
--echo --echo
SELECT COLLATION(c1) FROM v2| SELECT COLLATION(c1) FROM v2|
--echo
SELECT * FROM v3|

View File

@ -1410,4 +1410,33 @@ SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
DROP TABLE t1; DROP TABLE t1;
#
# Bug#21704: Renaming column does not update FK definition.
#
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings
CREATE TABLE t1(id INT PRIMARY KEY)
ENGINE=innodb;
CREATE TABLE t2(
t1_id INT PRIMARY KEY,
CONSTRAINT fk1 FOREIGN KEY (t1_id) REFERENCES t1(id))
ENGINE=innodb;
--echo
--disable_result_log
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 CHANGE id id2 INT;
--enable_result_log
--echo
DROP TABLE t2;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -27,7 +27,7 @@ explain extended select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" E
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select (case 1 when 1 then _latin1'one' when 2 then _latin1'two' else _latin1'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END` Note 1003 select (case 1 when 1 then 'one' when 2 then 'two' else 'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END`
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END; select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
two two
@ -147,7 +147,7 @@ COALESCE('a' COLLATE latin1_bin,'b');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce(_latin1'a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,_latin1'1') AS `COALESCE(1,'1')`,coalesce(1.1,_latin1'1') AS `COALESCE(1.1,'1')`,coalesce((_latin1'a' collate latin1_bin),_latin1'b') AS `COALESCE('a' COLLATE latin1_bin,'b')` Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce('a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,'1') AS `COALESCE(1,'1')`,coalesce(1.1,'1') AS `COALESCE(1.1,'1')`,coalesce(('a' collate latin1_bin),'b') AS `COALESCE('a' COLLATE latin1_bin,'b')`
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (

View File

@ -0,0 +1,888 @@
set sql_mode=no_engine_substitution;
set storage_engine = InnoDB;
set autocommit=1;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
drop function if exists f2;
drop procedure if exists bug12713_call;
drop procedure if exists bug12713_dump_spvars;
drop procedure if exists dummy;
create table t1 (a int);
create table t2 (a int unique);
create table t3 (a int);
set sql_mode=default;
insert into t1 (a) values (1), (2);
insert into t3 (a) values (1), (2);
create function f2(x int) returns int
begin
insert into t2 (a) values (x);
insert into t2 (a) values (x);
return x;
end|
set autocommit=0;
flush status;
insert into t2 (a) values (1001);
insert into t1 (a) values (f2(1));
ERROR 23000: Duplicate entry '1' for key 'a'
select * from t2;
a
1001
rollback;
select * from t2;
a
insert into t2 (a) values (1002);
insert into t3 (a) select f2(2) from t1;
ERROR 23000: Duplicate entry '2' for key 'a'
select * from t2;
a
1002
rollback;
select * from t2;
a
insert into t2 (a) values (1003);
update t1 set a= a + f2(3);
ERROR 23000: Duplicate entry '3' for key 'a'
select * from t2;
a
1003
rollback;
select * from t2;
a
insert into t2 (a) values (1004);
update t1, t3 set t1.a = 0, t3.a = 0 where (f2(4) = 4) and (t1.a = t3.a);
ERROR 23000: Duplicate entry '4' for key 'a'
select * from t2;
a
1004
rollback;
select * from t2;
a
insert into t2 (a) values (1005);
delete from t1 where (a = f2(5));
ERROR 23000: Duplicate entry '5' for key 'a'
select * from t2;
a
1005
rollback;
select * from t2;
a
insert into t2 (a) values (1006);
delete from t1, t3 using t1, t3 where (f2(6) = 6) ;
ERROR 23000: Duplicate entry '6' for key 'a'
select * from t2;
a
1006
rollback;
select * from t2;
a
insert into t2 (a) values (1007);
replace t1 values (f2(7));
ERROR 23000: Duplicate entry '7' for key 'a'
select * from t2;
a
1007
rollback;
select * from t2;
a
insert into t2 (a) values (1008);
replace into t3 (a) select f2(8) from t1;
ERROR 23000: Duplicate entry '8' for key 'a'
select * from t2;
a
1008
rollback;
select * from t2;
a
insert into t2 (a) values (1009);
select f2(9) from t1 ;
ERROR 23000: Duplicate entry '9' for key 'a'
select * from t2;
a
1009
rollback;
select * from t2;
a
insert into t2 (a) values (1010);
show databases where (f2(10) = 10);
ERROR 23000: Duplicate entry '10' for key 'a'
select * from t2;
a
1010
rollback;
select * from t2;
a
insert into t2 (a) values (1011);
show tables where (f2(11) = 11);
ERROR 23000: Duplicate entry '11' for key 'a'
select * from t2;
a
1011
rollback;
select * from t2;
a
insert into t2 (a) values (1012);
show triggers where (f2(12) = 12);
ERROR 23000: Duplicate entry '12' for key 'a'
select * from t2;
a
1012
rollback;
select * from t2;
a
insert into t2 (a) values (1013);
show table status where (f2(13) = 13);
ERROR 23000: Duplicate entry '13' for key 'a'
select * from t2;
a
1013
rollback;
select * from t2;
a
insert into t2 (a) values (1014);
show open tables where (f2(14) = 14);
ERROR 23000: Duplicate entry '14' for key 'a'
select * from t2;
a
1014
rollback;
select * from t2;
a
insert into t2 (a) values (1015);
show columns in mysql.proc where (f2(15) = 15);
ERROR 23000: Duplicate entry '15' for key 'a'
select * from t2;
a
1015
rollback;
select * from t2;
a
insert into t2 (a) values (1016);
show status where (f2(16) = 16);
ERROR 23000: Duplicate entry '16' for key 'a'
select * from t2;
a
1016
rollback;
select * from t2;
a
insert into t2 (a) values (1017);
show variables where (f2(17) = 17);
ERROR 23000: Duplicate entry '17' for key 'a'
select * from t2;
a
1017
rollback;
select * from t2;
a
insert into t2 (a) values (1018);
show charset where (f2(18) = 18);
ERROR 23000: Duplicate entry '18' for key 'a'
select * from t2;
a
1018
rollback;
select * from t2;
a
insert into t2 (a) values (1019);
show collation where (f2(19) = 19);
ERROR 23000: Duplicate entry '19' for key 'a'
select * from t2;
a
1019
rollback;
select * from t2;
a
# We need at least one procedure to make sure the WHERE clause is
# evaluated
create procedure dummy() begin end;
insert into t2 (a) values (1020);
show procedure status where (f2(20) = 20);
ERROR 23000: Duplicate entry '20' for key 'a'
select * from t2;
a
1020
rollback;
select * from t2;
a
drop procedure dummy;
insert into t2 (a) values (1021);
show function status where (f2(21) = 21);
ERROR 23000: Duplicate entry '21' for key 'a'
select * from t2;
a
1021
rollback;
select * from t2;
a
insert into t2 (a) values (1022);
prepare stmt from "insert into t1 (a) values (f2(22))";
execute stmt;
ERROR 23000: Duplicate entry '22' for key 'a'
select * from t2;
a
1022
rollback;
select * from t2;
a
insert into t2 (a) values (1023);
do (f2(23));
Warnings:
Error 1062 Duplicate entry '23' for key 'a'
select * from t2;
a
1023
rollback;
select * from t2;
a
create procedure bug12713_call ()
begin
insert into t2 (a) values (24);
insert into t2 (a) values (24);
end|
insert into t2 (a) values (1024);
call bug12713_call();
ERROR 23000: Duplicate entry '24' for key 'a'
select * from t2;
a
24
1024
rollback;
select * from t2;
a
=======================================================================
Testing select_to_file
=======================================================================
insert into t2 (a) values (1025);
select f2(25) into outfile "../tmp/dml.out" from t1;
ERROR 23000: Duplicate entry '25' for key 'a'
select * from t2;
a
1025
rollback;
select * from t2;
a
insert into t2 (a) values (1026);
load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=f2(26);
ERROR 23000: Duplicate entry '26' for key 'a'
select * from t2;
a
1026
rollback;
select * from t2;
a
=======================================================================
Testing select_dumpvar
=======================================================================
insert into t2 (a) values (1027);
select f2(27) into @foo;
ERROR 23000: Duplicate entry '27' for key 'a'
select * from t2;
a
1027
rollback;
select * from t2;
a
=======================================================================
Testing Select_fetch_into_spvars
=======================================================================
create procedure bug12713_dump_spvars ()
begin
declare foo int;
declare continue handler for sqlexception
begin
select "Exception trapped";
end;
select f2(28) into foo;
select * from t2;
end|
insert into t2 (a) values (1028);
call bug12713_dump_spvars ();
Exception trapped
Exception trapped
a
1028
rollback;
select * from t2;
a
=======================================================================
Cleanup
=======================================================================
set autocommit=default;
drop table t1;
drop table t2;
drop table t3;
drop function f2;
drop procedure bug12713_call;
drop procedure bug12713_dump_spvars;
#
# Bug#12713 Error in a stored function called from a SELECT doesn't
# cause ROLLBACK of statem
#
# Verify that two-phase commit is not issued for read-only
# transactions.
#
# Verify that two-phase commit is issued for read-write transactions,
# even if the change is done inside a stored function called from
# SELECT or SHOW statement.
#
set autocommit=0;
drop table if exists t1;
drop table if exists t2;
drop function if exists f1;
drop procedure if exists p_verify_status_increment;
set sql_mode=no_engine_substitution;
create table t1 (a int unique);
create table t2 (a int) engine=myisam;
set sql_mode=default;
#
# An auxiliary procedure to track Handler_prepare and Handler_commit
# statistics.
#
create procedure
p_verify_status_increment(commit_inc_mixed int, prepare_inc_mixed int,
commit_inc_row int, prepare_inc_row int)
begin
declare commit_inc int;
declare prepare_inc int;
declare old_commit_count int default ifnull(@commit_count, 0);
declare old_prepare_count int default ifnull(@prepare_count, 0);
declare c_res int;
# Use a cursor to have just one access to I_S instead of 2, it is very slow
# and amounts for over 90% of test CPU time
declare c cursor for
select variable_value
from information_schema.session_status
where variable_name='Handler_commit' or variable_name='Handler_prepare'
order by variable_name;
if @@global.binlog_format = 'ROW' then
set commit_inc= commit_inc_row;
set prepare_inc= prepare_inc_row;
else
set commit_inc= commit_inc_mixed;
set prepare_inc= prepare_inc_mixed;
end if;
open c;
fetch c into c_res;
set @commit_count=c_res;
fetch c into c_res;
set @prepare_count=c_res;
close c;
if old_commit_count + commit_inc <> @commit_count then
select concat("Expected commit increment: ", commit_inc,
" actual: ", @commit_count - old_commit_count)
as 'ERROR';
elseif old_prepare_count + prepare_inc <> @prepare_count then
select concat("Expected prepare increment: ", prepare_inc,
" actual: ", @prepare_count - old_prepare_count)
as 'ERROR';
else
select '' as 'SUCCESS';
end if;
end|
# Reset Handler_commit and Handler_prepare counters
flush status;
#
# 1. Read-only statement: SELECT
#
select * from t1;
a
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
# 2. Read-write statement: INSERT, insert 1 row.
#
insert into t1 (a) values (1);
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 3. Read-write statement: UPDATE, update 1 row.
#
update t1 set a=2;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 4. Read-write statement: UPDATE, update 0 rows, 1 row matches WHERE
#
# Note the wrong Handler_prepare/Handler_commit count is due to
# Bug#29157 "UPDATE, changed rows incorrect" and
# Bug#Bug #33846 UPDATE word:Wrong 'Changed rows' if InnoDB, unique
# key and no rows qualify WHERE
#
update t1 set a=2;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 5. Read-write statement: UPDATE, update 0 rows, 0 rows match WHERE
#
# In mixed replication mode, there is a read-only transaction
# in InnoDB and also the statement is written to the binary log.
# So we have two commits but no 2pc, since the first engine's
# transaction is read-only.
# In the row level replication mode, we only have the read-only
# transaction in InnoDB and nothing is written to the binary log.
#
update t1 set a=3 where a=1;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
# 6. Read-write statement: DELETE, delete 0 rows.
#
delete from t1 where a=1;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
# 7. Read-write statement: DELETE, delete 1 row.
#
delete from t1 where a=2;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 8. Read-write statement: unqualified DELETE
#
# In statement or mixed replication mode, we call
# handler::ha_delete_all_rows() and write statement text
# to the binary log. This results in two read-write transactions.
# In row level replication mode, we do not call
# handler::ha_delete_all_rows(), but delete rows one by one.
# Since there are no rows, nothing is written to the binary log.
# Thus we have just one read-only transaction in InnoDB.
delete from t1;
call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
# 9. Read-write statement: REPLACE, change 1 row.
#
replace t1 set a=1;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 10. Read-write statement: REPLACE, change 0 rows.
#
replace t1 set a=1;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 11. Read-write statement: IODKU, change 1 row.
#
insert t1 set a=1 on duplicate key update a=a+1;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
select * from t1;
a
2
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 12. Read-write statement: IODKU, change 0 rows.
#
insert t1 set a=2 on duplicate key update a=2;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
# 13. Read-write statement: INSERT IGNORE, change 0 rows.
#
insert ignore t1 set a=2;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
# 14. Read-write statement: INSERT IGNORE, change 1 row.
#
insert ignore t1 set a=1;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 15. Read-write statement: UPDATE IGNORE, change 0 rows.
#
update ignore t1 set a=2 where a=1;
call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
#
# Create a stored function that modifies a
# non-transactional table. Demonstrate that changes in
# non-transactional tables do not affect the two phase commit
# algorithm.
#
create function f1() returns int
begin
insert t2 set a=2;
return 2;
end|
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
# 16. A function changes non-trans-table.
#
select f1();
f1()
2
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
commit;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
# 17. Read-only statement, a function changes non-trans-table.
#
select f1() from t1;
f1()
2
2
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
# 18. Read-write statement: UPDATE, change 0 (transactional) rows.
#
select count(*) from t2;
count(*)
3
update t1 set a=2 where a=f1()+10;
select count(*) from t2;
count(*)
5
call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
#
# Replace the non-transactional table with a temporary
# transactional table. Demonstrate that a change to a temporary
# transactional table does not provoke 2-phase commit, although
# does trigger a commit and a binlog write (in statement mode).
#
drop table t2;
set sql_mode=no_engine_substitution;
create temporary table t2 (a int);
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
set sql_mode=default;
# 19. A function changes temp-trans-table.
#
select f1();
f1()
2
# Two commits because a binary log record is written
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
# 20. Read-only statement, a function changes non-trans-table.
#
select f1() from t1;
f1()
2
2
# Two commits because a binary log record is written
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
# 21. Read-write statement: UPDATE, change 0 (transactional) rows.
#
update t1 set a=2 where a=f1()+10;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
# 22. DDL: ALTER TEMPORARY TABLE, should not cause a 2pc
#
alter table t2 add column b int default 5;
# A commit is done internally by ALTER.
call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
commit;
# There is nothing left to commit
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
# 23. DDL: RENAME TEMPORARY TABLE, does not start a transaction
# No test because of Bug#8729 "rename table fails on temporary table"
# 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction
truncate table t2;
call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
commit;
# There is nothing left to commit
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
# 25. Read-write statement: unqualified DELETE
delete from t2;
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
commit;
# There is nothing left to commit
call p_verify_status_increment(2, 0, 1, 0);
SUCCESS
# 25. DDL: DROP TEMPORARY TABLE, does not start a transaction
#
drop temporary table t2;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
commit;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
# 26. Verify that SET AUTOCOMMIT issues an implicit commit
#
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
set autocommit=1;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
rollback;
select a from t1 where a=3;
a
3
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
delete from t1 where a=3;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
set autocommit=0;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# Sic: not actually changing the value of autocommit
set autocommit=0;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
rollback;
select a from t1 where a=3;
a
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
# 27. Savepoint management
#
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
savepoint a;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
insert t1 set a=4;
# Sic: a bug. Binlog did not register itself this time.
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
release savepoint a;
rollback;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
select a from t1 where a=3;
a
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
commit;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
# 28. Read-write statement: DO
#
create table t2 (a int);
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
do (select f1() from t1 where a=2);
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
commit;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
# 29. Read-write statement: MULTI-DELETE
#
delete t1, t2 from t1 join t2 on (t1.a=t2.a) where t1.a=2;
commit;
call p_verify_status_increment(4, 4, 4, 4);
SUCCESS
# 30. Read-write statement: INSERT-SELECT, MULTI-UPDATE, REPLACE-SELECT
#
insert into t2 select a from t1;
commit;
replace into t2 select a from t1;
commit;
call p_verify_status_increment(8, 8, 8, 8);
SUCCESS
update t1, t2 set t1.a=4, t2.a=8 where t1.a=t2.a and t1.a=1;
commit;
call p_verify_status_increment(4, 4, 4, 4);
SUCCESS
# 31. DDL: various DDL with transactional tables
#
# Sic: no table is created.
create table if not exists t2 (a int) select 6 union select 7;
Warnings:
Note 1050 Table 't2' already exists
# Sic: first commits the statement, and then the transaction.
call p_verify_status_increment(4, 4, 4, 4);
SUCCESS
create table t3 select a from t2;
call p_verify_status_increment(4, 4, 4, 4);
SUCCESS
alter table t3 add column (b int);
call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
truncate table t3;
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
call p_verify_status_increment(3, 0, 3, 0);
SUCCESS
# Sic: after this bug is fixed, CHECK leaves no pending transaction
commit;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
check table t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
test.t3 check status OK
call p_verify_status_increment(6, 0, 6, 0);
SUCCESS
commit;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
drop view v1;
call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
#
# Cleanup
#
drop table t1;
drop procedure p_verify_status_increment;
drop function f1;

View File

@ -1511,7 +1511,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087

View File

@ -1789,4 +1789,48 @@ DROP TABLE t2;
# -- End of test case for Bug#21380. # -- End of test case for Bug#21380.
# --
# -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
# --
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
SET sql_mode = NO_ZERO_DATE;
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
ERROR 42000: Invalid default value for 'c2'
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
ERROR 42000: Invalid default value for 'c2'
# -- Check that NULL column still can be created.
CREATE TABLE t2(c1 TIMESTAMP NULL);
# -- Check ALTER TABLE.
ALTER TABLE t1 ADD INDEX(c1);
ERROR 42000: Invalid default value for 'c2'
# -- Check DATETIME.
SET sql_mode = '';
CREATE TABLE t3(c1 DATETIME NOT NULL);
INSERT INTO t3 VALUES (0);
SET sql_mode = TRADITIONAL;
ALTER TABLE t3 ADD INDEX(c1);
ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'c1' at row 1
# -- Cleanup.
SET sql_mode = '';
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
# -- End of Bug#18834.
End of 5.1 tests End of 5.1 tests

View File

@ -519,7 +519,7 @@ explain extended SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select charset(_latin1'a') AS `charset('a')`,collation(_latin1'a') AS `collation('a')`,coercibility(_latin1'a') AS `coercibility('a')`,(_latin1'a' = _latin1'A') AS `'a'='A'` Note 1003 select charset('a') AS `charset('a')`,collation('a') AS `collation('a')`,coercibility('a') AS `coercibility('a')`,('a' = 'A') AS `'a'='A'`
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'collation_client'; SHOW VARIABLES LIKE 'collation_client';
Variable_name Value Variable_name Value

View File

@ -445,7 +445,7 @@ explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM",
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'1 1.1.1.000002') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'1 1.1.1.000002') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")` Note 1003 select makedate(1997,1) AS `makedate(1997,1)`,addtime('31.12.97 11.59.59.999999 PM','1 1.1.1.000002') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime('31.12.97 11.59.59.999999 PM','1 1.1.1.000002') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff('01.01.97 11:59:59.000001 PM','31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date('15-01-2001 12:59:59','%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond('1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")`
create table t1 (d date); create table t1 (d date);
insert into t1 values ('2004-07-14'),('2005-07-14'); insert into t1 values ('2004-07-14'),('2005-07-14');
select date_format(d,"%d") from t1 order by 1; select date_format(d,"%d") from t1 order by 1;

View File

@ -16,25 +16,34 @@ FROM t1|
CREATE VIEW v2 AS SELECT _utf8'ÑеÑ<C2B5>Ñ' as c1| CREATE VIEW v2 AS SELECT _utf8'ÑеÑ<C2B5>Ñ' as c1|
CREATE VIEW v3 AS SELECT _utf8'ÑеÑ<C2B5>Ñ'|
SHOW CREATE VIEW v1| SHOW CREATE VIEW v1|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _koi8r'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_ci
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `c1` koi8r koi8r_general_ci v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `c1` koi8r koi8r_general_ci
SHOW CREATE VIEW v3|
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `ÔÅÓÔ` koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NULL mysqltest1 v1 select 'ÔÅÓÔ' AS `c1`,`mysqltest1`.`t1`.`ËÏÌ` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER koi8r koi8r_general_ci
FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 SELECT 'ÔÅÓÔ' as c1 NONE NO root@localhost DEFINER koi8r koi8r_general_ci NULL mysqltest1 v2 select 'ÔÅÓÔ' AS `c1` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v3 select 'ÔÅÓÔ' AS `ÔÅÓÔ` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1| SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@ -45,6 +54,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1) COLLATION(c1)
utf8_general_ci utf8_general_ci
SELECT * FROM v3|
ÔÅÓÔ
ÔÅÓÔ
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
@ -54,27 +67,35 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci| SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
use mysqltest1| use mysqltest1|
set names koi8r| set names koi8r|
SHOW CREATE VIEW v1| SHOW CREATE VIEW v1|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _koi8r'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_ci
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `c1` koi8r koi8r_general_ci v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `c1` koi8r koi8r_general_ci
SHOW CREATE VIEW v3|
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `ÔÅÓÔ` koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NULL mysqltest1 v1 select 'ÔÅÓÔ' AS `c1`,`mysqltest1`.`t1`.`ËÏÌ` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER koi8r koi8r_general_ci
FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 SELECT 'ÔÅÓÔ' as c1 NONE NO root@localhost DEFINER koi8r koi8r_general_ci NULL mysqltest1 v2 select 'ÔÅÓÔ' AS `c1` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v3 select 'ÔÅÓÔ' AS `ÔÅÓÔ` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1| SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@ -85,6 +106,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1) COLLATION(c1)
utf8_general_ci utf8_general_ci
SELECT * FROM v3|
ÔÅÓÔ
ÔÅÓÔ
---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
@ -99,27 +124,36 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci| SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
use mysqltest1| use mysqltest1|
set names koi8r| set names koi8r|
SHOW CREATE VIEW v1| SHOW CREATE VIEW v1|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _koi8r'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_ci
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `c1` koi8r koi8r_general_ci v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `c1` koi8r koi8r_general_ci
SHOW CREATE VIEW v3|
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select _utf8'ÑеÑ<C2B5>Ñ' AS `ÔÅÓÔ` koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v1 select 'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` NONE YES root@localhost DEFINER koi8r koi8r_general_ci NULL mysqltest1 v1 select 'ÔÅÓÔ' AS `c1`,`mysqltest1`.`t1`.`ËÏÌ` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 select 'ÔÅÓÔ' AS `c1` NONE NO root@localhost DEFINER koi8r koi8r_general_ci NULL mysqltest1 v2 select 'ÔÅÓÔ' AS `c1` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v3 select 'ÔÅÓÔ' AS `ÔÅÓÔ` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1| SELECT COLLATION(c1), COLLATION(c2) FROM v1|
COLLATION(c1) COLLATION(c2) COLLATION(c1) COLLATION(c2)
@ -129,6 +163,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1) COLLATION(c1)
utf8_general_ci utf8_general_ci
SELECT * FROM v3|
ÔÅÓÔ
ÔÅÓÔ
---> connection: default ---> connection: default
use test| use test|
DROP DATABASE mysqltest1| DROP DATABASE mysqltest1|

View File

@ -16,25 +16,34 @@ FROM t1|
CREATE VIEW v2 AS SELECT _koi8r'ÔÅÓÔ' as c1| CREATE VIEW v2 AS SELECT _koi8r'ÔÅÓÔ' as c1|
CREATE VIEW v3 AS SELECT _koi8r'ÔÅÓÔ'|
SHOW CREATE VIEW v1| SHOW CREATE VIEW v1|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _utf8'тест' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select еÑ<C2B5>Ñ' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_ci
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci
SHOW CREATE VIEW v3|
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select _koi8r'ÔÅÓÔ' AS `ÑеÑ<C2B5>Ñ` utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v1 SELECT 'тест' AS c1, кол AS c2 NULL mysqltest1 v1 select 'ÑеÑ<C2B5>Ñ' AS `c1`,`mysqltest1`.`t1`.`кол` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 SELECT 'тест' as c1 NONE NO root@localhost DEFINER utf8 utf8_general_ci NULL mysqltest1 v2 select 'ÑеÑ<C2B5>Ñ' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v3 select 'ÑеÑ<C2B5>Ñ' AS `ÑеÑ<C2B5>Ñ` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1| SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@ -45,6 +54,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1) COLLATION(c1)
koi8r_general_ci koi8r_general_ci
SELECT * FROM v3|
ÑеÑ<EFBFBD>Ñ
ÑеÑ<EFBFBD>Ñ
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
@ -54,27 +67,35 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci| SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
use mysqltest1| use mysqltest1|
set names utf8| set names utf8|
SHOW CREATE VIEW v1| SHOW CREATE VIEW v1|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _utf8'тест' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select еÑ<C2B5>Ñ' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_ci
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci
SHOW CREATE VIEW v3|
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select _koi8r'ÔÅÓÔ' AS `ÑеÑ<C2B5>Ñ` utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v1 SELECT 'тест' AS c1, кол AS c2 NULL mysqltest1 v1 select 'ÑеÑ<C2B5>Ñ' AS `c1`,`mysqltest1`.`t1`.`кол` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 SELECT 'тест' as c1 NONE NO root@localhost DEFINER utf8 utf8_general_ci NULL mysqltest1 v2 select 'ÑеÑ<C2B5>Ñ' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v3 select 'ÑеÑ<C2B5>Ñ' AS `ÑеÑ<C2B5>Ñ` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1| SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@ -85,6 +106,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1) COLLATION(c1)
koi8r_general_ci koi8r_general_ci
SELECT * FROM v3|
ÑеÑ<EFBFBD>Ñ
ÑеÑ<EFBFBD>Ñ
---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
@ -99,27 +124,36 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci| SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
use mysqltest1| use mysqltest1|
set names utf8| set names utf8|
SHOW CREATE VIEW v1| SHOW CREATE VIEW v1|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _utf8'тест' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select еÑ<C2B5>Ñ' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_ci
SHOW CREATE VIEW v2| SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci
SHOW CREATE VIEW v3|
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select _koi8r'ÔÅÓÔ' AS `ÑеÑ<C2B5>Ñ` utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v1 select 'тест' AS `c1`,`t1`.`кол` AS `c2` from `t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci NULL mysqltest1 v1 select 'ÑеÑ<EFBFBD>Ñ' AS `c1`,`mysqltest1`.`t1`.`кол` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 select 'ÑеÑ<C2B5>Ñ' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci NULL mysqltest1 v2 select 'ÑеÑ<C2B5>Ñ' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v3 select 'ÑеÑ<C2B5>Ñ' AS `ÑеÑ<C2B5>Ñ` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1| SELECT COLLATION(c1), COLLATION(c2) FROM v1|
COLLATION(c1) COLLATION(c2) COLLATION(c1) COLLATION(c2)
@ -129,6 +163,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1) COLLATION(c1)
koi8r_general_ci koi8r_general_ci
SELECT * FROM v3|
ÑеÑ<EFBFBD>Ñ
ÑеÑ<EFBFBD>Ñ
---> connection: default ---> connection: default
use test| use test|
DROP DATABASE mysqltest1| DROP DATABASE mysqltest1|

View File

@ -17,7 +17,7 @@ explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 fulltext a a 0 1 100.00 Using where 1 SIMPLE t1 fulltext a a 0 1 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against (_latin1'collections')) Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections'))
select * from t1 where MATCH(a,b) AGAINST ("indexes"); select * from t1 where MATCH(a,b) AGAINST ("indexes");
a b a b
Full-text indexes are called collections Full-text indexes are called collections
@ -87,7 +87,7 @@ explain extended select * from t1 where MATCH(a,b) AGAINST("support -collections
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 fulltext a a 0 1 100.00 Using where 1 SIMPLE t1 fulltext a a 0 1 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against (_latin1'support -collections' in boolean mode)) Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('support -collections' in boolean mode))
select * from t1 where MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE); select * from t1 where MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE);
a b a b
MySQL has now support for full-text search MySQL has now support for full-text search

View File

@ -91,7 +91,7 @@ explain extended select password('idkfa '), old_password('idkfa');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select password(_latin1'idkfa ') AS `password('idkfa ')`,old_password(_latin1'idkfa') AS `old_password('idkfa')` Note 1003 select password('idkfa ') AS `password('idkfa ')`,old_password('idkfa') AS `old_password('idkfa')`
select encrypt('1234','_.'); select encrypt('1234','_.');
encrypt('1234','_.') encrypt('1234','_.')
# #

View File

@ -182,4 +182,4 @@ explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_dec
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select des_decrypt(des_encrypt(_latin1'hello',4),_latin1'password2') AS `des_decrypt(des_encrypt("hello",4),'password2')`,des_decrypt(des_encrypt(_latin1'hello',_latin1'hidden')) AS `des_decrypt(des_encrypt("hello","hidden"))` Note 1003 select des_decrypt(des_encrypt('hello',4),'password2') AS `des_decrypt(des_encrypt("hello",4),'password2')`,des_decrypt(des_encrypt('hello','hidden')) AS `des_decrypt(des_encrypt("hello","hidden"))`

View File

@ -43,7 +43,7 @@ explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using filesort
Warnings: Warnings:
Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like _latin1'%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like '%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary))
select nullif(u, 1) from t1; select nullif(u, 1) from t1;
nullif(u, 1) nullif(u, 1)
NULL NULL

View File

@ -146,7 +146,7 @@ explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (_latin1'a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin)))
drop table t1; drop table t1;
set names utf8; set names utf8;
create table t1 (a char(10) character set utf8 not null); create table t1 (a char(10) character set utf8 not null);

View File

@ -5,12 +5,12 @@ explain extended select * from t1 where a like 'abc%';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index 1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like _latin1'abc%') Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%')
explain extended select * from t1 where a like concat('abc','%'); explain extended select * from t1 where a like concat('abc','%');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index 1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like concat(_latin1'abc',_latin1'%')) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like concat('abc','%'))
select * from t1 where a like "abc%"; select * from t1 where a like "abc%";
a a
abc abc

View File

@ -52,7 +52,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where ('this is a test of some long text to see what happens' regexp _latin1'is a test of some long text to') Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where ('this is a test of some long text to see what happens' regexp 'is a test of some long text to')
select * from t1 where xxx regexp('is a test of some long text to '); select * from t1 where xxx regexp('is a test of some long text to ');
xxx xxx
this is a test of some long text to see what happens this is a test of some long text to see what happens

View File

@ -5,7 +5,7 @@ explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select interval((55,10,20,30,40,50,60,70,80,90,100)) AS `INTERVAL(55,10,20,30,40,50,60,70,80,90,100)`,interval((3,1,(1 + 1),(((1 + 1) + 1) + 1))) AS `interval(3,1,1+1,1+1+1+1)`,field(_latin1'IBM',_latin1'NCA',_latin1'ICL',_latin1'SUN',_latin1'IBM',_latin1'DIGITAL') AS `field("IBM","NCA","ICL","SUN","IBM","DIGITAL")`,field(_latin1'A',_latin1'B',_latin1'C') AS `field("A","B","C")`,elt(2,_latin1'ONE',_latin1'TWO',_latin1'THREE') AS `elt(2,"ONE","TWO","THREE")`,interval((0,1,2,3,4)) AS `interval(0,1,2,3,4)`,(elt(1,1,2,3) | 0) AS `elt(1,1,2,3)|0`,(elt(1,1.1,1.2,1.3) + 0) AS `elt(1,1.1,1.2,1.3)+0` Note 1003 select interval((55,10,20,30,40,50,60,70,80,90,100)) AS `INTERVAL(55,10,20,30,40,50,60,70,80,90,100)`,interval((3,1,(1 + 1),(((1 + 1) + 1) + 1))) AS `interval(3,1,1+1,1+1+1+1)`,field('IBM','NCA','ICL','SUN','IBM','DIGITAL') AS `field("IBM","NCA","ICL","SUN","IBM","DIGITAL")`,field('A','B','C') AS `field("A","B","C")`,elt(2,'ONE','TWO','THREE') AS `elt(2,"ONE","TWO","THREE")`,interval((0,1,2,3,4)) AS `interval(0,1,2,3,4)`,(elt(1,1,2,3) | 0) AS `elt(1,1,2,3)|0`,(elt(1,1.1,1.2,1.3) + 0) AS `elt(1,1.1,1.2,1.3)+0`
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56); SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56);
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56) INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56)
1 1

View File

@ -817,57 +817,57 @@ explain extended select md5('hello');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select md5(_latin1'hello') AS `md5('hello')` Note 1003 select md5('hello') AS `md5('hello')`
explain extended select sha('abc'); explain extended select sha('abc');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select sha(_latin1'abc') AS `sha('abc')` Note 1003 select sha('abc') AS `sha('abc')`
explain extended select sha1('abc'); explain extended select sha1('abc');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select sha(_latin1'abc') AS `sha1('abc')` Note 1003 select sha('abc') AS `sha1('abc')`
explain extended select soundex(''); explain extended select soundex('');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select soundex(_latin1'') AS `soundex('')` Note 1003 select soundex('') AS `soundex('')`
explain extended select 'mood' sounds like 'mud'; explain extended select 'mood' sounds like 'mud';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select (soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'` Note 1003 select (soundex('mood') = soundex('mud')) AS `'mood' sounds like 'mud'`
explain extended select aes_decrypt(aes_encrypt('abc','1'),'1'); explain extended select aes_decrypt(aes_encrypt('abc','1'),'1');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')` Note 1003 select aes_decrypt(aes_encrypt('abc','1'),'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`
explain extended select concat('*',space(5),'*'); explain extended select concat('*',space(5),'*');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')` Note 1003 select concat('*',repeat(' ',5),'*') AS `concat('*',space(5),'*')`
explain extended select reverse('abc'); explain extended select reverse('abc');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select reverse(_latin1'abc') AS `reverse('abc')` Note 1003 select reverse('abc') AS `reverse('abc')`
explain extended select rpad('a',4,'1'); explain extended select rpad('a',4,'1');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')` Note 1003 select rpad('a',4,'1') AS `rpad('a',4,'1')`
explain extended select lpad('a',4,'1'); explain extended select lpad('a',4,'1');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')` Note 1003 select lpad('a',4,'1') AS `lpad('a',4,'1')`
explain extended select concat_ws(',','',NULL,'a'); explain extended select concat_ws(',','',NULL,'a');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')` Note 1003 select concat_ws(',','',NULL,'a') AS `concat_ws(',','',NULL,'a')`
explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c'); explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -882,7 +882,7 @@ explain extended select locate("a","b",2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)` Note 1003 select locate('a','b',2) AS `locate("a","b",2)`
explain extended select format(130,10); explain extended select format(130,10);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -907,7 +907,7 @@ explain extended select binary 'HE';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select cast(_latin1'HE' as char charset binary) AS `binary 'HE'` Note 1003 select cast('HE' as char charset binary) AS `binary 'HE'`
explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' '); explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' ');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -917,7 +917,7 @@ explain extended select FIELD('b' COLLATE latin1_bin,'A','B');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select field((_latin1'b' collate latin1_bin),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')` Note 1003 select field(('b' collate latin1_bin),'A','B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`
explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d'); explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -937,37 +937,37 @@ explain extended select length('\n\t\r\b\0\_\%\\');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')` Note 1003 select length('\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`
explain extended select bit_length('\n\t\r\b\0\_\%\\'); explain extended select bit_length('\n\t\r\b\0\_\%\\');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` Note 1003 select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
explain extended select bit_length('\n\t\r\b\0\_\%\\'); explain extended select bit_length('\n\t\r\b\0\_\%\\');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` Note 1003 select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
explain extended select concat('monty',' was here ','again'); explain extended select concat('monty',' was here ','again');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')` Note 1003 select concat('monty',' was here ','again') AS `concat('monty',' was here ','again')`
explain extended select length('hello'); explain extended select length('hello');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select length(_latin1'hello') AS `length('hello')` Note 1003 select length('hello') AS `length('hello')`
explain extended select char(ascii('h')); explain extended select char(ascii('h'));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select char(ascii(_latin1'h')) AS `char(ascii('h'))` Note 1003 select char(ascii('h')) AS `char(ascii('h'))`
explain extended select ord('h'); explain extended select ord('h');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select ord(_latin1'h') AS `ord('h')` Note 1003 select ord('h') AS `ord('h')`
explain extended select quote(1/0); explain extended select quote(1/0);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -977,17 +977,17 @@ explain extended select crc32("123");
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select crc32(_latin1'123') AS `crc32("123")` Note 1003 select crc32('123') AS `crc32("123")`
explain extended select replace('aaaa','a','b'); explain extended select replace('aaaa','a','b');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')` Note 1003 select replace('aaaa','a','b') AS `replace('aaaa','a','b')`
explain extended select insert('txs',2,1,'hi'); explain extended select insert('txs',2,1,'hi');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')` Note 1003 select insert('txs',2,1,'hi') AS `insert('txs',2,1,'hi')`
explain extended select left(_latin2'a',1); explain extended select left(_latin2'a',1);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -1012,12 +1012,12 @@ explain extended select SUBSTR('abcdefg',3,2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)` Note 1003 select substr('abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`
explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2); explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select substring_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)` Note 1003 select substring_index('1abcd;2abcd;3abcd;4abcd',';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`
explain extended select trim(_latin2' a '); explain extended select trim(_latin2' a ');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -1037,7 +1037,7 @@ explain extended select decode(encode(repeat("a",100000),"monty"),"monty");
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select decode(encode(repeat(_latin1'a',100000),_latin1'monty'),_latin1'monty') AS `decode(encode(repeat("a",100000),"monty"),"monty")` Note 1003 select decode(encode(repeat('a',100000),'monty'),'monty') AS `decode(encode(repeat("a",100000),"monty"),"monty")`
SELECT lpad(12345, 5, "#"); SELECT lpad(12345, 5, "#");
lpad(12345, 5, "#") lpad(12345, 5, "#")
12345 12345
@ -1282,39 +1282,39 @@ EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > _latin1'ab') Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > 'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab'; EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab') Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab'; EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading _latin1'y' from `test`.`t1`.`s`) > _latin1'ab') Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading 'y' from `test`.`t1`.`s`) > 'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab'; EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing _latin1'y' from `test`.`t1`.`s`) > _latin1'ab') Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing 'y' from `test`.`t1`.`s`) > 'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab'; EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab') Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
DROP TABLE t1; DROP TABLE t1;
create table t1(f1 varchar(4)); create table t1(f1 varchar(4));
explain extended select encode(f1,'zxcv') as 'enc' from t1; explain extended select encode(f1,'zxcv') as 'enc' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found 1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select encode('',_latin1'zxcv') AS `enc` from `test`.`t1` Note 1003 select encode('','zxcv') AS `enc` from `test`.`t1`
explain extended select decode(f1,'zxcv') as 'enc' from t1; explain extended select decode(f1,'zxcv') as 'enc' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found 1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select decode('',_latin1'zxcv') AS `enc` from `test`.`t1` Note 1003 select decode('','zxcv') AS `enc` from `test`.`t1`
drop table t1; drop table t1;
create table t1 (a bigint not null)engine=myisam; create table t1 (a bigint not null)engine=myisam;
insert into t1 set a = 1024*1024*1024*4; insert into t1 set a = 1024*1024*1024*4;
@ -1390,7 +1390,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 const PRIMARY PRIMARY 12 const 1 100.00 Using index 1 SIMPLE t2 const PRIMARY PRIMARY 12 const 1 100.00 Using index
1 SIMPLE t1 ref code code 13 const 3 100.00 Using where; Using index 1 SIMPLE t1 ref code code 13 const 3 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5)) Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and (length(`test`.`t1`.`code`) = 5))
DROP TABLE t1,t2; DROP TABLE t1,t2;
select encode(NULL, NULL); select encode(NULL, NULL);
encode(NULL, NULL) encode(NULL, NULL)

View File

@ -839,7 +839,7 @@ explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_d
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select period_add(_latin1'9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,_latin1'9404') AS `period_diff(199505,"9404")`,from_days(to_days(_latin1'960101')) AS `from_days(to_days("960101"))`,dayofmonth(_latin1'1997-01-02') AS `dayofmonth("1997-01-02")`,month(_latin1'1997-01-02') AS `month("1997-01-02")`,monthname(_latin1'1972-03-04') AS `monthname("1972-03-04")`,dayofyear(_latin1'0000-00-00') AS `dayofyear("0000-00-00")`,hour(_latin1'1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute(_latin1'23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week(_latin1'1998-03-03',0) AS `WEEK("1998-03-03")`,yearweek(_latin1'2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year(_latin1'98-02-03') AS `year("98-02-03")`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname(_latin1'1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec(_latin1'0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format(_latin1'1997-01-02 03:04:05',_latin1'%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp(_latin1'1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,(_latin1'1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,(_latin1'1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from _latin1'1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)` Note 1003 select period_add('9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,'9404') AS `period_diff(199505,"9404")`,from_days(to_days('960101')) AS `from_days(to_days("960101"))`,dayofmonth('1997-01-02') AS `dayofmonth("1997-01-02")`,month('1997-01-02') AS `month("1997-01-02")`,monthname('1972-03-04') AS `monthname("1972-03-04")`,dayofyear('0000-00-00') AS `dayofyear("0000-00-00")`,hour('1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute('23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week('1998-03-03',0) AS `WEEK("1998-03-03")`,yearweek('2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year('98-02-03') AS `year("98-02-03")`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname('1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec('0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format('1997-01-02 03:04:05','%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp('1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,('1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,('1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,('1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from '1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,('1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
SET @TMP='2007-08-01 12:22:49'; SET @TMP='2007-08-01 12:22:49';
CREATE TABLE t1 (d DATETIME); CREATE TABLE t1 (d DATETIME);
INSERT INTO t1 VALUES ('2007-08-01 12:22:59'); INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
@ -1069,7 +1069,7 @@ timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` Note 1003 select timestampdiff(WEEK,'2001-02-01','2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,'2001-02-01 12:59:59.120000','2001-05-01 12:58:58.119999') AS `a2`
select time_format('100:00:00', '%H %k %h %I %l'); select time_format('100:00:00', '%H %k %h %I %l');
time_format('100:00:00', '%H %k %h %I %l') time_format('100:00:00', '%H %k %h %I %l')
100 100 04 04 4 100 100 04 04 4

View File

@ -439,12 +439,12 @@ explain extended SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select astext(geometryfromwkb(aswkb(geometryfromtext(_latin1'POINT(1 4)')))) AS `AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))` Note 1003 select astext(geometryfromwkb(aswkb(geometryfromtext('POINT(1 4)')))) AS `AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))`
explain extended SELECT AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)')))); explain extended SELECT AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)'))));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select astext(geometryfromwkb(aswkb(geometryfromtext(_latin1'POINT(1 4)')))) AS `AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)'))))` Note 1003 select astext(geometryfromwkb(aswkb(geometryfromtext('POINT(1 4)')))) AS `AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)'))))`
SELECT SRID(GeomFromText('LineString(1 1,2 2)',101)); SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
SRID(GeomFromText('LineString(1 1,2 2)',101)) SRID(GeomFromText('LineString(1 1,2 2)',101))
101 101
@ -452,7 +452,7 @@ explain extended SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select srid(geometryfromtext(_latin1'LineString(1 1,2 2)',101)) AS `SRID(GeomFromText('LineString(1 1,2 2)',101))` Note 1003 select srid(geometryfromtext('LineString(1 1,2 2)',101)) AS `SRID(GeomFromText('LineString(1 1,2 2)',101))`
explain extended select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimple(Point(3, 6)); explain extended select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimple(Point(3, 6));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used

View File

@ -1562,7 +1562,7 @@ explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 50.78 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 50.78 Using where; Using index
Warnings: Warnings:
Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = _latin1'i121') and (`test`.`t1`.`b` = _latin1'a') and (`test`.`t1`.`a2` >= _latin1'b')) Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b'))
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
@ -1579,7 +1579,7 @@ explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 50.61 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 50.61 Using where; Using index
Warnings: Warnings:
Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = _latin1'i121') and (`test`.`t2`.`b` = _latin1'a') and (`test`.`t2`.`a2` >= _latin1'b')) Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b'))
explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
@ -1808,7 +1808,7 @@ explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
Warnings: Warnings:
Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = _latin1'c') and (`test`.`t1`.`a1` > _latin1'a') and (`test`.`t1`.`a2` > _latin1'a')) Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a'))
explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
@ -1816,7 +1816,7 @@ explain extended select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
Warnings: Warnings:
Note 1003 select (ord(`test`.`t1`.`a1`) + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`)) AS `ord(a1) + count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`a1` > _latin1'a') and (`test`.`t1`.`a2` > _latin1'a')) Note 1003 select (ord(`test`.`t1`.`a1`) + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`)) AS `ord(a1) + count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a'))
select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
count(distinct a1,a2,b) count(distinct a1,a2,b)
4 4
@ -1924,19 +1924,19 @@ where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a1
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (((`test`.`t1`.`a1` = _latin1'b') or (`test`.`t1`.`a1` = _latin1'd') or (`test`.`t1`.`a1` = _latin1'a') or (`test`.`t1`.`a1` = _latin1'c')) and (`test`.`t1`.`a2` > _latin1'a') and (`test`.`t1`.`c` > _latin1'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
explain extended select a1,a2,b,min(c),max(c) from t1 explain extended select a1,a2,b,min(c),max(c) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort 1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = _latin1'b') or (`test`.`t1`.`a1` = _latin1'd') or (`test`.`t1`.`a1` = _latin1'a') or (`test`.`t1`.`a1` = _latin1'c')) and (`test`.`t1`.`a2` > _latin1'a') and (`test`.`t1`.`d` > _latin1'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select a1,a2,b,c from t1 explain extended select a1,a2,b,c from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort 1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`a1` = _latin1'b') or (`test`.`t1`.`a1` = _latin1'd') or (`test`.`t1`.`a1` = _latin1'a') or (`test`.`t1`.`a1` = _latin1'c')) and (`test`.`t1`.`a2` > _latin1'a') and (`test`.`t1`.`d` > _latin1'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
@ -1944,7 +1944,7 @@ explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a'
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` = _latin1'b') or (`test`.`t1`.`a1` = _latin1'd') or (`test`.`t1`.`a1` = _latin1'a') or (`test`.`t1`.`a1` = _latin1'c')) and (`test`.`t1`.`a2` > _latin1'a') and (`test`.`t1`.`c` > _latin1'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
@ -1968,12 +1968,12 @@ explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > _latin1'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
Warnings: Warnings:
Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > _latin1'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select distinct(a1) from t1 where ord(a2) = 98; explain select distinct(a1) from t1 where ord(a2) = 98;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index

View File

@ -387,15 +387,11 @@ show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.views where TABLE_NAME like "v%"; select * from information_schema.views where TABLE_NAME like "v%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL test v0 select schema_name from information_schema.schemata NONE NO root@localhost DEFINER latin1 latin1_swedish_ci NULL test v0 select `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v1 select table_name from information_schema.tables NULL test v1 select `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = 'v1') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
where table_name="v1" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci NULL test v2 select `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = 'v2') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v2 select column_name from information_schema.columns NULL test v3 select `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like 'latin1%') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
where table_name="v2" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci NULL test v4 select `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like 'latin1%') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets
where CHARACTER_SET_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v4 select COLLATION_NAME from information_schema.collations
where COLLATION_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
drop view v0, v1, v2, v3, v4; drop view v0, v1, v2, v3, v4;
create table t1 (a int); create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost; grant select,update,insert on t1 to mysqltest_1@localhost;
@ -488,9 +484,9 @@ create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION; create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views; select * from information_schema.views;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL test v1 select a from t1 with check option CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v2 select a from t1 WITH LOCAL CHECK OPTION LOCAL YES root@localhost DEFINER latin1 latin1_swedish_ci NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v3 select a from t1 WITH CASCADED CHECK OPTION CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
grant select (a) on test.t1 to joe@localhost with grant option; grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES; select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
@ -1175,7 +1171,7 @@ select * from information_schema.views
where table_name='v1' or table_name='v2'; where table_name='v1' or table_name='v2';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci NULL test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci
NULL test v2 select 1 NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci NULL test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci
drop view v1, v2; drop view v1, v2;
drop table t1; drop table t1;
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
@ -1559,8 +1555,7 @@ AS SELECT *
FROM INFORMATION_SCHEMA.TABLES; FROM INFORMATION_SCHEMA.TABLES;
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1';
VIEW_DEFINITION VIEW_DEFINITION
SELECT * select `TABLES`.`TABLE_CATALOG` AS `TABLE_CATALOG`,`TABLES`.`TABLE_SCHEMA` AS `TABLE_SCHEMA`,`TABLES`.`TABLE_NAME` AS `TABLE_NAME`,`TABLES`.`TABLE_TYPE` AS `TABLE_TYPE`,`TABLES`.`ENGINE` AS `ENGINE`,`TABLES`.`VERSION` AS `VERSION`,`TABLES`.`ROW_FORMAT` AS `ROW_FORMAT`,`TABLES`.`TABLE_ROWS` AS `TABLE_ROWS`,`TABLES`.`AVG_ROW_LENGTH` AS `AVG_ROW_LENGTH`,`TABLES`.`DATA_LENGTH` AS `DATA_LENGTH`,`TABLES`.`MAX_DATA_LENGTH` AS `MAX_DATA_LENGTH`,`TABLES`.`INDEX_LENGTH` AS `INDEX_LENGTH`,`TABLES`.`DATA_FREE` AS `DATA_FREE`,`TABLES`.`AUTO_INCREMENT` AS `AUTO_INCREMENT`,`TABLES`.`CREATE_TIME` AS `CREATE_TIME`,`TABLES`.`UPDATE_TIME` AS `UPDATE_TIME`,`TABLES`.`CHECK_TIME` AS `CHECK_TIME`,`TABLES`.`TABLE_COLLATION` AS `TABLE_COLLATION`,`TABLES`.`CHECKSUM` AS `CHECKSUM`,`TABLES`.`CREATE_OPTIONS` AS `CREATE_OPTIONS`,`TABLES`.`TABLE_COMMENT` AS `TABLE_COMMENT` from `INFORMATION_SCHEMA`.`TABLES`
FROM INFORMATION_SCHEMA.TABLES
DROP VIEW v1; DROP VIEW v1;
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME ='information_schema'; WHERE SCHEMA_NAME ='information_schema';

View File

@ -210,7 +210,7 @@ v2
select view_definition from information_schema.views a select view_definition from information_schema.views a
where a.table_name = 'v2'; where a.table_name = 'v2';
view_definition view_definition
select f1 from testdb_1.v1 select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
select view_definition from information_schema.views a select view_definition from information_schema.views a
where a.table_name = 'testdb_1.v1'; where a.table_name = 'testdb_1.v1';
view_definition view_definition

View File

@ -1634,4 +1634,17 @@ vid tid idx name type
3 1 2 c1 NULL 3 1 2 c1 NULL
3 1 1 pk NULL 3 1 1 pk NULL
DROP TABLE t1; DROP TABLE t1;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(id INT PRIMARY KEY)
ENGINE=innodb;
CREATE TABLE t2(
t1_id INT PRIMARY KEY,
CONSTRAINT fk1 FOREIGN KEY (t1_id) REFERENCES t1(id))
ENGINE=innodb;
ALTER TABLE t1 CHANGE id id2 INT;
DROP TABLE t2;
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests

View File

@ -1,3 +1,4 @@
set @@global.concurrent_insert= 0;
drop table if exists t1, t2, t3; drop table if exists t1, t2, t3;
create table t1 (kill_id int); create table t1 (kill_id int);
insert into t1 values(connection_id()); insert into t1 values(connection_id());

View File

@ -2011,7 +2011,7 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 SET collation_connection = latin1_swedish_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */ /*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like 'a%') */
/*!50002 WITH CASCADED CHECK OPTION */; /*!50002 WITH CASCADED CHECK OPTION */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
@ -2182,7 +2182,7 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 SET collation_connection = latin1_swedish_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */ /*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like 'a%') */
/*!50002 WITH CASCADED CHECK OPTION */; /*!50002 WITH CASCADED CHECK OPTION */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
@ -4230,6 +4230,40 @@ LOCK TABLES `test` WRITE;
UNLOCK TABLES; UNLOCK TABLES;
drop database `test-database`; drop database `test-database`;
use test; use test;
# -----------------------------------------------------------------
# -- Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1.
# -----------------------------------------------------------------
DROP DATABASE IF EXISTS mysqldump_test_db;
CREATE DATABASE mysqldump_test_db;
use mysqldump_test_db;
CREATE VIEW v1(x, y) AS SELECT 'a', 'a';
SELECT view_definition
FROM INFORMATION_SCHEMA.VIEWS
WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1';
view_definition
select 'a' AS `x`,'a' AS `y`
---> Dumping mysqldump_test_db to bug30217.sql
DROP DATABASE mysqldump_test_db;
use test;
---> Restoring mysqldump_test_db...
SELECT view_definition
FROM INFORMATION_SCHEMA.VIEWS
WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1';
view_definition
select 'a' AS `x`,'a' AS `y`
DROP DATABASE mysqldump_test_db;
# -- End of test case for Bug#32538.
# #
# End of 5.1 tests # End of 5.1 tests
# #

View File

@ -1505,7 +1505,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087

View File

@ -387,5 +387,5 @@ explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using where; Using index 1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like _latin1'1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` having `test`.`t1`.`a` Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` having `test`.`t1`.`a`
drop table t1; drop table t1;

View File

@ -3,3 +3,10 @@ execute stmt1;
ID USER HOST DB COMMAND TIME STATE INFO ID USER HOST DB COMMAND TIME STATE INFO
number root localhost test Query time executing SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!='Daemon' number root localhost test Query time executing SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!='Daemon'
deallocate prepare stmt1; deallocate prepare stmt1;
FLUSH STATUS;
SHOW GLOBAL STATUS LIKE 'com_select';
Variable_name Value
Com_select 102
SHOW GLOBAL STATUS LIKE 'com_select';
Variable_name Value
Com_select 102

View File

@ -6,7 +6,7 @@ explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnu
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select NULL AS `NULL`,NULL AS `NULL`,isnull(NULL) AS `isnull(null)`,isnull((1 / 0)) AS `isnull(1/0)`,isnull(((1 / 0) = NULL)) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,_latin1'TRUE') AS `ifnull(null,"TRUE")`,ifnull(_latin1'TRUE',_latin1'ERROR') AS `ifnull("TRUE","ERROR")`,isnull((1 / 0)) AS `1/0 is null`,(1 is not null) AS `1 is not null` Note 1003 select NULL AS `NULL`,NULL AS `NULL`,isnull(NULL) AS `isnull(null)`,isnull((1 / 0)) AS `isnull(1/0)`,isnull(((1 / 0) = NULL)) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,'TRUE') AS `ifnull(null,"TRUE")`,ifnull('TRUE','ERROR') AS `ifnull("TRUE","ERROR")`,isnull((1 / 0)) AS `1/0 is null`,(1 is not null) AS `1 is not null`
select 1 | NULL,1 & NULL,1+NULL,1-NULL; select 1 | NULL,1 & NULL,1+NULL,1-NULL;
1 | NULL 1 & NULL 1+NULL 1-NULL 1 | NULL 1 & NULL 1+NULL 1-NULL
NULL NULL NULL NULL NULL NULL NULL NULL
@ -49,7 +49,7 @@ explain extended select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),ine
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select inet_ntoa(NULL) AS `inet_ntoa(null)`,inet_aton(NULL) AS `inet_aton(null)`,inet_aton(_latin1'122.256') AS `inet_aton("122.256")`,inet_aton(_latin1'122.226.') AS `inet_aton("122.226.")`,inet_aton(_latin1'') AS `inet_aton("")` Note 1003 select inet_ntoa(NULL) AS `inet_ntoa(null)`,inet_aton(NULL) AS `inet_aton(null)`,inet_aton('122.256') AS `inet_aton("122.256")`,inet_aton('122.226.') AS `inet_aton("122.226.")`,inet_aton('') AS `inet_aton("")`
create table t1 (x int); create table t1 (x int);
insert into t1 values (null); insert into t1 values (null);
select * from t1 where x != 0; select * from t1 where x != 0;

View File

@ -1733,6 +1733,158 @@ a b
9999999999999999 14632475938453979136 9999999999999999 14632475938453979136
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
drop view if exists v1;
drop table if exists t1;
create table t1 (a int, b int);
insert into t1 values (1,1), (2,2), (3,3);
insert into t1 values (3,1), (1,2), (2,3);
prepare stmt from "create view v1 as select * from t1";
execute stmt;
drop table t1;
create table t1 (a int, b int);
drop view v1;
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` latin1 latin1_swedish_ci
drop view v1;
prepare stmt from "create view v1 (c,d) as select a,b from t1";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d` from `t1` latin1 latin1_swedish_ci
select * from v1;
c d
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d` from `t1` latin1 latin1_swedish_ci
select * from v1;
c d
drop view v1;
prepare stmt from "create view v1 (c) as select b+1 from t1";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci
select * from v1;
c
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci
select * from v1;
c
drop view v1;
prepare stmt from "create view v1 (c,d,e,f) as select a,b,a in (select a+2 from t1), a = all (select a from t1) from t1";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d`,`t1`.`a` in (select (`t1`.`a` + 2) AS `a+2` from `t1`) AS `e`,`t1`.`a` = all (select `t1`.`a` AS `a` from `t1`) AS `f` from `t1` latin1 latin1_swedish_ci
select * from v1;
c d e f
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `c`,`t1`.`b` AS `d`,`t1`.`a` in (select (`t1`.`a` + 2) AS `a+2` from `t1`) AS `e`,`t1`.`a` = all (select `t1`.`a` AS `a` from `t1`) AS `f` from `t1` latin1 latin1_swedish_ci
select * from v1;
c d e f
drop view v1;
prepare stmt from "create or replace view v1 as select 1";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
select * from v1;
1
1
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
select * from v1;
1
1
drop view v1;
prepare stmt from "create view v1 as select 1, 1";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`,1 AS `My_exp_1` latin1 latin1_swedish_ci
select * from v1;
1 My_exp_1
1 1
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`,1 AS `My_exp_1` latin1 latin1_swedish_ci
select * from v1;
1 My_exp_1
1 1
drop view v1;
prepare stmt from "create view v1 (x) as select a from t1 where a > 1";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `x` from `t1` where (`t1`.`a` > 1) latin1 latin1_swedish_ci
select * from v1;
x
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `x` from `t1` where (`t1`.`a` > 1) latin1 latin1_swedish_ci
select * from v1;
x
drop view v1;
prepare stmt from "create view v1 as select * from `t1` `b`";
execute stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `b`.`a` AS `a`,`b`.`b` AS `b` from `t1` `b` latin1 latin1_swedish_ci
select * from v1;
a b
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `b`.`a` AS `a`,`b`.`b` AS `b` from `t1` `b` latin1 latin1_swedish_ci
select * from v1;
a b
drop view v1;
prepare stmt from "create view v1 (a,b,c) as select * from t1";
execute stmt;
ERROR HY000: View's SELECT and view's field list have different column counts
execute stmt;
ERROR HY000: View's SELECT and view's field list have different column counts
deallocate prepare stmt;
drop table t1;
create temporary table t1 (a int, b int);
prepare stmt from "create view v1 as select * from t1";
execute stmt;
ERROR HY000: View's SELECT refers to a temporary table 't1'
execute stmt;
ERROR HY000: View's SELECT refers to a temporary table 't1'
deallocate prepare stmt;
drop table t1;
prepare stmt from "create view v1 as select * from t1";
ERROR 42S02: Table 'test.t1' doesn't exist
prepare stmt from "create view v1 as select * from `t1` `b`";
ERROR 42S02: Table 'test.t1' doesn't exist
End of 5.0 tests. End of 5.0 tests.
create procedure proc_1() reset query cache; create procedure proc_1() reset query cache;
call proc_1(); call proc_1();

View File

@ -1507,7 +1507,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087

View File

@ -1505,7 +1505,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087

View File

@ -1075,7 +1075,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
def VIEWS TABLE_CATALOG TABLE_CATALOG 253 1536 0 Y 0 0 33 def VIEWS TABLE_CATALOG TABLE_CATALOG 253 1536 0 Y 0 0 33
def VIEWS TABLE_SCHEMA TABLE_SCHEMA 253 192 4 N 1 0 33 def VIEWS TABLE_SCHEMA TABLE_SCHEMA 253 192 4 N 1 0 33
def VIEWS TABLE_NAME TABLE_NAME 253 192 2 N 1 0 33 def VIEWS TABLE_NAME TABLE_NAME 253 192 2 N 1 0 33
def VIEWS VIEW_DEFINITION VIEW_DEFINITION 252 589815 8 N 17 0 33 def VIEWS VIEW_DEFINITION VIEW_DEFINITION 252 589815 15 N 17 0 33
def VIEWS CHECK_OPTION CHECK_OPTION 253 24 4 N 1 0 33 def VIEWS CHECK_OPTION CHECK_OPTION 253 24 4 N 1 0 33
def VIEWS IS_UPDATABLE IS_UPDATABLE 253 9 2 N 1 0 33 def VIEWS IS_UPDATABLE IS_UPDATABLE 253 9 2 N 1 0 33
def VIEWS DEFINER DEFINER 253 231 14 N 1 0 33 def VIEWS DEFINER DEFINER 253 231 14 N 1 0 33
@ -1083,7 +1083,7 @@ def VIEWS SECURITY_TYPE SECURITY_TYPE 253 21 7 N 1 0 33
def VIEWS CHARACTER_SET_CLIENT CHARACTER_SET_CLIENT 253 96 6 N 1 0 33 def VIEWS CHARACTER_SET_CLIENT CHARACTER_SET_CLIENT 253 96 6 N 1 0 33
def VIEWS COLLATION_CONNECTION COLLATION_CONNECTION 253 96 6 N 1 0 33 def VIEWS COLLATION_CONNECTION COLLATION_CONNECTION 253 96 6 N 1 0 33
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL test v1 SELECT 1 NONE NO root@localhost DEFINER binary binary NULL test v1 select 1 AS `1` NONE NO root@localhost DEFINER binary binary
---------------------------------------------------------------- ----------------------------------------------------------------
SHOW CREATE PROCEDURE p1; SHOW CREATE PROCEDURE p1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
@ -1404,7 +1404,7 @@ CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT '
set names utf8; set names utf8;
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _koi8r'тест' AS `test` koi8r koi8r_general_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'тест' AS `test` koi8r koi8r_general_ci
SHOW CREATE PROCEDURE p1; SHOW CREATE PROCEDURE p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()

View File

@ -324,29 +324,29 @@ Pos Instruction
0 set str@1 NULL 0 set str@1 NULL
1 set_case_expr (12) 0 i@0 1 set_case_expr (12) 0 i@0
2 jump_if_not 5(12) (case_expr@0 = 1) 2 jump_if_not 5(12) (case_expr@0 = 1)
3 set str@1 _latin1'1' 3 set str@1 '1'
4 jump 12 4 jump 12
5 jump_if_not 8(12) (case_expr@0 = 2) 5 jump_if_not 8(12) (case_expr@0 = 2)
6 set str@1 _latin1'2' 6 set str@1 '2'
7 jump 12 7 jump 12
8 jump_if_not 11(12) (case_expr@0 = 3) 8 jump_if_not 11(12) (case_expr@0 = 3)
9 set str@1 _latin1'3' 9 set str@1 '3'
10 jump 12 10 jump 12
11 set str@1 _latin1'unknown' 11 set str@1 'unknown'
12 stmt 0 "SELECT str" 12 stmt 0 "SELECT str"
SHOW PROCEDURE CODE proc_19194_searched; SHOW PROCEDURE CODE proc_19194_searched;
Pos Instruction Pos Instruction
0 set str@1 NULL 0 set str@1 NULL
1 jump_if_not 4(11) (i@0 = 1) 1 jump_if_not 4(11) (i@0 = 1)
2 set str@1 _latin1'1' 2 set str@1 '1'
3 jump 11 3 jump 11
4 jump_if_not 7(11) (i@0 = 2) 4 jump_if_not 7(11) (i@0 = 2)
5 set str@1 _latin1'2' 5 set str@1 '2'
6 jump 11 6 jump 11
7 jump_if_not 10(11) (i@0 = 3) 7 jump_if_not 10(11) (i@0 = 3)
8 set str@1 _latin1'3' 8 set str@1 '3'
9 jump 11 9 jump 11
10 set str@1 _latin1'unknown' 10 set str@1 'unknown'
11 stmt 0 "SELECT str" 11 stmt 0 "SELECT str"
SHOW PROCEDURE CODE proc_19194_nested_1; SHOW PROCEDURE CODE proc_19194_nested_1;
Pos Instruction Pos Instruction
@ -354,59 +354,59 @@ Pos Instruction
1 set str_j@3 NULL 1 set str_j@3 NULL
2 set_case_expr (27) 0 i@0 2 set_case_expr (27) 0 i@0
3 jump_if_not 6(27) (case_expr@0 = 10) 3 jump_if_not 6(27) (case_expr@0 = 10)
4 set str_i@2 _latin1'10' 4 set str_i@2 '10'
5 jump 27 5 jump 27
6 jump_if_not 20(27) (case_expr@0 = 20) 6 jump_if_not 20(27) (case_expr@0 = 20)
7 set str_i@2 _latin1'20' 7 set str_i@2 '20'
8 jump_if_not 11(18) (j@1 = 1) 8 jump_if_not 11(18) (j@1 = 1)
9 set str_j@3 _latin1'1' 9 set str_j@3 '1'
10 jump 18 10 jump 18
11 jump_if_not 14(18) (j@1 = 2) 11 jump_if_not 14(18) (j@1 = 2)
12 set str_j@3 _latin1'2' 12 set str_j@3 '2'
13 jump 18 13 jump 18
14 jump_if_not 17(18) (j@1 = 3) 14 jump_if_not 17(18) (j@1 = 3)
15 set str_j@3 _latin1'3' 15 set str_j@3 '3'
16 jump 18 16 jump 18
17 set str_j@3 _latin1'unknown' 17 set str_j@3 'unknown'
18 stmt 0 "select "i was 20"" 18 stmt 0 "select "i was 20""
19 jump 27 19 jump 27
20 jump_if_not 23(27) (case_expr@0 = 30) 20 jump_if_not 23(27) (case_expr@0 = 30)
21 set str_i@2 _latin1'30' 21 set str_i@2 '30'
22 jump 27 22 jump 27
23 jump_if_not 26(27) (case_expr@0 = 40) 23 jump_if_not 26(27) (case_expr@0 = 40)
24 set str_i@2 _latin1'40' 24 set str_i@2 '40'
25 jump 27 25 jump 27
26 set str_i@2 _latin1'unknown' 26 set str_i@2 'unknown'
27 stmt 0 "SELECT str_i, str_j" 27 stmt 0 "SELECT str_i, str_j"
SHOW PROCEDURE CODE proc_19194_nested_2; SHOW PROCEDURE CODE proc_19194_nested_2;
Pos Instruction Pos Instruction
0 set str_i@2 NULL 0 set str_i@2 NULL
1 set str_j@3 NULL 1 set str_j@3 NULL
2 jump_if_not 5(27) (i@0 = 10) 2 jump_if_not 5(27) (i@0 = 10)
3 set str_i@2 _latin1'10' 3 set str_i@2 '10'
4 jump 27 4 jump 27
5 jump_if_not 20(27) (i@0 = 20) 5 jump_if_not 20(27) (i@0 = 20)
6 set str_i@2 _latin1'20' 6 set str_i@2 '20'
7 set_case_expr (18) 0 j@1 7 set_case_expr (18) 0 j@1
8 jump_if_not 11(18) (case_expr@0 = 1) 8 jump_if_not 11(18) (case_expr@0 = 1)
9 set str_j@3 _latin1'1' 9 set str_j@3 '1'
10 jump 18 10 jump 18
11 jump_if_not 14(18) (case_expr@0 = 2) 11 jump_if_not 14(18) (case_expr@0 = 2)
12 set str_j@3 _latin1'2' 12 set str_j@3 '2'
13 jump 18 13 jump 18
14 jump_if_not 17(18) (case_expr@0 = 3) 14 jump_if_not 17(18) (case_expr@0 = 3)
15 set str_j@3 _latin1'3' 15 set str_j@3 '3'
16 jump 18 16 jump 18
17 set str_j@3 _latin1'unknown' 17 set str_j@3 'unknown'
18 stmt 0 "select "i was 20"" 18 stmt 0 "select "i was 20""
19 jump 27 19 jump 27
20 jump_if_not 23(27) (i@0 = 30) 20 jump_if_not 23(27) (i@0 = 30)
21 set str_i@2 _latin1'30' 21 set str_i@2 '30'
22 jump 27 22 jump 27
23 jump_if_not 26(27) (i@0 = 40) 23 jump_if_not 26(27) (i@0 = 40)
24 set str_i@2 _latin1'40' 24 set str_i@2 '40'
25 jump 27 25 jump 27
26 set str_i@2 _latin1'unknown' 26 set str_i@2 'unknown'
27 stmt 0 "SELECT str_i, str_j" 27 stmt 0 "SELECT str_i, str_j"
SHOW PROCEDURE CODE proc_19194_nested_3; SHOW PROCEDURE CODE proc_19194_nested_3;
Pos Instruction Pos Instruction
@ -414,59 +414,59 @@ Pos Instruction
1 set str_j@3 NULL 1 set str_j@3 NULL
2 set_case_expr (28) 0 i@0 2 set_case_expr (28) 0 i@0
3 jump_if_not 6(28) (case_expr@0 = 10) 3 jump_if_not 6(28) (case_expr@0 = 10)
4 set str_i@2 _latin1'10' 4 set str_i@2 '10'
5 jump 28 5 jump 28
6 jump_if_not 21(28) (case_expr@0 = 20) 6 jump_if_not 21(28) (case_expr@0 = 20)
7 set str_i@2 _latin1'20' 7 set str_i@2 '20'
8 set_case_expr (19) 1 j@1 8 set_case_expr (19) 1 j@1
9 jump_if_not 12(19) (case_expr@1 = 1) 9 jump_if_not 12(19) (case_expr@1 = 1)
10 set str_j@3 _latin1'1' 10 set str_j@3 '1'
11 jump 19 11 jump 19
12 jump_if_not 15(19) (case_expr@1 = 2) 12 jump_if_not 15(19) (case_expr@1 = 2)
13 set str_j@3 _latin1'2' 13 set str_j@3 '2'
14 jump 19 14 jump 19
15 jump_if_not 18(19) (case_expr@1 = 3) 15 jump_if_not 18(19) (case_expr@1 = 3)
16 set str_j@3 _latin1'3' 16 set str_j@3 '3'
17 jump 19 17 jump 19
18 set str_j@3 _latin1'unknown' 18 set str_j@3 'unknown'
19 stmt 0 "select "i was 20"" 19 stmt 0 "select "i was 20""
20 jump 28 20 jump 28
21 jump_if_not 24(28) (case_expr@0 = 30) 21 jump_if_not 24(28) (case_expr@0 = 30)
22 set str_i@2 _latin1'30' 22 set str_i@2 '30'
23 jump 28 23 jump 28
24 jump_if_not 27(28) (case_expr@0 = 40) 24 jump_if_not 27(28) (case_expr@0 = 40)
25 set str_i@2 _latin1'40' 25 set str_i@2 '40'
26 jump 28 26 jump 28
27 set str_i@2 _latin1'unknown' 27 set str_i@2 'unknown'
28 stmt 0 "SELECT str_i, str_j" 28 stmt 0 "SELECT str_i, str_j"
SHOW PROCEDURE CODE proc_19194_nested_4; SHOW PROCEDURE CODE proc_19194_nested_4;
Pos Instruction Pos Instruction
0 set str_i@2 NULL 0 set str_i@2 NULL
1 set str_j@3 NULL 1 set str_j@3 NULL
2 jump_if_not 5(26) (i@0 = 10) 2 jump_if_not 5(26) (i@0 = 10)
3 set str_i@2 _latin1'10' 3 set str_i@2 '10'
4 jump 26 4 jump 26
5 jump_if_not 19(26) (i@0 = 20) 5 jump_if_not 19(26) (i@0 = 20)
6 set str_i@2 _latin1'20' 6 set str_i@2 '20'
7 jump_if_not 10(17) (j@1 = 1) 7 jump_if_not 10(17) (j@1 = 1)
8 set str_j@3 _latin1'1' 8 set str_j@3 '1'
9 jump 17 9 jump 17
10 jump_if_not 13(17) (j@1 = 2) 10 jump_if_not 13(17) (j@1 = 2)
11 set str_j@3 _latin1'2' 11 set str_j@3 '2'
12 jump 17 12 jump 17
13 jump_if_not 16(17) (j@1 = 3) 13 jump_if_not 16(17) (j@1 = 3)
14 set str_j@3 _latin1'3' 14 set str_j@3 '3'
15 jump 17 15 jump 17
16 set str_j@3 _latin1'unknown' 16 set str_j@3 'unknown'
17 stmt 0 "select "i was 20"" 17 stmt 0 "select "i was 20""
18 jump 26 18 jump 26
19 jump_if_not 22(26) (i@0 = 30) 19 jump_if_not 22(26) (i@0 = 30)
20 set str_i@2 _latin1'30' 20 set str_i@2 '30'
21 jump 26 21 jump 26
22 jump_if_not 25(26) (i@0 = 40) 22 jump_if_not 25(26) (i@0 = 40)
23 set str_i@2 _latin1'40' 23 set str_i@2 '40'
24 jump 26 24 jump 26
25 set str_i@2 _latin1'unknown' 25 set str_i@2 'unknown'
26 stmt 0 "SELECT str_i, str_j" 26 stmt 0 "SELECT str_i, str_j"
CALL proc_19194_nested_1(10, 1); CALL proc_19194_nested_1(10, 1);
str_i str_j str_i str_j
@ -793,7 +793,7 @@ end while;
end// end//
show procedure code proc_33618_h; show procedure code proc_33618_h;
Pos Instruction Pos Instruction
0 set count1@1 _latin1'0' 0 set count1@1 '0'
1 set vb@2 NULL 1 set vb@2 NULL
2 set last_row@3 NULL 2 set last_row@3 NULL
3 jump_if_not 24(24) (num@0 >= 1) 3 jump_if_not 24(24) (num@0 >= 1)
@ -818,7 +818,7 @@ Pos Instruction
22 jump 3 22 jump 3
show procedure code proc_33618_c; show procedure code proc_33618_c;
Pos Instruction Pos Instruction
0 set count1@1 _latin1'0' 0 set count1@1 '0'
1 set vb@2 NULL 1 set vb@2 NULL
2 set last_row@3 NULL 2 set last_row@3 NULL
3 jump_if_not 23(23) (num@0 >= 1) 3 jump_if_not 23(23) (num@0 >= 1)

View File

@ -1508,7 +1508,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087

View File

@ -1511,7 +1511,7 @@ explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
Warnings: Warnings:
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> _latin1'')) Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087

View File

@ -393,13 +393,13 @@ EXPLAIN EXTENDED SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 43 NULL 2 100.00 Using where; Using index 1 SIMPLE t1 index NULL PRIMARY 43 NULL 2 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = _latin1'2002-08-03') Note 1003 select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = '2002-08-03')
EXPLAIN EXTENDED SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); EXPLAIN EXTENDED SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
2 SUBQUERY t1 index NULL PRIMARY 43 NULL 2 100.00 Using where; Using index 2 SUBQUERY t1 index NULL PRIMARY 43 NULL 2 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select (select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = _latin1'2002-08-03')) AS `(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')` Note 1003 select (select distinct `test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = '2002-08-03')) AS `(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')`
SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
date date
2002-08-03 2002-08-03
@ -540,13 +540,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings: Warnings:
Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = _latin1'1') Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index 1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings: Warnings:
Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = _latin1'1')) Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
drop table t1; drop table t1;
CREATE TABLE t1 (a int(1)); CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
@ -1024,7 +1024,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found 1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found
2 UNCACHEABLE SUBQUERY t1 system NULL NULL NULL NULL 0 0.00 const row not found 2 UNCACHEABLE SUBQUERY t1 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select (select encrypt(_latin1'test') AS `ENCRYPT('test')` from `test`.`t1`) AS `(SELECT ENCRYPT('test') FROM t1)` from `test`.`t1` Note 1003 select (select encrypt('test') AS `ENCRYPT('test')` from `test`.`t1`) AS `(SELECT ENCRYPT('test') FROM t1)` from `test`.`t1`
EXPLAIN EXTENDED SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1; EXPLAIN EXTENDED SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found 1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found
@ -1481,7 +1481,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < _latin1'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
drop table t1,t2; drop table t1,t2;
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (a int); create table t3 (a int);
@ -2820,19 +2820,19 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1`
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`)))) Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`))))
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = _latin1'0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1`
DROP TABLE t1,t2; DROP TABLE t1,t2;
CREATE TABLE t1 (a char(5), b char(5)); CREATE TABLE t1 (a char(5), b char(5));
INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa');

View File

@ -112,7 +112,7 @@ v1 CREATE TEMPORARY TABLE `v1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create view v1; show create view v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'This is view' AS `A` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'This is view' AS `A` latin1 latin1_swedish_ci
drop view v1; drop view v1;
select * from v1; select * from v1;
A A

View File

@ -2016,4 +2016,42 @@ i j
10 10 10 10
unlock tables; unlock tables;
drop table t1; drop table t1;
drop table if exists t1, t2;
drop trigger if exists trg1;
drop trigger if exists trg2;
create table t1 (a int);
create table t2 (b int);
create trigger trg1 after update on t1 for each row set @a= @a+1;
create trigger trg2 after update on t2 for each row set @b= @b+1;
insert into t1 values (1), (2), (3);
insert into t2 values (1), (2), (3);
set @a= 0;
set @b= 0;
update t1, t2 set t1.a= t1.a, t2.b= t2.b;
select @a, @b;
@a @b
3 3
update t1, t2 set t1.a= t2.b, t2.b= t1.a;
select @a, @b;
@a @b
6 6
update t1 set a= a;
select @a, @b;
@a @b
9 6
update t2 set b= b;
select @a, @b;
@a @b
9 9
update t1 set a= 1;
select @a, @b;
@a @b
12 9
update t2 set b= 1;
select @a, @b;
@a @b
12 12
drop trigger trg1;
drop trigger trg2;
drop table t1, t2;
End of 5.1 tests. End of 5.1 tests.

View File

@ -519,7 +519,7 @@ coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select charset(load_file(_latin1'MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `charset(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`,collation(load_file(_latin1'MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `collation(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`,coercibility(load_file(_latin1'MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))` Note 1003 select charset(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `charset(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`,collation(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `collation(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`,coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`
update t1 set imagem=load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat') where id=1; update t1 set imagem=load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat') where id=1;
select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1; select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
if(imagem is null, "ERROR", "OK") length(imagem) if(imagem is null, "ERROR", "OK") length(imagem)

View File

@ -0,0 +1,12 @@
set debug= 'T';
select @@debug;
@@debug
T
set debug= '+P';
select @@debug;
@@debug
P:T
set debug= '-P';
select @@debug;
@@debug
T

View File

@ -3061,7 +3061,7 @@ TheEnd
TheEnd TheEnd
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'The\ZEnd' AS `TheEnd` latin1 latin1_swedish_ci
DROP VIEW v1; DROP VIEW v1;
CREATE TABLE t1 (mydate DATETIME); CREATE TABLE t1 (mydate DATETIME);
INSERT INTO t1 VALUES INSERT INTO t1 VALUES
@ -3613,7 +3613,26 @@ ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default val
set @@sql_mode=@old_mode; set @@sql_mode=@old_mode;
drop view v1; drop view v1;
drop table t1; drop table t1;
End of 5.0 tests. # -----------------------------------------------------------------
# -- Bug#34337: Server crash when Altering a view using a table name.
# -----------------------------------------------------------------
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(c1 INT);
SELECT * FROM t1;
c1
ALTER ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW t1 (c2) AS SELECT (1);
ERROR HY000: 'test.t1' is not VIEW
DROP TABLE t1;
# -- End of test case for Bug#34337.
# -----------------------------------------------------------------
# -- End of 5.0 tests.
# -----------------------------------------------------------------
DROP DATABASE IF EXISTS `d-1`; DROP DATABASE IF EXISTS `d-1`;
CREATE DATABASE `d-1`; CREATE DATABASE `d-1`;
USE `d-1`; USE `d-1`;
@ -3676,4 +3695,59 @@ DROP TABLE t1;
# End of test case for Bug#26676. # End of test case for Bug#26676.
End of 5.1 tests. # -----------------------------------------------------------------
# -- Bug#32538: View definition picks up character set, but not collation
# -----------------------------------------------------------------
DROP VIEW IF EXISTS v1;
SET collation_connection = latin1_general_ci;
CREATE VIEW v1 AS SELECT _latin1 'text1' AS c1, 'text2' AS c2;
SELECT COLLATION(c1), COLLATION(c2) FROM v1;
COLLATION(c1) COLLATION(c2)
latin1_swedish_ci latin1_general_ci
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'text1' AS `c1`,'text2' AS `c2` latin1 latin1_general_ci
SELECT * FROM v1 WHERE c1 = 'text1';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin1_general_ci,COERCIBLE) for operation '='
SELECT * FROM v1 WHERE c2 = 'text2';
c1 c2
text1 text2
use test;
SET names latin1;
SELECT COLLATION(c1), COLLATION(c2) FROM v1;
COLLATION(c1) COLLATION(c2)
latin1_swedish_ci latin1_general_ci
SELECT * FROM v1 WHERE c1 = 'text1';
c1 c2
text1 text2
SELECT * FROM v1 WHERE c2 = 'text2';
ERROR HY000: Illegal mix of collations (latin1_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation '='
DROP VIEW v1;
# -- End of test case for Bug#32538.
drop view if exists a;
drop procedure if exists p;
create procedure p()
begin
declare continue handler for sqlexception begin end;
create view a as select 1;
end|
call p();
call p();
drop view a;
drop procedure p;
# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------

View File

@ -469,6 +469,7 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop database mysqltest; drop database mysqltest;
drop view if exists v1; drop view if exists v1;
drop table if exists t1;
create table t1 as select * from mysql.user where user=''; create table t1 as select * from mysql.user where user='';
delete from mysql.user where user=''; delete from mysql.user where user='';
flush privileges; flush privileges;

View File

@ -379,7 +379,7 @@ master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t2)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; DROP TABLE t2 master-bin.000001 # Query # # use `test`; DROP TABLE t2
master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
@ -391,7 +391,7 @@ master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2 master-bin.000001 # Query # # use `test`; TRUNCATE table t2
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */

View File

@ -73,7 +73,7 @@ explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 fulltext a a 0 1 100.00 Using where 1 SIMPLE t1 fulltext a a 0 1 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against (_latin1'collections')) Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections'))
select * from t1 where MATCH(a,b) AGAINST ("indexes"); select * from t1 where MATCH(a,b) AGAINST ("indexes");
a b a b
Full-text indexes are called collections Full-text indexes are called collections

View File

@ -251,7 +251,7 @@ master-bin.000001 # Query # # use `test`; drop table t1,t2
master-bin.000001 # Query # # use `test`; create temporary table ti (a int) engine=innodb master-bin.000001 # Query # # use `test`; create temporary table ti (a int) engine=innodb
master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; insert into ti values(1) master-bin.000001 # Query # # use `test`; insert into ti values(1)
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; create temporary table t1 (a int) engine=myisam master-bin.000001 # Query # # use `test`; create temporary table t1 (a int) engine=myisam
master-bin.000001 # Query # # use `test`; insert t1 values (1) master-bin.000001 # Query # # use `test`; insert t1 values (1)
master-bin.000001 # Query # # use `test`; create table t0 (n int) master-bin.000001 # Query # # use `test`; create table t0 (n int)
@ -358,11 +358,11 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (8,8)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (9,9) master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (9,9)
master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2 master-bin.000001 # Query # # use `test`; TRUNCATE table t2
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (10,10) master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (10,10)
master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (100,100) master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (100,100)
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; DROP TABLE t1,t2 master-bin.000001 # Query # # use `test`; DROP TABLE t1,t2
reset master; reset master;
create table t1 (a int) engine=innodb; create table t1 (a int) engine=innodb;

View File

@ -25,7 +25,7 @@ explain extended select is_free_lock("lock"), is_used_lock("lock");
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select is_free_lock(_latin1'lock') AS `is_free_lock("lock")`,is_used_lock(_latin1'lock') AS `is_used_lock("lock")` Note 1003 select is_free_lock('lock') AS `is_free_lock("lock")`,is_used_lock('lock') AS `is_used_lock("lock")`
select is_free_lock("lock2"); select is_free_lock("lock2");
is_free_lock("lock2") is_free_lock("lock2")
1 1

View File

@ -11,7 +11,7 @@ explain extended select master_pos_wait('master-bin.999999',0,2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select master_pos_wait(_latin1'master-bin.999999',0,2) AS `master_pos_wait('master-bin.999999',0,2)` Note 1003 select master_pos_wait('master-bin.999999',0,2) AS `master_pos_wait('master-bin.999999',0,2)`
select master_pos_wait('master-bin.999999',0); select master_pos_wait('master-bin.999999',0);
stop slave sql_thread; stop slave sql_thread;
master_pos_wait('master-bin.999999',0) master_pos_wait('master-bin.999999',0)

View File

@ -10,6 +10,7 @@
# #
############################################################################## ##############################################################################
rpl_ndb_circular : Bug#33849 COMMIT event missing in cluster circular replication.
rpl_ndb_circular_simplex : Bug#33849 COMMIT event missing in cluster circular replication.
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open

View File

@ -33,3 +33,14 @@ SELECT IS_USED_LOCK('bug31418') = CONNECTION_ID();
--change_user --change_user
SELECT IS_FREE_LOCK('bug31418'); SELECT IS_FREE_LOCK('bug31418');
SELECT IS_USED_LOCK('bug31418'); SELECT IS_USED_LOCK('bug31418');
#
# Bug#31222: com_% global status counters behave randomly with
# mysql_change_user.
#
# Moved to not_embedded_server.test due to Bug#34517: SHOW GLOBAL STATUS does
# not work properly in embedded server.
#
# TODO: move it back when Bug#34517 is fixed (don't forget to add
# --force-restart into change_user-master.opt).
#

View File

@ -0,0 +1,6 @@
-- source include/have_log_bin.inc
-- source include/have_innodb.inc
let $engine_type = InnoDB;
-- source include/commit.inc

View File

@ -1385,4 +1385,68 @@ DROP TABLE t2;
--echo # -- End of test case for Bug#21380. --echo # -- End of test case for Bug#21380.
--echo --echo
--echo # --
--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
--echo # --
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
--enable_warnings
--echo
CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
--echo
SET sql_mode = NO_ZERO_DATE;
--echo
--error ER_INVALID_DEFAULT
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
--echo
--error ER_INVALID_DEFAULT
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
--echo
--echo # -- Check that NULL column still can be created.
CREATE TABLE t2(c1 TIMESTAMP NULL);
--echo
--echo # -- Check ALTER TABLE.
--error ER_INVALID_DEFAULT
ALTER TABLE t1 ADD INDEX(c1);
--echo
--echo # -- Check DATETIME.
SET sql_mode = '';
--echo
CREATE TABLE t3(c1 DATETIME NOT NULL);
INSERT INTO t3 VALUES (0);
--echo
SET sql_mode = TRADITIONAL;
--echo
--error ER_TRUNCATED_WRONG_VALUE
ALTER TABLE t3 ADD INDEX(c1);
--echo
--echo # -- Cleanup.
SET sql_mode = '';
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
--echo
--echo # -- End of Bug#18834.
--echo
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -85,6 +85,10 @@ CREATE VIEW v2 AS SELECT _utf8'тест' as c1|
--echo --echo
CREATE VIEW v3 AS SELECT _utf8'тест'|
--echo
# #
# First-round checks. # First-round checks.
# #
@ -120,6 +124,7 @@ SET @@collation_connection= cp1251_general_ci|
--disable_result_log --disable_result_log
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
--enable_result_log --enable_result_log
use mysqltest1| use mysqltest1|
@ -168,7 +173,7 @@ DROP DATABASE mysqltest1|
--echo --echo
--echo ---> connection: con3 --echo ---> connection: con3
# - Switch environment variables and trigger loading stored procedures; # - Switch environment variables and trigger loading views;
SET @@character_set_client= cp1251| SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251| SET @@character_set_results= cp1251|
@ -177,6 +182,7 @@ SET @@collation_connection= cp1251_general_ci|
--disable_result_log --disable_result_log
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
--enable_result_log --enable_result_log
use mysqltest1| use mysqltest1|

View File

@ -85,6 +85,10 @@ CREATE VIEW v2 AS SELECT _koi8r'
--echo --echo
CREATE VIEW v3 AS SELECT _koi8r'ÔÅÓÔ'|
--echo
# #
# First-round checks. # First-round checks.
# #
@ -120,6 +124,7 @@ SET @@collation_connection= cp1251_general_ci|
--disable_result_log --disable_result_log
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
--enable_result_log --enable_result_log
use mysqltest1| use mysqltest1|
@ -168,7 +173,7 @@ DROP DATABASE mysqltest1|
--echo --echo
--echo ---> connection: con3 --echo ---> connection: con3
# - Switch environment variables and trigger loading stored procedures; # - Switch environment variables and trigger loading views;
SET @@character_set_client= cp1251| SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251| SET @@character_set_results= cp1251|
@ -177,6 +182,7 @@ SET @@collation_connection= cp1251_general_ci|
--disable_result_log --disable_result_log
SELECT * FROM mysqltest1.v1| SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2| SELECT * FROM mysqltest1.v2|
SELECT * FROM mysqltest1.v3|
--enable_result_log --enable_result_log
use mysqltest1| use mysqltest1|

View File

@ -16,11 +16,9 @@ ctype_big5 : BUG#26711 2007-06-21 Lars Test has never worked on Do
federated_transactions : Bug#29523 Transactions do not work federated_transactions : Bug#29523 Transactions do not work
lowercase_table3 : Bug#32667 lowercase_table3.test reports to error log lowercase_table3 : Bug#32667 lowercase_table3.test reports to error log
kill : Bug#29149: Test "kill" fails on Windows
innodb_mysql : Bug#32724: innodb_mysql.test fails randomly innodb_mysql : Bug#32724: innodb_mysql.test fails randomly
wait_timeout : Bug#32801 wait_timeout.test fails randomly wait_timeout : Bug#32801 wait_timeout.test fails randomly
ctype_create : Bug#32965 main.ctype_create fails ctype_create : Bug#32965 main.ctype_create fails
status : Bug#32966 main.status fails status : Bug#32966 main.status fails
ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166 ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
csv_alter_table : Bug#33696 2008-01-21 pcrews no .result file - bug allows NULL columns in CSV tables csv_alter_table : Bug#33696 2008-01-21 pcrews no .result file - bug allows NULL columns in CSV tables
query_cache_debug : Bug#34424: query_cache_debug.test leads to valgrind warnings

View File

@ -6,6 +6,10 @@
# #
-- source include/not_embedded.inc -- source include/not_embedded.inc
# Disable concurrent inserts to avoid test failures when reading the
# connection id which was inserted into a table by another thread.
set @@global.concurrent_insert= 0;
connect (con1, localhost, root,,); connect (con1, localhost, root,,);
connect (con2, localhost, root,,); connect (con2, localhost, root,,);

View File

@ -396,6 +396,9 @@ unlock tables;
connection insert; connection insert;
--reap --reap
connection default; connection default;
let $wait_condition=
select count(*) = 1 from t1;
--source include/wait_condition.inc
select * from t1; select * from t1;
drop table t1; drop table t1;
disconnect flush; disconnect flush;

View File

@ -1 +1 @@
--log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE --log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE

View File

@ -1799,6 +1799,61 @@ create table test (a int);
drop database `test-database`; drop database `test-database`;
use test; use test;
###########################################################################
--echo
--echo # -----------------------------------------------------------------
--echo # -- Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1.
--echo # -----------------------------------------------------------------
--echo
--disable_warnings
DROP DATABASE IF EXISTS mysqldump_test_db;
--enable_warnings
CREATE DATABASE mysqldump_test_db;
use mysqldump_test_db;
--echo
CREATE VIEW v1(x, y) AS SELECT 'a', 'a';
--echo
SELECT view_definition
FROM INFORMATION_SCHEMA.VIEWS
WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1';
--echo
--echo ---> Dumping mysqldump_test_db to bug30217.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30217.sql
--echo
DROP DATABASE mysqldump_test_db;
use test;
--echo
--echo ---> Restoring mysqldump_test_db...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug30217.sql
--echo
SELECT view_definition
FROM INFORMATION_SCHEMA.VIEWS
WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1';
--echo
DROP DATABASE mysqldump_test_db;
--echo
--echo # -- End of test case for Bug#32538.
--echo
###########################################################################
--echo # --echo #
--echo # End of 5.1 tests --echo # End of 5.1 tests

View File

@ -20,4 +20,38 @@ prepare stmt1 from ' SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!
execute stmt1; execute stmt1;
deallocate prepare stmt1; deallocate prepare stmt1;
#
# Bug#31222: com_% global status counters behave randomly with
# mysql_change_user.
#
# Moved from change_user.test due to Bug#34517: SHOW GLOBAL STATUS does not
# work properly in embedded server.
#
# TODO: move it back when Bug#34517 is fixed.
#
FLUSH STATUS;
--disable_result_log
--disable_query_log
let $i = 100;
while ($i)
{
dec $i;
SELECT 1;
}
--enable_query_log
--enable_result_log
SHOW GLOBAL STATUS LIKE 'com_select';
--change_user
SHOW GLOBAL STATUS LIKE 'com_select';
# End of 5.1 tests # End of 5.1 tests

View File

@ -1838,6 +1838,129 @@ select * from t1 where a = @a and b = @b;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
#
# Bug#32890 Crash after repeated create and drop of tables and views
#
--disable_warnings
drop view if exists v1;
drop table if exists t1;
--enable_warnings
create table t1 (a int, b int);
insert into t1 values (1,1), (2,2), (3,3);
insert into t1 values (3,1), (1,2), (2,3);
prepare stmt from "create view v1 as select * from t1";
execute stmt;
drop table t1;
create table t1 (a int, b int);
drop view v1;
execute stmt;
show create view v1;
drop view v1;
prepare stmt from "create view v1 (c,d) as select a,b from t1";
execute stmt;
show create view v1;
select * from v1;
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create view v1 (c) as select b+1 from t1";
execute stmt;
show create view v1;
select * from v1;
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create view v1 (c,d,e,f) as select a,b,a in (select a+2 from t1), a = all (select a from t1) from t1";
execute stmt;
show create view v1;
select * from v1;
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create or replace view v1 as select 1";
execute stmt;
show create view v1;
select * from v1;
execute stmt;
show create view v1;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create view v1 as select 1, 1";
execute stmt;
show create view v1;
select * from v1;
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create view v1 (x) as select a from t1 where a > 1";
execute stmt;
show create view v1;
select * from v1;
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create view v1 as select * from `t1` `b`";
execute stmt;
show create view v1;
select * from v1;
drop view v1;
execute stmt;
deallocate prepare stmt;
show create view v1;
select * from v1;
drop view v1;
prepare stmt from "create view v1 (a,b,c) as select * from t1";
--error ER_VIEW_WRONG_LIST
execute stmt;
--error ER_VIEW_WRONG_LIST
execute stmt;
deallocate prepare stmt;
drop table t1;
create temporary table t1 (a int, b int);
prepare stmt from "create view v1 as select * from t1";
--error ER_VIEW_SELECT_TMPTABLE
execute stmt;
--error ER_VIEW_SELECT_TMPTABLE
execute stmt;
deallocate prepare stmt;
drop table t1;
--error ER_NO_SUCH_TABLE
prepare stmt from "create view v1 as select * from t1";
--error ER_NO_SUCH_TABLE
prepare stmt from "create view v1 as select * from `t1` `b`";
--echo End of 5.0 tests. --echo End of 5.0 tests.
# #

View File

@ -2304,4 +2304,37 @@ unlock tables;
drop table t1; drop table t1;
#
# Bug#23771 AFTER UPDATE trigger not invoked when there are no changes of the data
#
--disable_warnings
drop table if exists t1, t2;
drop trigger if exists trg1;
drop trigger if exists trg2;
--enable_warnings
create table t1 (a int);
create table t2 (b int);
create trigger trg1 after update on t1 for each row set @a= @a+1;
create trigger trg2 after update on t2 for each row set @b= @b+1;
insert into t1 values (1), (2), (3);
insert into t2 values (1), (2), (3);
set @a= 0;
set @b= 0;
update t1, t2 set t1.a= t1.a, t2.b= t2.b;
select @a, @b;
update t1, t2 set t1.a= t2.b, t2.b= t1.a;
select @a, @b;
update t1 set a= a;
select @a, @b;
update t2 set b= b;
select @a, @b;
update t1 set a= 1;
select @a, @b;
update t2 set b= 1;
select @a, @b;
drop trigger trg1;
drop trigger trg2;
drop table t1, t2;
--echo End of 5.1 tests. --echo End of 5.1 tests.

View File

@ -0,0 +1,12 @@
--source include/have_debug.inc
#
# Bug#34678 @@debug variable's incremental mode
#
set debug= 'T';
select @@debug;
set debug= '+P';
select @@debug;
set debug= '-P';
select @@debug;

View File

@ -3468,7 +3468,41 @@ set @@sql_mode=@old_mode;
drop view v1; drop view v1;
drop table t1; drop table t1;
--echo End of 5.0 tests. ###########################################################################
--echo # -----------------------------------------------------------------
--echo # -- Bug#34337: Server crash when Altering a view using a table name.
--echo # -----------------------------------------------------------------
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--echo
CREATE TABLE t1(c1 INT);
--echo
SELECT * FROM t1;
--error ER_WRONG_OBJECT
ALTER ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW t1 (c2) AS SELECT (1);
--echo
DROP TABLE t1;
--echo
--echo # -- End of test case for Bug#34337.
--echo
###########################################################################
--echo # -----------------------------------------------------------------
--echo # -- End of 5.0 tests.
--echo # -----------------------------------------------------------------
# #
# Bug#21370 View renaming lacks tablename_to_filename encoding # Bug#21370 View renaming lacks tablename_to_filename encoding
@ -3540,4 +3574,88 @@ DROP TABLE t1;
--echo # End of test case for Bug#26676. --echo # End of test case for Bug#26676.
--echo --echo
--echo End of 5.1 tests. ###########################################################################
--echo # -----------------------------------------------------------------
--echo # -- Bug#32538: View definition picks up character set, but not collation
--echo # -----------------------------------------------------------------
--echo
--disable_warnings
DROP VIEW IF EXISTS v1;
--enable_warnings
--echo
SET collation_connection = latin1_general_ci;
CREATE VIEW v1 AS SELECT _latin1 'text1' AS c1, 'text2' AS c2;
--echo
SELECT COLLATION(c1), COLLATION(c2) FROM v1;
--echo
SHOW CREATE VIEW v1;
--echo
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT * FROM v1 WHERE c1 = 'text1';
--echo
SELECT * FROM v1 WHERE c2 = 'text2';
--echo
use test;
SET names latin1;
--echo
SELECT COLLATION(c1), COLLATION(c2) FROM v1;
--echo
SELECT * FROM v1 WHERE c1 = 'text1';
--echo
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT * FROM v1 WHERE c2 = 'text2';
--echo
DROP VIEW v1;
--echo
--echo # -- End of test case for Bug#32538.
--echo
#
# Bug#34587 Creating a view inside a stored procedure leads to a server crash
#
--disable_warnings
drop view if exists a;
drop procedure if exists p;
--enable_warnings
delimiter |;
create procedure p()
begin
declare continue handler for sqlexception begin end;
create view a as select 1;
end|
delimiter ;|
call p();
call p();
drop view a;
drop procedure p;
###########################################################################
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------

View File

@ -614,6 +614,7 @@ drop database mysqltest;
# #
--disable_warnings --disable_warnings
drop view if exists v1; drop view if exists v1;
drop table if exists t1;
--enable_warnings --enable_warnings
# Backup anonymous users and remove them. (They get in the way of # Backup anonymous users and remove them. (They get in the way of

View File

@ -332,6 +332,7 @@ void my_thread_end(void)
/* tmp->dbug is allocated inside DBUG library */ /* tmp->dbug is allocated inside DBUG library */
if (tmp->dbug) if (tmp->dbug)
{ {
DBUG_POP();
free(tmp->dbug); free(tmp->dbug);
tmp->dbug=0; tmp->dbug=0;
} }

View File

@ -2736,7 +2736,15 @@ get_info:
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */ if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */
{ {
int error=handle_local_infile(mysql,(char*) pos); int error;
if (!(mysql->options.client_flag & CLIENT_LOCAL_FILES))
{
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
DBUG_RETURN(1);
}
error= handle_local_infile(mysql,(char*) pos);
if ((length= cli_safe_read(mysql)) == packet_error || error) if ((length= cli_safe_read(mysql)) == packet_error || error)
DBUG_RETURN(1); DBUG_RETURN(1);
goto get_info; /* Get info packet */ goto get_info; /* Get info packet */

View File

@ -60,8 +60,16 @@ extern "C" int event_queue_element_compare_q(void *, uchar *, uchar *);
int event_queue_element_compare_q(void *vptr, uchar* a, uchar *b) int event_queue_element_compare_q(void *vptr, uchar* a, uchar *b)
{ {
my_time_t lhs = ((Event_queue_element *)a)->execute_at; Event_queue_element *left = (Event_queue_element *)a;
my_time_t rhs = ((Event_queue_element *)b)->execute_at; Event_queue_element *right = (Event_queue_element *)b;
my_time_t lhs = left->execute_at;
my_time_t rhs = right->execute_at;
if (left->status == Event_queue_element::DISABLED)
return right->status != Event_queue_element::DISABLED;
if (right->status == Event_queue_element::DISABLED)
return 1;
return (lhs < rhs ? -1 : (lhs > rhs ? 1 : 0)); return (lhs < rhs ? -1 : (lhs > rhs ? 1 : 0));
} }
@ -434,8 +442,34 @@ Event_queue::recalculate_activation_times(THD *thd)
((Event_queue_element*)queue_element(&queue, i))->update_timing_fields(thd); ((Event_queue_element*)queue_element(&queue, i))->update_timing_fields(thd);
} }
queue_fix(&queue); queue_fix(&queue);
/*
The disabled elements are moved to the end during the `fix`.
Start from the end and remove all of the elements which are
disabled. When we find the first non-disabled one we break, as we
have removed all. The queue has been ordered in a way the disabled
events are at the end.
*/
for (i= queue.elements; i > 0; i--)
{
Event_queue_element *element = (Event_queue_element*)queue_element(&queue, i - 1);
if (element->status != Event_queue_element::DISABLED)
break;
/*
This won't cause queue re-order, because we remove
always the last element.
*/
queue_remove(&queue, i - 1);
delete element;
}
UNLOCK_QUEUE_DATA(); UNLOCK_QUEUE_DATA();
/*
XXX: The events are dropped only from memory and not from disk
even if `drop_list[j]->dropped` is TRUE. There will be still on the
disk till next server restart.
Please add code here to do it.
*/
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -737,7 +737,7 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
if (protocol->write()) if (protocol->write())
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
send_eof(thd); my_eof(thd);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
@ -1185,7 +1185,12 @@ Events::load_events_from_db(THD *thd)
{ {
/* /*
If not created, a stale event - drop if immediately if If not created, a stale event - drop if immediately if
ON COMPLETION NOT PRESERVE ON COMPLETION NOT PRESERVE.
XXX: This won't be replicated, thus the drop won't appear in
in the slave. When the slave is restarted it will drop events.
However, as the slave will be "out of sync", it might happen that
an event created on the master, after master restart, won't be
replicated to the slave correctly, as the create will fail there.
*/ */
int rc= table->file->ha_delete_row(table->record[0]); int rc= table->file->ha_delete_row(table->record[0]);
if (rc) if (rc)

View File

@ -9454,7 +9454,7 @@ ha_ndbcluster::cond_push(const COND *cond)
my_errno= HA_ERR_OUT_OF_MEM; my_errno= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
DBUG_EXECUTE("where",print_where((COND *)cond, m_tabname);); DBUG_EXECUTE("where",print_where((COND *)cond, m_tabname, QT_ORDINARY););
DBUG_RETURN(m_cond->cond_push(cond, table, (NDBTAB *)m_table)); DBUG_RETURN(m_cond->cond_push(cond, table, (NDBTAB *)m_table));
} }

View File

@ -283,6 +283,7 @@ static void run_query(THD *thd, char *buf, char *end,
thd_ndb->m_error_code, thd_ndb->m_error_code,
(int) thd->is_error(), thd->is_slave_error); (int) thd->is_error(), thd->is_slave_error);
} }
close_thread_tables(thd);
/* /*
XXX: this code is broken. mysql_parse()/mysql_reset_thd_for_next_command() XXX: this code is broken. mysql_parse()/mysql_reset_thd_for_next_command()
can not be called from within a statement, and can not be called from within a statement, and

View File

@ -575,6 +575,295 @@ void ha_close_connection(THD* thd)
/* ======================================================================== /* ========================================================================
======================= TRANSACTIONS ===================================*/ ======================= TRANSACTIONS ===================================*/
/**
Transaction handling in the server
==================================
In each client connection, MySQL maintains two transactional
states:
- a statement transaction,
- a standard, also called normal transaction.
Historical note
---------------
"Statement transaction" is a non-standard term that comes
from the times when MySQL supported BerkeleyDB storage engine.
First of all, it should be said that in BerkeleyDB auto-commit
mode auto-commits operations that are atomic to the storage
engine itself, such as a write of a record, and are too
high-granular to be atomic from the application perspective
(MySQL). One SQL statement could involve many BerkeleyDB
auto-committed operations and thus BerkeleyDB auto-commit was of
little use to MySQL.
Secondly, instead of SQL standard savepoints, BerkeleyDB
provided the concept of "nested transactions". In a nutshell,
transactions could be arbitrarily nested, but when the parent
transaction was committed or aborted, all its child (nested)
transactions were handled committed or aborted as well.
Commit of a nested transaction, in turn, made its changes
visible, but not durable: it destroyed the nested transaction,
all its changes would become available to the parent and
currently active nested transactions of this parent.
So the mechanism of nested transactions was employed to
provide "all or nothing" guarantee of SQL statements
required by the standard.
A nested transaction would be created at start of each SQL
statement, and destroyed (committed or aborted) at statement
end. Such nested transaction was internally referred to as
a "statement transaction" and gave birth to the term.
<Historical note ends>
Since then a statement transaction is started for each statement
that accesses transactional tables or uses the binary log. If
the statement succeeds, the statement transaction is committed.
If the statement fails, the transaction is rolled back. Commits
of statement transactions are not durable -- each such
transaction is nested in the normal transaction, and if the
normal transaction is rolled back, the effects of all enclosed
statement transactions are undone as well. Technically,
a statement transaction can be viewed as a savepoint which is
maintained automatically in order to make effects of one
statement atomic.
The normal transaction is started by the user and is ended
usually upon a user request as well. The normal transaction
encloses transactions of all statements issued between
its beginning and its end.
In autocommit mode, the normal transaction is equivalent
to the statement transaction.
Since MySQL supports PSEA (pluggable storage engine
architecture), more than one transactional engine can be
active at a time. Hence transactions, from the server
point of view, are always distributed. In particular,
transactional state is maintained independently for each
engine. In order to commit a transaction the two phase
commit protocol is employed.
Not all statements are executed in context of a transaction.
Administrative and status information statements do not modify
engine data, and thus do not start a statement transaction and
also have no effect on the normal transaction. Examples of such
statements are SHOW STATUS and RESET SLAVE.
Similarly DDL statements are not transactional,
and therefore a transaction is [almost] never started for a DDL
statement. The difference between a DDL statement and a purely
administrative statement though is that a DDL statement always
commits the current transaction before proceeding, if there is
any.
At last, SQL statements that work with non-transactional
engines also have no effect on the transaction state of the
connection. Even though they are written to the binary log,
and the binary log is, overall, transactional, the writes
are done in "write-through" mode, directly to the binlog
file, followed with a OS cache sync, in other words,
bypassing the binlog undo log (translog).
They do not commit the current normal transaction.
A failure of a statement that uses non-transactional tables
would cause a rollback of the statement transaction, but
in case there no non-transactional tables are used,
no statement transaction is started.
Data layout
-----------
The server stores its transaction-related data in
thd->transaction. This structure has two members of type
THD_TRANS. These members correspond to the statement and
normal transactions respectively:
- thd->transaction.stmt contains a list of engines
that are participating in the given statement
- thd->transaction.all contains a list of engines that
have participated in any of the statement transactions started
within the context of the normal transaction.
Each element of the list contains a pointer to the storage
engine, engine-specific transactional data, and engine-specific
transaction flags.
In autocommit mode thd->transaction.all is empty.
Instead, data of thd->transaction.stmt is
used to commit/rollback the normal transaction.
The list of registered engines has a few important properties:
- no engine is registered in the list twice
- engines are present in the list a reverse temporal order --
new participants are always added to the beginning of the list.
Transaction life cycle
----------------------
When a new connection is established, thd->transaction
members are initialized to an empty state.
If a statement uses any tables, all affected engines
are registered in the statement engine list. In
non-autocommit mode, the same engines are registered in
the normal transaction list.
At the end of the statement, the server issues a commit
or a roll back for all engines in the statement list.
At this point transaction flags of an engine, if any, are
propagated from the statement list to the list of the normal
transaction.
When commit/rollback is finished, the statement list is
cleared. It will be filled in again by the next statement,
and emptied again at the next statement's end.
The normal transaction is committed in a similar way
(by going over all engines in thd->transaction.all list)
but at different times:
- upon COMMIT SQL statement is issued by the user
- implicitly, by the server, at the beginning of a DDL statement
or SET AUTOCOMMIT={0|1} statement.
The normal transaction can be rolled back as well:
- if the user has requested so, by issuing ROLLBACK SQL
statement
- if one of the storage engines requested a rollback
by setting thd->transaction_rollback_request. This may
happen in case, e.g., when the transaction in the engine was
chosen a victim of the internal deadlock resolution algorithm
and rolled back internally. When such a situation happens, there
is little the server can do and the only option is to rollback
transactions in all other participating engines. In this case
the rollback is accompanied by an error sent to the user.
As follows from the use cases above, the normal transaction
is never committed when there is an outstanding statement
transaction. In most cases there is no conflict, since
commits of the normal transaction are issued by a stand-alone
administrative or DDL statement, thus no outstanding statement
transaction of the previous statement exists. Besides,
all statements that manipulate with the normal transaction
are prohibited in stored functions and triggers, therefore
no conflicting situation can occur in a sub-statement either.
The remaining rare cases when the server explicitly has
to commit the statement transaction prior to committing the normal
one cover error-handling scenarios (see for example
SQLCOM_LOCK_TABLES).
When committing a statement or a normal transaction, the server
either uses the two-phase commit protocol, or issues a commit
in each engine independently. The two-phase commit protocol
is used only if:
- all participating engines support two-phase commit (provide
handlerton::prepare PSEA API call) and
- transactions in at least two engines modify data (i.e. are
not read-only).
Note that the two phase commit is used for
statement transactions, even though they are not durable anyway.
This is done to ensure logical consistency of data in a multiple-
engine transaction.
For example, imagine that some day MySQL supports unique
constraint checks deferred till the end of statement. In such
case a commit in one of the engines may yield ER_DUP_KEY,
and MySQL should be able to gracefully abort statement
transactions of other participants.
After the normal transaction has been committed,
thd->transaction.all list is cleared.
When a connection is closed, the current normal transaction, if
any, is rolled back.
Roles and responsibilities
--------------------------
The server has no way to know that an engine participates in
the statement and a transaction has been started
in it unless the engine says so. Thus, in order to be
a part of a transaction, the engine must "register" itself.
This is done by invoking trans_register_ha() server call.
Normally the engine registers itself whenever handler::external_lock()
is called. trans_register_ha() can be invoked many times: if
an engine is already registered, the call does nothing.
In case autocommit is not set, the engine must register itself
twice -- both in the statement list and in the normal transaction
list.
In which list to register is a parameter of trans_register_ha().
Note, that although the registration interface in itself is
fairly clear, the current usage practice often leads to undesired
effects. E.g. since a call to trans_register_ha() in most engines
is embedded into implementation of handler::external_lock(), some
DDL statements start a transaction (at least from the server
point of view) even though they are not expected to. E.g.
CREATE TABLE does not start a transaction, since
handler::external_lock() is never called during CREATE TABLE. But
CREATE TABLE ... SELECT does, since handler::external_lock() is
called for the table that is being selected from. This has no
practical effects currently, but must be kept in mind
nevertheless.
Once an engine is registered, the server will do the rest
of the work.
During statement execution, whenever any of data-modifying
PSEA API methods is used, e.g. handler::write_row() or
handler::update_row(), the read-write flag is raised in the
statement transaction for the involved engine.
Currently All PSEA calls are "traced", and the data can not be
changed in a way other than issuing a PSEA call. Important:
unless this invariant is preserved the server will not know that
a transaction in a given engine is read-write and will not
involve the two-phase commit protocol!
At the end of a statement, server call
ha_autocommit_or_rollback() is invoked. This call in turn
invokes handlerton::prepare() for every involved engine.
Prepare is followed by a call to handlerton::commit_one_phase()
If a one-phase commit will suffice, handlerton::prepare() is not
invoked and the server only calls handlerton::commit_one_phase().
At statement commit, the statement-related read-write engine
flag is propagated to the corresponding flag in the normal
transaction. When the commit is complete, the list of registered
engines is cleared.
Rollback is handled in a similar fashion.
Additional notes on DDL and the normal transaction.
---------------------------------------------------
DDLs and operations with non-transactional engines
do not "register" in thd->transaction lists, and thus do not
modify the transaction state. Besides, each DDL in
MySQL is prefixed with an implicit normal transaction commit
(a call to end_active_trans()), and thus leaves nothing
to modify.
However, as it has been pointed out with CREATE TABLE .. SELECT,
some DDL statements can start a *new* transaction.
Behaviour of the server in this case is currently badly
defined.
DDL statements use a form of "semantic" logging
to maintain atomicity: if CREATE TABLE .. SELECT failed,
the newly created table is deleted.
In addition, some DDL statements issue interim transaction
commits: e.g. ALTER TABLE issues a commit after data is copied
from the original table to the internal temporary table. Other
statements, e.g. CREATE TABLE ... SELECT do not always commit
after itself.
And finally there is a group of DDL statements such as
RENAME/DROP TABLE that doesn't start a new transaction
and doesn't commit.
This diversity makes it hard to say what will happen if
by chance a stored function is invoked during a DDL --
whether any modifications it makes will be committed or not
is not clear. Fortunately, SQL grammar of few DDLs allows
invocation of a stored function.
A consistent behaviour is perhaps to always commit the normal
transaction after all DDLs, just like the statement transaction
is always committed at the end of all statements.
*/
/** /**
Register a storage engine for a transaction. Register a storage engine for a transaction.
@ -592,7 +881,7 @@ void ha_close_connection(THD* thd)
void trans_register_ha(THD *thd, bool all, handlerton *ht_arg) void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
{ {
THD_TRANS *trans; THD_TRANS *trans;
handlerton **ht; Ha_trx_info *ha_info;
DBUG_ENTER("trans_register_ha"); DBUG_ENTER("trans_register_ha");
DBUG_PRINT("enter",("%s", all ? "all" : "stmt")); DBUG_PRINT("enter",("%s", all ? "all" : "stmt"));
@ -604,12 +893,13 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
else else
trans= &thd->transaction.stmt; trans= &thd->transaction.stmt;
for (ht=trans->ht; *ht; ht++) ha_info= thd->ha_data[ht_arg->slot].ha_info + static_cast<unsigned>(all);
if (*ht == ht_arg)
if (ha_info->is_started())
DBUG_VOID_RETURN; /* already registered, return */ DBUG_VOID_RETURN; /* already registered, return */
trans->ht[trans->nht++]=ht_arg; ha_info->register_ha(trans, ht_arg);
DBUG_ASSERT(*ht == ht_arg);
trans->no_2pc|=(ht_arg->prepare==0); trans->no_2pc|=(ht_arg->prepare==0);
if (thd->transaction.xid_state.xid.is_null()) if (thd->transaction.xid_state.xid.is_null())
thd->transaction.xid_state.xid.set(thd->query_id); thd->transaction.xid_state.xid.set(thd->query_id);
@ -626,18 +916,19 @@ int ha_prepare(THD *thd)
{ {
int error=0, all=1; int error=0, all=1;
THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
handlerton **ht=trans->ht; Ha_trx_info *ha_info= trans->ha_list;
DBUG_ENTER("ha_prepare"); DBUG_ENTER("ha_prepare");
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (trans->nht) if (ha_info)
{ {
for (; *ht; ht++) for (; ha_info; ha_info= ha_info->next())
{ {
int err; int err;
handlerton *ht= ha_info->ht();
status_var_increment(thd->status_var.ha_prepare_count); status_var_increment(thd->status_var.ha_prepare_count);
if ((*ht)->prepare) if (ht->prepare)
{ {
if ((err= (*(*ht)->prepare)(*ht, thd, all))) if ((err= ht->prepare(ht, thd, all)))
{ {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
ha_rollback_trans(thd, all); ha_rollback_trans(thd, all);
@ -649,7 +940,7 @@ int ha_prepare(THD *thd)
{ {
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
ha_resolve_storage_engine_name(*ht)); ha_resolve_storage_engine_name(ht));
} }
} }
} }
@ -657,6 +948,62 @@ int ha_prepare(THD *thd)
DBUG_RETURN(error); DBUG_RETURN(error);
} }
/**
Check if we can skip the two-phase commit.
A helper function to evaluate if two-phase commit is mandatory.
As a side effect, propagates the read-only/read-write flags
of the statement transaction to its enclosing normal transaction.
@retval TRUE we must run a two-phase commit. Returned
if we have at least two engines with read-write changes.
@retval FALSE Don't need two-phase commit. Even if we have two
transactional engines, we can run two independent
commits if changes in one of the engines are read-only.
*/
static
bool
ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list,
bool all)
{
/* The number of storage engines that have actual changes. */
unsigned rw_ha_count= 0;
Ha_trx_info *ha_info;
for (ha_info= ha_list; ha_info; ha_info= ha_info->next())
{
if (ha_info->is_trx_read_write())
++rw_ha_count;
if (! all)
{
Ha_trx_info *ha_info_all= &thd->ha_data[ha_info->ht()->slot].ha_info[1];
DBUG_ASSERT(ha_info != ha_info_all);
/*
Merge read-only/read-write information about statement
transaction to its enclosing normal transaction. Do this
only if in a real transaction -- that is, if we know
that ha_info_all is registered in thd->transaction.all.
Since otherwise we only clutter the normal transaction flags.
*/
if (ha_info_all->is_started()) /* FALSE if autocommit. */
ha_info_all->coalesce_trx_with(ha_info);
}
else if (rw_ha_count > 1)
{
/*
It is a normal transaction, so we don't need to merge read/write
information up, and the need for two-phase commit has been
already established. Break the loop prematurely.
*/
break;
}
}
return rw_ha_count > 1;
}
/** /**
@retval @retval
0 ok 0 ok
@ -674,12 +1021,25 @@ int ha_prepare(THD *thd)
int ha_commit_trans(THD *thd, bool all) int ha_commit_trans(THD *thd, bool all)
{ {
int error= 0, cookie= 0; int error= 0, cookie= 0;
/*
'all' means that this is either an explicit commit issued by
user, or an implicit commit issued by a DDL.
*/
THD_TRANS *trans= all ? &thd->transaction.all : &thd->transaction.stmt; THD_TRANS *trans= all ? &thd->transaction.all : &thd->transaction.stmt;
bool is_real_trans= all || thd->transaction.all.nht == 0; bool is_real_trans= all || thd->transaction.all.ha_list == 0;
handlerton **ht= trans->ht; Ha_trx_info *ha_info= trans->ha_list;
my_xid xid= thd->transaction.xid_state.xid.get_my_xid(); my_xid xid= thd->transaction.xid_state.xid.get_my_xid();
DBUG_ENTER("ha_commit_trans"); DBUG_ENTER("ha_commit_trans");
/*
We must not commit the normal transaction if a statement
transaction is pending. Otherwise statement transaction
flags will not get propagated to its normal transaction's
counterpart.
*/
DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL ||
trans == &thd->transaction.stmt);
if (thd->in_sub_stmt) if (thd->in_sub_stmt)
{ {
/* /*
@ -701,8 +1061,10 @@ int ha_commit_trans(THD *thd, bool all)
DBUG_RETURN(2); DBUG_RETURN(2);
} }
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (trans->nht) if (ha_info)
{ {
bool must_2pc;
if (is_real_trans && wait_if_global_read_lock(thd, 0, 0)) if (is_real_trans && wait_if_global_read_lock(thd, 0, 0))
{ {
ha_rollback_trans(thd, all); ha_rollback_trans(thd, all);
@ -727,12 +1089,26 @@ int ha_commit_trans(THD *thd, bool all)
if (is_real_trans) /* not a statement commit */ if (is_real_trans) /* not a statement commit */
thd->stmt_map.close_transient_cursors(); thd->stmt_map.close_transient_cursors();
if (!trans->no_2pc && trans->nht > 1) must_2pc= ha_check_and_coalesce_trx_read_only(thd, ha_info, all);
if (!trans->no_2pc && must_2pc)
{ {
for (; *ht && !error; ht++) for (; ha_info && !error; ha_info= ha_info->next())
{ {
int err; int err;
if ((err= (*(*ht)->prepare)(*ht, thd, all))) handlerton *ht= ha_info->ht();
/*
Do not call two-phase commit if this particular
transaction is read-only. This allows for simpler
implementation in engines that are always read-only.
*/
if (! ha_info->is_trx_read_write())
continue;
/*
Sic: we know that prepare() is not NULL since otherwise
trans->no_2pc would have been set.
*/
if ((err= ht->prepare(ht, thd, all)))
{ {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error= 1; error= 1;
@ -770,24 +1146,26 @@ int ha_commit_one_phase(THD *thd, bool all)
{ {
int error=0; int error=0;
THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
bool is_real_trans=all || thd->transaction.all.nht == 0; bool is_real_trans=all || thd->transaction.all.ha_list == 0;
handlerton **ht=trans->ht; Ha_trx_info *ha_info= trans->ha_list, *ha_info_next;
DBUG_ENTER("ha_commit_one_phase"); DBUG_ENTER("ha_commit_one_phase");
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (trans->nht) if (ha_info)
{ {
for (ht=trans->ht; *ht; ht++) for (; ha_info; ha_info= ha_info_next)
{ {
int err; int err;
if ((err= (*(*ht)->commit)(*ht, thd, all))) handlerton *ht= ha_info->ht();
if ((err= ht->commit(ht, thd, all)))
{ {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error=1; error=1;
} }
status_var_increment(thd->status_var.ha_commit_count); status_var_increment(thd->status_var.ha_commit_count);
*ht= 0; ha_info_next= ha_info->next();
ha_info->reset(); /* keep it conveniently zero-filled */
} }
trans->nht=0; trans->ha_list= 0;
trans->no_2pc=0; trans->no_2pc=0;
if (is_real_trans) if (is_real_trans)
thd->transaction.xid_state.xid.null(); thd->transaction.xid_state.xid.null();
@ -810,8 +1188,17 @@ int ha_rollback_trans(THD *thd, bool all)
{ {
int error=0; int error=0;
THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
bool is_real_trans=all || thd->transaction.all.nht == 0; Ha_trx_info *ha_info= trans->ha_list, *ha_info_next;
bool is_real_trans=all || thd->transaction.all.ha_list == 0;
DBUG_ENTER("ha_rollback_trans"); DBUG_ENTER("ha_rollback_trans");
/*
We must not rollback the normal transaction if a statement
transaction is pending.
*/
DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL ||
trans == &thd->transaction.stmt);
if (thd->in_sub_stmt) if (thd->in_sub_stmt)
{ {
/* /*
@ -826,24 +1213,26 @@ int ha_rollback_trans(THD *thd, bool all)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (trans->nht) if (ha_info)
{ {
/* Close all cursors that can not survive ROLLBACK */ /* Close all cursors that can not survive ROLLBACK */
if (is_real_trans) /* not a statement commit */ if (is_real_trans) /* not a statement commit */
thd->stmt_map.close_transient_cursors(); thd->stmt_map.close_transient_cursors();
for (handlerton **ht=trans->ht; *ht; ht++) for (; ha_info; ha_info= ha_info_next)
{ {
int err; int err;
if ((err= (*(*ht)->rollback)(*ht, thd, all))) handlerton *ht= ha_info->ht();
if ((err= ht->rollback(ht, thd, all)))
{ // cannot happen { // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1; error=1;
} }
status_var_increment(thd->status_var.ha_rollback_count); status_var_increment(thd->status_var.ha_rollback_count);
*ht= 0; ha_info_next= ha_info->next();
ha_info->reset(); /* keep it conveniently zero-filled */
} }
trans->nht=0; trans->ha_list= 0;
trans->no_2pc=0; trans->no_2pc=0;
if (is_real_trans) if (is_real_trans)
thd->transaction.xid_state.xid.null(); thd->transaction.xid_state.xid.null();
@ -889,17 +1278,19 @@ int ha_autocommit_or_rollback(THD *thd, int error)
{ {
DBUG_ENTER("ha_autocommit_or_rollback"); DBUG_ENTER("ha_autocommit_or_rollback");
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (thd->transaction.stmt.nht) if (thd->transaction.stmt.ha_list)
{ {
if (!error) if (!error)
{ {
if (ha_commit_stmt(thd)) if (ha_commit_trans(thd, 0))
error=1; error=1;
} }
else if (thd->transaction_rollback_request && !thd->in_sub_stmt)
(void) ha_rollback(thd);
else else
(void) ha_rollback_stmt(thd); {
(void) ha_rollback_trans(thd, 0);
if (thd->transaction_rollback_request && !thd->in_sub_stmt)
(void) ha_rollback(thd);
}
thd->variables.tx_isolation=thd->session_tx_isolation; thd->variables.tx_isolation=thd->session_tx_isolation;
} }
@ -1199,7 +1590,7 @@ bool mysql_xa_recover(THD *thd)
} }
pthread_mutex_unlock(&LOCK_xid_cache); pthread_mutex_unlock(&LOCK_xid_cache);
send_eof(thd); my_eof(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -1246,43 +1637,49 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv)
int error=0; int error=0;
THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt : THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt :
&thd->transaction.all); &thd->transaction.all);
handlerton **ht=trans->ht, **end_ht; Ha_trx_info *ha_info, *ha_info_next;
DBUG_ENTER("ha_rollback_to_savepoint"); DBUG_ENTER("ha_rollback_to_savepoint");
trans->nht=sv->nht;
trans->no_2pc=0; trans->no_2pc=0;
end_ht=ht+sv->nht;
/* /*
rolling back to savepoint in all storage engines that were part of the rolling back to savepoint in all storage engines that were part of the
transaction when the savepoint was set transaction when the savepoint was set
*/ */
for (; ht < end_ht; ht++) for (ha_info= sv->ha_list; ha_info; ha_info= ha_info->next())
{ {
int err; int err;
DBUG_ASSERT((*ht)->savepoint_set != 0); handlerton *ht= ha_info->ht();
if ((err= (*(*ht)->savepoint_rollback)(*ht, thd, (uchar *)(sv+1)+(*ht)->savepoint_offset))) DBUG_ASSERT(ht);
DBUG_ASSERT(ht->savepoint_set != 0);
if ((err= ht->savepoint_rollback(ht, thd,
(uchar *)(sv+1)+ht->savepoint_offset)))
{ // cannot happen { // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1; error=1;
} }
status_var_increment(thd->status_var.ha_savepoint_rollback_count); status_var_increment(thd->status_var.ha_savepoint_rollback_count);
trans->no_2pc|=(*ht)->prepare == 0; trans->no_2pc|= ht->prepare == 0;
} }
/* /*
rolling back the transaction in all storage engines that were not part of rolling back the transaction in all storage engines that were not part of
the transaction when the savepoint was set the transaction when the savepoint was set
*/ */
for (; *ht ; ht++) for (ha_info= trans->ha_list; ha_info != sv->ha_list;
ha_info= ha_info_next)
{ {
int err; int err;
if ((err= (*(*ht)->rollback)(*ht, thd, !thd->in_sub_stmt))) handlerton *ht= ha_info->ht();
if ((err= ht->rollback(ht, thd, !thd->in_sub_stmt)))
{ // cannot happen { // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1; error=1;
} }
status_var_increment(thd->status_var.ha_rollback_count); status_var_increment(thd->status_var.ha_rollback_count);
*ht=0; // keep it conveniently zero-filled ha_info_next= ha_info->next();
ha_info->reset(); /* keep it conveniently zero-filled */
} }
trans->ha_list= sv->ha_list;
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -1297,26 +1694,32 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv)
int error=0; int error=0;
THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt : THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt :
&thd->transaction.all); &thd->transaction.all);
handlerton **ht=trans->ht; Ha_trx_info *ha_info= trans->ha_list;
DBUG_ENTER("ha_savepoint"); DBUG_ENTER("ha_savepoint");
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
for (; *ht; ht++) for (; ha_info; ha_info= ha_info->next())
{ {
int err; int err;
if (! (*ht)->savepoint_set) handlerton *ht= ha_info->ht();
DBUG_ASSERT(ht);
if (! ht->savepoint_set)
{ {
my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "SAVEPOINT"); my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "SAVEPOINT");
error=1; error=1;
break; break;
} }
if ((err= (*(*ht)->savepoint_set)(*ht, thd, (uchar *)(sv+1)+(*ht)->savepoint_offset))) if ((err= ht->savepoint_set(ht, thd, (uchar *)(sv+1)+ht->savepoint_offset)))
{ // cannot happen { // cannot happen
my_error(ER_GET_ERRNO, MYF(0), err); my_error(ER_GET_ERRNO, MYF(0), err);
error=1; error=1;
} }
status_var_increment(thd->status_var.ha_savepoint_count); status_var_increment(thd->status_var.ha_savepoint_count);
} }
sv->nht=trans->nht; /*
Remember the list of registered storage engines. All new
engines are prepended to the beginning of the list.
*/
sv->ha_list= trans->ha_list;
#endif /* USING_TRANSACTIONS */ #endif /* USING_TRANSACTIONS */
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -1324,20 +1727,19 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv)
int ha_release_savepoint(THD *thd, SAVEPOINT *sv) int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
{ {
int error=0; int error=0;
THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt : Ha_trx_info *ha_info= sv->ha_list;
&thd->transaction.all);
handlerton **ht=trans->ht, **end_ht;
DBUG_ENTER("ha_release_savepoint"); DBUG_ENTER("ha_release_savepoint");
end_ht=ht+sv->nht; for (; ha_info; ha_info= ha_info->next())
for (; ht < end_ht; ht++)
{ {
int err; int err;
if (!(*ht)->savepoint_release) handlerton *ht= ha_info->ht();
/* Savepoint life time is enclosed into transaction life time. */
DBUG_ASSERT(ht);
if (!ht->savepoint_release)
continue; continue;
if ((err= (*(*ht)->savepoint_release)(*ht, thd, if ((err= ht->savepoint_release(ht, thd,
(uchar *)(sv+1)+ (uchar *)(sv+1) + ht->savepoint_offset)))
(*ht)->savepoint_offset)))
{ // cannot happen { // cannot happen
my_error(ER_GET_ERRNO, MYF(0), err); my_error(ER_GET_ERRNO, MYF(0), err);
error=1; error=1;
@ -2506,6 +2908,36 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt)
return update_frm_version(table); return update_frm_version(table);
} }
/**
A helper function to mark a transaction read-write,
if it is started.
*/
inline
void
handler::mark_trx_read_write()
{
Ha_trx_info *ha_info= &ha_thd()->ha_data[ht->slot].ha_info[0];
/*
When a storage engine method is called, the transaction must
have been started, unless it's a DDL call, for which the
storage engine starts the transaction internally, and commits
it internally, without registering in the ha_list.
Unfortunately here we can't know know for sure if the engine
has registered the transaction or not, so we must check.
*/
if (ha_info->is_started())
{
DBUG_ASSERT(has_transactions());
/*
table_share can be NULL in ha_delete_table(). See implementation
of standalone function ha_delete_table() in sql_base.cc.
*/
if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE)
ha_info->set_trx_read_write();
}
}
/** /**
Repair table: public interface. Repair table: public interface.
@ -2516,6 +2948,9 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt)
int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt) int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt)
{ {
int result; int result;
mark_trx_read_write();
if ((result= repair(thd, check_opt))) if ((result= repair(thd, check_opt)))
return result; return result;
return update_frm_version(table); return update_frm_version(table);
@ -2532,6 +2967,8 @@ int
handler::ha_bulk_update_row(const uchar *old_data, uchar *new_data, handler::ha_bulk_update_row(const uchar *old_data, uchar *new_data,
uint *dup_key_found) uint *dup_key_found)
{ {
mark_trx_read_write();
return bulk_update_row(old_data, new_data, dup_key_found); return bulk_update_row(old_data, new_data, dup_key_found);
} }
@ -2545,6 +2982,8 @@ handler::ha_bulk_update_row(const uchar *old_data, uchar *new_data,
int int
handler::ha_delete_all_rows() handler::ha_delete_all_rows()
{ {
mark_trx_read_write();
return delete_all_rows(); return delete_all_rows();
} }
@ -2558,6 +2997,8 @@ handler::ha_delete_all_rows()
int int
handler::ha_reset_auto_increment(ulonglong value) handler::ha_reset_auto_increment(ulonglong value)
{ {
mark_trx_read_write();
return reset_auto_increment(value); return reset_auto_increment(value);
} }
@ -2571,6 +3012,8 @@ handler::ha_reset_auto_increment(ulonglong value)
int int
handler::ha_backup(THD* thd, HA_CHECK_OPT* check_opt) handler::ha_backup(THD* thd, HA_CHECK_OPT* check_opt)
{ {
mark_trx_read_write();
return backup(thd, check_opt); return backup(thd, check_opt);
} }
@ -2584,6 +3027,8 @@ handler::ha_backup(THD* thd, HA_CHECK_OPT* check_opt)
int int
handler::ha_restore(THD* thd, HA_CHECK_OPT* check_opt) handler::ha_restore(THD* thd, HA_CHECK_OPT* check_opt)
{ {
mark_trx_read_write();
return restore(thd, check_opt); return restore(thd, check_opt);
} }
@ -2597,6 +3042,8 @@ handler::ha_restore(THD* thd, HA_CHECK_OPT* check_opt)
int int
handler::ha_optimize(THD* thd, HA_CHECK_OPT* check_opt) handler::ha_optimize(THD* thd, HA_CHECK_OPT* check_opt)
{ {
mark_trx_read_write();
return optimize(thd, check_opt); return optimize(thd, check_opt);
} }
@ -2610,6 +3057,8 @@ handler::ha_optimize(THD* thd, HA_CHECK_OPT* check_opt)
int int
handler::ha_analyze(THD* thd, HA_CHECK_OPT* check_opt) handler::ha_analyze(THD* thd, HA_CHECK_OPT* check_opt)
{ {
mark_trx_read_write();
return analyze(thd, check_opt); return analyze(thd, check_opt);
} }
@ -2623,6 +3072,8 @@ handler::ha_analyze(THD* thd, HA_CHECK_OPT* check_opt)
bool bool
handler::ha_check_and_repair(THD *thd) handler::ha_check_and_repair(THD *thd)
{ {
mark_trx_read_write();
return check_and_repair(thd); return check_and_repair(thd);
} }
@ -2636,6 +3087,8 @@ handler::ha_check_and_repair(THD *thd)
int int
handler::ha_disable_indexes(uint mode) handler::ha_disable_indexes(uint mode)
{ {
mark_trx_read_write();
return disable_indexes(mode); return disable_indexes(mode);
} }
@ -2649,6 +3102,8 @@ handler::ha_disable_indexes(uint mode)
int int
handler::ha_enable_indexes(uint mode) handler::ha_enable_indexes(uint mode)
{ {
mark_trx_read_write();
return enable_indexes(mode); return enable_indexes(mode);
} }
@ -2662,6 +3117,8 @@ handler::ha_enable_indexes(uint mode)
int int
handler::ha_discard_or_import_tablespace(my_bool discard) handler::ha_discard_or_import_tablespace(my_bool discard)
{ {
mark_trx_read_write();
return discard_or_import_tablespace(discard); return discard_or_import_tablespace(discard);
} }
@ -2677,6 +3134,8 @@ handler::ha_discard_or_import_tablespace(my_bool discard)
void void
handler::ha_prepare_for_alter() handler::ha_prepare_for_alter()
{ {
mark_trx_read_write();
prepare_for_alter(); prepare_for_alter();
} }
@ -2690,6 +3149,8 @@ handler::ha_prepare_for_alter()
int int
handler::ha_rename_table(const char *from, const char *to) handler::ha_rename_table(const char *from, const char *to)
{ {
mark_trx_read_write();
return rename_table(from, to); return rename_table(from, to);
} }
@ -2703,6 +3164,8 @@ handler::ha_rename_table(const char *from, const char *to)
int int
handler::ha_delete_table(const char *name) handler::ha_delete_table(const char *name)
{ {
mark_trx_read_write();
return delete_table(name); return delete_table(name);
} }
@ -2716,6 +3179,8 @@ handler::ha_delete_table(const char *name)
void void
handler::ha_drop_table(const char *name) handler::ha_drop_table(const char *name)
{ {
mark_trx_read_write();
return drop_table(name); return drop_table(name);
} }
@ -2729,6 +3194,8 @@ handler::ha_drop_table(const char *name)
int int
handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info) handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info)
{ {
mark_trx_read_write();
return create(name, form, info); return create(name, form, info);
} }
@ -2743,6 +3210,8 @@ int
handler::ha_create_handler_files(const char *name, const char *old_name, handler::ha_create_handler_files(const char *name, const char *old_name,
int action_flag, HA_CREATE_INFO *info) int action_flag, HA_CREATE_INFO *info)
{ {
mark_trx_read_write();
return create_handler_files(name, old_name, action_flag, info); return create_handler_files(name, old_name, action_flag, info);
} }
@ -2761,6 +3230,8 @@ handler::ha_change_partitions(HA_CREATE_INFO *create_info,
const uchar *pack_frm_data, const uchar *pack_frm_data,
size_t pack_frm_len) size_t pack_frm_len)
{ {
mark_trx_read_write();
return change_partitions(create_info, path, copied, deleted, return change_partitions(create_info, path, copied, deleted,
pack_frm_data, pack_frm_len); pack_frm_data, pack_frm_len);
} }
@ -2775,6 +3246,8 @@ handler::ha_change_partitions(HA_CREATE_INFO *create_info,
int int
handler::ha_drop_partitions(const char *path) handler::ha_drop_partitions(const char *path)
{ {
mark_trx_read_write();
return drop_partitions(path); return drop_partitions(path);
} }
@ -2788,6 +3261,8 @@ handler::ha_drop_partitions(const char *path)
int int
handler::ha_rename_partitions(const char *path) handler::ha_rename_partitions(const char *path)
{ {
mark_trx_read_write();
return rename_partitions(path); return rename_partitions(path);
} }
@ -2801,6 +3276,8 @@ handler::ha_rename_partitions(const char *path)
int int
handler::ha_optimize_partitions(THD *thd) handler::ha_optimize_partitions(THD *thd)
{ {
mark_trx_read_write();
return optimize_partitions(thd); return optimize_partitions(thd);
} }
@ -2814,6 +3291,8 @@ handler::ha_optimize_partitions(THD *thd)
int int
handler::ha_analyze_partitions(THD *thd) handler::ha_analyze_partitions(THD *thd)
{ {
mark_trx_read_write();
return analyze_partitions(thd); return analyze_partitions(thd);
} }
@ -2827,6 +3306,8 @@ handler::ha_analyze_partitions(THD *thd)
int int
handler::ha_check_partitions(THD *thd) handler::ha_check_partitions(THD *thd)
{ {
mark_trx_read_write();
return check_partitions(thd); return check_partitions(thd);
} }
@ -2840,6 +3321,8 @@ handler::ha_check_partitions(THD *thd)
int int
handler::ha_repair_partitions(THD *thd) handler::ha_repair_partitions(THD *thd)
{ {
mark_trx_read_write();
return repair_partitions(thd); return repair_partitions(thd);
} }
@ -2866,7 +3349,7 @@ int ha_enable_transaction(THD *thd, bool on)
is an optimization hint that storage engine is free to ignore. is an optimization hint that storage engine is free to ignore.
So, let's commit an open transaction (if any) now. So, let's commit an open transaction (if any) now.
*/ */
if (!(error= ha_commit_stmt(thd))) if (!(error= ha_commit_trans(thd, 0)))
error= end_trans(thd, COMMIT); error= end_trans(thd, COMMIT);
} }
DBUG_RETURN(error); DBUG_RETURN(error);
@ -3826,7 +4309,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
} }
if (!result) if (!result)
send_eof(thd); my_eof(thd);
return result; return result;
} }
@ -4044,6 +4527,9 @@ int handler::ha_write_row(uchar *buf)
{ {
int error; int error;
DBUG_ENTER("handler::ha_write_row"); DBUG_ENTER("handler::ha_write_row");
mark_trx_read_write();
if (unlikely(error= write_row(buf))) if (unlikely(error= write_row(buf)))
DBUG_RETURN(error); DBUG_RETURN(error);
if (unlikely(error= binlog_log_row<Write_rows_log_event>(table, 0, buf))) if (unlikely(error= binlog_log_row<Write_rows_log_event>(table, 0, buf)))
@ -4062,6 +4548,8 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
*/ */
DBUG_ASSERT(new_data == table->record[0]); DBUG_ASSERT(new_data == table->record[0]);
mark_trx_read_write();
if (unlikely(error= update_row(old_data, new_data))) if (unlikely(error= update_row(old_data, new_data)))
return error; return error;
if (unlikely(error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data))) if (unlikely(error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data)))
@ -4072,6 +4560,9 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
int handler::ha_delete_row(const uchar *buf) int handler::ha_delete_row(const uchar *buf)
{ {
int error; int error;
mark_trx_read_write();
if (unlikely(error= delete_row(buf))) if (unlikely(error= delete_row(buf)))
return error; return error;
if (unlikely(error= binlog_log_row<Delete_rows_log_event>(table, buf, 0))) if (unlikely(error= binlog_log_row<Delete_rows_log_event>(table, buf, 0)))

View File

@ -721,14 +721,14 @@ struct handlerton
#define HTON_SUPPORT_LOG_TABLES (1 << 7) //Engine supports log tables #define HTON_SUPPORT_LOG_TABLES (1 << 7) //Engine supports log tables
#define HTON_NO_PARTITION (1 << 8) //You can not partition these tables #define HTON_NO_PARTITION (1 << 8) //You can not partition these tables
typedef struct st_thd_trans class Ha_trx_info;
struct THD_TRANS
{ {
/* number of entries in the ht[] */
uint nht;
/* true is not all entries in the ht[] support 2pc */ /* true is not all entries in the ht[] support 2pc */
bool no_2pc; bool no_2pc;
/* storage engines that registered themselves for this transaction */ /* storage engines that registered in this transaction */
handlerton *ht[MAX_HA]; Ha_trx_info *ha_list;
/* /*
The purpose of this flag is to keep track of non-transactional The purpose of this flag is to keep track of non-transactional
tables that were modified in scope of: tables that were modified in scope of:
@ -758,7 +758,106 @@ typedef struct st_thd_trans
saved value. saved value.
*/ */
bool modified_non_trans_table; bool modified_non_trans_table;
} THD_TRANS;
void reset() { no_2pc= FALSE; modified_non_trans_table= FALSE; }
};
/**
Either statement transaction or normal transaction - related
thread-specific storage engine data.
If a storage engine participates in a statement/transaction,
an instance of this class is present in
thd->transaction.{stmt|all}.ha_list. The addition to
{stmt|all}.ha_list is made by trans_register_ha().
When it's time to commit or rollback, each element of ha_list
is used to access storage engine's prepare()/commit()/rollback()
methods, and also to evaluate if a full two phase commit is
necessary.
@sa General description of transaction handling in handler.cc.
*/
class Ha_trx_info
{
public:
/** Register this storage engine in the given transaction context. */
void register_ha(THD_TRANS *trans, handlerton *ht_arg)
{
DBUG_ASSERT(m_flags == 0);
DBUG_ASSERT(m_ht == NULL);
DBUG_ASSERT(m_next == NULL);
m_ht= ht_arg;
m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
m_next= trans->ha_list;
trans->ha_list= this;
}
/** Clear, prepare for reuse. */
void reset()
{
m_next= NULL;
m_ht= NULL;
m_flags= 0;
}
Ha_trx_info() { reset(); }
void set_trx_read_write()
{
DBUG_ASSERT(is_started());
m_flags|= (int) TRX_READ_WRITE;
}
bool is_trx_read_write() const
{
DBUG_ASSERT(is_started());
return m_flags & (int) TRX_READ_WRITE;
}
bool is_started() const { return m_ht != NULL; }
/** Mark this transaction read-write if the argument is read-write. */
void coalesce_trx_with(const Ha_trx_info *stmt_trx)
{
/*
Must be called only after the transaction has been started.
Can be called many times, e.g. when we have many
read-write statements in a transaction.
*/
DBUG_ASSERT(is_started());
if (stmt_trx->is_trx_read_write())
set_trx_read_write();
}
Ha_trx_info *next() const
{
DBUG_ASSERT(is_started());
return m_next;
}
handlerton *ht() const
{
DBUG_ASSERT(is_started());
return m_ht;
}
private:
enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
/** Auxiliary, used for ha_list management */
Ha_trx_info *m_next;
/**
Although a given Ha_trx_info instance is currently always used
for the same storage engine, 'ht' is not-NULL only when the
corresponding storage is a part of a transaction.
*/
handlerton *m_ht;
/**
Transaction flags related to this engine.
Not-null only if this instance is a part of transaction.
May assume a combination of enum values above.
*/
uchar m_flags;
};
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED, enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
ISO_REPEATABLE_READ, ISO_SERIALIZABLE}; ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
@ -1640,7 +1739,14 @@ protected:
provide useful functionality. provide useful functionality.
*/ */
virtual int rename_table(const char *from, const char *to); virtual int rename_table(const char *from, const char *to);
/**
Delete a table in the engine. Called for base as well as temporary
tables.
*/
virtual int delete_table(const char *name); virtual int delete_table(const char *name);
private:
/* Private helpers */
inline void mark_trx_read_write();
private: private:
/* /*
Low-level primitives for storage engines. These should be Low-level primitives for storage engines. These should be
@ -1822,8 +1928,6 @@ extern TYPELIB myisam_stats_method_typelib;
extern ulong total_ha, total_ha_2pc; extern ulong total_ha, total_ha_2pc;
/* Wrapper functions */ /* Wrapper functions */
#define ha_commit_stmt(thd) (ha_commit_trans((thd), FALSE))
#define ha_rollback_stmt(thd) (ha_rollback_trans((thd), FALSE))
#define ha_commit(thd) (ha_commit_trans((thd), TRUE)) #define ha_commit(thd) (ha_commit_trans((thd), TRUE))
#define ha_rollback(thd) (ha_rollback_trans((thd), TRUE)) #define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))

View File

@ -442,9 +442,10 @@ uint Item::decimal_precision() const
} }
void Item::print_item_w_name(String *str) void Item::print_item_w_name(String *str, enum_query_type query_type)
{ {
print(str); print(str, query_type);
if (name) if (name)
{ {
THD *thd= current_thd; THD *thd= current_thd;
@ -1128,7 +1129,7 @@ Item_splocal::this_item_addr(THD *thd, Item **)
} }
void Item_splocal::print(String *str) void Item_splocal::print(String *str, enum_query_type)
{ {
str->reserve(m_name.length+8); str->reserve(m_name.length+8);
str->append(m_name.str, m_name.length); str->append(m_name.str, m_name.length);
@ -1182,7 +1183,7 @@ Item_case_expr::this_item_addr(THD *thd, Item **)
} }
void Item_case_expr::print(String *str) void Item_case_expr::print(String *str, enum_query_type)
{ {
if (str->reserve(MAX_INT_WIDTH + sizeof("case_expr@"))) if (str->reserve(MAX_INT_WIDTH + sizeof("case_expr@")))
return; /* purecov: inspected */ return; /* purecov: inspected */
@ -1276,12 +1277,12 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
} }
void Item_name_const::print(String *str) void Item_name_const::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("NAME_CONST(")); str->append(STRING_WITH_LEN("NAME_CONST("));
name_item->print(str); name_item->print(str, query_type);
str->append(','); str->append(',');
value_item->print(str); value_item->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -1298,12 +1299,12 @@ public:
const char *table_name_arg, const char *field_name_arg) const char *table_name_arg, const char *field_name_arg)
:Item_ref(context_arg, item, table_name_arg, field_name_arg) {} :Item_ref(context_arg, item, table_name_arg, field_name_arg) {}
void print (String *str) virtual inline void print (String *str, enum_query_type query_type)
{ {
if (ref) if (ref)
(*ref)->print(str); (*ref)->print(str, query_type);
else else
Item_ident::print(str); Item_ident::print(str, query_type);
} }
}; };
@ -1455,7 +1456,9 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
set(dt); set(dt);
} }
else else
; // Do nothing {
// Do nothing
}
} }
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
left_is_superset(this, &dt)) left_is_superset(this, &dt))
@ -1872,7 +1875,7 @@ const char *Item_ident::full_name() const
return tmp; return tmp;
} }
void Item_ident::print(String *str) void Item_ident::print(String *str, enum_query_type query_type)
{ {
THD *thd= current_thd; THD *thd= current_thd;
char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME]; char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME];
@ -2134,7 +2137,7 @@ String *Item_int::val_str(String *str)
return str; return str;
} }
void Item_int::print(String *str) void Item_int::print(String *str, enum_query_type query_type)
{ {
// my_charset_bin is good enough for numbers // my_charset_bin is good enough for numbers
str_value.set(value, &my_charset_bin); str_value.set(value, &my_charset_bin);
@ -2165,7 +2168,7 @@ String *Item_uint::val_str(String *str)
} }
void Item_uint::print(String *str) void Item_uint::print(String *str, enum_query_type query_type)
{ {
// latin1 is good enough for numbers // latin1 is good enough for numbers
str_value.set((ulonglong) value, default_charset()); str_value.set((ulonglong) value, default_charset());
@ -2257,7 +2260,7 @@ String *Item_decimal::val_str(String *result)
return result; return result;
} }
void Item_decimal::print(String *str) void Item_decimal::print(String *str, enum_query_type query_type)
{ {
my_decimal2string(E_DEC_FATAL_ERROR, &decimal_value, 0, 0, 0, &str_value); my_decimal2string(E_DEC_FATAL_ERROR, &decimal_value, 0, 0, 0, &str_value);
str->append(str_value); str->append(str_value);
@ -2310,12 +2313,39 @@ my_decimal *Item_float::val_decimal(my_decimal *decimal_value)
} }
void Item_string::print(String *str) void Item_string::print(String *str, enum_query_type query_type)
{
if (query_type == QT_ORDINARY && is_cs_specified())
{ {
str->append('_'); str->append('_');
str->append(collation.collation->csname); str->append(collation.collation->csname);
}
str->append('\''); str->append('\'');
if (query_type == QT_ORDINARY ||
my_charset_same(str_value.charset(), system_charset_info))
{
str_value.print(str); str_value.print(str);
}
else
{
THD *thd= current_thd;
LEX_STRING utf8_lex_str;
thd->convert_string(&utf8_lex_str,
system_charset_info,
str_value.c_ptr_safe(),
str_value.length(),
str_value.charset());
String utf8_str(utf8_lex_str.str,
utf8_lex_str.length,
system_charset_info);
utf8_str.print(str);
}
str->append('\''); str->append('\'');
} }
@ -3082,7 +3112,7 @@ Item_param::eq(const Item *arg, bool binary_cmp) const
/* End of Item_param related */ /* End of Item_param related */
void Item_param::print(String *str) void Item_param::print(String *str, enum_query_type query_type)
{ {
if (state == NO_VALUE) if (state == NO_VALUE)
{ {
@ -4795,7 +4825,7 @@ int Item_float::save_in_field(Field *field, bool no_conversions)
} }
void Item_float::print(String *str) void Item_float::print(String *str, enum_query_type query_type)
{ {
if (presentation) if (presentation)
{ {
@ -4913,7 +4943,7 @@ warn:
} }
void Item_hex_string::print(String *str) void Item_hex_string::print(String *str, enum_query_type query_type)
{ {
char *end= (char*) str_value.ptr() + str_value.length(), char *end= (char*) str_value.ptr() + str_value.length(),
*ptr= end - min(str_value.length(), sizeof(longlong)); *ptr= end - min(str_value.length(), sizeof(longlong));
@ -5175,7 +5205,7 @@ Item *Item_field::update_value_transformer(uchar *select_arg)
} }
void Item_field::print(String *str) void Item_field::print(String *str, enum_query_type query_type)
{ {
if (field && field->table->const_table) if (field && field->table->const_table)
{ {
@ -5187,7 +5217,7 @@ void Item_field::print(String *str)
str->append('\''); str->append('\'');
return; return;
} }
Item_ident::print(str); Item_ident::print(str, query_type);
} }
@ -5527,7 +5557,7 @@ void Item_ref::cleanup()
} }
void Item_ref::print(String *str) void Item_ref::print(String *str, enum_query_type query_type)
{ {
if (ref) if (ref)
{ {
@ -5538,10 +5568,10 @@ void Item_ref::print(String *str)
append_identifier(thd, str, name, (uint) strlen(name)); append_identifier(thd, str, name, (uint) strlen(name));
} }
else else
(*ref)->print(str); (*ref)->print(str, query_type);
} }
else else
Item_ident::print(str); Item_ident::print(str, query_type);
} }
@ -5731,11 +5761,11 @@ Item *Item_ref::get_tmp_table_item(THD *thd)
} }
void Item_ref_null_helper::print(String *str) void Item_ref_null_helper::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("<ref_null_helper>(")); str->append(STRING_WITH_LEN("<ref_null_helper>("));
if (ref) if (ref)
(*ref)->print(str); (*ref)->print(str, query_type);
else else
str->append('?'); str->append('?');
str->append(')'); str->append(')');
@ -5927,7 +5957,7 @@ error:
} }
void Item_default_value::print(String *str) void Item_default_value::print(String *str, enum_query_type query_type)
{ {
if (!arg) if (!arg)
{ {
@ -5935,7 +5965,7 @@ void Item_default_value::print(String *str)
return; return;
} }
str->append(STRING_WITH_LEN("default(")); str->append(STRING_WITH_LEN("default("));
arg->print(str); arg->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -6071,10 +6101,10 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
return FALSE; return FALSE;
} }
void Item_insert_value::print(String *str) void Item_insert_value::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("values(")); str->append(STRING_WITH_LEN("values("));
arg->print(str); arg->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -6195,7 +6225,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
} }
void Item_trigger_field::print(String *str) void Item_trigger_field::print(String *str, enum_query_type query_type)
{ {
str->append((row_version == NEW_ROW) ? "NEW" : "OLD", 3); str->append((row_version == NEW_ROW) ? "NEW" : "OLD", 3);
str->append('.'); str->append('.');
@ -6385,13 +6415,13 @@ Item_cache* Item_cache::get_cache(const Item *item)
} }
void Item_cache::print(String *str) void Item_cache::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("<cache>(")); str->append(STRING_WITH_LEN("<cache>("));
if (example) if (example)
example->print(str); example->print(str, query_type);
else else
Item::print(str); Item::print(str, query_type);
str->append(')'); str->append(')');
} }

View File

@ -113,7 +113,6 @@ public:
} }
}; };
/*************************************************************************/ /*************************************************************************/
/* /*
A framework to easily handle different return types for hybrid items A framework to easily handle different return types for hybrid items
@ -769,20 +768,24 @@ public:
*/ */
virtual bool const_during_execution() const virtual bool const_during_execution() const
{ return (used_tables() & ~PARAM_TABLE_BIT) == 0; } { return (used_tables() & ~PARAM_TABLE_BIT) == 0; }
/*
This is an essential method for correct functioning of VIEWS. /**
To save a view in an .frm file we need its unequivocal This method is used for to:
definition in SQL that takes into account sql_mode and - to generate a view definition query (SELECT-statement);
environmental settings. Currently such definition is restored - to generate a SQL-query for EXPLAIN EXTENDED;
by traversing through the parsed tree of a view and - to generate a SQL-query to be shown in INFORMATION_SCHEMA;
print()'ing SQL syntax of every node to a String buffer. This - debug.
method is used to print the SQL definition of an item. The
second use of this method is for EXPLAIN EXTENDED, to print For more information about view definition query, INFORMATION_SCHEMA
the SQL of a query after all optimizations of the parsed tree query and why they should be generated from the Item-tree, @see
have been done. mysql_register_view().
*/ */
virtual void print(String *str_arg) { str_arg->append(full_name()); } virtual inline void print(String *str, enum_query_type query_type)
void print_item_w_name(String *); {
str->append(full_name());
}
void print_item_w_name(String *, enum_query_type query_type);
virtual void update_used_tables() {} virtual void update_used_tables() {}
virtual void split_sum_func(THD *thd, Item **ref_pointer_array, virtual void split_sum_func(THD *thd, Item **ref_pointer_array,
List<Item> &fields) {} List<Item> &fields) {}
@ -1010,6 +1013,23 @@ public:
class sp_head; class sp_head;
class Item_basic_constant :public Item
{
public:
/* to prevent drop fixed flag (no need parent cleanup call) */
void cleanup()
{
/*
Restore the original field name as it might not have been allocated
in the statement memory. If the name is auto generated, it must be
done again between subsequent executions of a prepared statement.
*/
if (orig_name)
name= orig_name;
}
};
/***************************************************************************** /*****************************************************************************
The class is a base class for representation of stored routine variables in The class is a base class for representation of stored routine variables in
the Item-hierarchy. There are the following kinds of SP-vars: the Item-hierarchy. There are the following kinds of SP-vars:
@ -1134,7 +1154,7 @@ public:
const Item *this_item() const; const Item *this_item() const;
Item **this_item_addr(THD *thd, Item **); Item **this_item_addr(THD *thd, Item **);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
public: public:
inline const LEX_STRING *my_name() const; inline const LEX_STRING *my_name() const;
@ -1203,7 +1223,7 @@ public:
Item_case_expr can not occur in views, so here it is only for debug Item_case_expr can not occur in views, so here it is only for debug
purposes. purposes.
*/ */
void print(String *str); virtual void print(String *str, enum_query_type query_type);
private: private:
uint m_case_expr_id; uint m_case_expr_id;
@ -1261,7 +1281,7 @@ public:
String *val_str(String *sp); String *val_str(String *sp);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool is_null(); bool is_null();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
Item_result result_type() const Item_result result_type() const
{ {
@ -1292,7 +1312,7 @@ bool agg_item_charsets(DTCollation &c, const char *name,
Item **items, uint nitems, uint flags, int item_sep); Item **items, uint nitems, uint flags, int item_sep);
class Item_num: public Item class Item_num: public Item_basic_constant
{ {
public: public:
Item_num() {} /* Remove gcc warning */ Item_num() {} /* Remove gcc warning */
@ -1343,7 +1363,7 @@ public:
const char *full_name() const; const char *full_name() const;
void cleanup(); void cleanup();
bool remove_dependence_processor(uchar * arg); bool remove_dependence_processor(uchar * arg);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
virtual bool change_context_processor(uchar *cntx) virtual bool change_context_processor(uchar *cntx)
{ context= (Name_resolution_context *)cntx; return FALSE; } { context= (Name_resolution_context *)cntx; return FALSE; }
friend bool insert_fields(THD *thd, Name_resolution_context *context, friend bool insert_fields(THD *thd, Name_resolution_context *context,
@ -1473,7 +1493,7 @@ public:
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
int fix_outer_field(THD *thd, Field **field, Item **reference); int fix_outer_field(THD *thd, Field **field, Item **reference);
virtual Item *update_value_transformer(uchar *select_arg); virtual Item *update_value_transformer(uchar *select_arg);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
Field::geometry_type get_geometry_type() const Field::geometry_type get_geometry_type() const
{ {
DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY); DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY);
@ -1484,7 +1504,7 @@ public:
friend class st_select_lex_unit; friend class st_select_lex_unit;
}; };
class Item_null :public Item class Item_null :public Item_basic_constant
{ {
public: public:
Item_null(char *name_par=0) Item_null(char *name_par=0)
@ -1506,12 +1526,15 @@ public:
bool send(Protocol *protocol, String *str); bool send(Protocol *protocol, String *str);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NULL; } enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
/* to prevent drop fixed flag (no need parent cleanup call) */
void cleanup() {}
bool basic_const_item() const { return 1; } bool basic_const_item() const { return 1; }
Item *clone_item() { return new Item_null(name); } Item *clone_item() { return new Item_null(name); }
bool is_null() { return 1; } bool is_null() { return 1; }
void print(String *str) { str->append(STRING_WITH_LEN("NULL")); }
virtual inline void print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN("NULL"));
}
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
}; };
@ -1645,7 +1668,7 @@ public:
*/ */
virtual table_map used_tables() const virtual table_map used_tables() const
{ return state != NO_VALUE ? (table_map)0 : PARAM_TABLE_BIT; } { return state != NO_VALUE ? (table_map)0 : PARAM_TABLE_BIT; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool is_null() bool is_null()
{ DBUG_ASSERT(state != NO_VALUE); return state == NULL_VALUE; } { DBUG_ASSERT(state != NO_VALUE); return state == NULL_VALUE; }
bool basic_const_item() const; bool basic_const_item() const;
@ -1701,9 +1724,7 @@ public:
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
bool basic_const_item() const { return 1; } bool basic_const_item() const { return 1; }
Item *clone_item() { return new Item_int(name,value,max_length); } Item *clone_item() { return new Item_int(name,value,max_length); }
// to prevent drop fixed flag (no need parent cleanup call) virtual void print(String *str, enum_query_type query_type);
void cleanup() {}
void print(String *str);
Item_num *neg() { value= -value; return this; } Item_num *neg() { value= -value; return this; }
uint decimal_precision() const uint decimal_precision() const
{ return (uint)(max_length - test(value < 0)); } { return (uint)(max_length - test(value < 0)); }
@ -1723,7 +1744,7 @@ public:
String *val_str(String*); String *val_str(String*);
Item *clone_item() { return new Item_uint(name, value, max_length); } Item *clone_item() { return new Item_uint(name, value, max_length); }
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
Item_num *neg (); Item_num *neg ();
uint decimal_precision() const { return max_length; } uint decimal_precision() const { return max_length; }
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;} bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
@ -1757,9 +1778,7 @@ public:
{ {
return new Item_decimal(name, &decimal_value, decimals, max_length); return new Item_decimal(name, &decimal_value, decimals, max_length);
} }
// to prevent drop fixed flag (no need parent cleanup call) virtual void print(String *str, enum_query_type query_type);
void cleanup() {}
void print(String *str);
Item_num *neg() Item_num *neg()
{ {
my_decimal_neg(&decimal_value); my_decimal_neg(&decimal_value);
@ -1813,12 +1832,10 @@ public:
String *val_str(String*); String *val_str(String*);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool basic_const_item() const { return 1; } bool basic_const_item() const { return 1; }
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {}
Item *clone_item() Item *clone_item()
{ return new Item_float(name, value, decimals, max_length); } { return new Item_float(name, value, decimals, max_length); }
Item_num *neg() { value= -value; return this; } Item_num *neg() { value= -value; return this; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool eq(const Item *, bool binary_cmp) const; bool eq(const Item *, bool binary_cmp) const;
}; };
@ -1831,17 +1848,23 @@ public:
uint length) uint length)
:Item_float(NullS, val_arg, decimal_par, length), func_name(str) :Item_float(NullS, val_arg, decimal_par, length), func_name(str)
{} {}
void print(String *str) { str->append(func_name); }
virtual inline void print(String *str, enum_query_type query_type)
{
str->append(func_name);
}
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
}; };
class Item_string :public Item class Item_string :public Item_basic_constant
{ {
public: public:
Item_string(const char *str,uint length, Item_string(const char *str,uint length,
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
uint repertoire= MY_REPERTOIRE_UNICODE30) uint repertoire= MY_REPERTOIRE_UNICODE30)
: m_cs_specified(FALSE)
{ {
str_value.set_or_copy_aligned(str, length, cs); str_value.set_or_copy_aligned(str, length, cs);
collation.set(cs, dv, repertoire); collation.set(cs, dv, repertoire);
@ -1860,6 +1883,7 @@ public:
} }
/* Just create an item and do not fill string representation */ /* Just create an item and do not fill string representation */
Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
: m_cs_specified(FALSE)
{ {
collation.set(cs, dv); collation.set(cs, dv);
max_length= 0; max_length= 0;
@ -1870,6 +1894,7 @@ public:
Item_string(const char *name_par, const char *str, uint length, Item_string(const char *name_par, const char *str, uint length,
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
uint repertoire= MY_REPERTOIRE_UNICODE30) uint repertoire= MY_REPERTOIRE_UNICODE30)
: m_cs_specified(FALSE)
{ {
str_value.set_or_copy_aligned(str, length, cs); str_value.set_or_copy_aligned(str, length, cs);
collation.set(cs, dv, repertoire); collation.set(cs, dv, repertoire);
@ -1919,10 +1944,50 @@ public:
str_value.append(str, length); str_value.append(str, length);
max_length= str_value.numchars() * collation.collation->mbmaxlen; max_length= str_value.numchars() * collation.collation->mbmaxlen;
} }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
/**
Return TRUE if character-set-introducer was explicitly specified in the
original query for this item (text literal).
This operation is to be called from Item_string::print(). The idea is
that when a query is generated (re-constructed) from the Item-tree,
character-set-introducers should appear only for those literals, where
they were explicitly specified by the user. Otherwise, that may lead to
loss collation information (character set introducers implies default
collation for the literal).
Basically, that makes sense only for views and hopefully will be gone
one day when we start using original query as a view definition.
@return This operation returns the value of m_cs_specified attribute.
@retval TRUE if character set introducer was explicitly specified in
the original query.
@retval FALSE otherwise.
*/
inline bool is_cs_specified() const
{
return m_cs_specified;
}
/**
Set the value of m_cs_specified attribute.
m_cs_specified attribute shows whether character-set-introducer was
explicitly specified in the original query for this text literal or
not. The attribute makes sense (is used) only for views.
This operation is to be called from the parser during parsing an input
query.
*/
inline void set_cs_specified(bool cs_specified)
{
m_cs_specified= cs_specified;
}
private:
bool m_cs_specified;
}; };
@ -1936,7 +2001,12 @@ public:
:Item_string(NullS, str, length, cs, dv), func_name(name_par) :Item_string(NullS, str, length, cs, dv), func_name(name_par)
{} {}
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
void print(String *str) { str->append(func_name); }
virtual inline void print(String *str, enum_query_type query_type)
{
str->append(func_name);
}
bool check_partition_func_processor(uchar *int_arg) {return TRUE;} bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
}; };
@ -2005,10 +2075,10 @@ public:
}; };
class Item_hex_string: public Item class Item_hex_string: public Item_basic_constant
{ {
public: public:
Item_hex_string(): Item() {} Item_hex_string() {}
Item_hex_string(const char *str,uint str_length); Item_hex_string(const char *str,uint str_length);
enum Type type() const { return VARBIN_ITEM; } enum Type type() const { return VARBIN_ITEM; }
double val_real() double val_real()
@ -2024,9 +2094,7 @@ public:
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum Item_result cast_to_int_type() const { return INT_RESULT; } enum Item_result cast_to_int_type() const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
// to prevent drop fixed flag (no need parent cleanup call) virtual void print(String *str, enum_query_type query_type);
void cleanup() {}
void print(String *str);
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
virtual Item *safe_charset_converter(CHARSET_INFO *tocs); virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
@ -2147,7 +2215,7 @@ public:
} }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg) bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
{ return (*ref)->walk(processor, walk_subquery, arg); } { return (*ref)->walk(processor, walk_subquery, arg); }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool result_as_longlong() bool result_as_longlong()
{ {
return (*ref)->result_as_longlong(); return (*ref)->result_as_longlong();
@ -2294,7 +2362,7 @@ public:
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool val_bool(); bool val_bool();
bool get_date(MYSQL_TIME *ltime, uint fuzzydate); bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
/* /*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
*/ */
@ -2469,7 +2537,7 @@ public:
enum Type type() const { return DEFAULT_VALUE_ITEM; } enum Type type() const { return DEFAULT_VALUE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
int save_in_field(Field *field_arg, bool no_conversions); int save_in_field(Field *field_arg, bool no_conversions);
table_map used_tables() const { return (table_map)0L; } table_map used_tables() const { return (table_map)0L; }
@ -2502,7 +2570,7 @@ public:
arg(a) {} arg(a) {}
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
int save_in_field(Field *field_arg, bool no_conversions) int save_in_field(Field *field_arg, bool no_conversions)
{ {
return Item_field::save_in_field(field_arg, no_conversions); return Item_field::save_in_field(field_arg, no_conversions);
@ -2573,7 +2641,7 @@ public:
enum Type type() const { return TRIGGER_FIELD_ITEM; } enum Type type() const { return TRIGGER_FIELD_ITEM; }
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
table_map used_tables() const { return (table_map)0L; } table_map used_tables() const { return (table_map)0L; }
Field *get_tmp_table_field() { return 0; } Field *get_tmp_table_field() { return 0; }
Item *copy_or_same(THD *thd) { return this; } Item *copy_or_same(THD *thd) { return this; }
@ -2617,7 +2685,7 @@ private:
}; };
class Item_cache: public Item class Item_cache: public Item_basic_constant
{ {
protected: protected:
Item *example; Item *example;
@ -2664,9 +2732,7 @@ public:
static Item_cache* get_cache(const Item *item); static Item_cache* get_cache(const Item *item);
table_map used_tables() const { return used_table_map; } table_map used_tables() const { return used_table_map; }
virtual void keep_array() {} virtual void keep_array() {}
// to prevent drop fixed flag (no need parent cleanup call) virtual void print(String *str, enum_query_type query_type);
void cleanup() {}
void print(String *str);
bool eq_def(Field *field) bool eq_def(Field *field)
{ {
return cached_field ? cached_field->eq_def (field) : FALSE; return cached_field ? cached_field->eq_def (field) : FALSE;

View File

@ -286,10 +286,10 @@ longlong Item_func_not::val_int()
higher than the precedence of NOT. higher than the precedence of NOT.
*/ */
void Item_func_not::print(String *str) void Item_func_not::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
Item_func::print(str); Item_func::print(str, query_type);
str->append(')'); str->append(')');
} }
@ -321,12 +321,12 @@ bool Item_func_not_all::empty_underlying_subquery()
(test_sub_item && !test_sub_item->any_value())); (test_sub_item && !test_sub_item->any_value()));
} }
void Item_func_not_all::print(String *str) void Item_func_not_all::print(String *str, enum_query_type query_type)
{ {
if (show) if (show)
Item_func::print(str); Item_func::print(str, query_type);
else else
args[0]->print(str); args[0]->print(str, query_type);
} }
@ -1422,10 +1422,10 @@ void Item_func_truth::fix_length_and_dec()
} }
void Item_func_truth::print(String *str) void Item_func_truth::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" is ")); str->append(STRING_WITH_LEN(" is "));
if (! affirmative) if (! affirmative)
str->append(STRING_WITH_LEN("not ")); str->append(STRING_WITH_LEN("not "));
@ -2109,16 +2109,16 @@ longlong Item_func_between::val_int()
} }
void Item_func_between::print(String *str) void Item_func_between::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
args[0]->print(str); args[0]->print(str, query_type);
if (negated) if (negated)
str->append(STRING_WITH_LEN(" not")); str->append(STRING_WITH_LEN(" not"));
str->append(STRING_WITH_LEN(" between ")); str->append(STRING_WITH_LEN(" between "));
args[1]->print(str); args[1]->print(str, query_type);
str->append(STRING_WITH_LEN(" and ")); str->append(STRING_WITH_LEN(" and "));
args[2]->print(str); args[2]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -2763,26 +2763,26 @@ uint Item_func_case::decimal_precision() const
Fix this so that it prints the whole CASE expression Fix this so that it prints the whole CASE expression
*/ */
void Item_func_case::print(String *str) void Item_func_case::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("(case ")); str->append(STRING_WITH_LEN("(case "));
if (first_expr_num != -1) if (first_expr_num != -1)
{ {
args[first_expr_num]->print(str); args[first_expr_num]->print(str, query_type);
str->append(' '); str->append(' ');
} }
for (uint i=0 ; i < ncases ; i+=2) for (uint i=0 ; i < ncases ; i+=2)
{ {
str->append(STRING_WITH_LEN("when ")); str->append(STRING_WITH_LEN("when "));
args[i]->print(str); args[i]->print(str, query_type);
str->append(STRING_WITH_LEN(" then ")); str->append(STRING_WITH_LEN(" then "));
args[i+1]->print(str); args[i+1]->print(str, query_type);
str->append(' '); str->append(' ');
} }
if (else_expr_num != -1) if (else_expr_num != -1)
{ {
str->append(STRING_WITH_LEN("else ")); str->append(STRING_WITH_LEN("else "));
args[else_expr_num]->print(str); args[else_expr_num]->print(str, query_type);
str->append(' '); str->append(' ');
} }
str->append(STRING_WITH_LEN("end)")); str->append(STRING_WITH_LEN("end)"));
@ -3706,14 +3706,14 @@ void Item_func_in::fix_length_and_dec()
} }
void Item_func_in::print(String *str) void Item_func_in::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
args[0]->print(str); args[0]->print(str, query_type);
if (negated) if (negated)
str->append(STRING_WITH_LEN(" not")); str->append(STRING_WITH_LEN(" not"));
str->append(STRING_WITH_LEN(" in (")); str->append(STRING_WITH_LEN(" in ("));
print_args(str, 1); print_args(str, 1, query_type);
str->append(STRING_WITH_LEN("))")); str->append(STRING_WITH_LEN("))"));
} }
@ -4084,19 +4084,19 @@ void Item_cond::update_used_tables()
} }
void Item_cond::print(String *str) void Item_cond::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
List_iterator_fast<Item> li(list); List_iterator_fast<Item> li(list);
Item *item; Item *item;
if ((item=li++)) if ((item=li++))
item->print(str); item->print(str, query_type);
while ((item=li++)) while ((item=li++))
{ {
str->append(' '); str->append(' ');
str->append(func_name()); str->append(func_name());
str->append(' '); str->append(' ');
item->print(str); item->print(str, query_type);
} }
str->append(')'); str->append(')');
} }
@ -4279,10 +4279,10 @@ longlong Item_func_isnotnull::val_int()
} }
void Item_func_isnotnull::print(String *str) void Item_func_isnotnull::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" is not null)")); str->append(STRING_WITH_LEN(" is not null)"));
} }
@ -5276,24 +5276,24 @@ Item *Item_equal::transform(Item_transformer transformer, uchar *arg)
return Item_func::transform(transformer, arg); return Item_func::transform(transformer, arg);
} }
void Item_equal::print(String *str) void Item_equal::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
str->append('('); str->append('(');
List_iterator_fast<Item_field> it(fields); List_iterator_fast<Item_field> it(fields);
Item *item; Item *item;
if (const_item) if (const_item)
const_item->print(str); const_item->print(str, query_type);
else else
{ {
item= it++; item= it++;
item->print(str); item->print(str, query_type);
} }
while ((item= it++)) while ((item= it++))
{ {
str->append(','); str->append(',');
str->append(' '); str->append(' ');
item->print(str); item->print(str, query_type);
} }
str->append(')'); str->append(')');
} }

View File

@ -123,7 +123,7 @@ public:
virtual bool val_bool(); virtual bool val_bool();
virtual longlong val_int(); virtual longlong val_int();
virtual void fix_length_and_dec(); virtual void fix_length_and_dec();
virtual void print(String *str); virtual void print(String *str, enum_query_type query_type);
protected: protected:
Item_func_truth(Item *a, bool a_value, bool a_affirmative) Item_func_truth(Item *a, bool a_value, bool a_affirmative)
@ -338,7 +338,12 @@ public:
optimize_type select_optimize() const { return OPTIMIZE_OP; } optimize_type select_optimize() const { return OPTIMIZE_OP; }
virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; } virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; } bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; }
void print(String *str) { Item_func::print_op(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print_op(str, query_type);
}
bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); } bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
bool is_bool_func() { return 1; } bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
@ -368,7 +373,7 @@ public:
enum Functype functype() const { return NOT_FUNC; } enum Functype functype() const { return NOT_FUNC; }
const char *func_name() const { return "not"; } const char *func_name() const { return "not"; }
Item *neg_transformer(THD *thd); Item *neg_transformer(THD *thd);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
class Item_maxmin_subselect; class Item_maxmin_subselect;
@ -433,7 +438,7 @@ public:
longlong val_int(); longlong val_int();
enum Functype functype() const { return NOT_ALL_FUNC; } enum Functype functype() const { return NOT_ALL_FUNC; }
const char *func_name() const { return "<not>"; } const char *func_name() const { return "<not>"; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; }; void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; };
void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; }; void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; };
bool empty_underlying_subquery(); bool empty_underlying_subquery();
@ -594,7 +599,7 @@ public:
const char *func_name() const { return "between"; } const char *func_name() const { return "between"; }
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool is_bool_func() { return 1; } bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
uint decimal_precision() const { return 1; } uint decimal_precision() const { return 1; }
@ -608,7 +613,11 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "strcmp"; } const char *func_name() const { return "strcmp"; }
void print(String *str) { Item_func::print(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
}
}; };
@ -711,7 +720,12 @@ public:
void fix_length_and_dec(); void fix_length_and_dec();
uint decimal_precision() const { return args[0]->decimal_precision(); } uint decimal_precision() const { return args[0]->decimal_precision(); }
const char *func_name() const { return "nullif"; } const char *func_name() const { return "nullif"; }
void print(String *str) { Item_func::print(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
}
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
bool is_null(); bool is_null();
}; };
@ -1141,7 +1155,7 @@ public:
enum Item_result result_type () const { return cached_result_type; } enum Item_result result_type () const { return cached_result_type; }
enum_field_types field_type() const { return cached_field_type; } enum_field_types field_type() const { return cached_field_type; }
const char *func_name() const { return "case"; } const char *func_name() const { return "case"; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
Item *find_item(String *str); Item *find_item(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
void cleanup(); void cleanup();
@ -1208,7 +1222,7 @@ public:
} }
optimize_type select_optimize() const optimize_type select_optimize() const
{ return OPTIMIZE_KEY; } { return OPTIMIZE_KEY; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
enum Functype functype() const { return IN_FUNC; } enum Functype functype() const { return IN_FUNC; }
const char *func_name() const { return " IN "; } const char *func_name() const { return " IN "; }
bool nulls_in_row(); bool nulls_in_row();
@ -1330,7 +1344,7 @@ public:
table_map not_null_tables() const table_map not_null_tables() const
{ return abort_on_null ? not_null_tables_cache : 0; } { return abort_on_null ? not_null_tables_cache : 0; }
Item *neg_transformer(THD *thd); Item *neg_transformer(THD *thd);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; } CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
void top_level_item() { abort_on_null=1; } void top_level_item() { abort_on_null=1; }
}; };
@ -1395,7 +1409,12 @@ public:
longlong val_int(); longlong val_int();
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
const char *func_name() const { return "regexp"; } const char *func_name() const { return "regexp"; }
void print(String *str) { print_op(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
print_op(str, query_type);
}
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
}; };
@ -1407,7 +1426,11 @@ public:
Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b) {} Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b) {}
longlong val_int() { return 0;} longlong val_int() { return 0;}
const char *func_name() const { return "regex"; } const char *func_name() const { return "regex"; }
void print(String *str) { print_op(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
print_op(str, query_type);
}
}; };
#endif /* USE_REGEX */ #endif /* USE_REGEX */
@ -1444,7 +1467,7 @@ public:
List<Item>* argument_list() { return &list; } List<Item>* argument_list() { return &list; }
table_map used_tables() const; table_map used_tables() const;
void update_used_tables(); void update_used_tables();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
COND **conds); COND **conds);
@ -1568,7 +1591,7 @@ public:
void update_used_tables(); void update_used_tables();
bool walk(Item_processor processor, bool walk_subquery, uchar *arg); bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
Item *transform(Item_transformer transformer, uchar *arg); Item *transform(Item_transformer transformer, uchar *arg);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
CHARSET_INFO *compare_collation() CHARSET_INFO *compare_collation()
{ return fields.head()->collation.collation; } { return fields.head()->collation.collation; }
}; };

View File

@ -374,37 +374,37 @@ table_map Item_func::not_null_tables() const
} }
void Item_func::print(String *str) void Item_func::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
str->append('('); str->append('(');
print_args(str, 0); print_args(str, 0, query_type);
str->append(')'); str->append(')');
} }
void Item_func::print_args(String *str, uint from) void Item_func::print_args(String *str, uint from, enum_query_type query_type)
{ {
for (uint i=from ; i < arg_count ; i++) for (uint i=from ; i < arg_count ; i++)
{ {
if (i != from) if (i != from)
str->append(','); str->append(',');
args[i]->print(str); args[i]->print(str, query_type);
} }
} }
void Item_func::print_op(String *str) void Item_func::print_op(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
for (uint i=0 ; i < arg_count-1 ; i++) for (uint i=0 ; i < arg_count-1 ; i++)
{ {
args[i]->print(str); args[i]->print(str, query_type);
str->append(' '); str->append(' ');
str->append(func_name()); str->append(func_name());
str->append(' '); str->append(' ');
} }
args[arg_count-1]->print(str); args[arg_count-1]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -884,10 +884,10 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
} }
void Item_func_signed::print(String *str) void Item_func_signed::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("cast(")); str->append(STRING_WITH_LEN("cast("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as signed)")); str->append(STRING_WITH_LEN(" as signed)"));
} }
@ -955,10 +955,10 @@ longlong Item_func_signed::val_int()
} }
void Item_func_unsigned::print(String *str) void Item_func_unsigned::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("cast(")); str->append(STRING_WITH_LEN("cast("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as unsigned)")); str->append(STRING_WITH_LEN(" as unsigned)"));
} }
@ -1064,7 +1064,7 @@ err:
} }
void Item_decimal_typecast::print(String *str) void Item_decimal_typecast::print(String *str, enum_query_type query_type)
{ {
char len_buf[20*3 + 1]; char len_buf[20*3 + 1];
char *end; char *end;
@ -1072,7 +1072,7 @@ void Item_decimal_typecast::print(String *str)
uint precision= my_decimal_length_to_precision(max_length, decimals, uint precision= my_decimal_length_to_precision(max_length, decimals,
unsigned_flag); unsigned_flag);
str->append(STRING_WITH_LEN("cast(")); str->append(STRING_WITH_LEN("cast("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as decimal(")); str->append(STRING_WITH_LEN(" as decimal("));
end=int10_to_str(precision, len_buf,10); end=int10_to_str(precision, len_buf,10);
@ -2537,16 +2537,16 @@ longlong Item_func_locate::val_int()
} }
void Item_func_locate::print(String *str) void Item_func_locate::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("locate(")); str->append(STRING_WITH_LEN("locate("));
args[1]->print(str); args[1]->print(str, query_type);
str->append(','); str->append(',');
args[0]->print(str); args[0]->print(str, query_type);
if (arg_count == 3) if (arg_count == 3)
{ {
str->append(','); str->append(',');
args[2]->print(str); args[2]->print(str, query_type);
} }
str->append(')'); str->append(')');
} }
@ -3095,7 +3095,7 @@ void Item_udf_func::cleanup()
} }
void Item_udf_func::print(String *str) void Item_udf_func::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
str->append('('); str->append('(');
@ -3103,7 +3103,7 @@ void Item_udf_func::print(String *str)
{ {
if (i != 0) if (i != 0)
str->append(','); str->append(',');
args[i]->print_item_w_name(str); args[i]->print_item_w_name(str, query_type);
} }
str->append(')'); str->append(')');
} }
@ -3683,12 +3683,12 @@ longlong Item_func_benchmark::val_int()
} }
void Item_func_benchmark::print(String *str) void Item_func_benchmark::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("benchmark(")); str->append(STRING_WITH_LEN("benchmark("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(','); str->append(',');
args[1]->print(str); args[1]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -4264,22 +4264,23 @@ my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
} }
void Item_func_set_user_var::print(String *str) void Item_func_set_user_var::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("(@")); str->append(STRING_WITH_LEN("(@"));
str->append(name.str, name.length); str->append(name.str, name.length);
str->append(STRING_WITH_LEN(":=")); str->append(STRING_WITH_LEN(":="));
args[0]->print(str); args[0]->print(str, query_type);
str->append(')'); str->append(')');
} }
void Item_func_set_user_var::print_as_stmt(String *str) void Item_func_set_user_var::print_as_stmt(String *str,
enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("set @")); str->append(STRING_WITH_LEN("set @"));
str->append(name.str, name.length); str->append(name.str, name.length);
str->append(STRING_WITH_LEN(":=")); str->append(STRING_WITH_LEN(":="));
args[0]->print(str); args[0]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -4652,7 +4653,7 @@ enum Item_result Item_func_get_user_var::result_type() const
} }
void Item_func_get_user_var::print(String *str) void Item_func_get_user_var::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("(@")); str->append(STRING_WITH_LEN("(@"));
str->append(name.str,name.length); str->append(name.str,name.length);
@ -4750,7 +4751,7 @@ my_decimal* Item_user_var_as_out_param::val_decimal(my_decimal *decimal_buffer)
} }
void Item_user_var_as_out_param::print(String *str) void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
{ {
str->append('@'); str->append('@');
str->append(name.str,name.length); str->append(name.str,name.length);
@ -5089,12 +5090,12 @@ double Item_func_match::val_real()
table->record[0], 0)); table->record[0], 0));
} }
void Item_func_match::print(String *str) void Item_func_match::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("(match ")); str->append(STRING_WITH_LEN("(match "));
print_args(str, 1); print_args(str, 1, query_type);
str->append(STRING_WITH_LEN(" against (")); str->append(STRING_WITH_LEN(" against ("));
args[0]->print(str); args[0]->print(str, query_type);
if (flags & FT_BOOL) if (flags & FT_BOOL)
str->append(STRING_WITH_LEN(" in boolean mode")); str->append(STRING_WITH_LEN(" in boolean mode"));
else if (flags & FT_EXPAND) else if (flags & FT_EXPAND)
@ -5505,7 +5506,7 @@ Item_result
Item_func_sp::result_type() const Item_func_sp::result_type() const
{ {
DBUG_ENTER("Item_func_sp::result_type"); DBUG_ENTER("Item_func_sp::result_type");
DBUG_PRINT("info", ("m_sp = %p", m_sp)); DBUG_PRINT("info", ("m_sp = %p", (void *) m_sp));
DBUG_ASSERT(sp_result_field); DBUG_ASSERT(sp_result_field);
DBUG_RETURN(sp_result_field->result_type()); DBUG_RETURN(sp_result_field->result_type());
} }

View File

@ -140,9 +140,9 @@ public:
inline uint argument_count() const { return arg_count; } inline uint argument_count() const { return arg_count; }
inline void remove_arguments() { arg_count=0; } inline void remove_arguments() { arg_count=0; }
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void print_op(String *str); void print_op(String *str, enum_query_type query_type);
void print_args(String *str, uint from); void print_args(String *str, uint from, enum_query_type query_type);
virtual void fix_num_length_and_dec(); virtual void fix_num_length_and_dec();
void count_only_length(); void count_only_length();
void count_real_length(); void count_real_length();
@ -293,7 +293,12 @@ class Item_num_op :public Item_func_numhybrid
public: public:
Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {} Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {}
virtual void result_precision()= 0; virtual void result_precision()= 0;
void print(String *str) { print_op(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
print_op(str, query_type);
}
void find_num_type(); void find_num_type();
String *str_op(String *str) { DBUG_ASSERT(0); return 0; } String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
@ -339,7 +344,7 @@ public:
longlong val_int_from_str(int *error); longlong val_int_from_str(int *error);
void fix_length_and_dec() void fix_length_and_dec()
{ max_length=args[0]->max_length; unsigned_flag=0; } { max_length=args[0]->max_length; unsigned_flag=0; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
uint decimal_precision() const { return args[0]->decimal_precision(); } uint decimal_precision() const { return args[0]->decimal_precision(); }
}; };
@ -352,7 +357,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ max_length=args[0]->max_length; unsigned_flag=1; } { max_length=args[0]->max_length; unsigned_flag=1; }
longlong val_int(); longlong val_int();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -373,7 +378,7 @@ public:
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
void fix_length_and_dec() {}; void fix_length_and_dec() {};
const char *func_name() const { return "decimal_typecast"; } const char *func_name() const { return "decimal_typecast"; }
void print(String *); virtual void print(String *str, enum_query_type query_type);
}; };
@ -441,7 +446,12 @@ public:
longlong val_int(); longlong val_int();
const char *func_name() const { return "DIV"; } const char *func_name() const { return "DIV"; }
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str) { print_op(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
print_op(str, query_type);
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
}; };
@ -843,7 +853,7 @@ public:
const char *func_name() const { return "locate"; } const char *func_name() const { return "locate"; }
longlong val_int(); longlong val_int();
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -900,7 +910,11 @@ public:
Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {} Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {}
Item_func_bit(Item *a) :Item_int_func(a) {} Item_func_bit(Item *a) :Item_int_func(a) {}
void fix_length_and_dec() { unsigned_flag= 1; } void fix_length_and_dec() { unsigned_flag= 1; }
void print(String *str) { print_op(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
print_op(str, query_type);
}
}; };
class Item_func_bit_or :public Item_func_bit class Item_func_bit_or :public Item_func_bit
@ -950,7 +964,11 @@ public:
Item_func_bit_neg(Item *a) :Item_func_bit(a) {} Item_func_bit_neg(Item *a) :Item_func_bit(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "~"; } const char *func_name() const { return "~"; }
void print(String *str) { Item_func::print(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
}
}; };
@ -979,7 +997,7 @@ public:
longlong val_int(); longlong val_int();
const char *func_name() const { return "benchmark"; } const char *func_name() const { return "benchmark"; }
void fix_length_and_dec() { max_length=1; maybe_null=0; } void fix_length_and_dec() { max_length=1; maybe_null=0; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -1076,7 +1094,7 @@ public:
Item_result result_type () const { return udf.result_type(); } Item_result result_type () const { return udf.result_type(); }
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
bool is_expensive() { return 1; } bool is_expensive() { return 1; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -1313,8 +1331,8 @@ public:
enum Item_result result_type () const { return cached_result_type; } enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void print_as_stmt(String *str); void print_as_stmt(String *str, enum_query_type query_type);
const char *func_name() const { return "set_user_var"; } const char *func_name() const { return "set_user_var"; }
int save_in_field(Field *field, bool no_conversions, int save_in_field(Field *field, bool no_conversions,
bool can_use_result_field); bool can_use_result_field);
@ -1344,7 +1362,7 @@ public:
my_decimal *val_decimal(my_decimal*); my_decimal *val_decimal(my_decimal*);
String *val_str(String* str); String *val_str(String* str);
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
enum Item_result result_type() const; enum Item_result result_type() const;
/* /*
We must always return variables as strings to guard against selects of type We must always return variables as strings to guard against selects of type
@ -1389,7 +1407,7 @@ public:
my_decimal *val_decimal(my_decimal *decimal_buffer); my_decimal *val_decimal(my_decimal *decimal_buffer);
/* fix_fields() binds variable name with its entry structure */ /* fix_fields() binds variable name with its entry structure */
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void set_null_value(CHARSET_INFO* cs); void set_null_value(CHARSET_INFO* cs);
void set_value(const char *str, uint length, CHARSET_INFO* cs); void set_value(const char *str, uint length, CHARSET_INFO* cs);
}; };
@ -1467,7 +1485,7 @@ public:
/* The following should be safe, even if we compare doubles */ /* The following should be safe, even if we compare doubles */
longlong val_int() { DBUG_ASSERT(fixed == 1); return val_real() != 0.0; } longlong val_int() { DBUG_ASSERT(fixed == 1); return val_real() != 0.0; }
double val_real(); double val_real();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool fix_index(); bool fix_index();
void init_search(bool no_order); void init_search(bool no_order);

View File

@ -225,7 +225,12 @@ public:
return "sp_unknown"; return "sp_unknown";
} }
} }
void print(String *str) { Item_func::print(str); }
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
}
void fix_length_and_dec() { maybe_null= 1; } void fix_length_and_dec() { maybe_null= 1; }
bool is_null() { (void) val_int(); return null_value; } bool is_null() { (void) val_int(); return null_value; }
}; };

View File

@ -134,14 +134,14 @@ bool Item_row::check_cols(uint c)
return 0; return 0;
} }
void Item_row::print(String *str) void Item_row::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
for (uint i= 0; i < arg_count; i++) for (uint i= 0; i < arg_count; i++)
{ {
if (i) if (i)
str->append(','); str->append(',');
items[i]->print(str); items[i]->print(str, query_type);
} }
str->append(')'); str->append(')');
} }

View File

@ -65,7 +65,7 @@ public:
bool const_item() const { return const_item_cache; }; bool const_item() const { return const_item_cache; };
enum Item_result result_type() const { return ROW_RESULT; } enum Item_result result_type() const { return ROW_RESULT; }
void update_used_tables(); void update_used_tables();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool walk(Item_processor processor, bool walk_subquery, uchar *arg); bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
Item *transform(Item_transformer transformer, uchar *arg); Item *transform(Item_transformer transformer, uchar *arg);

View File

@ -1594,20 +1594,20 @@ void Item_func_trim::fix_length_and_dec()
} }
} }
void Item_func_trim::print(String *str) void Item_func_trim::print(String *str, enum_query_type query_type)
{ {
if (arg_count == 1) if (arg_count == 1)
{ {
Item_func::print(str); Item_func::print(str, query_type);
return; return;
} }
str->append(Item_func_trim::func_name()); str->append(Item_func_trim::func_name());
str->append('('); str->append('(');
str->append(mode_name()); str->append(mode_name());
str->append(' '); str->append(' ');
args[1]->print(str); args[1]->print(str, query_type);
str->append(STRING_WITH_LEN(" from ")); str->append(STRING_WITH_LEN(" from "));
args[0]->print(str); args[0]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -2116,12 +2116,12 @@ String *Item_func_format::val_str(String *str)
} }
void Item_func_format::print(String *str) void Item_func_format::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("format(")); str->append(STRING_WITH_LEN("format("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(','); str->append(',');
args[1]->print(str); args[1]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -2292,14 +2292,14 @@ Item *Item_func_make_set::transform(Item_transformer transformer, uchar *arg)
} }
void Item_func_make_set::print(String *str) void Item_func_make_set::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("make_set(")); str->append(STRING_WITH_LEN("make_set("));
item->print(str); item->print(str, query_type);
if (arg_count) if (arg_count)
{ {
str->append(','); str->append(',');
print_args(str, 0); print_args(str, 0, query_type);
} }
str->append(')'); str->append(')');
} }
@ -2710,10 +2710,10 @@ void Item_func_conv_charset::fix_length_and_dec()
max_length = args[0]->max_length*conv_charset->mbmaxlen; max_length = args[0]->max_length*conv_charset->mbmaxlen;
} }
void Item_func_conv_charset::print(String *str) void Item_func_conv_charset::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("convert(")); str->append(STRING_WITH_LEN("convert("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" using ")); str->append(STRING_WITH_LEN(" using "));
str->append(conv_charset->csname); str->append(conv_charset->csname);
str->append(')'); str->append(')');
@ -2781,10 +2781,10 @@ bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const
} }
void Item_func_set_collation::print(String *str) void Item_func_set_collation::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" collate ")); str->append(STRING_WITH_LEN(" collate "));
DBUG_ASSERT(args[1]->basic_const_item() && DBUG_ASSERT(args[1]->basic_const_item() &&
args[1]->type() == Item::STRING_ITEM); args[1]->type() == Item::STRING_ITEM);
@ -2903,10 +2903,10 @@ String *Item_func_unhex::val_str(String *str)
} }
void Item_func_binary::print(String *str) void Item_func_binary::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("cast(")); str->append(STRING_WITH_LEN("cast("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as binary)")); str->append(STRING_WITH_LEN(" as binary)"));
} }

View File

@ -225,7 +225,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "trim"; } const char *func_name() const { return "trim"; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
virtual const char *mode_name() const { return "both"; } virtual const char *mode_name() const { return "both"; }
}; };
@ -482,7 +482,7 @@ public:
Item_str_func::walk(processor, walk_subquery, arg); Item_str_func::walk(processor, walk_subquery, arg);
} }
Item *transform(Item_transformer transformer, uchar *arg); Item *transform(Item_transformer transformer, uchar *arg);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -494,7 +494,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "format"; } const char *func_name() const { return "format"; }
void print(String *); virtual void print(String *str, enum_query_type query_type);
}; };
@ -617,7 +617,7 @@ public:
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
max_length=args[0]->max_length; max_length=args[0]->max_length;
} }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
const char *func_name() const { return "cast_as_binary"; } const char *func_name() const { return "cast_as_binary"; }
}; };
@ -719,7 +719,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "convert"; } const char *func_name() const { return "convert"; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
class Item_func_set_collation :public Item_str_func class Item_func_set_collation :public Item_str_func
@ -731,7 +731,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
const char *func_name() const { return "collate"; } const char *func_name() const { return "collate"; }
enum Functype functype() const { return COLLATE_FUNC; } enum Functype functype() const { return COLLATE_FUNC; }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
Item_field *filed_for_view_update() Item_field *filed_for_view_update()
{ {
/* this function is transparent for view updating */ /* this function is transparent for view updating */

View File

@ -306,10 +306,10 @@ void Item_subselect::update_used_tables()
} }
void Item_subselect::print(String *str) void Item_subselect::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
engine->print(str); engine->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -391,10 +391,10 @@ void Item_maxmin_subselect::cleanup()
} }
void Item_maxmin_subselect::print(String *str) void Item_maxmin_subselect::print(String *str, enum_query_type query_type)
{ {
str->append(max?"<max>":"<min>", 5); str->append(max?"<max>":"<min>", 5);
Item_singlerow_subselect::print(str); Item_singlerow_subselect::print(str, query_type);
} }
@ -630,10 +630,10 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex):
} }
void Item_exists_subselect::print(String *str) void Item_exists_subselect::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("exists")); str->append(STRING_WITH_LEN("exists"));
Item_subselect::print(str); Item_subselect::print(str, query_type);
} }
@ -1553,16 +1553,16 @@ err:
} }
void Item_in_subselect::print(String *str) void Item_in_subselect::print(String *str, enum_query_type query_type)
{ {
if (transformed) if (transformed)
str->append(STRING_WITH_LEN("<exists>")); str->append(STRING_WITH_LEN("<exists>"));
else else
{ {
left_expr->print(str); left_expr->print(str, query_type);
str->append(STRING_WITH_LEN(" in ")); str->append(STRING_WITH_LEN(" in "));
} }
Item_subselect::print(str); Item_subselect::print(str, query_type);
} }
@ -1587,18 +1587,18 @@ Item_allany_subselect::select_transformer(JOIN *join)
} }
void Item_allany_subselect::print(String *str) void Item_allany_subselect::print(String *str, enum_query_type query_type)
{ {
if (transformed) if (transformed)
str->append(STRING_WITH_LEN("<exists>")); str->append(STRING_WITH_LEN("<exists>"));
else else
{ {
left_expr->print(str); left_expr->print(str, query_type);
str->append(' '); str->append(' ');
str->append(func->symbol(all)); str->append(func->symbol(all));
str->append(all ? " all " : " any ", 5); str->append(all ? " all " : " any ", 5);
} }
Item_subselect::print(str); Item_subselect::print(str, query_type);
} }
@ -2384,22 +2384,24 @@ table_map subselect_union_engine::upper_select_const_tables()
} }
void subselect_single_select_engine::print(String *str) void subselect_single_select_engine::print(String *str,
enum_query_type query_type)
{ {
select_lex->print(thd, str); select_lex->print(thd, str, query_type);
} }
void subselect_union_engine::print(String *str) void subselect_union_engine::print(String *str, enum_query_type query_type)
{ {
unit->print(str); unit->print(str, query_type);
} }
void subselect_uniquesubquery_engine::print(String *str) void subselect_uniquesubquery_engine::print(String *str,
enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("<primary_index_lookup>(")); str->append(STRING_WITH_LEN("<primary_index_lookup>("));
tab->ref.items[0]->print(str); tab->ref.items[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" in ")); str->append(STRING_WITH_LEN(" in "));
str->append(tab->table->s->table_name.str, tab->table->s->table_name.length); str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
KEY *key_info= tab->table->key_info+ tab->ref.key; KEY *key_info= tab->table->key_info+ tab->ref.key;
@ -2408,16 +2410,17 @@ void subselect_uniquesubquery_engine::print(String *str)
if (cond) if (cond)
{ {
str->append(STRING_WITH_LEN(" where ")); str->append(STRING_WITH_LEN(" where "));
cond->print(str); cond->print(str, query_type);
} }
str->append(')'); str->append(')');
} }
void subselect_indexsubquery_engine::print(String *str) void subselect_indexsubquery_engine::print(String *str,
enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("<index_lookup>(")); str->append(STRING_WITH_LEN("<index_lookup>("));
tab->ref.items[0]->print(str); tab->ref.items[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" in ")); str->append(STRING_WITH_LEN(" in "));
str->append(tab->table->s->table_name.str, tab->table->s->table_name.length); str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
KEY *key_info= tab->table->key_info+ tab->ref.key; KEY *key_info= tab->table->key_info+ tab->ref.key;
@ -2428,12 +2431,12 @@ void subselect_indexsubquery_engine::print(String *str)
if (cond) if (cond)
{ {
str->append(STRING_WITH_LEN(" where ")); str->append(STRING_WITH_LEN(" where "));
cond->print(str); cond->print(str, query_type);
} }
if (having) if (having)
{ {
str->append(STRING_WITH_LEN(" having ")); str->append(STRING_WITH_LEN(" having "));
having->print(str); having->print(str, query_type);
} }
str->append(')'); str->append(')');
} }

View File

@ -103,7 +103,7 @@ public:
inline bool get_const_item_cache() { return const_item_cache; } inline bool get_const_item_cache() { return const_item_cache; }
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
void update_used_tables(); void update_used_tables();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
virtual bool have_guarded_conds() { return FALSE; } virtual bool have_guarded_conds() { return FALSE; }
bool change_engine(subselect_engine *eng) bool change_engine(subselect_engine *eng)
{ {
@ -203,7 +203,7 @@ protected:
public: public:
Item_maxmin_subselect(THD *thd, Item_subselect *parent, Item_maxmin_subselect(THD *thd, Item_subselect *parent,
st_select_lex *select_lex, bool max); st_select_lex *select_lex, bool max);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void cleanup(); void cleanup();
bool any_value() { return was_values; } bool any_value() { return was_values; }
void register_value() { was_values= TRUE; } void register_value() { was_values= TRUE; }
@ -234,7 +234,7 @@ public:
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool val_bool(); bool val_bool();
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
friend class select_exists_subselect; friend class select_exists_subselect;
friend class subselect_uniquesubquery_engine; friend class subselect_uniquesubquery_engine;
@ -312,7 +312,7 @@ public:
void top_level_item() { abort_on_null=1; } void top_level_item() { abort_on_null=1; }
inline bool is_top_level_item() { return abort_on_null; } inline bool is_top_level_item() { return abort_on_null; }
bool test_limit(st_select_lex_unit *unit); bool test_limit(st_select_lex_unit *unit);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
friend class Item_ref_null_helper; friend class Item_ref_null_helper;
@ -335,7 +335,7 @@ public:
// only ALL subquery has upper not // only ALL subquery has upper not
subs_type substype() { return all?ALL_SUBS:ANY_SUBS; } subs_type substype() { return all?ALL_SUBS:ANY_SUBS; }
trans_res select_transformer(JOIN *join); trans_res select_transformer(JOIN *join);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -399,7 +399,7 @@ public:
virtual bool may_be_null() { return maybe_null; }; virtual bool may_be_null() { return maybe_null; };
virtual table_map upper_select_const_tables()= 0; virtual table_map upper_select_const_tables()= 0;
static table_map calc_const_tables(TABLE_LIST *); static table_map calc_const_tables(TABLE_LIST *);
virtual void print(String *str)= 0; virtual void print(String *str, enum_query_type query_type)= 0;
virtual bool change_result(Item_subselect *si, select_subselect *result)= 0; virtual bool change_result(Item_subselect *si, select_subselect *result)= 0;
virtual bool no_tables()= 0; virtual bool no_tables()= 0;
virtual bool is_executed() const { return FALSE; } virtual bool is_executed() const { return FALSE; }
@ -430,7 +430,7 @@ public:
uint8 uncacheable(); uint8 uncacheable();
void exclude(); void exclude();
table_map upper_select_const_tables(); table_map upper_select_const_tables();
void print (String *str); virtual void print (String *str, enum_query_type query_type);
bool change_result(Item_subselect *si, select_subselect *result); bool change_result(Item_subselect *si, select_subselect *result);
bool no_tables(); bool no_tables();
bool may_be_null(); bool may_be_null();
@ -454,7 +454,7 @@ public:
uint8 uncacheable(); uint8 uncacheable();
void exclude(); void exclude();
table_map upper_select_const_tables(); table_map upper_select_const_tables();
void print (String *str); virtual void print (String *str, enum_query_type query_type);
bool change_result(Item_subselect *si, select_subselect *result); bool change_result(Item_subselect *si, select_subselect *result);
bool no_tables(); bool no_tables();
bool is_executed() const; bool is_executed() const;
@ -511,7 +511,7 @@ public:
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; } uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; }
void exclude(); void exclude();
table_map upper_select_const_tables() { return 0; } table_map upper_select_const_tables() { return 0; }
void print (String *str); virtual void print (String *str, enum_query_type query_type);
bool change_result(Item_subselect *si, select_subselect *result); bool change_result(Item_subselect *si, select_subselect *result);
bool no_tables(); bool no_tables();
int scan_table(); int scan_table();
@ -565,7 +565,7 @@ public:
having(having_arg) having(having_arg)
{} {}
int exec(); int exec();
void print (String *str); virtual void print (String *str, enum_query_type query_type);
}; };

View File

@ -359,14 +359,14 @@ void Item_sum::make_field(Send_field *tmp_field)
} }
void Item_sum::print(String *str) void Item_sum::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
for (uint i=0 ; i < arg_count ; i++) for (uint i=0 ; i < arg_count ; i++)
{ {
if (i) if (i)
str->append(','); str->append(',');
args[i]->print(str); args[i]->print(str, query_type);
} }
str->append(')'); str->append(')');
} }
@ -2716,7 +2716,7 @@ void Item_udf_sum::cleanup()
} }
void Item_udf_sum::print(String *str) void Item_udf_sum::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
str->append('('); str->append('(');
@ -2724,7 +2724,7 @@ void Item_udf_sum::print(String *str)
{ {
if (i) if (i)
str->append(','); str->append(',');
args[i]->print(str); args[i]->print(str, query_type);
} }
str->append(')'); str->append(')');
} }
@ -3460,7 +3460,7 @@ String* Item_func_group_concat::val_str(String* str)
} }
void Item_func_group_concat::print(String *str) void Item_func_group_concat::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("group_concat(")); str->append(STRING_WITH_LEN("group_concat("));
if (distinct) if (distinct)
@ -3469,7 +3469,7 @@ void Item_func_group_concat::print(String *str)
{ {
if (i) if (i)
str->append(','); str->append(',');
args[i]->print(str); args[i]->print(str, query_type);
} }
if (arg_count_order) if (arg_count_order)
{ {
@ -3478,7 +3478,7 @@ void Item_func_group_concat::print(String *str)
{ {
if (i) if (i)
str->append(','); str->append(',');
(*order[i]->item)->print(str); (*order[i]->item)->print(str, query_type);
if (order[i]->asc) if (order[i]->asc)
str->append(STRING_WITH_LEN(" ASC")); str->append(STRING_WITH_LEN(" ASC"));
else else

View File

@ -343,7 +343,7 @@ public:
} }
virtual bool const_item() const { return forced_const; } virtual bool const_item() const { return forced_const; }
void make_field(Send_field *field); void make_field(Send_field *field);
void print(String *str); virtual void print(String *str, enum_query_type query_type);
void fix_num_length_and_dec(); void fix_num_length_and_dec();
/* /*
@ -984,7 +984,7 @@ public:
void reset_field() {}; void reset_field() {};
void update_field() {}; void update_field() {};
void cleanup(); void cleanup();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -1257,7 +1257,7 @@ public:
String* val_str(String* str); String* val_str(String* str);
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
void no_rows_in_result() {} void no_rows_in_result() {}
void print(String *str); virtual void print(String *str, enum_query_type query_type);
virtual bool change_context_processor(uchar *cntx) virtual bool change_context_processor(uchar *cntx)
{ context= (Name_resolution_context *)cntx; return FALSE; } { context= (Name_resolution_context *)cntx; return FALSE; }
}; };

View File

@ -2217,23 +2217,23 @@ static const char *interval_names[]=
"second_microsecond" "second_microsecond"
}; };
void Item_date_add_interval::print(String *str) void Item_date_add_interval::print(String *str, enum_query_type query_type)
{ {
str->append('('); str->append('(');
args[0]->print(str); args[0]->print(str, query_type);
str->append(date_sub_interval?" - interval ":" + interval "); str->append(date_sub_interval?" - interval ":" + interval ");
args[1]->print(str); args[1]->print(str, query_type);
str->append(' '); str->append(' ');
str->append(interval_names[int_type]); str->append(interval_names[int_type]);
str->append(')'); str->append(')');
} }
void Item_extract::print(String *str) void Item_extract::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("extract(")); str->append(STRING_WITH_LEN("extract("));
str->append(interval_names[int_type]); str->append(interval_names[int_type]);
str->append(STRING_WITH_LEN(" from ")); str->append(STRING_WITH_LEN(" from "));
args[0]->print(str); args[0]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -2374,20 +2374,20 @@ bool Item_char_typecast::eq(const Item *item, bool binary_cmp) const
return 1; return 1;
} }
void Item_typecast::print(String *str) void Item_typecast::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("cast(")); str->append(STRING_WITH_LEN("cast("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as ")); str->append(STRING_WITH_LEN(" as "));
str->append(cast_type()); str->append(cast_type());
str->append(')'); str->append(')');
} }
void Item_char_typecast::print(String *str) void Item_char_typecast::print(String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN("cast(")); str->append(STRING_WITH_LEN("cast("));
args[0]->print(str); args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as char")); str->append(STRING_WITH_LEN(" as char"));
if (cast_length >= 0) if (cast_length >= 0)
{ {
@ -2822,7 +2822,7 @@ null_date:
} }
void Item_func_add_time::print(String *str) void Item_func_add_time::print(String *str, enum_query_type query_type)
{ {
if (is_date) if (is_date)
{ {
@ -2836,9 +2836,9 @@ void Item_func_add_time::print(String *str)
else else
str->append(STRING_WITH_LEN("subtime(")); str->append(STRING_WITH_LEN("subtime("));
} }
args[0]->print(str); args[0]->print(str, query_type);
str->append(','); str->append(',');
args[1]->print(str); args[1]->print(str, query_type);
str->append(')'); str->append(')');
} }
@ -3083,7 +3083,7 @@ null_date:
} }
void Item_func_timestamp_diff::print(String *str) void Item_func_timestamp_diff::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
str->append('('); str->append('(');
@ -3123,7 +3123,7 @@ void Item_func_timestamp_diff::print(String *str)
for (uint i=0 ; i < 2 ; i++) for (uint i=0 ; i < 2 ; i++)
{ {
str->append(','); str->append(',');
args[i]->print(str); args[i]->print(str, query_type);
} }
str->append(')'); str->append(')');
} }
@ -3163,7 +3163,7 @@ String *Item_func_get_format::val_str(String *str)
} }
void Item_func_get_format::print(String *str) void Item_func_get_format::print(String *str, enum_query_type query_type)
{ {
str->append(func_name()); str->append(func_name());
str->append('('); str->append('(');
@ -3181,7 +3181,7 @@ void Item_func_get_format::print(String *str)
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
} }
args[0]->print(str); args[0]->print(str, query_type);
str->append(')'); str->append(')');
} }

View File

@ -694,7 +694,7 @@ public:
longlong val_int(); longlong val_int();
bool get_date(MYSQL_TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -711,7 +711,7 @@ class Item_extract :public Item_int_func
const char *func_name() const { return "extract"; } const char *func_name() const { return "extract"; }
void fix_length_and_dec(); void fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void print(String *str); virtual void print(String *str, enum_query_type query_type);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
}; };
@ -735,7 +735,7 @@ public:
max_length=args[0]->max_length; max_length=args[0]->max_length;
} }
virtual const char* cast_type() const= 0; virtual const char* cast_type() const= 0;
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -767,7 +767,7 @@ public:
const char* cast_type() const { return "char"; }; const char* cast_type() const { return "char"; };
String *val_str(String *a); String *val_str(String *a);
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -901,7 +901,7 @@ public:
{ {
return tmp_table_field_from_field_type(table, 0); return tmp_table_field_from_field_type(table, 0);
} }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
const char *func_name() const { return "add_time"; } const char *func_name() const { return "add_time"; }
double val_real() { return val_real_from_decimal(); } double val_real() { return val_real_from_decimal(); }
my_decimal *val_decimal(my_decimal *decimal_value) my_decimal *val_decimal(my_decimal *decimal_value)
@ -977,7 +977,7 @@ public:
decimals=0; decimals=0;
maybe_null=1; maybe_null=1;
} }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };
@ -1001,7 +1001,7 @@ public:
decimals=0; decimals=0;
max_length=17*MY_CHARSET_BIN_MB_MAXLEN; max_length=17*MY_CHARSET_BIN_MB_MAXLEN;
} }
void print(String *str); virtual void print(String *str, enum_query_type query_type);
}; };

View File

@ -3383,6 +3383,16 @@ THD::binlog_start_trans_and_stmt()
if (options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) if (options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
trans_register_ha(this, TRUE, binlog_hton); trans_register_ha(this, TRUE, binlog_hton);
trans_register_ha(this, FALSE, binlog_hton); trans_register_ha(this, FALSE, binlog_hton);
/*
Mark statement transaction as read/write. We never start
a binary log transaction and keep it read-only,
therefore it's best to mark the transaction read/write just
at the same time we start it.
Not necessary to mark the normal transaction read/write
since the statement-level flag will be propagated automatically
inside ha_commit_trans.
*/
ha_data[binlog_hton->slot].ha_info[0].set_trx_read_write();
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -3116,7 +3116,7 @@ int Format_description_log_event::do_apply_event(Relay_log_info const *rli)
original place when it comes to us; we'll know this by checking original place when it comes to us; we'll know this by checking
log_pos ("artificial" events have log_pos == 0). log_pos ("artificial" events have log_pos == 0).
*/ */
if (!artificial_event && created && thd->transaction.all.nht) if (!artificial_event && created && thd->transaction.all.ha_list)
{ {
/* This is not an error (XA is safe), just an information */ /* This is not an error (XA is safe), just an information */
rli->report(INFORMATION_LEVEL, 0, rli->report(INFORMATION_LEVEL, 0,

View File

@ -44,6 +44,19 @@
#include "sql_plugin.h" #include "sql_plugin.h"
#include "scheduler.h" #include "scheduler.h"
/**
Query type constants.
QT_ORDINARY -- ordinary SQL query.
QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
character set introducers).
*/
enum enum_query_type
{
QT_ORDINARY,
QT_IS
};
/* TODO convert all these three maps to Bitmap classes */ /* TODO convert all these three maps to Bitmap classes */
typedef ulonglong table_map; /* Used for table bits in join */ typedef ulonglong table_map; /* Used for table bits in join */
#if MAX_INDEXES <= 64 #if MAX_INDEXES <= 64
@ -1711,7 +1724,7 @@ bool mysql_manager_submit(void (*action)());
/* sql_test.cc */ /* sql_test.cc */
#ifndef DBUG_OFF #ifndef DBUG_OFF
void print_where(COND *cond,const char *info); void print_where(COND *cond,const char *info, enum_query_type query_type);
void print_cached_tables(void); void print_cached_tables(void);
void TEST_filesort(SORT_FIELD *sortorder,uint s_length); void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
void print_plan(JOIN* join,uint idx, double record_count, double read_time, void print_plan(JOIN* join,uint idx, double record_count, double read_time,

View File

@ -2734,8 +2734,18 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
(TABLE_LIST*) 0, &not_used); // Flush logs (TABLE_LIST*) 0, &not_used); // Flush logs
} }
/* reenable logs after the options were reloaded */ /* reenable logs after the options were reloaded */
logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_TABLE:LOG_NONE, if (log_output_options & LOG_NONE)
{
logger.set_handlers(LOG_FILE,
opt_slow_log ? LOG_TABLE : LOG_NONE,
opt_log ? LOG_TABLE : LOG_NONE); opt_log ? LOG_TABLE : LOG_NONE);
}
else
{
logger.set_handlers(LOG_FILE,
opt_slow_log ? log_output_options : LOG_NONE,
opt_log ? log_output_options : LOG_NONE);
}
break; break;
#ifdef USE_ONE_SIGNAL_HAND #ifdef USE_ONE_SIGNAL_HAND
case THR_SERVER_ALARM: case THR_SERVER_ALARM:

Some files were not shown because too many files have changed in this diff Show More