[Libreoffice-commits] core.git: 2 commits - connectivity/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Dec 18 21:25:10 UTC 2018
connectivity/source/drivers/postgresql/pq_preparedstatement.cxx | 12 ++++---
connectivity/source/drivers/postgresql/pq_statement.cxx | 17 +++++++---
2 files changed, 21 insertions(+), 8 deletions(-)
New commits:
commit aa41e17e809a5398974b3b5f53a41c6632df284c
Author: Lionel Elie Mamane <lionel at mamane.lu>
AuthorDate: Tue Dec 18 22:12:06 2018 +0100
Commit: Lionel Elie Mamane <lionel at mamane.lu>
CommitDate: Tue Dec 18 22:18:12 2018 +0100
postgresql: any execute should close previous ResultSet
not only executeQuery.
Change-Id: I2ee72078c48f622484dba46436f53990a45da364
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
index a976d7e3dfc4..3f721bf7f1ab 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
@@ -278,10 +278,6 @@ void PreparedStatement::raiseSQLException( const char * errorMsg )
Reference< XResultSet > PreparedStatement::executeQuery( )
{
- Reference< XCloseable > lastResultSet = m_lastResultset;
- if( lastResultSet.is() )
- lastResultSet->close();
-
if( ! execute( ) )
{
raiseSQLException( "not a query" );
@@ -357,6 +353,10 @@ sal_Bool PreparedStatement::execute( )
m_executedStatement = buf.makeStringAndClear();
+ Reference< XCloseable > lastResultSet = m_lastResultset;
+ if( lastResultSet.is() )
+ lastResultSet->close();
+
m_lastResultset.clear();
m_lastTableInserted.clear();
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx
index a95a48674607..471bded3330c 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -235,10 +235,6 @@ void Statement::raiseSQLException(
Reference< XResultSet > Statement::executeQuery(const OUString& sql )
{
- Reference< XCloseable > lastResultSetHolder = m_lastResultset;
- if( lastResultSetHolder.is() )
- lastResultSetHolder->close();
-
if( ! execute( sql ) )
{
raiseSQLException( sql, "not a query" );
@@ -805,6 +801,10 @@ sal_Bool Statement::execute( const OUString& sql )
checkClosed();
OString cmd = OUStringToOString( sql, m_pSettings );
+ Reference< XCloseable > lastResultSetHolder = m_lastResultset;
+ if( lastResultSetHolder.is() )
+ lastResultSetHolder->close();
+
m_lastResultset.clear();
m_lastTableInserted.clear();
commit a9d4f2bebda3380a3b6843f9df1204c9b062b3a8
Author: Lionel Elie Mamane <lionel at mamane.lu>
AuthorDate: Tue Dec 18 22:04:18 2018 +0100
Commit: Lionel Elie Mamane <lionel at mamane.lu>
CommitDate: Tue Dec 18 22:18:12 2018 +0100
postgresql: correctly implement XMultipleResults interface
note that we implement it in a very limited way, since we will always
return only a single result.
Change-Id: Idc7927d1a6896b78f6de8627ba857982821ac629
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
index 865222cbcc83..a976d7e3dfc4 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
@@ -741,6 +741,10 @@ sal_Int32 PreparedStatement::getUpdateCount( )
}
sal_Bool PreparedStatement::getMoreResults( )
{
+ Reference< XCloseable > lastResultSet = m_lastResultset;
+ if( lastResultSet.is() )
+ lastResultSet->close();
+ m_multipleResultUpdateCount = -1;
return false;
}
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx
index db99a20910b0..a95a48674607 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -936,6 +936,15 @@ sal_Int32 Statement::getUpdateCount( )
sal_Bool Statement::getMoreResults( )
{
+ // The PostgreSQL C interface always returns a single result,
+ // so we will never have multiple ones.
+ // Implicitly close the open resultset (if any) as per spec,
+ // and setup to signal "no more result, neither as resultset,
+ // nor as update count".
+ Reference< XCloseable > lastResultSetHolder = m_lastResultset;
+ if( lastResultSetHolder.is() )
+ lastResultSetHolder->close();
+ m_multipleResultUpdateCount = -1;
return false;
}
More information about the Libreoffice-commits
mailing list