~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
16
/*
17
  Delete of records and truncate of tables.
18
19
  Multi-table deletes were introduced by Monty and Sinisa
20
*/
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
21
#include "config.h"
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
22
#include "drizzled/sql_select.h"
23
#include "drizzled/error.h"
24
#include "drizzled/probes.h"
25
#include "drizzled/sql_parse.h"
26
#include "drizzled/sql_base.h"
27
#include "drizzled/lock.h"
1126.10.18 by Padraig O'Sullivan
Various small build fixes for when dtrace is enabled.
28
#include "drizzled/probes.h"
1237.9.2 by Padraig O'Sullivan
Moved opt_range.[cc,h] into the optimizer directory and namespace and renamed the files to
29
#include "drizzled/optimizer/range.h"
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
30
#include "drizzled/records.h"
1241.9.64 by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal.
31
#include "drizzled/internal/iocache.h"
1273.1.2 by Jay Pipes
This patch does not change any algorithms or code paths,
32
#include "drizzled/transaction_services.h"
1905.1.1 by Brian Aker
Adding FileSort class.
33
#include "drizzled/filesort.h"
1 by brian
clean slate
34
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
35
namespace drizzled
36
{
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
37
1 by brian
clean slate
38
/**
39
  Implement DELETE SQL word.
40
41
  @note Like implementations of other DDL/DML in MySQL, this function
42
  relies on the caller to close the thread tables. This is done in the
43
  end of dispatch_command().
44
*/
45
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
46
bool delete_query(Session *session, TableList *table_list, COND *conds,
1237.6.1 by Brian Aker
Remove dead bits in parser/whitespace/etc.
47
                  SQL_LIST *order, ha_rows limit, uint64_t,
1 by brian
clean slate
48
                  bool reset_auto_increment)
49
{
1237.6.1 by Brian Aker
Remove dead bits in parser/whitespace/etc.
50
  int		error;
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
51
  Table		*table;
1237.13.3 by Padraig O'Sullivan
Performed numerous style cleanups in range.[cc,h].
52
  optimizer::SqlSelect *select= NULL;
1538 by Brian Aker
Code shuffle on ReadRecord
53
  ReadRecord	info;
1 by brian
clean slate
54
  bool          using_limit=limit != HA_POS_ERROR;
1237.6.1 by Brian Aker
Remove dead bits in parser/whitespace/etc.
55
  bool		transactional_table, const_cond;
1 by brian
clean slate
56
  bool          const_cond_result;
57
  ha_rows	deleted= 0;
482 by Brian Aker
Remove uint.
58
  uint32_t usable_index= MAX_KEY;
846 by Brian Aker
Removing on typedeffed class.
59
  Select_Lex   *select_lex= &session->lex->select_lex;
1910.2.8 by Brian Aker
Enapsulate Kill.
60
  Session::killed_state_t killed_status= Session::NOT_KILLED;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
61
1109.1.3 by Brian Aker
Move names around a bit (to align similar methods)
62
  if (session->openTablesLock(table_list))
1126.10.7 by Padraig O'Sullivan
Added calls to the dtrace delete begin/end probes.
63
  {
64
    DRIZZLE_DELETE_DONE(1, 0);
1109.1.2 by Brian Aker
More from the table patch
65
    return true;
1126.10.7 by Padraig O'Sullivan
Added calls to the dtrace delete begin/end probes.
66
  }
737 by Brian Aker
Updates for dead code removal (and forced assert() in delete).
67
68
  table= table_list->table;
69
  assert(table);
70
520.1.22 by Brian Aker
Second pass of thd cleanup
71
  session->set_proc_info("init");
1 by brian
clean slate
72
  table->map=1;
73
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
74
  if (prepare_delete(session, table_list, &conds))
1864.3.21 by Brian Aker
sql_delete removal of goto
75
  {
76
    DRIZZLE_DELETE_DONE(1, 0);
77
    return true;
78
  }
1 by brian
clean slate
79
80
  /* check ORDER BY even if it can be ignored */
81
  if (order && order->elements)
82
  {
327.2.4 by Brian Aker
Refactoring table.h
83
    TableList   tables;
1 by brian
clean slate
84
    List<Item>   fields;
85
    List<Item>   all_fields;
86
87
    tables.table = table;
88
    tables.alias = table_list->alias;
89
520.1.22 by Brian Aker
Second pass of thd cleanup
90
      if (select_lex->setup_ref_array(session, order->elements) ||
91
	  setup_order(session, select_lex->ref_pointer_array, &tables,
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
92
                    fields, all_fields, (Order*) order->first))
1864.3.21 by Brian Aker
sql_delete removal of goto
93
      {
94
        delete select;
95
        free_underlaid_joins(session, &session->lex->select_lex);
96
        DRIZZLE_DELETE_DONE(1, 0);
97
98
        return true;
99
      }
1 by brian
clean slate
100
  }
101
102
  const_cond= (!conds || conds->const_item());
103
520.1.22 by Brian Aker
Second pass of thd cleanup
104
  select_lex->no_error= session->lex->ignore;
1 by brian
clean slate
105
106
  const_cond_result= const_cond && (!conds || conds->val_int());
520.1.22 by Brian Aker
Second pass of thd cleanup
107
  if (session->is_error())
1 by brian
clean slate
108
  {
109
    /* Error evaluating val_int(). */
163 by Brian Aker
Merge Monty's code.
110
    return(true);
1 by brian
clean slate
111
  }
112
113
  /*
114
    Test if the user wants to delete all rows and deletion doesn't have
115
    any side-effects (because of triggers), so we can use optimized
116
    handler::delete_all_rows() method.
117
118
    We implement fast TRUNCATE for InnoDB even if triggers are
119
    present.  TRUNCATE ignores triggers.
120
121
    We can use delete_all_rows() if and only if:
122
    - We allow new functions (not using option --skip-new), and are
123
      not in safe mode (not using option --safe-mode)
124
    - There is no limit clause
125
    - The condition is constant
126
    - If there is a condition, then it it produces a non-zero value
127
    - If the current command is DELETE FROM with no where clause
128
      (i.e., not TRUNCATE) then:
129
      - We should not be binlogging this statement row-based, and
130
      - there should be no delete triggers associated with the table.
131
  */
581 by Brian Aker
Second pass through on replication row patch
132
  if (!using_limit && const_cond_result)
1 by brian
clean slate
133
  {
1208.3.2 by brian
Update for Cursor renaming.
134
    /* Update the table->cursor->stats.records number */
135
    table->cursor->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
136
    ha_rows const maybe_deleted= table->cursor->stats.records;
137
    if (!(error=table->cursor->ha_delete_all_rows()))
1 by brian
clean slate
138
    {
139
      error= -1;				// ok
140
      deleted= maybe_deleted;
141
      goto cleanup;
142
    }
143
    if (error != HA_ERR_WRONG_COMMAND)
144
    {
1216.1.1 by Brian Aker
Move print_error up to Engine.
145
      table->print_error(error,MYF(0));
1 by brian
clean slate
146
      error=0;
147
      goto cleanup;
148
    }
149
    /* Handler didn't support fast delete; Delete rows one by one */
150
  }
151
  if (conds)
152
  {
153
    Item::cond_result result;
520.1.22 by Brian Aker
Second pass of thd cleanup
154
    conds= remove_eq_conds(session, conds, &result);
1 by brian
clean slate
155
    if (result == Item::COND_FALSE)             // Impossible where
156
      limit= 0;
157
  }
158
1208.3.2 by brian
Update for Cursor renaming.
159
  /* Update the table->cursor->stats.records number */
160
  table->cursor->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
1 by brian
clean slate
161
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
162
  table->covering_keys.reset();
163
  table->quick_keys.reset();		// Can't use 'only index'
1237.9.2 by Padraig O'Sullivan
Moved opt_range.[cc,h] into the optimizer directory and namespace and renamed the files to
164
  select= optimizer::make_select(table, 0, 0, conds, 0, &error);
1 by brian
clean slate
165
  if (error)
1864.3.21 by Brian Aker
sql_delete removal of goto
166
  {
167
    DRIZZLE_DELETE_DONE(1, 0);
168
    return true;
169
  }
170
1237.6.1 by Brian Aker
Remove dead bits in parser/whitespace/etc.
171
  if ((select && select->check_quick(session, false, limit)) || !limit)
1 by brian
clean slate
172
  {
173
    delete select;
520.1.22 by Brian Aker
Second pass of thd cleanup
174
    free_underlaid_joins(session, select_lex);
175
    session->row_count_func= 0;
1126.10.18 by Padraig O'Sullivan
Various small build fixes for when dtrace is enabled.
176
    DRIZZLE_DELETE_DONE(0, 0);
1124.2.14 by Diego Medina
* On certain UPDATE and DELETE statements, drizzled failed an assert() in
177
    /**
178
     * Resetting the Diagnostic area to prevent
179
     * lp bug# 439719
180
     */
181
    session->main_da.reset_diagnostics_area();
836 by Brian Aker
Fixed session call from function to method.
182
    session->my_ok((ha_rows) session->row_count_func);
1 by brian
clean slate
183
    /*
184
      We don't need to call reset_auto_increment in this case, because
185
      mysql_truncate always gives a NULL conds argument, hence we never
186
      get here.
187
    */
1126.10.7 by Padraig O'Sullivan
Added calls to the dtrace delete begin/end probes.
188
    return 0; // Nothing to delete
1 by brian
clean slate
189
  }
190
191
  /* If running in safe sql mode, don't allow updates without keys */
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
192
  if (table->quick_keys.none())
1 by brian
clean slate
193
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
194
    session->server_status|=SERVER_QUERY_NO_INDEX_USED;
1 by brian
clean slate
195
  }
196
197
  if (order && order->elements)
198
  {
482 by Brian Aker
Remove uint.
199
    uint32_t         length= 0;
1711.6.1 by Brian Aker
Style on structure cleanup
200
    SortField  *sortorder;
1 by brian
clean slate
201
    ha_rows examined_rows;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
202
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
203
    if ((!select || table->quick_keys.none()) && limit != HA_POS_ERROR)
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
204
      usable_index= optimizer::get_index_for_order(table, (Order*)(order->first), limit);
1 by brian
clean slate
205
206
    if (usable_index == MAX_KEY)
207
    {
1905.1.1 by Brian Aker
Adding FileSort class.
208
      FileSort filesort(*session);
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
209
      table->sort.io_cache= new internal::IO_CACHE;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
210
211
1905.1.1 by Brian Aker
Adding FileSort class.
212
      if (not (sortorder= make_unireg_sortorder((Order*) order->first, &length, NULL)) ||
213
	  (table->sort.found_records = filesort.run(table, sortorder, length,
214
						    select, HA_POS_ERROR, 1,
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
215
						    examined_rows)) == HA_POS_ERROR)
1 by brian
clean slate
216
      {
217
        delete select;
520.1.22 by Brian Aker
Second pass of thd cleanup
218
        free_underlaid_joins(session, &session->lex->select_lex);
1864.3.21 by Brian Aker
sql_delete removal of goto
219
220
        DRIZZLE_DELETE_DONE(1, 0);
221
        return true;
1 by brian
clean slate
222
      }
223
      /*
224
        Filesort has already found and selected the rows we want to delete,
225
        so we don't need the where clause
226
      */
227
      delete select;
520.1.22 by Brian Aker
Second pass of thd cleanup
228
      free_underlaid_joins(session, select_lex);
1 by brian
clean slate
229
      select= 0;
230
    }
231
  }
232
233
  /* If quick select is used, initialize it before retrieving rows. */
234
  if (select && select->quick && select->quick->reset())
235
  {
236
    delete select;
520.1.22 by Brian Aker
Second pass of thd cleanup
237
    free_underlaid_joins(session, select_lex);
1864.3.21 by Brian Aker
sql_delete removal of goto
238
    DRIZZLE_DELETE_DONE(1, 0);
239
    return true;
1 by brian
clean slate
240
  }
1237.6.1 by Brian Aker
Remove dead bits in parser/whitespace/etc.
241
1 by brian
clean slate
242
  if (usable_index==MAX_KEY)
1538 by Brian Aker
Code shuffle on ReadRecord
243
  {
244
    info.init_read_record(session,table,select,1,1);
245
  }
1 by brian
clean slate
246
  else
1538 by Brian Aker
Code shuffle on ReadRecord
247
  {
1539.1.3 by Brian Aker
Additional function -> method for readrecord
248
    info.init_read_record_idx(session, table, 1, usable_index);
1538 by Brian Aker
Code shuffle on ReadRecord
249
  }
1 by brian
clean slate
250
520.1.22 by Brian Aker
Second pass of thd cleanup
251
  session->set_proc_info("updating");
1 by brian
clean slate
252
253
  table->mark_columns_needed_for_delete();
254
1910.2.8 by Brian Aker
Enapsulate Kill.
255
  while (!(error=info.read_record(&info)) && !session->getKilled() &&
520.1.22 by Brian Aker
Second pass of thd cleanup
256
	 ! session->is_error())
1 by brian
clean slate
257
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
258
    // session->is_error() is tested to disallow delete row on error
259
    if (!(select && select->skip_record())&& ! session->is_error() )
1 by brian
clean slate
260
    {
1672.3.6 by Brian Aker
First pass in encapsulating row
261
      if (!(error= table->cursor->deleteRecord(table->getInsertRecord())))
1 by brian
clean slate
262
      {
263
	deleted++;
264
	if (!--limit && using_limit)
265
	{
266
	  error= -1;
267
	  break;
268
	}
269
      }
270
      else
271
      {
1216.1.1 by Brian Aker
Move print_error up to Engine.
272
	table->print_error(error,MYF(0));
1 by brian
clean slate
273
	/*
274
	  In < 4.0.14 we set the error number to 0 here, but that
275
	  was not sensible, because then MySQL would not roll back the
276
	  failed DELETE, and also wrote it to the binlog. For MyISAM
277
	  tables a DELETE probably never should fail (?), but for
278
	  InnoDB it can fail in a FOREIGN KEY error or an
279
	  out-of-tablespace error.
280
	*/
281
 	error= 1;
282
	break;
283
      }
284
    }
285
    else
1208.3.2 by brian
Update for Cursor renaming.
286
      table->cursor->unlock_row();  // Row failed selection, release lock on it
1 by brian
clean slate
287
  }
1910.2.8 by Brian Aker
Enapsulate Kill.
288
  killed_status= session->getKilled();
520.1.22 by Brian Aker
Second pass of thd cleanup
289
  if (killed_status != Session::NOT_KILLED || session->is_error())
1 by brian
clean slate
290
    error= 1;					// Aborted
1237.6.1 by Brian Aker
Remove dead bits in parser/whitespace/etc.
291
520.1.22 by Brian Aker
Second pass of thd cleanup
292
  session->set_proc_info("end");
1538 by Brian Aker
Code shuffle on ReadRecord
293
  info.end_read_record();
1 by brian
clean slate
294
1208.2.2 by Brian Aker
Merge Truncate patch. This fixes all of the "half setup" of Truncate. Still
295
cleanup:
296
1 by brian
clean slate
297
  if (reset_auto_increment && (error < 0))
298
  {
299
    /*
300
      We're really doing a truncate and need to reset the table's
301
      auto-increment counter.
302
    */
1208.3.2 by brian
Update for Cursor renaming.
303
    int error2= table->cursor->ha_reset_auto_increment(0);
1 by brian
clean slate
304
305
    if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
306
    {
1216.1.1 by Brian Aker
Move print_error up to Engine.
307
      table->print_error(error2, MYF(0));
1 by brian
clean slate
308
      error= 1;
309
    }
310
  }
311
312
  delete select;
1208.3.2 by brian
Update for Cursor renaming.
313
  transactional_table= table->cursor->has_transactions();
1 by brian
clean slate
314
315
  if (!transactional_table && deleted > 0)
1273.1.13 by Jay Pipes
Style cleanup around TransactionContext::modified_non_trans_table and dead code removal
316
    session->transaction.stmt.markModifiedNonTransData();
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
317
1 by brian
clean slate
318
  /* See similar binlogging code in sql_update.cc, for comments */
1273.1.13 by Jay Pipes
Style cleanup around TransactionContext::modified_non_trans_table and dead code removal
319
  if ((error < 0) || session->transaction.stmt.hasModifiedNonTransData())
1 by brian
clean slate
320
  {
1273.1.13 by Jay Pipes
Style cleanup around TransactionContext::modified_non_trans_table and dead code removal
321
    if (session->transaction.stmt.hasModifiedNonTransData())
322
      session->transaction.all.markModifiedNonTransData();
1 by brian
clean slate
323
  }
1273.1.13 by Jay Pipes
Style cleanup around TransactionContext::modified_non_trans_table and dead code removal
324
  assert(transactional_table || !deleted || session->transaction.stmt.hasModifiedNonTransData());
520.1.22 by Brian Aker
Second pass of thd cleanup
325
  free_underlaid_joins(session, select_lex);
1 by brian
clean slate
326
1126.10.25 by Padraig O'Sullivan
Updated calls to some dtrace probes to cast the parameter to const char *
327
  DRIZZLE_DELETE_DONE((error >= 0 || session->is_error()), deleted);
520.1.22 by Brian Aker
Second pass of thd cleanup
328
  if (error < 0 || (session->lex->ignore && !session->is_fatal_error))
1 by brian
clean slate
329
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
330
    session->row_count_func= deleted;
1124.2.14 by Diego Medina
* On certain UPDATE and DELETE statements, drizzled failed an assert() in
331
    /**
332
     * Resetting the Diagnostic area to prevent
333
     * lp bug# 439719
334
     */
1124.2.16 by Diego Medina
uncommented a call to reset_diagnostics_area()
335
    session->main_da.reset_diagnostics_area();    
836 by Brian Aker
Fixed session call from function to method.
336
    session->my_ok((ha_rows) session->row_count_func);
1 by brian
clean slate
337
  }
1625.2.2 by Joe Daly
add counter logic for rows sent/received/inserted/updated
338
  session->status_var.deleted_row_count+= deleted;
1864.3.21 by Brian Aker
sql_delete removal of goto
339
1126.10.7 by Padraig O'Sullivan
Added calls to the dtrace delete begin/end probes.
340
  return (error >= 0 || session->is_error());
1 by brian
clean slate
341
}
342
343
344
/*
345
  Prepare items in DELETE statement
346
347
  SYNOPSIS
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
348
    prepare_delete()
520.1.22 by Brian Aker
Second pass of thd cleanup
349
    session			- thread handler
1 by brian
clean slate
350
    table_list		- global/local table list
351
    conds		- conditions
352
353
  RETURN VALUE
163 by Brian Aker
Merge Monty's code.
354
    false OK
355
    true  error
1 by brian
clean slate
356
*/
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
357
int prepare_delete(Session *session, TableList *table_list, Item **conds)
1 by brian
clean slate
358
{
846 by Brian Aker
Removing on typedeffed class.
359
  Select_Lex *select_lex= &session->lex->select_lex;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
360
1 by brian
clean slate
361
  List<Item> all_fields;
362
520.1.22 by Brian Aker
Second pass of thd cleanup
363
  session->lex->allow_sum_func= 0;
364
  if (setup_tables_and_check_access(session, &session->lex->select_lex.context,
365
                                    &session->lex->select_lex.top_join_list,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
366
                                    table_list,
1 by brian
clean slate
367
                                    &select_lex->leaf_tables, false) ||
1109.1.5 by Brian Aker
More extraction from sql_base
368
      session->setup_conds(table_list, conds))
163 by Brian Aker
Merge Monty's code.
369
    return(true);
1 by brian
clean slate
370
  {
327.2.4 by Brian Aker
Refactoring table.h
371
    TableList *duplicate;
1220.1.13 by Brian Aker
Remove mysql_lock_have_duplicate() (we don't have merge, and our partition
372
    if ((duplicate= unique_table(table_list, table_list->next_global)))
1 by brian
clean slate
373
    {
1054.1.9 by Brian Aker
This is a large number of refactors against the Session class for its
374
      my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->alias);
163 by Brian Aker
Merge Monty's code.
375
      return(true);
1 by brian
clean slate
376
    }
377
  }
378
379
  if (select_lex->inner_refs_list.elements &&
520.1.22 by Brian Aker
Second pass of thd cleanup
380
    fix_inner_refs(session, all_fields, select_lex, select_lex->ref_pointer_array))
51.2.2 by Patrick Galbraith
Removed DBUGs from
381
    return(-1);
1 by brian
clean slate
382
163 by Brian Aker
Merge Monty's code.
383
  return(false);
1 by brian
clean slate
384
}
385
386
387
/***************************************************************************
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
388
  TRUNCATE Table
1 by brian
clean slate
389
****************************************************************************/
390
391
/*
392
  Optimize delete of all rows by doing a full generate of the table
393
  This will work even if the .ISM and .ISD tables are destroyed
394
*/
395
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
396
bool truncate(Session& session, TableList *table_list)
1 by brian
clean slate
397
{
398
  bool error;
1273.1.2 by Jay Pipes
This patch does not change any algorithms or code paths,
399
  TransactionServices &transaction_services= TransactionServices::singleton();
1208.2.2 by Brian Aker
Merge Truncate patch. This fixes all of the "half setup" of Truncate. Still
400
1183.1.29 by Brian Aker
Clean up interface so that Truncate sets the propper engine when
401
  uint64_t save_options= session.options;
1 by brian
clean slate
402
  table_list->lock_type= TL_WRITE;
1183.1.29 by Brian Aker
Clean up interface so that Truncate sets the propper engine when
403
  session.options&= ~(OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
404
  init_select(session.lex);
405
  error= delete_query(&session, table_list, (COND*) 0, (SQL_LIST*) 0,
398.1.8 by Monty Taylor
Enabled -Wlong-long.
406
                      HA_POS_ERROR, 0L, true);
1 by brian
clean slate
407
  /*
163 by Brian Aker
Merge Monty's code.
408
    Safety, in case the engine ignored ha_enable_transaction(false)
520.1.22 by Brian Aker
Second pass of thd cleanup
409
    above. Also clears session->transaction.*.
1 by brian
clean slate
410
  */
1405.3.5 by Jay Pipes
TransactionServices method names now meet code style guidelines.
411
  error= transaction_services.autocommitOrRollback(&session, error);
1183.1.29 by Brian Aker
Clean up interface so that Truncate sets the propper engine when
412
  session.options= save_options;
413
1208.2.2 by Brian Aker
Merge Truncate patch. This fixes all of the "half setup" of Truncate. Still
414
  return error;
1 by brian
clean slate
415
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
416
417
} /* namespace drizzled */