summaryrefslogtreecommitdiff
path: root/odb/relational/mysql/schema.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-01-26 12:43:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-01-26 12:43:16 +0200
commitaf12ffe836de09ec84f666effa4df347eeb07a43 (patch)
treedc0aec9f8fee545c84be098414772cf2b277c30d /odb/relational/mysql/schema.cxx
parentc1d2ec5bbd5969332f3278f39d2a7a8f0abc0493 (diff)
Implement support for database schema
New pragma qualifier: namespace. New pragma specifier: schema. The table specifier was extended to accept a schema prefix. New option: --default- schema. The common/schema test was extended to cover the new functionality.
Diffstat (limited to 'odb/relational/mysql/schema.cxx')
-rw-r--r--odb/relational/mysql/schema.cxx22
1 files changed, 19 insertions, 3 deletions
diff --git a/odb/relational/mysql/schema.cxx b/odb/relational/mysql/schema.cxx
index 428db1c..1bdb6dd 100644
--- a/odb/relational/mysql/schema.cxx
+++ b/odb/relational/mysql/schema.cxx
@@ -91,10 +91,12 @@ namespace relational
name (sema_rel::foreign_key& fk)
{
// In MySQL, foreign key names are database-global. Make them
- // unique by prefixing the key name with table name.
+ // unique by prefixing the key name with table name. Note,
+ // however, that they cannot be prefixed with the database name.
//
- return static_cast<sema_rel::table&> (fk.scope ()).name () +
- '_' + fk.name ();
+ return quote_id (
+ static_cast<sema_rel::table&> (fk.scope ()).name ().uname ()
+ + "_" + fk.name ());
}
virtual void
@@ -124,6 +126,20 @@ namespace relational
}
};
entry<create_table> create_table_;
+
+ struct create_index: relational::create_index, context
+ {
+ create_index (base const& x): base (x) {}
+
+ virtual string
+ name (sema_rel::index& in)
+ {
+ // In MySQL an index cannot be qualified with the database name.
+ //
+ return quote_id (in.name ().uname ());
+ }
+ };
+ entry<create_index> create_index_;
}
}
}