LibreOffice Module connectivity (master) 1
Public Member Functions | Private Attributes | List of all members
dbtools::DatabaseMetaData Class Reference

encapsulates meta data about a database/connection which cannot be obtained from the usual XDatabaseMetaData result set. More...

#include <dbmetadata.hxx>

Public Member Functions

 DatabaseMetaData ()
 
 DatabaseMetaData (const css::uno::Reference< css::sdbc::XConnection > &_connection)
 constructs a DatabaseMetaData instance More...
 
 DatabaseMetaData (const DatabaseMetaData &_copyFrom)
 
DatabaseMetaDataoperator= (const DatabaseMetaData &_copyFrom)
 
 DatabaseMetaData (DatabaseMetaData &&_copyFrom) noexcept
 
DatabaseMetaDataoperator= (DatabaseMetaData &&_copyFrom) noexcept
 
 ~DatabaseMetaData ()
 
bool isConnected () const
 determines whether or not the instances is based on a valid connection More...
 
void reset (const css::uno::Reference< css::sdbc::XConnection > &_connection)
 resets the instance so that it's based on a new connection More...
 
const OUString & getIdentifierQuoteString () const
 wraps XDatabaseMetaData::getIdentifierQuoteString More...
 
const OUString & getCatalogSeparator () const
 wraps XDatabaseMetaData::getCatalogSeparator More...
 
bool supportsSubqueriesInFrom () const
 determines whether the database supports sub queries in the FROM part of a SELECT clause are supported. More...
 
bool supportsPrimaryKeys () const
 checks whether the database supports primary keys More...
 
bool restrictIdentifiersToSQL92 () const
 determines whether names in the database should be restricted to SQL-92 identifiers More...
 
bool generateASBeforeCorrelationName () const
 determines whether when generating SQL statements, an AS keyword should be generated before a correlation name. More...
 
bool shouldEscapeDateTime () const
 should date time be escaped like '2001-01-01' => {D '2001-01-01' } More...
 
bool shouldSubstituteParameterNames () const
 should named parameters (:foo, [foo]) be replaced by unnamed parameters (?) More...
 
bool isAutoIncrementPrimaryKey () const
 auto increment columns should be automatically used as primary key. More...
 
sal_Int32 getBooleanComparisonMode () const
 determines the syntax to use for boolean comparison predicates More...
 
bool supportsRelations () const
 determines in relations are supported. More...
 
bool supportsColumnAliasInOrderBy () const
 determines if column alias names can be used in the order by clause. More...
 
bool supportsUserAdministration (const css::uno::Reference< css::uno::XComponentContext > &_rContext) const
 determines whether user administration is supported for the database More...
 
bool displayEmptyTableFolders () const
 determines whether in the application UI, empty table folders (aka catalogs/schemas) should be displayed More...
 
bool supportsThreads () const
 determines that threads are supported. More...
 

Private Attributes

::std::unique_ptr< DatabaseMetaData_Implm_pImpl
 

Detailed Description

encapsulates meta data about a database/connection which cannot be obtained from the usual XDatabaseMetaData result set.

Meta data perhaps isn't really the right term ... Some of the methods in this class involved heuristics, some are just a convenient wrapper around more complex ways to obtain the same information.

Definition at line 49 of file dbmetadata.hxx.

Constructor & Destructor Documentation

◆ DatabaseMetaData() [1/4]

dbtools::DatabaseMetaData::DatabaseMetaData ( )

Definition at line 168 of file dbmetadata.cxx.

References m_pImpl.

◆ DatabaseMetaData() [2/4]

dbtools::DatabaseMetaData::DatabaseMetaData ( const css::uno::Reference< css::sdbc::XConnection > &  _connection)

constructs a DatabaseMetaData instance

Parameters
_rxConnectionis the connection whose meta data you're interested in. Note that some of the information provided by this class can only be obtained if this connection denotes an application-level connection, i.e. supports the com.sun.star.sdb.Connection service.
Exceptions
css::lang::IllegalArgumentExceptionif the given connection is not <NULL>, but the XDatabaseMetaData provided by it are <NULL>
css::sdbc::SQLExceptionif obtaining the meta data from the connection throws an SQLException
css::uno::RuntimeExceptionif obtaining the meta data from the connection throws a RuntimeException

◆ DatabaseMetaData() [3/4]

dbtools::DatabaseMetaData::DatabaseMetaData ( const DatabaseMetaData _copyFrom)

Definition at line 180 of file dbmetadata.cxx.

References m_pImpl.

◆ DatabaseMetaData() [4/4]

dbtools::DatabaseMetaData::DatabaseMetaData ( DatabaseMetaData &&  _copyFrom)
noexcept

Definition at line 185 of file dbmetadata.cxx.

References m_pImpl.

◆ ~DatabaseMetaData()

dbtools::DatabaseMetaData::~DatabaseMetaData ( )

Definition at line 205 of file dbmetadata.cxx.

Member Function Documentation

◆ displayEmptyTableFolders()

bool dbtools::DatabaseMetaData::displayEmptyTableFolders ( ) const

determines whether in the application UI, empty table folders (aka catalogs/schemas) should be displayed

Definition at line 400 of file dbmetadata.cxx.

References Any, DBG_UNHANDLED_EXCEPTION, Exception, m_pImpl, and SAL_WARN.

◆ generateASBeforeCorrelationName()

bool dbtools::DatabaseMetaData::generateASBeforeCorrelationName ( ) const

determines whether when generating SQL statements, an AS keyword should be generated before a correlation name.

E.g., it determines whether SELECT * FROM table AS correlation_name or SELECT * FROM table correlation_name is generated.

Definition at line 282 of file dbmetadata.cxx.

References Any, m_pImpl, and SAL_WARN.

Referenced by connectivity::OSQLParseNode::impl_parseNodeToString_throw().

◆ getBooleanComparisonMode()

sal_Int32 dbtools::DatabaseMetaData::getBooleanComparisonMode ( ) const

determines the syntax to use for boolean comparison predicates

See also
css::sdb::BooleanComparisonMode

Definition at line 322 of file dbmetadata.cxx.

References Any, m_pImpl, mode, and SAL_WARN.

◆ getCatalogSeparator()

const OUString & dbtools::DatabaseMetaData::getCatalogSeparator ( ) const

wraps XDatabaseMetaData::getCatalogSeparator

Definition at line 263 of file dbmetadata.cxx.

References m_pImpl.

Referenced by connectivity::OSQLParseNode::parseLeaf().

◆ getIdentifierQuoteString()

const OUString & dbtools::DatabaseMetaData::getIdentifierQuoteString ( ) const

wraps XDatabaseMetaData::getIdentifierQuoteString

Definition at line 257 of file dbmetadata.cxx.

References m_pImpl.

Referenced by connectivity::OSQLParseNode::impl_parseTableNameNodeToString_throw(), and connectivity::OSQLParseNode::parseLeaf().

◆ isAutoIncrementPrimaryKey()

bool dbtools::DatabaseMetaData::isAutoIncrementPrimaryKey ( ) const

auto increment columns should be automatically used as primary key.

Definition at line 312 of file dbmetadata.cxx.

References Any, m_pImpl, and SAL_WARN.

◆ isConnected()

bool dbtools::DatabaseMetaData::isConnected ( ) const

determines whether or not the instances is based on a valid connection

As long as this method returns true<TRUE>, you should expect all other methods throwing an SQLException when called.

Definition at line 209 of file dbmetadata.cxx.

References m_pImpl.

◆ operator=() [1/2]

DatabaseMetaData & dbtools::DatabaseMetaData::operator= ( const DatabaseMetaData _copyFrom)

Definition at line 190 of file dbmetadata.cxx.

References m_pImpl.

◆ operator=() [2/2]

DatabaseMetaData & dbtools::DatabaseMetaData::operator= ( DatabaseMetaData &&  _copyFrom)
noexcept

Definition at line 199 of file dbmetadata.cxx.

References m_pImpl.

◆ reset()

void dbtools::DatabaseMetaData::reset ( const css::uno::Reference< css::sdbc::XConnection > &  _connection)
inline

resets the instance so that it's based on a new connection

Definition at line 90 of file dbmetadata.hxx.

◆ restrictIdentifiersToSQL92()

bool dbtools::DatabaseMetaData::restrictIdentifiersToSQL92 ( ) const

determines whether names in the database should be restricted to SQL-92 identifiers

Effectively, this method checks the EnableSQL92Check property of the data source settings, if present.

Definition at line 269 of file dbmetadata.cxx.

References Any, m_pImpl, and SAL_WARN.

◆ shouldEscapeDateTime()

bool dbtools::DatabaseMetaData::shouldEscapeDateTime ( ) const

should date time be escaped like '2001-01-01' => {D '2001-01-01' }

Definition at line 292 of file dbmetadata.cxx.

References Any, m_pImpl, and SAL_WARN.

Referenced by connectivity::OSQLParseNode::addDateValue().

◆ shouldSubstituteParameterNames()

bool dbtools::DatabaseMetaData::shouldSubstituteParameterNames ( ) const

should named parameters (:foo, [foo]) be replaced by unnamed parameters (?)

Definition at line 302 of file dbmetadata.cxx.

References Any, m_pImpl, and SAL_WARN.

Referenced by connectivity::OSQLParseNode::impl_parseNodeToString_throw().

◆ supportsColumnAliasInOrderBy()

bool dbtools::DatabaseMetaData::supportsColumnAliasInOrderBy ( ) const

determines if column alias names can be used in the order by clause.

Returns
<TRUE> when relations are supported, otherwise <FALSE>

Definition at line 360 of file dbmetadata.cxx.

References Any, m_pImpl, and SAL_WARN.

◆ supportsPrimaryKeys()

bool dbtools::DatabaseMetaData::supportsPrimaryKeys ( ) const

checks whether the database supports primary keys

Since there's no dedicated API to ask a database for this, a heuristics needs to be applied. First, the PrimaryKeySupport settings of the data source is examined. If it is <TRUE> or <FALSE>, then value is returned. If it is <NULL>, then the database meta data are examined for support of core SQL grammar, and the result is returned. The assumption is that a database/driver which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience shows this is true most of the time.

Definition at line 235 of file dbmetadata.cxx.

References Any, DBG_UNHANDLED_EXCEPTION, Exception, and m_pImpl.

◆ supportsRelations()

bool dbtools::DatabaseMetaData::supportsRelations ( ) const

determines in relations are supported.

Returns
<TRUE> when relations are supported, otherwise <FALSE>

Definition at line 332 of file dbmetadata.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, and m_pImpl.

◆ supportsSubqueriesInFrom()

bool dbtools::DatabaseMetaData::supportsSubqueriesInFrom ( ) const

determines whether the database supports sub queries in the FROM part of a SELECT clause are supported.

Exceptions
css::sdbc::SQLExceptionwith SQLState 08003 (connection does not exist) if the instances was default-constructed and does not have a connection, yet.

Definition at line 215 of file dbmetadata.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, and m_pImpl.

Referenced by connectivity::OSQLParseTreeIteratorImpl::OSQLParseTreeIteratorImpl(), and connectivity::OSQLParseNode::parseNodeToExecutableStatement().

◆ supportsThreads()

bool dbtools::DatabaseMetaData::supportsThreads ( ) const

determines that threads are supported.

Returns
<TRUE> when threads are supported, otherwise <FALSE>

Definition at line 423 of file dbmetadata.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, and m_pImpl.

◆ supportsUserAdministration()

bool dbtools::DatabaseMetaData::supportsUserAdministration ( const css::uno::Reference< css::uno::XComponentContext > &  _rContext) const

determines whether user administration is supported for the database

User administration support is controlled by the availability of the XUsersSupplier interface, and it returning a non-NULL users container.

Parameters
_rContextthe component context we operate in. Might be needed to create the css.sdbc.DriverManager instance.

Definition at line 371 of file dbmetadata.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, and m_pImpl.

Member Data Documentation

◆ m_pImpl

::std::unique_ptr< DatabaseMetaData_Impl > dbtools::DatabaseMetaData::m_pImpl
private

The documentation for this class was generated from the following files: