~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/embedded_innodb/embedded_innodb_engine.cc

  • Committer: Brian Aker
  • Date: 2010-08-05 22:16:39 UTC
  • mfrom: (1685.1.8 drizzle)
  • Revision ID: brian@gaz-20100805221639-w0x32wre7t9slqov
Rollup of Embedded, resolve_stack_dump, boost LIB in include, Archive refactoring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
#include <fcntl.h>
81
81
 
82
82
#include <string>
 
83
#include <boost/algorithm/string.hpp>
83
84
#include <map>
84
85
#include <fstream>
85
86
#include <drizzled/message/table.pb.h>
148
149
    return EmbeddedInnoDBCursor_exts;
149
150
  }
150
151
 
 
152
  bool validateCreateTableOption(const std::string &key,
 
153
                                 const std::string &state);
 
154
 
151
155
  int doCreateTable(Session&,
152
156
                    Table& table_arg,
153
157
                    const drizzled::TableIdentifier &identifier,
778
782
  return err;
779
783
}
780
784
 
 
785
bool EmbeddedInnoDBEngine::validateCreateTableOption(const std::string &key,
 
786
                                                     const std::string &state)
 
787
{
 
788
  if (boost::iequals(key, "ROW_FORMAT"))
 
789
  {
 
790
    if (boost::iequals(state, "COMPRESSED"))
 
791
      return true;
 
792
 
 
793
    if (boost::iequals(state, "COMPACT"))
 
794
      return true;
 
795
 
 
796
    if (boost::iequals(state, "DYNAMIC"))
 
797
      return true;
 
798
 
 
799
    if (boost::iequals(state, "REDUNDANT"))
 
800
      return true;
 
801
  }
 
802
 
 
803
  return false;
 
804
}
 
805
 
 
806
static ib_tbl_fmt_t parse_ib_table_format(const std::string &value)
 
807
{
 
808
  if (boost::iequals(value, "REDUNDANT"))
 
809
    return IB_TBL_REDUNDANT;
 
810
  else if (boost::iequals(value, "COMPACT"))
 
811
    return IB_TBL_COMPACT;
 
812
  else if (boost::iequals(value, "DYNAMIC"))
 
813
    return IB_TBL_DYNAMIC;
 
814
  else if (boost::iequals(value, "COMPRESSED"))
 
815
    return IB_TBL_COMPRESSED;
 
816
 
 
817
  assert(false); /* You need to add possible table formats here */
 
818
  return IB_TBL_COMPACT;
 
819
}
781
820
 
782
821
int EmbeddedInnoDBEngine::doCreateTable(Session &session,
783
822
                                        Table& table_obj,
796
835
 
797
836
  TableIdentifier_to_innodb_name(identifier, &innodb_table_name);
798
837
 
 
838
  ib_tbl_fmt_t innodb_table_format= IB_TBL_COMPACT;
 
839
 
 
840
  const size_t num_engine_options= table_message.engine().options_size();
 
841
  for (size_t x= 0; x < num_engine_options; x++)
 
842
  {
 
843
    const message::Engine::Option &engine_option= table_message.engine().options(x);
 
844
    if (boost::iequals(engine_option.name(), "ROW_FORMAT"))
 
845
    {
 
846
      innodb_table_format= parse_ib_table_format(engine_option.state());
 
847
    }
 
848
  }
 
849
 
799
850
  innodb_err= ib_table_schema_create(innodb_table_name.c_str(),
800
 
                                     &innodb_table_schema, IB_TBL_COMPACT, 0);
 
851
                                     &innodb_table_schema,
 
852
                                     innodb_table_format, 0);
801
853
 
802
854
  if (innodb_err != DB_SUCCESS)
803
855
  {