summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx')
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx82
1 files changed, 41 insertions, 41 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
index 2b344843deb2..0c54630f25f2 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
@@ -23,6 +23,7 @@
#include "mysqlc_propertyids.hxx"
#include "mysqlc_resultsetmetadata.hxx"
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
@@ -31,8 +32,6 @@
using namespace connectivity::mysqlc;
using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::container;
using namespace com::sun::star::io;
@@ -41,12 +40,12 @@ using ::osl::MutexGuard;
OUString OPreparedStatement::getImplementationName()
{
- return "com.sun.star.sdbcx.mysqlc.PreparedStatement";
+ return u"com.sun.star.sdbcx.mysqlc.PreparedStatement"_ustr;
}
css::uno::Sequence<OUString> OPreparedStatement::getSupportedServiceNames()
{
- return { "com.sun.star.sdbc.PreparedStatement" };
+ return { u"com.sun.star.sdbc.PreparedStatement"_ustr };
}
sal_Bool OPreparedStatement::supportsService(OUString const& ServiceName)
@@ -73,9 +72,9 @@ OPreparedStatement::OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pS
OPreparedStatement::~OPreparedStatement() {}
-void SAL_CALL OPreparedStatement::acquire() throw() { OCommonStatement::acquire(); }
+void SAL_CALL OPreparedStatement::acquire() noexcept { OCommonStatement::acquire(); }
-void SAL_CALL OPreparedStatement::release() throw() { OCommonStatement::release(); }
+void SAL_CALL OPreparedStatement::release() noexcept { OCommonStatement::release(); }
Any SAL_CALL OPreparedStatement::queryInterface(const Type& rType)
{
@@ -95,7 +94,7 @@ Sequence<Type> SAL_CALL OPreparedStatement::getTypes()
Reference<XResultSetMetaData> SAL_CALL OPreparedStatement::getMetaData()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
if (!m_xMetaData.is())
{
@@ -109,7 +108,7 @@ Reference<XResultSetMetaData> SAL_CALL OPreparedStatement::getMetaData()
void SAL_CALL OPreparedStatement::close()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
if (mysql_stmt_close(m_pStmt))
{
@@ -124,7 +123,7 @@ void SAL_CALL OPreparedStatement::close()
sal_Bool SAL_CALL OPreparedStatement::execute()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
{
@@ -149,7 +148,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
sal_Int32 SAL_CALL OPreparedStatement::executeUpdate()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
{
@@ -176,7 +175,7 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate()
void SAL_CALL OPreparedStatement::setString(sal_Int32 parameter, const OUString& x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
OString stringie(OUStringToOString(x, m_xConnection->getConnectionEncoding()));
@@ -191,15 +190,15 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 parameter, const OUString&
Reference<XConnection> SAL_CALL OPreparedStatement::getConnection()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
- return m_xConnection.get();
+ return m_xConnection;
}
Reference<XResultSet> SAL_CALL OPreparedStatement::executeQuery()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
{
@@ -226,7 +225,7 @@ Reference<XResultSet> SAL_CALL OPreparedStatement::executeQuery()
void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 parameter, sal_Bool x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -238,7 +237,7 @@ void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 parameter, sal_Bool x)
void SAL_CALL OPreparedStatement::setByte(sal_Int32 parameter, sal_Int8 x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -250,7 +249,7 @@ void SAL_CALL OPreparedStatement::setByte(sal_Int32 parameter, sal_Int8 x)
void SAL_CALL OPreparedStatement::setDate(sal_Int32 parameter, const Date& aData)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
MYSQL_TIME my_time = {};
@@ -268,7 +267,7 @@ void SAL_CALL OPreparedStatement::setDate(sal_Int32 parameter, const Date& aData
void SAL_CALL OPreparedStatement::setTime(sal_Int32 parameter, const Time& aVal)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
MYSQL_TIME my_time = {};
@@ -286,7 +285,7 @@ void SAL_CALL OPreparedStatement::setTime(sal_Int32 parameter, const Time& aVal)
void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 parameter, const DateTime& aVal)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
MYSQL_TIME my_time = {};
@@ -307,7 +306,7 @@ void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 parameter, const DateTi
void SAL_CALL OPreparedStatement::setDouble(sal_Int32 parameter, double x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -319,7 +318,7 @@ void SAL_CALL OPreparedStatement::setDouble(sal_Int32 parameter, double x)
void SAL_CALL OPreparedStatement::setFloat(sal_Int32 parameter, float x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -331,7 +330,7 @@ void SAL_CALL OPreparedStatement::setFloat(sal_Int32 parameter, float x)
void SAL_CALL OPreparedStatement::setInt(sal_Int32 parameter, sal_Int32 x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -343,7 +342,7 @@ void SAL_CALL OPreparedStatement::setInt(sal_Int32 parameter, sal_Int32 x)
void SAL_CALL OPreparedStatement::setLong(sal_Int32 parameter, sal_Int64 aVal)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -355,7 +354,7 @@ void SAL_CALL OPreparedStatement::setLong(sal_Int32 parameter, sal_Int64 aVal)
void SAL_CALL OPreparedStatement::setNull(sal_Int32 parameter, sal_Int32 /*sqlType*/)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -367,7 +366,7 @@ void SAL_CALL OPreparedStatement::setNull(sal_Int32 parameter, sal_Int32 /*sqlTy
void SAL_CALL OPreparedStatement::setClob(sal_Int32 parameter, const Reference<XClob>& /* x */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setClob", *this);
@@ -376,7 +375,7 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 parameter, const Reference<X
void SAL_CALL OPreparedStatement::setBlob(sal_Int32 parameter, const Reference<XBlob>& /* x */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setBlob", *this);
@@ -385,7 +384,7 @@ void SAL_CALL OPreparedStatement::setBlob(sal_Int32 parameter, const Reference<X
void SAL_CALL OPreparedStatement::setArray(sal_Int32 parameter, const Reference<XArray>& /* x */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setArray", *this);
@@ -394,7 +393,7 @@ void SAL_CALL OPreparedStatement::setArray(sal_Int32 parameter, const Reference<
void SAL_CALL OPreparedStatement::setRef(sal_Int32 parameter, const Reference<XRef>& /* x */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setRef", *this);
@@ -403,7 +402,7 @@ void SAL_CALL OPreparedStatement::setRef(sal_Int32 parameter, const Reference<XR
void SAL_CALL OPreparedStatement::setObjectWithInfo(sal_Int32 parameterIndex, const Any& value,
sal_Int32 targetSqlType, sal_Int32 /* scale */)
{
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
MutexGuard aGuard(m_aMutex);
checkParameterIndex(parameterIndex);
@@ -432,7 +431,7 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo(sal_Int32 parameterIndex, co
{
OString sAscii
= OUStringToOString(sValue, getOwnConnection()->getConnectionEncoding());
- std::stringstream sStream{ sAscii.getStr() };
+ std::stringstream sStream{ std::string(sAscii) };
sStream >> nValue;
m_binds[nIndex].buffer_type = MYSQL_TYPE_DOUBLE;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &nValue, MYSQL_TYPE_DOUBLE,
@@ -457,7 +456,7 @@ void SAL_CALL OPreparedStatement::setObjectNull(sal_Int32 parameter, sal_Int32 /
const OUString& /* typeName */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setObjectNull",
@@ -467,7 +466,7 @@ void SAL_CALL OPreparedStatement::setObjectNull(sal_Int32 parameter, sal_Int32 /
void SAL_CALL OPreparedStatement::setObject(sal_Int32 parameter, const Any& /* x */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setObject", *this);
@@ -476,7 +475,7 @@ void SAL_CALL OPreparedStatement::setObject(sal_Int32 parameter, const Any& /* x
void SAL_CALL OPreparedStatement::setShort(sal_Int32 parameter, sal_Int16 x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
@@ -488,13 +487,14 @@ void SAL_CALL OPreparedStatement::setShort(sal_Int32 parameter, sal_Int16 x)
void SAL_CALL OPreparedStatement::setBytes(sal_Int32 parameter, const Sequence<sal_Int8>& x)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter - 1;
- m_binds[nIndex].buffer_type = MYSQL_TYPE_BLOB; // FIXME
- mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_BLOB);
+ m_binds[nIndex].buffer_type = MYSQL_TYPE_BLOB;
+ mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x[0], MYSQL_TYPE_BLOB, x.getLength());
m_bindMetas[nIndex].is_null = false;
+ m_bindMetas[nIndex].length = x.getLength();
}
void SAL_CALL OPreparedStatement::setCharacterStream(sal_Int32 parameter,
@@ -502,7 +502,7 @@ void SAL_CALL OPreparedStatement::setCharacterStream(sal_Int32 parameter,
sal_Int32 /* length */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException(
@@ -514,7 +514,7 @@ void SAL_CALL OPreparedStatement::setBinaryStream(sal_Int32 parameter,
sal_Int32 /* length */)
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setBinaryStream",
@@ -524,7 +524,7 @@ void SAL_CALL OPreparedStatement::setBinaryStream(sal_Int32 parameter,
void SAL_CALL OPreparedStatement::clearParameters()
{
MutexGuard aGuard(m_aMutex);
- checkDisposed(OPreparedStatement::rBHelper.bDisposed);
+ checkDisposed(rBHelper.bDisposed);
for (size_t i = 0; i < m_binds.size(); ++i)
{
@@ -569,9 +569,9 @@ void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, con
void OPreparedStatement::checkParameterIndex(sal_Int32 column)
{
- if (column < 1 || column > static_cast<sal_Int32>(m_paramCount))
+ if (column < 1 || o3tl::make_unsigned(column) > m_paramCount)
{
- throw SQLException("Parameter index out of range", *this, OUString(), 1, Any());
+ throw SQLException(u"Parameter index out of range"_ustr, *this, OUString(), 1, Any());
}
}