[Libreoffice-commits] core.git: 12 commits - connectivity/Library_firebird_sdbc.mk connectivity/source
Andrzej J.R. Hunt
andrzej at ahunt.org
Sun Aug 11 08:08:18 PDT 2013
connectivity/Library_firebird_sdbc.mk | 3
connectivity/source/drivers/firebird/Columns.cxx | 29 ++
connectivity/source/drivers/firebird/Columns.hxx | 35 +++
connectivity/source/drivers/firebird/Connection.cxx | 11 -
connectivity/source/drivers/firebird/Connection.hxx | 21 +
connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 121 ++++-------
connectivity/source/drivers/firebird/Driver.cxx | 24 ++
connectivity/source/drivers/firebird/Driver.hxx | 21 +
connectivity/source/drivers/firebird/PreparedStatement.cxx | 48 +---
connectivity/source/drivers/firebird/PreparedStatement.hxx | 8
connectivity/source/drivers/firebird/ResultSet.cxx | 27 --
connectivity/source/drivers/firebird/Statement.cxx | 43 +--
connectivity/source/drivers/firebird/Statement.hxx | 7
connectivity/source/drivers/firebird/StatementCommonBase.cxx | 109 +++++----
connectivity/source/drivers/firebird/StatementCommonBase.hxx | 15 -
connectivity/source/drivers/firebird/Table.cxx | 65 +++++
connectivity/source/drivers/firebird/Table.hxx | 51 ++++
connectivity/source/drivers/firebird/Tables.cxx | 88 ++++++++
connectivity/source/drivers/firebird/Tables.hxx | 66 ++++++
19 files changed, 576 insertions(+), 216 deletions(-)
New commits:
commit baaa43446f5661177b4900f260bba313883c4032
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Aug 10 13:05:12 2013 +0100
Reduce getColumnPrivileges verbosity. (firebird-sdbc)
Change-Id: I06f7d7e12c5b5dce1f902261e45afa39ed7a8665
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 1b49d0f..f4bf92a 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1081,51 +1081,29 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
uno::Reference< XRow > xRow( rs, UNO_QUERY_THROW );
ODatabaseMetaDataResultSet::ORows aResults;
+ ODatabaseMetaDataResultSet::ORow aCurrentRow(8);
+ aCurrentRow[0] = new ORowSetValueDecorator(); // Unused
+ aCurrentRow[1] = new ORowSetValueDecorator(); // 1. TABLE_CAT Unsupported
+ aCurrentRow[2] = new ORowSetValueDecorator(); // 1. TABLE_SCHEM Unsupported
+
while( rs->next() )
{
- // TODO: avoid reallocations here.
- ODatabaseMetaDataResultSet::ORow aCurrentRow;
- aCurrentRow.reserve(9);
-
- // 0. Empty
- aCurrentRow.push_back(new ORowSetValueDecorator());
- // 1. TABLE_CAT
- aCurrentRow.push_back(new ORowSetValueDecorator());
- // 2. TABLE_SCHEM
- aCurrentRow.push_back(new ORowSetValueDecorator());
-
// 3. TABLE_NAME
{
OUString sTableName = xRow->getString(1);
sanitizeIdentifier(sTableName);
- aCurrentRow.push_back(new ORowSetValueDecorator(sTableName));
+ aCurrentRow[3] = new ORowSetValueDecorator(sTableName);
}
- // 3. COLUMN_NAME
+ // 4. COLUMN_NAME
{
OUString sColumnName = xRow->getString(6);
sanitizeIdentifier(sColumnName);
- aCurrentRow.push_back(new ORowSetValueDecorator(sColumnName));
- }
- // 4. GRANTOR
- {
- OUString sGrantor = xRow->getString(2);
- aCurrentRow.push_back(new ORowSetValueDecorator(sGrantor));
- }
- // 5. GRANTEE
- {
- OUString sGrantee = xRow->getString(3);
- aCurrentRow.push_back(new ORowSetValueDecorator(sGrantee));
- }
- // 6. Privilege
- {
- OUString sPrivilege = xRow->getString(4);
- aCurrentRow.push_back(new ORowSetValueDecorator(sPrivilege));
- }
- // 7. IS_GRANTABLE
- {
- sal_Bool bIsGrantable = xRow->getBoolean(5);
- aCurrentRow.push_back(new ORowSetValueDecorator(bIsGrantable));
+ aCurrentRow[4] = new ORowSetValueDecorator(sColumnName);
}
+ aCurrentRow[5] = new ORowSetValueDecorator(xRow->getString(2)); // 5. GRANTOR
+ aCurrentRow[6] = new ORowSetValueDecorator(xRow->getString(3)); // 6. GRANTEE
+ aCurrentRow[7] = new ORowSetValueDecorator(xRow->getString(4)); // 7. Privilege
+ aCurrentRow[7] = new ORowSetValueDecorator(xRow->getBoolean(5)); // 8. Grantable
aResults.push_back(aCurrentRow);
}
commit e6ae90b0723ed0cbf8c9c7dab65d235d0b78431a
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Aug 10 12:58:32 2013 +0100
Reduce verbosity of getTables. (firebird-sdbc)
Change-Id: Ief8d962d39b27acfb19adaee5e470417ee98b371
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 177d041..1b49d0f 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1378,58 +1378,63 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
uno::Reference< XResultSet > rs = statement->executeQuery(query.getStr());
uno::Reference< XRow > xRow( rs, UNO_QUERY_THROW );
- ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORows aResults;
+
+ ODatabaseMetaDataResultSet::ORow aCurrentRow(6);
+ aCurrentRow[0] = new ORowSetValueDecorator(); // 0. Unused
+ aCurrentRow[1] = new ORowSetValueDecorator(); // 1. Table_Cat Unsupported
+ aCurrentRow[2] = new ORowSetValueDecorator(); // 2. Table_Schem Unsupported
while( rs->next() )
{
- ODatabaseMetaDataResultSet::ORow aCurrentRow(3);
-
- OUString sTableName = xRow->getString(1);
- sanitizeIdentifier(sTableName);
- sal_Int16 systemFlag = xRow->getShort(2);
- sal_Int16 tableType = xRow->getShort(3);
- uno::Reference< XBlob > xBlob = xRow->getBlob(4);
-
- OUString aDescription;
- if (xBlob.is())
+ // 3. TABLE_NAME
{
- sal_Int32 aBlobLength = (sal_Int32) xBlob->length();
- aDescription = OUString((char*) xBlob->getBytes(0, aBlobLength).getArray(),
- aBlobLength,
- RTL_TEXTENCODING_UTF8);
+ OUString sTableName = xRow->getString(1);
+ sanitizeIdentifier(sTableName);
+ aCurrentRow[3] = new ORowSetValueDecorator(sTableName);
}
-
- OUString aTableType;
- if( 1 == systemFlag )
+ // 4. TABLE_TYPE
{
- aTableType = OUString::createFromAscii("SYSTEM TABLE");
+ sal_Int16 nSystemFlag = xRow->getShort(2);
+ sal_Int16 nTableType = xRow->getShort(3);
+ OUString sTableType;
- }
- else
- {
- if( 0 == tableType )
+ if (nSystemFlag == 1)
{
- aTableType = OUString::createFromAscii("TABLE");
+ sTableType = "SYSTEM TABLE";
}
else
{
- aTableType = OUString::createFromAscii("VIEW");
+ if (nTableType == 0)
+ sTableType = "TABLE";
+ else
+ sTableType = "VIEW";
}
+
+ aCurrentRow[4] = new ORowSetValueDecorator(sTableType);
}
+ // 5. REMARKS
+ {
+ uno::Reference< XBlob > xBlob = xRow->getBlob(4);
+ OUString sDescription;
- // 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(sTableName));
- // TABLE_TYPE
- aCurrentRow.push_back(new ORowSetValueDecorator(aTableType));
- // REMARKS
- aCurrentRow.push_back(new ORowSetValueDecorator(aDescription));
+ if (xBlob.is())
+ {
+ // TODO: we should actually be using CLOB here instead.
+ // However we haven't implemented CLOB yet, so use BLOB.
+ sal_Int32 aBlobLength = (sal_Int32) xBlob->length();
+ sDescription = OUString((char*) xBlob->getBytes(0, aBlobLength).getArray(),
+ aBlobLength,
+ RTL_TEXTENCODING_UTF8);
+ }
+
+ aCurrentRow[5] = new ORowSetValueDecorator(sDescription);
+ }
- aRows.push_back(aCurrentRow);
+ aResults.push_back(aCurrentRow);
}
- pResultSet->setRows( aRows );
+ pResultSet->setRows( aResults );
return xResultSet;
}
commit d12ddee812480595745b656113475468bddc4b1a
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Aug 10 12:45:21 2013 +0100
Creation of skeleton Columns. (firebird-sdbc)
Change-Id: I5289dc68c05190e67420c51d8857dab5187cd98b
diff --git a/connectivity/source/drivers/firebird/Columns.hxx b/connectivity/source/drivers/firebird/Columns.hxx
index a1130ff..c49dbfa 100644
--- a/connectivity/source/drivers/firebird/Columns.hxx
+++ b/connectivity/source/drivers/firebird/Columns.hxx
@@ -21,7 +21,7 @@ namespace connectivity
class Columns: public ::connectivity::OColumnsHelper
{
public:
- Columns(::cppu::OWeakObject& pTable,
+ Columns(::cppu::OWeakObject& rTable,
::osl::Mutex& rMutex,
const ::connectivity::TStringVector &_rVector);
};
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index f53d229..fe14352 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -7,18 +7,21 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "Columns.hxx"
#include "Table.hxx"
using namespace ::connectivity;
using namespace ::connectivity::firebird;
using namespace ::connectivity::sdbcx;
+using namespace ::osl;
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::sdbc;
Table::Table(Tables* pTables,
+ Mutex& rMutex,
const uno::Reference< XConnection >& rConnection,
const OUString& rName,
const OUString& rType,
@@ -31,7 +34,8 @@ Table::Table(Tables* pTables,
rType,
rDescription,
"",
- "")
+ ""),
+ m_rMutex(rMutex)
{
(void) nPrivileges;
}
@@ -39,9 +43,9 @@ Table::Table(Tables* pTables,
//----- OTableHelper ---------------------------------------------------------
OCollection* Table::createColumns(const TStringVector& rNames)
{
- (void) rNames;
- // TODO: IMPLEMENT ME
- return 0;
+ return new Columns(*this,
+ m_rMutex,
+ rNames);
}
OCollection* Table::createKeys(const TStringVector& rNames)
diff --git a/connectivity/source/drivers/firebird/Table.hxx b/connectivity/source/drivers/firebird/Table.hxx
index 426f906..f074e18 100644
--- a/connectivity/source/drivers/firebird/Table.hxx
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -21,8 +21,12 @@ namespace connectivity
class Table: public OTableHelper
{
+ private:
+ ::osl::Mutex& m_rMutex;
+
public:
Table(Tables* pTables,
+ ::osl::Mutex& rMutex,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
const OUString& rName,
const OUString& rType,
diff --git a/connectivity/source/drivers/firebird/Tables.cxx b/connectivity/source/drivers/firebird/Tables.cxx
index e44e952..e894450 100644
--- a/connectivity/source/drivers/firebird/Tables.cxx
+++ b/connectivity/source/drivers/firebird/Tables.cxx
@@ -28,6 +28,7 @@ Tables::Tables(ODatabaseMetaData& xMetaData,
::osl::Mutex& rMutex,
const TStringVector& rVector) :
OCollection(rParent, sal_True, rMutex, rVector),
+ m_rMutex(rMutex),
m_xMetaData(xMetaData)
{
}
@@ -57,6 +58,7 @@ ObjectType Tables::createObject(const OUString& rName)
throw RuntimeException();
ObjectType xRet(new Table(this,
+ m_rMutex,
m_xMetaData.getConnection(),
rName,
"", // TODO: Type
diff --git a/connectivity/source/drivers/firebird/Tables.hxx b/connectivity/source/drivers/firebird/Tables.hxx
index 2b3453c..85d7079 100644
--- a/connectivity/source/drivers/firebird/Tables.hxx
+++ b/connectivity/source/drivers/firebird/Tables.hxx
@@ -25,6 +25,9 @@ namespace connectivity
*/
class Tables: public ::connectivity::sdbcx::OCollection
{
+ private:
+ ::osl::Mutex& m_rMutex;
+
protected:
// OCollection: pure virtual functions requiring implementation
virtual void impl_refresh()
commit 83994aa7cd4558588f85d451358fe8f7a560816b
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Aug 10 12:39:38 2013 +0100
Add skeleton Columns. (firebird-sdbc)
Change-Id: If58976bbb8a64d5092fcf33d3d09cdde145ecfe1
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk
index 0a36970..066d60ad 100644
--- a/connectivity/Library_firebird_sdbc.mk
+++ b/connectivity/Library_firebird_sdbc.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Library_set_componentfile,firebird_sdbc,connectivity/source/dri
$(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
connectivity/source/drivers/firebird/Blob \
+ connectivity/source/drivers/firebird/Columns \
connectivity/source/drivers/firebird/Connection \
connectivity/source/drivers/firebird/DatabaseMetaData \
connectivity/source/drivers/firebird/Driver \
diff --git a/connectivity/source/drivers/firebird/Columns.cxx b/connectivity/source/drivers/firebird/Columns.cxx
new file mode 100644
index 0000000..c1e7034
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Columns.cxx
@@ -0,0 +1,29 @@
+/* -*- 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 "Columns.hxx"
+
+using namespace ::connectivity;
+using namespace ::connectivity::firebird;
+
+using namespace ::cppu;
+using namespace ::osl;
+
+Columns::Columns(OWeakObject& rTable,
+ Mutex& rMutex,
+ const TStringVector& rVector):
+ OColumnsHelper(rTable,
+ sal_True, // TODO: is this case sensitivity?
+ rMutex,
+ rVector)
+{
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Columns.hxx b/connectivity/source/drivers/firebird/Columns.hxx
new file mode 100644
index 0000000..a1130ff
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Columns.hxx
@@ -0,0 +1,35 @@
+/* -*- 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_COLUMNS_HXX
+#define CONNECTIVITY_FIREBIRD_COLUMNS_HXX
+
+#include "Table.hxx"
+
+#include <connectivity/TColumnsHelper.hxx>
+
+namespace connectivity
+{
+ namespace firebird
+ {
+ class Columns: public ::connectivity::OColumnsHelper
+ {
+ public:
+ Columns(::cppu::OWeakObject& pTable,
+ ::osl::Mutex& rMutex,
+ const ::connectivity::TStringVector &_rVector);
+ };
+
+ } // namespace firebird
+} // namespace connectivity
+
+
+#endif // CONNECTIVITY_FIREBIRD_COLUMNS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit f496a1cb39b33e3dff1b3f0475dc00c904a2c5f4
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Sat Aug 10 11:06:48 2013 +0100
Implement Tables::createObject. (firebird-sdbc)
Change-Id: I9a4d301a0edf27af2dc3c571156592406c5019f9
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index c557600..f53d229 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -9,4 +9,53 @@
#include "Table.hxx"
+using namespace ::connectivity;
+using namespace ::connectivity::firebird;
+using namespace ::connectivity::sdbcx;
+
+using namespace ::rtl;
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::sdbc;
+
+Table::Table(Tables* pTables,
+ const uno::Reference< XConnection >& rConnection,
+ const OUString& rName,
+ const OUString& rType,
+ const OUString& rDescription,
+ sal_Int32 nPrivileges):
+ OTableHelper(pTables,
+ rConnection,
+ sal_True,
+ rName,
+ rType,
+ rDescription,
+ "",
+ "")
+{
+ (void) nPrivileges;
+}
+
+//----- OTableHelper ---------------------------------------------------------
+OCollection* Table::createColumns(const TStringVector& rNames)
+{
+ (void) rNames;
+ // TODO: IMPLEMENT ME
+ return 0;
+}
+
+OCollection* Table::createKeys(const TStringVector& rNames)
+{
+ (void) rNames;
+ // TODO: IMPLEMENT ME
+ return 0;
+}
+
+OCollection* Table::createIndexes(const TStringVector& rNames)
+{
+ (void) rNames;
+ // TODO: IMPLEMENT ME
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Table.hxx b/connectivity/source/drivers/firebird/Table.hxx
index b97a9fd..426f906 100644
--- a/connectivity/source/drivers/firebird/Table.hxx
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -10,6 +10,8 @@
#ifndef CONNECTIVITY_FIREBIRD_TABLE_HXX
#define CONNECTIVITY_FIREBIRD_TABLE_HXX
+#include "Tables.hxx"
+
#include <connectivity/TTableHelper.hxx>
namespace connectivity
@@ -19,6 +21,22 @@ namespace connectivity
class Table: public OTableHelper
{
+ public:
+ Table(Tables* pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const OUString& rName,
+ const OUString& rType,
+ const OUString& rDescription,
+ sal_Int32 _nPrivileges);
+
+ // OTableHelper
+ virtual ::connectivity::sdbcx::OCollection* createColumns(
+ const ::connectivity::TStringVector& rNames);
+ virtual ::connectivity::sdbcx::OCollection* createKeys(
+ const ::connectivity::TStringVector& rNames);
+ virtual ::connectivity::sdbcx::OCollection* createIndexes(
+ const ::connectivity::TStringVector& rNames);
+
};
} // namespace firebird
diff --git a/connectivity/source/drivers/firebird/Tables.cxx b/connectivity/source/drivers/firebird/Tables.cxx
index 52b1512..e44e952 100644
--- a/connectivity/source/drivers/firebird/Tables.cxx
+++ b/connectivity/source/drivers/firebird/Tables.cxx
@@ -7,8 +7,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "Table.hxx"
#include "Tables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+
using namespace ::connectivity::firebird;
using namespace ::connectivity::sdbcx;
using namespace ::cppu;
@@ -20,10 +23,12 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
-Tables::Tables(::cppu::OWeakObject& rParent,
+Tables::Tables(ODatabaseMetaData& xMetaData,
+ ::cppu::OWeakObject& rParent,
::osl::Mutex& rMutex,
const TStringVector& rVector) :
- OCollection(rParent, sal_True, rMutex, rVector)
+ OCollection(rParent, sal_True, rMutex, rVector),
+ m_xMetaData(xMetaData)
{
}
@@ -36,23 +41,46 @@ void Tables::impl_refresh()
ObjectType Tables::createObject(const OUString& rName)
{
- (void) rName;
- // TODO: IMPLEMENT ME
- return ObjectType();
-}
+ // TODO: parse the name.
+ // TODO: use table types
+ uno::Reference< XResultSet > xTables = m_xMetaData.getTables(Any(),
+ OUString(),
+ rName,
+ uno::Sequence< OUString >());
-//----- XDrop ----------------------------------------------------------------
-void SAL_CALL Tables::dropByName(const OUString& rName)
- throw (SQLException, NoSuchElementException, RuntimeException)
-{
- (void) rName;
- // TODO: IMPLEMENT ME
-}
+ if (!xTables.is())
+ throw RuntimeException();
-void SAL_CALL Tables::dropByIndex(const sal_Int32 nIndex)
- throw (SQLException, IndexOutOfBoundsException, RuntimeException)
-{
- (void) nIndex;
- // TODO: IMPLEMENT ME
+ uno::Reference< XRow > xRow(xTables,UNO_QUERY);
+
+ if (!xRow.is() || !xTables->next())
+ throw RuntimeException();
+
+ ObjectType xRet(new Table(this,
+ m_xMetaData.getConnection(),
+ rName,
+ "", // TODO: Type
+ "", // TODO: Description
+ 0)); // TODO: privileges
+
+ if (xTables->next())
+ throw RuntimeException(); // Only one table should be returned
+
+ return xRet;
}
+
+// //----- XDrop ----------------------------------------------------------------
+// void SAL_CALL Tables::dropByName(const OUString& rName)
+// throw (SQLException, NoSuchElementException, RuntimeException)
+// {
+// (void) rName;
+// // TODO: IMPLEMENT ME
+// }
+//
+// void SAL_CALL Tables::dropByIndex(const sal_Int32 nIndex)
+// throw (SQLException, IndexOutOfBoundsException, RuntimeException)
+// {
+// (void) nIndex;
+// // TODO: IMPLEMENT ME
+// }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Tables.hxx b/connectivity/source/drivers/firebird/Tables.hxx
index 89f188d..2b3453c 100644
--- a/connectivity/source/drivers/firebird/Tables.hxx
+++ b/connectivity/source/drivers/firebird/Tables.hxx
@@ -10,6 +10,8 @@
#ifndef CONNECTIVITY_FIREBIRD_TABLES_HXX
#define CONNECTIVITY_FIREBIRD_TABLES_HXX
+#include "DatabaseMetaData.hxx"
+
#include <connectivity/sdbcx/VCollection.hxx>
namespace connectivity
@@ -30,23 +32,26 @@ namespace connectivity
virtual ::connectivity::sdbcx::ObjectType createObject(
const ::rtl::OUString& rName);
+ ODatabaseMetaData& m_xMetaData;
+
public:
- Tables(::cppu::OWeakObject& rParent,
+ Tables(ODatabaseMetaData& xMetaData,
+ ::cppu::OWeakObject& rParent,
::osl::Mutex& rMutex,
const TStringVector& rVector);
// TODO: we should also implement XDataDescriptorFactory, XRefreshable,
// XAppend, etc., but all are optional.
- // XDrop
- virtual void SAL_CALL dropByName(const ::rtl::OUString& rName)
- throw (::com::sun::star::sdbc::SQLException,
- ::com::sun::star::container::NoSuchElementException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL dropByIndex(const sal_Int32 nIndex)
- throw (::com::sun::star::sdbc::SQLException,
- com::sun::star::lang::IndexOutOfBoundsException,
- ::com::sun::star::uno::RuntimeException);
+// // XDrop
+// virtual void SAL_CALL dropByName(const ::rtl::OUString& rName)
+// throw (::com::sun::star::sdbc::SQLException,
+// ::com::sun::star::container::NoSuchElementException,
+// ::com::sun::star::uno::RuntimeException);
+// virtual void SAL_CALL dropByIndex(const sal_Int32 nIndex)
+// throw (::com::sun::star::sdbc::SQLException,
+// com::sun::star::lang::IndexOutOfBoundsException,
+// ::com::sun::star::uno::RuntimeException);
};
} // namespace firebird
commit 73341eddbf3e42a121d80cada4d1252af80f5396
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Thu Aug 8 22:00:36 2013 +0100
Add sdbcx.Table (firebird-sdbc)
Change-Id: Iae9a4d1292d0dcd2da17c5a5552a3986b306a550
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk
index b00ba7b..0a36970 100644
--- a/connectivity/Library_firebird_sdbc.mk
+++ b/connectivity/Library_firebird_sdbc.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
connectivity/source/drivers/firebird/Services \
connectivity/source/drivers/firebird/Statement \
connectivity/source/drivers/firebird/StatementCommonBase \
+ connectivity/source/drivers/firebird/Table \
connectivity/source/drivers/firebird/Tables \
connectivity/source/drivers/firebird/Util \
))
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
new file mode 100644
index 0000000..c557600
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -0,0 +1,12 @@
+/* -*- 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 "Table.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Table.hxx b/connectivity/source/drivers/firebird/Table.hxx
new file mode 100644
index 0000000..b97a9fd
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -0,0 +1,29 @@
+/* -*- 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_TABLE_HXX
+#define CONNECTIVITY_FIREBIRD_TABLE_HXX
+
+#include <connectivity/TTableHelper.hxx>
+
+namespace connectivity
+{
+ namespace firebird
+ {
+
+ class Table: public OTableHelper
+ {
+ };
+
+ } // namespace firebird
+} // namespace connectivity
+
+#endif // CONNECTIVITY_FIREBIRD_TABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit 464a0b50008e7b6824edc28d56685b8e4fd3d632
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Thu Aug 8 18:04:18 2013 +0100
First chunk of skeleton sdbcx.Container. (firebird-sdbc)
Change-Id: Ic92c4d13b0ed9aba622d3a2459f9677d8cce3245
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk
index 1893718..b00ba7b 100644
--- a/connectivity/Library_firebird_sdbc.mk
+++ b/connectivity/Library_firebird_sdbc.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
connectivity/source/drivers/firebird/Services \
connectivity/source/drivers/firebird/Statement \
connectivity/source/drivers/firebird/StatementCommonBase \
+ connectivity/source/drivers/firebird/Tables \
connectivity/source/drivers/firebird/Util \
))
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index 0402581..870e7b6 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -22,9 +22,9 @@
#include "Driver.hxx"
#include "PreparedStatement.hxx"
#include "Statement.hxx"
+#include "Tables.hxx"
#include "Util.hxx"
-
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@@ -761,4 +761,13 @@ void OConnection::clearStatements()
}
m_aStatements.clear();
}
+
+//----- XTablesSupplier ------------------------------------------------------
+uno::Reference< XNameAccess > OConnection::getTables()
+ throw (RuntimeException)
+{
+ // TODO: IMPLEMENT ME PROPERLY
+ //return new Tables();
+ return 0;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx
index 5e35b36..361ce23 100644
--- a/connectivity/source/drivers/firebird/Connection.hxx
+++ b/connectivity/source/drivers/firebird/Connection.hxx
@@ -27,7 +27,7 @@
#include <connectivity/CommonTools.hxx>
#include <connectivity/OSubComponent.hxx>
-#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/compbase5.hxx>
#include <cppuhelper/weakref.hxx>
#include <map>
#include <OTypeInfo.hxx>
@@ -42,17 +42,19 @@
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
namespace connectivity
{
namespace firebird
{
- typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XConnection,
- ::com::sun::star::sdbc::XWarningsSupplier,
- ::com::sun::star::lang::XServiceInfo,
- ::com::sun::star::document::XDocumentEventListener
- > OConnection_BASE;
+ typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::document::XDocumentEventListener,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::sdbc::XConnection,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbcx::XTablesSupplier
+ > OConnection_BASE;
class OStatementCommonBase;
class FirebirdDriver;
@@ -159,6 +161,13 @@ namespace connectivity
// css.lang.XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ // XTablesSupplier
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getTables()
+ throw(::com::sun::star::uno::RuntimeException);
+
+
+
inline ::rtl::OUString getUserName() const { return m_sUser; }
inline isc_db_handle& getDBHandle() { return m_DBHandler; }
inline FirebirdDriver* getDriver() const { return m_pDriver;}
diff --git a/connectivity/source/drivers/firebird/Tables.cxx b/connectivity/source/drivers/firebird/Tables.cxx
new file mode 100644
index 0000000..52b1512
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Tables.cxx
@@ -0,0 +1,58 @@
+/* -*- 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 "Tables.hxx"
+
+using namespace ::connectivity::firebird;
+using namespace ::connectivity::sdbcx;
+using namespace ::cppu;
+using namespace ::rtl;
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+Tables::Tables(::cppu::OWeakObject& rParent,
+ ::osl::Mutex& rMutex,
+ const TStringVector& rVector) :
+ OCollection(rParent, sal_True, rMutex, rVector)
+{
+}
+
+//----- OCollection -----------------------------------------------------------
+void Tables::impl_refresh()
+ throw(RuntimeException)
+{
+ // TODO: IMPLEMENT ME
+}
+
+ObjectType Tables::createObject(const OUString& rName)
+{
+ (void) rName;
+ // TODO: IMPLEMENT ME
+ return ObjectType();
+}
+
+//----- XDrop ----------------------------------------------------------------
+void SAL_CALL Tables::dropByName(const OUString& rName)
+ throw (SQLException, NoSuchElementException, RuntimeException)
+{
+ (void) rName;
+ // TODO: IMPLEMENT ME
+}
+
+void SAL_CALL Tables::dropByIndex(const sal_Int32 nIndex)
+ throw (SQLException, IndexOutOfBoundsException, RuntimeException)
+{
+ (void) nIndex;
+ // TODO: IMPLEMENT ME
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Tables.hxx b/connectivity/source/drivers/firebird/Tables.hxx
new file mode 100644
index 0000000..89f188d
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Tables.hxx
@@ -0,0 +1,58 @@
+/* -*- 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_TABLES_HXX
+#define CONNECTIVITY_FIREBIRD_TABLES_HXX
+
+#include <connectivity/sdbcx/VCollection.hxx>
+
+namespace connectivity
+{
+ namespace firebird
+ {
+
+ /**
+ * This implements com.sun.star.sdbcx.Container, which seems to be
+ * also known by the name of Tables and Collection.
+ */
+ class Tables: public ::connectivity::sdbcx::OCollection
+ {
+ protected:
+ // OCollection: pure virtual functions requiring implementation
+ virtual void impl_refresh()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::connectivity::sdbcx::ObjectType createObject(
+ const ::rtl::OUString& rName);
+
+ public:
+ Tables(::cppu::OWeakObject& rParent,
+ ::osl::Mutex& rMutex,
+ const TStringVector& rVector);
+
+ // TODO: we should also implement XDataDescriptorFactory, XRefreshable,
+ // XAppend, etc., but all are optional.
+
+ // XDrop
+ virtual void SAL_CALL dropByName(const ::rtl::OUString& rName)
+ throw (::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL dropByIndex(const sal_Int32 nIndex)
+ throw (::com::sun::star::sdbc::SQLException,
+ com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ };
+
+ } // namespace firebird
+} // namespace connectivity
+
+
+#endif // CONNECTIVITY_FIREBIRD_TABLES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit 0c2b01f038b55d6410242e98067845ec6cda4b5a
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Thu Aug 8 10:08:27 2013 +0100
Add skeleton sdbcx methods to Driver. (firebird-sdbc)
Change-Id: I531b4260e6ada7f82d71957381b0cc4896678d55
diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx
index 21afe46..7be842a 100644
--- a/connectivity/source/drivers/firebird/Driver.cxx
+++ b/connectivity/source/drivers/firebird/Driver.cxx
@@ -32,6 +32,7 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
using namespace ::osl;
@@ -81,8 +82,9 @@ rtl::OUString FirebirdDriver::getImplementationName_Static() throw(RuntimeExcept
Sequence< OUString > FirebirdDriver::getSupportedServiceNames_Static() throw (RuntimeException)
{
// TODO: add com.sun.star.sdbcx.Driver once all sdbc functionality is implemented
- Sequence< OUString > aSNS( 1 );
+ Sequence< OUString > aSNS( 2 );
aSNS[0] = OUString("com.sun.star.sdbc.Driver");
+ aSNS[0] = OUString("com.sun.star.sdbcx.Driver");
return aSNS;
}
@@ -167,6 +169,26 @@ sal_Int32 SAL_CALL FirebirdDriver::getMinorVersion( ) throw(RuntimeException)
return 0;
}
+//----- XDataDefinitionSupplier
+uno::Reference< XTablesSupplier > SAL_CALL FirebirdDriver::getDataDefinitionByConnection(
+ const uno::Reference< XConnection >& rxConnection)
+ throw(SQLException, RuntimeException)
+{
+ (void) rxConnection;
+ // TODO: IMPLEMENT ME
+ return 0;
+}
+
+uno::Reference< XTablesSupplier > SAL_CALL FirebirdDriver::getDataDefinitionByURL(
+ const OUString& rsURL,
+ const uno::Sequence< PropertyValue >& rInfo)
+ throw(SQLException, RuntimeException)
+{
+ (void) rsURL;
+ (void) rInfo;
+ // TODO: IMPLEMENT ME
+ return 0;
+}
namespace connectivity
{
diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx
index fcb0f57..545d98a 100644
--- a/connectivity/source/drivers/firebird/Driver.hxx
+++ b/connectivity/source/drivers/firebird/Driver.hxx
@@ -22,9 +22,10 @@
#include "Connection.hxx"
-#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <cppuhelper/compbase2.hxx>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <cppuhelper/compbase3.hxx>
namespace connectivity
{
@@ -37,7 +38,8 @@ namespace connectivity
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL FirebirdDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
- typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver,
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::sdbcx::XDataDefinitionSupplier,
::com::sun::star::lang::XServiceInfo > ODriver_BASE;
class FirebirdDriver : public ODriver_BASE
@@ -69,6 +71,19 @@ namespace connectivity
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XDataDefinitionSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >
+ SAL_CALL getDataDefinitionByConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& rxConnection)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >
+ SAL_CALL getDataDefinitionByURL(
+ const OUString& rsURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rInfo)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
};
}
commit 75b2c92cfbaafff09e4f6e40010e5bc876979794
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Thu Aug 8 08:16:41 2013 +0100
Improve exceptions in Statement.
Change-Id: Ib1915c143abee8c9162477da07462a68dd45e03c
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 7e4b5af..9a9f988 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -79,20 +79,15 @@ void OPreparedStatement::ensurePrepared()
m_pInSqlda->sqln = 10;
} // TODO: free this on closing
- aErr = prepareAndDescribeStatement(m_sSqlStatement,
- m_pOutSqlda,
- m_pInSqlda);
- if (aErr)
- {
- SAL_WARN("connectivity.firebird", "prepareAndDescribeStatement failed");
- }
- else if (m_aStatementHandle)
- {
- isc_dsql_describe_bind(m_statusVector,
- &m_aStatementHandle,
- 1,
+ prepareAndDescribeStatement(m_sSqlStatement,
+ m_pOutSqlda,
m_pInSqlda);
- }
+
+
+ aErr = isc_dsql_describe_bind(m_statusVector,
+ &m_aStatementHandle,
+ 1,
+ m_pInSqlda);
if (aErr)
{
diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx
index 3cf8c79..db44f51 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -110,24 +110,18 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
XSQLDA* pOutSqlda = 0;
- int aErr = 0;
+ ISC_STATUS aErr = 0;
- aErr = prepareAndDescribeStatement(sql,
- pOutSqlda);
+ prepareAndDescribeStatement(sql,
+ pOutSqlda);
+
+ aErr = isc_dsql_execute(m_statusVector,
+ &m_pConnection->getTransaction(),
+ &m_aStatementHandle,
+ 1,
+ NULL);
if (aErr)
- {
- SAL_WARN("connectivity.firebird", "prepareAndDescribeStatement failed");
- }
- else
- {
- aErr = isc_dsql_execute(m_statusVector,
- &m_pConnection->getTransaction(),
- &m_aStatementHandle,
- 1,
- NULL);
- if (aErr)
- SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
- }
+ SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
m_xResultSet = new OResultSet(m_pConnection,
uno::Reference< XInterface >(*this),
@@ -135,14 +129,11 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
pOutSqlda);
// TODO: deal with cleanup
-// close();
evaluateStatusVector(m_statusVector, sql, *this);
if (isDDLStatement(m_aStatementHandle))
- {
m_pConnection->commit();
- }
return m_xResultSet;
}
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index ee294fe..632962a 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -74,17 +74,9 @@ void OStatementCommonBase::freeStatementHandle()
isc_dsql_free_statement(m_statusVector,
&m_aStatementHandle,
DSQL_drop);
- try {
- 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);
- }
+ evaluateStatusVector(m_statusVector,
+ "isc_dsql_free_statement",
+ *this);
}
}
@@ -130,9 +122,10 @@ void SAL_CALL OStatementCommonBase::close()
dispose();
}
-int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
+void OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
XSQLDA*& pOutSqlda,
XSQLDA* pInSqlda)
+ throw (SQLException)
{
MutexGuard aGuard(m_pConnection->getMutex());
@@ -145,48 +138,43 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
pOutSqlda->sqln = 10;
}
- int aErr = 0;
+ ISC_STATUS aErr = 0;
aErr = isc_dsql_allocate_statement(m_statusVector,
&m_pConnection->getDBHandle(),
&m_aStatementHandle);
if (aErr)
- {
- SAL_WARN("connectivity.firebird", "isc_dsql_allocate_statement failed");
- return aErr;
- }
- else
- {
- aErr = isc_dsql_prepare(m_statusVector,
- &m_pConnection->getTransaction(),
- &m_aStatementHandle,
- 0,
- OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
- FIREBIRD_SQL_DIALECT,
- pInSqlda);
- }
+ evaluateStatusVector(m_statusVector,
+ "isc_dsql_allocate_statement",
+ *this);
+
+ aErr = isc_dsql_prepare(m_statusVector,
+ &m_pConnection->getTransaction(),
+ &m_aStatementHandle,
+ 0,
+ OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
+ FIREBIRD_SQL_DIALECT,
+ pInSqlda);
if (aErr)
- {
- SAL_WARN("connectivity.firebird", "isc_dsql_prepare failed");
- return aErr;
- }
- else
- {
- aErr = isc_dsql_describe(m_statusVector,
- &m_aStatementHandle,
- 1,
- pOutSqlda);
- }
+ evaluateStatusVector(m_statusVector,
+ "isc_dsql_prepare",
+ *this);
+
+ aErr = isc_dsql_describe(m_statusVector,
+ &m_aStatementHandle,
+ 1,
+ pOutSqlda);
+
- // Ensure we have enough space in pOutSqlda
if (aErr)
- {
- SAL_WARN("connectivity.firebird", "isc_dsql_describe failed");
- return aErr;
- }
- else if (!aErr && (pOutSqlda->sqld > pOutSqlda->sqln))
+ evaluateStatusVector(m_statusVector,
+ "isc_dsql_describe",
+ *this);
+
+ // Ensure we have enough space in pOutSqlda
+ if (pOutSqlda->sqld > pOutSqlda->sqln)
{
int n = pOutSqlda->sqld;
free(pOutSqlda);
@@ -200,16 +188,11 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
// Process each XSQLVAR parameter structure in the output XSQLDA
if (aErr)
- {
- SAL_WARN("connectivity.firebird","isc_dsql_describe failed when resizing pOutSqlda");
- return aErr;
- }
- else
- {
- mallocSQLVAR(pOutSqlda);
- }
+ evaluateStatusVector(m_statusVector,
+ "isc_dsql_describe",
+ *this);
- return aErr;
+ mallocSQLVAR(pOutSqlda);
}
// ---- XMultipleResults - UNSUPPORTED ----------------------------------------
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
index a64026e..db172fa 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
@@ -86,9 +86,12 @@ namespace connectivity
::com::sun::star::uno::Any& rValue,
sal_Int32 nHandle) const;
virtual ~OStatementCommonBase();
- int prepareAndDescribeStatement(const OUString& sqlIn,
- XSQLDA*& pOutSqlda,
- XSQLDA* pInSqlda=0);
+
+ void prepareAndDescribeStatement(const OUString& sqlIn,
+ XSQLDA*& pOutSqlda,
+ XSQLDA* pInSqlda=0)
+ throw (::com::sun::star::sdbc::SQLException);
+
bool isDDLStatement(isc_stmt_handle& aStatementHandle)
throw (::com::sun::star::sdbc::SQLException);
commit 6e11164d57c5f8be324e32f65a31b1112e65639f
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 7 22:37:59 2013 +0100
Explicit close/disposing.
Change-Id: Idcd89bd5f879a38f4c06f3602313672fb20bd098
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index da53c7a..7e4b5af 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -177,14 +177,14 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException)
{
- SAL_INFO("connectivity.firebird", "close()");
-
- MutexGuard aGuard( m_pConnection->getMutex() );
- checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
-
OStatementCommonBase::close();
}
+void SAL_CALL OPreparedStatement::disposing()
+{
+ close();
+}
+
void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex,
const OUString& x)
throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.hxx b/connectivity/source/drivers/firebird/PreparedStatement.hxx
index afb73d7..8d4a0e1 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.hxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.hxx
@@ -154,7 +154,12 @@ namespace connectivity
::com::sun::star::uno::RuntimeException);
// XCloseable
- virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL close()
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
// XResultSetMetaDataSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx
index ed63ea6..3cf8c79 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -181,4 +181,13 @@ uno::Sequence< Type > SAL_CALL OStatement::getTypes()
OStatementCommonBase::getTypes());
}
+void SAL_CALL OStatement::close() throw(SQLException, RuntimeException)
+{
+ OStatementCommonBase::close();
+}
+
+void SAL_CALL OStatement::disposing()
+{
+ close();
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/Statement.hxx b/connectivity/source/drivers/firebird/Statement.hxx
index 7f68aad..bfac534 100644
--- a/connectivity/source/drivers/firebird/Statement.hxx
+++ b/connectivity/source/drivers/firebird/Statement.hxx
@@ -77,6 +77,13 @@ namespace connectivity
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
getTypes()
throw(::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close()
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
};
}
commit 6044f52c5e34de55f1f07bf29519f0ed3b937516
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 7 21:58:31 2013 +0100
Improve statement handle handling.
Change-Id: I81809634600c580bb50843e697071d62bc6802a4
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index f391618..da53c7a 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -54,7 +54,6 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,
:OStatementCommonBase(_pConnection)
,m_aTypeInfo(_TypeInfo)
,m_sSqlStatement(sql)
- ,m_statementHandle(0)
,m_pOutSqlda(0)
,m_pInSqlda(0)
{
@@ -68,7 +67,7 @@ void OPreparedStatement::ensurePrepared()
MutexGuard aGuard(m_pConnection->getMutex());
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
- if (m_statementHandle)
+ if (m_aStatementHandle)
return;
ISC_STATUS aErr = 0;
@@ -81,17 +80,16 @@ void OPreparedStatement::ensurePrepared()
} // TODO: free this on closing
aErr = prepareAndDescribeStatement(m_sSqlStatement,
- m_statementHandle,
m_pOutSqlda,
m_pInSqlda);
if (aErr)
{
SAL_WARN("connectivity.firebird", "prepareAndDescribeStatement failed");
}
- else if (m_statementHandle)
+ else if (m_aStatementHandle)
{
isc_dsql_describe_bind(m_statusVector,
- &m_statementHandle,
+ &m_aStatementHandle,
1,
m_pInSqlda);
}
@@ -108,7 +106,7 @@ void OPreparedStatement::ensurePrepared()
m_pInSqlda->version = SQLDA_VERSION1;
m_pInSqlda->sqln = nItems;
isc_dsql_describe_bind(m_statusVector,
- &m_statementHandle,
+ &m_aStatementHandle,
1,
m_pInSqlda);
}
@@ -117,7 +115,7 @@ void OPreparedStatement::ensurePrepared()
// };
// char aResultBuffer[8];
// isc_dsql_sql_info(m_statusVector,
-// &m_statementHandle,
+// &m_aStatementHandle,
// sizeof(aItems),
// aItems,
// sizeof(aResultBuffer),
@@ -184,11 +182,6 @@ void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException)
MutexGuard aGuard( m_pConnection->getMutex() );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
- if (m_statementHandle)
- {
- // TODO: implement
- }
-
OStatementCommonBase::close();
}
@@ -265,7 +258,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
aErr = isc_dsql_execute(m_statusVector,
&m_pConnection->getTransaction(),
- &m_statementHandle,
+ &m_aStatementHandle,
1,
m_pInSqlda);
if (aErr)
@@ -276,7 +269,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
m_xResultSet = new OResultSet(m_pConnection,
uno::Reference< XInterface >(*this),
- m_statementHandle,
+ m_aStatementHandle,
m_pOutSqlda);
return m_xResultSet.is();
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.hxx b/connectivity/source/drivers/firebird/PreparedStatement.hxx
index 60d5c66..afb73d7 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.hxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.hxx
@@ -69,7 +69,6 @@ namespace connectivity
::rtl::OUString m_sSqlStatement;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
- isc_stmt_handle m_statementHandle;
XSQLDA* m_pOutSqlda;
XSQLDA* m_pInSqlda;
void checkParameterIndex(sal_Int32 nParameterIndex)
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index ad7fe81..921305f 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -265,21 +265,7 @@ void OResultSet::disposing(void)
MutexGuard aGuard(m_pConnection->getMutex());
- if (m_statementHandle)
- {
- isc_dsql_free_statement(m_statusVector,
- &m_statementHandle,
- DSQL_drop);
- try {
- 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);
- }
- }
+ // TODO: free the sqlda
m_xMetaData = NULL;
}
diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx
index 5317c43..ed63ea6 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -110,12 +110,9 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
XSQLDA* pOutSqlda = 0;
- isc_stmt_handle aStatementHandle = 0;
int aErr = 0;
-
aErr = prepareAndDescribeStatement(sql,
- aStatementHandle,
pOutSqlda);
if (aErr)
{
@@ -125,7 +122,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
{
aErr = isc_dsql_execute(m_statusVector,
&m_pConnection->getTransaction(),
- &aStatementHandle,
+ &m_aStatementHandle,
1,
NULL);
if (aErr)
@@ -134,7 +131,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
m_xResultSet = new OResultSet(m_pConnection,
uno::Reference< XInterface >(*this),
- aStatementHandle,
+ m_aStatementHandle,
pOutSqlda);
// TODO: deal with cleanup
@@ -142,7 +139,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
evaluateStatusVector(m_statusVector, sql, *this);
- if (isDDLStatement(aStatementHandle))
+ if (isDDLStatement(m_aStatementHandle))
{
m_pConnection->commit();
}
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index baf53ca..ee294fe 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -48,6 +48,7 @@ OStatementCommonBase::OStatementCommonBase(OConnection* _pConnection)
: OStatementCommonBase_Base(_pConnection->getMutex()),
OPropertySetHelper(OStatementCommonBase_Base::rBHelper),
m_pConnection(_pConnection),
+ m_aStatementHandle( 0 ),
rBHelper(OStatementCommonBase_Base::rBHelper)
{
m_pConnection->acquire();
@@ -65,6 +66,28 @@ void OStatementCommonBase::disposeResultSet()
m_xResultSet = uno::Reference< XResultSet>();
}
+void OStatementCommonBase::freeStatementHandle()
+ throw (SQLException)
+{
+ if (m_aStatementHandle)
+ {
+ isc_dsql_free_statement(m_statusVector,
+ &m_aStatementHandle,
+ DSQL_drop);
+ try {
+ 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);
+ }
+ }
+}
+
//-----------------------------------------------------------------------------
Any SAL_CALL OStatementCommonBase::queryInterface( const Type & rType ) throw(RuntimeException)
{
@@ -91,27 +114,30 @@ void SAL_CALL OStatementCommonBase::cancel( ) throw(RuntimeException)
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
// cancel the current sql statement
}
-// -------------------------------------------------------------------------
-void SAL_CALL OStatementCommonBase::close( ) throw(SQLException, RuntimeException)
+void SAL_CALL OStatementCommonBase::close()
+ throw(SQLException, RuntimeException)
{
- SAL_INFO("connectivity.firebird", "close().");
+ SAL_INFO("connectivity.firebird", "close");
{
MutexGuard aGuard(m_pConnection->getMutex());
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
disposeResultSet();
+ freeStatementHandle();
}
+
dispose();
}
int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
- isc_stmt_handle& aStatementHandle,
- XSQLDA*& pOutSqlda,
- XSQLDA* pInSqlda)
+ XSQLDA*& pOutSqlda,
+ XSQLDA* pInSqlda)
{
MutexGuard aGuard(m_pConnection->getMutex());
+ freeStatementHandle();
+
if (!pOutSqlda)
{
pOutSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(10));
@@ -123,7 +149,7 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
aErr = isc_dsql_allocate_statement(m_statusVector,
&m_pConnection->getDBHandle(),
- &aStatementHandle);
+ &m_aStatementHandle);
if (aErr)
{
@@ -134,7 +160,7 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
{
aErr = isc_dsql_prepare(m_statusVector,
&m_pConnection->getTransaction(),
- &aStatementHandle,
+ &m_aStatementHandle,
0,
OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
FIREBIRD_SQL_DIALECT,
@@ -149,7 +175,7 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
else
{
aErr = isc_dsql_describe(m_statusVector,
- &aStatementHandle,
+ &m_aStatementHandle,
1,
pOutSqlda);
}
@@ -167,7 +193,7 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
pOutSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(n));
pOutSqlda->version = SQLDA_VERSION1;
aErr = isc_dsql_describe(m_statusVector,
- &aStatementHandle,
+ &m_aStatementHandle,
1,
pOutSqlda);
}
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
index 0496b11..a64026e 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
@@ -61,9 +61,12 @@ namespace connectivity
OConnection* m_pConnection;
ISC_STATUS_ARRAY m_statusVector;
- protected:
+ isc_stmt_handle m_aStatementHandle;
+ protected:
void disposeResultSet();
+ void freeStatementHandle()
+ throw (::com::sun::star::sdbc::SQLException);
// OPropertyArrayUsageHelper
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
@@ -84,7 +87,6 @@ namespace connectivity
sal_Int32 nHandle) const;
virtual ~OStatementCommonBase();
int prepareAndDescribeStatement(const OUString& sqlIn,
- isc_stmt_handle& aStatementHandle,
XSQLDA*& pOutSqlda,
XSQLDA* pInSqlda=0);
bool isDDLStatement(isc_stmt_handle& aStatementHandle)
commit af0e281eed91238ddb2a77d51f9e7cb99b3a72d7
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 7 19:40:32 2013 +0100
Remove unnecessary duplication.
Change-Id: Ie7b507f477f7591f9198a1cba6506dd6adec1f1b
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index c91af92..ad7fe81 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -576,17 +576,6 @@ void SAL_CALL OResultSet::close() throw(SQLException, RuntimeException)
{
MutexGuard aGuard(m_pConnection->getMutex());
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
- ISC_STATUS_ARRAY aStatusVector;
- ISC_STATUS aErr;
- aErr = isc_dsql_free_statement(aStatusVector,
- &m_statementHandle,
- DSQL_drop);
- if (aErr)
- evaluateStatusVector(aStatusVector,
- "isc_dsql_free_statement",
- *this);
-
}
dispose();
}
More information about the Libreoffice-commits
mailing list