← Back to team overview

drizzle-discuss team mailing list archive

Re: Extending CREATE TABLE syntax.


On Tue, 29 Jun 2010 18:01:57 +0900, Toru Maesaka <dev@xxxxxxxxx> wrote:
> I was wondering if there is a way to extend the CREATE TABLE syntax so
> that storage engines can provide their own option for specific tables
> (such as table specific optimization argument). MariaDB has done this
> and has a good documentation on it.
>   - http://askmonty.org/wiki/Manual:Extending_CREATE_TABLE

Yep, you can!

It's engine options.

bool InnobaseEngine::validateCreateTableOption(const std::string &key, const std::string &state)
  if (boost::iequals(key, "ROW_FORMAT"))
    if (boost::iequals(state, "COMPRESSED"))
      return true;

    if (boost::iequals(state, "COMPACT"))
      return true;

    if (boost::iequals(state, "DYNAMIC"))
      return true;

    if (boost::iequals(state, "REDUNDANT"))
      return true;

  return false;

and you can then do something like this in create table:
  size_t num_engine_options= create_proto.engine().options_size();
  for (size_t x= 0; x < num_engine_options; ++x)
    if (boost::iequals(create_proto.engine().options(x).name(), "ROW_FORMAT"))
      if (boost::iequals(create_proto.engine().options(x).state(), "COMPRESSED"))
        iflags= DICT_TF_FORMAT_ZIP;

and there you have it, ROW_FORMAT for InnoDB.

Stewart Smith