mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 23:07:56 +02:00
GH #192: Unsigned integer values not handled properly in result sets
This commit is contained in:
@@ -62,7 +62,7 @@ bool Extractor::extract(std::size_t pos, Poco::Int8& val)
|
||||
|
||||
bool Extractor::extract(std::size_t pos, Poco::UInt8& val)
|
||||
{
|
||||
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
||||
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ bool Extractor::extract(std::size_t pos, Poco::Int16& val)
|
||||
|
||||
bool Extractor::extract(std::size_t pos, Poco::UInt16& val)
|
||||
{
|
||||
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val);
|
||||
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ bool Extractor::extract(std::size_t pos, Poco::Int32& val)
|
||||
|
||||
bool Extractor::extract(std::size_t pos, Poco::UInt32& val)
|
||||
{
|
||||
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
|
||||
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ bool Extractor::extract(std::size_t pos, Poco::Int64& val)
|
||||
|
||||
bool Extractor::extract(std::size_t pos, Poco::UInt64& val)
|
||||
{
|
||||
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
|
||||
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ bool Extractor::extract(std::size_t pos, long& val)
|
||||
|
||||
bool Extractor::extract(std::size_t pos, unsigned long& val)
|
||||
{
|
||||
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
|
||||
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -255,7 +255,7 @@ void Extractor::reset()
|
||||
}
|
||||
|
||||
|
||||
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, std::size_t length)
|
||||
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, std::size_t length, bool isUnsigned)
|
||||
{
|
||||
MYSQL_BIND bind = {0};
|
||||
my_bool isNull = 0;
|
||||
@@ -264,6 +264,7 @@ bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* b
|
||||
bind.buffer_type = type;
|
||||
bind.buffer = buffer;
|
||||
bind.buffer_length = static_cast<unsigned long>(length);
|
||||
bind.is_unsigned = isUnsigned;
|
||||
|
||||
if (!_stmt.fetchColumn(pos, &bind))
|
||||
return false;
|
||||
|
@@ -217,6 +217,7 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
|
||||
_row[i].buffer = &_buffer[0] + offset;
|
||||
_row[i].length = &_lengths[i];
|
||||
_row[i].is_null = &_isNull[i];
|
||||
_row[i].is_unsigned = (fields[i].flags & UNSIGNED_FLAG) > 0;
|
||||
|
||||
offset += _row[i].buffer_length;
|
||||
}}
|
||||
|
@@ -86,7 +86,7 @@ void StatementExecutor::prepare(const std::string& query)
|
||||
void StatementExecutor::bindParams(MYSQL_BIND* params, std::size_t count)
|
||||
{
|
||||
if (_state < STMT_COMPILED)
|
||||
throw StatementException("Satement is not compiled yet");
|
||||
throw StatementException("Statement is not compiled yet");
|
||||
|
||||
if (count != mysql_stmt_param_count(_pHandle))
|
||||
throw StatementException("wrong bind parameters count", 0, _query);
|
||||
@@ -101,7 +101,7 @@ void StatementExecutor::bindParams(MYSQL_BIND* params, std::size_t count)
|
||||
void StatementExecutor::bindResult(MYSQL_BIND* result)
|
||||
{
|
||||
if (_state < STMT_COMPILED)
|
||||
throw StatementException("Satement is not compiled yet");
|
||||
throw StatementException("Statement is not compiled yet");
|
||||
|
||||
if (mysql_stmt_bind_result(_pHandle, result) != 0)
|
||||
throw StatementException("mysql_stmt_bind_result error ", _pHandle, _query);
|
||||
@@ -111,7 +111,7 @@ void StatementExecutor::bindResult(MYSQL_BIND* result)
|
||||
void StatementExecutor::execute()
|
||||
{
|
||||
if (_state < STMT_COMPILED)
|
||||
throw StatementException("Satement is not compiled yet");
|
||||
throw StatementException("Statement is not compiled yet");
|
||||
|
||||
if (mysql_stmt_execute(_pHandle) != 0)
|
||||
throw StatementException("mysql_stmt_execute error", _pHandle, _query);
|
||||
@@ -127,7 +127,7 @@ void StatementExecutor::execute()
|
||||
bool StatementExecutor::fetch()
|
||||
{
|
||||
if (_state < STMT_EXECUTED)
|
||||
throw StatementException("Satement is not executed yet");
|
||||
throw StatementException("Statement is not executed yet");
|
||||
|
||||
int res = mysql_stmt_fetch(_pHandle);
|
||||
|
||||
@@ -141,7 +141,7 @@ bool StatementExecutor::fetch()
|
||||
bool StatementExecutor::fetchColumn(std::size_t n, MYSQL_BIND *bind)
|
||||
{
|
||||
if (_state < STMT_EXECUTED)
|
||||
throw StatementException("Satement is not executed yet");
|
||||
throw StatementException("Statement is not executed yet");
|
||||
|
||||
int res = mysql_stmt_fetch_column(_pHandle, bind, static_cast<unsigned int>(n), 0);
|
||||
|
||||
|
Reference in New Issue
Block a user