~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

  • Committer: Brian Aker
  • Date: 2010-03-27 21:22:09 UTC
  • Revision ID: brian@gaz-20100327212209-ey71k8qwst00i8q2
Innodb is now in the house (aka... it handls its own DFE).

Show diffs side-by-side

added added

removed removed

Lines of Context:
415
415
  return true;
416
416
}
417
417
 
418
 
class DropTable : 
419
 
  public unary_function<StorageEngine *, void>
420
 
{
421
 
  uint64_t &success_count;
422
 
  TableIdentifier &identifier;
423
 
  Session &session;
424
 
 
425
 
public:
426
 
 
427
 
  DropTable(Session &session_arg, TableIdentifier &arg, uint64_t &count_arg) :
428
 
    success_count(count_arg),
429
 
    identifier(arg),
430
 
    session(session_arg)
431
 
  {
432
 
  }
433
 
 
434
 
  result_type operator() (argument_type engine)
435
 
  {
436
 
    bool success= engine->doDropTable(session, identifier);
437
 
 
438
 
    if (success)
439
 
      success_count++;
440
 
  }
441
 
};
442
 
 
443
 
 
444
418
/**
445
419
   returns ENOENT if the file doesn't exists.
446
420
*/
469
443
 
470
444
  engine= StorageEngine::findByName(session, src_proto.engine().name());
471
445
 
472
 
  if (engine)
 
446
  if (not engine)
473
447
  {
474
 
    error= StorageEngine::dropTable(session, *engine, identifier);
 
448
    my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0), identifier.getSQLPath().c_str());
 
449
 
 
450
    return ER_CORRUPT_TABLE_DEFINITION;
475
451
  }
476
452
 
 
453
  error= StorageEngine::dropTable(session, *engine, identifier);
 
454
 
477
455
  if (error_proto && error == 0)
478
456
    return 0;
479
457
 
489
467
  engine.setTransactionReadWrite(session);
490
468
  error= engine.doDropTable(session, identifier);
491
469
 
492
 
  if (not error)
493
 
  {
494
 
    if (not engine.check_flag(HTON_BIT_HAS_DATA_DICTIONARY))
495
 
    {
496
 
      uint64_t counter; // @todo We need to refactor to check that.
497
 
 
498
 
      for_each(vector_of_schema_engines.begin(), vector_of_schema_engines.end(),
499
 
               DropTable(session, identifier, counter));
500
 
    }
501
 
  }
502
 
 
503
470
  return error;
504
471
}
505
472
 
 
473
 
506
474
/**
507
475
  Initiates table-file and calls appropriate database-creator.
508
476
 
543
511
    }
544
512
    else
545
513
    {
546
 
      bool do_create= true;
547
 
      if (not share.storage_engine->check_flag(HTON_BIT_HAS_DATA_DICTIONARY))
548
 
      {
549
 
        int protoerr= StorageEngine::writeDefinitionFromPath(identifier, table_message);
550
 
 
551
 
        if (protoerr)
552
 
        {
553
 
          error= protoerr;
554
 
          do_create= false;
555
 
        }
556
 
      }
557
 
 
558
 
      if (do_create)
559
 
      {
560
 
        share.storage_engine->setTransactionReadWrite(session);
561
 
 
562
 
        error= share.storage_engine->doCreateTable(&session,
563
 
                                                   table,
564
 
                                                   identifier,
565
 
                                                   table_message);
566
 
      }
 
514
      share.storage_engine->setTransactionReadWrite(session);
 
515
 
 
516
      error= share.storage_engine->doCreateTable(&session,
 
517
                                                 table,
 
518
                                                 identifier,
 
519
                                                 table_message);
567
520
    }
568
521
 
569
522
    if (error)
570
523
    {
571
 
      if (not share.storage_engine->check_flag(HTON_BIT_HAS_DATA_DICTIONARY))
572
 
        plugin::StorageEngine::deleteDefinitionFromPath(identifier);
573
 
 
574
524
      my_error(ER_CANT_CREATE_TABLE, MYF(ME_BELL+ME_WAITTANG), identifier.getSQLPath().c_str(), error);
575
525
    }
576
526