diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-07-25 12:13:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-07-27 10:30:15 +0200 |
commit | 923639283d2bae0b82cb605fa4680a3058c9d973 (patch) | |
tree | 3c122b70129cdd2b502e1f7056eac896c109f03a /odb/relational/mysql | |
parent | adfa9bbd04cd3571932ee7675344ca723bfa1eab (diff) |
Add support for defining indexes
New db pragma qualifier: index. New tests: common/index, mysql/index,
pgsql/index.
Diffstat (limited to 'odb/relational/mysql')
-rw-r--r-- | odb/relational/mysql/schema.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/odb/relational/mysql/schema.cxx b/odb/relational/mysql/schema.cxx index 4050d70..8068fc4 100644 --- a/odb/relational/mysql/schema.cxx +++ b/odb/relational/mysql/schema.cxx @@ -125,6 +125,36 @@ namespace relational } }; entry<create_table> create_table_; + + struct create_index: relational::create_index, context + { + create_index (base const& x): base (x) {} + + virtual void + create (sema_rel::index& in) + { + os << "CREATE "; + + if (!in.type ().empty ()) + os << in.type () << ' '; + + os << "INDEX " << name (in); + + if (!in.method ().empty ()) + os << " USING " << in.method (); + + os << endl + << " ON " << table_name (in) << " ("; + + columns (in); + + os << ")" << endl; + + if (!in.options ().empty ()) + os << ' ' << in.options () << endl; + } + }; + entry<create_index> create_index_; } } } |