Update POCO library.

This commit is contained in:
Sandu Liviu Catalin committed 2023-03-23 20:19:11 +02:00
1 parent 8d15f4b6e9
commit 233fc103f9
2521 files changed
+257092 -72789

No files matched your search

+53 -9
View File
@@ -30,7 +30,10 @@ namespace ODBC {
Binder::Binder(const StatementHandle& rStmt,
std::size_t maxFieldSize,
Binder::ParameterBinding dataBinding,
const TypeInfo* pDataTypes):
const TypeInfo* pDataTypes,
Poco::TextEncoding::Ptr pFromEncoding,
Poco::TextEncoding::Ptr pDBEncoding):
Poco::Data::AbstractBinder(pFromEncoding, pDBEncoding),
_rStmt(rStmt),
_paramBinding(dataBinding),
_pTypeInfo(pDataTypes),
@@ -99,13 +102,30 @@ void Binder::freeMemory()
DateTimeVecVec::iterator itDateTimeVec = _dateTimeVecVec.begin();
DateTimeVecVec::iterator itDateTimeVecEnd = _dateTimeVecVec.end();
for (; itDateTimeVec != itDateTimeVecEnd; ++itDateTimeVec) delete *itDateTimeVec;
if (transcodeRequired() && _inParams.size())
{
ParamMap::iterator itInParams = _inParams.begin();
ParamMap::iterator itInParamsEnd = _inParams.end();
for (; itInParams != itInParamsEnd; ++itInParams) free(itInParams->first);
}
}
void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
{
char* pTCVal = 0;
SQLINTEGER size = 0;
if (transcodeRequired())
{
std::string tcVal;
transcode(val, tcVal);
size = (SQLINTEGER)tcVal.size();
pTCVal = reinterpret_cast<char*>(std::calloc((size_t)size+1, 1));
std::memcpy(pTCVal, tcVal.data(), size);
}
else size = (SQLINTEGER)val.size();
SQLPOINTER pVal = 0;
SQLINTEGER size = (SQLINTEGER) val.size();
SQLINTEGER colSize = 0;
SQLSMALLINT decDigits = 0;
getColSizeAndPrecision(pos, SQL_C_CHAR, colSize, decDigits, val.size());
@@ -120,8 +140,16 @@ void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
}
else if (isInBound(dir))
{
pVal = (SQLPOINTER) val.c_str();
_inParams.insert(ParamMap::value_type(pVal, size));
if (!pTCVal)
{
pVal = (SQLPOINTER)val.c_str();
_inParams.insert(ParamMap::value_type(pVal, size));
}
else
{
pVal = (SQLPOINTER)pTCVal;
_inParams.insert(ParamMap::value_type(pVal, size));
}
}
else
throw InvalidArgumentException("Parameter must be [in] OR [out] bound.");
@@ -421,12 +449,28 @@ void Binder::synchronize()
Utility::dateTimeSync(*it->second, *it->first);
}
if (_strings.size())
if (!transcodeRequired())
{
StringMap::iterator it = _strings.begin();
StringMap::iterator end = _strings.end();
for(; it != end; ++it)
it->second->assign(it->first, std::strlen(it->first));
if (_strings.size())
{
StringMap::iterator it = _strings.begin();
StringMap::iterator end = _strings.end();
for (; it != end; ++it)
it->second->assign(it->first, std::strlen(it->first));
}
}
else
{
if (_strings.size())
{
StringMap::iterator it = _strings.begin();
StringMap::iterator end = _strings.end();
for (; it != end; ++it)
{
std::string str(it->first, std::strlen(it->first));
reverseTranscode(str, *it->second);
}
}
}
if (_uuids.size())
+11 -8
View File
@@ -15,6 +15,8 @@
#include "Poco/Data/ODBC/ConnectionHandle.h"
#include "Poco/Data/ODBC/Utility.h"
#include "Poco/Data/ODBC/ODBCException.h"
#include "Poco/Error.h"
#include "Poco/Debugger.h"
namespace Poco {
@@ -22,14 +24,14 @@ namespace Data {
namespace ODBC {
ConnectionHandle::ConnectionHandle(EnvironmentHandle* pEnvironment):
ConnectionHandle::ConnectionHandle(EnvironmentHandle* pEnvironment):
_pEnvironment(pEnvironment ? pEnvironment : new EnvironmentHandle),
_hdbc(SQL_NULL_HDBC),
_hdbc(SQL_NULL_HDBC),
_ownsEnvironment(pEnvironment ? false : true)
{
if (Utility::isError(SQLAllocHandle(SQL_HANDLE_DBC,
_pEnvironment->handle(),
&_hdbc)))
if (Utility::isError(SQLAllocHandle(SQL_HANDLE_DBC,
_pEnvironment->handle(),
&_hdbc)))
{
throw ODBCException("Could not allocate connection handle.");
}
@@ -42,10 +44,11 @@ ConnectionHandle::~ConnectionHandle()
{
SQLDisconnect(_hdbc);
SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_DBC, _hdbc);
if (_ownsEnvironment) delete _pEnvironment;
poco_assert (!Utility::isError(rc));
#if defined(_DEBUG)
if (Utility::isError(rc))
Debugger::enter(Poco::Error::getMessage(Poco::Error::last()), __FILE__, __LINE__);
#endif
}
catch (...)
{
+11 -6
View File
@@ -15,6 +15,8 @@
#include "Poco/Data/ODBC/EnvironmentHandle.h"
#include "Poco/Data/ODBC/Utility.h"
#include "Poco/Data/ODBC/ODBCException.h"
#include "Poco/Error.h"
#include "Poco/Debugger.h"
namespace Poco {
@@ -24,12 +26,12 @@ namespace ODBC {
EnvironmentHandle::EnvironmentHandle(): _henv(SQL_NULL_HENV)
{
if (Utility::isError(SQLAllocHandle(SQL_HANDLE_ENV,
SQL_NULL_HANDLE,
if (Utility::isError(SQLAllocHandle(SQL_HANDLE_ENV,
SQL_NULL_HANDLE,
&_henv)) ||
Utility::isError(SQLSetEnvAttr(_henv,
SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3,
Utility::isError(SQLSetEnvAttr(_henv,
SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3,
0)))
{
throw ODBCException("Could not initialize environment.");
@@ -42,7 +44,10 @@ EnvironmentHandle::~EnvironmentHandle()
try
{
SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_ENV, _henv);
poco_assert (!Utility::isError(rc));
#if defined(_DEBUG)
if (Utility::isError(rc))
Debugger::enter(Poco::Error::getMessage(Poco::Error::last()), __FILE__, __LINE__);
#endif
}
catch (...)
{
+6 -8
View File
@@ -35,13 +35,11 @@ const std::string Extractor::FLD_SIZE_EXCEEDED_FMT = "Specified data size (%z by
Extractor::Extractor(const StatementHandle& rStmt,
Preparator::Ptr pPreparator,
TextEncoding::Ptr pDBEncoding):
TextEncoding::Ptr pDBEncoding,
Poco::TextEncoding::Ptr pToEncoding): AbstractExtractor(pDBEncoding, pToEncoding),
_rStmt(rStmt),
_pPreparator(pPreparator),
_dataExtraction(pPreparator->getDataExtraction()),
_pDBEncoding(pDBEncoding),
_transcode(_pDBEncoding && !_pDBEncoding->isA("UTF-8")),
_pToEncoding(_transcode ? Poco::TextEncoding::find("UTF-8") : nullptr)
_dataExtraction(pPreparator->getDataExtraction())
{
}
@@ -707,7 +705,7 @@ bool Extractor::extract(std::size_t pos, std::string& val)
{
bool ret = false;
if (!_transcode)
if (!transcodeRequired())
{
if (Preparator::DE_MANUAL == _dataExtraction)
ret = extractManualImpl(pos, val, SQL_C_CHAR);
@@ -721,8 +719,8 @@ bool Extractor::extract(std::size_t pos, std::string& val)
ret = extractManualImpl(pos, result, SQL_C_CHAR);
else
ret = extractBoundImpl(pos, result);
Poco::TextConverter converter(*_pDBEncoding, *_pToEncoding);
converter.convert(result, val);
transcode(result, val);
}
return ret;
+1
View File
@@ -160,6 +160,7 @@ void ODBCMetaColumn::init()
setType(MetaColumn::FDT_DATE); break;
case SQL_TYPE_TIME:
case -154: //MS SQL Server custom type SQL_SS_TIME2
setType(MetaColumn::FDT_TIME); break;
case SQL_TYPE_TIMESTAMP:
+30 -26
View File
@@ -83,7 +83,7 @@ void ODBCStatementImpl::compileImpl()
addPreparator();
Binder::ParameterBinding bind = session().getFeature("autoBind") ?
Binder::ParameterBinding bind = session().getFeature("autoBind") ?
Binder::PB_IMMEDIATE : Binder::PB_AT_EXEC;
const TypeInfo* pDT = 0;
@@ -92,14 +92,15 @@ void ODBCStatementImpl::compileImpl()
Poco::Any dti = session().getProperty("dataTypeInfo");
pDT = AnyCast<const TypeInfo*>(dti);
}
catch (NotSupportedException&)
catch (NotSupportedException&)
{
}
std::size_t maxFieldSize = AnyCast<std::size_t>(session().getProperty("maxFieldSize"));
_pBinder = new Binder(_stmt, maxFieldSize, bind, pDT);
_pBinder = new Binder(_stmt, maxFieldSize, bind, pDT, TextEncoding::find("UTF-8"),
TextEncoding::find(Poco::RefAnyCast<std::string>(session().getProperty("dbEncoding"))));
makeInternalExtractors();
doPrepare();
@@ -109,12 +110,12 @@ void ODBCStatementImpl::compileImpl()
void ODBCStatementImpl::makeInternalExtractors()
{
if (hasData() && !extractions().size())
if (hasData() && !extractions().size())
{
try
{
fillColumns();
}
}
catch (DataFormatException&)
{
if (isStoredProcedure()) return;
@@ -135,7 +136,7 @@ void ODBCStatementImpl::addPreparator()
if (statement.empty())
throw ODBCException("Empty statements are illegal");
Preparator::DataExtraction ext = session().getFeature("autoExtract") ?
Preparator::DataExtraction ext = session().getFeature("autoExtract") ?
Preparator::DE_BOUND : Preparator::DE_MANUAL;
std::size_t maxFieldSize = AnyCast<std::size_t>(session().getProperty("maxFieldSize"));
@@ -146,7 +147,8 @@ void ODBCStatementImpl::addPreparator()
_preparations.push_back(new Preparator(*_preparations[0]));
_extractors.push_back(new Extractor(_stmt, _preparations.back(),
TextEncoding::find(Poco::RefAnyCast<std::string>(session().getProperty("dbEncoding")))));
TextEncoding::find(Poco::RefAnyCast<std::string>(session().getProperty("dbEncoding"))),
TextEncoding::find("UTF-8")));
}
@@ -164,7 +166,7 @@ void ODBCStatementImpl::doPrepare()
if (it != itEnd && (*it)->isBulk())
{
std::size_t limit = getExtractionLimit();
if (limit == Limit::LIMIT_UNLIMITED)
if (limit == Limit::LIMIT_UNLIMITED)
throw InvalidArgumentException("Bulk operation not allowed without limit.");
checkError(Poco::Data::ODBC::SQLSetStmtAttr(_stmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) limit, 0),
"SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)");
@@ -239,13 +241,13 @@ void ODBCStatementImpl::putData()
{
dataSize = (SQLINTEGER) _pBinder->parameterSize(pParam);
if (Utility::isError(SQLPutData(_stmt, pParam, dataSize)))
if (Utility::isError(SQLPutData(_stmt, pParam, dataSize)))
throw StatementException(_stmt, "SQLPutData()");
}
else // if pParam is null pointer, do a dummy call
{
char dummy = 0;
if (Utility::isError(SQLPutData(_stmt, &dummy, 0)))
if (Utility::isError(SQLPutData(_stmt, &dummy, 0)))
throw StatementException(_stmt, "SQLPutData()");
}
}
@@ -399,10 +401,10 @@ void ODBCStatementImpl::checkError(SQLRETURN rc, const std::string& msg)
if (Utility::isError(rc))
{
std::ostringstream os;
os << std::endl << "Requested SQL statement: " << toString() << std::endl;
os << "Native SQL statement: " << nativeSQL() << std::endl;
os << std::endl << "Requested SQL statement: " << toString() << std::endl;
os << "Native SQL statement: " << nativeSQL() << std::endl;
std::string str(msg); str += os.str();
throw StatementException(_stmt, str);
}
}
@@ -420,26 +422,28 @@ void ODBCStatementImpl::fillColumns()
}
bool ODBCStatementImpl::isStoredProcedure() const
{
std::string str = toString();
if (trimInPlace(str).size() < 2) return false;
bool ODBCStatementImpl::isStoredProcedure() const
{
std::string str = toString();
if (trimInPlace(str).size() < 2) return false;
return ('{' == str[0] && '}' == str[str.size()-1]);
return ('{' == str[0] && '}' == str[str.size()-1]);
}
const MetaColumn& ODBCStatementImpl::metaColumn(std::size_t pos) const
{
std::size_t curDataSet = currentDataSet();
poco_assert_dbg (curDataSet < _columnPtrs.size());
if (curDataSet < _columnPtrs.size())
{
std::size_t sz = _columnPtrs[curDataSet].size();
std::size_t sz = _columnPtrs[curDataSet].size();
if (0 == sz || pos > sz - 1)
throw InvalidAccessException(format("Invalid column number: %u", pos));
if (0 == sz || pos > sz - 1)
throw InvalidAccessException(format("Invalid column number: %u", pos));
return *_columnPtrs[curDataSet][pos];
return *_columnPtrs[curDataSet][pos];
}
else throw Poco::IllegalStateException("currentDataSet index out of range");
}
+5 -5
View File
@@ -23,14 +23,14 @@ namespace Data {
namespace ODBC {
Parameter::Parameter(const StatementHandle& rStmt, std::size_t colNum) :
_rStmt(rStmt),
Parameter::Parameter(const StatementHandle& rStmt, std::size_t colNum) :
_rStmt(rStmt),
_number(colNum)
{
init();
}
Parameter::~Parameter()
{
}
@@ -38,8 +38,8 @@ Parameter::~Parameter()
void Parameter::init()
{
if (Utility::isError(SQLDescribeParam(_rStmt,
(SQLUSMALLINT) _number + 1,
if (Utility::isError(SQLDescribeParam(_rStmt,
(SQLUSMALLINT) _number + 1,
&_dataType,
&_columnSize,
&_decimalDigits,
+19 -19
View File
@@ -31,7 +31,7 @@ SessionImpl::SessionImpl(const std::string& connect,
std::size_t loginTimeout,
std::size_t maxFieldSize,
bool autoBind,
bool autoExtract):
bool autoExtract):
Poco::Data::AbstractSessionImpl<SessionImpl>(connect, loginTimeout),
_connector(Connector::KEY),
_maxFieldSize(maxFieldSize),
@@ -49,7 +49,7 @@ SessionImpl::SessionImpl(const std::string& connect,
SessionImpl::SessionImpl(const std::string& connect,
Poco::Any maxFieldSize,
Poco::Any maxFieldSize,
bool enforceCapability,
bool autoBind,
bool autoExtract): Poco::Data::AbstractSessionImpl<SessionImpl>(connect),
@@ -136,20 +136,20 @@ void SessionImpl::open(const std::string& connect)
}
_dataTypes.fillTypeInfo(_db);
addProperty("dataTypeInfo",
&SessionImpl::setDataTypeInfo,
addProperty("dataTypeInfo",
&SessionImpl::setDataTypeInfo,
&SessionImpl::dataTypeInfo);
addFeature("autoCommit",
&SessionImpl::autoCommit,
addFeature("autoCommit",
&SessionImpl::autoCommit,
&SessionImpl::isAutoCommit);
addFeature("autoBind",
&SessionImpl::autoBind,
addFeature("autoBind",
&SessionImpl::autoBind,
&SessionImpl::isAutoBind);
addFeature("autoExtract",
&SessionImpl::autoExtract,
addFeature("autoExtract",
&SessionImpl::autoExtract,
&SessionImpl::isAutoExtract);
addProperty("maxFieldSize",
@@ -222,11 +222,11 @@ bool SessionImpl::canTransact() const
if (ODBC_TXN_CAPABILITY_UNKNOWN == _canTransact)
{
SQLUSMALLINT ret;
checkError(Poco::Data::ODBC::SQLGetInfo(_db, SQL_TXN_CAPABLE, &ret, 0, 0),
checkError(Poco::Data::ODBC::SQLGetInfo(_db, SQL_TXN_CAPABLE, &ret, 0, 0),
"Failed to obtain transaction capability info.");
_canTransact = (SQL_TC_NONE != ret) ?
ODBC_TXN_CAPABILITY_TRUE :
_canTransact = (SQL_TC_NONE != ret) ?
ODBC_TXN_CAPABILITY_TRUE :
ODBC_TXN_CAPABILITY_FALSE;
}
@@ -329,10 +329,10 @@ Poco::UInt32 SessionImpl::transactionIsolation(SQLULEN isolation)
void SessionImpl::autoCommit(const std::string&, bool val)
{
checkError(Poco::Data::ODBC::SQLSetConnectAttr(_db,
SQL_ATTR_AUTOCOMMIT,
val ? (SQLPOINTER) SQL_AUTOCOMMIT_ON :
(SQLPOINTER) SQL_AUTOCOMMIT_OFF,
checkError(Poco::Data::ODBC::SQLSetConnectAttr(_db,
SQL_ATTR_AUTOCOMMIT,
val ? (SQLPOINTER) SQL_AUTOCOMMIT_ON :
(SQLPOINTER) SQL_AUTOCOMMIT_OFF,
SQL_IS_UINTEGER), "Failed to set automatic commit.");
}
@@ -415,7 +415,7 @@ void SessionImpl::close()
{
commit();
}
catch (ConnectionException&)
catch (ConnectionException&)
{
}
@@ -433,7 +433,7 @@ int SessionImpl::maxStatementLength() const
0,
0)))
{
throw ConnectionException(_db,
throw ConnectionException(_db,
"SQLGetInfo(SQL_MAXIMUM_STATEMENT_LENGTH)");
}
+23 -23
View File
@@ -110,7 +110,7 @@ void TypeInfo::fillTypeInfo(SQLHDBC pHDBC)
char literalSuffix[stringSize] = { 0 };
char createParams[stringSize] = { 0 };
char localTypeName[stringSize] = { 0 };
TypeInfoTup ti("TYPE_NAME", "",
"DATA_TYPE", 0,
"COLUMN_SIZE", 0,
@@ -142,10 +142,10 @@ void TypeInfo::fillTypeInfo(SQLHDBC pHDBC)
ti.set<4>(literalSuffix);
rc = SQLGetData(hstmt, 6, SQL_C_CHAR, createParams, sizeof(createParams), &ind);
ti.set<5>(createParams);
rc = SQLGetData(hstmt, 7, SQL_C_SSHORT, &ti.get<6>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 8, SQL_C_SSHORT, &ti.get<7>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 9, SQL_C_SSHORT, &ti.get<8>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 10, SQL_C_SSHORT, &ti.get<9>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 7, SQL_C_SSHORT, &ti.get<6>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 8, SQL_C_SSHORT, &ti.get<7>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 9, SQL_C_SSHORT, &ti.get<8>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 10, SQL_C_SSHORT, &ti.get<9>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 11, SQL_C_SSHORT, &ti.get<10>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 12, SQL_C_SSHORT, &ti.get<11>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 13, SQL_C_CHAR, localTypeName, sizeof(localTypeName), &ind);
@@ -192,7 +192,7 @@ bool TypeInfo::tryGetInfo(SQLSMALLINT type, const std::string& param, DynamicAny
return true;
}
}
return false;
}
@@ -239,24 +239,24 @@ void TypeInfo::print(std::ostream& ostr)
for (; it != end; ++it)
{
ostr << it->get<0>() << "\t"
<< it->get<1>() << "\t"
<< it->get<2>() << "\t"
<< it->get<3>() << "\t"
<< it->get<4>() << "\t"
<< it->get<5>() << "\t"
<< it->get<6>() << "\t"
<< it->get<7>() << "\t"
<< it->get<8>() << "\t"
<< it->get<9>() << "\t"
<< it->get<10>() << "\t"
<< it->get<11>() << "\t"
<< it->get<12>() << "\t"
<< it->get<13>() << "\t"
ostr << it->get<0>() << "\t"
<< it->get<1>() << "\t"
<< it->get<2>() << "\t"
<< it->get<3>() << "\t"
<< it->get<4>() << "\t"
<< it->get<5>() << "\t"
<< it->get<6>() << "\t"
<< it->get<7>() << "\t"
<< it->get<8>() << "\t"
<< it->get<9>() << "\t"
<< it->get<10>() << "\t"
<< it->get<11>() << "\t"
<< it->get<12>() << "\t"
<< it->get<13>() << "\t"
<< it->get<14>() << "\t"
<< it->get<15>() << "\t"
<< it->get<16>() << "\t"
<< it->get<17>() << "\t"
<< it->get<15>() << "\t"
<< it->get<16>() << "\t"
<< it->get<17>() << "\t"
<< it->get<18>() << std::endl;
}
}
+18 -18
View File
@@ -38,7 +38,7 @@ namespace ODBC {
void makeUTF16(SQLCHAR* pSQLChar, SQLINTEGER length, std::string& target)
{
int len = length;
if (SQL_NTS == len)
if (SQL_NTS == len)
len = (int) std::strlen((const char *) pSQLChar);
UTF8Encoding utf8Encoding;
@@ -59,7 +59,7 @@ void makeUTF8(Poco::Buffer<SQLWCHAR>& buffer, SQLINTEGER length, SQLPOINTER pTar
std::string result;
if (0 != converter.convert(buffer.begin(), length, result))
throw DataFormatException("Error converting UTF-16 to UTF-8");
std::memset(pTarget, 0, targetLength);
std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength);
}
@@ -69,7 +69,7 @@ SQLRETURN SQLColAttribute(SQLHSTMT hstmt,
SQLUSMALLINT iCol,
SQLUSMALLINT iField,
SQLPOINTER pCharAttr,
SQLSMALLINT cbCharAttrMax,
SQLSMALLINT cbCharAttrMax,
SQLSMALLINT* pcbCharAttr,
NumAttrPtrType pNumAttr)
{
@@ -93,7 +93,7 @@ SQLRETURN SQLColAttribute(SQLHSTMT hstmt,
iCol,
iField,
pCharAttr,
cbCharAttrMax,
cbCharAttrMax,
pcbCharAttr,
pNumAttr);
}
@@ -133,8 +133,8 @@ SQLRETURN SQLConnect(SQLHDBC hdbc,
std::string sqlPWD;
makeUTF16(szAuthStr, cbAuthStr, sqlPWD);
return SQLConnectW(hdbc,
return SQLConnectW(hdbc,
(SQLWCHAR*) sqlDSN.c_str(), cbDSN,
(SQLWCHAR*) sqlUID.c_str(), cbUID,
(SQLWCHAR*) sqlPWD.c_str(), cbAuthStr);
@@ -211,7 +211,7 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC hdbc,
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
return rc;
}
return SQLGetConnectAttrW(hdbc,
fAttribute,
@@ -231,9 +231,9 @@ SQLRETURN SQLGetCursorName(SQLHSTMT hstmt,
SQLRETURN SQLSetDescField(SQLHDESC hdesc,
SQLSMALLINT iRecord,
SQLSMALLINT iRecord,
SQLSMALLINT iField,
SQLPOINTER rgbValue,
SQLPOINTER rgbValue,
SQLINTEGER cbValueMax)
{
if (isString(rgbValue, cbValueMax))
@@ -242,16 +242,16 @@ SQLRETURN SQLSetDescField(SQLHDESC hdesc,
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
return SQLSetDescFieldW(hdesc,
iRecord,
iRecord,
iField,
(SQLPOINTER) str.c_str(),
(SQLPOINTER) str.c_str(),
(SQLINTEGER) str.size() * sizeof(SQLWCHAR));
}
return SQLSetDescFieldW(hdesc,
iRecord,
iRecord,
iField,
rgbValue,
rgbValue,
cbValueMax);
}
@@ -296,7 +296,7 @@ SQLRETURN SQLGetDescRec(SQLHDESC hdesc,
SQLSMALLINT* pfType,
SQLSMALLINT* pfSubType,
SQLLEN* pLength,
SQLSMALLINT* pPrecision,
SQLSMALLINT* pPrecision,
SQLSMALLINT* pScale,
SQLSMALLINT* pNullable)
{
@@ -391,7 +391,7 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC hdbc,
return SQLSetConnectAttrW(hdbc,
fAttribute,
(SQLWCHAR*) str.c_str(),
(SQLWCHAR*) str.c_str(),
(SQLINTEGER) str.size() * sizeof(SQLWCHAR));
}
@@ -487,7 +487,7 @@ SQLRETURN SQLGetInfo(SQLHDBC hdbc,
pcbInfoValue);
makeUTF8(buffer, *pcbInfoValue, rgbInfoValue, cbInfoValueMax);
return rc;
}
@@ -590,12 +590,12 @@ SQLRETURN SQLDriverConnect(SQLHDBC hdbc,
SQLUSMALLINT fDriverCompletion)
{
SQLSMALLINT len = cbConnStrIn;
if (SQL_NTS == len)
if (SQL_NTS == len)
len = (SQLSMALLINT) std::strlen((const char*) szConnStrIn) + 1;
std::string connStrIn;
makeUTF16(szConnStrIn, len, connStrIn);
Buffer<SQLWCHAR> out(cbConnStrOutMax);
SQLRETURN rc = SQLDriverConnectW(hdbc,
hwnd,
+16 -16
View File
@@ -97,7 +97,7 @@ SQLRETURN SQLConnect(SQLHDBC hdbc,
std::wstring sqlPWD;
makeUTF16(szAuthStr, cbAuthStr, sqlPWD);
return SQLConnectW(hdbc,
(SQLWCHAR*) sqlDSN.c_str(),
(SQLSMALLINT) sqlDSN.size(),
@@ -155,8 +155,8 @@ SQLRETURN SQLExecDirect(SQLHSTMT hstmt,
std::wstring sqlStr;
makeUTF16(szSqlStr, cbSqlStr, sqlStr);
return SQLExecDirectW(hstmt,
(SQLWCHAR*) sqlStr.c_str(),
return SQLExecDirectW(hstmt,
(SQLWCHAR*) sqlStr.c_str(),
(SQLINTEGER) sqlStr.size());
}
@@ -180,7 +180,7 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC hdbc,
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
return rc;
}
return SQLGetConnectAttrW(hdbc,
fAttribute,
@@ -200,9 +200,9 @@ SQLRETURN SQLGetCursorName(SQLHSTMT hstmt,
SQLRETURN SQLSetDescField(SQLHDESC hdesc,
SQLSMALLINT iRecord,
SQLSMALLINT iRecord,
SQLSMALLINT iField,
SQLPOINTER rgbValue,
SQLPOINTER rgbValue,
SQLINTEGER cbValueMax)
{
if (isString(rgbValue, cbValueMax))
@@ -211,18 +211,18 @@ SQLRETURN SQLSetDescField(SQLHDESC hdesc,
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
SQLRETURN rc = SQLSetDescFieldW(hdesc,
iRecord,
iRecord,
iField,
(SQLPOINTER) str.c_str(),
(SQLPOINTER) str.c_str(),
(SQLINTEGER) str.size() * sizeof(std::wstring::value_type));
return rc;
}
return SQLSetDescFieldW(hdesc,
iRecord,
iRecord,
iField,
rgbValue,
rgbValue,
cbValueMax);
}
@@ -266,7 +266,7 @@ SQLRETURN SQLGetDescRec(SQLHDESC hdesc,
SQLSMALLINT* pfType,
SQLSMALLINT* pfSubType,
SQLLEN* pLength,
SQLSMALLINT* pPrecision,
SQLSMALLINT* pPrecision,
SQLSMALLINT* pScale,
SQLSMALLINT* pNullable)
{
@@ -344,8 +344,8 @@ SQLRETURN SQLPrepare(SQLHSTMT hstmt,
std::wstring sqlStr;
makeUTF16(szSqlStr, cbSqlStr, sqlStr);
return SQLPrepareW(hstmt,
(SQLWCHAR*) sqlStr.c_str(),
return SQLPrepareW(hstmt,
(SQLWCHAR*) sqlStr.c_str(),
(SQLINTEGER) sqlStr.size());
}
@@ -362,13 +362,13 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC hdbc,
return SQLSetConnectAttrW(hdbc,
fAttribute,
(SQLWCHAR*) str.c_str(),
(SQLWCHAR*) str.c_str(),
(SQLINTEGER) str.size() * sizeof(std::wstring::value_type));
}
return SQLSetConnectAttrW(hdbc,
fAttribute,
rgbValue,
rgbValue,
cbValue);
}
@@ -576,7 +576,7 @@ SQLRETURN SQLDriverConnect(SQLHDBC hdbc,
{
std::wstring connStrIn;
int len = cbConnStrIn;
if (SQL_NTS == len)
if (SQL_NTS == len)
len = (int) std::strlen((const char*) szConnStrIn);
Poco::UnicodeConverter::toUTF16((const char *) szConnStrIn, len, connStrIn);
+6 -6
View File
@@ -41,7 +41,7 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
SQLSMALLINT len2 = length;
RETCODE rc = 0;
if (!Utility::isError(rc = SQLDrivers(henv,
if (!Utility::isError(rc = SQLDrivers(henv,
SQL_FETCH_FIRST,
desc,
length,
@@ -52,12 +52,12 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
{
do
{
driverMap.insert(DSNMap::value_type(std::string((char *) desc),
driverMap.insert(DSNMap::value_type(std::string((char *) desc),
std::string((char *) attr)));
std::memset(desc, 0, length);
std::memset(attr, 0, length);
len2 = length;
}while (!Utility::isError(rc = SQLDrivers(henv,
}while (!Utility::isError(rc = SQLDrivers(henv,
SQL_FETCH_NEXT,
desc,
length,
@@ -67,7 +67,7 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
&len2)));
}
if (SQL_NO_DATA != rc)
if (SQL_NO_DATA != rc)
throw EnvironmentException(henv);
return driverMap;
@@ -88,7 +88,7 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
SQLSMALLINT len2 = length;
RETCODE rc = 0;
while (!Utility::isError(rc = Poco::Data::ODBC::SQLDataSources(henv,
while (!Utility::isError(rc = Poco::Data::ODBC::SQLDataSources(henv,
SQL_FETCH_NEXT,
dsn,
SQL_MAX_DSN_LENGTH,
@@ -103,7 +103,7 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
len2 = length;
}
if (SQL_NO_DATA != rc)
if (SQL_NO_DATA != rc)
throw EnvironmentException(henv);
return dsnMap;