~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

  • Committer: Mark Atwood
  • Date: 2011-05-30 01:04:52 UTC
  • mfrom: (2302.1.9 refactor)
  • Revision ID: me@mark.atwood.name-20110530010452-uc93pknn1h2a4osc
mergeĀ lp:~olafvdspek/drizzle/refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
512
512
  } 
513
513
};
514
514
 
515
 
/* This will later be converted to identifier::Tables */
516
 
class DropTables: public std::unary_function<StorageEngine *, void>
517
 
{
518
 
  Session &session;
519
 
  identifier::table::vector &table_identifiers;
520
 
 
521
 
public:
522
 
 
523
 
  DropTables(Session &session_arg, identifier::table::vector &table_identifiers_arg) :
524
 
    session(session_arg),
525
 
    table_identifiers(table_identifiers_arg)
526
 
  { }
527
 
 
528
 
  result_type operator() (argument_type engine)
529
 
  {
530
 
    // True returning from DropTable means the table has been successfully
531
 
    // deleted, so it should be removed from the list of tables to drop
532
 
    table_identifiers.erase(std::remove_if(table_identifiers.begin(),
533
 
                                           table_identifiers.end(),
534
 
                                           DropTable(session, engine)),
535
 
                            table_identifiers.end());
536
 
  }
537
 
};
538
 
 
539
515
/*
540
516
  This only works for engines which use file based DFE.
541
517
 
578
554
    }
579
555
  }
580
556
 
581
 
  std::for_each(g_engines.begin(), g_engines.end(),
582
 
                DropTables(session, table_identifiers));
 
557
  BOOST_FOREACH(EngineVector::reference it, g_engines)
 
558
  {
 
559
    table_identifiers.erase(std::remove_if(table_identifiers.begin(), table_identifiers.end(), DropTable(session, it)),
 
560
      table_identifiers.end());
 
561
  }
583
562
 
584
563
  /*
585
564
    Now we just clean up anything that might left over.
971
950
  return 0;
972
951
}
973
952
 
974
 
class CanCreateTable: public std::unary_function<StorageEngine *, bool>
975
 
{
976
 
  const identifier::Table &identifier;
977
 
 
978
 
public:
979
 
  CanCreateTable(const identifier::Table &identifier_arg) :
980
 
    identifier(identifier_arg)
981
 
  { }
982
 
 
983
 
  result_type operator() (argument_type engine)
984
 
  {
985
 
    return not engine->doCanCreateTable(identifier);
986
 
  }
987
 
};
988
 
 
989
 
 
990
953
/**
991
954
  @note on success table can be created.
992
955
*/
993
956
bool StorageEngine::canCreateTable(const identifier::Table &identifier)
994
957
{
995
 
  EngineVector::iterator iter=
996
 
    std::find_if(g_engines.begin(), g_engines.end(),
997
 
                 CanCreateTable(identifier));
998
 
 
999
 
  if (iter == g_engines.end())
 
958
  BOOST_FOREACH(EngineVector::reference it, g_engines)
1000
959
  {
1001
 
    return true;
 
960
    if (not it->doCanCreateTable(identifier))
 
961
      return false;
1002
962
  }
1003
 
 
1004
 
  return false;
 
963
  return true;
1005
964
}
1006
965
 
1007
966
bool StorageEngine::readTableFile(const std::string &path, message::Table &table_message)
1033
992
 
1034
993
std::ostream& operator<<(std::ostream& output, const StorageEngine &engine)
1035
994
{
1036
 
  output << "StorageEngine:(";
1037
 
  output <<  engine.getName();
1038
 
  output << ")";
1039
 
 
1040
 
  return output;
 
995
  return output << "StorageEngine:(" <<  engine.getName() << ")";
1041
996
}
1042
997
 
1043
998
} /* namespace plugin */