diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-06 10:55:40 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-06 13:46:49 +0100 |
commit | 4ef1215d6a380b05bb8bb8d6fca869ac7eca05ff (patch) | |
tree | ca6a55bf2cd108ceb4f79e78c1d92c0b1389a002 /connectivity | |
parent | 17a2a19ca23c0e3acf6dadc5ccdad054395738ef (diff) |
Retrieve all char indexes for rebuildIndexes. (firebird-sdbc)
This provides the SQL SELECT statement necessary to retrieve all the indexes
needing rebuilding.
Change-Id: I07661277682f83dc3f2d33a398abd83593c9928d
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.cxx | 44 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.hxx | 8 |
2 files changed, 52 insertions, 0 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index de795eb221fe..5cca8113ada6 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -274,6 +274,12 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property if (m_bIsEmbedded) // Add DocumentEventListener to save the .fdb as needed { + // TODO: this is only needed when we change icu versions, so ideally + // we somehow keep track of which icu version we have. There might + // be something db internal that we can check, or we might have to store + // it in the .odb. + rebuildIndexes(); + uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(::comphelper::getProcessComponentContext()); uno::Reference< frame::XFrames > xFrames( xFramesSupplier->getFrames(), @@ -783,4 +789,42 @@ uno::Reference< XTablesSupplier > OConnection::createCatalog() } } + +void OConnection::rebuildIndexes() throw(SQLException) +{ + + SAL_INFO("connectivity.firebird", "rebuildIndexes()"); + MutexGuard aGuard(m_aMutex); + + // We only need to do this for character based columns on user-created tables. + + OUString sSql( + // multiple columns possible per index, only select once + "SELECT DISTINCT indices.RDB$INDEX_NAME " + "FROM RDB$INDICES indices " + "JOIN RDB$INDEX_SEGMENTS index_segments " + "ON (indices.RDB$INDEX_NAME = index_segments.RDB$INDEX_NAME) " + "JOIN RDB$RELATION_FIELDS relation_fields " + "ON (index_segments.RDB$FIELD_NAME = relation_fields.RDB$FIELD_NAME) " + "JOIN RDB$FIELDS fields " + "ON (relation_fields.RDB$FIELD_SOURCE = fields.RDB$FIELD_NAME) " + + "WHERE (indices.RDB$SYSTEM_FLAG = 0) " + // TODO: what about blr_text2 etc. ? + "AND ((fields.RDB$FIELD_TYPE = " + OUString::number((int) blr_text) + ") " + " OR (fields.RDB$FIELD_TYPE = " + OUString::number((int) blr_varying) + ")) " + "AND (indices.RDB$INDEX_INACTIVE IS NULL OR indices.RDB$INDEX_INACTIVE = 0) " + ); + + + uno::Reference< XStatement > xStatement = createStatement(); + uno::Reference< XResultSet > xCharIndices = xStatement->executeQuery(sSql); + uno::Reference< XRow > xRow( xCharIndices, UNO_QUERY_THROW ); + while (xCharIndices->next()) + { + } + + Reference< XCloseable> xClose(xCharIndices,UNO_QUERY); + xClose->close(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index 4d7658d814ff..cdf6c443b98f 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -112,6 +112,14 @@ namespace connectivity ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + + /** + * Firebird stores binary collations for indexes on Character based + * columns, these can be binary-incompatible between different icu + * version, hence we need to rebuild the indexes when switching icu + * versions. + */ + void rebuildIndexes() throw( ::com::sun::star::sdbc::SQLException); void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException); void setupTransaction() throw(::com::sun::star::sdbc::SQLException); |