LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLSetDescRec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 55 0.0 %
Date: 2024-10-03 20:03:20 Functions: 0 1 0.0 %

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

Generated by: LCOV version 1.14