[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - dbaccess/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Oct 4 09:04:36 UTC 2018
dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 39 ++++++++++-------
1 file changed, 23 insertions(+), 16 deletions(-)
New commits:
commit f19cba204552ecb11b97c8047320733c498cf518
Author: Lionel Elie Mamane <lionel at mamane.lu>
AuthorDate: Sat Sep 15 07:19:28 2018 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Oct 4 11:04:09 2018 +0200
tdf#119569 try most likely to succeed method to get column metadata _before_
We first try to prepare the statement and get metadata
information. That's fine. Some DB engines/drivers will not give column
information on an unexectured prepared statement. In that case, first
try to execute the statement with all parameters set to NULL, which is
likely to succeed. If not, keep "execute the raw SQL indiscriminately"
as a last resort. I'm not sure it will ever be useful, though.
Change-Id: I76b5fd6b2059e96fabe9a611c8e3ed115acfc964
Reviewed-on: https://gerrit.libreoffice.org/60884
Tested-by: Jenkins
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
(cherry picked from commit 6bebb05bd4b338e1ed3dac2c02b8b4186dc79675)
Reviewed-on: https://gerrit.libreoffice.org/60885
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index e7a7af6870e9..c385c5fbbf37 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -789,29 +789,36 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( )
}
catch( const Exception& ) { }
- try
+ if ( !xResultSetMeta.is() && xPreparedStatement.is() )
{
- if ( !xResultSetMeta.is() )
+ try
{
- xStatement.reset( Reference< XStatement >( m_xConnection->createStatement(), UNO_QUERY_THROW ) );
- Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW );
- try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( false ) ); }
- catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); }
- xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW );
+ //@see issue http://qa.openoffice.org/issues/show_bug.cgi?id=110111
+ // access returns a different order of column names when executing select * from
+ // and asking the columns from the metadata.
+ Reference< XParameters > xParameters( xPreparedStatement, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xPara = getParameters();
+ for(sal_Int32 i = 1;i <= xPara->getCount();++i)
+ xParameters->setNull(i,DataType::VARCHAR);
+ xResMetaDataSup.set(xPreparedStatement->executeQuery(), UNO_QUERY_THROW );
xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW );
}
+ catch( const Exception& ) { }
}
- catch( const Exception& )
+
+ if ( !xResultSetMeta.is() )
{
- //@see issue http://qa.openoffice.org/issues/show_bug.cgi?id=110111
- // access returns a different order of column names when executing select * from
- // and asking the columns from the metadata.
- Reference< XParameters > xParameters( xPreparedStatement, UNO_QUERY_THROW );
- Reference< XIndexAccess > xPara = getParameters();
- for(sal_Int32 i = 1;i <= xPara->getCount();++i)
- xParameters->setNull(i,DataType::VARCHAR);
- xResMetaDataSup.set(xPreparedStatement->executeQuery(), UNO_QUERY_THROW );
+ xStatement.reset( Reference< XStatement >( m_xConnection->createStatement(), UNO_QUERY_THROW ) );
+ Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW );
+ try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( false ) ); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); }
+ xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW );
xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW );
+
+ if (xResultSetMeta.is())
+ {
+ SAL_WARN("dbaccess", "OSingleSelectQueryComposer::getColumns failed to get xResultSetMeta from executed PreparedStatement, but got it from 'no escape processing' statement. SQL command:\n\t" << sSQL );
+ }
}
if ( aSelectColumns->get().empty() )
More information about the Libreoffice-commits
mailing list