~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_delete.cc

  • Committer: Brian Aker
  • Date: 2009-11-12 16:13:04 UTC
  • mfrom: (1211.1.7 staging)
  • Revision ID: brian@gaz-20091112161304-opamiauv36fg0n6u
Rollup of Brian, Padraig, and Stewart patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
  */
130
130
  if (!using_limit && const_cond_result)
131
131
  {
132
 
    /* Update the table->file->stats.records number */
133
 
    table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
134
 
    ha_rows const maybe_deleted= table->file->stats.records;
135
 
    if (!(error=table->file->ha_delete_all_rows()))
 
132
    /* Update the table->cursor->stats.records number */
 
133
    table->cursor->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
 
134
    ha_rows const maybe_deleted= table->cursor->stats.records;
 
135
    if (!(error=table->cursor->ha_delete_all_rows()))
136
136
    {
137
137
      error= -1;                                // ok
138
138
      deleted= maybe_deleted;
140
140
    }
141
141
    if (error != HA_ERR_WRONG_COMMAND)
142
142
    {
143
 
      table->file->print_error(error,MYF(0));
 
143
      table->cursor->print_error(error,MYF(0));
144
144
      error=0;
145
145
      goto cleanup;
146
146
    }
154
154
      limit= 0;
155
155
  }
156
156
 
157
 
  /* Update the table->file->stats.records number */
158
 
  table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
 
157
  /* Update the table->cursor->stats.records number */
 
158
  table->cursor->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
159
159
 
160
160
  table->covering_keys.reset();
161
161
  table->quick_keys.reset();            // Can't use 'only index'
196
196
    }
197
197
  }
198
198
  if (options & OPTION_QUICK)
199
 
    (void) table->file->extra(HA_EXTRA_QUICK);
 
199
    (void) table->cursor->extra(HA_EXTRA_QUICK);
200
200
 
201
201
  if (order && order->elements)
202
202
  {
248
248
 
249
249
  session->set_proc_info("updating");
250
250
 
251
 
  will_batch= !table->file->start_bulk_delete();
 
251
  will_batch= !table->cursor->start_bulk_delete();
252
252
 
253
253
 
254
254
  table->mark_columns_needed_for_delete();
259
259
    // session->is_error() is tested to disallow delete row on error
260
260
    if (!(select && select->skip_record())&& ! session->is_error() )
261
261
    {
262
 
      if (!(error= table->file->ha_delete_row(table->record[0])))
 
262
      if (!(error= table->cursor->ha_delete_row(table->record[0])))
263
263
      {
264
264
        deleted++;
265
265
        if (!--limit && using_limit)
270
270
      }
271
271
      else
272
272
      {
273
 
        table->file->print_error(error,MYF(0));
 
273
        table->cursor->print_error(error,MYF(0));
274
274
        /*
275
275
          In < 4.0.14 we set the error number to 0 here, but that
276
276
          was not sensible, because then MySQL would not roll back the
284
284
      }
285
285
    }
286
286
    else
287
 
      table->file->unlock_row();  // Row failed selection, release lock on it
 
287
      table->cursor->unlock_row();  // Row failed selection, release lock on it
288
288
  }
289
289
  killed_status= session->killed;
290
290
  if (killed_status != Session::NOT_KILLED || session->is_error())
291
291
    error= 1;                                   // Aborted
292
 
  if (will_batch && (loc_error= table->file->end_bulk_delete()))
 
292
  if (will_batch && (loc_error= table->cursor->end_bulk_delete()))
293
293
  {
294
294
    if (error != 1)
295
 
      table->file->print_error(loc_error,MYF(0));
 
295
      table->cursor->print_error(loc_error,MYF(0));
296
296
    error=1;
297
297
  }
298
298
  session->set_proc_info("end");
299
299
  end_read_record(&info);
300
300
  if (options & OPTION_QUICK)
301
 
    (void) table->file->extra(HA_EXTRA_NORMAL);
 
301
    (void) table->cursor->extra(HA_EXTRA_NORMAL);
302
302
 
303
303
cleanup:
304
304
 
308
308
      We're really doing a truncate and need to reset the table's
309
309
      auto-increment counter.
310
310
    */
311
 
    int error2= table->file->ha_reset_auto_increment(0);
 
311
    int error2= table->cursor->ha_reset_auto_increment(0);
312
312
 
313
313
    if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
314
314
    {
315
 
      table->file->print_error(error2, MYF(0));
 
315
      table->cursor->print_error(error2, MYF(0));
316
316
      error= 1;
317
317
    }
318
318
  }
319
319
 
320
320
  delete select;
321
 
  transactional_table= table->file->has_transactions();
 
321
  transactional_table= table->cursor->has_transactions();
322
322
 
323
323
  if (!transactional_table && deleted > 0)
324
324
    session->transaction.stmt.modified_non_trans_table= true;