Sun Studio ODBC compile fixes

This commit is contained in:
Aleksandar Fabijanic 2008-05-30 19:00:11 +00:00
parent fafec95355
commit 4fe33a7c49
11 changed files with 49 additions and 50 deletions

View File

@ -82,8 +82,8 @@ public:
explicit Diagnostics(H& rHandle): _rHandle(rHandle) explicit Diagnostics(H& rHandle): _rHandle(rHandle)
/// Creates and initializes the Diagnostics. /// Creates and initializes the Diagnostics.
{ {
memset(_connectionName, 0, sizeof(_connectionName)); std::memset(_connectionName, 0, sizeof(_connectionName));
memset(_serverName, 0, sizeof(_serverName)); std::memset(_serverName, 0, sizeof(_serverName));
diagnostics(); diagnostics();
} }
@ -192,13 +192,13 @@ public:
{ {
std::size_t len = sizeof(_connectionName) > none.length() ? std::size_t len = sizeof(_connectionName) > none.length() ?
none.length() : sizeof(_connectionName) - 1; none.length() : sizeof(_connectionName) - 1;
memcpy(_connectionName, none.c_str(), len); std::memcpy(_connectionName, none.c_str(), len);
} }
else if (0 == _connectionName[0]) else if (0 == _connectionName[0])
{ {
std::size_t len = sizeof(_connectionName) > na.length() ? std::size_t len = sizeof(_connectionName) > na.length() ?
na.length() : sizeof(_connectionName) - 1; na.length() : sizeof(_connectionName) - 1;
memcpy(_connectionName, na.c_str(), len); std::memcpy(_connectionName, na.c_str(), len);
} }
if (Utility::isError(SQLGetDiagField(handleType, if (Utility::isError(SQLGetDiagField(handleType,
@ -211,20 +211,20 @@ public:
{ {
std::size_t len = sizeof(_serverName) > none.length() ? std::size_t len = sizeof(_serverName) > none.length() ?
none.length() : sizeof(_serverName) - 1; none.length() : sizeof(_serverName) - 1;
memcpy(_serverName, none.c_str(), len); std::memcpy(_serverName, none.c_str(), len);
} }
else if (0 == _serverName[0]) else if (0 == _serverName[0])
{ {
std::size_t len = sizeof(_serverName) > na.length() ? std::size_t len = sizeof(_serverName) > na.length() ?
na.length() : sizeof(_serverName) - 1; na.length() : sizeof(_serverName) - 1;
memcpy(_serverName, na.c_str(), len); std::memcpy(_serverName, na.c_str(), len);
} }
} }
_fields.push_back(df); _fields.push_back(df);
memset(df._sqlState, 0, SQL_STATE_SIZE); std::memset(df._sqlState, 0, SQL_STATE_SIZE);
memset(df._message, 0, SQL_MESSAGE_LENGTH); std::memset(df._message, 0, SQL_MESSAGE_LENGTH);
df._nativeError = 0; df._nativeError = 0;
++count; ++count;

View File

@ -403,7 +403,7 @@ void Binder::synchronize()
StringMap::iterator it = _strings.begin(); StringMap::iterator it = _strings.begin();
StringMap::iterator end = _strings.end(); StringMap::iterator end = _strings.end();
for(; it != end; ++it) for(; it != end; ++it)
it->second->assign(it->first, strlen(it->first)); it->second->assign(it->first, std::strlen(it->first));
} }
} }
@ -519,8 +519,8 @@ void Binder::setParamSetSize(std::size_t length)
{ {
if (0 == _paramSetSize) if (0 == _paramSetSize)
{ {
if (Utility::isError(SQLSetStmtAttr(_rStmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, SQL_IS_UINTEGER)) || if (Utility::isError(Poco::Data::ODBC::SQLSetStmtAttr(_rStmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, SQL_IS_UINTEGER)) ||
Utility::isError(SQLSetStmtAttr(_rStmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) length, SQL_IS_UINTEGER))) Utility::isError(Poco::Data::ODBC::SQLSetStmtAttr(_rStmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) length, SQL_IS_UINTEGER)))
throw StatementException(_rStmt, "SQLSetStmtAttr()"); throw StatementException(_rStmt, "SQLSetStmtAttr()");
_paramSetSize = static_cast<SQLINTEGER>(length); _paramSetSize = static_cast<SQLINTEGER>(length);

View File

@ -74,7 +74,7 @@ bool Extractor::extractBoundImpl<std::string>(std::size_t pos, std::string& val)
std::size_t dataSize = _rPreparation.actualDataSize(pos); std::size_t dataSize = _rPreparation.actualDataSize(pos);
char* sp = AnyCast<char*>(_rPreparation[pos]); char* sp = AnyCast<char*>(_rPreparation[pos]);
std::size_t len = strlen(sp); std::size_t len = std::strlen(sp);
if (len < dataSize) dataSize = len; if (len < dataSize) dataSize = len;
checkDataSize(dataSize); checkDataSize(dataSize);
val.assign(sp, dataSize); val.assign(sp, dataSize);
@ -377,7 +377,7 @@ bool Extractor::extractManualImpl<std::string>(std::size_t pos, std::string& val
do do
{ {
memset(pChar, 0, CHUNK_SIZE); std::memset(pChar, 0, CHUNK_SIZE);
len = 0; len = 0;
rc = SQLGetData(_rStmt, rc = SQLGetData(_rStmt,
(SQLUSMALLINT) pos + 1, (SQLUSMALLINT) pos + 1,
@ -433,7 +433,7 @@ bool Extractor::extractManualImpl<Poco::Data::BLOB>(std::size_t pos,
do do
{ {
memset(pChar, 0, CHUNK_SIZE); std::memset(pChar, 0, CHUNK_SIZE);
len = 0; len = 0;
rc = SQLGetData(_rStmt, rc = SQLGetData(_rStmt,
(SQLUSMALLINT) pos + 1, (SQLUSMALLINT) pos + 1,

View File

@ -58,14 +58,14 @@ ODBCMetaColumn::~ODBCMetaColumn()
void ODBCMetaColumn::getDescription() void ODBCMetaColumn::getDescription()
{ {
memset(_columnDesc.name, 0, NAME_BUFFER_LENGTH); std::memset(_columnDesc.name, 0, NAME_BUFFER_LENGTH);
_columnDesc.nameBufferLength = 0; _columnDesc.nameBufferLength = 0;
_columnDesc.dataType = 0; _columnDesc.dataType = 0;
_columnDesc.size = 0; _columnDesc.size = 0;
_columnDesc.decimalDigits = 0; _columnDesc.decimalDigits = 0;
_columnDesc.isNullable = 0; _columnDesc.isNullable = 0;
if (Utility::isError(SQLDescribeCol(_rStmt, if (Utility::isError(Poco::Data::ODBC::SQLDescribeCol(_rStmt,
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based (SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
_columnDesc.name, _columnDesc.name,
NAME_BUFFER_LENGTH, NAME_BUFFER_LENGTH,
@ -84,7 +84,7 @@ void ODBCMetaColumn::init()
{ {
getDescription(); getDescription();
if (Utility::isError(SQLColAttribute(_rStmt, if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt,
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based (SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
SQL_DESC_LENGTH, SQL_DESC_LENGTH,
0, 0,

View File

@ -181,7 +181,7 @@ void ODBCStatementImpl::doPrepare()
Poco::UInt32 limit = getExtractionLimit(); Poco::UInt32 limit = getExtractionLimit();
if (limit == Limit::LIMIT_UNLIMITED) if (limit == Limit::LIMIT_UNLIMITED)
throw InvalidArgumentException("Bulk operation not allowed without limit."); throw InvalidArgumentException("Bulk operation not allowed without limit.");
checkError(SQLSetStmtAttr(_stmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) limit, 0), checkError(Poco::Data::ODBC::SQLSetStmtAttr(_stmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) limit, 0),
"SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)"); "SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)");
} }
@ -386,7 +386,7 @@ std::string ODBCStatementImpl::nativeSQL()
{ {
delete [] pNative; delete [] pNative;
pNative = new char[retlen]; pNative = new char[retlen];
memset(pNative, 0, retlen); std::memset(pNative, 0, retlen);
length = retlen; length = retlen;
if (Utility::isError(SQLNativeSql(_rConnection, if (Utility::isError(SQLNativeSql(_rConnection,
(SQLCHAR*) statement.c_str(), (SQLCHAR*) statement.c_str(),

View File

@ -52,7 +52,7 @@ Preparation::Preparation(const StatementHandle& rStmt,
_dataExtraction(dataExtraction) _dataExtraction(dataExtraction)
{ {
SQLCHAR* pStr = (SQLCHAR*) statement.c_str(); SQLCHAR* pStr = (SQLCHAR*) statement.c_str();
if (Utility::isError(SQLPrepare(_rStmt, pStr, (SQLINTEGER) statement.length()))) if (Utility::isError(Poco::Data::ODBC::SQLPrepare(_rStmt, pStr, (SQLINTEGER) statement.length())))
throw StatementException(_rStmt); throw StatementException(_rStmt);
} }

View File

@ -85,7 +85,7 @@ void SessionImpl::open()
SQLCHAR connectOutput[512] = {0}; SQLCHAR connectOutput[512] = {0};
SQLSMALLINT result; SQLSMALLINT result;
if (Utility::isError(SQLDriverConnect(_db if (Utility::isError(Poco::Data::ODBC::SQLDriverConnect(_db
, NULL , NULL
,(SQLCHAR*) _connect.c_str() ,(SQLCHAR*) _connect.c_str()
,(SQLSMALLINT) SQL_NTS ,(SQLSMALLINT) SQL_NTS
@ -120,7 +120,7 @@ void SessionImpl::open()
&SessionImpl::setMaxFieldSize, &SessionImpl::setMaxFieldSize,
&SessionImpl::getMaxFieldSize); &SessionImpl::getMaxFieldSize);
SQLSetConnectAttr(_db, SQL_ATTR_QUIET_MODE, 0, 0); Poco::Data::ODBC::SQLSetConnectAttr(_db, SQL_ATTR_QUIET_MODE, 0, 0);
if (!canTransact()) autoCommit("", true); if (!canTransact()) autoCommit("", true);
} }
@ -129,7 +129,7 @@ void SessionImpl::open()
bool SessionImpl::canTransact() bool SessionImpl::canTransact()
{ {
SQLUSMALLINT ret; SQLUSMALLINT ret;
checkError(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."); "Failed to obtain transaction capability info.");
return (SQL_TC_NONE != ret); return (SQL_TC_NONE != ret);
@ -138,7 +138,7 @@ bool SessionImpl::canTransact()
void SessionImpl::autoCommit(const std::string&, bool val) void SessionImpl::autoCommit(const std::string&, bool val)
{ {
checkError(SQLSetConnectAttr(_db, checkError(Poco::Data::ODBC::SQLSetConnectAttr(_db,
SQL_ATTR_AUTOCOMMIT, SQL_ATTR_AUTOCOMMIT,
val ? (SQLPOINTER) SQL_AUTOCOMMIT_ON : val ? (SQLPOINTER) SQL_AUTOCOMMIT_ON :
(SQLPOINTER) SQL_AUTOCOMMIT_OFF, (SQLPOINTER) SQL_AUTOCOMMIT_OFF,
@ -150,7 +150,7 @@ bool SessionImpl::isAutoCommit(const std::string&)
{ {
Poco::UInt32 value = 0; Poco::UInt32 value = 0;
checkError(SQLGetConnectAttr(_db, checkError(Poco::Data::ODBC::SQLGetConnectAttr(_db,
SQL_ATTR_AUTOCOMMIT, SQL_ATTR_AUTOCOMMIT,
&value, &value,
0, 0,
@ -164,7 +164,7 @@ bool SessionImpl::isConnected()
{ {
Poco::UInt32 value = 0; Poco::UInt32 value = 0;
if (Utility::isError(SQLGetConnectAttr(_db, if (Utility::isError(Poco::Data::ODBC::SQLGetConnectAttr(_db,
SQL_ATTR_CONNECTION_DEAD, SQL_ATTR_CONNECTION_DEAD,
&value, &value,
0, 0,
@ -179,7 +179,7 @@ bool SessionImpl::isTransaction()
{ {
Poco::UInt32 value = 0; Poco::UInt32 value = 0;
checkError(SQLGetConnectAttr(_db, checkError(Poco::Data::ODBC::SQLGetConnectAttr(_db,
SQL_ATTR_AUTOCOMMIT, SQL_ATTR_AUTOCOMMIT,
&value, &value,
0, 0,
@ -206,7 +206,7 @@ int SessionImpl::maxStatementLength()
{ {
SQLUINTEGER info; SQLUINTEGER info;
SQLRETURN rc = 0; SQLRETURN rc = 0;
if (Utility::isError(rc = SQLGetInfo(_db, if (Utility::isError(rc = Poco::Data::ODBC::SQLGetInfo(_db,
SQL_MAXIMUM_STATEMENT_LENGTH, SQL_MAXIMUM_STATEMENT_LENGTH,
(SQLPOINTER) &info, (SQLPOINTER) &info,
0, 0,

View File

@ -56,14 +56,14 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
const int length = sizeof(SQLCHAR) * 512; const int length = sizeof(SQLCHAR) * 512;
SQLCHAR desc[length]; SQLCHAR desc[length];
memset(desc, 0, length); std::memset(desc, 0, length);
SQLSMALLINT len1 = length; SQLSMALLINT len1 = length;
SQLCHAR attr[length]; SQLCHAR attr[length];
memset(attr, 0, length); std::memset(attr, 0, length);
SQLSMALLINT len2 = length; SQLSMALLINT len2 = length;
RETCODE rc = 0; RETCODE rc = 0;
while (!Utility::isError(rc = SQLDrivers(henv, while (!Utility::isError(rc = Poco::Data::ODBC::SQLDrivers(henv,
SQL_FETCH_NEXT, SQL_FETCH_NEXT,
desc, desc,
length, length,
@ -74,8 +74,8 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
{ {
driverMap.insert(DSNMap::value_type(std::string((char *) desc), driverMap.insert(DSNMap::value_type(std::string((char *) desc),
std::string((char *) attr))); std::string((char *) attr)));
memset(desc, 0, length); std::memset(desc, 0, length);
memset(attr, 0, length); std::memset(attr, 0, length);
len2 = length; len2 = length;
} }
@ -93,14 +93,14 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
const int dsnLength = sizeof(SQLCHAR) * (SQL_MAX_DSN_LENGTH + 1); const int dsnLength = sizeof(SQLCHAR) * (SQL_MAX_DSN_LENGTH + 1);
SQLCHAR dsn[dsnLength]; SQLCHAR dsn[dsnLength];
memset(dsn, 0, dsnLength); std::memset(dsn, 0, dsnLength);
SQLSMALLINT len1 = sizeof(SQLCHAR) * SQL_MAX_DSN_LENGTH; SQLSMALLINT len1 = sizeof(SQLCHAR) * SQL_MAX_DSN_LENGTH;
SQLCHAR desc[length]; SQLCHAR desc[length];
memset(desc, 0, length); std::memset(desc, 0, length);
SQLSMALLINT len2 = length; SQLSMALLINT len2 = length;
RETCODE rc = 0; RETCODE rc = 0;
while (!Utility::isError(rc = SQLDataSources(henv, while (!Utility::isError(rc = Poco::Data::ODBC::SQLDataSources(henv,
SQL_FETCH_NEXT, SQL_FETCH_NEXT,
dsn, dsn,
SQL_MAX_DSN_LENGTH, SQL_MAX_DSN_LENGTH,
@ -110,8 +110,8 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
&len2))) &len2)))
{ {
dsnMap.insert(DSNMap::value_type(std::string((char *) dsn), std::string((char *) desc))); dsnMap.insert(DSNMap::value_type(std::string((char *) dsn), std::string((char *) desc)));
memset(dsn, 0, dsnLength); std::memset(dsn, 0, dsnLength);
memset(desc, 0, length); std::memset(desc, 0, length);
len2 = length; len2 = length;
} }
@ -125,7 +125,7 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
void Utility::dateTimeSync(Poco::DateTime& dt, const SQL_TIMESTAMP_STRUCT& ts) void Utility::dateTimeSync(Poco::DateTime& dt, const SQL_TIMESTAMP_STRUCT& ts)
{ {
double msec = ts.fraction/1000000; double msec = ts.fraction/1000000;
double usec = 1000 * (msec - floor(msec)); double usec = 1000 * (msec - std::floor(msec));
dt.assign(ts.year, dt.assign(ts.year,
ts.month, ts.month,
@ -133,8 +133,8 @@ void Utility::dateTimeSync(Poco::DateTime& dt, const SQL_TIMESTAMP_STRUCT& ts)
ts.hour, ts.hour,
ts.minute, ts.minute,
ts.second, ts.second,
(int) floor(msec), (int) std::floor(msec),
(int) floor(usec)); (int) std::floor(usec));
} }

View File

@ -467,7 +467,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
SQLLEN lengths[6] = { 0 }; SQLLEN lengths[6] = { 0 };
fourth = 0; fourth = 0;
fifth = 0.0f; fifth = 0.0f;
memset(&sixth, 0, sizeof(sixth)); std::memset(&sixth, 0, sizeof(sixth));
if (SQLExecutor::DE_BOUND == extractMode) if (SQLExecutor::DE_BOUND == extractMode)
{ {
@ -594,9 +594,9 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
} }
assert (0 == strncmp(str[0].c_str(), chr[0], str[0].size())); assert (0 == std::strncmp(str[0].c_str(), chr[0], str[0].size()));
assert (0 == strncmp(str[1].c_str(), chr[1], str[1].size())); assert (0 == std::strncmp(str[1].c_str(), chr[1], str[1].size()));
assert (0 == strncmp(str[2].c_str(), chr[2], str[2].size())); assert (0 == std::strncmp(str[2].c_str(), chr[2], str[2].size()));
assert (4 == fourth); assert (4 == fourth);
assert (1.5 == fifth); assert (1.5 == fifth);

View File

@ -91,15 +91,14 @@ inline Poco::UInt32 Bulk::size() const
namespace Keywords { namespace Keywords {
template <typename T> inline Bulk bulk(const Limit& limit = Limit(Limit::LIMIT_UNLIMITED, false, false))
inline Bulk bulk(const T& limit)
/// Convenience function for creation of bulk. /// Convenience function for creation of bulk.
{ {
return Bulk(limit); return Bulk(limit);
} }
inline void bulk(char) inline void bulk()
/// Dummy bulk function. Used for bulk binding creation /// Dummy bulk function. Used for bulk binding creation
/// (see BulkBinding) and bulk extraction signalling to Statement. /// (see BulkBinding) and bulk extraction signalling to Statement.
{ {
@ -109,7 +108,7 @@ inline void bulk(char)
} // namespace Keywords } // namespace Keywords
typedef void (*BulkFnType)(char); typedef void (*BulkFnType)();
} } // namespace Poco::Data } } // namespace Poco::Data

View File

@ -56,7 +56,7 @@ public:
LIMIT_UNLIMITED = 0xffffffffu LIMIT_UNLIMITED = 0xffffffffu
}; };
Limit(Poco::UInt32 value, bool hardLimit, bool isLowerLimit); Limit(Poco::UInt32 value, bool hardLimit = false, bool isLowerLimit = false);
/// Creates the Limit. /// Creates the Limit.
/// ///
/// Value contains the upper row hint, if hardLimit is set to true, the limit acts as a hard /// Value contains the upper row hint, if hardLimit is set to true, the limit acts as a hard