Commit 4f8bc052 authored by Vadim Zeitlin's avatar Vadim Zeitlin

Remove dt_unsigned_long and x_unsigned_long type constants.

There is no need for a separate type for "unsigned long" as we don't have
special types neither for "unsigned int" nor for "long" and this type was not
handled correctly in the ODBC backend that mapped "unsigned int" to
SQL_BIGINT, even though the former is almost always 32 bits and the latter is
always 64 bits.

Simply remove these types to avoid the problem and simplify the code.
Signed-off-by: 's avatarVadim Zeitlin <vz-soci@zeitlins.org>
parent e1c04c81
......@@ -37,7 +37,7 @@ namespace.</p>
// data types, as seen by the user
enum data_type
{
dt_string, dt_date, dt_double, dt_integer, dt_unsigned_long, dt_long_long
dt_string, dt_date, dt_double, dt_integer, dt_long_long
};
// the enum type for indicator variables
......@@ -47,7 +47,7 @@ enum indicator { i_ok, i_null, i_truncated };
enum exchange_type
{
x_char, x_cstring, x_stdstring, x_short, x_integer,
x_unsigned_long, x_long_long, x_double, x_stdtm, x_statement,
x_long_long, x_double, x_stdtm, x_statement,
x_rowid, x_blob
};
......
......@@ -118,7 +118,7 @@ sql &lt;&lt; "select count(*) from invoices", into(count);
</tr>
<tr>
<td>oid</td>
<td><code>dt_unsigned_long</code></td>
<td><code>dt_integer</code></td>
<td><code>unsigned long</code></td>
</tr>
<tr>
......
......@@ -415,9 +415,6 @@ for(std::size_t i = 0; i != r.size(); ++i)
case dt_integer:
doc &lt;&lt; r.get&lt;int&gt;(i);
break;
case dt_unsigned_long:
doc &lt;&lt; r.get&lt;unsigned long&gt;(i);
break;
case dt_long_long:
doc &lt;&lt; r.get&lt;long long&gt;(i);
break;
......@@ -455,10 +452,6 @@ requested.</p>
<td><code>dt_integer</code></td>
<td><code>int</code></td>
</tr>
<tr>
<td><code>dt_unsigned_long</code></td>
<td><code>unsigned long</code></td>
</tr>
<tr>
<td><code>dt_long_long</code></td>
<td><code>long long</code></td>
......
......@@ -48,8 +48,7 @@ to the backend interface are named here, but documented on the <a
<pre class="example">
// data types, as seen by the user
enum data_type { dt_string, dt_date, dt_double, dt_integer,
dt_unsigned_long, dt_long_long };
enum data_type { dt_string, dt_date, dt_double, dt_integer, dt_long_long };
// the enum type for indicator variables
enum indicator { i_ok, i_null, i_truncated };
......
......@@ -78,12 +78,6 @@ void firebird_standard_into_type_backend::exchangeData()
*reinterpret_cast<short*>(data_) = t;
}
break;
case x_unsigned_long:
{
unsigned long t = from_isc<unsigned long>(var);
*reinterpret_cast<unsigned long*>(data_) = t;
}
break;
case x_integer:
{
int t = from_isc<int>(var);
......
......@@ -108,9 +108,6 @@ void firebird_standard_use_type_backend::exchangeData()
case x_integer:
to_isc<int>(data_, var);
break;
case x_unsigned_long:
to_isc<unsigned long>(data_, var);
break;
case x_long_long:
to_isc<long long>(data_, var);
break;
......
......@@ -74,12 +74,6 @@ void firebird_vector_into_type_backend::exchangeData(std::size_t row)
setIntoVector(data_, row, tmp);
}
break;
case x_unsigned_long:
{
unsigned long tmp = from_isc<unsigned long>(var);
setIntoVector(data_, row, tmp);
}
break;
case x_long_long:
{
long long tmp = from_isc<long long>(var);
......@@ -147,9 +141,6 @@ void firebird_vector_into_type_backend::resize(std::size_t sz)
case x_integer:
resizeVector<int> (data_, sz);
break;
case x_unsigned_long:
resizeVector<unsigned long>(data_, sz);
break;
case x_long_long:
resizeVector<long long> (data_, sz);
break;
......@@ -183,9 +174,6 @@ std::size_t firebird_vector_into_type_backend::size()
case x_integer:
sz = getVectorSize<int> (data_);
break;
case x_unsigned_long:
sz = getVectorSize<unsigned long>(data_);
break;
case x_long_long:
sz = getVectorSize<long long> (data_);
break;
......
......@@ -132,11 +132,6 @@ void firebird_vector_use_type_backend::exchangeData(std::size_t row)
static_cast<void*>(getUseVectorValue<int>(data_, row)),
var);
break;
case x_unsigned_long:
to_isc<unsigned long>(
static_cast<void*>(getUseVectorValue<unsigned long>(data_, row)),
var);
break;
case x_long_long:
to_isc<long long>(
static_cast<void*>(getUseVectorValue<long long>(data_, row)),
......@@ -182,9 +177,6 @@ std::size_t firebird_vector_use_type_backend::size()
case x_integer:
sz = getVectorSize<int> (data_);
break;
case x_unsigned_long:
sz = getVectorSize<unsigned long>(data_);
break;
case x_long_long:
sz = getVectorSize<long long> (data_);
break;
......
......@@ -103,12 +103,6 @@ void mysql_standard_into_type_backend::post_fetch(
parse_num(buf, *dest);
}
break;
case x_unsigned_long:
{
unsigned long *dest = static_cast<unsigned long *>(data_);
parse_num(buf, *dest);
}
break;
case x_long_long:
{
long long *dest = static_cast<long long *>(data_);
......
......@@ -83,15 +83,6 @@ void mysql_standard_use_type_backend::pre_use(indicator const *ind)
snprintf(buf_, bufSize, "%d", *static_cast<int*>(data_));
}
break;
case x_unsigned_long:
{
std::size_t const bufSize
= std::numeric_limits<unsigned long>::digits10 + 2;
buf_ = new char[bufSize];
snprintf(buf_, bufSize, "%lu",
*static_cast<unsigned long*>(data_));
}
break;
case x_long_long:
{
std::size_t const bufSize
......
......@@ -377,10 +377,8 @@ void mysql_statement_backend::describe_column(int colNum,
case FIELD_TYPE_CHAR: //MYSQL_TYPE_TINY:
case FIELD_TYPE_SHORT: //MYSQL_TYPE_SHORT:
case FIELD_TYPE_INT24: //MYSQL_TYPE_INT24:
type = dt_integer;
break;
case FIELD_TYPE_LONG: //MYSQL_TYPE_LONG:
type = field->flags & UNSIGNED_FLAG ? dt_unsigned_long : dt_integer;
type = dt_integer;
break;
case FIELD_TYPE_LONGLONG: //MYSQL_TYPE_LONGLONG:
type = field->flags & UNSIGNED_FLAG ? dt_unsigned_long_long :
......
......@@ -126,13 +126,6 @@ void mysql_vector_into_type_backend::post_fetch(bool gotData, indicator *ind)
set_invector_(data_, i, val);
}
break;
case x_unsigned_long:
{
unsigned long val;
parse_num(buf, val);
set_invector_(data_, i, val);
}
break;
case x_long_long:
{
long long val;
......@@ -195,7 +188,6 @@ void mysql_vector_into_type_backend::resize(std::size_t sz)
case x_char: resizevector_<char> (data_, sz); break;
case x_short: resizevector_<short> (data_, sz); break;
case x_integer: resizevector_<int> (data_, sz); break;
case x_unsigned_long: resizevector_<unsigned long>(data_, sz); break;
case x_long_long: resizevector_<long long> (data_, sz); break;
case x_unsigned_long_long:
resizevector_<unsigned long long>(data_, sz);
......@@ -218,7 +210,6 @@ std::size_t mysql_vector_into_type_backend::size()
case x_char: sz = get_vector_size<char> (data_); break;
case x_short: sz = get_vector_size<short> (data_); break;
case x_integer: sz = get_vector_size<int> (data_); break;
case x_unsigned_long: sz = get_vector_size<unsigned long>(data_); break;
case x_long_long: sz = get_vector_size<long long> (data_); break;
case x_unsigned_long_long:
sz = get_vector_size<unsigned long long>(data_);
......
......@@ -108,18 +108,6 @@ void mysql_vector_use_type_backend::pre_use(indicator const *ind)
snprintf(buf, bufSize, "%d", v[i]);
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *pv
= static_cast<std::vector<unsigned long> *>(data_);
std::vector<unsigned long> &v = *pv;
std::size_t const bufSize
= std::numeric_limits<unsigned long>::digits10 + 2;
buf = new char[bufSize];
snprintf(buf, bufSize, "%lu", v[i]);
}
break;
case x_long_long:
{
std::vector<long long> *pv
......@@ -203,8 +191,7 @@ std::size_t mysql_vector_use_type_backend::size()
case x_char: sz = get_vector_size<char> (data_); break;
case x_short: sz = get_vector_size<short> (data_); break;
case x_integer: sz = get_vector_size<int> (data_); break;
case x_unsigned_long: sz = get_vector_size<unsigned long>(data_); break;
case x_long_long: sz = get_vector_size<long long> (data_); break;
case x_long_long: sz = get_vector_size<long long> (data_); break;
case x_unsigned_long_long:
sz = get_vector_size<unsigned long long>(data_);
break;
......
......@@ -48,10 +48,6 @@ void odbc_standard_into_type_backend::define_by_pos(
odbcType_ = SQL_C_SLONG;
size = sizeof(long);
break;
case x_unsigned_long:
odbcType_ = SQL_C_ULONG;
size = sizeof(unsigned long);
break;
case x_long_long:
odbcType_ = SQL_C_SBIGINT;
size = sizeof(long long);
......
......@@ -30,11 +30,6 @@ void* odbc_standard_use_type_backend::prepare_for_bind(
cType = SQL_C_SLONG;
size = sizeof(int);
break;
case x_unsigned_long:
sqlType = SQL_BIGINT;
cType = SQL_C_ULONG;
size = sizeof(unsigned long);
break;
case x_long_long:
sqlType = SQL_BIGINT;
cType = SQL_C_SBIGINT;
......
......@@ -58,17 +58,6 @@ void odbc_vector_into_type_backend::define_by_pos(
data = &v[0];
}
break;
case x_unsigned_long:
{
odbcType_ = SQL_C_ULONG;
size = sizeof(unsigned long);
std::vector<unsigned long> *vp
= static_cast<std::vector<unsigned long> *>(data);
std::vector<unsigned long> &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_double:
{
odbcType_ = SQL_C_DOUBLE;
......@@ -282,13 +271,6 @@ void odbc_vector_into_type_backend::resize(std::size_t sz)
v->resize(sz);
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *v
= static_cast<std::vector<unsigned long> *>(data_);
v->resize(sz);
}
break;
case x_double:
{
std::vector<double> *v
......@@ -343,13 +325,6 @@ std::size_t odbc_vector_into_type_backend::size()
sz = v->size();
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *v
= static_cast<std::vector<unsigned long> *>(data_);
sz = v->size();
}
break;
case x_double:
{
std::vector<double> *v
......
......@@ -62,18 +62,6 @@ void odbc_vector_use_type_backend::prepare_for_bind(void *&data, SQLUINTEGER &si
data = &v[0];
}
break;
case x_unsigned_long:
{
sqlType = SQL_BIGINT;
cType = SQL_C_ULONG;
size = sizeof(unsigned long);
std::vector<unsigned long> *vp
= static_cast<std::vector<unsigned long> *>(data);
std::vector<unsigned long> &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_double:
{
sqlType = SQL_DOUBLE;
......@@ -335,13 +323,6 @@ std::size_t odbc_vector_use_type_backend::size()
sz = vp->size();
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *vp
= static_cast<std::vector<unsigned long> *>(data_);
sz = vp->size();
}
break;
case x_double:
{
std::vector<double> *vp
......
......@@ -75,10 +75,6 @@ void oracle_standard_into_type_backend::define_by_pos(
oracleType = SQLT_INT;
size = sizeof(int);
break;
case x_unsigned_long:
oracleType = SQLT_UIN;
size = sizeof(unsigned long);
break;
case x_double:
oracleType = SQLT_FLT;
size = sizeof(double);
......
......@@ -63,15 +63,6 @@ void oracle_standard_use_type_backend::prepare_for_bind(
data = buf_;
}
break;
case x_unsigned_long:
oracleType = SQLT_UIN;
size = sizeof(unsigned long);
if (readOnly)
{
buf_ = new char[size];
data = buf_;
}
break;
case x_double:
oracleType = SQLT_FLT;
size = sizeof(double);
......@@ -230,13 +221,6 @@ void oracle_standard_use_type_backend::pre_use(indicator const *ind)
*static_cast<int *>(static_cast<void *>(buf_)) = *static_cast<int *>(data_);
}
break;
case x_unsigned_long:
if (readOnly_)
{
*static_cast<unsigned long *>(static_cast<void *>(buf_))
= *static_cast<unsigned long *>(data_);
}
break;
case x_long_long:
{
size_t const size = 100; // arbitrary, but consistent with prepare_for_bind
......@@ -355,19 +339,6 @@ void oracle_standard_use_type_backend::post_use(bool gotData, indicator *ind)
}
}
break;
case x_unsigned_long:
if (readOnly_)
{
const unsigned long original = *static_cast<unsigned long *>(data_);
const unsigned long bound
= *static_cast<unsigned long *>(static_cast<void *>(buf_));
if (original != bound)
{
throw soci_error("Attempted modification of const use element");
}
}
break;
case x_long_long:
if (readOnly_)
{
......
......@@ -81,17 +81,6 @@ void oracle_vector_into_type_backend::define_by_pos(
data = &v[0];
}
break;
case x_unsigned_long:
{
oracleType = SQLT_UIN;
size = sizeof(unsigned long);
std::vector<unsigned long> *vp
= static_cast<std::vector<unsigned long> *>(data);
std::vector<unsigned long> &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_double:
{
oracleType = SQLT_FLT;
......@@ -350,13 +339,6 @@ void oracle_vector_into_type_backend::resize(std::size_t sz)
v->resize(sz);
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *v
= static_cast<std::vector<unsigned long> *>(data_);
v->resize(sz);
}
break;
case x_long_long:
{
std::vector<long long> *v
......@@ -423,13 +405,6 @@ std::size_t oracle_vector_into_type_backend::size()
sz = v->size();
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *v
= static_cast<std::vector<unsigned long> *>(data_);
sz = v->size();
}
break;
case x_long_long:
{
std::vector<long long> *v
......
......@@ -71,17 +71,6 @@ void oracle_vector_use_type_backend::prepare_for_bind(
data = &v[0];
}
break;
case x_unsigned_long:
{
oracleType = SQLT_UIN;
size = sizeof(unsigned long);
std::vector<unsigned long> *vp
= static_cast<std::vector<unsigned long> *>(data);
std::vector<unsigned long> &v(*vp);
prepare_indicators(v.size());
data = &v[0];
}
break;
case x_double:
{
oracleType = SQLT_FLT;
......@@ -348,13 +337,6 @@ std::size_t oracle_vector_use_type_backend::size()
sz = vp->size();
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *vp
= static_cast<std::vector<unsigned long> *>(data_);
sz = vp->size();
}
break;
case x_long_long:
{
std::vector<long long> *vp
......
......@@ -107,12 +107,6 @@ void postgresql_standard_into_type_backend::post_fetch(
*dest = string_to_integer<int>(buf);
}
break;
case x_unsigned_long:
{
unsigned long * dest = static_cast<unsigned long *>(data_);
*dest = string_to_unsigned_integer<unsigned long>(buf);
}
break;
case x_long_long:
{
long long * dest = static_cast<long long *>(data_);
......
......@@ -95,15 +95,6 @@ void postgresql_standard_use_type_backend::pre_use(indicator const * ind)
*static_cast<int *>(data_));
}
break;
case x_unsigned_long:
{
std::size_t const bufSize
= std::numeric_limits<unsigned long>::digits10 + 2;
buf_ = new char[bufSize];
snprintf(buf_, bufSize, "%lu",
*static_cast<unsigned long *>(data_));
}
break;
case x_long_long:
{
std::size_t const bufSize
......
......@@ -519,6 +519,7 @@ void postgresql_statement_backend::describe_column(int colNum, data_type & type,
case 16: // bool
case 21: // int2
case 23: // int4
case 26: // oid
type = dt_integer;
break;
......@@ -526,10 +527,6 @@ void postgresql_statement_backend::describe_column(int colNum, data_type & type,
type = dt_long_long;
break;
case 26: // oid
type = dt_unsigned_long;
break;
default:
throw soci_error("Unknown data type.");
}
......
......@@ -113,13 +113,6 @@ void postgresql_vector_into_type_backend::post_fetch(bool gotData, indicator * i
set_invector_(data_, i, val);
}
break;
case x_unsigned_long:
{
unsigned long const val =
string_to_unsigned_integer<unsigned long>(buf);
set_invector_(data_, i, val);
}
break;
case x_long_long:
{
long long const val = string_to_integer<long long>(buf);
......@@ -188,9 +181,6 @@ void postgresql_vector_into_type_backend::resize(std::size_t sz)
case x_integer:
resizevector_<int>(data_, sz);
break;
case x_unsigned_long:
resizevector_<unsigned long>(data_, sz);
break;
case x_long_long:
resizevector_<long long>(data_, sz);
break;
......@@ -226,9 +216,6 @@ std::size_t postgresql_vector_into_type_backend::size()
case x_integer:
sz = get_vector_size<int>(data_);
break;
case x_unsigned_long:
sz = get_vector_size<unsigned long>(data_);
break;
case x_long_long:
sz = get_vector_size<long long>(data_);
break;
......
......@@ -108,18 +108,6 @@ void postgresql_vector_use_type_backend::pre_use(indicator const * ind)
snprintf(buf, bufSize, "%d", v[i]);
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> * pv
= static_cast<std::vector<unsigned long> *>(data_);
std::vector<unsigned long> & v = *pv;
std::size_t const bufSize
= std::numeric_limits<unsigned long>::digits10 + 2;
buf = new char[bufSize];
snprintf(buf, bufSize, "%lu", v[i]);
}
break;
case x_long_long:
{
std::vector<long long>* pv
......@@ -209,9 +197,6 @@ std::size_t postgresql_vector_use_type_backend::size()
case x_integer:
sz = get_vector_size<int>(data_);
break;
case x_unsigned_long:
sz = get_vector_size<unsigned long>(data_);
break;
case x_long_long:
sz = get_vector_size<long long>(data_);
break;
......
......@@ -104,12 +104,6 @@ void sqlite3_standard_into_type_backend::post_fetch(bool gotData,
*dest = static_cast<int>(val);
}
break;
case x_unsigned_long:
{
unsigned long* dest = static_cast<unsigned long*>(data_);
*dest = string_to_unsigned_integer<unsigned long >(buf);
}
break;
case x_long_long:
{
long long* dest = static_cast<long long*>(data_);
......
......@@ -120,15 +120,6 @@ void sqlite3_standard_use_type_backend::pre_use(indicator const * ind)
*static_cast<int*>(data_));
}
break;
case x_unsigned_long:
{
std::size_t const bufSize
= std::numeric_limits<unsigned long>::digits10 + 2;
buf_ = new char[bufSize];
snprintf(buf_, bufSize, "%lu",
*static_cast<unsigned long*>(data_));
}
break;
case x_long_long:
{
std::size_t const bufSize
......
......@@ -341,11 +341,6 @@ void sqlite3_statement_backend::describe_column(int colNum, data_type & type,
type = dt_unsigned_long_long;
typeFound = true;
}
else if (dt.find("unsigned int", 0) != std::string::npos)
{
type = dt_unsigned_long;
typeFound = true;
}
else if (dt.find("int", 0) != std::string::npos)
{
type = dt_integer;
......
......@@ -110,12 +110,6 @@ void sqlite3_vector_into_type_backend::post_fetch(bool gotData, indicator * ind)
set_in_vector(data_, i, val);
}
break;
case x_unsigned_long:
{
unsigned long const val = string_to_unsigned_integer<unsigned long>(buf);
set_in_vector(data_, i, val);
}
break;
case x_long_long:
{
long long const val = string_to_integer<long long>(buf);
......@@ -164,9 +158,6 @@ void sqlite3_vector_into_type_backend::resize(std::size_t sz)
case x_integer:
resize_vector<int>(data_, sz);
break;
case x_unsigned_long:
resize_vector<unsigned long>(data_, sz);
break;
case x_long_long:
resize_vector<long long>(data_, sz);
break;
......@@ -202,9 +193,6 @@ std::size_t sqlite3_vector_into_type_backend::size()
case x_integer:
sz = get_vector_size<int>(data_);
break;
case x_unsigned_long:
sz = get_vector_size<unsigned long>(data_);
break;
case x_long_long:
sz = get_vector_size<long long>(data_);
break;
......
......@@ -146,18 +146,6 @@ void sqlite3_vector_use_type_backend::pre_use(indicator const * ind)
snprintf(buf, bufSize, "%d", v[i]);
}
break;
case x_unsigned_long:
{
std::vector<unsigned long> *pv
= static_cast<std::vector<unsigned long> *>(data_);
std::vector<unsigned long> &v = *pv;
std::size_t const bufSize
= std::numeric_limits<unsigned long>::digits10 + 2;
buf = new char[bufSize];
snprintf(buf, bufSize, "%lu", v[i]);
}
break;
case x_long_long:
{
std::vector<long long> *pv
......@@ -243,9 +231,6 @@ std::size_t sqlite3_vector_use_type_backend::size()
case x_integer:
sz = get_vector_size<int>(data_);
break;
case x_unsigned_long:
sz = get_vector_size<unsigned long>(data_);
break;
case x_long_long:
sz = get_vector_size<long long>(data_);
break;
......
......@@ -62,13 +62,6 @@ struct exchange_traits<char>
enum { x_type = x_char };
};
template <>