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

Generated by: LCOV version 1.14