aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-01-22 16:08:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-01-22 16:08:05 +0200
commit43539f96afd937bb8a5b73c98a755a9de93c5f49 (patch)
tree3e1e8bf59c65d87a806ef895096a936a0572cca3
parentc0b30bd6639ad43efbb8d7723ad0ad8c7b3991e0 (diff)
Fix INTERVAL types parsing
Assign default precisions, store seconds precision for INTERVAL DAY TO SECOND in scale since prec stores the days precisions.
-rw-r--r--odb/relational/oracle/context.cxx37
1 files changed, 29 insertions, 8 deletions
diff --git a/odb/relational/oracle/context.cxx b/odb/relational/oracle/context.cxx
index 1c2ea40..0f9bae1 100644
--- a/odb/relational/oracle/context.cxx
+++ b/odb/relational/oracle/context.cxx
@@ -311,12 +311,18 @@ namespace relational
{
prefix += " ";
prefix += id;
+
+ r.prec = true;
+ r.prec_value = 2;
s = parse_prec;
}
else if (id == "DAY" && prefix == "INTERVAL")
{
prefix += " ";
prefix += id;
+
+ r.prec = true;
+ r.prec_value = 2;
s = parse_prec;
}
else if (id == "TO" &&
@@ -329,11 +335,17 @@ namespace relational
else if (id == "MONTH" && prefix == "INTERVAL YEAR TO")
{
r.type = sql_type::INTERVAL_YM;
- s = parse_prec;
+ s = parse_done;
}
else if (id == "SECOND" && prefix == "INTERVAL DAY TO")
{
r.type = sql_type::INTERVAL_DS;
+
+ // Store seconds precision in scale since prec holds
+ // the days precision.
+ //
+ r.scale = true;
+ r.scale_value = 6;
s = parse_prec;
}
//
@@ -530,8 +542,19 @@ namespace relational
"type declaration");
}
- r.prec = true;
- r.prec_value = v;
+ // Store seconds precision in scale since prec holds
+ // the days precision for INTERVAL DAY TO SECOND.
+ //
+ if (r.type == sql_type::INTERVAL_DS)
+ {
+ r.scale = true;
+ r.scale_value = static_cast<short> (v);
+ }
+ else
+ {
+ r.prec = true;
+ r.prec_value = v;
+ }
t = l.next ();
}
@@ -540,14 +563,12 @@ namespace relational
//
if (t.punctuation () == sql_token::p_comma)
{
- // If we are parsing the precision of a TIMESTAMP or INTERVAL
- // type, there should be no scale present.
+ // Scale can only be specified for NUMBER.
//
- if (r.type == sql_type::TIMESTAMP ||
- string (prefix, 0, 8) == "INTERVAL")
+ if (r.type != sql_type::NUMBER)
{
throw invalid_sql_type (
- "invalid precision in Oracle type declaration");
+ "invalid scale in Oracle type declaration");
}
t = l.next ();