23#include <drizzled/errmsg_print.h>
24#include <drizzled/gettext.h>
25#include <drizzled/identifier.h>
26#include <drizzled/session.h>
27#include <drizzled/internal/my_sys.h>
28#include <drizzled/catalog/local.h>
29#include <drizzled/util/tablename_to_filename.h>
30#include <drizzled/util/backtrace.h>
31#include <drizzled/charset.h>
37#include <boost/algorithm/string/compare.hpp>
44Schema::Schema(
const drizzled::identifier::Catalog &catalog_arg,
46 db(db_arg.data(), db_arg.size()),
50 string::size_type lastPos= db.find_first_of(
'/', 0);
52 if (lastPos != std::string::npos)
54 catalog= db.substr(0, lastPos);
55 db.erase(0, lastPos + 1);
59 if (db_arg.empty() ==
false)
61 db_path += _catalog.getPath();
62 db_path += FN_LIBCHAR;
63 db_path += util::tablename_to_filename(db);
64 assert(db_path.length());
67 _corrected_db= boost::to_lower_copy(db);
70const std::string &Schema::getPath()
const
75bool Schema::compare(
const std::string &arg)
const
77 return boost::iequals(arg, db);
80bool Schema::compare(
const Schema& arg)
const
82 return boost::iequals(arg.getSchemaName(), db);
85bool Schema::isValid()
const
87 const charset_info_st& cs= my_charset_utf8mb4_general_ci;
88 int well_formed_error;
90 && db.size() <= NAME_LEN
92 && db.at(db.size() - 1) !=
' '
93 && db.size() == cs.cset->well_formed_len(cs, db, NAME_CHAR_LEN, &well_formed_error))
95 if (not well_formed_error)
98 my_error(ER_WRONG_DB_NAME, *
this);
102const std::string &Schema::getCatalogName()
const
104 return _catalog.name();
107std::ostream& operator<<(std::ostream& output,
const Schema&identifier)
109 return output <<
"identifier::Schema:(" << identifier.getCatalogName() <<
", " << identifier.getSchemaName() <<
", " << identifier.getPath() <<
")";
TODO: Rename this file - func.h is stupid.