[Libreoffice-commits] core.git: 9 commits - connectivity/registry connectivity/source
Andrzej J.R. Hunt
andrzej at ahunt.org
Wed Aug 14 09:28:12 PDT 2013
connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu | 10 -
connectivity/source/drivers/firebird/Catalog.cxx | 6
connectivity/source/drivers/firebird/Columns.cxx | 38 -----
connectivity/source/drivers/firebird/Columns.hxx | 3
connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 49 +++++-
connectivity/source/drivers/firebird/Table.cxx | 74 ++++++++++
connectivity/source/drivers/firebird/Table.hxx | 33 ++++
connectivity/source/drivers/firebird/Util.cxx | 8 -
connectivity/source/drivers/firebird/Util.hxx | 9 -
9 files changed, 165 insertions(+), 65 deletions(-)
New commits:
commit 96336caac7880de89c2c46523c2857de2c41f318
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 17:07:12 2013 +0100
Remove unneeded/irrelevant driver options. (firebird-sdbc)
Change-Id: Id4ae127eb6e7ebe1caee50cc3e3636da4ce818b3
diff --git a/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu
index 1141deb..e7aa436 100644
--- a/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu
+++ b/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu
@@ -62,16 +62,6 @@
</node>
</node><!--Properties-->
<node oor:name="Features">
- <node oor:name="UseCatalogInSelect" oor:op="replace">
- <prop oor:name="Value" oor:type="xs:boolean">
- <value>false</value>
- </prop>
- </node>
- <node oor:name="UseSchemaInSelect" oor:op="replace">
- <prop oor:name="Value" oor:type="xs:boolean">
- <value>false</value>
- </prop>
- </node>
</node><!--Features-->
<node oor:name="MetaData">
</node>
commit 60cda25e1d75144bdf15cad7a3f90f9a9e5b1282
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 14:23:42 2013 +0100
Remove XRename support from XTable. (firebird-sdbc)
Firebird doesn't support the renaming of tables, hence we need
to disable the api to rename tables.
Change-Id: I86045697f684280c591979dad4fdea2dde0db4ba
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index 03d7657..56f46be 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -10,6 +10,7 @@
#include "Columns.hxx"
#include "Table.hxx"
+#include <comphelper/sequence.hxx>
#include <connectivity/TIndexes.hxx>
#include <connectivity/TKeys.hxx>
@@ -103,4 +104,40 @@ void SAL_CALL Table::alterColumnByName(const OUString& rColName,
m_pColumns->refresh();
// TODO: implement me
}
+
+// ----- XRename --------------------------------------------------------------
+void SAL_CALL Table::rename(const OUString& rName)
+ throw(SQLException, ElementExistException, RuntimeException)
+{
+ (void) rName;
+ throw RuntimeException(); // Firebird doesn't support this.
+}
+
+// ----- XInterface -----------------------------------------------------------
+Any SAL_CALL Table::queryInterface(const Type& rType)
+ throw(RuntimeException)
+{
+ if (rType.getTypeName() == "com.sun.star.sdbcx.XRename")
+ return Any();
+
+ return OTableHelper::queryInterface(rType);
+}
+
+// ----- XTypeProvider --------------------------------------------------------
+uno::Sequence< Type > SAL_CALL Table::getTypes()
+ throw(RuntimeException)
+{
+ uno::Sequence< Type > aTypes = OTableHelper::getTypes();
+
+ for (int i = 0; i < aTypes.getLength(); i++)
+ {
+ if (aTypes[i].getTypeName() == "com.sun.star.sdbcx.XRename")
+ {
+ ::comphelper::removeElementAt(aTypes, i);
+ break;
+ }
+ }
+
+ return OTableHelper::getTypes();
+}
/* 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 cfeaea1..6ee5e36 100644
--- a/connectivity/source/drivers/firebird/Table.hxx
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -19,6 +19,10 @@ namespace connectivity
namespace firebird
{
+ /**
+ * Implements sdbcx.Table. We don't support table renaming (XRename)
+ * hence the appropriate methods are overriden.
+ */
class Table: public OTableHelper
{
private:
@@ -52,6 +56,23 @@ namespace connectivity
::com::sun::star::container::NoSuchElementException,
::com::sun::star::uno::RuntimeException);
+ // XRename -- UNSUPPORTED
+ virtual void SAL_CALL rename(const ::rtl::OUString& sName)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::container::ElementExistException,
+ ::com::sun::star::uno::RuntimeException);
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any
+ SAL_CALL queryInterface(const ::com::sun::star::uno::Type & rType)
+ throw(::com::sun::star::uno::RuntimeException);
+
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
+ SAL_CALL getTypes()
+ throw(::com::sun::star::uno::RuntimeException);
+
+
};
} // namespace firebird
commit 488f62781e20ebe196ed9cb00a0d41ca00ee0808
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 12:27:37 2013 +0100
Refresh columns after alter. (firebird-sdbc)
Without this the column data isn't updated after a change, which can
lead to e.g. the UI getting confused and producing errors.
Change-Id: I69ed79bbb987799fea7ecbbb1e516f7f9328ef9f
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index 80f107c..03d7657 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -100,6 +100,7 @@ void SAL_CALL Table::alterColumnByName(const OUString& rColName,
getConnection()->createStatement()->execute(sSql);
}
+ m_pColumns->refresh();
// TODO: implement me
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
commit b174e1b733892778c9301d3b1f8d92573d317de5
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 12:25:43 2013 +0100
Implement column-name altering. (firebird-sdbc)
Change-Id: I93bdbd37976fe467459b7fb39c26f6637ea7e84e
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index 1cd9813..80f107c 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -21,7 +21,10 @@ using namespace ::osl;
using namespace ::rtl;
using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
Table::Table(Tables* pTables,
Mutex& rMutex,
@@ -66,4 +69,37 @@ OCollection* Table::createIndexes(const TStringVector& rNames)
rNames);
}
+//----- XAlterTable -----------------------------------------------------------
+void SAL_CALL Table::alterColumnByName(const OUString& rColName,
+ const uno::Reference< XPropertySet >& rDescriptor)
+ throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ uno::Reference< XPropertySet > xColumn(m_pColumns->getByName(rColName), UNO_QUERY);
+
+ // sdbcx::Descriptor
+ bool bNameChanged = xColumn->getPropertyValue("Name") != rDescriptor->getPropertyValue("Name");
+ // sdbcx::ColumnDescriptor
+// bool bTypeChanged = xColumn->getPropertyValue("Type") != rDescriptor->getPropertyValue("Type");
+// bool bTypeNameChanged = xColumn->getPropertyValue("TypeName") != rDescriptor->getPropertyValue("TypeName");
+// bool bPrecisionChanged = xColumn->getPropertyValue("Precision") != rDescriptor->getPropertyValue("Precision");
+// bool bScaleChanged = xColumn->getPropertyValue("Scale") != rDescriptor->getPropertyValue("Scale");
+// bool bIsNullableChanged = xColumn->getPropertyValue("IsNullable") != rDescriptor->getPropertyValue("IsNullable");
+// bool bIsAutoIncrementChanged = xColumn->getPropertyValue("IsAutoIncrement") != rDescriptor->getPropertyValue("IsAutoIncrement");
+ // TODO: remainder
+
+ if (bNameChanged)
+ {
+ OUString sNewTableName;
+ rDescriptor->getPropertyValue("Name") >>= sNewTableName;
+ OUString sSql("ALTER TABLE \"" + getName() + "\" ALTER COLUMN \""
+ + rColName + "\" TO \"" + sNewTableName + "\"");
+
+ getConnection()->createStatement()->execute(sSql);
+ }
+
+ // TODO: implement me
+}
/* 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 0ea4695..cfeaea1 100644
--- a/connectivity/source/drivers/firebird/Table.hxx
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -40,6 +40,18 @@ namespace connectivity
virtual ::connectivity::sdbcx::OCollection* createIndexes(
const ::connectivity::TStringVector& rNames);
+ // XAlterTable
+ /**
+ * See ::com::sun::star::sdbcx::ColumnDescriptor for details of
+ * rDescriptor.
+ */
+ virtual void SAL_CALL alterColumnByName(
+ const ::rtl::OUString& rColName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rDescriptor)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException);
+
};
} // namespace firebird
commit 5b0c06c291157a08de568735935f5f9f6c80ee83
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 12:18:29 2013 +0100
ColumnsHelper can create the Column for us. (firebird-sdbc)
Change-Id: Ia51394a701a06b6d6bc2cf6e9628cca9ce274821
diff --git a/connectivity/source/drivers/firebird/Columns.cxx b/connectivity/source/drivers/firebird/Columns.cxx
index fbf54e0..d53c4f3 100644
--- a/connectivity/source/drivers/firebird/Columns.cxx
+++ b/connectivity/source/drivers/firebird/Columns.cxx
@@ -9,8 +9,6 @@
#include "Columns.hxx"
-#include <connectivity/sdbcx/VColumn.hxx>
-
#include <com/sun/star/sdbc/XRow.hpp>
using namespace ::connectivity;
@@ -35,40 +33,4 @@ Columns::Columns(Table& rTable,
OColumnsHelper::setParent(&rTable);
}
-ObjectType Columns::createObject(const OUString& rColumnName)
-{
- uno::Reference< XResultSet > xColumns = m_pTable->getConnection()->getMetaData()->getColumns(
- Any(),
- "",
- m_pTable->getName(),
- rColumnName);
-
- uno::Reference< XRow > xRow(xColumns, UNO_QUERY);
-
- if(!xColumns.is() || !xRow.is() || !xColumns->next())
- throw RuntimeException();
-
- ObjectType xColumn(new OColumn(rColumnName, // Name
- xRow->getString(6), // Type Name
- xRow->getString(13), // Default Value
- xRow->getString(12), // Description
- xRow->getInt(11), // Nullable
- xRow->getInt(7), // Precision
- xRow->getInt(9), // Scale
- xRow->getInt(5), // Type
- sal_False, // TODO: AutoIncrement
- // Might need a call to getTypes to determine autoincrement
- sal_False, // TODO: IsRowVersion?
- sal_False, // IsCurrency -- same as autoincrement
- sal_True, // Case sensitivity: yes
- "",
- "",
- m_pTable->getName()));
-
- if (xColumns->next())
- throw RuntimeException(); // There should only be one column retrieved
-
- return xColumn;
-}
-
/* 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
index dc006d1..f6ec64f 100644
--- a/connectivity/source/drivers/firebird/Columns.hxx
+++ b/connectivity/source/drivers/firebird/Columns.hxx
@@ -25,9 +25,6 @@ namespace connectivity
::osl::Mutex& rMutex,
const ::connectivity::TStringVector &_rVector);
- // OColumnsHelper
- virtual ::connectivity::sdbcx::ObjectType createObject(
- const ::rtl::OUString& rName);
};
} // namespace firebird
commit 2594878f706ffabb60cdc616bb7245bd5e5d41a9
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 10:03:42 2013 +0100
Correct negation to detect view. (firebird-sdbc)
Change-Id: I24e1bab96e9890bbe32a7e2f3edf8ed1ec15ef92
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 9e48385..664144e 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1407,7 +1407,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
sal_Int16 nSystemFlag = xRow->getShort(2);
sal_Int16 nTableType = xRow->getShort(3);
xRow->getBlob(5); // We have to retrieve a column to verify it is null.
- sal_Bool aIsView = xRow->wasNull();
+ sal_Bool aIsView = !xRow->wasNull();
OUString sTableType;
if (nSystemFlag == 1)
commit 324388fd1c53115c7fa3fd603002643346e3e3f1
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 09:56:06 2013 +0100
Trim sql identifiers as needed. (firebird-sdbc)
Change-Id: Ib61897ff2f5b459f5f6c75726be22ed99d383ec3
diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx
index 78c0377..cc8f5d7 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -19,10 +19,12 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
-void firebird::sanitizeIdentifier(OUString& rIdentifier)
+OUString& firebird::sanitizeIdentifier(OUString& rIdentifier)
{
- if (rIdentifier.getLength() > 31)
- rIdentifier = rIdentifier.copy(0, 31);
+ rIdentifier = rIdentifier.trim();
+ assert(rIdentifier.getLength() <= 31); // Firebird identifiers cannot be longer than this.
+
+ return rIdentifier;
}
void firebird::evaluateStatusVector(ISC_STATUS_ARRAY& aStatusVector,
diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx
index fcd34bf..9818482 100644
--- a/connectivity/source/drivers/firebird/Util.hxx
+++ b/connectivity/source/drivers/firebird/Util.hxx
@@ -25,10 +25,13 @@ namespace connectivity
/**
* Make sure an identifier is safe to use within the databse. Currently
* firebird seems to return identifiers with 93 character (instead of
- * 31). Use this to avoid issues when using the identifier in other
- * sql queries.
+ * 31), whereby the name is simply padded with trailing whitespace.
+ * This removes all trailing whitespace (i.e. if necessary so that
+ * the length is below 31 characters). Firebird automatically compensates
+ * for such shorter strings, however any trailing padding makes the gui
+ * editing of such names harder, hence we remove all trailing whitespace.
*/
- void sanitizeIdentifier(::rtl::OUString& rIdentifier);
+ ::rtl::OUString& sanitizeIdentifier(::rtl::OUString& rIdentifier);
/**
* Evaluate a firebird status vector and throw exceptions as necessary.
commit c73286f83c64b5216ee430c72a412a2903eee16b
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 09:30:52 2013 +0100
Use table type in getTables. (firebird-sdbc)
Change-Id: I78dc0afed58ad7dc51c64cac8c89abcda601f8b5
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index f4bf92a..9e48385 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1322,8 +1322,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
{
(void) catalog;
(void) schemaPattern;
- (void) types;
- // TODO: implement types
+
SAL_INFO("connectivity.firebird", "getTables() with "
"TableNamePattern: " << tableNamePattern);
@@ -1335,10 +1334,38 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
static const OUString wld("%");
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, "
+ "RDB$VIEW_BLR "
"FROM RDB$RELATIONS "
- "WHERE (RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1)");
+ "WHERE ");
+
+ // TODO: GLOBAL TEMPORARY, LOCAL TEMPORARY, ALIAS, SYNONYM
+ if ((types.getLength() == 0) || (types.getLength() == 1 && types[0].match(wld)))
+ {
+ // All table types? I.e. includes system tables.
+ queryBuf.append("(RDB$RELATION_TYPE = 0 OR RDB$RELATION_TYPE = 1) ");
+ }
+ else
+ {
+ for (int i = 0; i < types.getLength(); i++)
+ {
+ if (i)
+ queryBuf.append("OR ");
+
+ if (types[i] == "SYSTEM TABLE")
+ queryBuf.append("(RDB$SYSTEM_FLAG = 1 AND RDB$VIEW_BLR IS NULL) ");
+ else if (types[i] == "TABLE")
+ queryBuf.append("(RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NULL) ");
+ else if (types[i] == "VIEW")
+ queryBuf.append("(RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_BLR IS NOT NULL) ");
+ else
+ throw SQLException(); // TODO: implement other types, see above.
+
+ }
+ }
if (!tableNamePattern.isEmpty())
{
@@ -1350,6 +1377,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
queryBuf.append(sAppend.replaceAll(wld, tableNamePattern));
}
+
+
+
queryBuf.append(" ORDER BY RDB$RELATION_TYPE, RDB$RELATION_NAME");
OUString query = queryBuf.makeStringAndClear();
@@ -1373,20 +1403,25 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
}
// 4. TABLE_TYPE
{
+ // TODO: check this as the docs are a bit unclear.
sal_Int16 nSystemFlag = xRow->getShort(2);
sal_Int16 nTableType = xRow->getShort(3);
+ xRow->getBlob(5); // We have to retrieve a column to verify it is null.
+ sal_Bool aIsView = xRow->wasNull();
OUString sTableType;
if (nSystemFlag == 1)
{
sTableType = "SYSTEM TABLE";
}
+ else if (aIsView)
+ {
+ sTableType = "VIEW";
+ }
else
{
if (nTableType == 0)
sTableType = "TABLE";
- else
- sTableType = "VIEW";
}
aCurrentRow[4] = new ORowSetValueDecorator(sTableType);
commit 0506b35c50eddb010097b1359295da2ba6fd3ee1
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Aug 14 08:49:54 2013 +0100
Avoid selecting system tables for viewing. (firebird-sdbc)
Change-Id: I43816cbb345fa141f845da208a06ed9eb9a5303a
diff --git a/connectivity/source/drivers/firebird/Catalog.cxx b/connectivity/source/drivers/firebird/Catalog.cxx
index 0f84c94..4a0700d 100644
--- a/connectivity/source/drivers/firebird/Catalog.cxx
+++ b/connectivity/source/drivers/firebird/Catalog.cxx
@@ -28,10 +28,14 @@ Catalog::Catalog(const uno::Reference< XConnection >& rConnection):
void Catalog::refreshTables()
{
// TODO: set type -- currenty we also get system tables...
+ Sequence< OUString > aTypes(2);
+ aTypes[0] = "TABLE";
+ aTypes[1] = "VIEW";
+
uno::Reference< XResultSet > xTables = m_xMetaData->getTables(Any(),
"%",
"%",
- Sequence< OUString >());
+ aTypes);
TStringVector aTableNames;
More information about the Libreoffice-commits
mailing list