Manual merge of 5.1 into 5.1-runtime

parent dc98aa82
...@@ -224,7 +224,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -224,7 +224,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) AS `min(t3.a)` from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) AS `avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))` from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) AS `min(t3.a)` from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) AS `avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))` from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4`
select * from t3 where exists (select * from t2 where t2.b=t3.a); select * from t3 where exists (select * from t2 where t2.b=t3.a);
a a
...@@ -313,8 +313,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -313,8 +313,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 100.00 Using where 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 100.00 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings: Warnings:
Note 1276 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select (select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` AS `a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` Note 1003 select (select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` AS `a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
...@@ -330,9 +330,9 @@ patient_uq clinic_uq ...@@ -330,9 +330,9 @@ patient_uq clinic_uq
explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
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 t6 ALL NULL NULL NULL NULL 4 100.00 Using where 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 100.00 Using where
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1 100.00 Using where; Using index
Warnings: Warnings:
Note 1276 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
ERROR 23000: Column 'a' in field list is ambiguous ERROR 23000: Column 'a' in field list is ambiguous
...@@ -868,7 +868,7 @@ explain extended select (select a+1) from t1; ...@@ -868,7 +868,7 @@ explain extended select (select a+1) 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 3 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
Warnings: Warnings:
Note 1276 Field or reference 'a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1249 Select 2 was reduced during optimization Note 1249 Select 2 was reduced during optimization
Note 1003 select (`test`.`t1`.`a` + 1) AS `(select a+1)` from `test`.`t1` Note 1003 select (`test`.`t1`.`a` + 1) AS `(select a+1)` from `test`.`t1`
select (select a+1) from t1; select (select a+1) from t1;
...@@ -1741,9 +1741,9 @@ Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `tes ...@@ -1741,9 +1741,9 @@ Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `tes
explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
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 tt ALL NULL NULL NULL NULL 12 100.00 Using where 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 tt.id 1 100.00 Using where; Using index
Warnings: Warnings:
Note 1276 Field or reference 'tt.id' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
...@@ -2279,7 +2279,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -2279,7 +2279,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY up ALL NULL NULL NULL NULL 2 100.00 Using where 1 PRIMARY up ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 AS `Not_used` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 AS `Not_used` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))
drop table t1; drop table t1;
CREATE TABLE t1 (t1_a int); CREATE TABLE t1 (t1_a int);
......
...@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) ...@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
MY_INIT(argv[0]); MY_INIT(argv[0]);
log_init(); log_init();
umask(0117); umask(0117);
srand((unsigned int) time(0)); srand((uint) time(0));
/* Main function. */ /* Main function. */
......
...@@ -110,25 +110,22 @@ Event_worker_thread::print_warnings(THD *thd, Event_job_data *et) ...@@ -110,25 +110,22 @@ Event_worker_thread::print_warnings(THD *thd, Event_job_data *et)
SYNOPSIS SYNOPSIS
post_init_event_thread() post_init_event_thread()
thd Thread thd Thread
NOTES
Before this is called, one should not do any DBUG_XXX() calls.
*/ */
bool bool
post_init_event_thread(THD *thd) post_init_event_thread(THD *thd)
{ {
my_thread_init(); (void) init_new_connection_handler_thread();
pthread_detach_this_thread();
thd->real_id= pthread_self();
if (init_thr_lock() || thd->store_globals()) if (init_thr_lock() || thd->store_globals())
{ {
thd->cleanup(); thd->cleanup();
return TRUE; return TRUE;
} }
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
#endif
pthread_mutex_lock(&LOCK_thread_count); pthread_mutex_lock(&LOCK_thread_count);
threads.append(thd); threads.append(thd);
thread_count++; thread_count++;
...@@ -193,7 +190,7 @@ pre_init_event_thread(THD* thd) ...@@ -193,7 +190,7 @@ pre_init_event_thread(THD* thd)
thd->options|= OPTION_AUTO_IS_NULL; thd->options|= OPTION_AUTO_IS_NULL;
thd->client_capabilities|= CLIENT_MULTI_RESULTS; thd->client_capabilities|= CLIENT_MULTI_RESULTS;
pthread_mutex_lock(&LOCK_thread_count); pthread_mutex_lock(&LOCK_thread_count);
thd->thread_id= thread_id++; thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
/* /*
...@@ -224,20 +221,20 @@ pthread_handler_t ...@@ -224,20 +221,20 @@ pthread_handler_t
event_scheduler_thread(void *arg) event_scheduler_thread(void *arg)
{ {
/* needs to be first for thread_stack */ /* needs to be first for thread_stack */
THD *thd= (THD *)((struct scheduler_param *) arg)->thd; THD *thd= (THD *) ((struct scheduler_param *) arg)->thd;
Event_scheduler *scheduler= ((struct scheduler_param *) arg)->scheduler; Event_scheduler *scheduler= ((struct scheduler_param *) arg)->scheduler;
bool res;
my_free((char*)arg, MYF(0));
thd->thread_stack= (char *)&thd; // remember where our stack is thd->thread_stack= (char *)&thd; // remember where our stack is
res= post_init_event_thread(thd);
DBUG_ENTER("event_scheduler_thread"); DBUG_ENTER("event_scheduler_thread");
my_free((char*)arg, MYF(0));
if (!post_init_event_thread(thd)) if (!res)
scheduler->run(thd); scheduler->run(thd);
deinit_event_thread(thd); deinit_event_thread(thd);
pthread_exit(0);
DBUG_RETURN(0); // Against gcc warnings DBUG_RETURN(0); // Against gcc warnings
} }
...@@ -257,17 +254,13 @@ event_scheduler_thread(void *arg) ...@@ -257,17 +254,13 @@ event_scheduler_thread(void *arg)
pthread_handler_t pthread_handler_t
event_worker_thread(void *arg) event_worker_thread(void *arg)
{ {
/* needs to be first for thread_stack */
THD *thd; THD *thd;
Event_queue_element_for_exec *event= (Event_queue_element_for_exec *)arg; Event_queue_element_for_exec *event= (Event_queue_element_for_exec *)arg;
thd= event->thd; thd= event->thd;
thd->thread_stack= (char *) &thd; // remember where our stack is
Event_worker_thread worker_thread; Event_worker_thread worker_thread;
worker_thread.run(thd, (Event_queue_element_for_exec *)arg); worker_thread.run(thd, event);
deinit_event_thread(thd);
return 0; // Can't return anything here return 0; // Can't return anything here
} }
...@@ -286,13 +279,21 @@ event_worker_thread(void *arg) ...@@ -286,13 +279,21 @@ event_worker_thread(void *arg)
void void
Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event) Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
{ {
/* needs to be first for thread_stack */
char my_stack;
int ret; int ret;
Event_job_data *job_data= NULL; Event_job_data *job_data= NULL;
bool res;
thd->thread_stack= &my_stack; // remember where our stack is
res= post_init_event_thread(thd);
DBUG_ENTER("Event_worker_thread::run"); DBUG_ENTER("Event_worker_thread::run");
DBUG_PRINT("info", ("Baikonur, time is %d, BURAN reporting and operational." DBUG_PRINT("info", ("Baikonur, time is %d, BURAN reporting and operational."
"THD=0x%lx", time(NULL), thd)); "THD=0x%lx", time(NULL), thd));
if (post_init_event_thread(thd))
if (res)
goto end; goto end;
if (!(job_data= new Event_job_data())) if (!(job_data= new Event_job_data()))
...@@ -352,6 +353,8 @@ end: ...@@ -352,6 +353,8 @@ end:
event->name.str)); event->name.str));
delete event; delete event;
deinit_event_thread(thd);
pthread_exit(0);
} }
......
This diff is collapsed.
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