aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/oracle/context.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/relational/oracle/context.cxx')
-rw-r--r--odb/relational/oracle/context.cxx124
1 files changed, 68 insertions, 56 deletions
diff --git a/odb/relational/oracle/context.cxx b/odb/relational/oracle/context.cxx
index 37ada79..9093ce1 100644
--- a/odb/relational/oracle/context.cxx
+++ b/odb/relational/oracle/context.cxx
@@ -458,41 +458,38 @@ namespace relational
t = l.next ();
continue;
}
- else
+ else if (!prefix.empty ())
{
// Some prefixes can also be type names if not followed
// by the actual type name.
//
- if (!prefix.empty ())
+
+ if (prefix == "CHAR" || prefix == "CHARACTER")
{
- if (prefix == "CHAR" || prefix == "CHARACTER")
- {
- r.type = sql_type::CHAR;
- r.range = true;
- r.range_value = 1;
- r.byte_semantics = true;
- }
- else if (prefix == "NCHAR" ||
- prefix == "NATIONAL CHAR" ||
- prefix == "NATIONAL CHARACTER")
- {
- r.type = sql_type::NCHAR;
- r.range = true;
- r.range_value = 1;
- r.byte_semantics = false;
- }
- else if (prefix == "TIMESTAMP")
- {
- r.type = sql_type::TIMESTAMP;
- r.range = true;
- r.range_value = 6;
- }
+ r.type = sql_type::CHAR;
+ r.range = true;
+ r.range_value = 1;
+ r.byte_semantics = true;
}
-
- if (r.type == sql_type::invalid)
+ else if (prefix == "NCHAR" ||
+ prefix == "NATIONAL CHAR" ||
+ prefix == "NATIONAL CHARACTER")
+ {
+ r.type = sql_type::NCHAR;
+ r.range = true;
+ r.range_value = 1;
+ r.byte_semantics = false;
+ }
+ else if (prefix == "TIMESTAMP")
+ {
+ r.type = sql_type::TIMESTAMP;
+ r.range = true;
+ r.range_value = 6;
+ }
+ else
{
throw invalid_sql_type (
- "unknown Oracle type '" + t.identifier () + "'");
+ "incomplete Oracle type declaration: '" + prefix + "'");
}
// All of the possible types handled in this block can take an
@@ -501,6 +498,14 @@ namespace relational
//
s = parse_range;
}
+ else
+ {
+ assert (r.type == sql_type::invalid);
+
+ throw invalid_sql_type (
+ "unexepected '" + t.literal () + "' in Oracle "
+ "type declaration");
+ }
// Fall through.
//
@@ -545,9 +550,10 @@ namespace relational
//
if (r.type == sql_type::TIMESTAMP ||
string (prefix, 0, 8) == "INTERVAL")
+ {
throw invalid_sql_type (
- "invalid precision value '" + t.literal () + "' in "
- "Oracle type declaration");
+ "invalid precision in Oracle type declaration");
+ }
t = l.next ();
@@ -597,13 +603,13 @@ namespace relational
t = l.next ();
}
- s = parse_identifier;
+ s = r.type == sql_type::invalid ? parse_identifier : parse_done;
continue;
}
case parse_done:
{
throw invalid_sql_type (
- "invalid keyword '" + t.literal () + "' in Oracle "
+ "unexepected '" + t.literal () + "' in Oracle "
"type declaration");
break;
@@ -614,38 +620,44 @@ namespace relational
// Some prefixes can also be type names if not followed by the actual
// type name.
//
- if (r.type == sql_type::invalid && !prefix.empty ())
+ if (r.type == sql_type::invalid)
{
- if (prefix == "CHAR" || prefix == "CHARACTER")
- {
- r.type = sql_type::CHAR;
- r.range = true;
- r.range_value = 1;
- r.byte_semantics = true;
- }
- else if (prefix == "NCHAR" ||
- prefix == "NATIONAL CHAR" ||
- prefix == "NATIONAL CHARACTER")
+ if (!prefix.empty ())
{
- r.type = sql_type::NCHAR;
- r.range = true;
- r.range_value = 1;
- r.byte_semantics = false;
+ if (prefix == "CHAR" || prefix == "CHARACTER")
+ {
+ r.type = sql_type::CHAR;
+ r.range = true;
+ r.range_value = 1;
+ r.byte_semantics = true;
+ }
+ else if (prefix == "NCHAR" ||
+ prefix == "NATIONAL CHAR" ||
+ prefix == "NATIONAL CHARACTER")
+ {
+ r.type = sql_type::NCHAR;
+ r.range = true;
+ r.range_value = 1;
+ r.byte_semantics = false;
+ }
+ else if (prefix == "TIMESTAMP")
+ {
+ r.type = sql_type::TIMESTAMP;
+ r.range = true;
+ r.range_value = 6;
+ }
+ else
+ {
+ throw invalid_sql_type (
+ "incomplete Oracle type declaration: '" + prefix + "'");
+ }
}
- else if (prefix == "TIMESTAMP")
+ else
{
- r.type = sql_type::TIMESTAMP;
- r.range = true;
- r.range_value = 6;
+ throw invalid_sql_type ("invalid Oracle type declaration");
}
}
- if (r.type == sql_type::invalid)
- {
- throw invalid_sql_type (
- "incomplete Oracle type declaration: '" + prefix + "'");
- }
-
return r;
}
catch (sql_lexer::invalid_input const& e)