summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-09-08 09:50:48 +0000
committerOliver Bolte <obo@openoffice.org>2009-09-08 09:50:48 +0000
commit2dca9f97c600b3ab22155ba24390e3654fa8ff66 (patch)
treeded290eaf4b7a4797212e43f0712c86c6984139e
parent47b189a5b78253040718e509989c4637743bee9a (diff)
CWS-TOOLING: integrate CWS dbaperf3
2009-08-28 08:04:41 +0200 oj r275515 : wrong replacement 2009-08-28 07:57:44 +0200 oj r275514 : declaration of 'nRealSize' shadows a previous local 2009-08-20 10:17:11 +0200 oj r275168 : CWS-TOOLING: rebase CWS dbaperf3 to trunk@275001 (milestone: DEV300:m55) 2009-08-19 11:50:49 +0200 oj r275145 : #ii102891# minimize metadata calls 2009-06-22 12:20:15 +0200 oj r273213 : compile error 2009-06-22 12:19:45 +0200 oj r273212 : compile error 2009-06-18 08:54:08 +0200 oj r273099 : #i102891# reduce calls to databasemetadata 2009-06-18 08:19:55 +0200 oj r273095 : #i102891# reduce calls to databasemetadata
-rw-r--r--connectivity/inc/connectivity/TTableHelper.hxx45
-rw-r--r--connectivity/inc/connectivity/sdbcx/VKey.hxx1
-rw-r--r--connectivity/inc/connectivity/sdbcx/VView.hxx17
-rw-r--r--connectivity/inc/connectivity/sqlnode.hxx3
-rw-r--r--connectivity/source/commontools/ConnectionWrapper.cxx2
-rw-r--r--connectivity/source/commontools/DateConversion.cxx56
-rw-r--r--connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx2
-rw-r--r--connectivity/source/commontools/TColumnsHelper.cxx73
-rw-r--r--connectivity/source/commontools/TDatabaseMetaDataBase.cxx4
-rw-r--r--connectivity/source/commontools/TIndexColumns.cxx2
-rw-r--r--connectivity/source/commontools/TIndexes.cxx4
-rw-r--r--connectivity/source/commontools/TKey.cxx55
-rw-r--r--connectivity/source/commontools/TPrivilegesResultSet.cxx4
-rw-r--r--connectivity/source/commontools/TTableHelper.cxx213
-rw-r--r--connectivity/source/commontools/dbconversion.cxx4
-rw-r--r--connectivity/source/commontools/dbmetadata.cxx3
-rw-r--r--connectivity/source/commontools/dbtools.cxx5
-rw-r--r--connectivity/source/commontools/dbtools2.cxx49
-rw-r--r--connectivity/source/commontools/parameters.cxx2
-rw-r--r--connectivity/source/cpool/ZConnectionPool.cxx6
-rw-r--r--connectivity/source/cpool/ZPoolCollection.cxx4
-rw-r--r--connectivity/source/cpool/ZPooledConnection.cxx4
-rw-r--r--connectivity/source/drivers/adabas/BConnection.cxx5
-rw-r--r--connectivity/source/drivers/adabas/BDriver.cxx2
-rw-r--r--connectivity/source/drivers/adabas/BPreparedStatement.cxx4
-rw-r--r--connectivity/source/drivers/adabas/BTables.cxx2
-rw-r--r--connectivity/source/drivers/adabas/BViews.cxx2
-rw-r--r--connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx2
-rw-r--r--connectivity/source/drivers/ado/ADriver.cxx11
-rw-r--r--connectivity/source/drivers/ado/APreparedStatement.cxx4
-rw-r--r--connectivity/source/drivers/ado/AResultSet.cxx4
-rw-r--r--connectivity/source/drivers/ado/Aservices.cxx4
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx2
-rw-r--r--connectivity/source/drivers/evoab2/NDriver.cxx2
-rw-r--r--connectivity/source/drivers/evoab2/NResultSet.cxx2
-rw-r--r--connectivity/source/drivers/evoab2/NStatement.cxx4
-rw-r--r--connectivity/source/drivers/evoab2/NTables.cxx2
-rw-r--r--connectivity/source/drivers/file/FCatalog.cxx2
-rw-r--r--connectivity/source/drivers/file/FConnection.cxx4
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx4
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx10
-rw-r--r--connectivity/source/drivers/file/FTables.cxx2
-rw-r--r--connectivity/source/drivers/file/fcomp.cxx2
-rw-r--r--connectivity/source/drivers/hsqldb/HStorageMap.cxx8
-rw-r--r--connectivity/source/drivers/hsqldb/HTables.cxx2
-rw-r--r--connectivity/source/drivers/hsqldb/HViews.cxx2
-rw-r--r--connectivity/source/drivers/jdbc/JDriver.cxx2
-rw-r--r--connectivity/source/drivers/jdbc/ResultSet.cxx2
-rw-r--r--connectivity/source/drivers/kab/KResultSet.cxx4
-rw-r--r--connectivity/source/drivers/kab/KTables.cxx2
-rwxr-xr-xconnectivity/source/drivers/macab/MacabResultSet.cxx4
-rwxr-xr-xconnectivity/source/drivers/macab/MacabTables.cxx2
-rw-r--r--connectivity/source/drivers/mozab/MPreparedStatement.cxx2
-rw-r--r--connectivity/source/drivers/mozab/MResultSet.cxx6
-rw-r--r--connectivity/source/drivers/mozab/MResultSetMetaData.cxx2
-rw-r--r--connectivity/source/drivers/mozab/MTables.cxx2
-rw-r--r--connectivity/source/drivers/mysql/YTables.cxx2
-rw-r--r--connectivity/source/drivers/mysql/YViews.cxx2
-rw-r--r--connectivity/source/drivers/odbcbase/OConnection.cxx24
-rw-r--r--connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx176
-rw-r--r--connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx13
-rw-r--r--connectivity/source/drivers/odbcbase/OPreparedStatement.cxx22
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSet.cxx6
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx34
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx14
-rw-r--r--connectivity/source/inc/OSubComponent.hxx2
-rw-r--r--connectivity/source/inc/adabas/BPreparedStatement.hxx2
-rw-r--r--connectivity/source/inc/calc/CConnection.hxx2
-rw-r--r--connectivity/source/inc/odbc/OConnection.hxx6
-rw-r--r--connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx1
-rw-r--r--connectivity/source/inc/odbc/OPreparedStatement.hxx6
-rw-r--r--connectivity/source/inc/odbc/OResultSetMetaData.hxx1
-rw-r--r--connectivity/source/parse/sqlbison.y36
-rw-r--r--connectivity/source/parse/sqliterator.cxx15
-rw-r--r--connectivity/source/parse/sqlnode.cxx18
-rw-r--r--connectivity/source/sdbcx/VCatalog.cxx2
-rw-r--r--connectivity/source/sdbcx/VTable.cxx9
-rw-r--r--connectivity/source/sdbcx/VView.cxx13
78 files changed, 656 insertions, 424 deletions
diff --git a/connectivity/inc/connectivity/TTableHelper.hxx b/connectivity/inc/connectivity/TTableHelper.hxx
index fa9a64202d..ea9d4a57d4 100644
--- a/connectivity/inc/connectivity/TTableHelper.hxx
+++ b/connectivity/inc/connectivity/TTableHelper.hxx
@@ -39,17 +39,50 @@
namespace connectivity
{
+ typedef sal_Int32 OrdinalPosition;
+ struct ColumnDesc
+ {
+ ::rtl::OUString sName;
+ ::rtl::OUString aField6;
+ ::rtl::OUString sField13;
+ sal_Int32 nField5
+ , nField7
+ , nField9
+ , nField11;
+
+ OrdinalPosition nOrdinalPosition;
+
+ ColumnDesc() {}
+ ColumnDesc( const ::rtl::OUString& _rName
+ , sal_Int32 _nField5
+ , const ::rtl::OUString& _aField6
+ , sal_Int32 _nField7
+ , sal_Int32 _nField9
+ , sal_Int32 _nField11
+ , const ::rtl::OUString& _sField13
+ ,OrdinalPosition _nPosition )
+ :sName( _rName )
+ ,aField6(_aField6)
+ ,sField13(_sField13)
+ ,nField5(_nField5)
+ ,nField7(_nField7)
+ ,nField9(_nField9)
+ ,nField11(_nField11)
+ ,nOrdinalPosition( _nPosition )
+ {
+ }
+ };
typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
DECLARE_STL_USTRINGACCESS_MAP( sdbcx::TKeyProperties , TKeyMap);
+ struct OTableHelperImpl;
+
class OOO_DLLPUBLIC_DBTOOLS OTableHelper : public OTable_TYPEDEF
{
- TKeyMap m_aKeys;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::std::auto_ptr<OTableHelperImpl> m_pImpl;
void refreshPrimaryKeys(TStringVector& _rKeys);
void refreshForgeinKeys(TStringVector& _rKeys);
@@ -83,11 +116,15 @@ namespace connectivity
*/
virtual ::rtl::OUString getRenameStart() const;
+ virtual ~OTableHelper();
+
public:
virtual void refreshColumns();
virtual void refreshKeys();
virtual void refreshIndexes();
+ const ColumnDesc* getColumnDescription(const ::rtl::OUString& _sName) const;
+
public:
OTableHelper( sdbcx::OCollection* _pTables,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
@@ -103,7 +140,7 @@ namespace connectivity
);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
- inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xConnection; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const;
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
diff --git a/connectivity/inc/connectivity/sdbcx/VKey.hxx b/connectivity/inc/connectivity/sdbcx/VKey.hxx
index fa040a2369..1eee05742e 100644
--- a/connectivity/inc/connectivity/sdbcx/VKey.hxx
+++ b/connectivity/inc/connectivity/sdbcx/VKey.hxx
@@ -51,6 +51,7 @@ namespace connectivity
struct OOO_DLLPUBLIC_DBTOOLS KeyProperties
{
+ ::std::vector< ::rtl::OUString> m_aKeyColumnNames;
::rtl::OUString m_ReferencedTable;
sal_Int32 m_Type;
sal_Int32 m_UpdateRule;
diff --git a/connectivity/inc/connectivity/sdbcx/VView.hxx b/connectivity/inc/connectivity/sdbcx/VView.hxx
index 53a2abcdcd..0537c27316 100644
--- a/connectivity/inc/connectivity/sdbcx/VView.hxx
+++ b/connectivity/inc/connectivity/sdbcx/VView.hxx
@@ -42,30 +42,21 @@
#include "connectivity/sdbcx/VDescriptor.hxx"
#include "connectivity/dbtoolsdllapi.hxx"
#include <comphelper/IdPropArrayHelper.hxx>
+#include <cppuhelper/implbase2.hxx>
namespace connectivity
{
namespace sdbcx
{
- typedef ::cppu::OWeakObject OView_BASE;
+ typedef ::cppu::WeakImplHelper2< ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::container::XNamed> OView_BASE;
- class OOO_DLLPUBLIC_DBTOOLS OViewHelper
- {
- protected:
- ::osl::Mutex m_aMutex;
- ::cppu::OBroadcastHelper rBHelper;
-
- public:
- OViewHelper(): rBHelper(m_aMutex){}
- };
class OOO_DLLPUBLIC_DBTOOLS OView :
- public OViewHelper,
+ public ::comphelper::OMutexAndBroadcastHelper,
public OView_BASE,
- public ::com::sun::star::container::XNamed,
- public ::com::sun::star::lang::XServiceInfo,
public ::comphelper::OIdPropertyArrayUsageHelper<OView>,
public ODescriptor
{
diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx
index 6a919172c7..ad04cd29f4 100644
--- a/connectivity/inc/connectivity/sqlnode.hxx
+++ b/connectivity/inc/connectivity/sqlnode.hxx
@@ -404,7 +404,8 @@ namespace connectivity
static sal_Bool getTableComponents(const OSQLParseNode* _pTableNode,
::com::sun::star::uno::Any &_rCatalog,
::rtl::OUString &_rSchema,
- ::rtl::OUString &_rTable);
+ ::rtl::OUString &_rTable
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData);
// susbtitute all occurences of :var or [name] into the dynamic parameter ?
// _pNode will be modified if parameters exists
diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx
index dcbc501110..d417c33163 100644
--- a/connectivity/source/commontools/ConnectionWrapper.cxx
+++ b/connectivity/source/commontools/ConnectionWrapper.cxx
@@ -109,7 +109,7 @@ void OConnectionWrapper::setDelegation(const Reference< XConnection >& _xConnect
// -----------------------------------------------------------------------------
void OConnectionWrapper::disposing()
{
- m_xConnection = NULL;
+m_xConnection.clear();
}
//-----------------------------------------------------------------------------
OConnectionWrapper::~OConnectionWrapper()
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx
index bd6ad7bd76..bee1b9a69e 100644
--- a/connectivity/source/commontools/DateConversion.cxx
+++ b/connectivity/source/commontools/DateConversion.cxx
@@ -45,6 +45,7 @@
#include "TConnection.hxx"
#include "diagnose_ex.h"
#include <comphelper/numbers.hxx>
+#include <rtl/ustrbuf.hxx>
using namespace ::connectivity;
@@ -63,7 +64,7 @@ using namespace ::com::sun::star::beans;
::rtl::OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, sal_Bool bQuote,
const Reference< XTypeConverter >& _rxTypeConverter)
{
- ::rtl::OUString aRet;
+ ::rtl::OUStringBuffer aRet;
if (_rVal.hasValue())
{
try
@@ -78,18 +79,22 @@ using namespace ::com::sun::star::beans;
if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN)
{
if (::cppu::any2bool(_rVal))
- aRet = ::rtl::OUString::createFromAscii("1");
+ aRet.appendAscii("1");
else
- aRet = ::rtl::OUString::createFromAscii("0");
+ aRet.appendAscii("0");
}
else
- _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aRet;
+ {
+ ::rtl::OUString sTemp;
+ _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp;
+ aRet.append(sTemp);
+ }
break;
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
if (bQuote)
- aRet += ::rtl::OUString::createFromAscii("'");
+ aRet.appendAscii("'");
{
::rtl::OUString aTemp;
_rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp;
@@ -104,17 +109,22 @@ using namespace ::com::sun::star::beans;
aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(),sQuotToReplace);
} while (nIndex != -1);
- aRet += aTemp;
+ aRet.append(aTemp);
}
if (bQuote)
- aRet += ::rtl::OUString::createFromAscii("'");
+ aRet.appendAscii("'");
break;
case DataType::REAL:
case DataType::DOUBLE:
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::BIGINT:
- _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aRet;
+ default:
+ {
+ ::rtl::OUString sTemp;
+ _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp;
+ aRet.append(sTemp);
+ }
break;
case DataType::TIMESTAMP:
{
@@ -123,9 +133,11 @@ using namespace ::com::sun::star::beans;
// check if this is really a timestamp or only a date
if ( _rVal >>= aDateTime )
{
- if (bQuote) aRet += ::rtl::OUString::createFromAscii("{TS '");
- aRet += DBTypeConversion::toDateTimeString(aDateTime);
- if (bQuote) aRet += ::rtl::OUString::createFromAscii("'}");
+ if (bQuote)
+ aRet.appendAscii("{TS '");
+ aRet.append(DBTypeConversion::toDateTimeString(aDateTime));
+ if (bQuote)
+ aRet.appendAscii("'}");
break;
}
break;
@@ -134,20 +146,22 @@ using namespace ::com::sun::star::beans;
{
Date aDate;
OSL_VERIFY_RES( _rVal >>= aDate, "DBTypeConversion::toSQLString: _rVal is not date!");
- if (bQuote) aRet += ::rtl::OUString::createFromAscii("{D '");
- aRet += DBTypeConversion::toDateString(aDate);;
- if (bQuote) aRet += ::rtl::OUString::createFromAscii("'}");
+ if (bQuote)
+ aRet.appendAscii("{D '");
+ aRet.append(DBTypeConversion::toDateString(aDate));
+ if (bQuote)
+ aRet.appendAscii("'}");
} break;
case DataType::TIME:
{
Time aTime;
OSL_VERIFY_RES( _rVal >>= aTime,"DBTypeConversion::toSQLString: _rVal is not time!");
- if (bQuote) aRet += ::rtl::OUString::createFromAscii("{T '");
- aRet += DBTypeConversion::toTimeString(aTime);
- if (bQuote) aRet += ::rtl::OUString::createFromAscii("'}");
+ if (bQuote)
+ aRet.appendAscii("{T '");
+ aRet.append(DBTypeConversion::toTimeString(aTime));
+ if (bQuote)
+ aRet.appendAscii("'}");
} break;
- default:
- _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aRet;
}
}
catch ( const Exception& )
@@ -156,8 +170,8 @@ using namespace ::com::sun::star::beans;
}
}
else
- aRet = ::rtl::OUString::createFromAscii(" NULL ");
- return aRet;
+ aRet.appendAscii(" NULL ");
+ return aRet.makeStringAndClear();
}
// -----------------------------------------------------------------------------
Date DBTypeConversion::getNULLDate(const Reference< XNumberFormatsSupplier > &xSupplier)
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
index bd22077b5f..17fe520b1d 100644
--- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
@@ -133,7 +133,7 @@ void ODatabaseMetaDataResultSet::disposing(void)
::osl::MutexGuard aGuard(m_aMutex);
m_aStatement = NULL;
- m_xMetaData = NULL;
+m_xMetaData.clear();
m_aRowsIter = m_aRows.end();
m_aRows.clear();
m_aRowsIter = m_aRows.end();
diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx
index 97dfbb42c3..032d859575 100644
--- a/connectivity/source/commontools/TColumnsHelper.cxx
+++ b/connectivity/source/commontools/TColumnsHelper.cxx
@@ -37,6 +37,9 @@
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
#include <comphelper/types.hxx>
#include "connectivity/dbtools.hxx"
#include "TConnection.hxx"
@@ -51,7 +54,7 @@ using namespace connectivity;
using namespace dbtools;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
@@ -114,17 +117,67 @@ sdbcx::ObjectType OColumnsHelper::createObject(const ::rtl::OUString& _rName)
bAutoIncrement = aFind->second.first.first;
bIsCurrency = aFind->second.first.second;
nDataType = aFind->second.second;
+ } // if ( aFind != m_pImpl->m_aColumnInfo.end() )
+
+ sdbcx::ObjectType xRet;
+ const ColumnDesc* pColDesc = m_pTable->getColumnDescription(_rName);
+ if ( pColDesc )
+ {
+ Reference<XPropertySet> xPr = m_pTable;
+ Reference<XKeysSupplier> xKeysSup(xPr,UNO_QUERY);
+ Reference<XNameAccess> xPrimaryKeyColumns;
+ if ( xKeysSup.is() )
+ {
+ const Reference<XIndexAccess> xKeys = xKeysSup->getKeys();
+ if ( xKeys.is() )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ const sal_Int32 nKeyCount = xKeys->getCount();
+ for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++nKeyIter)
+ {
+ const Reference<XPropertySet> xKey(xKeys->getByIndex(nKeyIter),UNO_QUERY_THROW);
+ sal_Int32 nType = 0;
+ xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ if ( nType == KeyType::PRIMARY )
+ {
+ const Reference<XColumnsSupplier> xColS(xKey,UNO_QUERY_THROW);
+ xPrimaryKeyColumns = xColS->getColumns();
+ break;
+ }
+ } // for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++)
+ }
+ }
+ sal_Int32 nField11 = pColDesc->nField11;
+ if ( nField11 != ColumnValue::NO_NULLS && xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(_rName) )
+ {
+ nField11 = ColumnValue::NO_NULLS;
+ } // if ( xKeys.is() )
+ connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName,
+ pColDesc->aField6,
+ pColDesc->sField13,
+ nField11,
+ pColDesc->nField7,
+ pColDesc->nField9,
+ pColDesc->nField5,
+ bAutoIncrement,
+ sal_False,
+ bIsCurrency,
+ isCaseSensitive());
+
+ xRet = pRet;
}
-
+ else
+ {
- sdbcx::ObjectType xRet(::dbtools::createSDBCXColumn( m_pTable,
- xConnection,
- _rName,
- isCaseSensitive(),
- bQueryInfo,
- bAutoIncrement,
- bIsCurrency,
- nDataType),UNO_QUERY);
+ xRet.set(::dbtools::createSDBCXColumn( m_pTable,
+ xConnection,
+ _rName,
+ isCaseSensitive(),
+ bQueryInfo,
+ bAutoIncrement,
+ bIsCurrency,
+ nDataType),UNO_QUERY);
+ }
return xRet;
}
diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
index c5943e9da4..1a763b0c10 100644
--- a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
+++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
@@ -90,8 +90,8 @@ Sequence< PropertyValue > SAL_CALL ODatabaseMetaDataBase::getConnectionInfo( )
void SAL_CALL ODatabaseMetaDataBase::disposing( const EventObject& /*Source*/ ) throw(RuntimeException)
{
// cut off all references to the connection
- m_xConnection = NULL;
- m_xListenerHelper = NULL;
+m_xConnection.clear();
+m_xListenerHelper.clear();
}
// -----------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo( ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/commontools/TIndexColumns.cxx b/connectivity/source/commontools/TIndexColumns.cxx
index 81ef5a205f..1f10f853e9 100644
--- a/connectivity/source/commontools/TIndexColumns.cxx
+++ b/connectivity/source/commontools/TIndexColumns.cxx
@@ -85,7 +85,7 @@ sdbcx::ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
aSchema,aTable,_rName);
- sdbcx::ObjectType xRet = NULL;
+ sdbcx::ObjectType xRet;
if ( xResult.is() )
{
Reference< XRow > xRow(xResult,UNO_QUERY);
diff --git a/connectivity/source/commontools/TIndexes.cxx b/connectivity/source/commontools/TIndexes.cxx
index e53d62bd1c..b4ae00b603 100644
--- a/connectivity/source/commontools/TIndexes.cxx
+++ b/connectivity/source/commontools/TIndexes.cxx
@@ -97,8 +97,8 @@ sdbcx::ObjectType OIndexesHelper::createObject(const ::rtl::OUString& _rName)
{
sal_Int32 nClustered = xRow->getShort(7);
sal_Bool bPrimarKeyIndex = sal_False;
- xRow = NULL;
- xResult = NULL;
+ xRow.clear();
+ xResult.clear();
try
{
xResult = m_pTable->getMetaData()->getPrimaryKeys(aCatalog,aSchema,aTable);
diff --git a/connectivity/source/commontools/TKey.cxx b/connectivity/source/commontools/TKey.cxx
index ce0fd97b75..5f7605c255 100644
--- a/connectivity/source/commontools/TKey.cxx
+++ b/connectivity/source/commontools/TKey.cxx
@@ -71,38 +71,43 @@ void OTableKeyHelper::refreshColumns()
::std::vector< ::rtl::OUString> aVector;
if ( !isNew() )
{
- ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
- ::rtl::OUString aSchema,aTable;
- m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
- m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
-
- if ( m_Name.getLength() ) // foreign key
+ aVector = m_aProps->m_aKeyColumnNames;
+ if ( aVector.empty() )
{
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
- Reference< XResultSet > xResult = m_pTable->getMetaData()->getImportedKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
- aSchema,aTable);
-
- if ( xResult.is() )
+ if ( m_Name.getLength() ) // foreign key
{
- Reference< XRow > xRow(xResult,UNO_QUERY);
- while( xResult->next() )
+
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getImportedKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable);
+
+ if ( xResult.is() )
{
- ::rtl::OUString aForeignKeyColumn = xRow->getString(8);
- if(xRow->getString(12) == m_Name)
- aVector.push_back(aForeignKeyColumn);
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ {
+ ::rtl::OUString aForeignKeyColumn = xRow->getString(8);
+ if(xRow->getString(12) == m_Name)
+ aVector.push_back(aForeignKeyColumn);
+ }
}
}
- }
- if ( aVector.empty() )
- {
- Reference< XResultSet > xResult = m_pTable->getMetaData()->getPrimaryKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
- aSchema,aTable);
-
- if ( xResult.is() )
+
+ if ( aVector.empty() )
{
- Reference< XRow > xRow(xResult,UNO_QUERY);
- while( xResult->next() )
- aVector.push_back(xRow->getString(4));
+ const Reference< XResultSet > xResult = m_pTable->getMetaData()->getPrimaryKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable);
+
+ if ( xResult.is() )
+ {
+ const Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ aVector.push_back(xRow->getString(4));
+ } // if ( xResult.is() )
}
}
}
diff --git a/connectivity/source/commontools/TPrivilegesResultSet.cxx b/connectivity/source/commontools/TPrivilegesResultSet.cxx
index 10543df924..2752aa4d4b 100644
--- a/connectivity/source/commontools/TPrivilegesResultSet.cxx
+++ b/connectivity/source/commontools/TPrivilegesResultSet.cxx
@@ -127,8 +127,8 @@ const ORowSetValue& OResultSetPrivileges::getValue(sal_Int32 columnIndex)
void SAL_CALL OResultSetPrivileges::disposing(void)
{
ODatabaseMetaDataResultSet::disposing();
- m_xTables = NULL;
- m_xRow = NULL;
+m_xTables.clear();
+m_xRow.clear();
}
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetPrivileges::next( ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx
index e3c6bd4d11..9a150d4694 100644
--- a/connectivity/source/commontools/TTableHelper.cxx
+++ b/connectivity/source/commontools/TTableHelper.cxx
@@ -38,6 +38,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/implementationreference.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/extract.hxx>
#include <comphelper/types.hxx>
@@ -54,16 +55,70 @@ using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
+namespace
+{
+ /// helper class for column property change events which holds the OComponentDefinition weak
+typedef ::cppu::WeakImplHelper1 < XContainerListener > OTableContainerListener_BASE;
+class OTableContainerListener : public OTableContainerListener_BASE
+{
+ OTableHelper* m_pComponent;
+ ::std::map< ::rtl::OUString,bool> m_aRefNames;
+
+ OTableContainerListener(const OTableContainerListener&);
+ void operator =(const OTableContainerListener&);
+protected:
+ virtual ~OTableContainerListener(){}
+public:
+ OTableContainerListener(OTableHelper* _pComponent) : m_pComponent(_pComponent){}
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (RuntimeException)
+ {
+ }
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (RuntimeException)
+ {
+ ::rtl::OUString sName;
+ Event.Accessor >>= sName;
+ if ( m_aRefNames.find(sName) != m_aRefNames.end() )
+ m_pComponent->refreshKeys();
+ }
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (RuntimeException)
+ {
+ ::rtl::OUString sOldComposedName,sNewComposedName;
+ Event.ReplacedElement >>= sOldComposedName;
+ Event.Accessor >>= sNewComposedName;
+ if ( sOldComposedName != sNewComposedName && m_aRefNames.find(sOldComposedName) != m_aRefNames.end() )
+ m_pComponent->refreshKeys();
+ }
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& /*_rSource*/ ) throw (RuntimeException)
+ {
+ }
+ void clear() { m_pComponent = NULL; }
+ inline void add(const ::rtl::OUString& _sRefName) { m_aRefNames.insert(::std::map< ::rtl::OUString,bool>::value_type(_sRefName,true)); }
+};
+}
+namespace connectivity
+{
+ struct OTableHelperImpl
+ {
+ TKeyMap m_aKeys;
+ 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;
+ };
+}
OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
const Reference< XConnection >& _xConnection,
sal_Bool _bCase)
:OTable_TYPEDEF(_pTables,_bCase)
- ,m_xConnection(_xConnection)
+ ,m_pImpl(new OTableHelperImpl)
{
try
{
- m_xMetaData = m_xConnection->getMetaData();
+ m_pImpl->m_xConnection = _xConnection;
+ m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
}
catch(const Exception&)
{
@@ -85,42 +140,41 @@ OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
_Description,
_SchemaName,
_CatalogName)
- ,m_xConnection(_xConnection)
+ ,m_pImpl(new OTableHelperImpl)
{
try
{
- m_xMetaData = m_xConnection->getMetaData();
+ m_pImpl->m_xConnection = _xConnection;
+ m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
}
catch(const Exception&)
{
}
}
// -----------------------------------------------------------------------------
+OTableHelper::~OTableHelper()
+{
+}
+// -----------------------------------------------------------------------------
void SAL_CALL OTableHelper::disposing()
{
- OTable_TYPEDEF::disposing();
::osl::MutexGuard aGuard(m_aMutex);
- m_xConnection = NULL;
- m_xMetaData = NULL;
+ if ( m_pImpl->m_xTablePropertyListener.is() )
+ {
+ m_pTables->removeContainerListener(m_pImpl->m_xTablePropertyListener.getRef());
+ m_pImpl->m_xTablePropertyListener->clear();
+ m_pImpl->m_xTablePropertyListener.dispose();
+ }
+ OTable_TYPEDEF::disposing();
+
+ m_pImpl->m_xConnection = NULL;
+ m_pImpl->m_xMetaData = NULL;
+
}
// -------------------------------------------------------------------------
namespace
{
- typedef sal_Int32 OrdinalPosition;
- struct ColumnDesc
- {
- ::rtl::OUString sName;
- OrdinalPosition nOrdinalPosition;
-
- ColumnDesc() {}
- ColumnDesc( const ::rtl::OUString& _rName, OrdinalPosition _nPosition )
- :sName( _rName )
- ,nOrdinalPosition( _nPosition )
- {
- }
- };
-
/** collects ColumnDesc's from a resultset produced by XDatabaseMetaData::getColumns
*/
void lcl_collectColumnDescs_throw( const Reference< XResultSet >& _rxResult, ::std::vector< ColumnDesc >& _out_rColumns )
@@ -131,8 +185,14 @@ namespace
while ( _rxResult->next() )
{
sName = xRow->getString( 4 ); // COLUMN_NAME
+ sal_Int32 nField5 = xRow->getInt(5);
+ ::rtl::OUString aField6 = xRow->getString(6);
+ sal_Int32 nField7 = xRow->getInt(7)
+ , nField9 = xRow->getInt(9)
+ , nField11= xRow->getInt(11);
+ ::rtl::OUString sField13 = xRow->getString(13);
nOrdinalPosition = xRow->getInt( 17 ); // ORDINAL_POSITION
- _out_rColumns.push_back( ColumnDesc( sName, nOrdinalPosition ) );
+ _out_rColumns.push_back( ColumnDesc( sName,nField5,aField6,nField7,nField9,nField11,sField13, nOrdinalPosition ) );
}
}
@@ -201,16 +261,16 @@ void OTableHelper::refreshColumns()
) );
// collect the column names, together with their ordinal position
- ::std::vector< ColumnDesc > aColumns;
- lcl_collectColumnDescs_throw( xResult, aColumns );
+ m_pImpl->m_aColumnDesc.clear();
+ lcl_collectColumnDescs_throw( xResult, m_pImpl->m_aColumnDesc );
// ensure that the ordinal positions as obtained from the meta data do make sense
- lcl_sanitizeColumnDescs( aColumns );
+ lcl_sanitizeColumnDescs( m_pImpl->m_aColumnDesc );
// sort by ordinal position
::std::map< OrdinalPosition, ::rtl::OUString > aSortedColumns;
- for ( ::std::vector< ColumnDesc >::const_iterator copy = aColumns.begin();
- copy != aColumns.end();
+ for ( ::std::vector< ColumnDesc >::const_iterator copy = m_pImpl->m_aColumnDesc.begin();
+ copy != m_pImpl->m_aColumnDesc.end();
++copy
)
aSortedColumns[ copy->nOrdinalPosition ] = copy->sName;
@@ -229,6 +289,21 @@ void OTableHelper::refreshColumns()
else
m_pColumns = createColumns(aVector);
}
+// -----------------------------------------------------------------------------
+const ColumnDesc* OTableHelper::getColumnDescription(const ::rtl::OUString& _sName) const
+{
+ const ColumnDesc* pRet = NULL;
+ ::std::vector< ColumnDesc >::const_iterator aEnd = m_pImpl->m_aColumnDesc.end();
+ for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter)
+ {
+ if ( aIter->sName == _sName )
+ {
+ pRet = &*aIter;
+ break;
+ }
+ } // for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter)
+ return pRet;
+}
// -------------------------------------------------------------------------
void OTableHelper::refreshPrimaryKeys(TStringVector& _rNames)
{
@@ -237,14 +312,26 @@ void OTableHelper::refreshPrimaryKeys(TStringVector& _rNames)
aCatalog <<= m_CatalogName;
Reference< XResultSet > xResult = getMetaData()->getPrimaryKeys(aCatalog,m_SchemaName,m_Name);
- if ( xResult.is() && xResult->next() )
+ if ( xResult.is() )
{
- Reference< XRow > xRow(xResult,UNO_QUERY);
- const ::rtl::OUString aPkName = xRow->getString(6);
- m_aKeys.insert(TKeyMap::value_type(aPkName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(::rtl::OUString(),KeyType::PRIMARY,0,0))));
+ sdbcx::TKeyProperties pKeyProps(new sdbcx::KeyProperties(::rtl::OUString(),KeyType::PRIMARY,0,0));
+ ::rtl::OUString aPkName;
+ bool bAlreadyFetched = false;
+ const Reference< XRow > xRow(xResult,UNO_QUERY);
+ while ( xResult->next() )
+ {
+ pKeyProps->m_aKeyColumnNames.push_back(xRow->getString(4));
+ if ( !bAlreadyFetched )
+ {
+ aPkName = xRow->getString(6);
+ bAlreadyFetched = true;
+ }
+ }
+
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(aPkName,pKeyProps));
_rNames.push_back(aPkName);
- ::comphelper::disposeComponent(xResult);
- }
+ } // if ( xResult.is() && xResult->next() )
+ ::comphelper::disposeComponent(xResult);
}
// -------------------------------------------------------------------------
void OTableHelper::refreshForgeinKeys(TStringVector& _rNames)
@@ -257,7 +344,8 @@ void OTableHelper::refreshForgeinKeys(TStringVector& _rNames)
if ( xRow.is() )
{
- ::rtl::OUString aName,sCatalog,aSchema;
+ sdbcx::TKeyProperties pKeyProps;
+ ::rtl::OUString aName,sCatalog,aSchema,sOldFKName;
while( xResult->next() )
{
// this must be outsid the "if" because we have to call in a right order
@@ -267,29 +355,51 @@ void OTableHelper::refreshForgeinKeys(TStringVector& _rNames)
aSchema = xRow->getString(2);
aName = xRow->getString(3);
- const sal_Int32 nKeySeq = xRow->getInt(9);
+ const ::rtl::OUString sForeignKeyColumn = xRow->getString(8);
const sal_Int32 nUpdateRule = xRow->getInt(10);
const sal_Int32 nDeleteRule = xRow->getInt(11);
+ const ::rtl::OUString sFkName = xRow->getString(12);
- if ( nKeySeq == 1 )
- { // only append when the sequnce number is 1 to forbid serveral inserting the same key name
- const ::rtl::OUString sFkName = xRow->getString(12);
- if ( sFkName.getLength() && !xRow->wasNull() )
+ if ( pKeyProps.get() )
+ {
+ }
+
+
+ if ( sFkName.getLength() && !xRow->wasNull() )
+ {
+ if ( sOldFKName != sFkName )
{
- ::rtl::OUString sReferencedName;
- sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,sal_False,::dbtools::eInDataManipulation);
- m_aKeys.insert(TKeyMap::value_type(sFkName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule))));
+ if ( pKeyProps.get() )
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps));
+
+ const ::rtl::OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,sal_False,::dbtools::eInDataManipulation);
+ pKeyProps.reset(new sdbcx::KeyProperties(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule));
+ pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
_rNames.push_back(sFkName);
+ if ( m_pTables->hasByName(sReferencedName) )
+ {
+ if ( !m_pImpl->m_xTablePropertyListener.is() )
+ m_pImpl->m_xTablePropertyListener = ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>( new OTableContainerListener(this) );
+ m_pTables->addContainerListener(m_pImpl->m_xTablePropertyListener.getRef());
+ m_pImpl->m_xTablePropertyListener->add(sReferencedName);
+ } // if ( m_pTables->hasByName(sReferencedName) )
+ sOldFKName = sFkName;
+ } // if ( sOldFKName != sFkName )
+ else if ( pKeyProps.get() )
+ {
+ pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
}
}
- }
+ } // while( xResult->next() )
+ if ( pKeyProps.get() )
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps));
::comphelper::disposeComponent(xResult);
}
}
// -------------------------------------------------------------------------
void OTableHelper::refreshKeys()
{
- m_aKeys.clear();
+ m_pImpl->m_aKeys.clear();
TStringVector aNames;
@@ -386,7 +496,7 @@ void SAL_CALL OTableHelper::rename( const ::rtl::OUString& newName ) throw(SQLEx
sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
sSql += sComposedName;
- Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
if ( xStmt.is() )
{
xStmt->execute(sSql);
@@ -401,7 +511,7 @@ void SAL_CALL OTableHelper::rename( const ::rtl::OUString& newName ) throw(SQLEx
// -----------------------------------------------------------------------------
Reference< XDatabaseMetaData> OTableHelper::getMetaData() const
{
- return m_xMetaData;
+ return m_pImpl->m_xMetaData;
}
// -------------------------------------------------------------------------
void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
@@ -441,8 +551,8 @@ void SAL_CALL OTableHelper::release() throw()
sdbcx::TKeyProperties OTableHelper::getKeyProperties(const ::rtl::OUString& _sName) const
{
sdbcx::TKeyProperties pKeyProps;
- TKeyMap::const_iterator aFind = m_aKeys.find(_sName);
- if ( aFind != m_aKeys.end() )
+ TKeyMap::const_iterator aFind = m_pImpl->m_aKeys.find(_sName);
+ if ( aFind != m_pImpl->m_aKeys.end() )
{
pKeyProps = aFind->second;
}
@@ -457,7 +567,7 @@ sdbcx::TKeyProperties OTableHelper::getKeyProperties(const ::rtl::OUString& _sNa
// -----------------------------------------------------------------------------
void OTableHelper::addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties)
{
- m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties));
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties));
}
// -----------------------------------------------------------------------------
::rtl::OUString OTableHelper::getTypeCreatePattern() const
@@ -465,4 +575,7 @@ void OTableHelper::addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyPropert
return ::rtl::OUString();
}
// -----------------------------------------------------------------------------
-
+Reference< XConnection> OTableHelper::getConnection() const
+{
+ return m_pImpl->m_xConnection;
+}
diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx
index 2d4e51b305..d2682adf7b 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -99,9 +99,9 @@ namespace dbtools
::rtl::OUStringBuffer aTemp(toDateString(aDate));
aTemp.appendAscii(" ");
Time aTime(0,_rDateTime.Seconds,_rDateTime.Minutes,_rDateTime.Hours);
- aTemp.append(toTimeString(aTime));
+ aTemp.append( toTimeString(aTime) );
aTemp.appendAscii(".");
- aTemp.append(static_cast<sal_Int32>(_rDateTime.HundredthSeconds));
+ aTemp.append( static_cast<sal_Int32>(_rDateTime.HundredthSeconds));
return aTemp.makeStringAndClear();
}
//------------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx
index 064cb08159..2f9495e11a 100644
--- a/connectivity/source/commontools/dbmetadata.cxx
+++ b/connectivity/source/commontools/dbmetadata.cxx
@@ -157,10 +157,9 @@ namespace dbtools
const DatabaseMetaData_Impl& _metaData, ::boost::optional< ::rtl::OUString >& _cachedSetting,
::rtl::OUString (SAL_CALL XDatabaseMetaData::*_getter)() )
{
- lcl_checkConnected( _metaData );
-
if ( !_cachedSetting )
{
+ lcl_checkConnected( _metaData );
try
{
_cachedSetting.reset( (_metaData.xConnectionMetaData.get()->*_getter)() );
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index bfbfdc7383..eaf1d6fe8e 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -842,9 +842,8 @@ static ::rtl::OUString impl_doComposeTableName( const Reference< XDatabaseMetaDa
return ::rtl::OUString();
OSL_ENSURE(_rName.getLength(), "impl_doComposeTableName : at least the name should be non-empty !");
- ::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
-
- NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
+ const ::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
+ const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
::rtl::OUStringBuffer aComposedName;
diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx
index c9b4990f85..86a7f1e601 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -384,7 +384,7 @@ namespace
}
namespace
{
- Reference<XPropertySet> lcl_createSDBCXColumn(
+ Reference<XPropertySet> lcl_createSDBCXColumn(const Reference<XNameAccess>& _xPrimaryKeyColumns,
const Reference<XConnection>& _xConnection,
const Any& _aCatalog,
const ::rtl::OUString& _aSchema,
@@ -424,8 +424,7 @@ namespace
const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString();
::rtl::OUString sQuotedName = ::dbtools::quoteName(sQuote,_rName);
::rtl::OUString sComposedName;
- sComposedName = composeTableNameForSelect(
- _xConnection, getString( _aCatalog ), _aSchema, _aTable );
+ sComposedName = composeTableNameForSelect(_xConnection, getString( _aCatalog ), _aSchema, _aTable );
ColumnInformationMap aInfo(_bCase);
collectColumnInformation(_xConnection,sComposedName,sQuotedName,aInfo);
@@ -445,11 +444,19 @@ namespace
{
try
{
- Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable );
- Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW );
- while( xPKeys->next() ) // there can be only one primary key
+ if ( _xPrimaryKeyColumns.is() )
+ {
+ if ( _xPrimaryKeyColumns->hasByName(_rName) )
+ nField11 = ColumnValue::NO_NULLS;
+
+ }
+ else
+ {
+ Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable );
+ Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW );
+ while( xPKeys->next() ) // there can be only one primary key
{
- ::rtl::OUString sKeyColumn = xPKeyRow->getString(4);
+ ::rtl::OUString sKeyColumn = xPKeyRow->getString(4);
if ( aMixCompare(_rName,sKeyColumn) )
{
nField11 = ColumnValue::NO_NULLS;
@@ -457,6 +464,7 @@ namespace
}
}
}
+ }
catch(SQLException&)
{
OSL_ENSURE( false, "lcl_createSDBCXColumn: caught an exception!" );
@@ -521,10 +529,33 @@ Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable
_xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
_xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
- xProp = lcl_createSDBCXColumn(_xConnection,aCatalog, aSchema, aTable, _rName,_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
+ Reference<XKeysSupplier> xKeysSup(_xTable,UNO_QUERY);
+ Reference<XNameAccess> xPrimaryKeyColumns;
+ if ( xKeysSup.is() )
+ {
+ const Reference<XIndexAccess> xKeys = xKeysSup->getKeys();
+ if ( xKeys.is() )
+ {
+ const sal_Int32 nKeyCount = xKeys->getCount();
+ for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++nKeyIter)
+ {
+ const Reference<XPropertySet> xKey(xKeys->getByIndex(nKeyIter),UNO_QUERY_THROW);
+ sal_Int32 nType = 0;
+ xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ if ( nType == KeyType::PRIMARY )
+ {
+ const Reference<XColumnsSupplier> xColS(xKey,UNO_QUERY_THROW);
+ xPrimaryKeyColumns = xColS->getColumns();
+ break;
+ }
+ } // for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++)
+ }
+ }
+
+ xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, _rName,_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
if ( !xProp.is() )
{
- xProp = lcl_createSDBCXColumn(_xConnection,aCatalog, aSchema, aTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
+ xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
if ( !xProp.is() )
xProp = new connectivity::sdbcx::OColumn(_rName,
::rtl::OUString(),::rtl::OUString(),
diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx
index 837fb1ddfb..9114f20e12 100644
--- a/connectivity/source/commontools/parameters.cxx
+++ b/connectivity/source/commontools/parameters.cxx
@@ -118,7 +118,7 @@ namespace dbtools
//--------------------------------------------------------------------
void ParameterManager::clearAllParameterInformation()
{
- m_xInnerParamColumns = NULL;
+ m_xInnerParamColumns.clear();
if ( m_pOuterParameters.is() )
m_pOuterParameters->dispose();
m_pOuterParameters = NULL;
diff --git a/connectivity/source/cpool/ZConnectionPool.cxx b/connectivity/source/cpool/ZConnectionPool.cxx
index 3d708e10a7..d40aeccda0 100644
--- a/connectivity/source/cpool/ZConnectionPool.cxx
+++ b/connectivity/source/cpool/ZConnectionPool.cxx
@@ -181,8 +181,8 @@ void OConnectionPool::clear(sal_Bool _bDispose)
if (xProp.is())
xProp->removePropertyChangeListener(getTimeoutNodeName(),this);
- m_xDriverNode = NULL;
- m_xDriver = NULL;
+m_xDriverNode.clear();
+m_xDriver.clear();
}
//--------------------------------------------------------------------------
Reference< XConnection > SAL_CALL OConnectionPool::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
@@ -223,7 +223,7 @@ void SAL_CALL OConnectionPool::disposing( const ::com::sun::star::lang::EventObj
}
else
{
- m_xDriverNode = NULL;
+ m_xDriverNode.clear();
}
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx
index a4a3aa1780..679ea8d611 100644
--- a/connectivity/source/cpool/ZPoolCollection.cxx
+++ b/connectivity/source/cpool/ZPoolCollection.cxx
@@ -507,7 +507,7 @@ void SAL_CALL OPoolCollection::disposing( const EventObject& Source ) throw (Run
{
if ( xProp.is() )
xProp->removePropertyChangeListener(getEnablePoolingNodeName(),this);
- m_xConfigNode = NULL;
+ m_xConfigNode.clear();
}
else if ( xProp.is() )
xProp->removePropertyChangeListener(getEnableNodeName(),this);
@@ -577,7 +577,7 @@ void OPoolCollection::clearDesktop()
clearConnectionPools(sal_True);
if ( m_xDesktop.is() )
m_xDesktop->removeTerminateListener(this);
- m_xDesktop = NULL;
+m_xDesktop.clear();
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/cpool/ZPooledConnection.cxx b/connectivity/source/cpool/ZPooledConnection.cxx
index 8ee7adf6d2..64293811d5 100644
--- a/connectivity/source/cpool/ZPooledConnection.cxx
+++ b/connectivity/source/cpool/ZPooledConnection.cxx
@@ -64,14 +64,14 @@ void SAL_CALL OPooledConnection::disposing(void)
MutexGuard aGuard(m_aMutex);
if (m_xComponent.is())
m_xComponent->removeEventListener(this);
- m_xComponent = NULL;
+m_xComponent.clear();
::comphelper::disposeComponent(m_xRealConnection);
}
// -----------------------------------------------------------------------------
// XEventListener
void SAL_CALL OPooledConnection::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
{
- m_xComponent = NULL;
+m_xComponent.clear();
}
// -----------------------------------------------------------------------------
//XPooledConnection
diff --git a/connectivity/source/drivers/adabas/BConnection.cxx b/connectivity/source/drivers/adabas/BConnection.cxx
index 0eb8a5a727..151b886fd7 100644
--- a/connectivity/source/drivers/adabas/BConnection.cxx
+++ b/connectivity/source/drivers/adabas/BConnection.cxx
@@ -223,10 +223,7 @@ Reference< XPreparedStatement > SAL_CALL OAdabasConnection::prepareStatement( co
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
- if(m_aTypeInfo.empty())
- buildTypeInfo();
-
- Reference< XPreparedStatement > xReturn = new OAdabasPreparedStatement(this,m_aTypeInfo,sql);
+ Reference< XPreparedStatement > xReturn = new OAdabasPreparedStatement(this,sql);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
}
diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx
index 8f8870ad91..bcdd09cb7e 100644
--- a/connectivity/source/drivers/adabas/BDriver.cxx
+++ b/connectivity/source/drivers/adabas/BDriver.cxx
@@ -317,7 +317,7 @@ void SAL_CALL ODriver::disposing( const EventObject& Source ) throw(RuntimeExcep
}
}
}
- m_xORB = NULL;
+ m_xORB.clear();
}
}
// --------------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/adabas/BPreparedStatement.cxx b/connectivity/source/drivers/adabas/BPreparedStatement.cxx
index 4a4de6808a..3b398c8044 100644
--- a/connectivity/source/drivers/adabas/BPreparedStatement.cxx
+++ b/connectivity/source/drivers/adabas/BPreparedStatement.cxx
@@ -48,8 +48,8 @@ using namespace com::sun::star::container;
using namespace com::sun::star::io;
using namespace com::sun::star::util;
-OAdabasPreparedStatement::OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql)
-: ::connectivity::odbc::OPreparedStatement( _pConnection,_TypeInfo,sql)
+OAdabasPreparedStatement::OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::rtl::OUString& sql)
+: ::connectivity::odbc::OPreparedStatement( _pConnection,sql)
{
m_aSelectColumns = _pConnection->createSelectColumns(sql);
}
diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx
index fb4b8c6780..0d16aeba65 100644
--- a/connectivity/source/drivers/adabas/BTables.cxx
+++ b/connectivity/source/drivers/adabas/BTables.cxx
@@ -96,7 +96,7 @@ void OTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/adabas/BViews.cxx b/connectivity/source/drivers/adabas/BViews.cxx
index bac78d2b7a..b62f0d12ca 100644
--- a/connectivity/source/drivers/adabas/BViews.cxx
+++ b/connectivity/source/drivers/adabas/BViews.cxx
@@ -110,7 +110,7 @@ void OViews::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OViews::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx
index 39e933cf24..783707b8e0 100644
--- a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx
@@ -100,7 +100,7 @@ void ODatabaseMetaDataResultSet::disposing(void)
if(m_pRecordSet)
m_pRecordSet->Close();
m_aStatement = NULL;
- m_xMetaData = NULL;
+m_xMetaData.clear();
}
// -------------------------------------------------------------------------
Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx
index 33c1f80b4a..6ff8dedcf7 100644
--- a/connectivity/source/drivers/ado/ADriver.cxx
+++ b/connectivity/source/drivers/ado/ADriver.cxx
@@ -39,6 +39,8 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include "connectivity/dbexception.hxx"
#include "resource/ado_res.hrc"
+#include <Objbase.h>
+
#include "resource/sharedresources.hxx"
@@ -57,12 +59,19 @@ ODriver::ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang:
: ODriver_BASE(m_aMutex)
,m_xORB(_xORB)
{
- CoInitialize(NULL);
+ if ( FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) )
+ {
+ CoUninitialize();
+ int h = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ (void)h;
+ ++h;
+ }
}
// -------------------------------------------------------------------------
ODriver::~ODriver()
{
CoUninitialize();
+ CoInitialize(NULL);
}
//------------------------------------------------------------------------------
void ODriver::disposing()
diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx
index 517d17dd0c..38284a3d42 100644
--- a/connectivity/source/drivers/ado/APreparedStatement.cxx
+++ b/connectivity/source/drivers/ado/APreparedStatement.cxx
@@ -135,7 +135,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) thr
// -------------------------------------------------------------------------
void OPreparedStatement::disposing()
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
if (m_pParameters)
{
m_pParameters->Release();
@@ -295,7 +295,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLE
// first clear the old things
- m_xMetaData = NULL;
+m_xMetaData.clear();
disposeResultSet();
if(m_RecordSet.IsValid())
m_RecordSet.Close();
diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx
index f84a85eacc..10295db9a4 100644
--- a/connectivity/source/drivers/ado/AResultSet.cxx
+++ b/connectivity/source/drivers/ado/AResultSet.cxx
@@ -139,8 +139,8 @@ void OResultSet::disposing(void)
::osl::MutexGuard aGuard(m_aMutex);
if(m_pRecordSet)
m_pRecordSet->Close();
- m_xStatement = NULL;
- m_xMetaData = NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
}
// -------------------------------------------------------------------------
Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
diff --git a/connectivity/source/drivers/ado/Aservices.cxx b/connectivity/source/drivers/ado/Aservices.cxx
index 513d6b1454..00ae2a249b 100644
--- a/connectivity/source/drivers/ado/Aservices.cxx
+++ b/connectivity/source/drivers/ado/Aservices.cxx
@@ -121,7 +121,7 @@ extern "C" void SAL_CALL component_getImplementationEnvironment(
uno_Environment ** /*ppEnv*/
)
{
- *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
}
//---------------------------------------------------------------------------------------
@@ -143,7 +143,7 @@ extern "C" sal_Bool SAL_CALL component_writeInfo(
}
catch (::com::sun::star::registry::InvalidRegistryException& )
{
- OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ OSL_ENSURE(sal_False, "ADO::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
}
return sal_False;
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index d776a91c74..216dc2d9fc 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -1765,7 +1765,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const
m_pColumns->getByIndex(i) >>= xCol;
OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
- xCol = NULL;
+ xCol.clear();
} // if ( !aColName.getLength() )
const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
STR_DUPLICATE_VALUE_IN_COLUMN
diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx
index 7cf0824886..2324ec7a7d 100644
--- a/connectivity/source/drivers/evoab2/NDriver.cxx
+++ b/connectivity/source/drivers/evoab2/NDriver.cxx
@@ -82,7 +82,7 @@ void OEvoabDriver::disposing()
xComp->dispose();
}
catch (com::sun::star::lang::DisposedException e) {
- xComp=NULL;
+ xComp.clear();
}
}
}
diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx
index 1b79c43af7..c7e6a1617d 100644
--- a/connectivity/source/drivers/evoab2/NResultSet.cxx
+++ b/connectivity/source/drivers/evoab2/NResultSet.cxx
@@ -579,7 +579,7 @@ void OEvoabResultSet::disposing(void)
g_list_free(m_pContacts);
m_pContacts = NULL;
m_pStatement = NULL;
- m_xMetaData = NULL;
+m_xMetaData.clear();
}
// -------------------------------------------------------------------------
Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx
index 65cb703ffa..120ceb5248 100644
--- a/connectivity/source/drivers/evoab2/NStatement.cxx
+++ b/connectivity/source/drivers/evoab2/NStatement.cxx
@@ -463,7 +463,7 @@ rtl::OUString OCommonStatement::getTableName()
if( m_aSQLIterator.isTableNode( pAllTableNames->getChild( 0 ) ) )
OSQLParseNode::getTableComponents( pAllTableNames->getChild( 0 ),
- aCatalog,aSchema, aTableName );
+ aCatalog,aSchema, aTableName,NULL );
else if( SQL_ISRULE( pAllTableNames->getChild( 0 ), table_ref ) )
{
@@ -472,7 +472,7 @@ rtl::OUString OCommonStatement::getTableName()
{
aTableName = OSQLParseNode::getTableRange(pAllTableNames->getChild( 0 ));
if( !aTableName.getLength() )
- OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName);
+ OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName,NULL);
}
else
OSL_ENSURE( false, "odd table layout" );
diff --git a/connectivity/source/drivers/evoab2/NTables.cxx b/connectivity/source/drivers/evoab2/NTables.cxx
index 8b3d1a6532..0109d9f126 100644
--- a/connectivity/source/drivers/evoab2/NTables.cxx
+++ b/connectivity/source/drivers/evoab2/NTables.cxx
@@ -101,7 +101,7 @@ void OEvoabTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OEvoabTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx
index b98896786f..8dba811f7a 100644
--- a/connectivity/source/drivers/file/FCatalog.cxx
+++ b/connectivity/source/drivers/file/FCatalog.cxx
@@ -58,7 +58,7 @@ void SAL_CALL OFileCatalog::disposing()
::osl::MutexGuard aGuard(m_aMutex);
typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
- m_xMetaData = NULL;
+m_xMetaData.clear();
OFileCatalog_BASE::disposing();
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx
index 4b68c873f1..1894e34d91 100644
--- a/connectivity/source/drivers/file/FConnection.cxx
+++ b/connectivity/source/drivers/file/FConnection.cxx
@@ -383,8 +383,8 @@ void OConnection::disposing()
OConnection_BASE::disposing();
m_bClosed = sal_True;
- m_xDir = NULL;
- m_xContent = NULL;
+m_xDir.clear();
+m_xContent.clear();
m_xCatalog = WeakReference< XTablesSupplier>();
dispose_ChildImpl();
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index 82eea55ba8..914dddc59e 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -98,9 +98,7 @@ void OPreparedStatement::disposing()
}
m_xParamColumns = NULL;
-
-
- m_xMetaData = NULL;
+ m_xMetaData.clear();
if(m_aParameterRow.isValid())
{
m_aParameterRow->get().clear();
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index ae614f0c28..2a373922d6 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -174,13 +174,13 @@ void OResultSet::disposing(void)
OPropertySetHelper::disposing();
::osl::MutexGuard aGuard(m_aMutex);
- m_xStatement = NULL;
- m_xMetaData = NULL;
+ m_xStatement.clear();
+ m_xMetaData.clear();
m_pParseTree = NULL;
- m_xColNames = NULL;
- m_xColumns = NULL;
+ m_xColNames.clear();
+ m_xColumns = NULL;
m_xParamColumns = NULL;
- m_xColsIdx = NULL;
+ m_xColsIdx.clear();
Reference<XComponent> xComp = m_pTable;
if ( xComp.is() )
diff --git a/connectivity/source/drivers/file/FTables.cxx b/connectivity/source/drivers/file/FTables.cxx
index 0e02147df8..b9233eb8b0 100644
--- a/connectivity/source/drivers/file/FTables.cxx
+++ b/connectivity/source/drivers/file/FTables.cxx
@@ -68,7 +68,7 @@ void OTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
//------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index c402bdefc5..81c4fc052c 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -79,7 +79,7 @@ void OPredicateCompiler::dispose()
{
Clean();
m_orgColumns = NULL;
- m_xIndexes = NULL;
+m_xIndexes.clear();
}
//------------------------------------------------------------------
// inline OCursor& OPredicateCompiler::Cursor() const {return m_rCursor;}
diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
index 79bfb4be47..712c38eea0 100644
--- a/connectivity/source/drivers/hsqldb/HStorageMap.cxx
+++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
@@ -64,12 +64,12 @@ namespace connectivity
{
try
{
- m_xStream = NULL;
- m_xSeek = NULL;
+ m_xStream.clear();
+ m_xSeek.clear();
if ( m_xInputStream.is() )
{
m_xInputStream->closeInput();
- m_xInputStream = NULL;
+ m_xInputStream.clear();
}
if ( m_xOutputStream.is() )
{
@@ -86,7 +86,7 @@ namespace connectivity
OSL_UNUSED( e );
OSL_ENSURE(0,"Could not dispose OutputStream");
}
- m_xOutputStream = NULL;
+ m_xOutputStream.clear();
}
}
catch(Exception& )
diff --git a/connectivity/source/drivers/hsqldb/HTables.cxx b/connectivity/source/drivers/hsqldb/HTables.cxx
index 0e4f6fb6c8..9b3c08aa28 100644
--- a/connectivity/source/drivers/hsqldb/HTables.cxx
+++ b/connectivity/source/drivers/hsqldb/HTables.cxx
@@ -113,7 +113,7 @@ void OTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/HViews.cxx b/connectivity/source/drivers/hsqldb/HViews.cxx
index 4806203641..9c20fc0404 100644
--- a/connectivity/source/drivers/hsqldb/HViews.cxx
+++ b/connectivity/source/drivers/hsqldb/HViews.cxx
@@ -93,7 +93,7 @@ void HViews::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void HViews::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx
index aeec9ee2d1..e1066776a5 100644
--- a/connectivity/source/drivers/jdbc/JDriver.cxx
+++ b/connectivity/source/drivers/jdbc/JDriver.cxx
@@ -118,7 +118,7 @@ Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUStrin
java_sql_Connection* pConnection = new java_sql_Connection( *this );
xOut = pConnection;
if ( !pConnection->construct(url,info) )
- xOut = NULL; // an error occured and the java driver didn't throw an exception
+ xOut.clear(); // an error occured and the java driver didn't throw an exception
else
m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS );
}
diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx
index 7bcd93f23b..8a5a9a22a0 100644
--- a/connectivity/source/drivers/jdbc/ResultSet.cxx
+++ b/connectivity/source/drivers/jdbc/ResultSet.cxx
@@ -116,7 +116,7 @@ void java_sql_ResultSet::disposing(void)
OPropertySetHelper::disposing();
::osl::MutexGuard aGuard(m_aMutex);
- m_xMetaData = NULL;
+m_xMetaData.clear();
if( object )
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
diff --git a/connectivity/source/drivers/kab/KResultSet.cxx b/connectivity/source/drivers/kab/KResultSet.cxx
index 1455fd2b94..91ef3f6cae 100644
--- a/connectivity/source/drivers/kab/KResultSet.cxx
+++ b/connectivity/source/drivers/kab/KResultSet.cxx
@@ -124,8 +124,8 @@ void KabResultSet::disposing()
::osl::MutexGuard aGuard(m_aMutex);
- m_xStatement = NULL;
- m_xMetaData = NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
}
// -------------------------------------------------------------------------
Any SAL_CALL KabResultSet::queryInterface(const Type & rType) throw(RuntimeException)
diff --git a/connectivity/source/drivers/kab/KTables.cxx b/connectivity/source/drivers/kab/KTables.cxx
index 931e537a46..82131b8538 100644
--- a/connectivity/source/drivers/kab/KTables.cxx
+++ b/connectivity/source/drivers/kab/KTables.cxx
@@ -88,6 +88,6 @@ void KabTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void KabTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
diff --git a/connectivity/source/drivers/macab/MacabResultSet.cxx b/connectivity/source/drivers/macab/MacabResultSet.cxx
index 25113f9cf3..5a5d660c60 100755
--- a/connectivity/source/drivers/macab/MacabResultSet.cxx
+++ b/connectivity/source/drivers/macab/MacabResultSet.cxx
@@ -151,8 +151,8 @@ void MacabResultSet::disposing()
::osl::MutexGuard aGuard(m_aMutex);
- m_xStatement = NULL;
- m_xMetaData = NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
}
// -------------------------------------------------------------------------
Any SAL_CALL MacabResultSet::queryInterface(const Type & rType) throw(RuntimeException)
diff --git a/connectivity/source/drivers/macab/MacabTables.cxx b/connectivity/source/drivers/macab/MacabTables.cxx
index 82ccac7f97..7fa211ad76 100755
--- a/connectivity/source/drivers/macab/MacabTables.cxx
+++ b/connectivity/source/drivers/macab/MacabTables.cxx
@@ -88,6 +88,6 @@ void MacabTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void MacabTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
diff --git a/connectivity/source/drivers/mozab/MPreparedStatement.cxx b/connectivity/source/drivers/mozab/MPreparedStatement.cxx
index b3fd20bd2f..07e7551a8a 100644
--- a/connectivity/source/drivers/mozab/MPreparedStatement.cxx
+++ b/connectivity/source/drivers/mozab/MPreparedStatement.cxx
@@ -91,7 +91,7 @@ void SAL_CALL OPreparedStatement::disposing()
OCommonStatement::disposing();
- m_xMetaData = NULL;
+ m_xMetaData.clear();
if(m_aParameterRow.isValid())
{
m_aParameterRow->get().clear();
diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx
index f3755e95ab..081ff8369f 100644
--- a/connectivity/source/drivers/mozab/MResultSet.cxx
+++ b/connectivity/source/drivers/mozab/MResultSet.cxx
@@ -139,10 +139,10 @@ void OResultSet::disposing(void)
::osl::MutexGuard aGuard(m_aMutex);
- m_xStatement = NULL;
- m_xMetaData = NULL;
+ m_xStatement.clear();
+ m_xMetaData.clear();
m_pParseTree = NULL;
- m_xColumns = NULL;
+ m_xColumns = NULL;
m_xParamColumns = NULL;
m_pKeySet = NULL;
if(m_pTable)
diff --git a/connectivity/source/drivers/mozab/MResultSetMetaData.cxx b/connectivity/source/drivers/mozab/MResultSetMetaData.cxx
index ccfe2e3e90..a4d468d795 100644
--- a/connectivity/source/drivers/mozab/MResultSetMetaData.cxx
+++ b/connectivity/source/drivers/mozab/MResultSetMetaData.cxx
@@ -50,7 +50,7 @@ using namespace ::comphelper;
// -------------------------------------------------------------------------
OResultSetMetaData::~OResultSetMetaData()
{
- m_xColumns = NULL;
+ m_xColumns = NULL;
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mozab/MTables.cxx b/connectivity/source/drivers/mozab/MTables.cxx
index f04a9308e9..c6bac0f566 100644
--- a/connectivity/source/drivers/mozab/MTables.cxx
+++ b/connectivity/source/drivers/mozab/MTables.cxx
@@ -100,7 +100,7 @@ void OTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mysql/YTables.cxx b/connectivity/source/drivers/mysql/YTables.cxx
index 077adb5faa..8b2626d612 100644
--- a/connectivity/source/drivers/mysql/YTables.cxx
+++ b/connectivity/source/drivers/mysql/YTables.cxx
@@ -130,7 +130,7 @@ void OTables::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OTables::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mysql/YViews.cxx b/connectivity/source/drivers/mysql/YViews.cxx
index adeeb229da..3a2e133421 100644
--- a/connectivity/source/drivers/mysql/YViews.cxx
+++ b/connectivity/source/drivers/mysql/YViews.cxx
@@ -87,7 +87,7 @@ void OViews::impl_refresh( ) throw(RuntimeException)
// -------------------------------------------------------------------------
void OViews::disposing(void)
{
- m_xMetaData = NULL;
+m_xMetaData.clear();
OCollection::disposing();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/odbcbase/OConnection.cxx b/connectivity/source/drivers/odbcbase/OConnection.cxx
index fdc2985086..7465a6bc9d 100644
--- a/connectivity/source/drivers/odbcbase/OConnection.cxx
+++ b/connectivity/source/drivers/odbcbase/OConnection.cxx
@@ -69,6 +69,7 @@ OConnection::OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver)
,m_bParameterSubstitution(sal_False)
,m_bIgnoreDriverPrivileges(sal_False)
,m_bPreventGetVersionColumns(sal_False)
+ ,m_bReadOnly(sal_True)
{
m_pDriver->acquire();
}
@@ -104,7 +105,6 @@ SQLRETURN OConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int
if (m_aConnectionHandle == SQL_NULL_HANDLE)
return -1;
- sal_Bool bReadOnly; //weil Methode statisch hier noch einmal ein lokales bReadOnly
SQLRETURN nSQLRETURN = 0;
SDB_ODBC_CHAR szConnStrOut[4096];
SDB_ODBC_CHAR szConnStrIn[2048];
@@ -153,11 +153,11 @@ SQLRETURN OConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int
{
::rtl::OUString aVal;
OTools::GetInfo(this,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aVal,*this,getTextEncoding());
- bReadOnly = !aVal.compareToAscii("Y");
+ m_bReadOnly = !aVal.compareToAscii("Y");
}
catch(Exception&)
{
- bReadOnly = sal_True;
+ m_bReadOnly = sal_True;
}
try
{
@@ -172,7 +172,7 @@ SQLRETURN OConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int
// autocoomit ist immer default
- if (!bReadOnly)
+ if (!m_bReadOnly)
N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER);
return nSQLRETURN;
@@ -299,10 +299,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- if(m_aTypeInfo.empty())
- buildTypeInfo();
-
- Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,m_aTypeInfo,sql);
+ Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,sql);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
}
@@ -399,15 +396,10 @@ void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException,
m_aConnectionHandle,SQL_HANDLE_DBC,*this);
}
// --------------------------------------------------------------------------------
-sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OConnection_BASE::rBHelper.bDisposed);
-
-
- ::rtl::OUString aValue;
- OTools::GetInfo(this,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aValue,*this,getTextEncoding());
- return !aValue.compareToAscii("Y");
+ // const member which will initialized only once
+ return m_bReadOnly;
}
// --------------------------------------------------------------------------------
void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
index 60e185b4a7..97edeeffeb 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
@@ -43,6 +43,7 @@
#include "stdio.h"
#include "TPrivilegesResultSet.hxx"
#include <connectivity/dbexception.hxx>
+#include <rtl/ustrbuf.hxx>
using namespace connectivity::odbc;
using namespace com::sun::star::uno;
@@ -830,9 +831,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLExcepti
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
{
- ::rtl::OUString aValue;
- OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aValue,*this,m_pConnection->getTextEncoding());
- return aValue.toChar() == 'Y';
+ return m_pConnection->isReadOnly();
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
@@ -1324,186 +1323,197 @@ sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeExc
::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
{
SQLUINTEGER nValue;
- ::rtl::OUString aValue;
+ ::rtl::OUStringBuffer aValue;
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this);
if(nValue & SQL_FN_STR_ASCII)
- aValue = ::rtl::OUString::createFromAscii("ASCII,");
+ aValue.appendAscii("ASCII,");
if(nValue & SQL_FN_STR_BIT_LENGTH)
- aValue += ::rtl::OUString::createFromAscii("BIT_LENGTH,");
+ aValue.appendAscii("BIT_LENGTH,");
if(nValue & SQL_FN_STR_CHAR)
- aValue += ::rtl::OUString::createFromAscii("CHAR,");
+ aValue.appendAscii("CHAR,");
if(nValue & SQL_FN_STR_CHAR_LENGTH)
- aValue += ::rtl::OUString::createFromAscii("CHAR_LENGTH,");
+ aValue.appendAscii("CHAR_LENGTH,");
if(nValue & SQL_FN_STR_CHARACTER_LENGTH)
- aValue += ::rtl::OUString::createFromAscii("CHARACTER_LENGTH,");
+ aValue.appendAscii("CHARACTER_LENGTH,");
if(nValue & SQL_FN_STR_CONCAT)
- aValue += ::rtl::OUString::createFromAscii("CONCAT,");
+ aValue.appendAscii("CONCAT,");
if(nValue & SQL_FN_STR_DIFFERENCE)
- aValue += ::rtl::OUString::createFromAscii("DIFFERENCE,");
+ aValue.appendAscii("DIFFERENCE,");
if(nValue & SQL_FN_STR_INSERT)
- aValue += ::rtl::OUString::createFromAscii("INSERT,");
+ aValue.appendAscii("INSERT,");
if(nValue & SQL_FN_STR_LCASE)
- aValue += ::rtl::OUString::createFromAscii("LCASE,");
+ aValue.appendAscii("LCASE,");
if(nValue & SQL_FN_STR_LEFT)
- aValue += ::rtl::OUString::createFromAscii("LEFT,");
+ aValue.appendAscii("LEFT,");
if(nValue & SQL_FN_STR_LENGTH)
- aValue += ::rtl::OUString::createFromAscii("LENGTH,");
+ aValue.appendAscii("LENGTH,");
if(nValue & SQL_FN_STR_LOCATE)
- aValue += ::rtl::OUString::createFromAscii("LOCATE,");
+ aValue.appendAscii("LOCATE,");
if(nValue & SQL_FN_STR_LOCATE_2)
- aValue += ::rtl::OUString::createFromAscii("LOCATE_2,");
+ aValue.appendAscii("LOCATE_2,");
if(nValue & SQL_FN_STR_LTRIM)
- aValue += ::rtl::OUString::createFromAscii("LTRIM,");
+ aValue.appendAscii("LTRIM,");
if(nValue & SQL_FN_STR_OCTET_LENGTH)
- aValue += ::rtl::OUString::createFromAscii("OCTET_LENGTH,");
+ aValue.appendAscii("OCTET_LENGTH,");
if(nValue & SQL_FN_STR_POSITION)
- aValue += ::rtl::OUString::createFromAscii("POSITION,");
+ aValue.appendAscii("POSITION,");
if(nValue & SQL_FN_STR_REPEAT)
- aValue += ::rtl::OUString::createFromAscii("REPEAT,");
+ aValue.appendAscii("REPEAT,");
if(nValue & SQL_FN_STR_REPLACE)
- aValue += ::rtl::OUString::createFromAscii("REPLACE,");
+ aValue.appendAscii("REPLACE,");
if(nValue & SQL_FN_STR_RIGHT)
- aValue += ::rtl::OUString::createFromAscii("RIGHT,");
+ aValue.appendAscii("RIGHT,");
if(nValue & SQL_FN_STR_RTRIM)
- aValue += ::rtl::OUString::createFromAscii("RTRIM,");
+ aValue.appendAscii("RTRIM,");
if(nValue & SQL_FN_STR_SOUNDEX)
- aValue += ::rtl::OUString::createFromAscii("SOUNDEX,");
+ aValue.appendAscii("SOUNDEX,");
if(nValue & SQL_FN_STR_SPACE)
- aValue += ::rtl::OUString::createFromAscii("SPACE,");
+ aValue.appendAscii("SPACE,");
if(nValue & SQL_FN_STR_SUBSTRING)
- aValue += ::rtl::OUString::createFromAscii("SUBSTRING,");
+ aValue.appendAscii("SUBSTRING,");
if(nValue & SQL_FN_STR_UCASE)
- aValue += ::rtl::OUString::createFromAscii("UCASE,");
+ aValue.appendAscii("UCASE,");
- return aValue.copy(0,aValue.lastIndexOf(','));
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
{
SQLUINTEGER nValue;
- ::rtl::OUString aValue;
+ ::rtl::OUStringBuffer aValue;
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TIMEDATE_FUNCTIONS,nValue,*this);
if(nValue & SQL_FN_TD_CURRENT_DATE)
- aValue = ::rtl::OUString::createFromAscii("CURRENT_DATE,");
+ aValue.appendAscii("CURRENT_DATE,");
if(nValue & SQL_FN_TD_CURRENT_TIME)
- aValue += ::rtl::OUString::createFromAscii("CURRENT_TIME,");
+ aValue.appendAscii("CURRENT_TIME,");
if(nValue & SQL_FN_TD_CURRENT_TIMESTAMP)
- aValue += ::rtl::OUString::createFromAscii("CURRENT_TIMESTAMP,");
+ aValue.appendAscii("CURRENT_TIMESTAMP,");
if(nValue & SQL_FN_TD_CURDATE)
- aValue += ::rtl::OUString::createFromAscii("CURDATE,");
+ aValue.appendAscii("CURDATE,");
if(nValue & SQL_FN_TD_CURTIME)
- aValue += ::rtl::OUString::createFromAscii("CURTIME,");
+ aValue.appendAscii("CURTIME,");
if(nValue & SQL_FN_TD_DAYNAME)
- aValue += ::rtl::OUString::createFromAscii("DAYNAME,");
+ aValue.appendAscii("DAYNAME,");
if(nValue & SQL_FN_TD_DAYOFMONTH)
- aValue += ::rtl::OUString::createFromAscii("DAYOFMONTH,");
+ aValue.appendAscii("DAYOFMONTH,");
if(nValue & SQL_FN_TD_DAYOFWEEK)
- aValue += ::rtl::OUString::createFromAscii("DAYOFWEEK,");
+ aValue.appendAscii("DAYOFWEEK,");
if(nValue & SQL_FN_TD_DAYOFYEAR)
- aValue += ::rtl::OUString::createFromAscii("DAYOFYEAR,");
+ aValue.appendAscii("DAYOFYEAR,");
if(nValue & SQL_FN_TD_EXTRACT)
- aValue += ::rtl::OUString::createFromAscii("EXTRACT,");
+ aValue.appendAscii("EXTRACT,");
if(nValue & SQL_FN_TD_HOUR)
- aValue += ::rtl::OUString::createFromAscii("HOUR,");
+ aValue.appendAscii("HOUR,");
if(nValue & SQL_FN_TD_MINUTE)
- aValue += ::rtl::OUString::createFromAscii("MINUTE,");
+ aValue.appendAscii("MINUTE,");
if(nValue & SQL_FN_TD_MONTH)
- aValue += ::rtl::OUString::createFromAscii("MONTH,");
+ aValue.appendAscii("MONTH,");
if(nValue & SQL_FN_TD_MONTHNAME)
- aValue += ::rtl::OUString::createFromAscii("MONTHNAME,");
+ aValue.appendAscii("MONTHNAME,");
if(nValue & SQL_FN_TD_NOW)
- aValue += ::rtl::OUString::createFromAscii("NOW,");
+ aValue.appendAscii("NOW,");
if(nValue & SQL_FN_TD_QUARTER)
- aValue += ::rtl::OUString::createFromAscii("QUARTER,");
+ aValue.appendAscii("QUARTER,");
if(nValue & SQL_FN_TD_SECOND)
- aValue += ::rtl::OUString::createFromAscii("SECOND,");
+ aValue.appendAscii("SECOND,");
if(nValue & SQL_FN_TD_TIMESTAMPADD)
- aValue += ::rtl::OUString::createFromAscii("TIMESTAMPADD,");
+ aValue.appendAscii("TIMESTAMPADD,");
if(nValue & SQL_FN_TD_TIMESTAMPDIFF)
- aValue += ::rtl::OUString::createFromAscii("TIMESTAMPDIFF,");
+ aValue.appendAscii("TIMESTAMPDIFF,");
if(nValue & SQL_FN_TD_WEEK)
- aValue += ::rtl::OUString::createFromAscii("WEEK,");
+ aValue.appendAscii("WEEK,");
if(nValue & SQL_FN_TD_YEAR)
- aValue += ::rtl::OUString::createFromAscii("YEAR,");
+ aValue.appendAscii("YEAR,");
- return aValue.copy(0,aValue.lastIndexOf(','));
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
{
SQLUINTEGER nValue;
- ::rtl::OUString aValue;
+ ::rtl::OUStringBuffer aValue;
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SYSTEM_FUNCTIONS,nValue,*this);
if(nValue & SQL_FN_SYS_DBNAME)
- aValue += ::rtl::OUString::createFromAscii("DBNAME,");
+ aValue.appendAscii("DBNAME,");
if(nValue & SQL_FN_SYS_IFNULL)
- aValue += ::rtl::OUString::createFromAscii("IFNULL,");
+ aValue.appendAscii("IFNULL,");
if(nValue & SQL_FN_SYS_USERNAME)
- aValue += ::rtl::OUString::createFromAscii("USERNAME,");
+ aValue.appendAscii("USERNAME,");
- return aValue.copy(0,aValue.lastIndexOf(','));
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
{
SQLUINTEGER nValue;
- ::rtl::OUString aValue;
+ ::rtl::OUStringBuffer aValue;
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NUMERIC_FUNCTIONS,nValue,*this);
if(nValue & SQL_FN_NUM_ABS)
- aValue += ::rtl::OUString::createFromAscii("ABS,");
+ aValue.appendAscii("ABS,");
if(nValue & SQL_FN_NUM_ACOS)
- aValue += ::rtl::OUString::createFromAscii("ACOS,");
+ aValue.appendAscii("ACOS,");
if(nValue & SQL_FN_NUM_ASIN)
- aValue += ::rtl::OUString::createFromAscii("ASIN,");
+ aValue.appendAscii("ASIN,");
if(nValue & SQL_FN_NUM_ATAN)
- aValue += ::rtl::OUString::createFromAscii("ATAN,");
+ aValue.appendAscii("ATAN,");
if(nValue & SQL_FN_NUM_ATAN2)
- aValue += ::rtl::OUString::createFromAscii("ATAN2,");
+ aValue.appendAscii("ATAN2,");
if(nValue & SQL_FN_NUM_CEILING)
- aValue += ::rtl::OUString::createFromAscii("CEILING,");
+ aValue.appendAscii("CEILING,");
if(nValue & SQL_FN_NUM_COS)
- aValue += ::rtl::OUString::createFromAscii("COS,");
+ aValue.appendAscii("COS,");
if(nValue & SQL_FN_NUM_COT)
- aValue += ::rtl::OUString::createFromAscii("COT,");
+ aValue.appendAscii("COT,");
if(nValue & SQL_FN_NUM_DEGREES)
- aValue += ::rtl::OUString::createFromAscii("DEGREES,");
+ aValue.appendAscii("DEGREES,");
if(nValue & SQL_FN_NUM_EXP)
- aValue += ::rtl::OUString::createFromAscii("EXP,");
+ aValue.appendAscii("EXP,");
if(nValue & SQL_FN_NUM_FLOOR)
- aValue += ::rtl::OUString::createFromAscii("FLOOR,");
+ aValue.appendAscii("FLOOR,");
if(nValue & SQL_FN_NUM_LOG)
- aValue += ::rtl::OUString::createFromAscii("LOGF,");
+ aValue.appendAscii("LOGF,");
if(nValue & SQL_FN_NUM_LOG10)
- aValue += ::rtl::OUString::createFromAscii("LOG10,");
+ aValue.appendAscii("LOG10,");
if(nValue & SQL_FN_NUM_MOD)
- aValue += ::rtl::OUString::createFromAscii("MOD,");
+ aValue.appendAscii("MOD,");
if(nValue & SQL_FN_NUM_PI)
- aValue += ::rtl::OUString::createFromAscii("PI,");
+ aValue.appendAscii("PI,");
if(nValue & SQL_FN_NUM_POWER)
- aValue += ::rtl::OUString::createFromAscii("POWER,");
+ aValue.appendAscii("POWER,");
if(nValue & SQL_FN_NUM_RADIANS)
- aValue += ::rtl::OUString::createFromAscii("RADIANS,");
+ aValue.appendAscii("RADIANS,");
if(nValue & SQL_FN_NUM_RAND)
- aValue += ::rtl::OUString::createFromAscii("RAND,");
+ aValue.appendAscii("RAND,");
if(nValue & SQL_FN_NUM_ROUND)
- aValue += ::rtl::OUString::createFromAscii("ROUND,");
+ aValue.appendAscii("ROUND,");
if(nValue & SQL_FN_NUM_SIGN)
- aValue += ::rtl::OUString::createFromAscii("SIGN,");
+ aValue.appendAscii("SIGN,");
if(nValue & SQL_FN_NUM_SIN)
- aValue += ::rtl::OUString::createFromAscii("SIN,");
+ aValue.appendAscii("SIN,");
if(nValue & SQL_FN_NUM_SQRT)
- aValue += ::rtl::OUString::createFromAscii("SQRT,");
+ aValue.appendAscii("SQRT,");
if(nValue & SQL_FN_NUM_TAN)
- aValue += ::rtl::OUString::createFromAscii("TAN,");
+ aValue.appendAscii("TAN,");
if(nValue & SQL_FN_NUM_TRUNCATE)
- aValue += ::rtl::OUString::createFromAscii("TRUNCATE,");
+ aValue.appendAscii("TRUNCATE,");
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
- return aValue.copy(0,aValue.lastIndexOf(','));
+ return aValue.makeStringAndClear();
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
index 2c8f37de5c..773b9c0293 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
@@ -112,7 +112,7 @@ void ODatabaseMetaDataResultSet::disposing(void)
m_pConnection->freeStatementHandle(m_aStatementHandle);
m_aStatement = NULL;
- m_xMetaData = NULL;
+m_xMetaData.clear();
m_pConnection->release();
}
// -------------------------------------------------------------------------
@@ -434,7 +434,7 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex )
columnIndex = mapColumn(columnIndex);
::rtl::OUString aVal;
if(columnIndex <= m_nDriverColumnCount)
- aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,(SWORD)getMetaData()->getColumnType(columnIndex),m_bWasNull,**this,m_nTextEncoding);
+ aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,(SWORD)SQL_C_WCHAR,m_bWasNull,**this,m_nTextEncoding);
else
m_bWasNull = sal_True;
@@ -880,7 +880,8 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUS
else
pSchemaPat = NULL;
- aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ if ( catalog.hasValue() )
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
@@ -1179,8 +1180,10 @@ void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const ::rt
m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN, aFKQ, aFKO, aFKN;
- aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
- aFKQ = ::rtl::OUStringToOString(comphelper::getString(catalog2),m_nTextEncoding);
+ if ( catalog.hasValue() )
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ if ( catalog2.hasValue() )
+ aFKQ = ::rtl::OUStringToOString(comphelper::getString(catalog2),m_nTextEncoding);
const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
*pPKO = schema && schema->getLength() ? ::rtl::OUStringToOString(*schema,m_nTextEncoding).getStr() : NULL,
diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
index ed6b881212..503ceb9905 100644
--- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -65,9 +65,8 @@ using namespace com::sun::star::util;
IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.OPreparedStatement","com.sun.star.sdbc.PreparedStatement");
-OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql)
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql)
:OStatement_BASE2(_pConnection)
- ,m_aTypeInfo(_TypeInfo)
,numParams(0)
,boundParams(NULL)
,m_bPrepared(sal_False)
@@ -80,12 +79,11 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const TTypeInf
OSQLParser aParser(_pConnection->getDriver()->getORB());
::rtl::OUString sErrorMessage;
::rtl::OUString sNewSql;
- OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,sql);
- if(pNode)
+ ::std::auto_ptr<OSQLParseNode> pNode( aParser.parseTree(sErrorMessage,sql) );
+ if ( pNode.get() )
{ // special handling for parameters
- OSQLParseNode::substituteParameterNames(pNode);
+ OSQLParseNode::substituteParameterNames(pNode.get());
pNode->parseNodeToStr( sNewSql, _pConnection );
- delete pNode;
m_sSqlStatement = sNewSql;
}
}
@@ -819,12 +817,18 @@ sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType)
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
sal_Int32 prec = -1;
- if (m_aTypeInfo.size())
+ const TTypeInfoVector& rTypeInfo = m_pConnection->getTypeInfo();
+ if ( !rTypeInfo.empty() )
+ {
+ m_pConnection->buildTypeInfo();
+ }
+
+ if ( !rTypeInfo.empty() )
{
OTypeInfo aInfo;
aInfo.nType = (sal_Int16)sqlType;
- TTypeInfoVector::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo);
- if(aIter != m_aTypeInfo.end())
+ TTypeInfoVector::const_iterator aIter = ::std::find(rTypeInfo.begin(),rTypeInfo.end(),aInfo);
+ if(aIter != rTypeInfo.end())
prec = (*aIter).nPrecision;
}
return prec;
diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx
index 3792efedcd..f43f743b03 100644
--- a/connectivity/source/drivers/odbcbase/OResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx
@@ -188,8 +188,8 @@ void OResultSet::disposing(void)
if(m_bFreeHandle)
m_pStatement->getOwnConnection()->freeStatementHandle(m_aStatementHandle);
- m_xStatement = NULL;
- m_xMetaData = NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
}
// -------------------------------------------------------------------------
SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle)
@@ -1491,7 +1491,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn)
for (; pColumn < pColumnEnd; ++nColumn, ++pColumn)
{
- sal_Int32 nType = pColumn->getTypeKind();
+ const sal_Int32 nType = pColumn->getTypeKind();
switch (nType)
{
case DataType::CHAR:
diff --git a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
index 090cc2cec4..06fab6db28 100644
--- a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
@@ -134,32 +134,38 @@ SWORD OResultSetMetaData::getColumnODBCType(OConnection* _pConnection
{
nType = getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE );
}
+
return nType;
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- sal_Int32 nType = 0;
- if(!m_bUseODBC2Types)
+ ::std::map<sal_Int32,sal_Int32>::iterator aFind = m_aColumnTypes.find(column);
+ if ( aFind == m_aColumnTypes.end() )
{
- try
+ sal_Int32 nType = 0;
+ if(!m_bUseODBC2Types)
{
- nType = getNumColAttrib(column,SQL_DESC_CONCISE_TYPE);
- if(nType == SQL_UNKNOWN_TYPE)
- nType = getNumColAttrib(column, SQL_DESC_TYPE);
- nType = OTools::MapOdbcType2Jdbc(nType);
+ try
+ {
+ nType = getNumColAttrib(column,SQL_DESC_CONCISE_TYPE);
+ if(nType == SQL_UNKNOWN_TYPE)
+ nType = getNumColAttrib(column, SQL_DESC_TYPE);
+ nType = OTools::MapOdbcType2Jdbc(nType);
+ }
+ catch(SQLException& ) // in this case we have an odbc 2.0 driver
+ {
+ m_bUseODBC2Types = sal_True;
+ nType = OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_CONCISE_TYPE ));
+ }
}
- catch(SQLException& ) // in this case we have an odbc 2.0 driver
- {
- m_bUseODBC2Types = sal_True;
+ else
nType = OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_CONCISE_TYPE ));
- }
+ aFind = m_aColumnTypes.insert(::std::map<sal_Int32,sal_Int32>::value_type(column,nType)).first;
}
- else
- nType = OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_CONCISE_TYPE ));
- return nType;
+ return aFind->second;
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index caecaa7bca..9ecc9de7f3 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -571,9 +571,12 @@ Sequence<sal_Int8> OTools::getBytesValue(OConnection* _pConnection,
return ::rtl::OUString();
// Bei Fehler bricht der GETDATA-Makro mit return ab,
// bei NULL mit break!
- SQLINTEGER nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1);
+ SQLINTEGER nRealSize = 0;
+ if ( pcbValue > -1 )
+ nRealSize = pcbValue / sizeof(sal_Unicode);
+ SQLINTEGER nLen = pcbValue != SQL_NO_TOTAL ? std::min(nRealSize, nMaxLen) : (nMaxLen-1);
waCharArray[nLen] = 0;
- aData = ::rtl::OUString(waCharArray);
+ aData.append(waCharArray,nLen);
// Es handelt sich um Binaerdaten, um einen String, der fuer
// StarView zu lang ist oder der Treiber kann die Laenge der
@@ -598,7 +601,10 @@ Sequence<sal_Int8> OTools::getBytesValue(OConnection* _pConnection,
(SQLINTEGER)nLen+1,
&pcbValue),
_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
- nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1);
+ nRealSize = 0;
+ if ( pcbValue > -1 )
+ nRealSize = pcbValue / sizeof(sal_Unicode);
+ nLen = pcbValue != SQL_NO_TOTAL ? std::min(nRealSize, nMaxLen) : (nMaxLen-1);
waCharArray[nLen] = 0;
aData.append(::rtl::OUString(waCharArray));
@@ -628,7 +634,7 @@ Sequence<sal_Int8> OTools::getBytesValue(OConnection* _pConnection,
aCharArray[nLen] = 0;
if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nLen-1] == 0 && nLen > 0 )
--nLen;
- aData = ::rtl::OUString((const sal_Char*)aCharArray,nLen, _nTextEncoding);
+ aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen, _nTextEncoding));
// Es handelt sich um Binaerdaten, um einen String, der fuer
// StarView zu lang ist oder der Treiber kann die Laenge der
diff --git a/connectivity/source/inc/OSubComponent.hxx b/connectivity/source/inc/OSubComponent.hxx
index 642138dbc1..dd6150f4eb 100644
--- a/connectivity/source/inc/OSubComponent.hxx
+++ b/connectivity/source/inc/OSubComponent.hxx
@@ -78,7 +78,7 @@ namespace connectivity
{
// avoid ambiguity
::osl::MutexGuard aGuard( m_pDerivedImplementation->WEAK::rBHelper.rMutex );
- m_xParent = NULL;
+ m_xParent.clear();
}
void relase_ChildImpl()
{
diff --git a/connectivity/source/inc/adabas/BPreparedStatement.hxx b/connectivity/source/inc/adabas/BPreparedStatement.hxx
index 9ec400f67d..a9a863eeda 100644
--- a/connectivity/source/inc/adabas/BPreparedStatement.hxx
+++ b/connectivity/source/inc/adabas/BPreparedStatement.hxx
@@ -46,7 +46,7 @@ namespace connectivity
virtual void setResultSetType(sal_Int32 _par0) ;
virtual void setUsingBookmarks(sal_Bool _bUseBookmark) ;
public:
- OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql);
+ OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::rtl::OUString& sql);
};
}
}
diff --git a/connectivity/source/inc/calc/CConnection.hxx b/connectivity/source/inc/calc/CConnection.hxx
index effca09eba..a6e2d71ed9 100644
--- a/connectivity/source/inc/calc/CConnection.hxx
+++ b/connectivity/source/inc/calc/CConnection.hxx
@@ -87,7 +87,7 @@ namespace connectivity
}
~ODocHolder()
{
- m_xDoc = NULL;
+ m_xDoc.clear();
m_pConnection->releaseDoc();
}
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> getDoc() const { return m_xDoc; }
diff --git a/connectivity/source/inc/odbc/OConnection.hxx b/connectivity/source/inc/odbc/OConnection.hxx
index 49db427860..1b0339a742 100644
--- a/connectivity/source/inc/odbc/OConnection.hxx
+++ b/connectivity/source/inc/odbc/OConnection.hxx
@@ -89,12 +89,11 @@ namespace connectivity
sal_Bool m_bParameterSubstitution;
sal_Bool m_bIgnoreDriverPrivileges;
sal_Bool m_bPreventGetVersionColumns; // #i60273#
+ sal_Bool m_bReadOnly;
SQLRETURN OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent);
- void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
-
virtual OConnection* cloneConnection(); // creates a new connection
public:
@@ -154,6 +153,9 @@ namespace connectivity
SQLHANDLE createStatementHandle();
// close and free the handle and set it to SQL_NULLHANDLE
void freeStatementHandle(SQLHANDLE& _pHandle);
+
+ void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
+ const TTypeInfoVector& getTypeInfo() const { return m_aTypeInfo; }
};
}
}
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
index 2f0874a7c1..5078eb3ac5 100644
--- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
+++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
@@ -76,6 +76,7 @@ namespace connectivity
::std::map<sal_Int32, ::connectivity::TString2IntMap > m_aStrValueRange;
::std::map<sal_Int32, ::connectivity::TInt2StringMap > m_aIntValueRange;
+ ::std::map<sal_Int32,SWORD> m_aODBCColumnTypes;
SQLHANDLE m_aStatementHandle;
SQLHANDLE m_aConnectionHandle;
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
index 28b601f8d7..dfd2a62830 100644
--- a/connectivity/source/inc/odbc/OPreparedStatement.hxx
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -73,10 +73,6 @@ namespace connectivity
//====================================================================
// Data attributes
//====================================================================
- TTypeInfoVector m_aTypeInfo; // Hashtable containing an entry
- // for each row returned by
- // DatabaseMetaData.getTypeInfo.
-
SQLSMALLINT numParams; // Number of parameter markers
// for the prepared statement
@@ -119,7 +115,7 @@ namespace connectivity
public:
DECLARE_SERVICE_INFO();
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
- OPreparedStatement( OConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql);
+ OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql);
//XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
diff --git a/connectivity/source/inc/odbc/OResultSetMetaData.hxx b/connectivity/source/inc/odbc/OResultSetMetaData.hxx
index aacd518cf2..fb2c07321f 100644
--- a/connectivity/source/inc/odbc/OResultSetMetaData.hxx
+++ b/connectivity/source/inc/odbc/OResultSetMetaData.hxx
@@ -54,6 +54,7 @@ namespace connectivity
{
protected:
::std::vector<sal_Int32> m_vMapping; // when not every column is needed
+ ::std::map<sal_Int32,sal_Int32> m_aColumnTypes;
SQLHANDLE m_aStatementHandle;
OConnection* m_pConnection;
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index be1ee39d9b..97875dfd4d 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -3473,30 +3473,6 @@ OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage,
}
//-----------------------------------------------------------------------------
-/*sal_uInt32 OSQLParser::StrToTokenID(const ::rtl::OString & rName)
-{
- ::rtl::OString aName;
- if (rName.IsAlphaNumericAscii())
- aName = rName;
- else
- {
- aName = "'";
- aName += rName;
- aName += "'";
- }
-
- // Gewuenschten Token-Namen suchen:
- for (sal_uInt32 i = 0; i < SQLyyntoken; i++)
- {
- if (aName == TokenTypes[i].name)
- return TokenTypes[i].token;
- }
-
- // Nicht gefunden
- return 0;
-}*/
-
-//-----------------------------------------------------------------------------
::rtl::OUString OSQLParser::RuleIDToStr(sal_uInt32 nRuleID)
{
OSL_ENSURE(nRuleID < (sizeof yytname/sizeof yytname[0]), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
@@ -3599,17 +3575,15 @@ void OSQLParser::reduceLiteral(OSQLParseNode*& pLiteral, sal_Bool bAppendBlank)
OSL_ENSURE(pLiteral->isRule(), "This is no ::com::sun::star::chaos::Rule");
OSL_ENSURE(pLiteral->count() == 2, "OSQLParser::ReduceLiteral() Invalid count");
OSQLParseNode* pTemp = pLiteral;
- ::rtl::OUString aValue;
+ ::rtl::OUStringBuffer aValue(pLiteral->getChild(0)->getTokenValue());
if (bAppendBlank)
{
- ((aValue = pLiteral->getChild(0)->getTokenValue()) += ::rtl::OUString::createFromAscii(" ")) +=
- pLiteral->getChild(1)->getTokenValue();
+ aValue.appendAscii(" ");
}
- else
- (aValue = pLiteral->getChild(0)->getTokenValue()) +=
- pLiteral->getChild(1)->getTokenValue();
+
+ aValue.append(pLiteral->getChild(1)->getTokenValue());
- pLiteral = new OSQLInternalNode(aValue,SQL_NODE_STRING);
+ pLiteral = new OSQLInternalNode(aValue.makeStringAndClear(),SQL_NODE_STRING);
delete pTemp;
}
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
index 10a71b5015..c92fc9b709 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -460,7 +460,7 @@ void OSQLParseTreeIterator::traverseOneTableName( OSQLTables& _rTables,const OSQ
::rtl::OUString aTableRange(rTableRange);
// Tabellenname abholen
- OSQLParseNode::getTableComponents(pTableName,aCatalog,aSchema,aTableName);
+ OSQLParseNode::getTableComponents(pTableName,aCatalog,aSchema,aTableName,m_pImpl->m_xDatabaseMetaData);
// create the composed name like DOMAIN.USER.TABLE1
aComposedName = ::dbtools::composeTableName(m_pImpl->m_xDatabaseMetaData,
@@ -1687,13 +1687,7 @@ void OSQLParseTreeIterator::setSelectColumnName(::vos::ORef<OSQLColumns>& _rColu
OSL_ENSURE(_rColumns == m_aSelectColumns,"Invalid columns used here!");
ConstOSQLTablesIterator aFind = m_pImpl->m_pTables->find(rTableRange);
- if(aFind == m_pImpl->m_pTables->end())
- {
- ::rtl::OUString strExpression = rTableRange;
- strExpression += ::rtl::OUString::createFromAscii(".");
- strExpression += rColumnName;
- }
- else
+ if(aFind != m_pImpl->m_pTables->end())
appendColumns(_rColumns,rTableRange,aFind->second);
}
else if ( !rTableRange.getLength() )
@@ -1813,11 +1807,6 @@ void OSQLParseTreeIterator::setSelectColumnName(::vos::ORef<OSQLColumns>& _rColu
// Tabelle existiert nicht oder Feld nicht vorhanden
if (bError)
{
- ::rtl::OUString strExpression = rTableRange;
- if (strExpression.getLength())
- strExpression += ::rtl::OUString::createFromAscii(".");
- strExpression += rColumnName;
-
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 7ca6c92020..b4da3ba026 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -742,12 +742,15 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUStringBuffer& rSt
sal_Bool OSQLParseNode::getTableComponents(const OSQLParseNode* _pTableNode,
::com::sun::star::uno::Any &_rCatalog,
::rtl::OUString &_rSchema,
- ::rtl::OUString &_rTable)
+ ::rtl::OUString &_rTable,
+ const Reference< XDatabaseMetaData >& _xMetaData)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::getTableComponents" );
OSL_ENSURE(_pTableNode,"Wrong use of getTableComponents! _pTableNode is not allowed to be null!");
if(_pTableNode)
{
+ const sal_Bool bSupportsCatalog = _xMetaData.is() && _xMetaData->supportsCatalogsInDataManipulation();
+ const sal_Bool bSupportsSchema = _xMetaData.is() && _xMetaData->supportsSchemasInDataManipulation();
const OSQLParseNode* pTableNode = _pTableNode;
// clear the parameter given
_rCatalog = Any();
@@ -762,7 +765,10 @@ sal_Bool OSQLParseNode::getTableComponents(const OSQLParseNode* _pTableNode,
// check if we have schema_name rule
if(SQL_ISRULE(pTableNode,schema_name))
{
- _rSchema = pTableNode->getChild(0)->getTokenValue();
+ if ( bSupportsCatalog && !bSupportsSchema )
+ _rCatalog <<= pTableNode->getChild(0)->getTokenValue();
+ else
+ _rSchema = pTableNode->getChild(0)->getTokenValue();
pTableNode = pTableNode->getChild(2);
}
// check if we have table_name rule
@@ -1246,8 +1252,8 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const :
if (SQLyyparse() != 0)
{
m_sFieldName= ::rtl::OUString();
- m_xField = NULL;
- m_xFormatter = NULL;
+ m_xField.clear();
+ m_xFormatter.clear();
m_nFormatKey = 0;
m_nDateFormatKey = 0;
@@ -1267,8 +1273,8 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const :
(*s_pGarbageCollector)->clear();
m_sFieldName= ::rtl::OUString();
- m_xField = NULL;
- m_xFormatter = NULL;
+ m_xField.clear();
+ m_xFormatter.clear();
m_nFormatKey = 0;
m_nDateFormatKey = 0;
diff --git a/connectivity/source/sdbcx/VCatalog.cxx b/connectivity/source/sdbcx/VCatalog.cxx
index 3ee6bcb98d..5e33c7e4c7 100644
--- a/connectivity/source/sdbcx/VCatalog.cxx
+++ b/connectivity/source/sdbcx/VCatalog.cxx
@@ -226,7 +226,7 @@ void OCatalog::fillNames(Reference< XResultSet >& _xResult,TStringVector& _rName
{
_rNames.push_back( buildName(xRow) );
}
- xRow = NULL;
+ xRow.clear();
::comphelper::disposeComponent(_xResult);
}
}
diff --git a/connectivity/source/sdbcx/VTable.cxx b/connectivity/source/sdbcx/VTable.cxx
index 12bce92c8c..f610be3e65 100644
--- a/connectivity/source/sdbcx/VTable.cxx
+++ b/connectivity/source/sdbcx/VTable.cxx
@@ -215,10 +215,9 @@ Reference< XIndexAccess > SAL_CALL OTable::getKeys( ) throw(RuntimeException)
try
{
- refreshKeys();
+ if ( !m_pKeys )
+ refreshKeys();
xKeys = m_pKeys;
- if(!isNew())
- m_pKeys = NULL;
}
catch( const RuntimeException& )
{
@@ -283,8 +282,8 @@ void SAL_CALL OTable::rename( const ::rtl::OUString& newName ) throw(SQLExceptio
::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
- ::rtl::OUString sOldComposedName = getName();
- Reference< XDatabaseMetaData> xMetaData = getMetaData();
+ const ::rtl::OUString sOldComposedName = getName();
+ const Reference< XDatabaseMetaData> xMetaData = getMetaData();
if ( xMetaData.is() )
::dbtools::qualifiedNameComponents(xMetaData,newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::eInDataManipulation);
else
diff --git a/connectivity/source/sdbcx/VView.cxx b/connectivity/source/sdbcx/VView.cxx
index ebf0b5db42..8f221b1c70 100644
--- a/connectivity/source/sdbcx/VView.cxx
+++ b/connectivity/source/sdbcx/VView.cxx
@@ -53,7 +53,7 @@ OView::OView(sal_Bool _bCase,
sal_Int32 _CheckOption,
const ::rtl::OUString& _Command,
const ::rtl::OUString& _SchemaName,
- const ::rtl::OUString& _CatalogName) : ODescriptor(OViewHelper::rBHelper,_bCase)
+ const ::rtl::OUString& _CatalogName) : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase)
,m_CatalogName(_CatalogName)
,m_SchemaName(_SchemaName)
,m_Command(_Command)
@@ -66,7 +66,7 @@ OView::OView(sal_Bool _bCase,
}
// -------------------------------------------------------------------------
OView::OView(sal_Bool _bCase,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData)
- : ODescriptor(OViewHelper::rBHelper,_bCase,sal_True)
+ : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase,sal_True)
,m_xMetaData(_xMetaData)
{
construct();
@@ -97,17 +97,12 @@ void OView::disposing(void)
// -------------------------------------------------------------------------
Sequence< Type > SAL_CALL OView::getTypes( ) throw(RuntimeException)
{
- Sequence< Type > aTypes(2);
- aTypes.getArray()[0] = ::getCppuType(static_cast< Reference< ::com::sun::star::container::XNamed> *> (NULL));
- aTypes.getArray()[1] = ::getCppuType(static_cast< Reference< XServiceInfo> *> (NULL));
-
- return ::comphelper::concatSequences(ODescriptor::getTypes(),aTypes);
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OView_BASE::getTypes());
}
// -------------------------------------------------------------------------
Any SAL_CALL OView::queryInterface( const Type & rType ) throw(RuntimeException)
{
- Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::container::XNamed*> (this),
- static_cast< XServiceInfo*> (this));
+ Any aRet = OView_BASE::queryInterface( rType);
return aRet.hasValue() ? aRet : ODescriptor::queryInterface( rType);
}
// -------------------------------------------------------------------------