Commit 409f7af3 authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

make multi updates statistics visible in SHOW STATUS as Com_update_multi

parent fcec0858
...@@ -4010,7 +4010,7 @@ struct show_var_st status_vars[]= { ...@@ -4010,7 +4010,7 @@ struct show_var_st status_vars[]= {
{"Com_insert_select", (char*) (com_stat+(uint) SQLCOM_INSERT_SELECT),SHOW_LONG}, {"Com_insert_select", (char*) (com_stat+(uint) SQLCOM_INSERT_SELECT),SHOW_LONG},
{"Com_kill", (char*) (com_stat+(uint) SQLCOM_KILL),SHOW_LONG}, {"Com_kill", (char*) (com_stat+(uint) SQLCOM_KILL),SHOW_LONG},
{"Com_load", (char*) (com_stat+(uint) SQLCOM_LOAD),SHOW_LONG}, {"Com_load", (char*) (com_stat+(uint) SQLCOM_LOAD),SHOW_LONG},
{"Com_load_master_data", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_DATA),SHOW_LONG}, {"Com_load_master_data", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_DATA),SHOW_LONG},
{"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG}, {"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG},
{"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG}, {"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG},
{"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG}, {"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG},
...@@ -4048,6 +4048,7 @@ struct show_var_st status_vars[]= { ...@@ -4048,6 +4048,7 @@ struct show_var_st status_vars[]= {
{"Com_truncate", (char*) (com_stat+(uint) SQLCOM_TRUNCATE),SHOW_LONG}, {"Com_truncate", (char*) (com_stat+(uint) SQLCOM_TRUNCATE),SHOW_LONG},
{"Com_unlock_tables", (char*) (com_stat+(uint) SQLCOM_UNLOCK_TABLES),SHOW_LONG}, {"Com_unlock_tables", (char*) (com_stat+(uint) SQLCOM_UNLOCK_TABLES),SHOW_LONG},
{"Com_update", (char*) (com_stat+(uint) SQLCOM_UPDATE),SHOW_LONG}, {"Com_update", (char*) (com_stat+(uint) SQLCOM_UPDATE),SHOW_LONG},
{"Com_update_multi", (char*) (com_stat+(uint) SQLCOM_UPDATE_MULTI),SHOW_LONG},
{"Connections", (char*) &thread_id, SHOW_LONG_CONST}, {"Connections", (char*) &thread_id, SHOW_LONG_CONST},
{"Created_tmp_disk_tables", (char*) &created_tmp_disk_tables,SHOW_LONG}, {"Created_tmp_disk_tables", (char*) &created_tmp_disk_tables,SHOW_LONG},
{"Created_tmp_tables", (char*) &created_tmp_tables, SHOW_LONG}, {"Created_tmp_tables", (char*) &created_tmp_tables, SHOW_LONG},
......
...@@ -1894,24 +1894,30 @@ mysql_execute_command(THD *thd) ...@@ -1894,24 +1894,30 @@ mysql_execute_command(THD *thd)
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
if (select_lex->table_list.elements == 1) res= mysql_update(thd,tables,
select_lex->item_list,
lex->value_list,
select_lex->where,
(ORDER *) select_lex->order_list.first,
select_lex->select_limit,
lex->duplicates);
break;
case SQLCOM_UPDATE_MULTI:
if (check_access(thd,UPDATE_ACL,tables->db,&tables->grant.privilege))
goto error;
if (grant_option && check_grant(thd,UPDATE_ACL,tables))
goto error;
if (select_lex->item_list.elements != lex->value_list.elements)
{ {
res= mysql_update(thd,tables, send_error(thd,ER_WRONG_VALUE_COUNT);
select_lex->item_list, DBUG_VOID_RETURN;
lex->value_list,
select_lex->where,
(ORDER *) select_lex->order_list.first,
select_lex->select_limit,
lex->duplicates);
} }
else
{ {
multi_update *result; multi_update *result;
uint table_count; uint table_count;
TABLE_LIST *auxi; TABLE_LIST *auxi;
const char *msg=0; const char *msg=0;
lex->sql_command=SQLCOM_UPDATE_MULTI;
for (auxi= (TABLE_LIST*) tables, table_count=0 ; auxi ; auxi=auxi->next) for (auxi= (TABLE_LIST*) tables, table_count=0 ; auxi ; auxi=auxi->next)
table_count++; table_count++;
......
...@@ -3051,8 +3051,8 @@ opt_insert_update: ...@@ -3051,8 +3051,8 @@ opt_insert_update:
/* Update rows in a table */ /* Update rows in a table */
update: update:
UPDATE_SYM UPDATE_SYM
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_UPDATE; lex->sql_command= SQLCOM_UPDATE;
lex->select_lex.init_order(); lex->select_lex.init_order();
...@@ -3061,6 +3061,8 @@ update: ...@@ -3061,6 +3061,8 @@ update:
SET update_list where_clause opt_order_clause delete_limit_clause SET update_list where_clause opt_order_clause delete_limit_clause
{ {
Select->set_lock_for_tables($3); Select->set_lock_for_tables($3);
if (lex->select_lex->table_list.elements > 1)
lex->sql_command=SQLCOM_UPDATE_MULTI;
} }
; ;
......
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