From c0b30bd6639ad43efbb8d7723ad0ad8c7b3991e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 22 Jan 2012 15:44:52 +0200 Subject: Rename range to precision in Oracle generator --- odb/relational/oracle/common.cxx | 18 ++++---- odb/relational/oracle/context.cxx | 89 ++++++++++++++++++++------------------- odb/relational/oracle/context.hxx | 6 +-- odb/relational/oracle/header.cxx | 6 +-- 4 files changed, 60 insertions(+), 59 deletions(-) (limited to 'odb') diff --git a/odb/relational/oracle/common.cxx b/odb/relational/oracle/common.cxx index 0049b3f..708c4e7 100644 --- a/odb/relational/oracle/common.cxx +++ b/odb/relational/oracle/common.cxx @@ -115,9 +115,9 @@ namespace relational { const sql_type& st (*mi.st); - if (st.range) + if (st.prec) { - unsigned short r (st.range_value); + unsigned short r (st.prec_value); if (!st.scale) { @@ -137,10 +137,10 @@ namespace relational { // We can calculate the decimal exponent of the normalised // floating point equivalent of the fixed point number using - // e = r - s, where r is the range, s is the scale, and e the - // exponent. We can then use this to determine whether or not a - // value of Oracle SQL type NUMBER can be completely stored in - // the native floating point type. + // e = p - s, where p is the precision, s is the scale, and + // e the exponent. We can then use this to determine whether + // or not a value of Oracle SQL type NUMBER can be completely + // stored in the native floating point type. // // The maximum decimal precision of a float is 7 significant @@ -168,7 +168,7 @@ namespace relational } } else - // If there is not range, then this is a floating-point number. + // If there is no precision, then this is a floating-point number. // traverse_double (mi); @@ -180,9 +180,9 @@ namespace relational // seeing that in 99% of cases it is the precision that is the // limiting factor and not the exponent. // - if (mi.st->range_value <= 24) + if (mi.st->prec_value <= 24) traverse_float (mi); - else if (mi.st->range_value <= 53) + else if (mi.st->prec_value <= 53) traverse_double (mi); else traverse_big_float (mi); diff --git a/odb/relational/oracle/context.cxx b/odb/relational/oracle/context.cxx index 4eff3ed..1c2ea40 100644 --- a/odb/relational/oracle/context.cxx +++ b/odb/relational/oracle/context.cxx @@ -197,7 +197,7 @@ namespace relational enum state { parse_identifier, - parse_range, + parse_prec, parse_done }; @@ -223,10 +223,10 @@ namespace relational if ((id == "NUMBER") && prefix.empty ()) { // If NUMBER has no precision/scale, then it is a floating- - // point number. We indicate this by having no range. + // point number. We indicate this by having no precision. // r.type = sql_type::NUMBER; - s = parse_range; + s = parse_prec; } else if ((id == "DEC" || id == "DECIMAL" || id == "NUMERIC") && prefix.empty ()) @@ -236,17 +236,17 @@ namespace relational // point number. The scale defaults to zero. // r.type = sql_type::NUMBER; - s = parse_range; + s = parse_prec; } else if ((id == "INT" || id == "INTEGER" || id == "SMALLINT") && prefix.empty ()) { // INT, INTEGER, and SMALLINT map to NUMBER(38). They may not - // have range or scale explicitly specified. + // have precision or scale explicitly specified. // r.type = sql_type::NUMBER; - r.range = true; - r.range_value = 38; + r.prec = true; + r.prec_value = 38; s = parse_done; } @@ -256,10 +256,10 @@ namespace relational else if (id == "FLOAT" && prefix.empty ()) { r.type = sql_type::FLOAT; - r.range = true; - r.range_value = 126; + r.prec = true; + r.prec_value = 126; - s = parse_range; + s = parse_prec; } else if (id == "DOUBLE" && prefix.empty ()) { @@ -268,16 +268,16 @@ namespace relational else if (id == "PRECISION" && prefix == "DOUBLE") { r.type = sql_type::FLOAT; - r.range = true; - r.range_value = 126; + r.prec = true; + r.prec_value = 126; s = parse_done; } else if (id == "REAL" && prefix.empty ()) { r.type = sql_type::FLOAT; - r.range = true; - r.range_value = 63; + r.prec = true; + r.prec_value = 63; s = parse_done; } @@ -311,13 +311,13 @@ namespace relational { prefix += " "; prefix += id; - s = parse_range; + s = parse_prec; } else if (id == "DAY" && prefix == "INTERVAL") { prefix += " "; prefix += id; - s = parse_range; + s = parse_prec; } else if (id == "TO" && (prefix == "INTERVAL YEAR" || @@ -329,12 +329,12 @@ namespace relational else if (id == "MONTH" && prefix == "INTERVAL YEAR TO") { r.type = sql_type::INTERVAL_YM; - s = parse_range; + s = parse_prec; } else if (id == "SECOND" && prefix == "INTERVAL DAY TO") { r.type = sql_type::INTERVAL_DS; - s = parse_range; + s = parse_prec; } // // Timestamp with time zone (not supported). @@ -388,12 +388,12 @@ namespace relational // However, this may change in future versions. // r.type = sql_type::VARCHAR2; - s = parse_range; + s = parse_prec; } else if (id == "NVARCHAR2") { r.type = sql_type::NVARCHAR2; - s = parse_range; + s = parse_prec; } else if (id == "VARYING") { @@ -406,7 +406,7 @@ namespace relational prefix == "NATIONAL CHARACTER") r.type = sql_type::NVARCHAR2; - s = parse_range; + s = parse_prec; } else if (id == "NATIONAL" && prefix.empty ()) { @@ -415,7 +415,7 @@ namespace relational else if (id == "RAW" && prefix.empty ()) { r.type = sql_type::RAW; - s = parse_range; + s = parse_prec; } // // LOB types. @@ -461,8 +461,8 @@ namespace relational if (prefix == "CHAR" || prefix == "CHARACTER") { r.type = sql_type::CHAR; - r.range = true; - r.range_value = 1; + r.prec = true; + r.prec_value = 1; r.byte_semantics = true; } else if (prefix == "NCHAR" || @@ -470,15 +470,15 @@ namespace relational prefix == "NATIONAL CHARACTER") { r.type = sql_type::NCHAR; - r.range = true; - r.range_value = 1; + r.prec = true; + r.prec_value = 1; r.byte_semantics = false; } else if (prefix == "TIMESTAMP") { r.type = sql_type::TIMESTAMP; - r.range = true; - r.range_value = 6; + r.prec = true; + r.prec_value = 6; } else { @@ -486,11 +486,11 @@ namespace relational "incomplete Oracle type declaration: '" + prefix + "'"); } - // All of the possible types handled in this block can take an - // optional range specifier. Set the state and fall through to - // the parse_range handler. + // All of the possible types handled in this block can take + // an optional precision specifier. Set the state and fall + // through to the parse_prec handler. // - s = parse_range; + s = parse_prec; } else { @@ -504,7 +504,7 @@ namespace relational // Fall through. // } - case parse_range: + case parse_prec: { if (t.punctuation () == sql_token::p_lparen) { @@ -513,10 +513,11 @@ namespace relational if (t.type () != sql_token::t_int_lit) { throw invalid_sql_type ( - "integer range expected in Oracle type declaration"); + "integer size/precision expected in Oracle type " + "declaration"); } - // Parse the range. + // Parse the precision. // { unsigned short v; @@ -525,12 +526,12 @@ namespace relational if (!(is >> v && is.eof ())) { throw invalid_sql_type ( - "invalid range value '" + t.literal () + "' in Oracle " + "invalid prec value '" + t.literal () + "' in Oracle " "type declaration"); } - r.range = true; - r.range_value = v; + r.prec = true; + r.prec_value = v; t = l.next (); } @@ -621,8 +622,8 @@ namespace relational if (prefix == "CHAR" || prefix == "CHARACTER") { r.type = sql_type::CHAR; - r.range = true; - r.range_value = 1; + r.prec = true; + r.prec_value = 1; r.byte_semantics = true; } else if (prefix == "NCHAR" || @@ -630,15 +631,15 @@ namespace relational prefix == "NATIONAL CHARACTER") { r.type = sql_type::NCHAR; - r.range = true; - r.range_value = 1; + r.prec = true; + r.prec_value = 1; r.byte_semantics = false; } else if (prefix == "TIMESTAMP") { r.type = sql_type::TIMESTAMP; - r.range = true; - r.range_value = 6; + r.prec = true; + r.prec_value = 6; } else { diff --git a/odb/relational/oracle/context.hxx b/odb/relational/oracle/context.hxx index e130dfa..ea81136 100644 --- a/odb/relational/oracle/context.hxx +++ b/odb/relational/oracle/context.hxx @@ -55,14 +55,14 @@ namespace relational }; sql_type () : - type (invalid), range (false), scale (false), byte_semantics (true) + type (invalid), prec (false), scale (false), byte_semantics (true) { } core_type type; - bool range; - unsigned short range_value; // Oracle max value is 4000. + bool prec; + unsigned short prec_value; // Oracle max value is 4000. bool scale; short scale_value; // Oracle min value is -84. Max value is 127. diff --git a/odb/relational/oracle/header.cxx b/odb/relational/oracle/header.cxx index cc436de..c302a82 100644 --- a/odb/relational/oracle/header.cxx +++ b/odb/relational/oracle/header.cxx @@ -105,8 +105,8 @@ namespace relational // size_t n (19); - if (mi.st->range) - n = mi.st->range_value / 2 + mi.st->range_value % 2; + if (mi.st->prec) + n = mi.st->prec_value / 2 + mi.st->prec_value % 2; // We require an additional byte for each of the exponent and // negative value terminator values. @@ -182,7 +182,7 @@ namespace relational virtual void traverse_string (member_info& mi) { - size_t n (mi.st->range ? mi.st->range_value : 1); + size_t n (mi.st->prec ? mi.st->prec_value : 1); // National characters can be either UTF-8 or UTF-16 encoded, both // of which have a maximum character encoding size of 4 bytes. -- cgit v1.1