LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLSetDescRec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 53 0.0 %
Date: 2021-10-13 02:24:04 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       5             :  *
       6             :  * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V.
       7             :  */
       8             : 
       9             : /*
      10             :  * This code was created by Peter Harvey (mostly during Christmas 98/99).
      11             :  * This code is LGPL. Please ensure that this message remains in future
      12             :  * distributions and uses of this code (thats about all I get out of it).
      13             :  * - Peter Harvey pharvey@codebydesign.com
      14             :  *
      15             :  * This file has been modified for the MonetDB project.  See the file
      16             :  * Copyright in this directory for more information.
      17             :  */
      18             : 
      19             : /**********************************************************************
      20             :  * SQLSetDescRec()
      21             :  * CLI Compliance: ISO 92
      22             :  **********************************************************************/
      23             : 
      24             : #include "ODBCGlobal.h"
      25             : #include "ODBCStmt.h"
      26             : 
      27             : #ifdef ODBCDEBUG
      28             : static char *
      29           0 : translateSubType(SQLSMALLINT Type, SQLSMALLINT SubType)
      30             : {
      31           0 :         if (Type == SQL_DATETIME) {
      32           0 :                 switch (SubType) {
      33             :                 case SQL_CODE_DATE:
      34             :                         return "SQL_CODE_DATE";
      35           0 :                 case SQL_CODE_TIME:
      36           0 :                         return "SQL_CODE_TIME";
      37           0 :                 case SQL_CODE_TIMESTAMP:
      38           0 :                         return "SQL_CODE_TIMESTAMP";
      39           0 :                 default:
      40           0 :                         return "unknown";
      41             :                 }
      42           0 :         } else if (Type == SQL_INTERVAL) {
      43           0 :                 switch (SubType) {
      44             :                 case SQL_CODE_MONTH:
      45             :                         return "SQL_CODE_MONTH";
      46           0 :                 case SQL_CODE_YEAR:
      47           0 :                         return "SQL_CODE_YEAR";
      48           0 :                 case SQL_CODE_YEAR_TO_MONTH:
      49           0 :                         return "SQL_CODE_YEAR_TO_MONTH";
      50           0 :                 case SQL_CODE_DAY:
      51           0 :                         return "SQL_CODE_DAY";
      52           0 :                 case SQL_CODE_HOUR:
      53           0 :                         return "SQL_CODE_HOUR";
      54           0 :                 case SQL_CODE_MINUTE:
      55           0 :                         return "SQL_CODE_MINUTE";
      56           0 :                 case SQL_CODE_SECOND:
      57           0 :                         return "SQL_CODE_SECOND";
      58           0 :                 case SQL_CODE_DAY_TO_HOUR:
      59           0 :                         return "SQL_CODE_DAY_TO_HOUR";
      60           0 :                 case SQL_CODE_DAY_TO_MINUTE:
      61           0 :                         return "SQL_CODE_DAY_TO_MINUTE";
      62           0 :                 case SQL_CODE_DAY_TO_SECOND:
      63           0 :                         return "SQL_CODE_DAY_TO_SECOND";
      64           0 :                 case SQL_CODE_HOUR_TO_MINUTE:
      65           0 :                         return "SQL_CODE_HOUR_TO_MINUTE";
      66           0 :                 case SQL_CODE_HOUR_TO_SECOND:
      67           0 :                         return "SQL_CODE_HOUR_TO_SECOND";
      68           0 :                 case SQL_CODE_MINUTE_TO_SECOND:
      69           0 :                         return "SQL_CODE_MINUTE_TO_SECOND";
      70           0 :                 default:
      71           0 :                         return "unknown";
      72             :                 }
      73             :         } else
      74             :                 return "unused";
      75             : }
      76             : #endif
      77             : 
      78             : SQLRETURN SQL_API
      79             : SQLSetDescRec(SQLHDESC DescriptorHandle,
      80             :               SQLSMALLINT RecNumber,
      81             :               SQLSMALLINT Type,
      82             :               SQLSMALLINT SubType,
      83             :               SQLLEN Length,
      84             :               SQLSMALLINT Precision,
      85             :               SQLSMALLINT Scale,
      86             :               SQLPOINTER DataPtr,
      87             :               SQLLEN *StringLengthPtr,
      88             :               SQLLEN *IndicatorPtr)
      89             : {
      90             :         ODBCDesc *desc = (ODBCDesc *) DescriptorHandle;
      91             : 
      92             : #ifdef ODBCDEBUG
      93           0 :         ODBCLOG("SQLSetDescRec %p %d %s %s " LENFMT " %d %d %p %p %p\n",
      94             :                 DescriptorHandle, (int) RecNumber,
      95             :                 isAD(desc) ? translateCType(Type) : translateSQLType(Type),
      96             :                 translateSubType(Type, SubType), LENCAST Length,
      97             :                 (int) Precision, (int) Scale, DataPtr,
      98             :                 StringLengthPtr, IndicatorPtr);
      99             : #endif
     100             : 
     101           0 :         if (!isValidDesc(desc))
     102             :                 return SQL_INVALID_HANDLE;
     103             : 
     104           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_TYPE,
     105           0 :                              (SQLPOINTER) (intptr_t) Type, 0) == SQL_ERROR)
     106             :                 return SQL_ERROR;
     107           0 :         if ((Type == SQL_DATETIME || Type == SQL_INTERVAL) &&
     108           0 :             MNDBSetDescField(desc, RecNumber, SQL_DESC_DATETIME_INTERVAL_CODE,
     109           0 :                              (SQLPOINTER) (intptr_t) SubType, 0) == SQL_ERROR)
     110             :                 return SQL_ERROR;
     111           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_OCTET_LENGTH,
     112             :                              (SQLPOINTER) (intptr_t) Length, 0) == SQL_ERROR)
     113             :                 return SQL_ERROR;
     114           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_PRECISION,
     115           0 :                              (SQLPOINTER) (intptr_t) Precision, 0) == SQL_ERROR)
     116             :                 return SQL_ERROR;
     117           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_SCALE,
     118           0 :                              (SQLPOINTER) (intptr_t) Scale, 0) == SQL_ERROR)
     119             :                 return SQL_ERROR;
     120           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_OCTET_LENGTH_PTR,
     121             :                              (SQLPOINTER) StringLengthPtr, 0) == SQL_ERROR)
     122             :                 return SQL_ERROR;
     123           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_INDICATOR_PTR,
     124             :                              (SQLPOINTER) IndicatorPtr, 0) == SQL_ERROR)
     125             :                 return SQL_ERROR;
     126           0 :         if (MNDBSetDescField(desc, RecNumber, SQL_DESC_DATA_PTR,
     127             :                              (SQLPOINTER) DataPtr, 0) == SQL_ERROR)
     128             :                 return SQL_ERROR;
     129           0 :         return desc->Error ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
     130             : }

Generated by: LCOV version 1.14