[Libreoffice-commits] core.git: 8 commits - connectivity/Library_firebird_sdbc.mk connectivity/source
Andrzej J.R. Hunt
andrzej at ahunt.org
Sun Jul 21 09:53:36 PDT 2013
connectivity/Library_firebird_sdbc.mk | 1
connectivity/source/drivers/firebird/Blob.cxx | 214 +++++++++++++
connectivity/source/drivers/firebird/Blob.hxx | 86 +++++
connectivity/source/drivers/firebird/FConnection.cxx | 64 ++-
connectivity/source/drivers/firebird/FConnection.hxx | 11
connectivity/source/drivers/firebird/FDatabaseMetaData.cxx | 163 ++++-----
connectivity/source/drivers/firebird/FResultSet.cxx | 69 +++-
connectivity/source/drivers/firebird/FResultSet.hxx | 5
connectivity/source/drivers/firebird/FStatement.cxx | 35 +-
9 files changed, 523 insertions(+), 125 deletions(-)
New commits:
commit 51a42da0c6d60a95ca35c90e2a8a4dc27efdf40f
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sun Jul 21 18:07:35 2013 +0200
Add theoretical support for table descriptions (firebird-sdbc).
Untestable as we currently can't write blobs and therefore
don't have any way of reading blobs.
Change-Id: I7226bf89ec014c796279ce8075f1b82f36c3b7b1
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 0997e64..6745046 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -872,11 +872,6 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
(void) schemaPattern;
(void) types;
// TODO: implement types
- // TODO: RDB$DESCRIPTION is a BLOB column with user defined data.
- // Blobs cannot be retrieved with DSQL queries so we need to define
- // all the data we will be using at compile time instead -- i.e. we need
- // to specifically do the whole isc_* stuff here with the datatypes
- // compiled in.
SAL_INFO("connectivity.firebird", "getTables() with "
"TableNamePattern: " << tableNamePattern);
@@ -888,7 +883,8 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
// TODO: OUStringBuf
OUStringBuffer queryBuf(
"SELECT "
- "RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$RELATION_TYPE " //, RDB$DESCRIPTION
+ "RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$RELATION_TYPE, "
+ "RDB$DESCRIPTION "
"FROM RDB$RELATIONS "
"WHERE (RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1)");
@@ -914,10 +910,19 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
{
ODatabaseMetaDataResultSet::ORow aCurrentRow(3);
- OUString aTableName = xRow->getString(1);
- sal_Int16 systemFlag = xRow->getShort(2);
- sal_Int16 tableType = xRow->getShort(3);
- OUString aDescription; // xRow->getString(4);
+ OUString aTableName = xRow->getString(1);
+ sal_Int16 systemFlag = xRow->getShort(2);
+ sal_Int16 tableType = xRow->getShort(3);
+ uno::Reference< XBlob > xBlob = xRow->getBlob(4);
+
+ OUString aDescription;
+ if (xBlob.is())
+ {
+ sal_Int32 aBlobLength = (sal_Int32) xBlob->length();
+ aDescription = OUString((char*) xBlob->getBytes(0, aBlobLength).getArray(),
+ aBlobLength,
+ RTL_TEXTENCODING_UTF8);
+ }
OUString aTableType;
if( 1 == systemFlag )
commit 229a9c1ca024958808d7f6decad6213b20862abd
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sun Jul 21 17:45:08 2013 +0200
Implement the first parts of XBlob. (firebird-sdbc)
Change-Id: Iebb80168ec6fb941ca936834ed2275a598dff55e
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk
index 0c364c5..e884ca8 100644
--- a/connectivity/Library_firebird_sdbc.mk
+++ b/connectivity/Library_firebird_sdbc.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_Library_use_libraries,firebird_sdbc, \
$(eval $(call gb_Library_set_componentfile,firebird_sdbc,connectivity/source/drivers/firebird/firebird_sdbc))
$(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
+ connectivity/source/drivers/firebird/Blob \
connectivity/source/drivers/firebird/FConnection \
connectivity/source/drivers/firebird/FDatabaseMetaData \
connectivity/source/drivers/firebird/FDriver \
diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx
new file mode 100644
index 0000000..12b2622
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "Blob.hxx"
+#include "FConnection.hxx"
+
+#include "connectivity/dbexception.hxx"
+
+using namespace ::connectivity::firebird;
+
+using namespace ::cppu;
+using namespace ::osl;
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+Blob::Blob(isc_db_handle* pDatabaseHandle,
+ isc_tr_handle* pTransactionHandle,
+ ISC_QUAD& aBlobID):
+ Blob_BASE(m_aMutex),
+ m_pDatabaseHandle(pDatabaseHandle),
+ m_pTransactionHandle(pTransactionHandle),
+ m_blobID(aBlobID),
+ m_blobHandle(0),
+ m_bBlobOpened(false),
+ m_blobData(0)
+{
+}
+
+void Blob::ensureBlobIsOpened()
+ throw(SQLException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if (m_bBlobOpened)
+ return;
+
+ ISC_STATUS aErr;
+ aErr = isc_open_blob2(m_statusVector,
+ m_pDatabaseHandle,
+ m_pTransactionHandle,
+ &m_blobHandle,
+ &m_blobID,
+ 0,
+ NULL);
+ if (aErr)
+ OConnection::evaluateStatusVector(m_statusVector,
+ "isc_open_blob2",
+ *this);
+
+}
+
+void SAL_CALL Blob::disposing(void)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if (m_bBlobOpened)
+ {
+ ISC_STATUS aErr;
+ aErr = isc_close_blob(m_statusVector,
+ &m_blobHandle);
+ if (aErr)
+ {
+ try
+ {
+ OConnection::evaluateStatusVector(m_statusVector,
+ "isc_close_blob",
+ *this);
+ }
+ catch (SQLException e)
+ {
+ // we cannot throw any exceptions here anyway
+ SAL_WARN("connectivity.firebird", "isc_close_blob failed\n" <<
+ e.Message);
+ }
+ }
+ }
+
+ Blob_BASE::disposing();
+}
+
+sal_Int64 SAL_CALL Blob::length()
+ throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(Blob_BASE::rBHelper.bDisposed);
+ ensureBlobIsOpened();
+
+ char aBlobItems[] = {
+ isc_info_blob_total_length
+ };
+ char aResultBuffer[20];
+
+ isc_blob_info(m_statusVector,
+ &m_blobHandle,
+ sizeof(aBlobItems),
+ aBlobItems,
+ sizeof(aResultBuffer),
+ aResultBuffer);
+ OConnection::evaluateStatusVector(m_statusVector,
+ "isc_blob_info",
+ *this);
+ if (*aResultBuffer == isc_info_blob_total_length)
+ {
+ short aResultLength = (short) isc_vax_integer(aResultBuffer, 2);
+ return isc_vax_integer(aResultBuffer+2, aResultLength);
+ }
+ return 0;
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL Blob::getBytes(sal_Int64 aPosition, sal_Int32 aLength)
+ throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(Blob_BASE::rBHelper.bDisposed);
+ ensureBlobIsOpened();
+
+ sal_Int64 aTotalLength = length();
+
+ if (!(aPosition + aLength < aTotalLength))
+ {
+ throw SQLException("Byte array requested outwith valid range", *this, OUString(), 1, Any() );
+ }
+
+ if (aTotalLength != m_blobData.getLength())
+ {
+ m_blobData = uno::Sequence< sal_Int8 >(aTotalLength);
+ char* pArray = (char*) m_blobData.getArray();
+ sal_Int64 aBytesRead = 0;
+
+ unsigned short aLengthRead; // The amount read in in a isc_get_segment call
+
+ ISC_STATUS aErr;
+ do
+ {
+ aErr = isc_get_segment(m_statusVector,
+ &m_blobHandle,
+ &aLengthRead,
+ aTotalLength - aBytesRead,
+ pArray + aBytesRead);
+ }
+ while (aErr == 0 || m_statusVector[1] == isc_segment);
+ // Denotes either sucessful read, or only part of segment read successfully.
+ if (aErr)
+ {
+ m_blobData = uno::Sequence< sal_Int8 >(0);
+ OConnection::evaluateStatusVector(m_statusVector,
+ "isc_get_segment",
+ *this);
+ }
+ }
+
+ if (aLength<aTotalLength)
+ {
+ uno::Sequence< sal_Int8 > aRet(aLength);
+ memcpy(aRet.getArray(), m_blobData.getArray() + aLength, aLength);
+ return aRet;
+ }
+ else
+ {
+ return m_blobData; // TODO: subsequence
+ }
+}
+
+uno::Reference< XInputStream > SAL_CALL Blob::getBinaryStream()
+ throw(SQLException, RuntimeException)
+{
+// MutexGuard aGuard(m_aMutex);
+// checkDisposed(Blob_BASE::rBHelper.bDisposed);
+// ensureBlobIsOpened();
+
+ ::dbtools::throwFeatureNotImplementedException("Blob::positionOfBlob", *this);
+ return NULL;
+}
+
+sal_Int64 SAL_CALL Blob::position(const uno::Sequence< sal_Int8 >& rPattern,
+ sal_Int64 aStart)
+ throw(SQLException, RuntimeException)
+{
+// MutexGuard aGuard(m_aMutex);
+// checkDisposed(Blob_BASE::rBHelper.bDisposed);
+// ensureBlobIsOpened();
+
+ (void) rPattern;
+ (void) aStart;
+ ::dbtools::throwFeatureNotImplementedException("Blob::positionOfBlob", *this);
+ return 0;
+}
+
+sal_Int64 SAL_CALL Blob::positionOfBlob(const uno::Reference< XBlob >& rPattern,
+ sal_Int64 aStart)
+ throw(SQLException, RuntimeException)
+{
+// MutexGuard aGuard(m_aMutex);
+// checkDisposed(Blob_BASE::rBHelper.bDisposed);
+// ensureBlobIsOpened();
+
+ (void) rPattern;
+ (void) aStart;
+ ::dbtools::throwFeatureNotImplementedException("Blob::positionOfBlob", *this);
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Blob.hxx b/connectivity/source/drivers/firebird/Blob.hxx
new file mode 100644
index 0000000..f4eb792
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Blob.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef CONNECTIVITY_FIREBIRD_BLOB_HXX
+#define CONNECTIVITY_FIREBIRD_BLOB_HXX
+
+#include <ibase.h>
+
+#include <cppuhelper/compbase1.hxx>
+
+#include <com/sun/star/sdbc/XBlob.hpp>
+
+namespace connectivity
+{
+ namespace firebird
+ {
+ typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XBlob >
+ Blob_BASE;
+
+ class Blob :
+ public Blob_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+
+ isc_db_handle* m_pDatabaseHandle;
+ isc_tr_handle* m_pTransactionHandle;
+ // We store our own copy of the blob id as typically the statement
+ // manages it's own blob id, and blobs are independent of a statement
+ // in firebird.
+ ISC_QUAD m_blobID;
+ isc_blob_handle m_blobHandle;
+
+ bool m_bBlobOpened;
+
+ ISC_STATUS_ARRAY m_statusVector;
+
+ ::com::sun::star::uno::Sequence< sal_Int8 > m_blobData;
+
+ void ensureBlobIsOpened()
+ throw(::com::sun::star::sdbc::SQLException);
+
+ public:
+ Blob(isc_db_handle* pDatabaseHandle,
+ isc_tr_handle* pTransactionHandle,
+ ISC_QUAD& aBlobID);
+
+ // ---- XBlob ----------------------------------------------------
+ virtual sal_Int64 SAL_CALL
+ length()
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
+ getBytes(sal_Int64 aPosition, sal_Int32 aLength)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL
+ getBinaryStream()
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL
+ position(const ::com::sun::star::uno::Sequence< sal_Int8 >& rPattern,
+ sal_Int64 aStart)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL
+ positionOfBlob(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& rPattern,
+ sal_Int64 aStart)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // ---- OComponentHelper ------------------------------------------
+ virtual void SAL_CALL disposing();
+ };
+ }
+
+}
+
+#endif //CONNECTIVITY_FIREBIRD_BLOB_HXX
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index f09663b..3c05d06 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -285,6 +285,22 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.firebird.OConnection",
"com.sun.star.sdbc.Connection")
+Reference< XBlob> OConnection::createBlob(ISC_QUAD* pBlobId)
+ throw(SQLException)
+{
+ SAL_INFO("connectivity.firebird", "createBlob()");
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference< XBlob > xReturn = new Blob(&m_DBHandler,
+ &m_transactionHandle,
+ *pBlobId);
+
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+
+
//----- XConnection ----------------------------------------------------------
Reference< XStatement > SAL_CALL OConnection::createStatement( )
throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index 7bf25d3..5acaf51 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -36,6 +36,8 @@
#ifndef CONNECTIVITY_SCONNECTION_HXX
#define CONNECTIVITY_SCONNECTION_HXX
+#include "Blob.hxx"
+
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/document/DocumentEvent.hpp>
@@ -182,6 +184,15 @@ namespace connectivity
isc_tr_handle& getTransaction();
/**
+ * Create a new Blob tied to this connection. Blobs are tied to a
+ * transaction and not to a statement, hence the connection should
+ * deal with their management.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob>
+ createBlob(ISC_QUAD* pBlobID)
+ throw(::com::sun::star::sdbc::SQLException);
+
+ /**
* Evaluate a firebird status vector and throw exceptions as necessary.
* The content of the status vector is included in the thrown exception.
*/
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index b30a141..a234057 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -447,7 +447,7 @@ T OResultSet::retrieveValue(sal_Int32 columnIndex)
}
template <>
-OUString OResultSet::retrieveValue<OUString>(sal_Int32 columnIndex)
+OUString OResultSet::retrieveValue(sal_Int32 columnIndex)
{
if ((m_bWasNull = isNull(columnIndex)))
return OUString();
@@ -476,6 +476,14 @@ OUString OResultSet::retrieveValue<OUString>(sal_Int32 columnIndex)
}
}
+template <>
+ISC_QUAD* OResultSet::retrieveValue(sal_Int32 columnIndex)
+{
+ if ((m_bWasNull = isNull(columnIndex)))
+ return 0;
+ return (ISC_QUAD*) m_pSqlda->sqlvar[columnIndex-1].sqldata;
+}
+
template <typename T>
T OResultSet::safelyRetrieveValue(sal_Int32 columnIndex)
throw (SQLException)
@@ -601,14 +609,17 @@ uno::Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) th
return NULL;
}
-// -------------------------------------------------------------------------
-uno::Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+
+uno::Reference< XBlob > SAL_CALL OResultSet::getBlob(sal_Int32 columnIndex)
+ throw(SQLException, RuntimeException)
{
- (void) columnIndex;
MutexGuard aGuard(m_pConnection->getMutex());
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return NULL;
+ ISC_QUAD* pBlobID = safelyRetrieveValue< ISC_QUAD* >(columnIndex);
+ if (!pBlobID)
+ return 0;
+ return m_pConnection->createBlob(pBlobID);
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/firebird/FResultSet.hxx b/connectivity/source/drivers/firebird/FResultSet.hxx
index 011f9ff..3b4f734 100644
--- a/connectivity/source/drivers/firebird/FResultSet.hxx
+++ b/connectivity/source/drivers/firebird/FResultSet.hxx
@@ -243,7 +243,10 @@ namespace connectivity
};
// Specialisations have to be in the namespace and can't be within the class.
- template <> ::rtl::OUString OResultSet::retrieveValue< ::rtl::OUString >(sal_Int32 columnIndex);
+ template <> ::rtl::OUString
+ OResultSet::retrieveValue(sal_Int32 columnIndex);
+ template <> ISC_QUAD*
+ OResultSet::retrieveValue(sal_Int32 columnIndex);
}
}
#endif // CONNECTIVITY_SRESULTSET_HXX
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index 6a81754..5ccd0c0 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -322,7 +322,7 @@ int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
pVar->sqldata = (char *)malloc(sizeof(time_t));
break;
case SQL_BLOB:
- assert(false); // We cannot deal with blobs in DSQL
+ pVar->sqldata = (char*) malloc(sizeof(ISC_QUAD));
break;
case SQL_ARRAY:
assert(false); // TODO: implement
commit 997b440080cccc19e35e8c5e32d24ce6c0861779
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Jul 20 20:59:07 2013 +0200
Some cleanup of getTables(). (firebird-sdbc)
Change-Id: I0a16d5a97a25a95b61b1fd11cf276b72d7dad7c5
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 090a33b..0997e64 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -35,6 +35,10 @@
#include "FDatabaseMetaData.hxx"
#include "FDatabaseMetaDataResultSet.hxx"
+
+#include <ibase.h>
+#include <rtl/ustrbuf.hxx>
+
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
@@ -42,9 +46,11 @@
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
-#include <ibase.h>
-
using namespace connectivity::firebird;
+
+using namespace ::rtl;
+
+using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
@@ -71,7 +77,7 @@ ODatabaseMetaData::~ODatabaseMetaData()
{
}
-//----- Catalog Info ---------------------------------------------------------
+//----- Catalog Info -- UNSUPPORTED -------------------------------------------
OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator() throw(SQLException, RuntimeException)
{
return OUString();
@@ -107,7 +113,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) thro
return sal_False;
}
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs() throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs() throw(SQLException, RuntimeException)
{
return 0;
}
@@ -145,7 +151,7 @@ sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength() throw(SQLExceptio
sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex() throw(SQLException, RuntimeException)
{
- // No idea.
+ // TODO: No idea.
// See: http://www.firebirdsql.org/en/firebird-technical-specifications/
return 16;
}
@@ -771,9 +777,9 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates() throw(SQLException,
return sal_False;
}
-Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection() throw(SQLException, RuntimeException)
+uno::Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection() throw(SQLException, RuntimeException)
{
- return (Reference< XConnection >) m_pConnection;
+ return (uno::Reference< XConnection >) m_pConnection;
}
// -------------------------------------------------------------------------
// here follow all methods which return a resultset
@@ -781,19 +787,19 @@ Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection() throw(SQLEx
// of course you could implement it on your and you should do this because
// the general way is more memory expensive
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
{
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException)
{
SAL_INFO("connectivity.firebird", "getTypeInfo().");
// this returns an empty resultset where the column-names are already set
// in special the metadata of the resultset already returns the right columns
ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
- Reference< XResultSet > xResultSet = pResultSet;
+ uno::Reference< XResultSet > xResultSet = pResultSet;
static ODatabaseMetaDataResultSet::ORows aRows;
if(aRows.empty())
@@ -828,12 +834,12 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLExc
return xResultSet;
}
// -----------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
{
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
{
@@ -844,7 +850,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
{
@@ -855,69 +861,72 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
- const Any& catalog, const ::rtl::OUString& schemaPattern,
- const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern,
+ const Sequence< ::rtl::OUString >& types)
+ throw(SQLException, RuntimeException)
{
(void) catalog;
+ (void) schemaPattern;
(void) types;
- SAL_INFO("connectivity.firebird", "getTables(). "
- "Got called with schemaPattern: " << schemaPattern << " , "
+ // TODO: implement types
+ // TODO: RDB$DESCRIPTION is a BLOB column with user defined data.
+ // Blobs cannot be retrieved with DSQL queries so we need to define
+ // all the data we will be using at compile time instead -- i.e. we need
+ // to specifically do the whole isc_* stuff here with the datatypes
+ // compiled in.
+ SAL_INFO("connectivity.firebird", "getTables() with "
"TableNamePattern: " << tableNamePattern);
ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
- Reference< XResultSet > xResultSet = pResultSet;
- Reference< XStatement > statement = m_pConnection->createStatement();
+ uno::Reference< XResultSet > xResultSet = pResultSet;
+ uno::Reference< XStatement > statement = m_pConnection->createStatement();
static const OUString wld("%");
- OUString query(
+ // TODO: OUStringBuf
+ OUStringBuffer queryBuf(
"SELECT "
- "'schema' as schema, RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$RELATION_TYPE, 'description' as description " // avoid duplicates
+ "RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$RELATION_TYPE " //, RDB$DESCRIPTION
"FROM RDB$RELATIONS "
- "WHERE (RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1) ");
+ "WHERE (RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1)");
- if (!schemaPattern.isEmpty())
- {
- if (schemaPattern.match(wld))
- query += "AND 'schema' LIKE '%' ";
- else
- query += "AND 'schema' = '%' ";
- query = query.replaceAll(wld, schemaPattern);
- }
if (!tableNamePattern.isEmpty())
{
+ OUString sAppend;
if (tableNamePattern.match(wld))
- query += "AND RDB$RELATION_NAME LIKE '%' ";
+ sAppend = "AND RDB$RELATION_NAME LIKE '%' ";
else
- query += "AND RDB$RELATION_NAME = '%' ";
- query = query.replaceAll(wld, tableNamePattern);
+ sAppend = "AND RDB$RELATION_NAME = '%' ";
+
+ queryBuf.append(sAppend.replaceAll(wld, tableNamePattern));
}
+ queryBuf.append(" ORDER BY RDB$RELATION_TYPE, RDB$RELATION_NAME");
- SAL_INFO("connectivity.firebird", "getTables(). "
- "About to execute the query.");
+ OUString query = queryBuf.makeStringAndClear();
- Reference< XResultSet > rs = statement->executeQuery(query.getStr());
- Reference< XRow > xRow( rs, UNO_QUERY_THROW );
+ uno::Reference< XResultSet > rs = statement->executeQuery(query.getStr());
+ uno::Reference< XRow > xRow( rs, UNO_QUERY_THROW );
ODatabaseMetaDataResultSet::ORows aRows;
- sal_Int32 rows = 0;
+
while( rs->next() )
{
- ODatabaseMetaDataResultSet::ORow aRow(3);
-
- OUString schema = xRow->getString( 1 );
- OUString aTableName = xRow->getString( 2 );
- sal_Int16 systemFlag = xRow->getShort(3);
- sal_Int16 tableType = xRow->getShort(4);
- OUString desc = xRow->getString( 5 );
+ ODatabaseMetaDataResultSet::ORow aCurrentRow(3);
- rows++;
+ OUString aTableName = xRow->getString(1);
+ sal_Int16 systemFlag = xRow->getShort(2);
+ sal_Int16 tableType = xRow->getShort(3);
+ OUString aDescription; // xRow->getString(4);
OUString aTableType;
if( 1 == systemFlag )
{
aTableType = OUString::createFromAscii("SYSTEM TABLE");
- } else {
+ }
+ else
+ {
if( 0 == tableType )
{
aTableType = OUString::createFromAscii("TABLE");
@@ -928,10 +937,16 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
}
}
- aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
- aRow.push_back( new ORowSetValueDecorator( aTableType ) ); // Table type
- aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
- aRows.push_back(aRow);
+ // TABLE_CAT (catalog) may be null -- thus we omit it.
+ // TABLE_SCHEM (schema) may be null -- thus we omit it.
+ // TABLE_NAME
+ aCurrentRow.push_back(new ORowSetValueDecorator(aTableName));
+ // TABLE_TYPE
+ aCurrentRow.push_back(new ORowSetValueDecorator(aTableType));
+ // REMARKS
+ aCurrentRow.push_back(new ORowSetValueDecorator(aDescription));
+
+ aRows.push_back(aCurrentRow);
}
pResultSet->setRows( aRows );
@@ -939,7 +954,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
return xResultSet;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
const Any& catalog, const ::rtl::OUString& schemaPattern,
const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
{
@@ -950,7 +965,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
const Any& catalog, const ::rtl::OUString& schemaPattern,
const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
{
@@ -960,7 +975,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
(void) catalog;
@@ -969,7 +984,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
(void) catalog;
@@ -978,7 +993,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
(void) catalog;
@@ -987,7 +1002,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
(void) catalog;
@@ -996,7 +1011,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
{
@@ -1008,7 +1023,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
sal_Bool nullable ) throw(SQLException, RuntimeException)
{
@@ -1020,7 +1035,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
{
(void) catalog;
@@ -1029,7 +1044,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
@@ -1043,7 +1058,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException)
{
(void) catalog;
(void) schemaPattern;
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index 501e041..6a81754 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -291,23 +291,24 @@ int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
}
else
{
+ // TODO: confirm the sizings below.
for (int i=0; i < pOutSqlda->sqld; i++, pVar++)
{
int dtype = (pVar->sqltype & ~1); /* drop flag bit for now */
switch(dtype) {
+ case SQL_TEXT:
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
+ break;
case SQL_VARYING:
pVar->sqltype = SQL_TEXT;
- pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen + 2);
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
break;
- case SQL_TEXT:
+ case SQL_SHORT:
pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
break;
case SQL_LONG:
pVar->sqldata = (char *)malloc(sizeof(long));
break;
- case SQL_SHORT:
- pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
- break;
case SQL_FLOAT:
pVar->sqldata = (char *)malloc(sizeof(double));
break;
@@ -320,12 +321,30 @@ int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
case SQL_TIMESTAMP:
pVar->sqldata = (char *)malloc(sizeof(time_t));
break;
+ case SQL_BLOB:
+ assert(false); // We cannot deal with blobs in DSQL
+ break;
+ case SQL_ARRAY:
+ assert(false); // TODO: implement
+ break;
+ case SQL_TYPE_TIME:
+ assert(false); // TODO: implement
+ break;
+ case SQL_TYPE_DATE:
+ assert(false); // TODO: implement
+ break;
case SQL_INT64:
pVar->sqldata = (char *)malloc(sizeof(int));
break;
- /* process remaining types */
+ case SQL_NULL:
+ assert(false); // TODO: implement
+ break;
+ case SQL_QUAD:
+ assert(false); // TODO: implement
+ break;
default:
- OSL_ASSERT( false );
+ SAL_WARN("connectivity.firebird", "Unknown type: " << dtype);
+ assert(false);
break;
}
if (pVar->sqltype & 1)
commit b502e3fd8652e1eba85056336975afdb26c18bed
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Jul 20 13:27:07 2013 +0200
Add retrieval of SQL_VARYING (firebird-sdbc).
Change-Id: I504283d4ba83df1d8e5da7bee180ba181c651bb4
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 857335a..b30a141 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -449,14 +449,31 @@ T OResultSet::retrieveValue(sal_Int32 columnIndex)
template <>
OUString OResultSet::retrieveValue<OUString>(sal_Int32 columnIndex)
{
- // TODO: check we don't have SQL_VARYING (first 2 bytes = short with length
- // of string.
if ((m_bWasNull = isNull(columnIndex)))
return OUString();
- return OUString(m_pSqlda->sqlvar[columnIndex-1].sqldata,
- m_pSqlda->sqlvar[columnIndex-1].sqllen,
- RTL_TEXTENCODING_UTF8);
+ // &~1 to remove the "can contain NULL" indicator
+ int aSqlType = m_pSqlda->sqlvar[columnIndex-1].sqltype & ~1;
+ if (aSqlType == SQL_TEXT )
+ {
+ return OUString(m_pSqlda->sqlvar[columnIndex-1].sqldata,
+ m_pSqlda->sqlvar[columnIndex-1].sqllen,
+ RTL_TEXTENCODING_UTF8);
+ }
+ else if (aSqlType == SQL_VARYING)
+ {
+ // First 2 bytes are a short containing the length of the string
+ // No idea if sqllen is still valid here?
+ short aLength = *((short*) m_pSqlda->sqlvar[columnIndex-1].sqldata);
+ return OUString(m_pSqlda->sqlvar[columnIndex-1].sqldata + 2,
+ aLength,
+ RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ return OUString();
+ // TODO: Possibly do some sort of type conversion?
+ }
}
template <typename T>
commit 2d632ed1d8e062050519a2d9296ffefd84ecb411
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Jul 20 12:46:28 2013 +0200
Remove unneeded SAL_INFO/WARN/DEBUG.
Change-Id: I5212105c14619000a177433ad0326cae6bec3a6c
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index dfe0ffa..f09663b 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -120,8 +120,6 @@ OConnection::~OConnection()
void SAL_CALL OConnection::release() throw()
{
- SAL_INFO("connectivity.firebird", "release().");
-
relase_ChildImpl();
}
// -----------------------------------------------------------------------------
@@ -475,8 +473,6 @@ sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException
// --------------------------------------------------------------------------------
Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
{
- SAL_INFO("connectivity.firebird", "getMetaData().");
-
MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 081626d..090a33b 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -911,29 +911,6 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
OUString desc = xRow->getString( 5 );
rows++;
- if (rows < 10)
- {
- if ( 1 == rows )
- SAL_DEBUG("COLUMNS | "
- "schema | "
- "TABLENAME | "
- "SF| "
- "TT| "
- "desc |");
- SAL_DEBUG("Row " << OUString::number(0).concat(OUString::number(rows)) << ": | "
- << schema << " | "
- << aTableName << " | "
- << systemFlag << " | "
- << tableType << " | "
- << desc << " |");
- }
- else
- SAL_DEBUG("Row " << rows << ": | "
- << schema << " | "
- << aTableName << " | "
- << systemFlag << " | "
- << tableType << " | "
- << desc << " |");
OUString aTableType;
if( 1 == systemFlag )
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 817d042..857335a 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -134,8 +134,6 @@ sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
MutexGuard aGuard(m_pConnection->getMutex());
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- SAL_INFO("connectivity.firebird", "Fetching row from cursor");
-
m_currentRow++;
ISC_STATUS fetchStat = isc_dsql_fetch(m_statusVector,
@@ -343,7 +341,6 @@ void SAL_CALL OResultSet::checkRowIndex()
// -------------------------------------------------------------------------
void OResultSet::disposing(void)
{
- SAL_INFO("connectivity.firebird", "disposing().");
OPropertySetHelper::disposing();
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index eeb0df0..501e041 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -99,8 +99,6 @@ void OStatement_Base::disposeResultSet()
void OStatement_BASE2::disposing()
{
- SAL_INFO("connectivity.firebird", "disposing().");
-
MutexGuard aGuard(m_pConnection->getMutex());
disposeResultSet();
commit 2965924e39eee456acab7e83ffee591176b0dbc9
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Jul 20 12:31:13 2013 +0200
Ensure statement handles are cleanly disposed (firebird-sdbc).
Change-Id: If9406f409a31a00a530b2f458293f3836e178c8e
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index e984f61..dfe0ffa 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -663,12 +663,11 @@ void OConnection::buildTypeInfo() throw( SQLException)
SAL_INFO("connectivity.firebird", "buildTypeInfo(). "
"Closed.");
}
-//------------------------------------------------------------------------------
+
void OConnection::disposing()
{
SAL_INFO("connectivity.firebird", "disposing().");
- // we noticed that we should be destroied in near future so we have to dispose our statements
MutexGuard aGuard(m_aMutex);
for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
@@ -683,7 +682,13 @@ void OConnection::disposing()
m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
ISC_STATUS_ARRAY status; /* status vector */
- if (isc_detach_database(status, &m_DBHandler)) // TODO: this consistently crashes
+ if (m_transactionHandle)
+ {
+ // TODO: confirm whether we need to ask the user here.
+ isc_rollback_transaction(status, &m_transactionHandle);
+ }
+
+ if (isc_detach_database(status, &m_DBHandler))
if (pr_error(status, "dattach database"))
return;
// TODO: write to storage again?
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index b19ec4b..817d042 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -349,6 +349,24 @@ void OResultSet::disposing(void)
MutexGuard aGuard(m_pConnection->getMutex());
+ if (m_statementHandle)
+ {
+ isc_dsql_free_statement(m_statusVector,
+ &m_statementHandle,
+ DSQL_drop);
+ try {
+ OConnection::evaluateStatusVector(m_statusVector,
+ "isc_dsql_free_statement",
+ *this);
+ }
+ catch (SQLException e)
+ {
+ // we cannot throw any exceptions here anyway
+ SAL_WARN("connectivity.firebird", "isc_dsql_free_statement failed\n" <<
+ e.Message);
+ }
+ }
+
m_xMetaData = NULL;
}
// -------------------------------------------------------------------------
commit 7c07cb265980031c034947ed653f78905f1d2ff3
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Jul 20 12:05:44 2013 +0200
Delete temporary fdb when closing.
Change-Id: I81660c16a0d05b6800c96b636114664cff8ab5fb
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 9e6c261..e984f61 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -683,11 +683,18 @@ void OConnection::disposing()
m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
ISC_STATUS_ARRAY status; /* status vector */
- if (isc_detach_database(status, &m_DBHandler))
+ if (isc_detach_database(status, &m_DBHandler)) // TODO: this consistently crashes
if (pr_error(status, "dattach database"))
return;
// TODO: write to storage again?
- // and delete temporary file.
+ if (m_bIsEmbedded)
+ {
+ uno::Reference< ucb::XSimpleFileAccess > xFileAccess(
+ ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext()),
+ uno::UNO_QUERY);
+ if (xFileAccess->exists(m_sURL))
+ xFileAccess->kill(m_sURL);
+ }
dispose_ChildImpl();
cppu::WeakComponentImplHelperBase::disposing();
commit a815e1384dd47164aa0fcb17020293382d53adf0
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Jul 20 11:57:35 2013 +0200
Parse external file url and create new db as needed (firebird-sdbc).
Change-Id: I9dd13540242f6f641f64c44a7121547e0c75c32c
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 1381dfe..9e6c261 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -203,27 +203,29 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
uno::UNO_QUERY );
if ( !xFileAccess.is() )
{
- // TODO: Error
::connectivity::SharedResources aResources;
const OUString sMessage = aResources.getResourceString(STR_ERROR_NEW_VERSION);
::dbtools::throwGenericSQLException(sMessage ,*this);
}
- try {
- xFileAccess->writeFile(m_sURL,xDBStream->getInputStream());
- }
- catch (...)
- {
- // TODO
- }
+
+ xFileAccess->writeFile(m_sURL,xDBStream->getInputStream());
}
+ // TOOO: Get DB properties from XML
- if (bIsNewDatabase)
+ }
+ // External file AND/OR remote connection
+ else if (url.startsWith("sdbc:firebird:"))
+ {
+ m_sURL = url.copy(OUString("sdbc:firebird:").getLength());
+ if (m_sURL.startsWith("file://")) // TODO: are file urls really like this?
{
+ uno::Reference< ucb::XSimpleFileAccess > xFileAccess(
+ ucb::SimpleFileAccess::create(comphelper::getProcessComponentContext()),
+ uno::UNO_QUERY);
+ if (!xFileAccess->exists(m_sURL))
+ bIsNewDatabase = true;
}
- // Get DB properties from XML
-
}
- // else if url.begins(sdbc:firebird...)
ISC_STATUS_ARRAY status; /* status vector */
More information about the Libreoffice-commits
mailing list