summaryrefslogtreecommitdiff
path: root/odb/semantics
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-07-25 12:13:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-07-27 10:30:15 +0200
commit923639283d2bae0b82cb605fa4680a3058c9d973 (patch)
tree3c122b70129cdd2b502e1f7056eac896c109f03a /odb/semantics
parentadfa9bbd04cd3571932ee7675344ca723bfa1eab (diff)
Add support for defining indexes
New db pragma qualifier: index. New tests: common/index, mysql/index, pgsql/index.
Diffstat (limited to 'odb/semantics')
-rw-r--r--odb/semantics/elements.cxx4
-rw-r--r--odb/semantics/elements.hxx19
-rw-r--r--odb/semantics/relational/index.hxx31
-rw-r--r--odb/semantics/relational/key.hxx9
4 files changed, 54 insertions, 9 deletions
diff --git a/odb/semantics/elements.cxx b/odb/semantics/elements.cxx
index 4b8fcea..ddae187 100644
--- a/odb/semantics/elements.cxx
+++ b/odb/semantics/elements.cxx
@@ -27,13 +27,13 @@ namespace semantics
//
node::
node (path const& file, size_t line, size_t column, tree tn)
- : tree_node_ (tn), file_ (file), line_ (line), column_ (column)
+ : tree_node_ (tn), loc_ (file, line, column)
{
}
node::
node ()
- : file_ ("")
+ : loc_ (0)
{
// GCC plugin machinery #define's abort as a macro.
//
diff --git a/odb/semantics/elements.hxx b/odb/semantics/elements.hxx
index 59e058d..ac62ff9 100644
--- a/odb/semantics/elements.hxx
+++ b/odb/semantics/elements.hxx
@@ -20,6 +20,7 @@
#include <cutl/compiler/context.hxx>
#include <odb/gcc-fwd.hxx>
+#include <odb/location.hxx>
namespace semantics
{
@@ -134,22 +135,30 @@ namespace semantics
}
public:
+ typedef ::location location_type;
+
path const&
file () const
{
- return file_;
+ return loc_.file;
}
size_t
line () const
{
- return line_;
+ return loc_.line;
}
size_t
column () const
{
- return column_;
+ return loc_.column;
+ }
+
+ location_type const&
+ location () const
+ {
+ return loc_;
}
public:
@@ -204,9 +213,7 @@ namespace semantics
tree tree_node_;
unit_type* unit_;
- path file_;
- size_t line_;
- size_t column_;
+ location_type loc_;
};
//
diff --git a/odb/semantics/relational/index.hxx b/odb/semantics/relational/index.hxx
index af90b12..bf08a23 100644
--- a/odb/semantics/relational/index.hxx
+++ b/odb/semantics/relational/index.hxx
@@ -17,13 +17,42 @@ namespace semantics
class index: public key
{
public:
- index (string const& id): key (id) {}
+ index (string const& id,
+ string const& t = string (),
+ string const& m = string (),
+ string const& o = string ())
+ : key (id), type_ (t), method_ (m), options_ (o)
+ {
+ }
+
+ string const&
+ type () const
+ {
+ return type_;
+ }
+
+ string const&
+ method () const
+ {
+ return method_;
+ }
+
+ string const&
+ options () const
+ {
+ return options_;
+ }
virtual string
kind () const
{
return "index";
}
+
+ private:
+ string type_; // E.g., "UNIQUE", etc.
+ string method_; // E.g., "BTREE", etc.
+ string options_; // Database-specific index options.
};
}
}
diff --git a/odb/semantics/relational/key.hxx b/odb/semantics/relational/key.hxx
index 40e7499..3b86f1c 100644
--- a/odb/semantics/relational/key.hxx
+++ b/odb/semantics/relational/key.hxx
@@ -32,7 +32,15 @@ namespace semantics
return *column_;
}
+ string const&
+ options () const
+ {
+ return options_;
+ }
+
public:
+ contains (string const& o = string ()) : options_ (o) {}
+
void
set_left_node (key_type& n)
{
@@ -48,6 +56,7 @@ namespace semantics
protected:
key_type* key_;
column_type* column_;
+ string options_;
};
class key: public unameable