Commit e41f5cc4 authored by unknown's avatar unknown

manual merge


sql/event.cc:
  Auto merged
sql/event.h:
  Auto merged
sql/sql_show.cc:
  Auto merged
parents b3673095 203b37ef
create database if not exists events_test;
use events_test;
set global event_scheduler=0;
"Wait a bit to settle down"
delete from mysql.event;
set global event_scheduler= 1;
set @old_sql_mode:=@@sql_mode;
set sql_mode=ansi;
select get_lock('test_bug16407', 60);
get_lock('test_bug16407', 60)
1
create event e_16407 on schedule every 60 second do
begin
select get_lock('test_bug16407', 60);
drop table "hashed_num";
end|
"Now if everything is fine the event has compiled and is locked
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
# root events_test Connect # User lock select get_lock('test_bug16407', 60)
select release_lock('test_bug16407');
release_lock('test_bug16407')
1
set global event_scheduler= 0;
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
event_schema event_name sql_mode
events_test e_16407 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
"Let's check whether we change the sql_mode on ALTER EVENT"
set sql_mode='traditional';
alter event e_16407 do select 1;
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
event_schema event_name sql_mode
events_test e_16407 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
drop event e_16407;
"Another sql_mode test"
set sql_mode="traditional";
create table events_smode_test(ev_name char(10), a date) engine=myisam;
"This should never insert something"
create event ee_16407_2 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60);
insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
end|
insert into events_smode_test values ('test','1980-19-02')|
ERROR 22007: Incorrect date value: '1980-19-02' for column 'a' at row 1
"This is ok"
create event ee_16407_3 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60);
insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19');
insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29');
end|
set sql_mode=""|
"This will insert rows but they will be truncated"
create event ee_16407_4 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60);
insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956');
end|
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
event_schema event_name sql_mode
events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test ee_16407_4
set sql_mode="ansi";
select get_lock('ee_16407_2', 60);
get_lock('ee_16407_2', 60)
1
set global event_scheduler= 1;
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
# root events_test Connect # User lock select get_lock('ee_16407_2', 60)
# root events_test Connect # User lock select get_lock('ee_16407_2', 60)
# root events_test Connect # User lock select get_lock('ee_16407_2', 60)
select release_lock('ee_16407_2');
release_lock('ee_16407_2')
1
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
set global event_scheduler= 0;
select * from events_smode_test order by ev_name, a;
ev_name a
ee_16407_3 1980-02-19
ee_16407_3 1980-02-29
ee_16407_4 0000-00-00
"OK, last check before we drop them"
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
event_schema event_name sql_mode
events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test ee_16407_4
drop event ee_16407_2;
drop event ee_16407_3;
drop event ee_16407_4;
"And now one last test regarding sql_mode and call of SP from an event"
delete from events_smode_test;
set sql_mode='traditional';
create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end|
create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end|
create event ee_16407_5 on schedule every 60 second do
begin
select get_lock('ee_16407_5', 60);
call events_test.ee_16407_5_pendant();
end|
create event ee_16407_6 on schedule every 60 second do
begin
select get_lock('ee_16407_5', 60);
call events_test.ee_16407_6_pendant();
end|
set sql_mode='ansi';
select get_lock('ee_16407_5', 60);
get_lock('ee_16407_5', 60)
1
set global event_scheduler= 1;
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
# root events_test Connect # User lock select get_lock('ee_16407_5', 60)
# root events_test Connect # User lock select get_lock('ee_16407_5', 60)
select release_lock('ee_16407_5');
release_lock('ee_16407_5')
1
show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler NULL Connect # Sleeping NULL
select * from events_smode_test order by ev_name, a;
ev_name a
ee_16407_6 2004-02-29
"And here we check one more time before we drop the events"
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
event_schema event_name sql_mode
events_test ee_16407_5 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test ee_16407_6 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
drop event ee_16407_5;
drop event ee_16407_6;
drop procedure ee_16407_5_pendant;
drop procedure ee_16407_6_pendant;
set global event_scheduler= 0;
drop table events_smode_test;
set sql_mode=@old_sql_mode;
drop database events_test;
create database if not exists events_test;
use events_test;
#
# Start - 16407: Events: Changes in sql_mode won't be taken into account
#
set global event_scheduler=0;
--echo "Wait a bit to settle down"
--sleep 1
delete from mysql.event;
set global event_scheduler= 1;
set @old_sql_mode:=@@sql_mode;
set sql_mode=ansi;
select get_lock('test_bug16407', 60);
delimiter |;
create event e_16407 on schedule every 60 second do
begin
select get_lock('test_bug16407', 60);
drop table "hashed_num";
end|
delimiter ;|
--sleep 1
--echo "Now if everything is fine the event has compiled and is locked
--replace_column 1 # 6 #
show processlist;
select release_lock('test_bug16407');
set global event_scheduler= 0;
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
--echo "Let's check whether we change the sql_mode on ALTER EVENT"
set sql_mode='traditional';
alter event e_16407 do select 1;
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
drop event e_16407;
--echo "Another sql_mode test"
set sql_mode="traditional";
create table events_smode_test(ev_name char(10), a date) engine=myisam;
--echo "This should never insert something"
delimiter |;
create event ee_16407_2 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60);
insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
end|
--error 1292
insert into events_smode_test values ('test','1980-19-02')|
--echo "This is ok"
create event ee_16407_3 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60);
insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19');
insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29');
end|
set sql_mode=""|
--echo "This will insert rows but they will be truncated"
create event ee_16407_4 on schedule every 60 second do
begin
select get_lock('ee_16407_2', 60);
insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956');
end|
delimiter ;|
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
set sql_mode="ansi";
select get_lock('ee_16407_2', 60);
set global event_scheduler= 1;
--sleep 1
--replace_column 1 # 6 #
show processlist;
select release_lock('ee_16407_2');
--sleep 3
--replace_column 1 # 6 #
show processlist;
set global event_scheduler= 0;
select * from events_smode_test order by ev_name, a;
--echo "OK, last check before we drop them"
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
drop event ee_16407_2;
drop event ee_16407_3;
drop event ee_16407_4;
--echo "And now one last test regarding sql_mode and call of SP from an event"
delete from events_smode_test;
set sql_mode='traditional';
delimiter |;
create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end|
create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end|
create event ee_16407_5 on schedule every 60 second do
begin
select get_lock('ee_16407_5', 60);
call events_test.ee_16407_5_pendant();
end|
create event ee_16407_6 on schedule every 60 second do
begin
select get_lock('ee_16407_5', 60);
call events_test.ee_16407_6_pendant();
end|
delimiter ;|
set sql_mode='ansi';
select get_lock('ee_16407_5', 60);
set global event_scheduler= 1;
--sleep 1
--replace_column 1 # 6 #
show processlist;
select release_lock('ee_16407_5');
--sleep 3
--replace_column 1 # 6 #
show processlist;
select * from events_smode_test order by ev_name, a;
--echo "And here we check one more time before we drop the events"
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
drop event ee_16407_5;
drop event ee_16407_6;
drop procedure ee_16407_5_pendant;
drop procedure ee_16407_6_pendant;
set global event_scheduler= 0;
drop table events_smode_test;
set sql_mode=@old_sql_mode;
#
# End - 16407: Events: Changes in sql_mode won't be taken into account
#
drop database events_test;
...@@ -623,10 +623,18 @@ evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update) ...@@ -623,10 +623,18 @@ evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update)
table->field[EVEX_FIELD_STATUS]->store((longlong)et->status); table->field[EVEX_FIELD_STATUS]->store((longlong)et->status);
/*
Change the SQL_MODE only if body was present in an ALTER EVENT and of course
always during CREATE EVENT.
*/
if (et->body.str) if (et->body.str)
{
table->field[EVEX_FIELD_SQL_MODE]->store((longlong)thd->variables.sql_mode);
if (table->field[field_num= EVEX_FIELD_BODY]-> if (table->field[field_num= EVEX_FIELD_BODY]->
store(et->body.str, et->body.length, system_charset_info)) store(et->body.str, et->body.length, system_charset_info))
goto trunc_err; goto trunc_err;
}
if (et->starts.year) if (et->starts.year)
{ {
......
...@@ -112,7 +112,6 @@ public: ...@@ -112,7 +112,6 @@ public:
enum enum_event_status status; enum enum_event_status status;
sp_head *sphead; sp_head *sphead;
ulong sql_mode; ulong sql_mode;
const uchar *body_begin; const uchar *body_begin;
bool dropped; bool dropped;
......
...@@ -45,6 +45,8 @@ event_timed::init() ...@@ -45,6 +45,8 @@ event_timed::init()
definer_user.str= definer_host.str= 0; definer_user.str= definer_host.str= 0;
definer_user.length= definer_host.length= 0; definer_user.length= definer_host.length= 0;
sql_mode= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -580,6 +582,9 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table) ...@@ -580,6 +582,9 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
else else
et->comment.length= 0; et->comment.length= 0;
et->sql_mode= (ulong) table->field[EVEX_FIELD_SQL_MODE]->val_int();
DBUG_RETURN(0); DBUG_RETURN(0);
error: error:
DBUG_RETURN(EVEX_GET_FIELD_FAILED); DBUG_RETURN(EVEX_GET_FIELD_FAILED);
...@@ -1232,6 +1237,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root) ...@@ -1232,6 +1237,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
char *old_query; char *old_query;
uint old_query_len; uint old_query_len;
st_sp_chistics *p; st_sp_chistics *p;
ulong old_sql_mode= thd->variables.sql_mode;
char create_buf[2048]; char create_buf[2048];
String show_create(create_buf, sizeof(create_buf), system_charset_info); String show_create(create_buf, sizeof(create_buf), system_charset_info);
CHARSET_INFO *old_character_set_client, CHARSET_INFO *old_character_set_client,
...@@ -1251,6 +1257,8 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root) ...@@ -1251,6 +1257,8 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
thd->update_charset(); thd->update_charset();
DBUG_ENTER("event_timed::compile"); DBUG_ENTER("event_timed::compile");
DBUG_PRINT("info",("old_sql_mode=%d new_sql_mode=%d",old_sql_mode, sql_mode));
thd->variables.sql_mode= this->sql_mode;
/* Change the memory root for the execution time */ /* Change the memory root for the execution time */
if (mem_root) if (mem_root)
{ {
...@@ -1302,7 +1310,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root) ...@@ -1302,7 +1310,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
TODO: Handle sql_mode!! TODO: Handle sql_mode!!
*/ */
sphead->set_definer(definer.str, definer.length); sphead->set_definer(definer.str, definer.length);
sphead->set_info(0, 0, &lex.sp_chistics, 0/*sql_mode*/); sphead->set_info(0, 0, &lex.sp_chistics, sql_mode);
sphead->optimize(); sphead->optimize();
ret= 0; ret= 0;
done: done:
...@@ -1316,6 +1324,7 @@ done: ...@@ -1316,6 +1324,7 @@ done:
thd->query_length= old_query_len; thd->query_length= old_query_len;
thd->db= old_db; thd->db= old_db;
thd->variables.sql_mode= old_sql_mode;
thd->variables.character_set_client= old_character_set_client; thd->variables.character_set_client= old_character_set_client;
thd->variables.character_set_results= old_character_set_results; thd->variables.character_set_results= old_character_set_results;
thd->variables.collation_connection= old_collation_connection; thd->variables.collation_connection= old_collation_connection;
......
...@@ -3954,8 +3954,16 @@ fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table) ...@@ -3954,8 +3954,16 @@ fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
sch_table->field[3]->store(et.definer.str, et.definer.length, scs); sch_table->field[3]->store(et.definer.str, et.definer.length, scs);
sch_table->field[4]->store(et.body.str, et.body.length, scs); sch_table->field[4]->store(et.body.str, et.body.length, scs);
// [9] is SQL_MODE and is NULL for now, will be fixed later // [9] is SQL_MODE
sch_table->field[9]->set_null(); {
const char *sql_mode_str="";
ulong sql_mode_len=0;
sql_mode_str=
sys_var_thd_sql_mode::symbolic_mode_representation(thd, et.sql_mode,
&sql_mode_len);
sch_table->field[9]->store((const char*)sql_mode_str, sql_mode_len, scs);
}
if (et.expression) if (et.expression)
{ {
String show_str; String show_str;
...@@ -4802,7 +4810,7 @@ ST_FIELD_INFO events_fields_info[]= ...@@ -4802,7 +4810,7 @@ ST_FIELD_INFO events_fields_info[]=
{"EXECUTE_AT", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Execute at"}, {"EXECUTE_AT", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Execute at"},
{"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value"}, {"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value"},
{"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field"}, {"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field"},
{"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"STARTS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Starts"}, {"STARTS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Starts"},
{"ENDS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Ends"}, {"ENDS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Ends"},
{"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, "Status"}, {"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, "Status"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment