535
539
TODO -> Remove this to force all engines to implement their own file. Solves the "we only looked at dfe" problem.
537
void StorageEngine::doGetTableNames(CachedDirectory&, string&, set<string>&)
541
void StorageEngine::doGetTableNames(CachedDirectory&, SchemaIdentifier&, set<string>&)
540
544
class AddTableName :
541
545
public unary_function<StorageEngine *, void>
544
CachedDirectory& directory;
547
CachedDirectory &directory;
548
SchemaIdentifier &identifier;
545
549
TableNameList &set_of_names;
549
AddTableName(CachedDirectory& directory_arg, const string& database_name, set<string>& of_names) :
553
AddTableName(CachedDirectory &directory_arg, SchemaIdentifier &identifier_arg, set<string>& of_names) :
550
554
directory(directory_arg),
551
set_of_names(of_names)
556
result_type operator() (argument_type engine)
558
engine->doGetTableNames(directory, db, set_of_names);
562
class AddSchemaNames :
563
public unary_function<StorageEngine *, void>
565
SchemaNameList &set_of_names;
569
AddSchemaNames(set<string>& of_names) :
570
set_of_names(of_names)
574
result_type operator() (argument_type engine)
576
engine->doGetSchemaNames(set_of_names);
580
void StorageEngine::getSchemaNames(Session &session, SchemaNameList &set_of_names)
582
// Add hook here for engines to register schema.
583
for_each(vector_of_schema_engines.begin(), vector_of_schema_engines.end(),
584
AddSchemaNames(set_of_names));
586
plugin::Authorization::pruneSchemaNames(session.getSecurityContext(),
590
class StorageEngineGetSchemaDefinition: public unary_function<StorageEngine *, bool>
592
std::string schema_name;
593
message::Schema &schema_proto;
596
StorageEngineGetSchemaDefinition(const std::string schema_name_arg,
597
message::Schema &schema_proto_arg) :
598
schema_name(schema_name_arg),
599
schema_proto(schema_proto_arg)
601
transform(schema_name.begin(), schema_name.end(),
602
schema_name.begin(), ::tolower);
605
result_type operator() (argument_type engine)
607
return engine->doGetSchemaDefinition(schema_name, schema_proto);
612
Return value is "if parsed"
614
bool StorageEngine::getSchemaDefinition(TableIdentifier &identifier, message::Schema &proto)
616
return StorageEngine::getSchemaDefinition(identifier.getSchemaName(), proto);
619
bool StorageEngine::getSchemaDefinition(const std::string &schema_name, message::Schema &proto)
623
EngineVector::iterator iter=
624
find_if(vector_of_schema_engines.begin(), vector_of_schema_engines.end(),
625
StorageEngineGetSchemaDefinition(schema_name, proto));
627
if (iter != vector_of_schema_engines.end())
635
bool StorageEngine::doesSchemaExist(const std::string &schema_name)
637
message::Schema proto;
639
return StorageEngine::getSchemaDefinition(schema_name, proto);
642
bool StorageEngine::doesSchemaExist(TableIdentifier &identifier)
644
message::Schema proto;
646
return StorageEngine::getSchemaDefinition(identifier.getSchemaName(), proto);
650
const CHARSET_INFO *StorageEngine::getSchemaCollation(const std::string &schema_name)
652
message::Schema schmema_proto;
655
found= StorageEngine::getSchemaDefinition(schema_name, schmema_proto);
657
if (found && schmema_proto.has_collation())
659
const string buffer= schmema_proto.collation();
660
const CHARSET_INFO* cs= get_charset_by_name(buffer.c_str());
664
errmsg_printf(ERRMSG_LVL_ERROR,
665
_("Error while loading database options: '%s':"), schema_name.c_str());
666
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_UNKNOWN_COLLATION), buffer.c_str());
668
return default_charset_info;
674
return default_charset_info;
678
public unary_function<StorageEngine *, void>
680
const drizzled::message::Schema &schema_message;
684
CreateSchema(const drizzled::message::Schema &arg) :
689
result_type operator() (argument_type engine)
691
// @todo eomeday check that at least one engine said "true"
692
(void)engine->doCreateSchema(schema_message);
696
bool StorageEngine::createSchema(const drizzled::message::Schema &schema_message)
698
// Add hook here for engines to register schema.
699
for_each(vector_of_schema_engines.begin(), vector_of_schema_engines.end(),
700
CreateSchema(schema_message));
706
public unary_function<StorageEngine *, void>
708
uint64_t &success_count;
709
const string &schema_name;
713
DropSchema(const string &arg, uint64_t &count_arg) :
714
success_count(count_arg),
719
result_type operator() (argument_type engine)
721
// @todo someday check that at least one engine said "true"
722
bool success= engine->doDropSchema(schema_name);
729
bool StorageEngine::dropSchema(const string &schema_name)
732
// Add hook here for engines to register schema.
733
for_each(vector_of_schema_engines.begin(), vector_of_schema_engines.end(),
734
DropSchema(schema_name, counter));
736
return counter ? true : false;
740
public unary_function<StorageEngine *, void>
742
uint64_t &success_count;
743
const drizzled::message::Schema &schema_message;
747
AlterSchema(const drizzled::message::Schema &arg, uint64_t &count_arg) :
748
success_count(count_arg),
753
result_type operator() (argument_type engine)
755
// @todo eomeday check that at least one engine said "true"
756
bool success= engine->doAlterSchema(schema_message);
763
bool StorageEngine::alterSchema(const drizzled::message::Schema &schema_message)
765
uint64_t success_count= 0;
767
for_each(vector_of_schema_engines.begin(), vector_of_schema_engines.end(),
768
AlterSchema(schema_message, success_count));
770
return success_count ? true : false;
774
void StorageEngine::getTableNames(Session &session, const string &schema_name, TableNameList &set_of_names)
778
build_table_filename(tmp_path, schema_name.c_str(), "", false);
780
CachedDirectory directory(tmp_path, set_of_table_definition_ext);
782
if (not schema_name.compare("information_schema"))
555
identifier(identifier_arg),
556
set_of_names(of_names)
560
result_type operator() (argument_type engine)
562
engine->doGetTableNames(directory, identifier, set_of_names);
567
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("information_schema");
568
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("data_dictionary");
570
void StorageEngine::getTableNames(Session &session, SchemaIdentifier &schema_identifier, TableNameList &set_of_names)
572
CachedDirectory directory(schema_identifier.getPath(), set_of_table_definition_ext);
574
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
784
else if (not schema_name.compare("data_dictionary"))
576
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)