~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to sql/sql_delete.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-02 16:10:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070402161053-zkil9hjq9k5p1uzv
Tags: 5.0.37-0ubuntu1
* New upstream bugfix release.
  - Fixes replication failure with auto-increment and on duplicate key
    update, a regression introduced into 5.0.24. (LP: #95821)
* debian/control: Set Ubuntu maintainer.
* debian/rules: Change comments from 'Debian etch' to 'Ubuntu 7.04'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; either version 2 of the License, or
6
 
   (at your option) any later version.
 
5
   the Free Software Foundation; version 2 of the License.
7
6
 
8
7
   This program is distributed in the hope that it will be useful,
9
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
55
54
    table->file->print_error(error, MYF(0));
56
55
    DBUG_RETURN(error);
57
56
  }
58
 
  thd->proc_info="init";
 
57
  thd_proc_info(thd, "init");
59
58
  table->map=1;
60
59
 
61
60
  if (mysql_prepare_delete(thd, table_list, &conds))
76
75
    Test if the user wants to delete all rows and deletion doesn't have
77
76
    any side-effects (because of triggers), so we can use optimized
78
77
    handler::delete_all_rows() method.
 
78
    We implement fast TRUNCATE for InnoDB even if triggers are present. 
 
79
    TRUNCATE ignores triggers.
79
80
  */
80
81
  if (!using_limit && const_cond && (!conds || conds->val_int()) &&
81
82
      !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) &&
82
 
      !(table->triggers && table->triggers->has_delete_triggers()))
 
83
      (thd->lex->sql_command == SQLCOM_TRUNCATE ||
 
84
       !(table->triggers && table->triggers->has_delete_triggers()))
 
85
     )
83
86
  {
84
87
    deleted= table->file->records;
85
88
    if (!(error=table->file->delete_all_rows()))
143
146
 
144
147
  if (order && order->elements)
145
148
  {
146
 
    uint         length;
 
149
    uint         length= 0;
147
150
    SORT_FIELD  *sortorder;
148
151
    TABLE_LIST   tables;
149
152
    List<Item>   fields;
163
166
      DBUG_RETURN(TRUE);
164
167
    }
165
168
    
166
 
    if (!select && limit != HA_POS_ERROR)
 
169
    if ((!select || table->quick_keys.is_clear_all()) && limit != HA_POS_ERROR)
167
170
      usable_index= get_index_for_order(table, (ORDER*)(order->first), limit);
168
171
 
169
172
    if (usable_index == MAX_KEY)
206
209
 
207
210
  deleted=0L;
208
211
  init_ftfuncs(thd, select_lex, 1);
209
 
  thd->proc_info="updating";
 
212
  thd_proc_info(thd, "updating");
210
213
 
211
214
  if (table->triggers)
212
215
    table->triggers->mark_fields_used(thd, TRG_EVENT_DELETE);
262
265
  }
263
266
  if (thd->killed && !error)
264
267
    error= 1;                                   // Aborted
265
 
  thd->proc_info="end";
 
268
  thd_proc_info(thd, "end");
266
269
  end_read_record(&info);
267
270
  free_io_cache(table);                         // Will not do any harm
268
271
  if (options & OPTION_QUICK)
486
489
  DBUG_ENTER("multi_delete::prepare");
487
490
  unit= u;
488
491
  do_delete= 1;
489
 
  thd->proc_info="deleting from main table";
 
492
  thd_proc_info(thd, "deleting from main table");
490
493
  DBUG_RETURN(0);
491
494
}
492
495
 
750
753
 
751
754
bool multi_delete::send_eof()
752
755
{
753
 
  thd->proc_info="deleting from reference tables";
 
756
  thd_proc_info(thd, "deleting from reference tables");
754
757
 
755
758
  /* Does deletes for the last n - 1 tables, returns 0 if ok */
756
759
  int local_error= do_deletes();                // returns 0 if success
759
762
  local_error= local_error || error;
760
763
 
761
764
  /* reset used flags */
762
 
  thd->proc_info="end";
 
765
  thd_proc_info(thd, "end");
763
766
 
764
767
  /*
765
768
    We must invalidate the query cache before binlog writing and
904
907
  /* Probably InnoDB table */
905
908
  ulonglong save_options= thd->options;
906
909
  table_list->lock_type= TL_WRITE;
907
 
  thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
 
910
  thd->options&= ~(OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
908
911
  ha_enable_transaction(thd, FALSE);
909
912
  mysql_init_select(thd->lex);
910
913
  error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,