Bugzilla – Attachment 91663 Details for
Bug 72987
[firebird db integration] big-endian LibreOffice unable to open little-endian embedded firebird db (found 2944.512, support 11.2)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
doesn't work yet
0001-efforts-to-backup-db-instead-of-save.patch (text/plain), 12.50 KB, created by
Caolán McNamara
on 2014-01-08 12:28:17 UTC
(
hide
)
Description:
doesn't work yet
Filename:
MIME Type:
Creator:
Caolán McNamara
Created:
2014-01-08 12:28:17 UTC
Size:
12.50 KB
patch
obsolete
>From 3277871bad68b774583f4edac20ebf3a59ef31d6 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> >Date: Tue, 7 Jan 2014 15:21:41 +0000 >Subject: [PATCH] efforts to backup db instead of save > >Change-Id: I6295c32cf9aa5cd322e1328189057ace03723223 >--- > .../source/drivers/firebird/Connection.cxx | 203 +++++++++++++-------- > .../source/drivers/firebird/Connection.hxx | 3 +- > 2 files changed, 131 insertions(+), 75 deletions(-) > >diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx >index f555e2f..bce338d 100644 >--- a/connectivity/source/drivers/firebird/Connection.cxx >+++ b/connectivity/source/drivers/firebird/Connection.cxx >@@ -80,7 +80,7 @@ Connection::Connection(FirebirdDriver* _pDriver) > , m_pDriver(_pDriver) > , m_sConnectionURL() > , m_sFirebirdURL() >- , m_bIsEmbedded(sal_False) >+ , m_bIsEmbedded(false) > , m_xEmbeddedStorage(0) > , m_bIsFile(sal_False) > , m_sUser() >@@ -113,6 +113,9 @@ void SAL_CALL Connection::release() throw() > void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyValue >& info) > throw(SQLException, RuntimeException) > { >+ fprintf(stderr, "Connection::construct %s\n", OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr()); >+ >+ > SAL_INFO("connectivity.firebird", "construct()."); > > osl_atomic_increment( &m_refCount ); >@@ -251,13 +254,15 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV > dpbLength = dpb - dpbBuffer; > } > >+ m_sFirebirdURLAsUTF8 = OUStringToOString(m_sFirebirdURL, RTL_TEXTENCODING_UTF8); >+ > ISC_STATUS_ARRAY status; /* status vector */ > ISC_STATUS aErr; > if (bIsNewDatabase) > { > aErr = isc_create_database(status, >- m_sFirebirdURL.getLength(), >- OUStringToOString(m_sFirebirdURL,RTL_TEXTENCODING_UTF8).getStr(), >+ m_sFirebirdURLAsUTF8.getLength(), >+ m_sFirebirdURLAsUTF8.getStr(), > &m_aDBHandle, > dpbLength, > dpbBuffer, >@@ -270,8 +275,8 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV > else > { > aErr = isc_attach_database(status, >- m_sFirebirdURL.getLength(), >- OUStringToOString(m_sFirebirdURL, RTL_TEXTENCODING_UTF8).getStr(), >+ m_sFirebirdURLAsUTF8.getLength(), >+ m_sFirebirdURLAsUTF8.getStr(), > &m_aDBHandle, > dpbLength, > dpbBuffer); >@@ -283,12 +288,6 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV > > 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(); >- > // We need to attach as a document listener in order to be able to store > // the temporary db back into the .odb when saving > uno::Reference<XDocumentEventBroadcaster> xBroadcaster(m_xParentDocument, UNO_QUERY); >@@ -657,6 +656,8 @@ void SAL_CALL Connection::clearWarnings( ) throw(SQLException, RuntimeException > void SAL_CALL Connection::documentEventOccured( const DocumentEvent& _Event ) > throw(RuntimeException) > { >+ fprintf(stderr, "Connection::documentEventOccured\n"); >+ > MutexGuard aGuard(m_aMutex); > > if (!m_bIsEmbedded) >@@ -669,6 +670,120 @@ void SAL_CALL Connection::documentEventOccured( const DocumentEvent& _Event ) > { > SAL_INFO("connectivity.firebird", "Writing .fdb into .odb" ); > >+ { >+ ISC_STATUS status_vector[20]; >+ char spb_buff[128], *spb = spb_buff; >+ ISC_USHORT spblen; >+ ISC_STATUS aErr; >+ isc_svc_handle svc_handle = 0; >+ >+ *spb++ = isc_spb_version; >+ *spb++ = isc_spb_current_version; >+ >+ spblen = spb - spb_buff; >+ >+ aErr = isc_service_attach(status_vector, 0, "service_mgr", >+ &svc_handle, spblen, spb_buff); >+ >+ if (aErr) >+ { >+ fprintf(stderr, "bad\n"); >+ evaluateStatusVector(status_vector, "isc_service_attach", *this); >+ } >+ else >+ { >+ fprintf(stderr, "good\n"); >+ } >+#if 1 >+ char thd_buff[4096], *thd = thd_buff; >+ ISC_USHORT thdlen; >+ const char *backup_file = "/tmp/foo.gbk"; >+ >+ /* isc_service_attach happens here */ >+ *thd++ = isc_action_svc_backup; >+ >+ /* Set the database name */ >+ *thd++ = isc_spb_dbname; >+ ADD_SPB_LENGTH (thd, m_sFirebirdURLAsUTF8.getLength()); >+ for (sal_Int32 i = 0; i < m_sFirebirdURLAsUTF8.getLength(); ++i) >+ *thd++ = m_sFirebirdURLAsUTF8[i]; >+ >+ /* Set the backup file name */ >+ *thd++ = isc_spb_bkp_file; >+ ADD_SPB_LENGTH (thd, strlen (backup_file)); >+ for (const char *x = backup_file; *x;) >+ *thd++ = *x++; >+ >+ /* Tell backup process that you want output */ >+ *thd++ = isc_spb_verbose; >+ >+ thdlen = thd - thd_buff; >+ >+ aErr = isc_service_start(status_vector, &svc_handle, NULL, thdlen, thd_buff); >+ >+ if (aErr) >+ { >+ fprintf(stderr, "bad 2\n"); >+ evaluateStatusVector(status_vector, "isc_service_start", *this); >+ } >+ else >+ { >+ fprintf(stderr, "good 2\n"); >+ } >+ >+ const char sendbuf[] = { isc_info_svc_line }; >+ char respbuf[1024]; >+ const char* sl; >+ do { >+ aErr = isc_service_query(status_vector, &svc_handle, NULL, 0, NULL, >+ sizeof(sendbuf), sendbuf, >+ sizeof(respbuf), respbuf); >+ >+ if (aErr) >+ { >+ fprintf(stderr, "bad 3\n"); >+ evaluateStatusVector(status_vector, "isc_service_query", *this); >+ break; >+ } >+ else >+ { >+ fprintf(stderr, "good 3\n"); >+ } >+ >+ char* p = respbuf; >+ sl = p; >+ >+ if (*p++ == isc_info_svc_line) >+ { >+ const ISC_USHORT len = (ISC_USHORT) isc_vax_integer(p, sizeof(ISC_USHORT)); >+ p += sizeof(ISC_USHORT); >+ if (!len) >+ { >+ if (*p == isc_info_data_not_ready) >+ continue; >+ else if (*p == isc_info_end) >+ break; >+ } >+ >+ p[len] = '\0'; >+ fprintf(stderr, "%s\n", p); >+ } >+ } while (*sl == isc_info_svc_line); >+ >+ aErr = isc_service_detach(status_vector, &svc_handle); >+ >+ if (aErr) >+ { >+ fprintf(stderr, "bad 4\n"); >+ evaluateStatusVector(status_vector, "isc_service_detach", *this); >+ } >+ else >+ { >+ fprintf(stderr, "good 4\n"); >+ } >+#endif >+ } >+ > Reference< XStream > xDBStream(m_xEmbeddedStorage->openStreamElement(our_sDBLocation, > ElementModes::WRITE)); > >@@ -761,10 +876,13 @@ void Connection::disposing() > isc_rollback_transaction(status, &m_aTransactionHandle); > } > >+ fprintf(stderr, "isc_detach_database\n"); >+ > if (isc_detach_database(status, &m_aDBHandle)) > { > evaluateStatusVector(status, "isc_detach_database", *this); > } >+ > // TODO: write to storage again? > > dispose_ChildImpl(); >@@ -799,69 +917,6 @@ uno::Reference< XTablesSupplier > Connection::createCatalog() > m_xCatalog = xCatalog; > return m_xCatalog; > } >- > } > >-void Connection::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. >- >- // Ideally we'd use a FOR SELECT ... INTO .... DO ..., but that seems to >- // only be possible using PSQL, i.e. using a stored procedure. >- 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 > xCharIndicesStatement = createStatement(); >- uno::Reference< XResultSet > xCharIndices = >- xCharIndicesStatement->executeQuery(sSql); >- uno::Reference< XRow > xRow(xCharIndices, UNO_QUERY_THROW); >- >- uno::Reference< XStatement > xAlterIndexStatement = createStatement(); >- >- // ALTER is a DDL statement, hence using Statement will cause a commit >- // after every alter -- in this case this is inappropriate (xCharIndicesStatement >- // and its ResultSet become invalidated) hence we use the native api. >- while (xCharIndices->next()) >- { >- OUString sIndexName(sanitizeIdentifier(xRow->getString(1))); >- SAL_INFO("connectivity.firebird", "rebuilding index " + sIndexName); >- OString sAlterIndex = "ALTER INDEX \"" >- + OUStringToOString(sIndexName, RTL_TEXTENCODING_UTF8) >- + "\" ACTIVE"; >- >- ISC_STATUS_ARRAY aStatusVector; >- ISC_STATUS aErr; >- >- aErr = isc_dsql_execute_immediate(aStatusVector, >- &getDBHandle(), >- &getTransaction(), >- 0, // Length: 0 for null terminated >- sAlterIndex.getStr(), >- FIREBIRD_SQL_DIALECT, >- NULL); >- if (aErr) >- evaluateStatusVector(aStatusVector, >- "rebuildIndexes:isc_dsql_execute_immediate", >- *this); >- } >- commit(); >-} > /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx >index 7850da7..c85654a 100644 >--- a/connectivity/source/drivers/firebird/Connection.hxx >+++ b/connectivity/source/drivers/firebird/Connection.hxx >@@ -92,7 +92,8 @@ namespace connectivity > * temporary .fdb extracted from a .odb or a normal local file) or > * a remote url. > */ >- ::rtl::OUString m_sFirebirdURL; >+ OUString m_sFirebirdURL; >+ OString m_sFirebirdURLAsUTF8; > > /* EMBEDDED MODE DATA */ > /** Denotes that we have a .fdb stored within a .odb file. */ >-- >1.8.4.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 72987
:
91663
|
114274