summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-12-17 17:25:59 +0100
committerOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-12-17 17:25:59 +0100
commit898d0a4770a37226f3215fd069c7ec25370c3726 (patch)
treeb98c9d6bb27befda1a52637b6c3f8fb9cffff160 /connectivity
parentd7bee45fb0d3178bcf4bfe52fddd9e2b73735ee8 (diff)
parent55988d12e9edbdabd2a6b9b83c995e787d07b940 (diff)
Automated merge with http://hg.services.openoffice.org/cws/dba33e
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/inc/connectivity/TTableHelper.hxx9
-rw-r--r--connectivity/inc/connectivity/dbtools.hxx27
-rw-r--r--connectivity/source/commontools/TIndexes.cxx154
-rw-r--r--connectivity/source/commontools/TKeys.cxx154
-rw-r--r--connectivity/source/commontools/TTableHelper.cxx109
-rw-r--r--connectivity/source/commontools/dbtools2.cxx32
-rwxr-xr-xconnectivity/source/drivers/ado/ado.xcu5
7 files changed, 318 insertions, 172 deletions
diff --git a/connectivity/inc/connectivity/TTableHelper.hxx b/connectivity/inc/connectivity/TTableHelper.hxx
index d1c2cd331ada..f9384333930d 100644
--- a/connectivity/inc/connectivity/TTableHelper.hxx
+++ b/connectivity/inc/connectivity/TTableHelper.hxx
@@ -36,6 +36,10 @@
#include "connectivity/sdbcx/VKey.hxx"
#include "connectivity/StdTypeDefs.hxx"
#include <comphelper/stl_types.hxx>
+#include <com/sun/star/sdb/tools/XTableRename.hpp>
+#include <com/sun/star/sdb/tools/XTableAlteration.hpp>
+#include <com/sun/star/sdb/tools/XKeyAlteration.hpp>
+#include <com/sun/star/sdb/tools/XIndexAlteration.hpp>
namespace connectivity
{
@@ -158,6 +162,11 @@ namespace connectivity
void addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties);
virtual ::rtl::OUString getTypeCreatePattern() const;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableRename> getRenameService() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableAlteration> getAlterService() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XKeyAlteration> getKeyService() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XIndexAlteration> getIndexService() const;
};
}
#endif // CONNECTIVITY_TABLEHELPER_HXX
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx
index 32ef3bcb7da1..29bb9d0641d8 100644
--- a/connectivity/inc/connectivity/dbtools.hxx
+++ b/connectivity/inc/connectivity/dbtools.hxx
@@ -353,6 +353,33 @@ namespace dbtools
,const ::rtl::OUString& _sProperty,
sal_Bool _bDefault = sal_False);
+ /** retrieves a particular indirect data source setting
+
+ @param _rxDataSource
+ a data source component
+ @param _pAsciiSettingsName
+ the ASCII name of the setting to obtain
+ @param _rSettingsValue
+ the value of the setting, upon successfull return
+
+ @return
+ <FALSE/> if the setting is not present in the <member scope="com::sun::star::sdb">DataSource::Info</member>
+ member of the data source
+ <TRUE/> otherwise
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ bool getDataSourceSetting(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
+ const sal_Char* _pAsciiSettingsName,
+ ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
+ );
+ OOO_DLLPUBLIC_DBTOOLS
+ bool getDataSourceSetting(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
+ const ::rtl::OUString& _sSettingsName,
+ ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
+ );
+
OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getDefaultReportEngineServiceName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
/** quote the given name with the given quote string.
diff --git a/connectivity/source/commontools/TIndexes.cxx b/connectivity/source/commontools/TIndexes.cxx
index cf17b7a51411..c07e3e302f9a 100644
--- a/connectivity/source/commontools/TIndexes.cxx
+++ b/connectivity/source/commontools/TIndexes.cxx
@@ -143,73 +143,80 @@ sdbcx::ObjectType OIndexesHelper::appendObject( const ::rtl::OUString& _rForName
if ( m_pTable->isNew() )
return cloneDescriptor( descriptor );
- ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
- ::rtl::OUStringBuffer aSql( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE ")));
- ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
- ::rtl::OUString aDot = ::rtl::OUString::createFromAscii(".");
+ if ( m_pTable->getIndexService().is() )
+ {
+ m_pTable->getIndexService()->addIndex(m_pTable,descriptor);
+ }
+ else
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUStringBuffer aSql( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE ")));
+ ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString aDot = ::rtl::OUString::createFromAscii(".");
- if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE))))
- aSql.appendAscii("UNIQUE ");
- aSql.appendAscii("INDEX ");
+ if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE))))
+ aSql.appendAscii("UNIQUE ");
+ aSql.appendAscii("INDEX ");
- ::rtl::OUString aCatalog,aSchema,aTable;
- dbtools::qualifiedNameComponents(m_pTable->getMetaData(),m_pTable->getName(),aCatalog,aSchema,aTable,::dbtools::eInDataManipulation);
- ::rtl::OUString aComposedName;
+ ::rtl::OUString aCatalog,aSchema,aTable;
+ dbtools::qualifiedNameComponents(m_pTable->getMetaData(),m_pTable->getName(),aCatalog,aSchema,aTable,::dbtools::eInDataManipulation);
+ ::rtl::OUString aComposedName;
- aComposedName = dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable,sal_True,::dbtools::eInIndexDefinitions);
- if ( _rForName.getLength() )
- {
- aSql.append( ::dbtools::quoteName( aQuote, _rForName ) );
- aSql.appendAscii(" ON ");
- aSql.append(aComposedName);
- aSql.appendAscii(" ( ");
-
- Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
- Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
- Reference< XPropertySet > xColProp;
- sal_Bool bAddIndexAppendix = ::dbtools::getBooleanDataSourceSetting( m_pTable->getConnection(), "AddIndexAppendix" );
- sal_Int32 nCount = xColumns->getCount();
- for(sal_Int32 i = 0 ; i < nCount; ++i)
+ aComposedName = dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable,sal_True,::dbtools::eInIndexDefinitions);
+ if ( _rForName.getLength() )
{
- xColProp.set(xColumns->getByIndex(i),UNO_QUERY);
- aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
+ aSql.append( ::dbtools::quoteName( aQuote, _rForName ) );
+ aSql.appendAscii(" ON ");
+ aSql.append(aComposedName);
+ aSql.appendAscii(" ( ");
- if ( bAddIndexAppendix )
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ sal_Bool bAddIndexAppendix = ::dbtools::getBooleanDataSourceSetting( m_pTable->getConnection(), "AddIndexAppendix" );
+ sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i = 0 ; i < nCount; ++i)
{
+ xColProp.set(xColumns->getByIndex(i),UNO_QUERY);
+ aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
+
+ if ( bAddIndexAppendix )
+ {
- aSql.appendAscii(any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING)))
- ?
- " ASC"
- :
- " DESC");
+ aSql.appendAscii(any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING)))
+ ?
+ " ASC"
+ :
+ " DESC");
+ }
+ aSql.appendAscii(",");
}
- aSql.appendAscii(",");
+ aSql.setCharAt(aSql.getLength()-1,')');
}
- aSql.setCharAt(aSql.getLength()-1,')');
- }
- else
- {
- aSql.append(aComposedName);
+ else
+ {
+ aSql.append(aComposedName);
- Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
- Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
- Reference< XPropertySet > xColProp;
- if(xColumns->getCount() != 1)
- throw SQLException();
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ if(xColumns->getCount() != 1)
+ throw SQLException();
- xColumns->getByIndex(0) >>= xColProp;
+ xColumns->getByIndex(0) >>= xColProp;
- aSql.append(aDot);
- aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
- }
+ aSql.append(aDot);
+ aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
+ }
- Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
- if ( xStmt.is() )
- {
- ::rtl::OUString sSql = aSql.makeStringAndClear();
- xStmt->execute(sSql);
- ::comphelper::disposeComponent(xStmt);
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ ::rtl::OUString sSql = aSql.makeStringAndClear();
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
}
return createObject( _rForName );
@@ -221,27 +228,34 @@ void OIndexesHelper::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElem
Reference< XConnection> xConnection = m_pTable->getConnection();
if( xConnection.is() && !m_pTable->isNew())
{
- ::rtl::OUString aName,aSchema;
- sal_Int32 nLen = _sElementName.indexOf('.');
- if(nLen != -1)
- aSchema = _sElementName.copy(0,nLen);
- aName = _sElementName.copy(nLen+1);
+ if ( m_pTable->getIndexService().is() )
+ {
+ m_pTable->getIndexService()->dropIndex(m_pTable,_sElementName);
+ }
+ else
+ {
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ if(nLen != -1)
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
- ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
- ::rtl::OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::eInIndexDefinitions, false, false, true );
- ::rtl::OUString sIndexName,sTemp;
- sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), sTemp, aSchema, aName, sal_True, ::dbtools::eInIndexDefinitions );
+ ::rtl::OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::eInIndexDefinitions, false, false, true );
+ ::rtl::OUString sIndexName,sTemp;
+ sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), sTemp, aSchema, aName, sal_True, ::dbtools::eInIndexDefinitions );
- aSql += sIndexName
- + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON "))
- + aComposedName;
+ aSql += sIndexName
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON "))
+ + aComposedName;
- Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
- if ( xStmt.is() )
- {
- xStmt->execute(aSql);
- ::comphelper::disposeComponent(xStmt);
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
}
}
}
diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx
index 3dbe711552d7..c4cfc27b741a 100644
--- a/connectivity/source/commontools/TKeys.cxx
+++ b/connectivity/source/commontools/TKeys.cxx
@@ -150,69 +150,80 @@ sdbcx::ObjectType OKeysHelper::appendObject( const ::rtl::OUString& _rForName, c
return xNewDescriptor;
}
- // if we're here, we belong to a table which is not new, i.e. already exists in the database.
- // In this case, really append the new index.
-
const ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)));
+ sal_Int32 nUpdateRule = 0, nDeleteRule = 0;
+ ::rtl::OUString sReferencedName;
- ::rtl::OUString aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
- ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( );
- ::rtl::OUString aDot = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
-
- aSql += composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::eInTableDefinitions, false, false, true );
- aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ADD "));
-
- if ( nKeyType == KeyType::PRIMARY )
+ if ( nKeyType == KeyType::FOREIGN )
{
- aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PRIMARY KEY ("));
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)) >>= sReferencedName;
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_UPDATERULE)) >>= nUpdateRule;
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)) >>= nDeleteRule;
}
- else if ( nKeyType == KeyType::FOREIGN )
+
+ if ( m_pTable->getKeyService().is() )
{
- aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FOREIGN KEY ("));
+ m_pTable->getKeyService()->addKey(m_pTable,descriptor);
}
else
- throw SQLException();
-
- Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
- Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
- Reference< XPropertySet > xColProp;
- for(sal_Int32 i=0;i<xColumns->getCount();++i)
{
- ::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
- aSql += ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))
- + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
- }
- aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+ // if we're here, we belong to a table which is not new, i.e. already exists in the database.
+ // In this case, really append the new index.
+ ::rtl::OUStringBuffer aSql;
+ aSql.appendAscii("ALTER TABLE ");
+ ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString aDot = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
- sal_Int32 nUpdateRule = 0, nDeleteRule = 0;
- ::rtl::OUString sReferencedName;
+ aSql.append(composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::eInTableDefinitions, false, false, true ));
+ aSql.appendAscii(" ADD ");
- if ( nKeyType == KeyType::FOREIGN )
- {
- descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)) >>= sReferencedName;
-
- aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" REFERENCES "))
- + ::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::eInTableDefinitions);
- aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ("));
+ if ( nKeyType == KeyType::PRIMARY )
+ {
+ aSql.appendAscii(" PRIMARY KEY (");
+ }
+ else if ( nKeyType == KeyType::FOREIGN )
+ {
+ aSql.appendAscii(" FOREIGN KEY (");
+ }
+ else
+ throw SQLException();
- for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ for(sal_Int32 i = 0 ; i < xColumns->getCount() ; ++i)
{
- xColumns->getByIndex(i) >>= xColProp;
- aSql += ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN))))
- + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ if ( i > 0 )
+ aSql.appendAscii(",");
+ ::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
+ aSql.append( ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))) );
+
}
- aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+ aSql.appendAscii(")");
- descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_UPDATERULE)) >>= nUpdateRule;
- descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)) >>= nDeleteRule;
+ if ( nKeyType == KeyType::FOREIGN )
+ {
+ aSql.appendAscii(" REFERENCES ");
+ aSql.append(::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::eInTableDefinitions));
+ aSql.appendAscii(" (");
- aSql += getKeyRuleString(sal_True ,nUpdateRule);
- aSql += getKeyRuleString(sal_False ,nDeleteRule);
- }
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ if ( i > 0 )
+ aSql.appendAscii(",");
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql.append(::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN)))));
- Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
- xStmt->execute(aSql);
+ }
+ aSql.appendAscii(")");
+ aSql.append(getKeyRuleString(sal_True ,nUpdateRule));
+ aSql.append(getKeyRuleString(sal_False ,nDeleteRule));
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql.makeStringAndClear());
+ }
// find the name which the database gave the new key
::rtl::OUString sNewName( _rForName );
try
@@ -269,34 +280,41 @@ void OKeysHelper::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName
Reference< XConnection> xConnection = m_pTable->getConnection();
if ( xConnection.is() && !m_pTable->isNew() )
{
- ::rtl::OUString aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
-
- aSql += composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::eInTableDefinitions, false, false, true );
-
Reference<XPropertySet> xKey(getObject(_nPos),UNO_QUERY);
-
- sal_Int32 nKeyType = KeyType::PRIMARY;
- if ( xKey.is() )
- {
- ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
- xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nKeyType;
- }
- if ( KeyType::PRIMARY == nKeyType )
+ if ( m_pTable->getKeyService().is() )
{
- aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP PRIMARY KEY"));
+ m_pTable->getKeyService()->dropKey(m_pTable,xKey);
}
else
{
- aSql += getDropForeignKey();
- const ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString();
- aSql += ::dbtools::quoteName( aQuote,_sElementName);
- }
+ ::rtl::OUStringBuffer aSql;
+ aSql.appendAscii("ALTER TABLE ");
- Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
- if ( xStmt.is() )
- {
- xStmt->execute(aSql);
- ::comphelper::disposeComponent(xStmt);
+ aSql.append( composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::eInTableDefinitions, false, false, true ));
+
+ sal_Int32 nKeyType = KeyType::PRIMARY;
+ if ( xKey.is() )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nKeyType;
+ }
+ if ( KeyType::PRIMARY == nKeyType )
+ {
+ aSql.appendAscii(" DROP PRIMARY KEY");
+ }
+ else
+ {
+ aSql.append(getDropForeignKey());
+ const ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString();
+ aSql.append( ::dbtools::quoteName( aQuote,_sElementName) );
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql.makeStringAndClear());
+ ::comphelper::disposeComponent(xStmt);
+ }
}
}
}
diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx
index 477ec01c0499..38b5d7fc52f3 100644
--- a/connectivity/source/commontools/TTableHelper.cxx
+++ b/connectivity/source/commontools/TTableHelper.cxx
@@ -101,11 +101,40 @@ namespace connectivity
struct OTableHelperImpl
{
TKeyMap m_aKeys;
- Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ // helper services which can be provided by extensions
+ Reference< ::com::sun::star::sdb::tools::XTableRename> m_xRename;
+ Reference< ::com::sun::star::sdb::tools::XTableAlteration> m_xAlter;
+ Reference< ::com::sun::star::sdb::tools::XKeyAlteration> m_xKeyAlter;
+ Reference< ::com::sun::star::sdb::tools::XIndexAlteration> m_xIndexAlter;
+
+ Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>
m_xTablePropertyListener;
::std::vector< ColumnDesc > m_aColumnDesc;
+ OTableHelperImpl(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection)
+ : m_xConnection(_xConnection)
+ {
+ try
+ {
+ m_xMetaData = m_xConnection->getMetaData();
+ Reference<XMultiServiceFactory> xFac(_xConnection,UNO_QUERY);
+ if ( xFac.is() )
+ {
+ static const ::rtl::OUString s_sTableRename(RTL_CONSTASCII_USTRINGPARAM("TableRenameServiceName"));
+ m_xRename.set(xFac->createInstance(s_sTableRename),UNO_QUERY);
+ static const ::rtl::OUString s_sTableAlteration(RTL_CONSTASCII_USTRINGPARAM("TableAlterationServiceName"));
+ m_xAlter.set(xFac->createInstance(s_sTableAlteration),UNO_QUERY);
+ static const ::rtl::OUString s_sKeyAlteration(RTL_CONSTASCII_USTRINGPARAM("KeyAlterationServiceName"));
+ m_xKeyAlter.set(xFac->createInstance(s_sKeyAlteration),UNO_QUERY);
+ static const ::rtl::OUString s_sIndexAlteration(RTL_CONSTASCII_USTRINGPARAM("IndexAlterationServiceName"));
+ m_xIndexAlter.set(xFac->createInstance(s_sIndexAlteration),UNO_QUERY);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
};
}
@@ -113,16 +142,8 @@ OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
const Reference< XConnection >& _xConnection,
sal_Bool _bCase)
:OTable_TYPEDEF(_pTables,_bCase)
- ,m_pImpl(new OTableHelperImpl)
+ ,m_pImpl(new OTableHelperImpl(_xConnection))
{
- try
- {
- m_pImpl->m_xConnection = _xConnection;
- m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
- }
- catch(const Exception&)
- {
- }
}
// -------------------------------------------------------------------------
OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
@@ -140,16 +161,8 @@ OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
_Description,
_SchemaName,
_CatalogName)
- ,m_pImpl(new OTableHelperImpl)
+ ,m_pImpl(new OTableHelperImpl(_xConnection))
{
- try
- {
- m_pImpl->m_xConnection = _xConnection;
- m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
- }
- catch(const Exception&)
- {
- }
}
// -----------------------------------------------------------------------------
OTableHelper::~OTableHelper()
@@ -483,24 +496,31 @@ void SAL_CALL OTableHelper::rename( const ::rtl::OUString& newName ) throw(SQLEx
if(!isNew())
{
- ::rtl::OUString sSql = getRenameStart();
- ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ if ( m_pImpl->m_xRename.is() )
+ {
+ m_pImpl->m_xRename->rename(this,newName);
+ }
+ else
+ {
+ ::rtl::OUString sSql = getRenameStart();
+ ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
- ::rtl::OUString sCatalog,sSchema,sTable;
- ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
- ::rtl::OUString sComposedName;
- sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_True,::dbtools::eInDataManipulation);
- sSql += sComposedName
- + ::rtl::OUString::createFromAscii(" TO ");
- sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
- sSql += sComposedName;
+ ::rtl::OUString sComposedName;
+ sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_True,::dbtools::eInDataManipulation);
+ sSql += sComposedName
+ + ::rtl::OUString::createFromAscii(" TO ");
+ sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
+ sSql += sComposedName;
- Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
- if ( xStmt.is() )
- {
- xStmt->execute(sSql);
- ::comphelper::disposeComponent(xStmt);
+ Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
}
OTable_TYPEDEF::rename(newName);
@@ -579,3 +599,24 @@ Reference< XConnection> OTableHelper::getConnection() const
{
return m_pImpl->m_xConnection;
}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XTableRename> OTableHelper::getRenameService() const
+{
+ return m_pImpl->m_xRename;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XTableAlteration> OTableHelper::getAlterService() const
+{
+ return m_pImpl->m_xAlter;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XKeyAlteration> OTableHelper::getKeyService() const
+{
+ return m_pImpl->m_xKeyAlter;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XIndexAlteration> OTableHelper::getIndexService() const
+{
+ return m_pImpl->m_xIndexAlter;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx
index e08c3a33076d..8e7c3bdb5dca 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -596,7 +596,39 @@ bool getBooleanDataSourceSetting( const Reference< XConnection >& _rxConnection,
}
return bValue;
}
+// -------------------------------------------------------------------------
+bool getDataSourceSetting( const Reference< XInterface >& _xChild, const ::rtl::OUString& _sAsciiSettingsName,
+ Any& /* [out] */ _rSettingsValue )
+{
+ bool bIsPresent = false;
+ try
+ {
+ const Reference< XPropertySet> xDataSourceProperties( findDataSource( _xChild ), UNO_QUERY );
+ OSL_ENSURE( xDataSourceProperties.is(), "getDataSourceSetting: invalid data source object!" );
+ if ( !xDataSourceProperties.is() )
+ return false;
+
+ const Reference< XPropertySet > xSettings(
+ xDataSourceProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings") ) ),
+ UNO_QUERY_THROW
+ );
+ _rSettingsValue = xSettings->getPropertyValue( _sAsciiSettingsName );
+ bIsPresent = true;
+ }
+ catch( const Exception& )
+ {
+ bIsPresent = false;
+ }
+ return bIsPresent;
+}
+// -------------------------------------------------------------------------
+bool getDataSourceSetting( const Reference< XInterface >& _rxDataSource, const sal_Char* _pAsciiSettingsName,
+ Any& /* [out] */ _rSettingsValue )
+{
+ ::rtl::OUString sAsciiSettingsName = ::rtl::OUString::createFromAscii(_pAsciiSettingsName);
+ return getDataSourceSetting( _rxDataSource, sAsciiSettingsName,_rSettingsValue );
+}
// -----------------------------------------------------------------------------
sal_Bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp,const ::rtl::OUString& _sProperty,sal_Bool _bDefault)
{
diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu
index 8a106c70283f..04ef77872366 100755
--- a/connectivity/source/drivers/ado/ado.xcu
+++ b/connectivity/source/drivers/ado/ado.xcu
@@ -157,6 +157,11 @@
<value>3</value>
</prop>
</node>
+ <node oor:name="ColumnAliasInOrderBy" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
</node>
<node oor:name="Features">
<node oor:name="UseSQL92NamingConstraints" oor:op="replace">