LCOV - code coverage report
Current view: top level - connectivity/source/drivers/firebird - ResultSetMetaData.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 63 0.0 %
Date: 2014-04-14 Functions: 0 24 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 "ResultSetMetaData.hxx"
      21             : #include "Util.hxx"
      22             : 
      23             : #include <com/sun/star/sdbc/ColumnValue.hpp>
      24             : 
      25             : using namespace connectivity::firebird;
      26             : 
      27             : using namespace ::rtl;
      28             : 
      29             : using namespace com::sun::star::lang;
      30             : using namespace com::sun::star::sdbc;
      31             : using namespace com::sun::star::uno;
      32             : 
      33           0 : OResultSetMetaData::~OResultSetMetaData()
      34             : {
      35           0 : }
      36             : 
      37           0 : void OResultSetMetaData::verifyValidColumn(sal_Int32 column)
      38             :     throw(SQLException)
      39             : {
      40           0 :     if (column>getColumnCount() || column < 1)
      41           0 :         throw SQLException("Invalid column specified", *this, OUString(), 0, Any());
      42           0 : }
      43             : 
      44           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException, std::exception)
      45             : {
      46           0 :     return m_pSqlda->sqld;
      47             : }
      48             : 
      49           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
      50             : {
      51           0 :     verifyValidColumn(column);
      52           0 :     return 32; // Hard limit for firebird
      53             : }
      54             : 
      55           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnType(sal_Int32 column)
      56             :     throw(SQLException, RuntimeException, std::exception)
      57             : {
      58           0 :     verifyValidColumn(column);
      59             : 
      60           0 :     short aType = m_pSqlda->sqlvar[column-1].sqltype;
      61             : 
      62           0 :     return getColumnTypeFromFBType(aType);
      63             : }
      64             : 
      65           0 : sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive(sal_Int32 column)
      66             :     throw(SQLException, RuntimeException, std::exception)
      67             : {
      68             :     // Firebird is generally case sensitive when using quoted identifiers.
      69             :     // IF THIS CHANGES make ResultSet::findColumn to be case-insenstive as needed.
      70             :     // Generally names that are entirely UPPERCASE are case insensitive, however
      71             :     // there remains some ambiguity if there is another mixed-case-named column
      72             :     // of the same name. For safety always assume case insensitive.
      73             :     (void) column;
      74           0 :     return sal_True;
      75             : }
      76             : 
      77           0 : OUString SAL_CALL OResultSetMetaData::getSchemaName(sal_Int32 column)
      78             :     throw(SQLException, RuntimeException, std::exception)
      79             : {
      80             :     (void) column;
      81           0 :     return OUString(); // Schemas supported by firebird
      82             : }
      83             : 
      84           0 : OUString SAL_CALL OResultSetMetaData::getColumnName(sal_Int32 column)
      85             :     throw(SQLException, RuntimeException, std::exception)
      86             : {
      87           0 :     verifyValidColumn(column);
      88           0 :     OUString sRet(m_pSqlda->sqlvar[column-1].sqlname,
      89           0 :                     m_pSqlda->sqlvar[column-1].sqlname_length,
      90           0 :                     RTL_TEXTENCODING_UTF8);
      91           0 :     sanitizeIdentifier(sRet);
      92           0 :     return sRet;
      93             : }
      94             : 
      95           0 : OUString SAL_CALL OResultSetMetaData::getTableName(sal_Int32 column)
      96             :     throw(SQLException, RuntimeException, std::exception)
      97             : {
      98           0 :     verifyValidColumn(column);
      99           0 :     return OUString(m_pSqlda->sqlvar[column-1].relname,
     100           0 :                     m_pSqlda->sqlvar[column-1].relname_length,
     101           0 :                     RTL_TEXTENCODING_UTF8);
     102             : }
     103             : 
     104           0 : OUString SAL_CALL OResultSetMetaData::getCatalogName(sal_Int32 column)
     105             :     throw(SQLException, RuntimeException, std::exception)
     106             : {
     107             :     (void) column;
     108           0 :     return OUString(); // Catalogs not supported by firebird
     109             : }
     110             : 
     111           0 : OUString SAL_CALL OResultSetMetaData::getColumnTypeName(sal_Int32 column)
     112             :     throw(SQLException, RuntimeException, std::exception)
     113             : {
     114           0 :     verifyValidColumn(column);
     115             : 
     116           0 :     short aType = m_pSqlda->sqlvar[column-1].sqltype;
     117             : 
     118           0 :     return getColumnTypeNameFromFBType(aType);
     119             : }
     120             : 
     121           0 : OUString SAL_CALL OResultSetMetaData::getColumnLabel(sal_Int32 column)
     122             :     throw(SQLException, RuntimeException, std::exception)
     123             : {
     124             :     // TODO: clarify what this is -- probably not the alias
     125           0 :     return getColumnName(column);
     126             : }
     127             : 
     128           0 : OUString SAL_CALL OResultSetMetaData::getColumnServiceName(sal_Int32 column)
     129             :     throw(SQLException, RuntimeException, std::exception)
     130             : {
     131             :     // TODO: implement
     132             :     (void) column;
     133           0 :     return OUString();
     134             : }
     135             : 
     136           0 : sal_Bool SAL_CALL OResultSetMetaData::isCurrency(sal_Int32 column)
     137             :     throw(SQLException, RuntimeException, std::exception)
     138             : {
     139             :     (void) column;
     140           0 :     return sal_False;
     141             : }
     142             : 
     143           0 : sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement(sal_Int32 column)
     144             :     throw(SQLException, RuntimeException, std::exception)
     145             : {
     146             :     // Supported internally but no way of determining this here.
     147             :     (void) column;
     148           0 :     return sal_False;
     149             : }
     150             : 
     151             : 
     152           0 : sal_Bool SAL_CALL OResultSetMetaData::isSigned(sal_Int32 column)
     153             :     throw(SQLException, RuntimeException, std::exception)
     154             : {
     155             :     // Unsigned values aren't supported in firebird.
     156             :     (void) column;
     157           0 :     return sal_True;
     158             : }
     159             : 
     160           0 : sal_Int32 SAL_CALL OResultSetMetaData::getPrecision(sal_Int32 column)
     161             :     throw(SQLException, RuntimeException, std::exception)
     162             : {
     163             :     // TODO: implement
     164             :     (void) column;
     165           0 :     return 0;
     166             : }
     167             : 
     168           0 : sal_Int32 SAL_CALL OResultSetMetaData::getScale(sal_Int32 column)
     169             :     throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     170             : {
     171           0 :     return m_pSqlda->sqlvar[column-1].sqlscale;
     172             : }
     173             : 
     174           0 : sal_Int32 SAL_CALL OResultSetMetaData::isNullable(sal_Int32 column)
     175             :     throw(SQLException, RuntimeException, std::exception)
     176             : {
     177           0 :     if (m_pSqlda->sqlvar[column-1].sqltype & 1)
     178           0 :         return ColumnValue::NULLABLE;
     179             :     else
     180           0 :         return ColumnValue::NO_NULLS;
     181             : }
     182             : 
     183           0 : sal_Bool SAL_CALL OResultSetMetaData::isSearchable(sal_Int32 column)
     184             :     throw(SQLException, RuntimeException, std::exception)
     185             : {
     186             :     // TODO: Can the column be used as part of a where clause? Assume yes
     187             :     (void) column;
     188           0 :     return sal_True;
     189             : }
     190             : 
     191           0 : sal_Bool SAL_CALL OResultSetMetaData::isReadOnly(sal_Int32 column)
     192             :     throw(SQLException, RuntimeException, std::exception)
     193             : {
     194             :     (void) column;
     195           0 :     return m_pConnection->isReadOnly(); // Readonly only available on db level
     196             : }
     197             : 
     198           0 : sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable(sal_Int32 column)
     199             :     throw(SQLException, RuntimeException, std::exception)
     200             : {
     201             :     (void) column;
     202           0 :     return !m_pConnection->isReadOnly();
     203             : }
     204             : 
     205           0 : sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     206             : {
     207             :     (void) column;
     208           0 :     return !m_pConnection->isReadOnly();
     209             : }
     210             : 
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10