[SF 2272430] BLOB and CLOB

Renamed:
(Abstract)Preparation => (Abstract)Preparator
(Abstract)Prepare => (Abstract)Preparation
This commit is contained in:
Aleksandar Fabijanic
2008-11-24 00:38:23 +00:00
parent 161e49a6d4
commit a42e8d919b
75 changed files with 2616 additions and 2832 deletions

View File

@@ -45,7 +45,7 @@ namespace MySQL {
Binder::Binder()
{
}
Binder::~Binder()
{
@@ -54,56 +54,56 @@ Binder::~Binder()
void Binder::bind(std::size_t pos, const Poco::Int8& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
}
void Binder::bind(std::size_t pos, const Poco::UInt8& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
}
}
void Binder::bind(std::size_t pos, const Poco::Int16& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
}
void Binder::bind(std::size_t pos, const Poco::UInt16& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
}
void Binder::bind(std::size_t pos, const Poco::Int32& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
}
void Binder::bind(std::size_t pos, const Poco::UInt32& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
}
void Binder::bind(std::size_t pos, const Poco::Int64& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
}
void Binder::bind(std::size_t pos, const Poco::UInt64& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
}
@@ -111,111 +111,118 @@ void Binder::bind(std::size_t pos, const Poco::UInt64& val, Direction dir)
#ifndef POCO_LONG_IS_64_BIT
void Binder::bind(std::size_t pos, const long& val, Direction dir)
{
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
}
#endif
void Binder::bind(std::size_t pos, const bool& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
}
void Binder::bind(std::size_t pos, const float& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_FLOAT, &val, 0);
}
void Binder::bind(std::size_t pos, const double& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_DOUBLE, &val, 0);
}
void Binder::bind(std::size_t pos, const char& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
}
void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_STRING, val.c_str(), static_cast<int>(val.length()));
}
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val, Direction dir)
{
poco_assert(dir == PD_IN);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_BLOB, val.rawContent(), static_cast<int>(val.size()));
}
void Binder::bind(std::size_t pos, const Poco::Data::CLOB& val, Direction dir)
{
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_BLOB, val.rawContent(), static_cast<int>(val.size()));
}
void Binder::bind(std::size_t pos, const DateTime& val, Direction dir)
{
poco_assert(dir == PD_IN);
MYSQL_TIME mt = {0};
poco_assert(dir == PD_IN);
MYSQL_TIME mt = {0};
mt.year = val.year();
mt.month = val.month();
mt.day = val.day();
mt.hour = val.hour();
mt.minute = val.minute();
mt.second = val.second();
mt.second_part = val.millisecond();
mt.time_type = MYSQL_TIMESTAMP_DATETIME;
_dates.push_back(mt);
realBind(pos, MYSQL_TYPE_DATETIME, &_dates.back(), sizeof(mt));
mt.year = val.year();
mt.month = val.month();
mt.day = val.day();
mt.hour = val.hour();
mt.minute = val.minute();
mt.second = val.second();
mt.second_part = val.millisecond();
mt.time_type = MYSQL_TIMESTAMP_DATETIME;
_dates.push_back(mt);
realBind(pos, MYSQL_TYPE_DATETIME, &_dates.back(), sizeof(mt));
}
void Binder::bind(std::size_t pos, const Date& val, Direction dir)
{
poco_assert(dir == PD_IN);
MYSQL_TIME mt = {0};
poco_assert(dir == PD_IN);
MYSQL_TIME mt = {0};
mt.year = val.year();
mt.month = val.month();
mt.day = val.day();
mt.year = val.year();
mt.month = val.month();
mt.day = val.day();
_dates.push_back(mt);
realBind(pos, MYSQL_TYPE_DATE, &_dates.back(), sizeof(mt));
_dates.push_back(mt);
realBind(pos, MYSQL_TYPE_DATE, &_dates.back(), sizeof(mt));
}
void Binder::bind(std::size_t pos, const Time& val, Direction dir)
{
poco_assert(dir == PD_IN);
MYSQL_TIME mt = {0};
poco_assert(dir == PD_IN);
MYSQL_TIME mt = {0};
mt.hour = val.hour();
mt.minute = val.minute();
mt.second = val.second();
mt.hour = val.hour();
mt.minute = val.minute();
mt.second = val.second();
mt.time_type = MYSQL_TIMESTAMP_TIME;
_dates.push_back(mt);
realBind(pos, MYSQL_TYPE_TIME, &_dates.back(), sizeof(mt));
mt.time_type = MYSQL_TIMESTAMP_TIME;
_dates.push_back(mt);
realBind(pos, MYSQL_TYPE_TIME, &_dates.back(), sizeof(mt));
}
void Binder::bind(std::size_t pos, const NullData&, Direction dir)
{
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_NULL, 0, 0);
poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_NULL, 0, 0);
}
@@ -238,31 +245,31 @@ MYSQL_BIND* Binder::getBindArray() const
/*void Binder::updateDates()
{
for (size_t i = 0; i < _dates.size(); i++)
{
switch (_dates[i].mt.time_type)
{
case MYSQL_TIMESTAMP_DATE:
_dates[i].mt.year = _dates[i].link.date->year();
_dates[i].mt.month = _dates[i].link.date->month();
_dates[i].mt.day = _dates[i].link.date->day();
break;
case MYSQL_TIMESTAMP_DATETIME:
_dates[i].mt.year = _dates[i].link.dateTime->year();
_dates[i].mt.month = _dates[i].link.dateTime->month();
_dates[i].mt.day = _dates[i].link.dateTime->day();
_dates[i].mt.hour = _dates[i].link.dateTime->hour();
_dates[i].mt.minute = _dates[i].link.dateTime->minute();
_dates[i].mt.second = _dates[i].link.dateTime->second();
_dates[i].mt.second_part = _dates[i].link.dateTime->millisecond();
break;
case MYSQL_TIMESTAMP_TIME:
_dates[i].mt.hour = _dates[i].link.time->hour();
_dates[i].mt.minute = _dates[i].link.time->minute();
_dates[i].mt.second = _dates[i].link.time->second();
break;
}
}
for (size_t i = 0; i < _dates.size(); i++)
{
switch (_dates[i].mt.time_type)
{
case MYSQL_TIMESTAMP_DATE:
_dates[i].mt.year = _dates[i].link.date->year();
_dates[i].mt.month = _dates[i].link.date->month();
_dates[i].mt.day = _dates[i].link.date->day();
break;
case MYSQL_TIMESTAMP_DATETIME:
_dates[i].mt.year = _dates[i].link.dateTime->year();
_dates[i].mt.month = _dates[i].link.dateTime->month();
_dates[i].mt.day = _dates[i].link.dateTime->day();
_dates[i].mt.hour = _dates[i].link.dateTime->hour();
_dates[i].mt.minute = _dates[i].link.dateTime->minute();
_dates[i].mt.second = _dates[i].link.dateTime->second();
_dates[i].mt.second_part = _dates[i].link.dateTime->millisecond();
break;
case MYSQL_TIMESTAMP_TIME:
_dates[i].mt.hour = _dates[i].link.time->hour();
_dates[i].mt.minute = _dates[i].link.time->minute();
_dates[i].mt.second = _dates[i].link.time->second();
break;
}
}
}*/
///////////////////
@@ -284,7 +291,7 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
MYSQL_BIND b = {0};
b.buffer_type = type;
b.buffer = const_cast<void*>(buffer);
b.buffer = const_cast<void*>(buffer);
b.buffer_length = length;
_bindArray[pos] = b;
@@ -293,325 +300,343 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
void Binder::bind(std::size_t pos, const std::vector<Poco::Int8>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Int8>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Int8>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::UInt8>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::UInt8>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::UInt8>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Int16>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Int16>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Int16>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::UInt16>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::UInt16>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::UInt16>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Int32>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Int32>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Int32>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::UInt32>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::UInt32>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::UInt32>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Int64>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Int64>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Int64>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::UInt64>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::UInt64>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::UInt64>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<bool>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<bool>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<bool>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<float>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<float>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<float>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<double>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<double>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<double>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<char>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<char>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<char>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Data::BLOB>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Data::BLOB>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Data::BLOB>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Data::CLOB>& val, Direction dir)
{
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Data::CLOB>& val, Direction dir)
{
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Data::CLOB>& val, Direction dir)
{
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::DateTime>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::DateTime>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::DateTime>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Data::Date>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Data::Date>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Data::Date>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Data::Time>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Data::Time>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Data::Time>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<Poco::Data::NullData>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<Poco::Data::NullData>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<Poco::Data::NullData>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::vector<std::string>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::deque<std::string>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}
void Binder::bind(std::size_t pos, const std::list<std::string>& val, Direction dir)
{
throw NotImplementedException();
throw NotImplementedException();
}

View File

@@ -53,201 +53,217 @@ Extractor::~Extractor()
{
}
bool Extractor::extract(std::size_t pos, Poco::Int8& val)
{
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
return realExtractFixed(pos, MYSQL_TYPE_TINY, &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);
}
bool Extractor::extract(std::size_t pos, Poco::Int16& val)
{
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val);
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &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);
}
bool Extractor::extract(std::size_t pos, Poco::Int32& val)
{
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
return realExtractFixed(pos, MYSQL_TYPE_LONG, &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);
}
bool Extractor::extract(std::size_t pos, Poco::Int64& val)
{
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &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);
}
#ifndef POCO_LONG_IS_64_BIT
bool Extractor::extract(std::size_t pos, long& val)
/// Extracts a long. Returns false if null was received.
{
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
}
#endif
bool Extractor::extract(std::size_t pos, bool& val)
{
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
}
bool Extractor::extract(std::size_t pos, float& val)
{
return realExtractFixed(pos, MYSQL_TYPE_FLOAT, &val);
return realExtractFixed(pos, MYSQL_TYPE_FLOAT, &val);
}
bool Extractor::extract(std::size_t pos, double& val)
{
return realExtractFixed(pos, MYSQL_TYPE_DOUBLE, &val);
return realExtractFixed(pos, MYSQL_TYPE_DOUBLE, &val);
}
bool Extractor::extract(std::size_t pos, char& val)
{
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
}
bool Extractor::extract(std::size_t pos, std::string& val)
{
if (_metadata.columnsReturned() <= pos)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
if (_metadata.columnsReturned() <= pos)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
return false;
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_STRING)
throw MySQLException("Extractor: not a string");
val.assign(_metadata.rawData(pos), _metadata.length(pos));
return true;
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_STRING)
throw MySQLException("Extractor: not a string");
val.assign(reinterpret_cast<const char*>(_metadata.rawData(pos)), _metadata.length(pos));
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
{
if (_metadata.columnsReturned() <= pos)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
if (_metadata.columnsReturned() <= pos)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
return false;
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
throw MySQLException("Extractor: not a blob");
val.assignRaw(_metadata.rawData(pos), _metadata.length(pos));
return true;
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
throw MySQLException("Extractor: not a blob");
val.assignRaw(_metadata.rawData(pos), _metadata.length(pos));
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Data::CLOB& val)
{
if (_metadata.columnsReturned() <= pos)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
return false;
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
throw MySQLException("Extractor: not a blob");
val.assignRaw(reinterpret_cast<const char*>(_metadata.rawData(pos)), _metadata.length(pos));
return true;
}
bool Extractor::extract(std::size_t pos, DateTime& val)
{
MYSQL_TIME mt = {0};
MYSQL_TIME mt = {0};
if (!realExtractFixed(pos, MYSQL_TYPE_DATETIME, &mt))
return false;
if (!realExtractFixed(pos, MYSQL_TYPE_DATETIME, &mt))
return false;
val.assign(mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second, mt.second_part, 0);
return true;
val.assign(mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second, mt.second_part, 0);
return true;
}
bool Extractor::extract(std::size_t pos, Date& val)
{
MYSQL_TIME mt = {0};
MYSQL_TIME mt = {0};
if (!realExtractFixed(pos, MYSQL_TYPE_DATE, &mt))
return false;
if (!realExtractFixed(pos, MYSQL_TYPE_DATE, &mt))
return false;
val.assign(mt.year, mt.month, mt.day);
return true;
val.assign(mt.year, mt.month, mt.day);
return true;
}
bool Extractor::extract(std::size_t pos, Time& val)
{
MYSQL_TIME mt = {0};
MYSQL_TIME mt = {0};
if (!realExtractFixed(pos, MYSQL_TYPE_TIME, &mt))
return false;
if (!realExtractFixed(pos, MYSQL_TYPE_TIME, &mt))
return false;
val.assign(mt.hour, mt.minute, mt.second);
return true;
val.assign(mt.hour, mt.minute, mt.second);
return true;
}
bool Extractor::extract(std::size_t pos, Any& val)
{
return false;
return false;
}
bool Extractor::extract(std::size_t pos, DynamicAny& val)
bool Extractor::extract(std::size_t pos, Dynamic::Var& val)
{
return false;
return false;
}
bool Extractor::isNull(std::size_t col, std::size_t row)
{
poco_assert(row == POCO_DATA_INVALID_ROW);
poco_assert(row == POCO_DATA_INVALID_ROW);
if (_metadata.columnsReturned() <= col)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.columnsReturned() <= col)
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
if (_metadata.isNull(static_cast<Poco::UInt32>(col)))
return true;
if (_metadata.isNull(static_cast<Poco::UInt32>(col)))
return true;
return false;
return false;
}
void Extractor::reset()
{
AbstractExtractor::reset();
AbstractExtractor::reset();
}
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length)
{
MYSQL_BIND bind = {0};
my_bool isNull = 0;
MYSQL_BIND bind = {0};
my_bool isNull = 0;
bind.is_null = &isNull;
bind.buffer_type = type;
bind.buffer = buffer;
bind.buffer_length = static_cast<unsigned long>(length);
if (!_stmt.fetchColumn(pos, &bind))
return false;
bind.is_null = &isNull;
bind.buffer_type = type;
bind.buffer = buffer;
bind.buffer_length = static_cast<unsigned long>(length);
if (!_stmt.fetchColumn(pos, &bind))
return false;
return isNull == 0;
return isNull == 0;
}
@@ -258,363 +274,381 @@ bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* b
bool Extractor::extract(std::size_t , std::vector<Poco::Int8>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::Int8>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::Int8>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::UInt8>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::UInt8>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::UInt8>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::Int16>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::Int16>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::Int16>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::UInt16>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::UInt16>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::UInt16>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::Int32>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::Int32>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::Int32>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::UInt32>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::UInt32>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::UInt32>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::Int64>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::Int64>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::Int64>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Poco::UInt64>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Poco::UInt64>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Poco::UInt64>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
#ifndef POCO_LONG_IS_64_BIT
bool Extractor::extract(std::size_t , std::vector<long>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<long>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<long>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
#endif
bool Extractor::extract(std::size_t , std::vector<bool>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<bool>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<bool>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<float>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<float>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<float>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<double>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<double>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<double>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<char>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<char>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<char>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<std::string>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<std::string>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<std::string>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<BLOB>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<BLOB>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<BLOB>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<CLOB>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<CLOB>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<CLOB>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<DateTime>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<DateTime>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<DateTime>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Date>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Date>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Date>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Time>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Time>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Time>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<Any>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<Any>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<Any>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::vector<DynamicAny>& )
bool Extractor::extract(std::size_t , std::vector<Dynamic::Var>& )
{
throw NotImplementedException("std::vector extractor must be implemented.");
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::deque<DynamicAny>& )
bool Extractor::extract(std::size_t , std::deque<Dynamic::Var>& )
{
throw NotImplementedException("std::deque extractor must be implemented.");
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool Extractor::extract(std::size_t , std::list<DynamicAny>& )
bool Extractor::extract(std::size_t , std::list<Dynamic::Var>& )
{
throw NotImplementedException("std::list extractor must be implemented.");
throw NotImplementedException("std::list extractor must be implemented.");
}

View File

@@ -80,12 +80,12 @@ namespace
case MYSQL_TYPE_DOUBLE: return sizeof(double);
case MYSQL_TYPE_LONGLONG: return sizeof(Poco::Int64);
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
return sizeof(MYSQL_TIME);
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
return sizeof(MYSQL_TIME);
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
@@ -94,7 +94,7 @@ namespace
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
return field.length;
default:
throw Poco::Data::MySQL::StatementException("unknown field type");
}
@@ -140,9 +140,9 @@ namespace
case MYSQL_TYPE_BLOB:
return Poco::Data::MetaColumn::FDT_BLOB;
default:
return Poco::Data::MetaColumn::FDT_UNKNOWN;
return Poco::Data::MetaColumn::FDT_UNKNOWN;
}
}
}
} // namespace
@@ -184,7 +184,7 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
fields[i].name, // name
fieldType(fields[i]), // type
fieldSize(fields[i]), // length
0, // TODO: precision (Now I dont know how to get it)
0, // TODO: precision
!IS_NOT_NULL(fields[i].flags) // nullable
));
@@ -232,14 +232,14 @@ size_t ResultMetadata::length(size_t pos) const
return _lengths[pos];
}
const char* ResultMetadata::rawData(size_t pos) const
const unsigned char* ResultMetadata::rawData(size_t pos) const
{
return reinterpret_cast<const char*>(_row[pos].buffer);
return reinterpret_cast<const unsigned char*>(_row[pos].buffer);
}
bool ResultMetadata::isNull(size_t pos) const
{
return (_isNull[pos] != 0);
return (_isNull[pos] != 0);
}
}}} // namespace Poco::Data::MySQL