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

Generated by: LCOV version 1.10