[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mork/DriverTest.cxx | 10 +++--- connectivity/source/drivers/firebird/Catalog.cxx |4 +--- connectivity/source/drivers/hsqldb/HConnection.cxx | 13 + 3 files changed, 9 insertions(+), 18 deletions(-) New commits: commit 4209a4781071e778224c78fda498d09b3580448d Author: Stephan Bergmann AuthorDate: Tue Jun 2 21:46:59 2020 +0200 Commit: Stephan Bergmann CommitDate: Wed Jun 3 09:18:32 2020 +0200 Upcoming loplugin:elidestringvar: connectivity Change-Id: I406486e13b822c34cd2329cc3828dd0567be30e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95385 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx index e2f28494..bea76fd028dc 100644 --- a/connectivity/qa/connectivity/mork/DriverTest.cxx +++ b/connectivity/qa/connectivity/mork/DriverTest.cxx @@ -107,12 +107,10 @@ void MorkDriverTest::test_metadata() } const Any catalog; -const OUString schemaPattern = "%"; -const OUString tableNamePattern = "%"; const Sequence< OUString > types; Reference< XResultSet > xResultSet = -xDatabaseMetaData->getTables(catalog, schemaPattern, tableNamePattern, types); +xDatabaseMetaData->getTables(catalog, "%", "%", types); if (!xResultSet.is()) { CPPUNIT_ASSERT_MESSAGE("cannot retrieve tables!", xResultSet.is()); @@ -124,8 +122,7 @@ void MorkDriverTest::test_metadata() void MorkDriverTest::test_select_default_all() { -const OUString sql = "select \"E-mail\" from \"AddressBook\" ORDER BY \"E-mail\""; -Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql); +Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement("select \"E-mail\" from \"AddressBook\" ORDER BY \"E-mail\""); if (!xStatement.is()) { CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); @@ -164,8 +161,7 @@ void MorkDriverTest::test_select_default_all() void MorkDriverTest::test_select_list_table_joe_doe_5() { -const OUString sql = "select \"E-mail\" from \"does_5\" where \"E-mail\" LIKE '%doe5.org' "; -Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql); +Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement("select \"E-mail\" from \"does_5\" where \"E-mail\" LIKE '%doe5.org' "); if (!xStatement.is()) { CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); diff --git a/connectivity/source/drivers/firebird/Catalog.cxx b/connectivity/source/drivers/firebird/Catalog.cxx index f5969f31ce63..47fedab60d59 100644 --- a/connectivity/source/drivers/firebird/Catalog.cxx +++ b/connectivity/source/drivers/firebird/Catalog.cxx @@ -68,10 +68,8 @@ void Catalog::refreshGroups() //- IRefreshableUsers void Catalog::refreshUsers() { -OUString const sSql("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES"); - Reference xStmt= m_xMetaData->getConnection()->createStatement(); -uno::Reference< XResultSet > xUsers = xStmt->executeQuery(sSql); +uno::Reference< XResultSet > xUsers = xStmt->executeQuery("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES"); if (!xUsers.is()) return; diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx index b6cbc1e4879c..c3ff0169cea7 100644 --- a/connectivity/source/drivers/hsqldb/HConnection.cxx +++ b/connectivity/source/drivers/hsqldb/HConnection.cxx @@ -314,17 +314,14 @@ namespace connectivity::hsqldb if ( m_xContext.is() ) xProvider.set( GraphicProvider::create(m_xContext) ); -// assemble the image URL -OUString sImageURL = -// load the graphic from the global graphic repository -"private:graphicrepository/" -// the relative path within the images.zip -LINKED_TEXT_TABLE_IMAGE_RESOURCE; - // ask the provider to obtain a graphic Sequence< PropertyValue > aMediaProperties( 1 ); aMediaProperties[0].Name = "URL"; -aMediaProperties[0].Value <<= sImageURL; +aMediaProperties[0].Value <<= OUString( +// load the graphic from the global graphic repository +"private:graphicrepository/" +// the relative path within the images.zip +LINKED_TEXT_TABLE_IMAGE_RESOURCE); xGraphic = xProvider->queryGraphic( aMediaProperties ); OSL_ENSURE( xGraphic.is(), "OHsqlConnection::impl_getTextTableIcon_nothrow: the provider did not give us a graphic object!" ); } ___ Libreoffice-commits mailing list libreoffice-comm...@list
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/commontools/FValue_test.cxx |4 +- connectivity/qa/connectivity/mork/DriverTest.cxx |4 +- connectivity/source/commontools/paramwrapper.cxx |6 +-- connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx |5 --- connectivity/source/drivers/evoab2/NResultSet.cxx |4 +- connectivity/source/drivers/evoab2/NStatement.cxx |4 +- connectivity/source/drivers/file/FStatement.cxx|8 + connectivity/source/drivers/firebird/Driver.cxx| 12 +-- connectivity/source/drivers/hsqldb/HConnection.cxx |4 +- connectivity/source/drivers/hsqldb/HStorageMap.cxx | 10 +- connectivity/source/drivers/hsqldb/HTools.cxx |4 +- connectivity/source/drivers/hsqldb/HView.cxx |4 +- connectivity/source/drivers/jdbc/ConnectionLog.cxx |8 ++--- connectivity/source/drivers/jdbc/ContextClassLoader.cxx|4 +- connectivity/source/drivers/mork/MConnection.cxx |4 +- connectivity/source/drivers/mork/MDatabaseMetaData.cxx |5 --- connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx |5 --- connectivity/source/drivers/mysql_jdbc/YTable.cxx |5 --- connectivity/source/drivers/mysqlc/mysqlc_driver.cxx |5 --- connectivity/source/drivers/odbc/ORealDriver.cxx |5 --- connectivity/source/drivers/writer/WCatalog.cxx|5 --- connectivity/source/drivers/writer/WConnection.cxx |5 --- connectivity/source/drivers/writer/WDatabaseMetaData.cxx |5 --- connectivity/source/drivers/writer/WDriver.cxx |5 --- connectivity/source/drivers/writer/WTable.cxx | 16 +- connectivity/source/drivers/writer/WTables.cxx |5 --- connectivity/source/sdbcx/VDescriptor.cxx |5 --- 27 files changed, 45 insertions(+), 111 deletions(-) New commits: commit b43f64f430bc19c07f6b5d457a9168de5fb9de69 Author: Noel Grandin AuthorDate: Wed Jan 15 08:45:55 2020 +0200 Commit: Noel Grandin CommitDate: Wed Jan 15 08:43:46 2020 +0100 clang-tidy modernize-concat-nested-namespace in connectivity Change-Id: Id18966cc44c012730a872ebfa93f2b468cefff38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86823 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/connectivity/qa/connectivity/commontools/FValue_test.cxx b/connectivity/qa/connectivity/commontools/FValue_test.cxx index 036fbbc3ca5f..b6f0e36588ad 100644 --- a/connectivity/qa/connectivity/commontools/FValue_test.cxx +++ b/connectivity/qa/connectivity/commontools/FValue_test.cxx @@ -24,7 +24,7 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; -namespace connectivity { namespace commontools { +namespace connectivity::commontools { class FValueTest: public test::BootstrapFixture { @@ -359,7 +359,7 @@ void FValueTest::test_bool_creation() CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest); -}} +} CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx index 1ce3b981a238..e2f28494 100644 --- a/connectivity/qa/connectivity/mork/DriverTest.cxx +++ b/connectivity/qa/connectivity/mork/DriverTest.cxx @@ -16,7 +16,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; -namespace connectivity { namespace mork { +namespace connectivity::mork { class MorkDriverTest: public test::BootstrapFixture @@ -194,6 +194,6 @@ void MorkDriverTest::test_select_list_table_joe_doe_5() CPPUNIT_TEST_SUITE_REGISTRATION(MorkDriverTest); -}} +} CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx index 92c78e319276..e56cf9e24f01 100644 --- a/connectivity/source/commontools/paramwrapper.cxx +++ b/connectivity/source/commontools/paramwrapper.cxx @@ -33,9 +33,7 @@ #define PROPERTY_ID_VALUE 1000 -namespace dbtools -{ -namespace param +namespace dbtools::param { @@ -349,7 +347,7 @@ namespace param } -} } // namespace dbtools::param +} // namespace dbtools::param /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 85673db40afe..6045b0f3123c 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -44,9 +44,7 @@ namespace } } -namespace connectivity -{ -namespace evoab +namespace conne
[Libreoffice-commits] core.git: connectivity/qa connectivity/source connectivity/workben include/connectivity
connectivity/qa/connectivity/resource/sharedresources_test.cxx|8 ++--- connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx|2 - connectivity/source/commontools/RowFunctionParser.cxx |2 - connectivity/source/commontools/dbmetadata.cxx|4 +- connectivity/source/commontools/dbtools2.cxx |4 +- connectivity/source/commontools/sqlerror.cxx |2 - connectivity/source/commontools/warningscontainer.cxx |2 - connectivity/source/cpool/Zregistration.cxx |2 - connectivity/source/drivers/ado/AColumn.cxx |2 - connectivity/source/drivers/ado/Aservices.cxx |4 +- connectivity/source/drivers/calc/Cservices.cxx|4 +- connectivity/source/drivers/dbase/DTable.cxx | 10 +++--- connectivity/source/drivers/dbase/Dservices.cxx |4 +- connectivity/source/drivers/evoab2/NServices.cxx |4 +- connectivity/source/drivers/file/FStringFunctions.cxx |4 +- connectivity/source/drivers/firebird/Clob.cxx |6 +-- connectivity/source/drivers/firebird/Services.cxx |4 +- connectivity/source/drivers/flat/Eservices.cxx|4 +- connectivity/source/drivers/hsqldb/HDriver.cxx|8 ++--- connectivity/source/drivers/hsqldb/Hservices.cxx |4 +- connectivity/source/drivers/hsqldb/accesslog.cxx |4 +- connectivity/source/drivers/hsqldb/accesslog.hxx | 12 +++ connectivity/source/drivers/jdbc/DatabaseMetaData.cxx |8 ++--- connectivity/source/drivers/jdbc/jservices.cxx|4 +- connectivity/source/drivers/macab/MacabDriver.cxx |2 - connectivity/source/drivers/macab/MacabServices.cxx |4 +- connectivity/source/drivers/mork/MColumnAlias.cxx |2 - connectivity/source/drivers/mork/MColumnAlias.hxx |2 - connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx |2 - connectivity/source/drivers/mysql_jdbc/Yservices.cxx |2 - connectivity/source/drivers/mysqlc/mysqlc_general.cxx |4 +- connectivity/source/drivers/mysqlc/mysqlc_general.hxx |5 +-- connectivity/source/drivers/mysqlc/mysqlc_services.cxx|4 +- connectivity/source/drivers/odbc/oservices.cxx|4 +- connectivity/source/drivers/postgresql/pq_connection.cxx |2 - connectivity/source/drivers/postgresql/pq_driver.cxx |2 - connectivity/source/drivers/postgresql/pq_statics.cxx |8 ++--- connectivity/source/drivers/postgresql/pq_updateableresultset.cxx |2 - connectivity/source/drivers/writer/Wservices.cxx |4 +- connectivity/source/inc/resource/sharedresources.hxx | 14 connectivity/source/manager/mregistration.cxx |2 - connectivity/source/parse/internalnode.cxx|2 - connectivity/source/parse/sqlbison.y |6 +-- connectivity/source/parse/sqlflex.l | 14 connectivity/source/parse/sqliterator.cxx |2 - connectivity/source/parse/sqlnode.cxx |2 - connectivity/source/resource/sharedresources.cxx | 16 +- connectivity/workben/iniParser/main.cxx |2 - include/connectivity/dbtools.hxx |4 +- include/connectivity/internalnode.hxx |2 - include/connectivity/sqlnode.hxx |2 - include/connectivity/sqlparse.hxx |2 - include/connectivity/warningscontainer.hxx|2 - 53 files changed, 116 insertions(+), 117 deletions(-) New commits: commit 386bb99bf666c341af51df11ce11fa8d7d95a8ed Author: Noel Grandin AuthorDate: Wed Dec 18 13:34:12 2019 +0200 Commit: Noel Grandin CommitDate: Wed Dec 18 20:38:03 2019 +0100 sal_Char->char in connectivity Change-Id: Ie32cbef9b03d69044c401f79bc737cde6dd0ed5d Reviewed-on: https://gerrit.libreoffice.org/85396 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/connectivity/qa/connectivity/resource/sharedresources_test.cxx b/connectivity/qa/connectivity/resource/sharedresources_test.cxx index 2ef68eca8be8..a6bf22fba858 100644 --- a/connectivity/qa/connectivity/resource/sharedresources_test.cxx +++ b/connectivity/qa/connectivity/resource/sharedresources_test.cxx @@ -88,10 +88,10 @@ void SharedResourcesTest::testGetSourceStringWithSubstitutionThree() void SharedResourc
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx | 41 ++ connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx | 164 +- connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx |7 3 files changed, 130 insertions(+), 82 deletions(-) New commits: commit 41d3be4a48ea2abe019cd4f9b51bef703a2dc454 Author: Tamas Bunth AuthorDate: Mon Jul 29 13:27:38 2019 +0200 Commit: Tamás Bunth CommitDate: Mon Jul 29 22:33:38 2019 +0200 mysqlc: Fix query of cursor position in result set Fix queries like "IsAfterLast" in result sets of prepared statements in the mysql driver. Cursor position is stored in the driver, since the mysql C driver does not support the query of the cursor position. The cursor position works the following way: - 0 means the cursor is on "BeforeFirst". In that state calling of getXXX() methods is user error. - 1 means the first row is already fetched. - n means the last fow is fetched, where n is the total number of rows in the result set. - Everything bigger than n is "AfterLast" Change-Id: I131f2042606897019cc0f868dbc4151faf4850ac Reviewed-on: https://gerrit.libreoffice.org/76549 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index 3e48ce5b3750..24af725b0110 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -54,6 +54,7 @@ public: void testDBMetaData(); void testTimestampField(); void testNumericConversionPrepared(); +void testPreparedStmtIsAfterLast(); CPPUNIT_TEST_SUITE(MysqlTestDriver); CPPUNIT_TEST(testDBConnection); @@ -63,6 +64,7 @@ public: CPPUNIT_TEST(testDBMetaData); CPPUNIT_TEST(testTimestampField); CPPUNIT_TEST(testNumericConversionPrepared); +CPPUNIT_TEST(testPreparedStmtIsAfterLast); CPPUNIT_TEST_SUITE_END(); }; @@ -405,6 +407,45 @@ void MysqlTestDriver::testNumericConversionPrepared() xStatement->executeUpdate("DROP TABLE myTestTable"); } +/** + * Test cursor positioning method isAfterLast in case of using prepared + * statement. + */ +void MysqlTestDriver::testPreparedStmtIsAfterLast() +{ +Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); +if (!xConnection.is()) +CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); +uno::Reference xStatement = xConnection->createStatement(); +CPPUNIT_ASSERT(xStatement.is()); +xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + +// create test table +xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); +Reference xPrepared += xConnection->prepareStatement(OUString{ "INSERT INTO myTestTable VALUES (?)" }); +Reference xParams(xPrepared, UNO_QUERY); +constexpr int ROW_COUNT = 6; +for (int i = 0; i < ROW_COUNT; ++i) +{ +xParams->setShort(1, i); +xPrepared->executeUpdate(); +} + +// query test table +xPrepared = xConnection->prepareStatement("SELECT id from myTestTable where id = 3"); +Reference xResultSet = xPrepared->executeQuery(); + +// There should be exactly one row, therefore IsAfterLast is false at first. +xResultSet->next(); +CPPUNIT_ASSERT(!xResultSet->isAfterLast()); + +// attempt to fetch more data +bool hasData = xResultSet->next(); +CPPUNIT_ASSERT(!hasData); // now we are on "AfterLast" +CPPUNIT_ASSERT(xResultSet->isAfterLast()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(MysqlTestDriver); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index ae573a6d8fbc..7d2c5276d142 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -100,6 +100,62 @@ const std::type_index getTypeFromMysqlType(enum_field_types type) } } +bool OPreparedResultSet::fetchResult() +{ +// allocate array if it does not exist +if (m_aData == nullptr) +{ +m_aData.reset(new MYSQL_BIND[m_nColumnCount]); +memset(m_aData.get(), 0, m_nColumnCount * sizeof(MYSQL_BIND)); +m_aMetaData.reset(new BindMetaData[m_nColumnCount]); +} +for (sal_Int32 i = 0; i < m_nColumnCount; ++i) +{ +m_aMetaData[i].is_null = 0; +m_aMetaData[i].length = 0l; +m_aMetaData[i].error = 0; + +m_aData[i].is_null = &m_aMetaData[i].is_null; +m_aData[i].buffer_length = m_aFields[i].type == MYSQL_TYPE_BLOB ? 0 : m_aFields[i].length; +m_aData[i].length = &m_aMetaData[i].length; +m_aData[i].error = &m_aMetaData[i].error; +m_aData[i].buffer = nullptr; +m_aData[i].buffer_type = m_aFields[i].type; + +/
[Libreoffice-commits] core.git: connectivity/qa connectivity/source dbaccess/source extensions/source forms/source include/connectivity include/IwyuFilter_include.yaml reportdesign/source svx/source s
connectivity/qa/connectivity/mork/DriverTest.cxx|1 connectivity/source/commontools/BlobHelper.cxx |1 connectivity/source/commontools/ConnectionWrapper.cxx |2 connectivity/source/commontools/FValue.cxx |5 connectivity/source/commontools/TIndexes.cxx|3 connectivity/source/commontools/TKeyColumns.cxx |1 connectivity/source/commontools/TKeys.cxx |3 connectivity/source/commontools/TTableHelper.cxx|5 connectivity/source/commontools/conncleanup.cxx |2 connectivity/source/commontools/dbtools.cxx |1 connectivity/source/commontools/dbtools2.cxx|1 connectivity/source/commontools/formattedcolumnvalue.cxx|2 connectivity/source/commontools/parameters.cxx |3 connectivity/source/commontools/paramwrapper.cxx|1 connectivity/source/commontools/predicateinput.cxx |1 connectivity/source/commontools/sqlerror.cxx|1 connectivity/source/commontools/statementcomposer.cxx |3 connectivity/source/commontools/warningscontainer.cxx |3 connectivity/source/drivers/calc/CTable.cxx |1 connectivity/source/drivers/component/CResultSet.cxx|1 connectivity/source/drivers/dbase/DIndex.cxx|1 connectivity/source/drivers/dbase/DResultSet.cxx|1 connectivity/source/drivers/dbase/DTable.cxx|1 connectivity/source/drivers/evoab2/NColumns.cxx |1 connectivity/source/drivers/evoab2/NTable.cxx |2 connectivity/source/drivers/file/FDateFunctions.cxx |1 connectivity/source/drivers/firebird/Catalog.cxx|2 connectivity/source/drivers/firebird/Table.cxx |1 connectivity/source/drivers/flat/EResultSet.cxx |1 connectivity/source/drivers/flat/ETable.cxx |2 connectivity/source/drivers/hsqldb/HTable.cxx |1 connectivity/source/drivers/hsqldb/HView.cxx|1 connectivity/source/drivers/macab/MacabCatalog.cxx |1 connectivity/source/drivers/macab/MacabColumns.cxx |1 connectivity/source/drivers/macab/MacabTable.cxx|1 connectivity/source/drivers/macab/MacabTables.cxx |1 connectivity/source/drivers/mork/MCatalog.cxx |2 connectivity/source/drivers/mork/MColumns.cxx |1 connectivity/source/drivers/mork/MDriver.cxx|1 connectivity/source/drivers/mork/MResultSet.cxx |2 connectivity/source/drivers/mork/MStatement.cxx |1 connectivity/source/drivers/mork/MStatement.hxx |1 connectivity/source/drivers/mork/MTables.cxx|2 connectivity/source/drivers/mysql_jdbc/YTable.cxx |1 connectivity/source/drivers/postgresql/pq_resultset.cxx |1 connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx |2 connectivity/source/drivers/writer/WTable.cxx |1 connectivity/source/inc/TKeyValue.hxx |1 connectivity/source/inc/hsqldb/HView.hxx|1 connectivity/source/parse/PColumn.cxx |3 connectivity/source/sdbcx/VCatalog.cxx |2 connectivity/source/sdbcx/VCollection.cxx |1 connectivity/source/sdbcx/VColumn.cxx |1 connectivity/source/sdbcx/VDescriptor.cxx |2 connectivity/source/sdbcx/VIndex.cxx|1 connectivity/source/sdbcx/VIndexColumn.cxx |1 connectivity/source/sdbcx/VKey.cxx |1 connectivity/source/sdbcx/VKeyColumn.cxx|1 connectivity/source/sdbcx/VTable.cxx|1 connectivity/source/sdbcx/VView.cxx |1 dbaccess/source/core/api/CacheSet.cxx |1 dbaccess/source/core/api/FilteredContainer.cxx |1 dbaccess/source/core/api/TableDeco.cxx |1 dbaccess/source/core/api/column.cxx |2 dbaccess/source/core/api/preparedstatement.cxx |1 dbaccess/source/core/api/query.cxx |1 dbaccess/source/core/api/resultcolumn.cxx |1 dbaccess/source/core/api/resultcolumn.hxx |1 dbaccess/source/core/api/resultset
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx| 36 connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx | 11 +++- connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx |2 3 files changed, 44 insertions(+), 5 deletions(-) New commits: commit 76491860113d60965cd234770afcef747fe4bd65 Author: Tamas Bunth AuthorDate: Tue Jan 29 13:00:21 2019 +0100 Commit: Tamás Bunth CommitDate: Tue Jan 29 18:07:08 2019 +0100 mysqlc: fix timestamp query of result set Also add test for inserting and reading timestamp values. Change-Id: I2ba997c438f4e33965b0fe0602e58eddeff38b01 Reviewed-on: https://gerrit.libreoffice.org/67066 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index bfefeec132c1..1cbe34790421 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -20,6 +20,8 @@ #include #include #include + +#include #include #include @@ -50,6 +52,7 @@ public: void testDBPositionChange(); void testMultipleResultsets(); void testDBMetaData(); +void testTimestampField(); CPPUNIT_TEST_SUITE(MysqlTestDriver); CPPUNIT_TEST(testDBConnection); @@ -57,6 +60,7 @@ public: CPPUNIT_TEST(testIntegerInsertAndQuery); CPPUNIT_TEST(testMultipleResultsets); CPPUNIT_TEST(testDBMetaData); +CPPUNIT_TEST(testTimestampField); CPPUNIT_TEST_SUITE_END(); }; @@ -337,6 +341,38 @@ void MysqlTestDriver::testDBMetaData() nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); } +void MysqlTestDriver::testTimestampField() +{ +Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); +if (!xConnection.is()) +CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); +uno::Reference xStatement = xConnection->createStatement(); +CPPUNIT_ASSERT(xStatement.is()); +xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + +xStatement->executeUpdate( +"CREATE TABLE myTestTable (id INTEGER PRIMARY KEY, mytimestamp timestamp)"); +xStatement->executeUpdate("INSERT INTO myTestTable VALUES (1, '2008-02-16 20:15:03')"); + +// now let's query +Reference xResultSet += xStatement->executeQuery("SELECT mytimestamp from myTestTable"); + +xResultSet->next(); // use it +Reference xRow(xResultSet, UNO_QUERY); +CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xRow.is()); +util::DateTime dt = xRow->getTimestamp(1); +CPPUNIT_ASSERT_EQUAL(static_cast(2008), dt.Year); +CPPUNIT_ASSERT_EQUAL(static_cast(2), dt.Month); +CPPUNIT_ASSERT_EQUAL(static_cast(16), dt.Day); + +CPPUNIT_ASSERT_EQUAL(static_cast(20), dt.Hours); +CPPUNIT_ASSERT_EQUAL(static_cast(15), dt.Minutes); +CPPUNIT_ASSERT_EQUAL(static_cast(3), dt.Seconds); + +xStatement->executeUpdate("DROP TABLE myTestTable"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(MysqlTestDriver); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index c8a5f387bc95..05d5c1321604 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -236,7 +236,7 @@ uno::Reference SAL_CALL OResultSet::getBinaryStream(sal_Int32 colu OString sVal = m_aRows[m_nRowPosition][column - 1]; return new SequenceInputStream{ uno::Sequence( -reinterpret_cast(sVal.getStr()), getDataLength(column - 1)) }; +reinterpret_cast(sVal.getStr()), getDataLength(column)) }; } uno::Reference SAL_CALL OResultSet::getCharacterStream(sal_Int32 column) @@ -284,7 +284,7 @@ uno::Sequence SAL_CALL OResultSet::getBytes(sal_Int32 column) return uno::Sequence(); return uno::Sequence(reinterpret_cast(sVal.getStr()), - getDataLength(column - 1)); + getDataLength(column)); } Date SAL_CALL OResultSet::getDate(sal_Int32 column) @@ -476,7 +476,7 @@ Time SAL_CALL OResultSet::getTime(sal_Int32 column) return t; OString sVal = m_aRows[m_nRowPosition][column - 1]; -OString timeString{ sVal.getStr(), getDataLength(column - 1) }; +OString timeString{ sVal.getStr(), getDataLength(column) }; OString token; sal_Int32 nIndex, i = 0; @@ -515,11 +515,14 @@ DateTime SAL_CALL OResultSet::getTimestamp(sal_Int32 column) // YY-MM-DD HH:MM:SS std::vector dateAndTime -= lcl_split(OString{ sVal.getStr(), getDataLength(column - 1) }, ' '); += lcl_split(OString{ sVal.getStr(), getDataLength(column) }, ' '); auto dateParts = lcl_split(dateAndTime.at(0), '-'); auto timeParts = lcl_split(dateAndTime.at(1), ':'); +if (dateParts.size() < 2 || timeParts.size() < 2) +thro
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx|6 ++ connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx |9 - 2 files changed, 14 insertions(+), 1 deletion(-) New commits: commit 6e80862ee6851b75fc7fa628156400bb044391ee Author: Tamas Bunth AuthorDate: Tue Jan 22 13:06:45 2019 +0100 Commit: Tamás Bunth CommitDate: Tue Jan 22 17:43:41 2019 +0100 mysqlc: resultset's previous() on first position.. .. should move the cursor backwards to beforeFirst position and return false. Change-Id: Icbb4bed0ea39ea3a0bf375d5616e3ef768fc69d9 Reviewed-on: https://gerrit.libreoffice.org/66729 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index 0d1d9ef85145..bfefeec132c1 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -256,6 +256,12 @@ void MysqlTestDriver::testDBPositionChange() xResultSet->first(); CPPUNIT_ASSERT_EQUAL(1, xResultSet->getRow()); +// Now previous should put the cursor to before-first position, but it +// should return with false. +successPrevious = xResultSet->previous(); +CPPUNIT_ASSERT(!successPrevious); +CPPUNIT_ASSERT_EQUAL(0, xResultSet->getRow()); + nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement } diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index f8d3f8f01e29..c8a5f387bc95 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -652,8 +652,15 @@ sal_Bool SAL_CALL OResultSet::previous() MutexGuard aGuard(m_aMutex); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); -if (m_nRowPosition <= 0) +if (m_nRowPosition == 0) +{ +m_nRowPosition--; return false; +} +else if (m_nRowPosition < 0) +{ +return false; +} m_nRowPosition--; return true; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx| 42 connectivity/source/drivers/mysqlc/mysqlc_general.cxx | 18 + connectivity/source/drivers/mysqlc/mysqlc_general.hxx |4 connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx | 99 +- connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.hxx | 29 +- 5 files changed, 124 insertions(+), 68 deletions(-) New commits: commit ee33372f6406d7352bc7e19914ec5fb0059c4e01 Author: Tamas Bunth AuthorDate: Sat Dec 29 15:22:56 2018 +0100 Commit: Tamás Bunth CommitDate: Fri Jan 4 17:37:26 2019 +0100 mysqlc: Fix result set metadata related issue In order to allow fetching result of multiple result sets at time same time, all the data is fetched and copied on demand from the mysql result set. The mysql result set (MYSQL_RES) is freed afterwards. That means we need a copy of the meta information as well. Now all the meta data is stored in the driver for each result set, so it does not depend on the MYSQL_RES structure anymore. Also add test case for invoking some meta data queries before and after fetching the result set. Change-Id: Ie8bf993926ebe89cd362ab0b311d1f3d164b84df Reviewed-on: https://gerrit.libreoffice.org/65717 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index f93885fb34d9..0d1d9ef85145 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -13,7 +13,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -46,12 +49,14 @@ public: void testIntegerInsertAndQuery(); void testDBPositionChange(); void testMultipleResultsets(); +void testDBMetaData(); CPPUNIT_TEST_SUITE(MysqlTestDriver); CPPUNIT_TEST(testDBConnection); CPPUNIT_TEST(testCreateAndDropTable); CPPUNIT_TEST(testIntegerInsertAndQuery); CPPUNIT_TEST(testMultipleResultsets); +CPPUNIT_TEST(testDBMetaData); CPPUNIT_TEST_SUITE_END(); }; @@ -289,6 +294,43 @@ void MysqlTestDriver::testMultipleResultsets() xStatement->executeUpdate("DROP TABLE otherTable"); } +void MysqlTestDriver::testDBMetaData() +{ +Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); +if (!xConnection.is()) +CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); +uno::Reference xStatement = xConnection->createStatement(); +CPPUNIT_ASSERT(xStatement.is()); +xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + +auto nUpdateCount = xStatement->executeUpdate( +"CREATE TABLE myTestTable (id INTEGER PRIMARY KEY, name VARCHAR(20))"); +Reference xPrepared += xConnection->prepareStatement(OUString{ "INSERT INTO myTestTable VALUES (?, ?)" }); +Reference xParams(xPrepared, UNO_QUERY); +constexpr int ROW_COUNT = 3; +for (int i = 0; i < ROW_COUNT; ++i) +{ +xParams->setLong(1, i); +xParams->setString(2, "lorem"); +xPrepared->executeUpdate(); +} + +Reference xResultSet = xStatement->executeQuery("SELECT * from myTestTable"); +Reference xMetaDataSupplier(xResultSet, UNO_QUERY); +Reference xMetaData = xMetaDataSupplier->getMetaData(); +CPPUNIT_ASSERT_EQUAL(OUString{ "id" }, xMetaData->getColumnName(1)); +CPPUNIT_ASSERT_EQUAL(OUString{ "name" }, xMetaData->getColumnName(2)); +CPPUNIT_ASSERT(!xMetaData->isAutoIncrement(1)); +CPPUNIT_ASSERT(!xMetaData->isCaseSensitive(2)); // default collation should be case insensitive +xResultSet->next(); // use it +// test that meta data is usable even after fetching result set +CPPUNIT_ASSERT_EQUAL(OUString{ "name" }, xMetaData->getColumnName(2)); +CPPUNIT_ASSERT_THROW_MESSAGE("exception expected when indexing out of range", + xMetaData->getColumnName(3), sdbc::SQLException); +nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(MysqlTestDriver); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx index aa0b0a9e4e5a..5827b4bd35b9 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx @@ -225,11 +225,13 @@ sal_Int32 mysqlStrToOOOType(const OUString& sType) return css::sdbc::DataType::VARCHAR; } -OUString mysqlTypeToStr(MYSQL_FIELD* field) +OUString mysqlTypeToStr(MYSQL_FIELD* field) { return mysqlTypeToStr(field->type, field->flags); } + +OUString mysqlTypeToStr(unsigned type, unsigned flags) { -bool isUnsigned = (field->flags & UNSIGNED_FLAG) != 0; -bool isZerofill = (field->flags & ZEROFILL_FLAG) != 0; -switch
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx|2 + connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx | 29 +++- connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx |4 +- 3 files changed, 24 insertions(+), 11 deletions(-) New commits: commit 44416a16f40167cf9a60ff6fc7990a07df4e7d7b Author: Tamas Bunth AuthorDate: Mon Dec 10 10:43:14 2018 +0100 Commit: Tamás Bunth CommitDate: Fri Dec 14 11:19:58 2018 +0100 mysqlc: Fix obtaining field information in rs Result set field information should be stored correctly. It is queried from database on demand and stored locally. Change-Id: Ia62c62e6db32b45640b9fcd5f48c6249aecc41a2 Reviewed-on: https://gerrit.libreoffice.org/64861 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index ee502ed286b7..f93885fb34d9 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -182,6 +182,7 @@ void MysqlTestDriver::testIntegerInsertAndQuery() Reference xResultSet = xStatement->executeQuery("SELECT id from myTestTable"); CPPUNIT_ASSERT_MESSAGE("result set cannot be instantiated after query", xResultSet.is()); Reference xRow(xResultSet, UNO_QUERY); +Reference xColumnLocate(xResultSet, UNO_QUERY); CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xRow.is()); for (long i = 0; i < ROW_COUNT; ++i) @@ -189,6 +190,7 @@ void MysqlTestDriver::testIntegerInsertAndQuery() bool hasRow = xResultSet->next(); CPPUNIT_ASSERT_MESSAGE("not enough result after query", hasRow); CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(1)); // first and only column +CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(xColumnLocate->findColumn("id"))); // test findColumn } CPPUNIT_ASSERT_MESSAGE("Cursor is not on last position.", xResultSet->isLast()); // cursor is on last position diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index 5ee7aa943206..d6c2a9b724b4 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -134,6 +134,18 @@ void OResultSet::ensureResultFetched() } } +void OResultSet::ensureFieldInfoFetched() +{ +if (!m_aFields.empty()) +return; +unsigned nFieldCount = mysql_num_fields(m_pResult); +MYSQL_FIELD* pFields = mysql_fetch_fields(m_pResult); +m_aFields.reserve(nFieldCount); +for (unsigned i = 0; i < nFieldCount; ++i) +m_aFields.push_back(OUString{ +pFields[i].name, static_cast(strlen(pFields[i].name)), m_encoding }); +} + void OResultSet::fetchResult() { // Mysql C API does not allow simultaneously opened result sets, but sdbc does. @@ -143,20 +155,18 @@ void OResultSet::fetchResult() // TODO ensure that m_nRowCount = mysql_num_rows(m_pResult); +ensureFieldInfoFetched(); + // fetch all the data m_aRows.reserve(m_nRowCount); -m_nFieldCount = mysql_num_fields(m_pResult); -MYSQL_FIELD* pFields = mysql_fetch_fields(m_pResult); -m_aFields.assign(pFields, pFields + m_nFieldCount); - for (sal_Int32 row = 0; row < m_nRowCount; ++row) { MYSQL_ROW data = mysql_fetch_row(m_pResult); unsigned long* lengths = mysql_fetch_lengths(m_pResult); m_aRows.push_back(DataFields{}); // MYSQL_ROW is char**, array of strings -for (unsigned col = 0; col < m_nFieldCount; ++col) +for (std::size_t col = 0; col < m_aFields.size(); ++col) { m_aRows.back().push_back(OString{ data[col], static_cast(lengths[col]) }); } @@ -202,11 +212,12 @@ sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& columnName) { MutexGuard aGuard(m_aMutex); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); +ensureFieldInfoFetched(); -for (unsigned int i = 0; i < m_nFieldCount; ++i) +for (std::size_t i = 0; i < m_aFields.size(); ++i) { -if (columnName.equalsIgnoreAsciiCaseAscii(m_aFields[i].name)) -return i + 1; // sdbc indexes from 1 +if (columnName.equalsIgnoreAsciiCase(m_aFields[i])) +return static_cast(i) + 1; // sdbc indexes from 1 } throw SQLException("The column name '" + columnName + "' is not valid.", *this, "42S22", 0, @@ -1092,7 +1103,7 @@ css::uno::Reference SAL_CALL OResultSet::getProper void OResultSet::checkColumnIndex(sal_Int32 index) { -if (index < 1 || index > static_cast(m_nFieldCount)) +if (index < 1 || index > static_cast(m_aFields.size())) { /* static object for efficiency or thread safety is a problem ? */ throw SQLException("index out of range", *this, OUString(), 1, Any()); diff --git a/connectivity/source/drivers
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx| 11 +-- connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx |8 +++- 2 files changed, 16 insertions(+), 3 deletions(-) New commits: commit 878c36f829fd88cda95ca218a2cf03003f50e53d Author: Tamas Bunth AuthorDate: Fri Nov 23 18:31:37 2018 +0100 Commit: Tamás Bunth CommitDate: Sat Nov 24 23:15:51 2018 +0100 mysqlc: next() should move cursor from Last XResultSet::next() should move cursor when called while cursor is on the last position. It is not documented, but older versions of the mysqlc extension are implemented that way. The cursor goes to the so called afterlast position. Even so, the next() call on the last position should return false. Change-Id: I0fd145c920077151364a6a8c12e05290496b99c8 Reviewed-on: https://gerrit.libreoffice.org/63895 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index 44488848b5d6..16172439df0f 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -173,9 +173,16 @@ void MysqlTestDriver::testIntegerInsertAndQuery() CPPUNIT_ASSERT_MESSAGE("not enough result after query", hasRow); CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(1)); // first and only column } -bool hasRow = xResultSet->next(); -// no more rows +CPPUNIT_ASSERT_MESSAGE("Cursor is not on last position.", + xResultSet->isLast()); // cursor is on last position +CPPUNIT_ASSERT_EQUAL(ROW_COUNT, xResultSet->getRow()); // which is the last position + +bool hasRow = xResultSet->next(); // go to afterlast +// no more rows, next should return false CPPUNIT_ASSERT_MESSAGE("next returns true after last row", !hasRow); +// cursor should be in afterlast position +CPPUNIT_ASSERT_EQUAL(ROW_COUNT + 1, xResultSet->getRow()); +CPPUNIT_ASSERT_MESSAGE("Cursor is not on after-last position.", xResultSet->isAfterLast()); nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index f0f83e42c3a7..5ee7aa943206 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -691,8 +691,14 @@ sal_Bool SAL_CALL OResultSet::next() MutexGuard aGuard(m_aMutex); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); ensureResultFetched(); -if (m_nRowPosition + 1 >= m_nRowCount) +if (m_nRowPosition + 1 > m_nRowCount) // afterlast return false; +if (m_nRowPosition + 1 == m_nRowCount) // last +{ +// return false but take it to afterlast anyway +++m_nRowPosition; +return false; +} ++m_nRowPosition; return true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: connectivity/qa connectivity/source
connectivity/qa/connectivity/mysql/mysql.cxx|6 ++ connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx |2 +- 2 files changed, 7 insertions(+), 1 deletion(-) New commits: commit dbe401ba4b51e0d3ac14e2a32bdf765832957152 Author: Tamas Bunth AuthorDate: Thu Nov 8 18:48:54 2018 +0100 Commit: Tamás Bunth CommitDate: Fri Nov 9 21:52:23 2018 +0100 mysqlc: fix return value of XResultSet::next Change-Id: I59e4803a5d9b01062eb0eaca0bf65d28298bd3e4 Reviewed-on: https://gerrit.libreoffice.org/63121 Tested-by: Jenkins Reviewed-by: Tamás Bunth diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index 716a1219dee3..44488848b5d6 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -123,6 +123,7 @@ void MysqlTestDriver::testCreateAndDropTable() uno::Reference xStatement = xConnection->createStatement(); CPPUNIT_ASSERT(xStatement.is()); +xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); auto nUpdateCount = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); @@ -143,6 +144,7 @@ void MysqlTestDriver::testIntegerInsertAndQuery() Reference xStatement = xConnection->createStatement(); CPPUNIT_ASSERT(xStatement.is()); +xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); auto nUpdateCount = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); @@ -171,6 +173,9 @@ void MysqlTestDriver::testIntegerInsertAndQuery() CPPUNIT_ASSERT_MESSAGE("not enough result after query", hasRow); CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(1)); // first and only column } +bool hasRow = xResultSet->next(); +// no more rows +CPPUNIT_ASSERT_MESSAGE("next returns true after last row", !hasRow); nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement @@ -186,6 +191,7 @@ void MysqlTestDriver::testDBPositionChange() Reference xStatement = xConnection->createStatement(); CPPUNIT_ASSERT(xStatement.is()); +xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); auto nUpdateCount = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index 01c1889f4681..f0f83e42c3a7 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -691,7 +691,7 @@ sal_Bool SAL_CALL OResultSet::next() MutexGuard aGuard(m_aMutex); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); ensureResultFetched(); -if (m_nRowPosition >= m_nRowCount) +if (m_nRowPosition + 1 >= m_nRowCount) return false; ++m_nRowPosition; return true; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits