~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to sql/sql_delete.cc

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-05-11 18:47:32 UTC
  • mto: (2.1.2 sid) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100511184732-jhn055kfhxze24kt
Tags: upstream-5.1.46
ImportĀ upstreamĀ versionĀ 5.1.46

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
  SELECT_LEX   *select_lex= &thd->lex->select_lex;
51
51
  THD::killed_state killed_status= THD::NOT_KILLED;
52
52
  DBUG_ENTER("mysql_delete");
 
53
  bool save_binlog_row_based;
53
54
 
54
55
  THD::enum_binlog_query_type query_type=
55
56
    thd->lex->sql_command == SQLCOM_TRUNCATE ?
147
148
      query_type= THD::STMT_QUERY_TYPE;
148
149
      error= -1;                                // ok
149
150
      deleted= maybe_deleted;
 
151
      save_binlog_row_based= thd->current_stmt_binlog_row_based;
150
152
      goto cleanup;
151
153
    }
152
154
    if (error != HA_ERR_WRONG_COMMAND)
153
155
    {
154
156
      table->file->print_error(error,MYF(0));
155
157
      error=0;
 
158
      save_binlog_row_based= thd->current_stmt_binlog_row_based;
156
159
      goto cleanup;
157
160
    }
158
161
    /* Handler didn't support fast delete; Delete rows one by one */
293
296
 
294
297
  table->mark_columns_needed_for_delete();
295
298
 
 
299
  save_binlog_row_based= thd->current_stmt_binlog_row_based;
 
300
  if (thd->lex->sql_command == SQLCOM_TRUNCATE &&
 
301
      thd->current_stmt_binlog_row_based)
 
302
    thd->clear_current_stmt_binlog_row_based();
 
303
 
296
304
  while (!(error=info.read_record(&info)) && !thd->killed &&
297
305
         ! thd->is_error())
298
306
  {
390
398
  /* See similar binlogging code in sql_update.cc, for comments */
391
399
  if ((error < 0) || thd->transaction.stmt.modified_non_trans_table)
392
400
  {
393
 
    if (mysql_bin_log.is_open())
 
401
    if (mysql_bin_log.is_open() &&
 
402
        !(thd->lex->sql_command == SQLCOM_TRUNCATE &&
 
403
          thd->current_stmt_binlog_row_based &&
 
404
          find_temporary_table(thd, table_list)))
394
405
    {
395
406
      bool const is_trans=
396
407
        thd->lex->sql_command == SQLCOM_TRUNCATE ?
424
435
    if (thd->transaction.stmt.modified_non_trans_table)
425
436
      thd->transaction.all.modified_non_trans_table= TRUE;
426
437
  }
 
438
  thd->current_stmt_binlog_row_based= save_binlog_row_based;
427
439
  DBUG_ASSERT(transactional_table || !deleted || thd->transaction.stmt.modified_non_trans_table);
428
440
  free_underlaid_joins(thd, select_lex);
429
441
  if (error < 0 || 
1059
1071
 
1060
1072
static bool mysql_truncate_by_delete(THD *thd, TABLE_LIST *table_list)
1061
1073
{
1062
 
  bool error, save_binlog_row_based= thd->current_stmt_binlog_row_based;
 
1074
  bool error;
1063
1075
  DBUG_ENTER("mysql_truncate_by_delete");
1064
1076
  table_list->lock_type= TL_WRITE;
1065
1077
  mysql_init_select(thd->lex);
1066
 
  thd->clear_current_stmt_binlog_row_based();
1067
1078
  error= mysql_delete(thd, table_list, NULL, NULL, HA_POS_ERROR, LL(0), TRUE);
1068
1079
  ha_autocommit_or_rollback(thd, error);
1069
1080
  end_trans(thd, error ? ROLLBACK : COMMIT);
1070
 
  thd->current_stmt_binlog_row_based= save_binlog_row_based;
1071
1081
  DBUG_RETURN(error);
1072
1082
}
1073
1083