Skip to content

Commit

Permalink
Handle unsigned integer types as their signed versions.
Browse files Browse the repository at this point in the history
Map "unsigned short/int/long" to "short/int/long" instead of "unsigned long
long" they were all mapped to before. Unsigned variants can be compared to the
signed ones and back without loss but "unsigned long long" has a different
size and so can't always be converted from.

Signed-off-by: Vadim Zeitlin <vz-soci@zeitlins.org>
  • Loading branch information
vadz committed Jul 10, 2012
1 parent 4f8bc05 commit 2a88405
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/backends/mysql/statement.cpp
Expand Up @@ -378,7 +378,8 @@ void mysql_statement_backend::describe_column(int colNum,
case FIELD_TYPE_SHORT: //MYSQL_TYPE_SHORT:
case FIELD_TYPE_INT24: //MYSQL_TYPE_INT24:
case FIELD_TYPE_LONG: //MYSQL_TYPE_LONG:
type = dt_integer;
type = field->flags & UNSIGNED_FLAG ? dt_long_long
: dt_integer;
break;
case FIELD_TYPE_LONGLONG: //MYSQL_TYPE_LONGLONG:
type = field->flags & UNSIGNED_FLAG ? dt_unsigned_long_long :
Expand Down
15 changes: 15 additions & 0 deletions src/core/exchange-traits.h
Expand Up @@ -48,13 +48,23 @@ struct exchange_traits<short>
enum { x_type = x_short };
};

template <>
struct exchange_traits<unsigned short> : exchange_traits<short>
{
};

template <>
struct exchange_traits<int>
{
typedef basic_type_tag type_family;
enum { x_type = x_integer };
};

template <>
struct exchange_traits<unsigned int> : exchange_traits<int>
{
};

template <>
struct exchange_traits<char>
{
Expand Down Expand Up @@ -88,6 +98,11 @@ struct exchange_traits<long int>
enum { x_type = long_traits_helper<sizeof(long int)>::x_type };
};

template <>
struct exchange_traits<unsigned long> : exchange_traits<long>
{
};

template <>
struct exchange_traits<double>
{
Expand Down

0 comments on commit 2a88405

Please sign in to comment.