summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-12 15:09:22 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-12 15:09:22 +0100
commit7cc42f51e9ab152feb3c959fb2e412bc23440cf9 (patch)
treefb14c1750231b05ac4c46d143eb8ff3e93e4d7dc
parentCleanup firebird build files. (diff)
downloadcore-feature/firebird-sdbc2.tar.gz
core-feature/firebird-sdbc2.zip
Implement first part of FDatabaseMetaData. feature/firebird-sdbc2
Change-Id: I6dae1f2ecf265333c121f419c0041dd7525efa9e
-rw-r--r--connectivity/source/drivers/firebird/FConnection.cxx17
-rw-r--r--connectivity/source/drivers/firebird/FConnection.hxx6
-rw-r--r--connectivity/source/drivers/firebird/FDatabaseMetaData.cxx232
3 files changed, 128 insertions, 127 deletions
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 0735d24f770d..d506d29c9680 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -89,7 +89,8 @@ OConnection::OConnection(FirebirdDriver* _pDriver)
OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
m_xMetaData(NULL),
m_bIsEmbedded(sal_False),
- m_aURL(),
+ m_sConnectionURL(),
+ m_sURL(),
m_sUser(),
m_pDriver(_pDriver),
m_bClosed(sal_False),
@@ -147,6 +148,8 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
osl_atomic_increment( &m_refCount );
+ m_sConnectionURL = url;
+
bool bIsNewDatabase = false;
OUString aStorageURL;
if (url.equals("sdbc:embedded:firebird"))
@@ -176,10 +179,10 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
bIsNewDatabase = !m_xEmbeddedStorage->hasElements();
- m_aURL = utl::TempFile::CreateTempName() + ".fdb";
+ m_sURL = utl::TempFile::CreateTempName() + ".fdb";
SAL_INFO("connectivity.firebird", "Temporary .fdb location: "
- << OUStringToOString(m_aURL,RTL_TEXTENCODING_UTF8 ).getStr());
+ << OUStringToOString(m_sURL,RTL_TEXTENCODING_UTF8 ).getStr());
if (!bIsNewDatabase)
{
SAL_INFO("connectivity.firebird", "Extracting .fdb from .odb" );
@@ -204,7 +207,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
::dbtools::throwGenericSQLException(sMessage ,*this);
}
try {
- xFileAccess->writeFile(m_aURL,xDBStream->getInputStream());
+ xFileAccess->writeFile(m_sURL,xDBStream->getInputStream());
}
catch (...)
{
@@ -224,7 +227,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
if (bIsNewDatabase)
{
- if (isc_create_database(status, m_aURL.getLength(), OUStringToOString(m_aURL, RTL_TEXTENCODING_UTF8).getStr(),
+ if (isc_create_database(status, m_sURL.getLength(), OUStringToOString(m_sURL, RTL_TEXTENCODING_UTF8).getStr(),
&m_DBHandler, 0, NULL, 0))
{
if(pr_error(status, "create new database"))
@@ -233,7 +236,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
}
else
{
- if (isc_attach_database(status, m_aURL.getLength(), OUStringToOString(m_aURL, RTL_TEXTENCODING_UTF8).getStr(),
+ if (isc_attach_database(status, m_sURL.getLength(), OUStringToOString(m_sURL, RTL_TEXTENCODING_UTF8).getStr(),
&m_DBHandler, 0, NULL))
if (pr_error(status, "attach database"))
return;
@@ -577,7 +580,7 @@ void SAL_CALL OConnection::documentEventOccured( const DocumentEvent& _Event )
Reference< XInputStream > xInputStream;
if (xContext.is())
xInputStream =
- OStorageHelper::GetInputStreamFromURL(m_aURL, xContext);
+ OStorageHelper::GetInputStreamFromURL(m_sURL, xContext);
if (xInputStream.is())
OStorageHelper::CopyInputToOutput( xInputStream,
xDBStream->getOutputStream());
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index e91aef66d4f9..1e5168f19b65 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -99,7 +99,8 @@ namespace connectivity
::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
// an operation
sal_Bool m_bIsEmbedded;
- ::rtl::OUString m_aURL; // URL of connection
+ ::rtl::OUString m_sConnectionURL;
+ ::rtl::OUString m_sURL; // URL of connection
// or file path
::rtl::OUString m_sUser; // the user name
FirebirdDriver* m_pDriver; // Pointer to the owning
@@ -170,6 +171,9 @@ namespace connectivity
inline isc_db_handle getDBHandler() const { return m_DBHandler; }
inline FirebirdDriver* getDriver() const { return m_pDriver;}
inline rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; }
+
+ ::rtl::OUString getConnectionURL() const { return m_sConnectionURL; }
+ sal_Bool isEmbedded() const { return m_bIsEmbedded; }
};
}
}
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 0bdcc17c835f..5ea1aacddb78 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -42,6 +42,10 @@
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
+#include <gen/autoconfig.h>
+#include <fb_types.h>
+#include <constants.h>
+
using namespace connectivity::firebird;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
@@ -68,78 +72,111 @@ ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
ODatabaseMetaData::~ODatabaseMetaData()
{
}
-// -------------------------------------------------------------------------
-::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException)
+
+//----- Catalog Info ---------------------------------------------------------
+OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator() throw(SQLException, RuntimeException)
{
- ::rtl::OUString aVal;
+ return OUString();
+}
- return aVal;
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength() throw(SQLException, RuntimeException)
+{
+ return 0;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+
+OUString SAL_CALL ODatabaseMetaData::getCatalogTerm() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return OUString();
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return 0;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+
+//----- Max Sizes/Lengths -----------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return MAX_COLUMN_SIZE;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return MAX_COLUMN_SIZE;
}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength() throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return MAX_COLUMN_SIZE;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength() throw(SQLException, RuntimeException)
+{
+ return MAX_SQL_IDENTIFIER_SIZE;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex() throw(SQLException, RuntimeException)
+{
+ // No idea.
+ // See: http://www.firebirdsql.org/en/firebird-technical-specifications/
+ return MAX_INDEX_SEGMENTS;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength() throw(SQLException, RuntimeException)
+{
+ return MAX_SQL_IDENTIFIER_SIZE;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections() throw(SQLException, RuntimeException)
+{
+ return 100; // Arbitrary
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable() throw(SQLException, RuntimeException)
+{
+ // May however be smaller.
+ // See: http://www.firebirdsql.org/en/firebird-technical-specifications/
+ return MAX_COLUMN_SIZE;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength() throw(SQLException, RuntimeException)
+{
+ return MAX_COLUMN_SIZE;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength() throw(SQLException, RuntimeException)
+{
+ return MAX_SQL_IDENTIFIER_SIZE;
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException)
@@ -205,12 +242,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLExc
return sal_False;
}
// -------------------------------------------------------------------------
-::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
-{
- ::rtl::OUString aVal;
- return aVal;
-}
-// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException)
{
// normally this is "
@@ -229,12 +260,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( )
return sal_False;
}
// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException)
-{
- sal_Bool bValue = sal_False;
- return bValue;
-}
-// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
{
return sal_True;
@@ -320,21 +345,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions( ) throw
return sal_False;
}
// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException)
-{
- return sal_False;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
-{
- return sal_False;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
-{
- return sal_False;
-}
-// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
{
return sal_False;
@@ -357,20 +367,20 @@ sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLExcept
sal_Int32 nValue = 0; // 0 means no limit
return nValue;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
{
return sal_False;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
@@ -385,14 +395,14 @@ sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLExcepti
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return m_pConnection->isReadOnly();
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return m_pConnection->isEmbedded();
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
{
return sal_False;
@@ -427,25 +437,27 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLE
{
return sal_False;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ // Unsure
+ return sal_True;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
{
+ // Unsure
return sal_False;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
@@ -462,15 +474,15 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLExcep
{
return sal_False;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
-// -------------------------------------------------------------------------
+
sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
@@ -513,16 +525,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) t
return sal_False;
}
// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
-{
- return sal_False;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
-{
- return sal_False;
-}
-// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
{
return sal_False;
@@ -552,12 +554,10 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQL
{
return sal_False;
}
-// -------------------------------------------------------------------------
-::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+
+OUString SAL_CALL ODatabaseMetaData::getURL() throw(SQLException, RuntimeException)
{
- // TODO: return actual URL as necessary
- ::rtl::OUString aValue("sdbc:embedded:firebird");
- return aValue;
+ return m_pConnection->getConnectionURL();
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
@@ -694,8 +694,7 @@ sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLExcepti
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
{
- sal_Int32 nValue = 0; // 0 means no limit
- return nValue;
+ return USERNAME_LENGTH;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
@@ -757,10 +756,10 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException
{
return sal_False;
}
-// -------------------------------------------------------------------------
-Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException)
+
+Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection() throw(SQLException, RuntimeException)
{
- return (Reference< XConnection >)m_pConnection;//new OConnection(m_aConnectionHandle);
+ return (Reference< XConnection >) m_pConnection;
}
// -------------------------------------------------------------------------
// here follow all methods which return a resultset
@@ -814,11 +813,6 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLExc
pResultSet->setRows(aRows);
return xResultSet;
}
-// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
-{
- return NULL;
-}
// -----------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
{