summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-06-26 19:09:23 +0400
committerSergei Petrunia <psergey@askmonty.org>2014-06-26 19:09:23 +0400
commitc6be74458fd478b019ac357371d5aee8925fe012 (patch)
treeec719b8163e9a26adf795d8e4cbcf69bd39f7e73 /sql/sql_update.cc
parenta787edd7e660a00f015ca0a25ded0952085f7451 (diff)
downloadmariadb-git-c6be74458fd478b019ac357371d5aee8925fe012.tar.gz
MDEV-6398: ANALYZE UPDATE does not populate r_rows
- In print_explain_row(), do not forget to print r_rows. - Switch Explain_update from using its own counters to re-using Table_access_tracker. - Make ANALYZE UPDATE code structure uniform with ANALYZE DELETE.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r--sql/sql_update.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 44d3784becf..d71afe8eab0 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -725,9 +725,11 @@ int mysql_update(THD *thd,
if all updated columns are read
*/
can_compare_record= records_are_comparable(table);
+ explain->tracker.on_scan_init();
+
while (!(error=info.read_record(&info)) && !thd->killed)
{
- explain->on_record_read();
+ explain->tracker.on_record_read();
if (table->vfield)
update_virtual_fields(thd, table,
table->triggers ? VCOL_UPDATE_ALL :
@@ -738,7 +740,7 @@ int mysql_update(THD *thd,
if (table->file->was_semi_consistent_read())
continue; /* repeat the read of the same row if it still exists */
- explain->on_record_after_where();
+ explain->tracker.on_record_after_where();
store_record(table,record[1]);
if (fill_record_n_invoke_before_triggers(thd, table, fields, values, 0,
TRG_EVENT_UPDATE))
@@ -947,6 +949,7 @@ int mysql_update(THD *thd,
end_read_record(&info);
delete select;
+ select= NULL;
THD_STAGE_INFO(thd, stage_end);
(void) table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
@@ -996,11 +999,7 @@ int mysql_update(THD *thd,
id= thd->arg_of_last_insert_id_function ?
thd->first_successful_insert_id_in_prev_stmt : 0;
- if (thd->lex->analyze_stmt)
- {
- error= thd->lex->explain->send_explain(thd);
- }
- else if (error < 0)
+ if (error < 0 && !thd->lex->analyze_stmt)
{
char buff[MYSQL_ERRMSG_SIZE];
my_snprintf(buff, sizeof(buff), ER(ER_UPDATE_INFO), (ulong) found,
@@ -1019,10 +1018,14 @@ int mysql_update(THD *thd,
}
*found_return= found;
*updated_return= updated;
+
+
+ if (thd->lex->analyze_stmt)
+ goto emit_explain_and_leave;
+
DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
err:
-
delete select;
free_underlaid_joins(thd, select_lex);
table->disable_keyread();
@@ -1036,6 +1039,7 @@ produce_explain_and_leave:
*/
query_plan.save_explain_data(thd->lex->explain);
+emit_explain_and_leave:
int err2= thd->lex->explain->send_explain(thd);
delete select;