mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 00:15:27 +01:00
ODBC string truncation bug fix
This commit is contained in:
parent
533f42bfce
commit
9dde6fb1ef
@ -154,11 +154,16 @@ std::size_t Preparation::maxDataSize(std::size_t pos) const
|
||||
|
||||
try
|
||||
{
|
||||
sz = ODBCMetaColumn(_rStmt, pos).length();
|
||||
ODBCMetaColumn mc(_rStmt, pos);
|
||||
sz = mc.length();
|
||||
|
||||
// accomodate for terminating zero (non-bulk only!)
|
||||
if (!isBulk() && ODBCMetaColumn::FDT_STRING == mc.type()) ++sz;
|
||||
}
|
||||
catch (StatementException&) { }
|
||||
|
||||
if (!sz || sz > maxsz) sz = maxsz;
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
@ -331,8 +331,15 @@ public:
|
||||
/// Returns the length of prepared data. Defaults to 1.
|
||||
/// The length is greater than one for bulk operations.
|
||||
|
||||
void setBulk(bool bulkPrep = true);
|
||||
/// Sets bulk operation flag (always false at object creation time)
|
||||
|
||||
bool isBulk() const;
|
||||
/// Returns bulk operation flag.
|
||||
|
||||
private:
|
||||
Poco::UInt32 _length;
|
||||
bool _bulk;
|
||||
};
|
||||
|
||||
|
||||
@ -351,6 +358,17 @@ inline Poco::UInt32 AbstractPreparation::getLength() const
|
||||
}
|
||||
|
||||
|
||||
inline void AbstractPreparation::setBulk(bool bulkPrep)
|
||||
{
|
||||
_bulk = bulkPrep;
|
||||
}
|
||||
|
||||
|
||||
inline bool AbstractPreparation::isBulk() const
|
||||
{
|
||||
return _bulk;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Data
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "Poco/Data/Data.h"
|
||||
#include "Poco/Data/AbstractExtraction.h"
|
||||
#include "Poco/Data/Bulk.h"
|
||||
#include "Poco/Data/Prepare.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
@ -130,6 +131,7 @@ public:
|
||||
Poco::UInt32 limit = getLimit();
|
||||
if (limit != _rResult.size()) _rResult.resize(limit);
|
||||
pPrep->setLength(limit);
|
||||
pPrep->setBulk(true);
|
||||
return new Prepare<C>(pPrep, col, _rResult);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,8 @@ namespace Data {
|
||||
|
||||
|
||||
AbstractPreparation::AbstractPreparation(Poco::UInt32 length):
|
||||
_length(length)
|
||||
_length(length),
|
||||
_bulk(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user