Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/MariaResultPrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ void MariaResultPrep::cache_metadata() {

bool binary = fields[i].charsetnr == 63;
bool length1 = fields[i].length == 1;
MariaFieldType type = variable_type_from_field_type(fields[i].type, binary, length1);
bool is_unsigned = (fields[i].flags & UNSIGNED_FLAG ) != 0;
MariaFieldType type = variable_type_from_field_type(fields[i].type, binary, length1, is_unsigned);
types_.push_back(type);

LOG_VERBOSE << i << " -> " << fields[i].name << "(" << fields[i].type << ", " << binary << ") => " << type_name(type);
Expand Down
11 changes: 9 additions & 2 deletions src/MariaTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@

bool all_raw(SEXP x);

MariaFieldType variable_type_from_field_type(enum_field_types type, bool binary, bool length1) {
MariaFieldType variable_type_from_field_type(enum_field_types type, bool binary, bool length1, bool is_unsigned) {
if (type == MYSQL_TYPE_LONG) {
if (is_unsigned) {
// For unsigned ints, promote it to a double
return MY_DBL;
} else {
return MY_INT32;
}
}

switch (type) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_YEAR:
return MY_INT32;
Expand Down
2 changes: 1 addition & 1 deletion src/MariaTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum MariaFieldType {
MY_LGL // for BIT(1)
};

MariaFieldType variable_type_from_field_type(enum_field_types type, bool binary, bool length1);
MariaFieldType variable_type_from_field_type(enum_field_types type, bool binary, bool length1, bool is_unsigned);
std::string type_name(MariaFieldType type);
SEXPTYPE type_sexp(MariaFieldType type);

Expand Down
Loading