@@ -34139,39 +34139,38 @@ static void MYSQL_DML_START(THD *thd)
3413934139}
3414034140
3414134141
34142- static void MYSQL_DML_DONE (THD *thd, int rc )
34142+ static void MYSQL_DML_GET_STAT (THD * thd, ha_rows &found, ha_rows &changed )
3414334143{
3414434144 switch (thd->lex->sql_command) {
34145+ case SQLCOM_UPDATE:
34146+ case SQLCOM_UPDATE_MULTI:
34147+ case SQLCOM_DELETE_MULTI:
34148+ thd->lex->m_sql_cmd->get_dml_stat(found, changed);
34149+ break;
34150+ case SQLCOM_DELETE:
34151+ found= 0;
34152+ changed= (thd->get_row_count_func());
34153+ break;
34154+ default:
34155+ DBUG_ASSERT(0);
34156+ }
34157+ }
34158+
3414534159
34160+ static void MYSQL_DML_DONE(THD *thd, int rc, ha_rows found, ha_rows changed)
34161+ {
34162+ switch (thd->lex->sql_command) {
3414634163 case SQLCOM_UPDATE:
34147- MYSQL_UPDATE_DONE(
34148- rc,
34149- (rc ? 0 :
34150- ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
34151- ->num_found()),
34152- (rc ? 0 :
34153- ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
34154- ->num_updated()));
34164+ MYSQL_UPDATE_DONE(rc, found, changed);
3415534165 break;
3415634166 case SQLCOM_UPDATE_MULTI:
34157- MYSQL_MULTI_UPDATE_DONE(
34158- rc,
34159- (rc ? 0 :
34160- ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
34161- ->num_found()),
34162- (rc ? 0 :
34163- ((multi_update*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
34164- ->num_updated()));
34167+ MYSQL_MULTI_UPDATE_DONE(rc, found, changed);
3416534168 break;
3416634169 case SQLCOM_DELETE:
34167- MYSQL_DELETE_DONE(rc, (rc ? 0 : (ulong) (thd->get_row_count_func())) );
34170+ MYSQL_DELETE_DONE(rc, changed );
3416834171 break;
3416934172 case SQLCOM_DELETE_MULTI:
34170- MYSQL_MULTI_DELETE_DONE(
34171- rc,
34172- (rc ? 0 :
34173- ((multi_delete*)(((Sql_cmd_dml*)(thd->lex->m_sql_cmd))->get_result()))
34174- ->num_deleted()));
34173+ MYSQL_MULTI_DELETE_DONE(rc, changed);
3417534174 break;
3417634175 default:
3417734176 DBUG_ASSERT(0);
@@ -34260,6 +34259,7 @@ bool Sql_cmd_dml::prepare(THD *thd)
3426034259bool Sql_cmd_dml::execute(THD *thd)
3426134260{
3426234261 lex = thd->lex;
34262+ ha_rows found= 0, changed= 0;
3426334263 bool res;
3426434264
3426534265 SELECT_LEX_UNIT *unit = &lex->unit;
@@ -34310,6 +34310,8 @@ bool Sql_cmd_dml::execute(THD *thd)
3431034310
3431134311 if (res)
3431234312 goto err;
34313+ else
34314+ MYSQL_DML_GET_STAT(thd, found, changed);
3431334315
3431434316 res= unit->cleanup();
3431534317
@@ -34318,13 +34320,13 @@ bool Sql_cmd_dml::execute(THD *thd)
3431834320
3431934321 THD_STAGE_INFO(thd, stage_end);
3432034322
34321- MYSQL_DML_DONE(thd, res );
34323+ MYSQL_DML_DONE(thd, 0, found, changed );
3432234324
3432334325 return res;
3432434326
3432534327err:
3432634328 DBUG_ASSERT(thd->is_error() || thd->killed);
34327- MYSQL_DML_DONE(thd, 1);
34329+ MYSQL_DML_DONE(thd, 1, 0, 0 );
3432834330 THD_STAGE_INFO(thd, stage_end);
3432934331 (void)unit->cleanup();
3433034332 if (is_prepared())
0 commit comments