diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2020-05-09 16:01:12 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2020-05-10 07:38:17 +0200 |
commit | 244e1823c41221d53b0dc7b6d9595514930f8cca (patch) | |
tree | e0e3c10a643b8cf847dcac2f3e8fc798b5f193ee /connectivity | |
parent | 300bded85303b1821226329d6b985c197e55c68f (diff) |
mysql-sdbc: better separate what resultset provides what interface
PreparedStatement should not provide XStatement (!!)
since MySQL does not support multiple results for prepared statements,
PreparedStatement should not expose a XMultipleResults interface
Move those out of the common base to Statement itself.
Change-Id: Ice7478089441e1def6fd65ff117eb31d04ec46ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93864
Tested-by: Jenkins
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Diffstat (limited to 'connectivity')
3 files changed, 40 insertions, 41 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.hxx b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.hxx index 3c4edaf411ac..0177b15dbd03 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.hxx @@ -93,11 +93,6 @@ public: sal_Bool SAL_CALL execute() override; Reference<css::sdbc::XConnection> SAL_CALL getConnection() override; - // XStatement - using OCommonStatement::execute; - using OCommonStatement::executeQuery; - using OCommonStatement::executeUpdate; - // XParameters void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType) override; diff --git a/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx index b7073be5e6ec..0082f96b61d1 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx @@ -88,6 +88,11 @@ Sequence<Type> SAL_CALL OCommonStatement::getTypes() return concatSequences(aTypes.getTypes(), OCommonStatement_IBase::getTypes()); } +Sequence<Type> SAL_CALL OStatement::getTypes() +{ + return concatSequences(OStatement_BASE::getTypes(), OCommonStatement::getTypes()); +} + void SAL_CALL OCommonStatement::cancel() { MutexGuard aGuard(m_aMutex); @@ -114,7 +119,7 @@ void SAL_CALL OCommonStatement::close() // mysqlc_sdbc_driver::throwFeatureNotImplementedException("com:sun:star:sdbc:XBatchExecution"); // } -sal_Bool SAL_CALL OCommonStatement::execute(const OUString& sql) +sal_Bool SAL_CALL OStatement::execute(const OUString& sql) { MutexGuard aGuard(m_aMutex); checkDisposed(rBHelper.bDisposed); @@ -139,7 +144,7 @@ sal_Bool SAL_CALL OCommonStatement::execute(const OUString& sql) return getResult(); } -Reference<XResultSet> SAL_CALL OCommonStatement::executeQuery(const OUString& sql) +Reference<XResultSet> SAL_CALL OStatement::executeQuery(const OUString& sql) { bool isRS(execute(sql)); // if a MySQL error occurred, it was already thrown and the below is not executed @@ -156,7 +161,7 @@ Reference<XResultSet> SAL_CALL OCommonStatement::executeQuery(const OUString& sq return m_xResultSet; } -Reference<XConnection> SAL_CALL OCommonStatement::getConnection() +Reference<XConnection> SAL_CALL OStatement::getConnection() { MutexGuard aGuard(m_aMutex); checkDisposed(rBHelper.bDisposed); @@ -165,14 +170,14 @@ Reference<XConnection> SAL_CALL OCommonStatement::getConnection() return m_xConnection.get(); } -sal_Int32 SAL_CALL OCommonStatement::getUpdateCount() { return m_nAffectedRows; } +sal_Int32 SAL_CALL OStatement::getUpdateCount() { return m_nAffectedRows; } Any SAL_CALL OStatement::queryInterface(const Type& rType) { - Any aRet = ::cppu::queryInterface(rType, static_cast<XServiceInfo*>(this)); + Any aRet = OCommonStatement::queryInterface(rType); if (!aRet.hasValue()) { - aRet = OCommonStatement::queryInterface(rType); + aRet = OStatement_BASE::queryInterface(rType); } return aRet; } @@ -193,7 +198,7 @@ Any SAL_CALL OStatement::queryInterface(const Type& rType) // mysqlc_sdbc_driver::throwFeatureNotImplementedException("com:sun:star:sdbc:XBatchExecution"); // } -sal_Int32 SAL_CALL OCommonStatement::executeUpdate(const OUString& sql) +sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql) { MutexGuard aGuard(m_aMutex); checkDisposed(rBHelper.bDisposed); @@ -202,7 +207,7 @@ sal_Int32 SAL_CALL OCommonStatement::executeUpdate(const OUString& sql) return m_nAffectedRows; } -Reference<XResultSet> SAL_CALL OCommonStatement::getResultSet() +Reference<XResultSet> SAL_CALL OStatement::getResultSet() { MutexGuard aGuard(m_aMutex); checkDisposed(rBHelper.bDisposed); @@ -210,7 +215,7 @@ Reference<XResultSet> SAL_CALL OCommonStatement::getResultSet() return m_xResultSet; } -sal_Bool OCommonStatement::getResult() +bool OStatement::getResult() { // all callers already reset that assert(!m_xResultSet.is()); @@ -245,7 +250,7 @@ sal_Bool OCommonStatement::getResult() return false; } -sal_Bool SAL_CALL OCommonStatement::getMoreResults() +sal_Bool SAL_CALL OStatement::getMoreResults() { MutexGuard aGuard(m_aMutex); checkDisposed(rBHelper.bDisposed); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx b/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx index d74e0a6456ce..4416ccceb150 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx @@ -32,7 +32,7 @@ #include <com/sun/star/sdbc/XWarningsSupplier.hpp> #include <com/sun/star/util/XCancellable.hpp> -#include <cppuhelper/compbase5.hxx> +#include <cppuhelper/compbase3.hxx> #include <rtl/ref.hxx> namespace connectivity @@ -43,10 +43,10 @@ using ::com::sun::star::sdbc::SQLException; using ::com::sun::star::sdbc::SQLWarning; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Type; -typedef ::cppu::WeakComponentImplHelper5<css::sdbc::XStatement, css::sdbc::XWarningsSupplier, - css::util::XCancellable, css::sdbc::XCloseable, - css::sdbc::XMultipleResults> +typedef ::cppu::WeakComponentImplHelper3<css::sdbc::XWarningsSupplier, css::util::XCancellable, + css::sdbc::XCloseable> OCommonStatement_IBase; //************ Class: OCommonStatement @@ -71,7 +71,6 @@ protected: protected: void closeResultSet(); - sal_Bool getResult(); // OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* createArrayHelper() const override; @@ -98,10 +97,7 @@ public: // XInterface void SAL_CALL release() throw() override; - void SAL_CALL acquire() throw() override; - - // XInterface Any SAL_CALL queryInterface(const css::uno::Type& rType) override; //XTypeProvider @@ -110,15 +106,6 @@ public: // XPropertySet css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; - // XStatement - css::uno::Reference<css::sdbc::XResultSet> SAL_CALL executeQuery(const OUString& sql) override; - - sal_Int32 SAL_CALL executeUpdate(const OUString& sql) override; - - sal_Bool SAL_CALL execute(const OUString& sql) override; - - css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() override; - // XWarningsSupplier Any SAL_CALL getWarnings() override; @@ -130,13 +117,6 @@ public: // XCloseable void SAL_CALL close() override; - // XMultipleResults - css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getResultSet() override; - - sal_Int32 SAL_CALL getUpdateCount() override; - - sal_Bool SAL_CALL getMoreResults() override; - // other methods OConnection* getOwnConnection() const { return m_xConnection.get(); } @@ -144,11 +124,16 @@ private: using ::cppu::OPropertySetHelper::getFastPropertyValue; }; -class OStatement final : public OCommonStatement, public css::lang::XServiceInfo +typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::sdbc::XMultipleResults, + css::sdbc::XStatement> + OStatement_BASE; +class OStatement final : public OCommonStatement, public OStatement_BASE { virtual ~OStatement() override = default; + bool getResult(); + public: // A constructor which is required for the return of the objects OStatement(OConnection* _pConnection) @@ -162,11 +147,25 @@ public: virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + //XInterface Any SAL_CALL queryInterface(const css::uno::Type& rType) override; - void SAL_CALL acquire() throw() override; void SAL_CALL release() throw() override; + //XTypeProvider + css::uno::Sequence<Type> SAL_CALL getTypes() override; + + // XStatement + css::uno::Reference<css::sdbc::XResultSet> SAL_CALL executeQuery(const OUString& sql) override; + sal_Int32 SAL_CALL executeUpdate(const OUString& sql) override; + sal_Bool SAL_CALL execute(const OUString& sql) override; + css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() override; + + // XMultipleResults + css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getResultSet() override; + sal_Int32 SAL_CALL getUpdateCount() override; + sal_Bool SAL_CALL getMoreResults() override; + // XBatchExecution // void SAL_CALL addBatch(const OUString& sql) override; |