Loading mysql-test/t/kill.test +1 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ connection con1; drop table if exists t1; --enable_warnings --disable_reconnect create table t1 (kill_id int); insert into t1 values(connection_id()); Loading @@ -25,7 +26,6 @@ kill @id; connection con1; --disable_reconnect # this statement should fail --error 2006,2013 select 1; Loading sql/sql_help.cc +14 −16 Original line number Diff line number Diff line Loading @@ -623,38 +623,37 @@ bool mysqld_help(THD *thd, const char *mask) Protocol *protocol= thd->protocol; SQL_SELECT *select; st_find_field used_fields[array_elements(init_used_fields)]; DBUG_ENTER("mysqld_help"); TABLE_LIST *leaves= 0; TABLE_LIST tables[4]; List<String> topics_list, categories_list, subcategories_list; String name, description, example; int count_topics, count_categories, error; uint mlen= strlen(mask); size_t i; MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_help"); bzero((gptr)tables,sizeof(tables)); tables[0].alias= tables[0].table_name= (char*) "help_topic"; tables[0].lock_type= TL_READ; tables[0].next_global= tables[0].next_local= &tables[1]; tables[0].next_name_resolution_table= tables[0].next_local; tables[0].next_global= tables[0].next_local= tables[0].next_name_resolution_table= &tables[1]; tables[1].alias= tables[1].table_name= (char*) "help_category"; tables[1].lock_type= TL_READ; tables[1].next_global= tables[1].next_local= &tables[2]; tables[1].next_name_resolution_table= tables[1].next_local; tables[1].next_global= tables[1].next_local= tables[1].next_name_resolution_table= &tables[2]; tables[2].alias= tables[2].table_name= (char*) "help_relation"; tables[2].lock_type= TL_READ; tables[2].next_global= tables[2].next_local= &tables[3]; tables[2].next_name_resolution_table= tables[2].next_local; tables[2].next_global= tables[2].next_local= tables[2].next_name_resolution_table= &tables[3]; tables[3].alias= tables[3].table_name= (char*) "help_keyword"; tables[3].lock_type= TL_READ; tables[0].db= tables[1].db= tables[2].db= tables[3].db= (char*) "mysql"; List<String> topics_list, categories_list, subcategories_list; String name, description, example; int count_topics, count_categories, error; uint mlen= strlen(mask); MEM_ROOT *mem_root= thd->mem_root; if (open_and_lock_tables(thd, tables)) goto error; /* Init tables and fields to be usable from items tables do not contain VIEWs => we can pass 0 as conds */ setup_tables(thd, &thd->lex->select_lex.context, Loading @@ -663,7 +662,6 @@ bool mysqld_help(THD *thd, const char *mask) memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); if (init_fields(thd, tables, used_fields, array_elements(used_fields))) goto error; size_t i; for (i=0; i<sizeof(tables)/sizeof(TABLE_LIST); i++) tables[i].table->file->init_table_handle_for_HANDLER(); Loading sql/sql_insert.cc +4 −2 Original line number Diff line number Diff line Loading @@ -891,6 +891,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, if (select_lex->group_list.elements == 0) { context->table_list->next_local= save_next_local; /* first_name_resolution_table was set by resolve_in_table_list_only() */ context->first_name_resolution_table-> next_name_resolution_table= save_next_local; } Loading Loading @@ -2199,6 +2200,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) if (lex->select_lex.group_list.elements == 0) { context->table_list->next_local= save_next_local; /* first_name_resolution_table was set by resolve_in_table_list_only() */ context->first_name_resolution_table-> next_name_resolution_table= save_next_local; } Loading sql/sql_lex.cc +2 −2 Original line number Diff line number Diff line Loading @@ -1867,7 +1867,7 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local) */ if ((*link_to_local= test(select_lex.table_list.first))) { select_lex.context.table_list= first->next_local; select_lex.context.table_list= select_lex.context.first_name_resolution_table= first->next_local; select_lex.table_list.first= (byte*) (first->next_local); select_lex.table_list.elements--; //safety Loading sql/sql_parse.cc +37 −24 Original line number Diff line number Diff line Loading @@ -3254,7 +3254,7 @@ mysql_execute_command(THD *thd) /* Skip first table, which is the table we are inserting in */ TABLE_LIST *second_table= first_table->next_local; select_lex->table_list.first= (byte*) second_table; select_lex->context.table_list= second_table; select_lex->context.table_list= select_lex->context.first_name_resolution_table= second_table; res= mysql_insert_select_prepare(thd); if (!res && (result= new select_insert(first_table, first_table->table, Loading @@ -3270,8 +3270,8 @@ mysql_execute_command(THD *thd) which in turn resets context.table_list and context.first_name_resolution_table. */ select_lex->context.table_list= first_table->next_local; select_lex->context.first_name_resolution_table= first_table->next_local; select_lex->context.table_list= select_lex->context.first_name_resolution_table= second_table; res= handle_select(thd, lex, result, OPTION_SETUP_TABLES_DONE); delete result; } Loading Loading @@ -6013,6 +6013,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, char *alias_str; LEX *lex= thd->lex; DBUG_ENTER("add_table_to_list"); LINT_INIT(previous_table_ref); if (!table) DBUG_RETURN(0); // End of memory Loading Loading @@ -6108,9 +6109,23 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, /* Store the table reference preceding the current one. */ if (table_list.elements > 0) { previous_table_ref= (TABLE_LIST*) table_list.next; /* table_list.next points to the last inserted TABLE_LIST->next_local' element */ previous_table_ref= (TABLE_LIST*) (table_list.next - offsetof(TABLE_LIST, next_local)); DBUG_ASSERT(previous_table_ref); /* Set next_name_resolution_table of the previous table reference to point to the current table reference. In effect the list TABLE_LIST::next_name_resolution_table coincides with TABLE_LIST::next_local. Later this may be changed in store_top_level_join_columns() for NATURAL/USING joins. */ previous_table_ref->next_name_resolution_table= ptr; } /* Link the current table reference in a local list (list for current select). Notice that as a side effect here we set the next_local field of the Loading @@ -6118,15 +6133,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, list 'table_list'. */ table_list.link_in_list((byte*) ptr, (byte**) &ptr->next_local); /* Set next_name_resolution_table of the previous table reference to point to the current table reference. In effect the list TABLE_LIST::next_name_resolution_table coincides with TABLE_LIST::next_local. Later this may be changed in store_top_level_join_columns() for NATURAL/USING joins. */ if (table_list.elements > 1) previous_table_ref->next_name_resolution_table= ptr; ptr->next_name_resolution_table= NULL; /* Link table in global list (all used tables) */ lex->add_to_query_tables(ptr); Loading Loading @@ -6161,10 +6167,12 @@ bool st_select_lex::init_nested_join(THD *thd) NESTED_JOIN *nested_join; DBUG_ENTER("init_nested_join"); if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))) || !(nested_join= ptr->nested_join= (NESTED_JOIN *) thd->calloc(sizeof(NESTED_JOIN)))) if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+ sizeof(NESTED_JOIN)))) DBUG_RETURN(1); nested_join= ptr->nested_join= ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); join_list->push_front(ptr); ptr->embedding= embedding; ptr->join_list= join_list; Loading Loading @@ -6232,25 +6240,30 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd) The function nest last join operation as if it was enclosed in braces. RETURN VALUE Pointer to TABLE_LIST element created for the new nested join, if success 0, otherwise 0 Error # Pointer to TABLE_LIST element created for the new nested join */ TABLE_LIST *st_select_lex::nest_last_join(THD *thd) { TABLE_LIST *ptr; NESTED_JOIN *nested_join; List<TABLE_LIST> *embedded_list; DBUG_ENTER("nest_last_join"); if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))) || !(nested_join= ptr->nested_join= (NESTED_JOIN *) thd->calloc(sizeof(NESTED_JOIN)))) if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+ sizeof(NESTED_JOIN)))) DBUG_RETURN(0); nested_join= ptr->nested_join= ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); ptr->embedding= embedding; ptr->join_list= join_list; List<TABLE_LIST> *embedded_list= &nested_join->join_list; embedded_list= &nested_join->join_list; embedded_list->empty(); for (int i=0; i < 2; i++) for (uint i=0; i < 2; i++) { TABLE_LIST *table= join_list->pop(); table->join_list= embedded_list; Loading Loading
mysql-test/t/kill.test +1 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ connection con1; drop table if exists t1; --enable_warnings --disable_reconnect create table t1 (kill_id int); insert into t1 values(connection_id()); Loading @@ -25,7 +26,6 @@ kill @id; connection con1; --disable_reconnect # this statement should fail --error 2006,2013 select 1; Loading
sql/sql_help.cc +14 −16 Original line number Diff line number Diff line Loading @@ -623,38 +623,37 @@ bool mysqld_help(THD *thd, const char *mask) Protocol *protocol= thd->protocol; SQL_SELECT *select; st_find_field used_fields[array_elements(init_used_fields)]; DBUG_ENTER("mysqld_help"); TABLE_LIST *leaves= 0; TABLE_LIST tables[4]; List<String> topics_list, categories_list, subcategories_list; String name, description, example; int count_topics, count_categories, error; uint mlen= strlen(mask); size_t i; MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_help"); bzero((gptr)tables,sizeof(tables)); tables[0].alias= tables[0].table_name= (char*) "help_topic"; tables[0].lock_type= TL_READ; tables[0].next_global= tables[0].next_local= &tables[1]; tables[0].next_name_resolution_table= tables[0].next_local; tables[0].next_global= tables[0].next_local= tables[0].next_name_resolution_table= &tables[1]; tables[1].alias= tables[1].table_name= (char*) "help_category"; tables[1].lock_type= TL_READ; tables[1].next_global= tables[1].next_local= &tables[2]; tables[1].next_name_resolution_table= tables[1].next_local; tables[1].next_global= tables[1].next_local= tables[1].next_name_resolution_table= &tables[2]; tables[2].alias= tables[2].table_name= (char*) "help_relation"; tables[2].lock_type= TL_READ; tables[2].next_global= tables[2].next_local= &tables[3]; tables[2].next_name_resolution_table= tables[2].next_local; tables[2].next_global= tables[2].next_local= tables[2].next_name_resolution_table= &tables[3]; tables[3].alias= tables[3].table_name= (char*) "help_keyword"; tables[3].lock_type= TL_READ; tables[0].db= tables[1].db= tables[2].db= tables[3].db= (char*) "mysql"; List<String> topics_list, categories_list, subcategories_list; String name, description, example; int count_topics, count_categories, error; uint mlen= strlen(mask); MEM_ROOT *mem_root= thd->mem_root; if (open_and_lock_tables(thd, tables)) goto error; /* Init tables and fields to be usable from items tables do not contain VIEWs => we can pass 0 as conds */ setup_tables(thd, &thd->lex->select_lex.context, Loading @@ -663,7 +662,6 @@ bool mysqld_help(THD *thd, const char *mask) memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); if (init_fields(thd, tables, used_fields, array_elements(used_fields))) goto error; size_t i; for (i=0; i<sizeof(tables)/sizeof(TABLE_LIST); i++) tables[i].table->file->init_table_handle_for_HANDLER(); Loading
sql/sql_insert.cc +4 −2 Original line number Diff line number Diff line Loading @@ -891,6 +891,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, if (select_lex->group_list.elements == 0) { context->table_list->next_local= save_next_local; /* first_name_resolution_table was set by resolve_in_table_list_only() */ context->first_name_resolution_table-> next_name_resolution_table= save_next_local; } Loading Loading @@ -2199,6 +2200,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) if (lex->select_lex.group_list.elements == 0) { context->table_list->next_local= save_next_local; /* first_name_resolution_table was set by resolve_in_table_list_only() */ context->first_name_resolution_table-> next_name_resolution_table= save_next_local; } Loading
sql/sql_lex.cc +2 −2 Original line number Diff line number Diff line Loading @@ -1867,7 +1867,7 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local) */ if ((*link_to_local= test(select_lex.table_list.first))) { select_lex.context.table_list= first->next_local; select_lex.context.table_list= select_lex.context.first_name_resolution_table= first->next_local; select_lex.table_list.first= (byte*) (first->next_local); select_lex.table_list.elements--; //safety Loading
sql/sql_parse.cc +37 −24 Original line number Diff line number Diff line Loading @@ -3254,7 +3254,7 @@ mysql_execute_command(THD *thd) /* Skip first table, which is the table we are inserting in */ TABLE_LIST *second_table= first_table->next_local; select_lex->table_list.first= (byte*) second_table; select_lex->context.table_list= second_table; select_lex->context.table_list= select_lex->context.first_name_resolution_table= second_table; res= mysql_insert_select_prepare(thd); if (!res && (result= new select_insert(first_table, first_table->table, Loading @@ -3270,8 +3270,8 @@ mysql_execute_command(THD *thd) which in turn resets context.table_list and context.first_name_resolution_table. */ select_lex->context.table_list= first_table->next_local; select_lex->context.first_name_resolution_table= first_table->next_local; select_lex->context.table_list= select_lex->context.first_name_resolution_table= second_table; res= handle_select(thd, lex, result, OPTION_SETUP_TABLES_DONE); delete result; } Loading Loading @@ -6013,6 +6013,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, char *alias_str; LEX *lex= thd->lex; DBUG_ENTER("add_table_to_list"); LINT_INIT(previous_table_ref); if (!table) DBUG_RETURN(0); // End of memory Loading Loading @@ -6108,9 +6109,23 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, /* Store the table reference preceding the current one. */ if (table_list.elements > 0) { previous_table_ref= (TABLE_LIST*) table_list.next; /* table_list.next points to the last inserted TABLE_LIST->next_local' element */ previous_table_ref= (TABLE_LIST*) (table_list.next - offsetof(TABLE_LIST, next_local)); DBUG_ASSERT(previous_table_ref); /* Set next_name_resolution_table of the previous table reference to point to the current table reference. In effect the list TABLE_LIST::next_name_resolution_table coincides with TABLE_LIST::next_local. Later this may be changed in store_top_level_join_columns() for NATURAL/USING joins. */ previous_table_ref->next_name_resolution_table= ptr; } /* Link the current table reference in a local list (list for current select). Notice that as a side effect here we set the next_local field of the Loading @@ -6118,15 +6133,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, list 'table_list'. */ table_list.link_in_list((byte*) ptr, (byte**) &ptr->next_local); /* Set next_name_resolution_table of the previous table reference to point to the current table reference. In effect the list TABLE_LIST::next_name_resolution_table coincides with TABLE_LIST::next_local. Later this may be changed in store_top_level_join_columns() for NATURAL/USING joins. */ if (table_list.elements > 1) previous_table_ref->next_name_resolution_table= ptr; ptr->next_name_resolution_table= NULL; /* Link table in global list (all used tables) */ lex->add_to_query_tables(ptr); Loading Loading @@ -6161,10 +6167,12 @@ bool st_select_lex::init_nested_join(THD *thd) NESTED_JOIN *nested_join; DBUG_ENTER("init_nested_join"); if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))) || !(nested_join= ptr->nested_join= (NESTED_JOIN *) thd->calloc(sizeof(NESTED_JOIN)))) if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+ sizeof(NESTED_JOIN)))) DBUG_RETURN(1); nested_join= ptr->nested_join= ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); join_list->push_front(ptr); ptr->embedding= embedding; ptr->join_list= join_list; Loading Loading @@ -6232,25 +6240,30 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd) The function nest last join operation as if it was enclosed in braces. RETURN VALUE Pointer to TABLE_LIST element created for the new nested join, if success 0, otherwise 0 Error # Pointer to TABLE_LIST element created for the new nested join */ TABLE_LIST *st_select_lex::nest_last_join(THD *thd) { TABLE_LIST *ptr; NESTED_JOIN *nested_join; List<TABLE_LIST> *embedded_list; DBUG_ENTER("nest_last_join"); if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))) || !(nested_join= ptr->nested_join= (NESTED_JOIN *) thd->calloc(sizeof(NESTED_JOIN)))) if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+ sizeof(NESTED_JOIN)))) DBUG_RETURN(0); nested_join= ptr->nested_join= ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); ptr->embedding= embedding; ptr->join_list= join_list; List<TABLE_LIST> *embedded_list= &nested_join->join_list; embedded_list= &nested_join->join_list; embedded_list->empty(); for (int i=0; i < 2; i++) for (uint i=0; i < 2; i++) { TABLE_LIST *table= join_list->pop(); table->join_list= embedded_list; Loading