From baf36e763f65cba54c8168d10ade4f38a5f62c64 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 16 Oct 2009 14:16:52 +0200 Subject: #i104329# introduce a dedicated PrimaryKeySupport property at DataSource.Settings, which determines whether a data source should (be assumed to) support primary keys. Valid values are TRUE (=> supports), FALSE (=> doesn't support) and VOID (=> use the old heuristics, i.e. consult XDatabaseMetaData.supportsCoreSQLGrammar) --- connectivity/inc/connectivity/dbmetadata.hxx | 11 +++++++++++ connectivity/source/commontools/dbmetadata.cxx | 21 +++++++++++++++++++++ connectivity/source/drivers/ado/ado.xcu | 5 +++++ connectivity/source/drivers/jdbc/jdbc.xcu | 5 +++++ connectivity/source/drivers/odbc/odbc.xcu | 5 +++++ 5 files changed, 47 insertions(+) (limited to 'connectivity') diff --git a/connectivity/inc/connectivity/dbmetadata.hxx b/connectivity/inc/connectivity/dbmetadata.hxx index 32662c5c157a..e1a38c71b5fe 100644 --- a/connectivity/inc/connectivity/dbmetadata.hxx +++ b/connectivity/inc/connectivity/dbmetadata.hxx @@ -121,6 +121,17 @@ namespace dbtools */ bool supportsSubqueriesInFrom() const; + /** checks whether the database supports primary keys + + Since there's no dedicated API to ask a database for this, a heuristics needs to be applied. + First, the PrimaryKeySupport settings of the data source is examined. If it is + or , then value is returned. If it is , then the database meta data are examined + for support of core SQL grammar, and the result is returned. The assumption is that a database/driver + which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience + shows this is true most of the time. + */ + bool supportsPrimaryKeys() const; + /** determines whether names in the database should be restricted to SQL-92 identifiers Effectively, this method checks the EnableSQL92Check property of the data source settings, diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 70220b1cd563..0c0e4b3e6bbc 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -256,6 +256,27 @@ namespace dbtools return supportsSubQueries; } + //-------------------------------------------------------------------- + bool DatabaseMetaData::supportsPrimaryKeys() const + { + lcl_checkConnected( *m_pImpl ); + + bool supportsPrimaryKeys = false; + try + { + Any setting; + if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) + || !( setting >>= supportsPrimaryKeys ) + ) + supportsPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return supportsPrimaryKeys; + } + //-------------------------------------------------------------------- const ::rtl::OUString& DatabaseMetaData::getIdentifierQuoteString() const { diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu index 236d38bd7ff7..8a106c70283f 100755 --- a/connectivity/source/drivers/ado/ado.xcu +++ b/connectivity/source/drivers/ado/ado.xcu @@ -115,6 +115,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index 73fe2e9adc55..953e669906be 100755 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -145,6 +145,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu index cf306f10d57f..b3a9d7149650 100755 --- a/connectivity/source/drivers/odbc/odbc.xcu +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -150,6 +150,11 @@ true + + + true + + -- cgit v1.2.3 From f71d9e086e3735b0f489f5eac6bf735fb07f0f39 Mon Sep 17 00:00:00 2001 From: fs93730 Date: Fri, 16 Oct 2009 16:08:12 +0200 Subject: #i10000# --- connectivity/source/commontools/dbmetadata.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 0c0e4b3e6bbc..d148e5ca5a72 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -261,20 +261,20 @@ namespace dbtools { lcl_checkConnected( *m_pImpl ); - bool supportsPrimaryKeys = false; + bool doesSupportPrimaryKeys = false; try { Any setting; if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) - || !( setting >>= supportsPrimaryKeys ) + || !( setting >>= doesSupportPrimaryKeys ) ) - supportsPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); + doesSupportPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return supportsPrimaryKeys; + return doesSupportPrimaryKeys; } //-------------------------------------------------------------------- -- cgit v1.2.3 From 939ce4dfdd902e8adb2cfa4049c9e92b19d7d999 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 29 Oct 2009 12:00:17 +0100 Subject: #i106422# assure that the sequence stays alive when set binary data --- connectivity/source/drivers/odbcbase/OPreparedStatement.cxx | 11 +---------- connectivity/source/drivers/odbcbase/OTools.cxx | 5 +---- connectivity/source/inc/odbc/OBoundParam.hxx | 6 ++++++ 3 files changed, 8 insertions(+), 14 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 8d72c3271b82..1c963874d201 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -321,16 +321,6 @@ void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool setInt (parameterIndex, value); } // ------------------------------------------------------------------------- -#define PREP_BIND_PARAM(_ty,_jt) \ - OTools::bindParameter(m_pConnection, \ - m_aStatementHandle, \ - parameterIndex, \ - bindBuf, \ - getLengthBuf(parameterIndex), \ - (SWORD)_jt, \ - sal_False,m_pConnection->useOldDateFormat(),_pData,(Reference )*this,getOwnConnection()->getTextEncoding()) - - void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -568,6 +558,7 @@ void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) { setParameter(parameterIndex,DataType::BINARY,x.getLength(),(void*)&x); + boundParams[parameterIndex-1].setSequence(x); // this assures that the sequence stays alive } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx index 39c848f34eaf..3cadb33cf188 100644 --- a/connectivity/source/drivers/odbcbase/OTools.cxx +++ b/connectivity/source/drivers/odbcbase/OTools.cxx @@ -210,12 +210,9 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, if(pSeq) { - // memcpy(_pData,pSeq->getConstArray(),pSeq->getLength()); - _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + _pData = (sal_Int8*)pSeq->getConstArray(); *pLen = pSeq->getLength(); } - // _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); - // *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); } break; case SQL_LONGVARBINARY: diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx index c71977a94910..bc896c2361d8 100644 --- a/connectivity/source/inc/odbc/OBoundParam.hxx +++ b/connectivity/source/inc/odbc/OBoundParam.hxx @@ -119,6 +119,11 @@ namespace connectivity paramInputStreamLen = len; } + void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence) + { + aSequence = _aSequence; + } + //-------------------------------------------------------------------- // getInputStream // Gets the input stream for the bound parameter @@ -191,6 +196,7 @@ namespace connectivity // data is in native format. ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream; + ::com::sun::star::uno::Sequence< sal_Int8 > aSequence; // When an input stream is // bound to a parameter, the // input stream is saved -- cgit v1.2.3 From 7b84a221e4e00245c71fb9442ca8c84562ec08af Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 29 Oct 2009 13:03:41 +0100 Subject: #i106422# assure that the sequence stays alive when set binary data --- connectivity/source/drivers/odbcbase/OPreparedStatement.cxx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'connectivity') diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 1c963874d201..6e9d87e933ca 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -343,6 +343,10 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType, case SQL_NUMERIC: ++nRealSize; break; + case SQL_BINARY: + case SQL_VARBINARY: + nRealSize=1; //dummy buffer, binary data isn't copied + break; default: break; } -- cgit v1.2.3