aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/oracle
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/oracle
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/oracle')
-rw-r--r--odb/relational/oracle/context.cxx23
-rw-r--r--odb/relational/oracle/context.hxx2
-rw-r--r--odb/relational/oracle/schema.cxx20
3 files changed, 30 insertions, 15 deletions
diff --git a/odb/relational/oracle/context.cxx b/odb/relational/oracle/context.cxx
index d477a19..bb76ee7 100644
--- a/odb/relational/oracle/context.cxx
+++ b/odb/relational/oracle/context.cxx
@@ -103,13 +103,26 @@ namespace relational
}
string context::
- quote_id_impl (string const& id) const
+ quote_id_impl (qname const& id) const
{
string r;
- r.reserve (32);
- r += '"';
- r.append (id, 0, 30);
- r += '"';
+
+ bool f (true);
+ for (qname::iterator i (id.begin ()); i < id.end (); ++i)
+ {
+ if (i->empty ())
+ continue;
+
+ if (f)
+ f = false;
+ else
+ r += '.';
+
+ r += '"';
+ r.append (*i, 0, 30); // Max identifier length is 30.
+ r += '"';
+ }
+
return r;
}
diff --git a/odb/relational/oracle/context.hxx b/odb/relational/oracle/context.hxx
index ea81136..e19264a 100644
--- a/odb/relational/oracle/context.hxx
+++ b/odb/relational/oracle/context.hxx
@@ -98,7 +98,7 @@ namespace relational
protected:
virtual string
- quote_id_impl (string const&) const;
+ quote_id_impl (qname const&) const;
protected:
virtual string
diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx
index a371235..b98facc 100644
--- a/odb/relational/oracle/schema.cxx
+++ b/odb/relational/oracle/schema.cxx
@@ -94,7 +94,7 @@ namespace relational
drop_table (base const& x): base (x) {}
virtual void
- drop (string const& table)
+ drop (sema_rel::qname const& table)
{
// Oracle has no IF EXISTS conditional for dropping objects. The
// PL/SQL approach below seems to be the least error-prone and the
@@ -142,7 +142,7 @@ namespace relational
private:
friend class create_foreign_key;
- set<string> tables_; // Set of tables we have already defined.
+ set<qname> tables_; // Set of tables we have already defined.
};
entry<create_table> create_table_;
@@ -203,10 +203,12 @@ namespace relational
name (sema_rel::foreign_key& fk)
{
// In Oracle, foreign key names are schema-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 have a schema.
//
- 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 ());
}
};
entry<create_foreign_key> create_foreign_key_;
@@ -256,11 +258,11 @@ namespace relational
if (pk != 0 && pk->auto_ ())
{
- string const& tname (t.name ());
+ qname const& tname (t.name ());
string const& cname (pk->contains_begin ()->column ().name ());
- string seq_name (tname + "_seq");
- string trg_name (tname + "_trg");
+ qname seq_name (tname + "_seq");
+ qname trg_name (tname + "_trg");
// Sequence.
//
@@ -292,7 +294,7 @@ namespace relational
// Add foreign keys.
//
instance<add_foreign_key> fk (format_, *this);
- trav_rel::names n (*fk);
+ trav_rel::unames n (*fk);
names (t, n);
}
}