~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_delete.cc

  • Committer: Andrew Hutchings
  • Date: 2011-01-23 21:32:31 UTC
  • mto: (2108.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: andrew@linuxjedi.co.uk-20110123213231-dp2r4enepa9k4g36
Convert all unit tests to boost::test
Add pandora support for boost::test
Remove pandora support for gtest

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
  end of dispatch_command().
44
44
*/
45
45
 
46
 
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
 
46
bool delete_query(Session *session, TableList *table_list, COND *conds,
47
47
                  SQL_LIST *order, ha_rows limit, uint64_t,
48
48
                  bool reset_auto_increment)
49
49
{
71
71
  session->set_proc_info("init");
72
72
  table->map=1;
73
73
 
74
 
  if (mysql_prepare_delete(session, table_list, &conds))
 
74
  if (prepare_delete(session, table_list, &conds))
75
75
  {
76
76
    DRIZZLE_DELETE_DONE(1, 0);
77
77
    return true;
173
173
    delete select;
174
174
    free_underlaid_joins(session, select_lex);
175
175
    session->row_count_func= 0;
 
176
    if (session->is_error())
 
177
      return true;
176
178
    DRIZZLE_DELETE_DONE(0, 0);
177
179
    /**
178
180
     * Resetting the Diagnostic area to prevent
241
243
 
242
244
  if (usable_index==MAX_KEY)
243
245
  {
244
 
    info.init_read_record(session,table,select,1,1);
 
246
    if ((error= info.init_read_record(session,table,select,1,1)))
 
247
    {
 
248
      table->print_error(error, MYF(0));
 
249
      delete select;
 
250
      free_underlaid_joins(session, select_lex);
 
251
      return true;
 
252
    }
245
253
  }
246
254
  else
247
255
  {
248
 
    info.init_read_record_idx(session, table, 1, usable_index);
 
256
    if ((error= info.init_read_record_idx(session, table, 1, usable_index)))
 
257
    {
 
258
      table->print_error(error, MYF(0));
 
259
      delete select;
 
260
      free_underlaid_joins(session, select_lex);
 
261
      return true;
 
262
    }
249
263
  }
250
264
 
251
265
  session->set_proc_info("updating");
345
359
  Prepare items in DELETE statement
346
360
 
347
361
  SYNOPSIS
348
 
    mysql_prepare_delete()
 
362
    prepare_delete()
349
363
    session                     - thread handler
350
364
    table_list          - global/local table list
351
365
    conds               - conditions
354
368
    false OK
355
369
    true  error
356
370
*/
357
 
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds)
 
371
int prepare_delete(Session *session, TableList *table_list, Item **conds)
358
372
{
359
373
  Select_Lex *select_lex= &session->lex->select_lex;
360
374
 
378
392
 
379
393
  if (select_lex->inner_refs_list.elements &&
380
394
    fix_inner_refs(session, all_fields, select_lex, select_lex->ref_pointer_array))
381
 
    return(-1);
 
395
    return(true);
382
396
 
383
397
  return(false);
384
398
}
393
407
  This will work even if the .ISM and .ISD tables are destroyed
394
408
*/
395
409
 
396
 
bool mysql_truncate(Session& session, TableList *table_list)
 
410
bool truncate(Session& session, TableList *table_list)
397
411
{
398
412
  bool error;
399
413
  TransactionServices &transaction_services= TransactionServices::singleton();
401
415
  uint64_t save_options= session.options;
402
416
  table_list->lock_type= TL_WRITE;
403
417
  session.options&= ~(OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
404
 
  mysql_init_select(session.lex);
405
 
  error= mysql_delete(&session, table_list, (COND*) 0, (SQL_LIST*) 0,
 
418
  init_select(session.lex);
 
419
  error= delete_query(&session, table_list, (COND*) 0, (SQL_LIST*) 0,
406
420
                      HA_POS_ERROR, 0L, true);
407
421
  /*
408
422
    Safety, in case the engine ignored ha_enable_transaction(false)