LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLGetData.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 36 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             :  * SQLGetData()
      21             :  * CLI Compliance: ISO 92
      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             : #include "ODBCUtil.h"
      31             : 
      32             : SQLRETURN SQL_API
      33             : SQLGetData(SQLHSTMT StatementHandle,
      34             :            SQLUSMALLINT Col_or_Param_Num,
      35             :            SQLSMALLINT TargetType,
      36             :            SQLPOINTER TargetValuePtr,
      37             :            SQLLEN BufferLength,
      38             :            SQLLEN *StrLen_or_IndPtr)
      39             : {
      40             :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      41             : 
      42             : #ifdef ODBCDEBUG
      43           0 :         ODBCLOG("SQLGetData %p %u %s %p " LENFMT " %p\n",
      44             :                 StatementHandle, (unsigned int) Col_or_Param_Num,
      45             :                 translateCType(TargetType), TargetValuePtr,
      46             :                 LENCAST BufferLength, StrLen_or_IndPtr);
      47             : #endif
      48             : 
      49           0 :         if (!isValidStmt(stmt))
      50             :                  return SQL_INVALID_HANDLE;
      51             : 
      52           0 :         assert(stmt->Dbc);
      53           0 :         assert(stmt->Dbc->mid);
      54           0 :         assert(stmt->hdl);
      55             : 
      56           0 :         clearStmtErrors(stmt);
      57             : 
      58             :         /* check statement cursor state, query should be executed */
      59           0 :         if (stmt->State < EXECUTED0) {
      60             :                 /* Function sequence error */
      61           0 :                 addStmtError(stmt, "HY010", NULL, 0);
      62           0 :                 return SQL_ERROR;
      63             :         }
      64           0 :         if (stmt->State <= EXECUTED1) {
      65             :                 /* Invalid cursor state */
      66           0 :                 addStmtError(stmt, "24000", NULL, 0);
      67           0 :                 return SQL_ERROR;
      68             :         }
      69           0 :         if (stmt->rowSetSize == 0) {
      70             :                 /* SQLFetch failed */
      71             :                 /* General error */
      72           0 :                 addStmtError(stmt, "HY000", NULL, 0);
      73           0 :                 return SQL_ERROR;
      74             :         }
      75           0 :         if (stmt->rowSetSize > 1 &&
      76           0 :             stmt->cursorType == SQL_CURSOR_FORWARD_ONLY) {
      77             :                 /* Invalid cursor position */
      78           0 :                 addStmtError(stmt, "HY109", NULL, 0);
      79           0 :                 return SQL_ERROR;
      80             :         }
      81           0 :         if (Col_or_Param_Num <= 0 ||
      82           0 :             Col_or_Param_Num > stmt->ImplRowDescr->sql_desc_count) {
      83             :                 /* Invalid descriptor index */
      84           0 :                 addStmtError(stmt, "07009", NULL, 0);
      85           0 :                 return SQL_ERROR;
      86             :         }
      87           0 :         if (TargetValuePtr == NULL) {
      88             :                 /* Invalid use of null pointer */
      89           0 :                 addStmtError(stmt, "HY009", NULL, 0);
      90           0 :                 return SQL_ERROR;
      91             :         }
      92             : 
      93           0 :         if (Col_or_Param_Num != stmt->currentCol)
      94           0 :                 stmt->retrieved = 0;
      95           0 :         stmt->currentCol = Col_or_Param_Num;
      96             : 
      97           0 :         if (TargetType == SQL_ARD_TYPE) {
      98           0 :                 ODBCDesc *desc = stmt->ApplRowDescr;
      99             : 
     100           0 :                 if (Col_or_Param_Num > desc->sql_desc_count) {
     101             :                         /* Invalid descriptor index */
     102           0 :                         addStmtError(stmt, "07009", NULL, 0);
     103           0 :                         return SQL_ERROR;
     104             :                 }
     105           0 :                 TargetType = desc->descRec[Col_or_Param_Num].sql_desc_concise_type;
     106             :         }
     107             : 
     108           0 :         return ODBCFetch(stmt, Col_or_Param_Num, TargetType, TargetValuePtr,
     109             :                          BufferLength, StrLen_or_IndPtr, StrLen_or_IndPtr,
     110             :                          UNAFFECTED, UNAFFECTED, UNAFFECTED, 0, 0);
     111             : }

Generated by: LCOV version 1.14