LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLDescribeParam.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 29 0.0 %
Date: 2021-10-13 02:24:04 Functions: 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             :  * SQLDescribeParam()
      21             :  * CLI Compliance: ODBC (Microsoft)
      22             :  *
      23             :  * Author: Martin van Dinther, Sjoerd Mullender
      24             :  * Date  : 30 aug 2002
      25             :  *
      26             :  **********************************************************************/
      27             : 
      28             : #include "ODBCGlobal.h"
      29             : #include "ODBCStmt.h"
      30             : 
      31             : SQLRETURN SQL_API
      32             : SQLDescribeParam(SQLHSTMT StatementHandle,
      33             :                  SQLUSMALLINT ParameterNumber,
      34             :                  SQLSMALLINT *DataTypePtr,
      35             :                  SQLULEN *ParameterSizePtr,
      36             :                  SQLSMALLINT *DecimalDigitsPtr,
      37             :                  SQLSMALLINT *NullablePtr)
      38             : {
      39             :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      40             :         ODBCDescRec *rec;
      41             : 
      42             : #ifdef ODBCDEBUG
      43           0 :         ODBCLOG("SQLDescribeParam %p %u %p %p %p %p\n",
      44             :                 StatementHandle, (unsigned int) ParameterNumber,
      45             :                 DataTypePtr, ParameterSizePtr,
      46             :                 DecimalDigitsPtr, NullablePtr);
      47             : #endif
      48             : 
      49           0 :         if (!isValidStmt(stmt))
      50             :                  return SQL_INVALID_HANDLE;
      51             : 
      52           0 :         clearStmtErrors(stmt);
      53             : 
      54             :         /* check statement cursor state, query should be prepared or executed */
      55           0 :         if (stmt->State == INITED || stmt->State >= EXECUTED0) {
      56             :                 /* Function sequence error */
      57           0 :                 addStmtError(stmt, "HY010", NULL, 0);
      58           0 :                 return SQL_ERROR;
      59             :         }
      60             : 
      61           0 :         if (ParameterNumber < 1 ||
      62           0 :             ParameterNumber > stmt->ImplParamDescr->sql_desc_count) {
      63             :                 /* Invalid descriptor index */
      64           0 :                 addStmtError(stmt, "07009", NULL, 0);
      65           0 :                 return SQL_ERROR;
      66             :         }
      67             : 
      68           0 :         rec = &stmt->ImplParamDescr->descRec[ParameterNumber];
      69             : 
      70           0 :         if (DataTypePtr)
      71           0 :                 *DataTypePtr = rec->sql_desc_concise_type;
      72             : 
      73           0 :         if (NullablePtr)
      74           0 :                 *NullablePtr = rec->sql_desc_nullable;
      75             : 
      76             :         /* also see SQLDescribeCol */
      77           0 :         if (ParameterSizePtr)
      78           0 :                 *ParameterSizePtr = ODBCLength(rec, SQL_DESC_LENGTH);
      79             : 
      80             :         /* also see SQLDescribeCol */
      81           0 :         if (DecimalDigitsPtr) {
      82           0 :                 switch (rec->sql_desc_concise_type) {
      83           0 :                 case SQL_DECIMAL:
      84             :                 case SQL_NUMERIC:
      85           0 :                         *DecimalDigitsPtr = rec->sql_desc_scale;
      86           0 :                         break;
      87           0 :                 case SQL_BIT:
      88             :                 case SQL_TINYINT:
      89             :                 case SQL_SMALLINT:
      90             :                 case SQL_INTEGER:
      91             :                 case SQL_BIGINT:
      92             :                 case SQL_HUGEINT:
      93           0 :                         *DecimalDigitsPtr = 0;
      94           0 :                         break;
      95           0 :                 case SQL_TYPE_TIME:
      96             :                 case SQL_TYPE_TIMESTAMP:
      97             :                 case SQL_INTERVAL_SECOND:
      98             :                 case SQL_INTERVAL_DAY_TO_SECOND:
      99             :                 case SQL_INTERVAL_HOUR_TO_SECOND:
     100             :                 case SQL_INTERVAL_MINUTE_TO_SECOND:
     101           0 :                         *DecimalDigitsPtr = rec->sql_desc_precision;
     102           0 :                         break;
     103             :                 }
     104           0 :         }
     105             : 
     106             :         return SQL_SUCCESS;
     107             : }

Generated by: LCOV version 1.14