LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbc - ODatabaseMetaDataResultSet.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 664 0.0 %
Date: 2014-11-03 Functions: 0 88 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "TConnection.hxx"
      21             : 
      22             : #include "odbc/ODatabaseMetaDataResultSet.hxx"
      23             : #include <com/sun/star/sdbc/DataType.hpp>
      24             : #include <com/sun/star/sdbc/KeyRule.hpp>
      25             : #include <com/sun/star/sdbc/ProcedureResult.hpp>
      26             : #include <com/sun/star/sdbc/IndexType.hpp>
      27             : #include <comphelper/property.hxx>
      28             : #include <com/sun/star/lang/DisposedException.hpp>
      29             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      30             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      31             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      32             : #include <cppuhelper/typeprovider.hxx>
      33             : #include <comphelper/sequence.hxx>
      34             : #include "odbc/OResultSetMetaData.hxx"
      35             : #include "odbc/OTools.hxx"
      36             : #include <comphelper/types.hxx>
      37             : #include "FDatabaseMetaDataResultSetMetaData.hxx"
      38             : #include <connectivity/dbexception.hxx>
      39             : 
      40             : using namespace ::comphelper;
      41             : 
      42             : 
      43             : using namespace connectivity::odbc;
      44             : using namespace cppu;
      45             : 
      46             : using namespace ::com::sun::star::lang;
      47             : using namespace com::sun::star::uno;
      48             : using namespace com::sun::star::beans;
      49             : using namespace com::sun::star::sdbc;
      50             : using namespace com::sun::star::util;
      51             : 
      52             : 
      53           0 : ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection)
      54             :     :ODatabaseMetaDataResultSet_BASE(m_aMutex)
      55             :     ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper)
      56             : 
      57           0 :     ,m_aStatementHandle(_pConnection->createStatementHandle())
      58             :     ,m_aStatement(NULL)
      59             :     ,m_xMetaData(NULL)
      60             :     ,m_pRowStatusArray(NULL)
      61             :     ,m_pConnection(_pConnection)
      62           0 :     ,m_nTextEncoding(_pConnection->getTextEncoding())
      63             :     ,m_nRowPos(-1)
      64             :     ,m_nDriverColumnCount(0)
      65             :     ,m_nCurrentFetchState(0)
      66             :     ,m_bWasNull(true)
      67           0 :     ,m_bEOF(false)
      68             : {
      69             :     OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
      70           0 :     if( SQL_NULL_HANDLE == m_aStatementHandle )
      71           0 :         throw RuntimeException();
      72             : 
      73           0 :     osl_atomic_increment( &m_refCount );
      74           0 :     m_pConnection->acquire();
      75           0 :     m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
      76           0 :     osl_atomic_decrement( &m_refCount );
      77             :     //  allocBuffer();
      78           0 : }
      79             : 
      80             : 
      81           0 : ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
      82             : {
      83             :     OSL_ENSURE(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed,"Object wasn't disposed!");
      84           0 :     if(!ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed)
      85             :     {
      86           0 :         osl_atomic_increment( &m_refCount );
      87           0 :         dispose();
      88             :     }
      89           0 :     delete [] m_pRowStatusArray;
      90           0 : }
      91             : 
      92           0 : void ODatabaseMetaDataResultSet::disposing(void)
      93             : {
      94           0 :     OPropertySetHelper::disposing();
      95             : 
      96           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      97             : 
      98           0 :     m_pConnection->freeStatementHandle(m_aStatementHandle);
      99             : 
     100           0 :     m_aStatement    = NULL;
     101           0 : m_xMetaData.clear();
     102           0 :     m_pConnection->release();
     103           0 : }
     104             : 
     105           0 : Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     106             : {
     107           0 :     Any aRet = OPropertySetHelper::queryInterface(rType);
     108           0 :     return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
     109             : }
     110             : 
     111           0 : Reference< XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     112             : {
     113           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     114             : }
     115             : 
     116           0 : void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
     117             : {
     118           0 :     ODatabaseMetaDataResultSet_BASE::acquire();
     119           0 : }
     120             : 
     121           0 : void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
     122             : {
     123           0 :     ODatabaseMetaDataResultSet_BASE::release();
     124           0 : }
     125             : 
     126           0 : Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes(  ) throw(RuntimeException, std::exception)
     127             : {
     128           0 :     ::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(),
     129           0 :                                     cppu::UnoType<XFastPropertySet>::get(),
     130           0 :                                     cppu::UnoType<XPropertySet>::get());
     131             : 
     132           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
     133             : }
     134             : 
     135           0 : sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32  column)
     136             : {
     137           0 :     sal_Int32   map = column;
     138             : 
     139           0 :     if (!m_aColMapping.empty())
     140             :     {
     141             :         // Validate column number
     142           0 :         map = m_aColMapping[column];
     143             :     }
     144             : 
     145           0 :     return map;
     146             : }
     147             : 
     148             : 
     149           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
     150             : {
     151             : 
     152           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     153           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     154             : 
     155             : 
     156           0 :     Reference< XResultSetMetaData > xMeta = getMetaData();
     157           0 :     sal_Int32 nLen = xMeta->getColumnCount();
     158           0 :     sal_Int32 i = 1;
     159           0 :     for(;i<=nLen;++i)
     160             :     {
     161           0 :         if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
     162           0 :                 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
     163           0 :             return i;
     164             :     }
     165             : 
     166           0 :     ::dbtools::throwInvalidColumnException( columnName, *this );
     167             :     assert(false);
     168           0 :     return 0; // Never reached
     169             : }
     170             : 
     171           0 : template < typename T, SQLSMALLINT sqlTypeId > T ODatabaseMetaDataResultSet::getInteger ( sal_Int32 columnIndex )
     172             : {
     173           0 :     ::cppu::OBroadcastHelper& rBHelper(ODatabaseMetaDataResultSet_BASE::rBHelper);
     174           0 :     checkDisposed(rBHelper.bDisposed);
     175           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     176             : 
     177           0 :     columnIndex = mapColumn(columnIndex);
     178           0 :     T nVal = 0;
     179           0 :     if(columnIndex <= m_nDriverColumnCount)
     180             :     {
     181           0 :         getValue<T>(m_pConnection, m_aStatementHandle, columnIndex, sqlTypeId, m_bWasNull, **this, nVal);
     182             : 
     183           0 :         if ( !m_aValueRange.empty() )
     184             :         {
     185           0 :             ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter (m_aValueRange.find(columnIndex));
     186           0 :             if ( aValueRangeIter != m_aValueRange.end() )
     187           0 :                 return static_cast<T>(aValueRangeIter->second[nVal]);
     188             :         }
     189             :     }
     190             :     else
     191           0 :         m_bWasNull = true;
     192           0 :     return nVal;
     193             : }
     194             : 
     195             : 
     196           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     197             : {
     198           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getBinaryStream", *this );
     199           0 :     return NULL;
     200             : }
     201             : 
     202           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     203             : {
     204           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getCharacterStream", *this );
     205           0 :     return NULL;
     206             : }
     207             : 
     208             : 
     209           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     210             : {
     211             : 
     212           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     213           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     214             : 
     215           0 :     columnIndex = mapColumn(columnIndex);
     216             : 
     217           0 :     bool bRet = false;
     218           0 :     if(columnIndex <= m_nDriverColumnCount)
     219             :     {
     220           0 :         sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
     221           0 :         switch(nType)
     222             :         {
     223             :             case DataType::BIT:
     224             :                 {
     225           0 :                     sal_Int8 nValue = 0;
     226           0 :                     OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,&nValue,sizeof nValue);
     227           0 :                     bRet = nValue != 0;
     228             :                 }
     229           0 :                 break;
     230             :             default:
     231           0 :                 bRet = getInt(columnIndex) != 0;
     232             :         }
     233             :     }
     234           0 :     return bRet;
     235             : }
     236             : 
     237             : 
     238           0 : sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     239             : {
     240           0 :     return getInteger<sal_Int8, SQL_C_STINYINT>( columnIndex );
     241             : }
     242             : 
     243             : 
     244           0 : Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     245             : {
     246             : 
     247           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     248           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     249             : 
     250             : 
     251           0 :     columnIndex = mapColumn(columnIndex);
     252           0 :     if(columnIndex <= m_nDriverColumnCount)
     253             :     {
     254           0 :         sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
     255           0 :         switch(nType)
     256             :         {
     257             :             case DataType::CHAR:
     258             :             case DataType::VARCHAR:
     259             :             case DataType::LONGVARCHAR:
     260             :             {
     261           0 :                 OUString aRet = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this,m_nTextEncoding);
     262           0 :                 return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
     263             :             }
     264             :         }
     265           0 :         return OTools::getBytesValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
     266             :     }
     267             :     else
     268           0 :         m_bWasNull = true;
     269           0 :     return Sequence<sal_Int8>();
     270             : }
     271             : 
     272             : 
     273           0 : ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     274             : {
     275           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     276           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     277             : 
     278             : 
     279           0 :     columnIndex = mapColumn(columnIndex);
     280           0 :     if(columnIndex <= m_nDriverColumnCount)
     281             :     {
     282             :         DATE_STRUCT aDate;
     283           0 :         aDate.day = 0;
     284           0 :         aDate.month = 0;
     285           0 :         aDate.year = 0;
     286           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate);
     287           0 :         return Date(aDate.day,aDate.month,aDate.year);
     288             :     }
     289             :     else
     290           0 :         m_bWasNull = true;
     291           0 :     return Date();
     292             : }
     293             : 
     294             : 
     295           0 : double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     296             : {
     297             : 
     298           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     299           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     300             : 
     301             : 
     302           0 :     columnIndex = mapColumn(columnIndex);
     303           0 :     double nValue(0.0);
     304           0 :     if(columnIndex <= m_nDriverColumnCount)
     305           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,&nValue,sizeof nValue);
     306             :     else
     307           0 :         m_bWasNull = true;
     308           0 :     return nValue;
     309             : }
     310             : 
     311             : 
     312           0 : float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     313             : {
     314             : 
     315           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     316           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     317             : 
     318             : 
     319           0 :     columnIndex = mapColumn(columnIndex);
     320           0 :     float nVal(0);
     321           0 :     if(columnIndex <= m_nDriverColumnCount)
     322           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,&nVal,sizeof nVal);
     323             :     else
     324           0 :         m_bWasNull = true;
     325           0 :     return nVal;
     326             : }
     327             : 
     328             : 
     329           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     330             : {
     331           0 :     return getInteger<sal_Int32, SQL_C_SLONG>( columnIndex );
     332             : }
     333             : 
     334             : 
     335           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     336             : {
     337           0 :     return 0;
     338             : }
     339             : 
     340             : 
     341           0 : sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     342             : {
     343           0 :     return getInteger<sal_Int64, SQL_C_SBIGINT>( columnIndex );
     344             : }
     345             : 
     346             : 
     347           0 : Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData(  ) throw(SQLException, RuntimeException, std::exception)
     348             : {
     349           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     350           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     351           0 :     return m_xMetaData.is() ? m_xMetaData :  (m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle));
     352             : }
     353             : 
     354           0 : Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     355             : {
     356           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getArray", *this );
     357           0 :     return NULL;
     358             : }
     359             : 
     360           0 : Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     361             : {
     362           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getClob", *this );
     363           0 :     return NULL;
     364             : }
     365             : 
     366           0 : Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     367             : {
     368           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getBlob", *this );
     369           0 :     return NULL;
     370             : }
     371             : 
     372             : 
     373           0 : Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     374             : {
     375           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getRef", *this );
     376           0 :     return NULL;
     377             : }
     378             : 
     379             : 
     380           0 : Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
     381             : {
     382           0 :     ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getObject", *this );
     383           0 :     return Any();
     384             : }
     385             : 
     386             : 
     387           0 : sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     388             : {
     389           0 :     return getInteger<sal_Int16, SQL_C_SSHORT>( columnIndex );
     390             : }
     391             : 
     392             : 
     393           0 : OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     394             : {
     395             : 
     396           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     397           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     398             : 
     399             : 
     400           0 :     columnIndex = mapColumn(columnIndex);
     401           0 :     OUString aVal;
     402           0 :     if(columnIndex <= m_nDriverColumnCount)
     403           0 :         aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding);
     404             :     else
     405           0 :         m_bWasNull = true;
     406             : 
     407           0 :     return aVal;
     408             : }
     409             : 
     410             : 
     411             : 
     412             : 
     413           0 : ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     414             : {
     415             : 
     416           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     417           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     418             : 
     419             : 
     420           0 :     columnIndex = mapColumn(columnIndex);
     421           0 :     TIME_STRUCT aTime={0,0,0};
     422           0 :     if(columnIndex <= m_nDriverColumnCount)
     423           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime);
     424             :     else
     425           0 :         m_bWasNull = true;
     426           0 :     return Time(0, aTime.second,aTime.minute,aTime.hour, false);
     427             : }
     428             : 
     429             : 
     430             : 
     431           0 : ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     432             : {
     433             : 
     434           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     435           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     436             : 
     437             : 
     438           0 :     columnIndex = mapColumn(columnIndex);
     439           0 :     TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
     440           0 :     if(columnIndex <= m_nDriverColumnCount)
     441           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP, m_bWasNull, **this, &aTime, sizeof aTime);
     442             :     else
     443           0 :         m_bWasNull = true;
     444             :     return DateTime(aTime.fraction, aTime.second, aTime.minute, aTime.hour,
     445           0 :             aTime.day, aTime.month, aTime.year, false);
     446             : }
     447             : 
     448             : 
     449           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast(  ) throw(SQLException, RuntimeException, std::exception)
     450             : {
     451             : 
     452           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     453           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     454             : 
     455             : 
     456           0 :     return m_nCurrentFetchState == SQL_NO_DATA;
     457             : }
     458             : 
     459           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst(  ) throw(SQLException, RuntimeException, std::exception)
     460             : {
     461             : 
     462           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     463           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     464             : 
     465             : 
     466           0 :     return m_nRowPos == 1;
     467             : }
     468             : 
     469           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast(  ) throw(SQLException, RuntimeException, std::exception)
     470             : {
     471             : 
     472           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     473           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     474             : 
     475             : 
     476           0 :     return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
     477             : }
     478             : 
     479           0 : void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     480             : {
     481             : 
     482           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     483           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     484             : 
     485             : 
     486           0 :     if(first())
     487           0 :         previous();
     488           0 :     m_nCurrentFetchState = SQL_SUCCESS;
     489           0 : }
     490             : 
     491           0 : void SAL_CALL ODatabaseMetaDataResultSet::afterLast(  ) throw(SQLException, RuntimeException, std::exception)
     492             : {
     493             : 
     494           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     495           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     496             : 
     497             : 
     498           0 :     if(last())
     499           0 :         next();
     500           0 : }
     501             : 
     502             : 
     503           0 : void SAL_CALL ODatabaseMetaDataResultSet::close(  ) throw(SQLException, RuntimeException, std::exception)
     504             : {
     505             :     {
     506             : 
     507           0 :         checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     508           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     509             : 
     510             :     }
     511           0 :     dispose();
     512           0 : }
     513             : 
     514             : 
     515           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first(  ) throw(SQLException, RuntimeException, std::exception)
     516             : {
     517             : 
     518           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     519           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     520             : 
     521           0 :     m_bEOF = false;
     522             : 
     523           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
     524           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     525           0 :     bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
     526           0 :     if( bRet )
     527           0 :         m_nRowPos = 1;
     528           0 :     return bRet;
     529             : }
     530             : 
     531             : 
     532           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last(  ) throw(SQLException, RuntimeException, std::exception)
     533             : {
     534           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     535           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     536             : 
     537             : 
     538           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
     539           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     540             :     // here I know definitely that I stand on the last record
     541           0 :     bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
     542           0 :     if( bRet )
     543           0 :         m_bEOF = true;
     544           0 :     return bRet;
     545             : }
     546             : 
     547           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     548             : {
     549             : 
     550           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     551           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     552             : 
     553           0 :     m_bEOF = false;
     554             : 
     555           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
     556           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     557           0 :     bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     558           0 :     if(bRet)
     559           0 :         m_nRowPos = row;
     560           0 :     return bRet;
     561             : }
     562             : 
     563           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     564             : {
     565             : 
     566           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     567           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     568             : 
     569           0 :     m_bEOF = false;
     570             : 
     571           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
     572           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     573           0 :     bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     574           0 :     if(bRet)
     575           0 :         m_nRowPos += row;
     576           0 :     return bRet;
     577             : }
     578             : 
     579           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous(  ) throw(SQLException, RuntimeException, std::exception)
     580             : {
     581             : 
     582           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     583           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     584             : 
     585           0 :     m_bEOF = false;
     586             : 
     587           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
     588           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     589           0 :     bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     590           0 :     if(bRet)
     591           0 :         --m_nRowPos;
     592           0 :     else if ( m_nCurrentFetchState == SQL_NO_DATA )
     593           0 :         m_nRowPos = 0;
     594           0 :     return bRet;
     595             : }
     596             : 
     597           0 : Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement(  ) throw(SQLException, RuntimeException, std::exception)
     598             : {
     599           0 :     return NULL;
     600             : }
     601             : 
     602             : 
     603           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted(  ) throw(SQLException, RuntimeException, std::exception)
     604             : {
     605             : 
     606           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     607           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     608             : 
     609             : 
     610           0 :     return m_pRowStatusArray[0] == SQL_ROW_DELETED;
     611             : }
     612             : 
     613           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted(  ) throw(SQLException, RuntimeException, std::exception)
     614             : {
     615           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     616           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     617             : 
     618             : 
     619           0 :     return m_pRowStatusArray[0] == SQL_ROW_ADDED;
     620             : }
     621             : 
     622           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated(  ) throw(SQLException, RuntimeException, std::exception)
     623             : {
     624             : 
     625           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     626           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     627             : 
     628             : 
     629           0 :     return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
     630             : }
     631             : 
     632             : 
     633           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     634             : {
     635             : 
     636           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     637           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     638             : 
     639             : 
     640           0 :     return m_nRowPos == 0;
     641             : }
     642             : 
     643             : 
     644           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next(  ) throw(SQLException, RuntimeException, std::exception)
     645             : {
     646             : 
     647           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     648           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     649             : 
     650           0 :     m_bEOF = false;
     651             : 
     652           0 :     SQLRETURN nOldFetchStatus = m_nCurrentFetchState;
     653             :     //  m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
     654           0 :     m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
     655           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     656           0 :     bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     657           0 :     if(bRet || ( m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA ) )
     658           0 :         ++m_nRowPos;
     659           0 :     return bRet;
     660             : }
     661             : 
     662             : 
     663           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
     664             : {
     665             : 
     666           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     667           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     668             : 
     669             : 
     670           0 :     return m_bWasNull;
     671             : }
     672             : 
     673           0 : void SAL_CALL ODatabaseMetaDataResultSet::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
     674             : {
     675             : 
     676           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     677           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     678             : 
     679           0 : }
     680             : 
     681             : 
     682           0 : void SAL_CALL ODatabaseMetaDataResultSet::cancel(  ) throw(RuntimeException, std::exception)
     683             : {
     684             : 
     685           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     686           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     687             : 
     688             : 
     689           0 :     OTools::ThrowException(m_pConnection,N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
     690           0 : }
     691             : 
     692           0 : void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     693             : {
     694           0 : }
     695             : 
     696           0 : Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     697             : {
     698           0 :     return Any();
     699             : }
     700             : 
     701           0 : sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const throw(SQLException, RuntimeException)
     702             : {
     703           0 :     return ResultSetConcurrency::READ_ONLY;
     704             : }
     705             : 
     706           0 : sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const throw(SQLException, RuntimeException)
     707             : {
     708           0 :     return ResultSetType::FORWARD_ONLY;
     709             : }
     710             : 
     711           0 : sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const throw(SQLException, RuntimeException)
     712             : {
     713           0 :     return FetchDirection::FORWARD;
     714             : }
     715             : 
     716           0 : sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const throw(SQLException, RuntimeException)
     717             : {
     718           0 :     sal_Int32 nValue=1;
     719           0 :     return nValue;
     720             : }
     721             : 
     722           0 : OUString ODatabaseMetaDataResultSet::getCursorName() const throw(SQLException, RuntimeException)
     723             : {
     724           0 :     return OUString();
     725             : }
     726             : 
     727             : 
     728           0 : ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
     729             : {
     730             : 
     731           0 :     Sequence< com::sun::star::beans::Property > aProps(5);
     732           0 :     com::sun::star::beans::Property* pProperties = aProps.getArray();
     733           0 :     sal_Int32 nPos = 0;
     734           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
     735           0 :         PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0);
     736           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
     737           0 :         PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
     738           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
     739           0 :         PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
     740           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
     741           0 :         PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0);
     742           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
     743           0 :         PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0);
     744             : 
     745           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     746             : }
     747             : 
     748           0 : ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
     749             : {
     750           0 :     return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
     751             : }
     752             : 
     753           0 : sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue(
     754             :                             Any & rConvertedValue,
     755             :                             Any & rOldValue,
     756             :                             sal_Int32 nHandle,
     757             :                             const Any& rValue )
     758             :                                 throw (::com::sun::star::lang::IllegalArgumentException)
     759             : {
     760           0 :     switch(nHandle)
     761             :     {
     762             :         case PROPERTY_ID_CURSORNAME:
     763             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     764             :         case PROPERTY_ID_RESULTSETTYPE:
     765           0 :             throw ::com::sun::star::lang::IllegalArgumentException();
     766             :         case PROPERTY_ID_FETCHDIRECTION:
     767           0 :             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
     768             :         case PROPERTY_ID_FETCHSIZE:
     769           0 :             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
     770             :         default:
     771             :             ;
     772             :     }
     773           0 :     return sal_False;
     774             : }
     775             : 
     776           0 : void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& /*rValue*/ ) throw (Exception, std::exception)
     777             : {
     778           0 :     switch(nHandle)
     779             :     {
     780             :         case PROPERTY_ID_CURSORNAME:
     781             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     782             :         case PROPERTY_ID_RESULTSETTYPE:
     783             :         case PROPERTY_ID_FETCHDIRECTION:
     784             :         case PROPERTY_ID_FETCHSIZE:
     785           0 :             throw Exception();
     786             :         default:
     787             :             OSL_FAIL("setFastPropertyValue_NoBroadcast: Illegal handle value!");
     788             :     }
     789           0 : }
     790             : 
     791           0 : void ODatabaseMetaDataResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     792             : {
     793           0 :     switch(nHandle)
     794             :     {
     795             :         case PROPERTY_ID_CURSORNAME:
     796           0 :             rValue <<= getCursorName();
     797           0 :             break;
     798             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     799           0 :             rValue <<= getResultSetConcurrency();
     800           0 :             break;
     801             :         case PROPERTY_ID_RESULTSETTYPE:
     802           0 :             rValue <<= getResultSetType();
     803           0 :             break;
     804             :         case PROPERTY_ID_FETCHDIRECTION:
     805           0 :             rValue <<= getFetchDirection();
     806           0 :             break;
     807             :         case PROPERTY_ID_FETCHSIZE:
     808           0 :             rValue <<= getFetchSize();
     809           0 :             break;
     810             :     }
     811           0 : }
     812             : 
     813           0 : void ODatabaseMetaDataResultSet::openTypeInfo() throw(SQLException, RuntimeException)
     814             : {
     815           0 :     TInt2IntMap aMap;
     816           0 :     aMap[SQL_BIT]               = DataType::BIT;
     817           0 :     aMap[SQL_TINYINT]           = DataType::TINYINT;
     818           0 :     aMap[SQL_SMALLINT]          = DataType::SMALLINT;
     819           0 :     aMap[SQL_INTEGER]           = DataType::INTEGER;
     820           0 :     aMap[SQL_FLOAT]             = DataType::FLOAT;
     821           0 :     aMap[SQL_REAL]              = DataType::REAL;
     822           0 :     aMap[SQL_DOUBLE]            = DataType::DOUBLE;
     823           0 :     aMap[SQL_BIGINT]            = DataType::BIGINT;
     824             : 
     825           0 :     aMap[SQL_CHAR]              = DataType::CHAR;
     826           0 :     aMap[SQL_WCHAR]             = DataType::CHAR;
     827           0 :     aMap[SQL_VARCHAR]           = DataType::VARCHAR;
     828           0 :     aMap[SQL_WVARCHAR]          = DataType::VARCHAR;
     829           0 :     aMap[SQL_LONGVARCHAR]       = DataType::LONGVARCHAR;
     830           0 :     aMap[SQL_WLONGVARCHAR]      = DataType::LONGVARCHAR;
     831             : 
     832           0 :     aMap[SQL_TYPE_DATE]         = DataType::DATE;
     833           0 :     aMap[SQL_DATE]              = DataType::DATE;
     834           0 :     aMap[SQL_TYPE_TIME]         = DataType::TIME;
     835           0 :     aMap[SQL_TIME]              = DataType::TIME;
     836           0 :     aMap[SQL_TYPE_TIMESTAMP]    = DataType::TIMESTAMP;
     837           0 :     aMap[SQL_TIMESTAMP]         = DataType::TIMESTAMP;
     838             : 
     839           0 :     aMap[SQL_DECIMAL]           = DataType::DECIMAL;
     840           0 :     aMap[SQL_NUMERIC]           = DataType::NUMERIC;
     841             : 
     842           0 :     aMap[SQL_BINARY]            = DataType::BINARY;
     843           0 :     aMap[SQL_VARBINARY]         = DataType::VARBINARY;
     844           0 :     aMap[SQL_LONGVARBINARY]     = DataType::LONGVARBINARY;
     845             : 
     846           0 :     aMap[SQL_GUID]              = DataType::VARBINARY;
     847             : 
     848             : 
     849           0 :     m_aValueRange[2] = aMap;
     850             : 
     851           0 :     OTools::ThrowException(m_pConnection,N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this);
     852           0 :     checkColumnCount();
     853           0 : }
     854             : 
     855           0 : void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const OUString& schemaPattern,
     856             :                             const OUString& tableNamePattern,
     857             :                             const Sequence< OUString >& types )  throw(SQLException, RuntimeException)
     858             : {
     859           0 :     OString aPKQ,aPKO,aPKN,aCOL;
     860           0 :     const OUString *pSchemaPat = NULL;
     861             : 
     862           0 :     if(schemaPattern != "%")
     863           0 :         pSchemaPat = &schemaPattern;
     864             :     else
     865           0 :         pSchemaPat = NULL;
     866             : 
     867           0 :     if ( catalog.hasValue() )
     868           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
     869           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
     870           0 :     aPKN = OUStringToOString(tableNamePattern,m_nTextEncoding);
     871             : 
     872           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
     873           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
     874           0 :                 *pPKN = aPKN.getStr();
     875             : 
     876             : 
     877           0 :     const char  *pCOL = NULL;
     878           0 :     const char* pComma = ",";
     879           0 :     const OUString* pBegin = types.getConstArray();
     880           0 :     const OUString* pEnd = pBegin + types.getLength();
     881           0 :     for(;pBegin != pEnd;++pBegin)
     882             :     {
     883           0 :         aCOL += OUStringToOString(*pBegin,m_nTextEncoding);
     884           0 :         aCOL += pComma;
     885             :     }
     886           0 :     if ( !aCOL.isEmpty() )
     887             :     {
     888           0 :         aCOL = aCOL.replaceAt(aCOL.getLength()-1,1,pComma);
     889           0 :         pCOL = aCOL.getStr();
     890             :     }
     891             :     else
     892           0 :         pCOL = SQL_ALL_TABLE_TYPES;
     893             : 
     894           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     895             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
     896             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
     897             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
     898             :                             (SDB_ODBC_CHAR *) pCOL, pCOL ? SQL_NTS : 0);
     899           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     900           0 :     checkColumnCount();
     901             : 
     902           0 : }
     903             : 
     904           0 : void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeException)
     905             : {
     906           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     907             :                             0,0,
     908             :                             0,0,
     909             :                             0,0,
     910             :                             (SDB_ODBC_CHAR *) SQL_ALL_TABLE_TYPES,SQL_NTS);
     911           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     912             : 
     913           0 :     m_aColMapping.clear();
     914           0 :     m_aColMapping.push_back(-1);
     915           0 :     m_aColMapping.push_back(4);
     916           0 :     m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
     917           0 :     checkColumnCount();
     918           0 : }
     919             : 
     920           0 : void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeException)
     921             : {
     922           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     923             :                             (SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS,
     924             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     925             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     926             :                             (SDB_ODBC_CHAR *) "",SQL_NTS);
     927             : 
     928           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     929             : 
     930           0 :     m_aColMapping.clear();
     931           0 :     m_aColMapping.push_back(-1);
     932           0 :     m_aColMapping.push_back(1);
     933           0 :     m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
     934           0 :     checkColumnCount();
     935           0 : }
     936             : 
     937           0 : void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeException)
     938             : {
     939           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     940             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     941             :                             (SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS,
     942             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     943             :                             (SDB_ODBC_CHAR *) "",SQL_NTS);
     944           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     945             : 
     946           0 :     m_aColMapping.clear();
     947           0 :     m_aColMapping.push_back(-1);
     948           0 :     m_aColMapping.push_back(2);
     949           0 :     m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
     950           0 :     checkColumnCount();
     951           0 : }
     952             : 
     953           0 : void ODatabaseMetaDataResultSet::openColumnPrivileges(  const Any& catalog, const OUString& schema,
     954             :                                         const OUString& table,   const OUString& columnNamePattern )
     955             :                                         throw(SQLException, RuntimeException)
     956             : {
     957           0 :     const OUString *pSchemaPat = NULL;
     958             : 
     959           0 :     if(schema != "%")
     960           0 :         pSchemaPat = &schema;
     961             :     else
     962           0 :         pSchemaPat = NULL;
     963             : 
     964           0 :     OString aPKQ,aPKO,aPKN,aCOL;
     965             : 
     966           0 :     if ( catalog.hasValue() )
     967           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
     968           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
     969           0 :     aPKN = OUStringToOString(table,m_nTextEncoding);
     970           0 :     aCOL = OUStringToOString(columnNamePattern,m_nTextEncoding);
     971             : 
     972           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
     973           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
     974           0 :                 *pPKN = aPKN.getStr(),
     975           0 :                 *pCOL = aCOL.getStr();
     976             : 
     977             : 
     978           0 :     SQLRETURN nRetcode = N3SQLColumnPrivileges(m_aStatementHandle,
     979             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
     980             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
     981             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
     982             :                             (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
     983           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     984             : 
     985           0 :     checkColumnCount();
     986           0 : }
     987             : 
     988           0 : void ODatabaseMetaDataResultSet::openColumns(   const Any& catalog,             const OUString& schemaPattern,
     989             :                                 const OUString& tableNamePattern,    const OUString& columnNamePattern )
     990             :                                 throw(SQLException, RuntimeException)
     991             : {
     992           0 :     const OUString *pSchemaPat = NULL;
     993             : 
     994           0 :     if(schemaPattern != "%")
     995           0 :         pSchemaPat = &schemaPattern;
     996             :     else
     997           0 :         pSchemaPat = NULL;
     998             : 
     999           0 :     OString aPKQ,aPKO,aPKN,aCOL;
    1000           0 :     if ( catalog.hasValue() )
    1001           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1002           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1003           0 :     aPKN = OUStringToOString(tableNamePattern,m_nTextEncoding);
    1004           0 :     aCOL = OUStringToOString(columnNamePattern,m_nTextEncoding);
    1005             : 
    1006           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1007           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1008           0 :                 *pPKN = aPKN.getStr(),
    1009           0 :                 *pCOL = aCOL.getStr();
    1010             : 
    1011             : 
    1012           0 :     SQLRETURN nRetcode = N3SQLColumns(m_aStatementHandle,
    1013             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1014             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
    1015             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1016             :                             (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
    1017             : 
    1018           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1019           0 :     TInt2IntMap aMap;
    1020           0 :     aMap[SQL_BIT]               = DataType::BIT;
    1021           0 :     aMap[SQL_TINYINT]           = DataType::TINYINT;
    1022           0 :     aMap[SQL_SMALLINT]          = DataType::SMALLINT;
    1023           0 :     aMap[SQL_INTEGER]           = DataType::INTEGER;
    1024           0 :     aMap[SQL_FLOAT]             = DataType::FLOAT;
    1025           0 :     aMap[SQL_REAL]              = DataType::REAL;
    1026           0 :     aMap[SQL_DOUBLE]            = DataType::DOUBLE;
    1027           0 :     aMap[SQL_BIGINT]            = DataType::BIGINT;
    1028             : 
    1029           0 :     aMap[SQL_CHAR]              = DataType::CHAR;
    1030           0 :     aMap[SQL_WCHAR]             = DataType::CHAR;
    1031           0 :     aMap[SQL_VARCHAR]           = DataType::VARCHAR;
    1032           0 :     aMap[SQL_WVARCHAR]          = DataType::VARCHAR;
    1033           0 :     aMap[SQL_LONGVARCHAR]       = DataType::LONGVARCHAR;
    1034           0 :     aMap[SQL_WLONGVARCHAR]      = DataType::LONGVARCHAR;
    1035             : 
    1036           0 :     aMap[SQL_TYPE_DATE]         = DataType::DATE;
    1037           0 :     aMap[SQL_DATE]              = DataType::DATE;
    1038           0 :     aMap[SQL_TYPE_TIME]         = DataType::TIME;
    1039           0 :     aMap[SQL_TIME]              = DataType::TIME;
    1040           0 :     aMap[SQL_TYPE_TIMESTAMP]    = DataType::TIMESTAMP;
    1041           0 :     aMap[SQL_TIMESTAMP]         = DataType::TIMESTAMP;
    1042             : 
    1043           0 :     aMap[SQL_DECIMAL]           = DataType::DECIMAL;
    1044           0 :     aMap[SQL_NUMERIC]           = DataType::NUMERIC;
    1045             : 
    1046           0 :     aMap[SQL_BINARY]            = DataType::BINARY;
    1047           0 :     aMap[SQL_VARBINARY]         = DataType::VARBINARY;
    1048           0 :     aMap[SQL_LONGVARBINARY]     = DataType::LONGVARBINARY;
    1049             : 
    1050           0 :     aMap[SQL_GUID]              = DataType::VARBINARY;
    1051             : 
    1052           0 :     m_aValueRange[5] = aMap;
    1053           0 :     checkColumnCount();
    1054           0 : }
    1055             : 
    1056           0 : void ODatabaseMetaDataResultSet::openProcedureColumns(  const Any& catalog,     const OUString& schemaPattern,
    1057             :                                 const OUString& procedureNamePattern,const OUString& columnNamePattern )
    1058             :                                 throw(SQLException, RuntimeException)
    1059             : {
    1060           0 :     const OUString *pSchemaPat = NULL;
    1061             : 
    1062           0 :     if(schemaPattern != "%")
    1063           0 :         pSchemaPat = &schemaPattern;
    1064             :     else
    1065           0 :         pSchemaPat = NULL;
    1066             : 
    1067           0 :     OString aPKQ,aPKO,aPKN,aCOL;
    1068           0 :     if ( catalog.hasValue() )
    1069           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1070           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1071           0 :     aPKN = OUStringToOString(procedureNamePattern,m_nTextEncoding);
    1072           0 :     aCOL = OUStringToOString(columnNamePattern,m_nTextEncoding);
    1073             : 
    1074           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1075           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1076           0 :                 *pPKN = aPKN.getStr(),
    1077           0 :                 *pCOL = aCOL.getStr();
    1078             : 
    1079             : 
    1080           0 :     SQLRETURN nRetcode = N3SQLProcedureColumns(m_aStatementHandle,
    1081             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1082             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1083             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1084             :                             (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
    1085             : 
    1086           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1087           0 :     checkColumnCount();
    1088           0 : }
    1089             : 
    1090           0 : void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const OUString& schemaPattern,
    1091             :                                 const OUString& procedureNamePattern)
    1092             :                                 throw(SQLException, RuntimeException)
    1093             : {
    1094           0 :     const OUString *pSchemaPat = NULL;
    1095             : 
    1096           0 :     if(schemaPattern != "%")
    1097           0 :         pSchemaPat = &schemaPattern;
    1098             :     else
    1099           0 :         pSchemaPat = NULL;
    1100             : 
    1101           0 :     OString aPKQ,aPKO,aPKN;
    1102             : 
    1103           0 :     if ( catalog.hasValue() )
    1104           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1105           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1106           0 :     aPKN = OUStringToOString(procedureNamePattern,m_nTextEncoding);
    1107             : 
    1108           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1109           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1110           0 :                 *pPKN = aPKN.getStr();
    1111             : 
    1112             : 
    1113           0 :     SQLRETURN nRetcode = N3SQLProcedures(m_aStatementHandle,
    1114             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1115             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1116             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
    1117           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1118           0 :     checkColumnCount();
    1119           0 : }
    1120             : 
    1121           0 : void ODatabaseMetaDataResultSet::openSpecialColumns(bool _bRowVer,const Any& catalog, const OUString& schema,
    1122             :                                     const OUString& table,sal_Int32 scope,   bool nullable )
    1123             :                                     throw(SQLException, RuntimeException)
    1124             : {
    1125             :     // Some ODBC drivers really don't like getting an empty string as tableName
    1126             :     // E.g. psqlodbc up to at least version 09.01.0100 segfaults
    1127           0 :     if (table.isEmpty())
    1128             :     {
    1129           0 :         const char errMsg[] = "ODBC: Trying to get special columns of empty table name";
    1130           0 :         const char SQLState[] = "HY009";
    1131             :         throw SQLException( OUString(errMsg, sizeof(errMsg) - sizeof(errMsg[0]), RTL_TEXTENCODING_ASCII_US),
    1132             :                             *this,
    1133             :                             OUString(SQLState, sizeof(SQLState) - sizeof(SQLState[0]), RTL_TEXTENCODING_ASCII_US),
    1134             :                             -1,
    1135           0 :                             Any() );
    1136             :     }
    1137             : 
    1138           0 :     const OUString *pSchemaPat = NULL;
    1139             : 
    1140           0 :     if(schema != "%")
    1141           0 :         pSchemaPat = &schema;
    1142             :     else
    1143           0 :         pSchemaPat = NULL;
    1144             : 
    1145           0 :     OString aPKQ,aPKO,aPKN;
    1146           0 :     if ( catalog.hasValue() )
    1147           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1148           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
    1149           0 :     aPKN = OUStringToOString(table,m_nTextEncoding);
    1150             : 
    1151           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1152           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1153           0 :                 *pPKN = aPKN.getStr();
    1154             : 
    1155             : 
    1156           0 :     SQLRETURN nRetcode = N3SQLSpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID,
    1157             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1158             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1159             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1160             :                             (SQLSMALLINT)scope,
    1161             :                             nullable ? SQL_NULLABLE : SQL_NO_NULLS);
    1162           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1163           0 :     checkColumnCount();
    1164           0 : }
    1165             : 
    1166           0 : void ODatabaseMetaDataResultSet::openVersionColumns(const Any& catalog, const OUString& schema,
    1167             :                                     const OUString& table)  throw(SQLException, RuntimeException)
    1168             : {
    1169           0 :     openSpecialColumns(true,catalog,schema,table,SQL_SCOPE_TRANSACTION,false);
    1170           0 : }
    1171             : 
    1172           0 : void ODatabaseMetaDataResultSet::openBestRowIdentifier( const Any& catalog, const OUString& schema,
    1173             :                                         const OUString& table,sal_Int32 scope,bool nullable ) throw(SQLException, RuntimeException)
    1174             : {
    1175           0 :     openSpecialColumns(false,catalog,schema,table,scope,nullable);
    1176           0 : }
    1177             : 
    1178           0 : void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const OUString* schema,
    1179             :                                   const OUString* table,
    1180             :                                   const Any& catalog2, const OUString* schema2,
    1181             :                                   const OUString* table2) throw(SQLException, RuntimeException)
    1182             : {
    1183           0 :     OString aPKQ, aPKO, aPKN, aFKQ, aFKO, aFKN;
    1184           0 :     if ( catalog.hasValue() )
    1185           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1186           0 :     if ( catalog2.hasValue() )
    1187           0 :         aFKQ = OUStringToOString(comphelper::getString(catalog2),m_nTextEncoding);
    1188             : 
    1189           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1190           0 :                 *pPKO = schema && !schema->isEmpty() ? (aPKO = OUStringToOString(*schema,m_nTextEncoding)).getStr() : NULL,
    1191           0 :                 *pPKN = table   ? (aPKN = OUStringToOString(*table,m_nTextEncoding)).getStr(): NULL,
    1192           0 :                 *pFKQ = catalog2.hasValue() && !aFKQ.isEmpty() ? aFKQ.getStr() : NULL,
    1193           0 :                 *pFKO = schema2 && !schema2->isEmpty() ? (aFKO = OUStringToOString(*schema2,m_nTextEncoding)).getStr() : NULL,
    1194           0 :                 *pFKN = table2  ? (aFKN = OUStringToOString(*table2,m_nTextEncoding)).getStr() : NULL;
    1195             : 
    1196             : 
    1197           0 :     SQLRETURN nRetcode = N3SQLForeignKeys(m_aStatementHandle,
    1198             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1199             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
    1200             :                             (SDB_ODBC_CHAR *) pPKN, pPKN ? SQL_NTS : 0,
    1201             :                             (SDB_ODBC_CHAR *) pFKQ, (catalog2.hasValue() && !aFKQ.isEmpty()) ? SQL_NTS : 0,
    1202             :                             (SDB_ODBC_CHAR *) pFKO, pFKO ? SQL_NTS : 0,
    1203             :                             (SDB_ODBC_CHAR *) pFKN, SQL_NTS
    1204             :                             );
    1205           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1206           0 :     checkColumnCount();
    1207           0 : }
    1208             : 
    1209           0 : void ODatabaseMetaDataResultSet::openImportedKeys(const Any& catalog, const OUString& schema,
    1210             :                                   const OUString& table) throw(SQLException, RuntimeException)
    1211             : {
    1212             : 
    1213           0 :     openForeignKeys(Any(),NULL,NULL,catalog, schema.equalsAscii("%") ? &schema : NULL, &table);
    1214           0 : }
    1215             : 
    1216           0 : void ODatabaseMetaDataResultSet::openExportedKeys(const Any& catalog, const OUString& schema,
    1217             :                                   const OUString& table) throw(SQLException, RuntimeException)
    1218             : {
    1219           0 :     openForeignKeys(catalog, schema.equalsAscii("%") ? &schema : NULL, &table,Any(),NULL,NULL);
    1220           0 : }
    1221             : 
    1222           0 : void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const OUString& schema,
    1223             :                                   const OUString& table) throw(SQLException, RuntimeException)
    1224             : {
    1225           0 :     const OUString *pSchemaPat = NULL;
    1226             : 
    1227           0 :     if(schema != "%")
    1228           0 :         pSchemaPat = &schema;
    1229             :     else
    1230           0 :         pSchemaPat = NULL;
    1231             : 
    1232           0 :     OString aPKQ,aPKO,aPKN;
    1233             : 
    1234           0 :     if ( catalog.hasValue() )
    1235           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1236           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
    1237             : 
    1238           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1239           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1240           0 :                 *pPKN = (aPKN = OUStringToOString(table,m_nTextEncoding)).getStr();
    1241             : 
    1242             : 
    1243           0 :     SQLRETURN nRetcode = N3SQLPrimaryKeys(m_aStatementHandle,
    1244             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1245             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1246             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
    1247           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1248           0 :     checkColumnCount();
    1249           0 : }
    1250             : 
    1251           0 : void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const OUString& schemaPattern,
    1252             :                                   const OUString& tableNamePattern) throw(SQLException, RuntimeException)
    1253             : {
    1254           0 :     const OUString *pSchemaPat = NULL;
    1255             : 
    1256           0 :     if(schemaPattern != "%")
    1257           0 :         pSchemaPat = &schemaPattern;
    1258             :     else
    1259           0 :         pSchemaPat = NULL;
    1260             : 
    1261           0 :     OString aPKQ,aPKO,aPKN;
    1262             : 
    1263           0 :     if ( catalog.hasValue() )
    1264           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1265           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1266             : 
    1267           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1268           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1269           0 :                 *pPKN = (aPKN = OUStringToOString(tableNamePattern,m_nTextEncoding)).getStr();
    1270             : 
    1271             : 
    1272           0 :     SQLRETURN nRetcode = N3SQLTablePrivileges(m_aStatementHandle,
    1273             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1274             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1275             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
    1276           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1277           0 :     checkColumnCount();
    1278           0 : }
    1279             : 
    1280           0 : void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const OUString& schema,
    1281             :                                 const OUString& table, bool unique, bool approximate )
    1282             :                                 throw(SQLException, RuntimeException)
    1283             : {
    1284           0 :     const OUString *pSchemaPat = NULL;
    1285             : 
    1286           0 :     if(schema != "%")
    1287           0 :         pSchemaPat = &schema;
    1288             :     else
    1289           0 :         pSchemaPat = NULL;
    1290             : 
    1291           0 :     OString aPKQ,aPKO,aPKN;
    1292             : 
    1293           0 :     if ( catalog.hasValue() )
    1294           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1295           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
    1296             : 
    1297           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1298           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1299           0 :                 *pPKN = (aPKN = OUStringToOString(table,m_nTextEncoding)).getStr();
    1300             : 
    1301             : 
    1302           0 :     SQLRETURN nRetcode = N3SQLStatistics(m_aStatementHandle,
    1303             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1304             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1305             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1306             :                             unique ? SQL_INDEX_UNIQUE : SQL_INDEX_ALL,
    1307             :                             approximate ? 1 : 0);
    1308           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1309           0 :     checkColumnCount();
    1310           0 : }
    1311             : 
    1312           0 : void ODatabaseMetaDataResultSet::checkColumnCount()
    1313             : {
    1314           0 :     sal_Int16 nNumResultCols=0;
    1315           0 :     OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1316           0 :     m_nDriverColumnCount = nNumResultCols;
    1317           0 : }
    1318             : 
    1319             : 
    1320           0 : SWORD ODatabaseMetaDataResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
    1321             : {
    1322           0 :     ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
    1323           0 :     if ( aFind == m_aODBCColumnTypes.end() )
    1324           0 :         aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection,m_aStatementHandle,*this,columnIndex))).first;
    1325           0 :     return aFind->second;
    1326             : }
    1327             : 
    1328             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10