~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Stewart Smith
  • Date: 2008-11-21 16:06:07 UTC
  • mto: This revision was merged to the branch mainline in revision 593.
  • Revision ID: stewart@flamingspork.com-20081121160607-n6gdlt013spuo54r
remove mysql_frm_type
and fix engines to return correct value from delete_table when table doesn't exist.
(it should be ENOENT).

Also fix up some tests that manipulated frm files by hand. These tests are no longer valid and will need to be rewritten in the not too distant future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
322
322
    LOCK_open during wait_if_global_read_lock(), other threads could not
323
323
    close their tables. This would make a pretty deadlock.
324
324
  */
325
 
  error= mysql_rm_table_part2(session, tables, if_exists, drop_temporary, 0, 0);
 
325
  error= mysql_rm_table_part2(session, tables, if_exists, drop_temporary, 0);
326
326
 
327
327
  if (need_start_waiting)
328
328
    start_waiting_global_read_lock(session);
364
364
*/
365
365
 
366
366
int mysql_rm_table_part2(Session *session, TableList *tables, bool if_exists,
367
 
                         bool drop_temporary, bool drop_view,
368
 
                         bool dont_log_query)
 
367
                         bool drop_temporary, bool dont_log_query)
369
368
{
370
369
  TableList *table;
371
370
  char path[FN_REFLEN], *alias;
416
415
  {
417
416
    char *db=table->db;
418
417
    handlerton *table_type;
419
 
    enum legacy_db_type frm_db_type;
420
 
 
421
418
 
422
419
    error= drop_temporary_table(session, table);
423
420
 
485
482
                                        FN_IS_TMP : 0);
486
483
    }
487
484
    if (drop_temporary ||
488
 
        ((table_type == NULL && (access(path, F_OK) && ha_create_table_from_engine(session, db, alias))) ||
489
 
         (!drop_view && mysql_frm_type(session, path, &frm_db_type) != true)))
 
485
        ((table_type == NULL && (access(path, F_OK) && ha_create_table_from_engine(session, db, alias))))
 
486
        )
490
487
    {
491
488
      // Table was not found on disk and table can't be created from engine
492
489
      if (if_exists)
499
496
    else
500
497
    {
501
498
      char *end;
502
 
      if (table_type == NULL)
503
 
      {
504
 
        mysql_frm_type(session, path, &frm_db_type);
505
 
        table_type= ha_resolve_by_legacy_type(session, frm_db_type);
506
 
      }
507
499
      // Remove extension for delete
508
500
      *(end= path + path_length - reg_ext_length)= '\0';
509
 
      error= ha_delete_table(session, table_type, path, db, table->table_name,
 
501
      error= ha_delete_table(session, path, db, table->table_name,
510
502
                             !dont_log_query);
511
503
      if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && 
512
 
          (if_exists || table_type == NULL))
 
504
          if_exists)
513
505
      {
514
506
        error= 0;
515
507
        session->clear_error();
631
623
    != 0        Error
632
624
*/
633
625
 
634
 
bool quick_rm_table(handlerton *base,const char *db,
 
626
bool quick_rm_table(handlerton *base __attribute__((unused)),const char *db,
635
627
                    const char *table_name, uint32_t flags)
636
628
{
637
629
  char path[FN_REFLEN];
646
638
 
647
639
  error|= delete_table_proto_file(path);
648
640
 
649
 
  return(ha_delete_table(current_session, base, path, db, table_name, 0) ||
 
641
  return(ha_delete_table(current_session, path, db, table_name, 0) ||
650
642
              error);
651
643
}
652
644
 
4408
4400
  char path[FN_REFLEN];
4409
4401
  ha_rows copied= 0,deleted= 0;
4410
4402
  handlerton *old_db_type, *new_db_type, *save_old_db_type;
4411
 
  legacy_db_type table_type;
4412
4403
 
4413
4404
  new_name_buff[0]= '\0';
4414
4405
 
4461
4452
    into the main table list, like open_tables does).
4462
4453
    This code is wrong and will be removed, please do not copy.
4463
4454
  */
4464
 
  (void)mysql_frm_type(session, new_name_buff, &table_type);
4465
4455
 
4466
4456
  if (!(table= open_n_lock_single_table(session, table_list, TL_WRITE_ALLOW_READ)))
4467
4457
    return(true);