LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLSetEnvAttr.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 32 34.4 %
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             :  * SQLSetEnvAttr()
      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 "ODBCEnv.h"
      30             : #include <sys/types.h>            /* for ssize_t on Darwin */
      31             : 
      32             : 
      33             : SQLRETURN SQL_API
      34             : SQLSetEnvAttr(SQLHENV EnvironmentHandle,
      35             :               SQLINTEGER Attribute,
      36             :               SQLPOINTER ValuePtr,
      37             :               SQLINTEGER StringLength)
      38             : {
      39             :         ODBCEnv *env = (ODBCEnv *) EnvironmentHandle;
      40             : 
      41             : #ifdef ODBCDEBUG
      42           2 :         ODBCLOG("SQLSetEnvAttr %p %s %p %d\n",
      43             :                 EnvironmentHandle, translateEnvAttribute(Attribute),
      44             :                 ValuePtr, (int) StringLength);
      45             : #endif
      46             : 
      47             :         (void) StringLength;    /* Stefan: unused!? */
      48             : 
      49             :         /* global attribute */
      50           2 :         if (Attribute == SQL_ATTR_CONNECTION_POOLING && env == NULL) {
      51           0 :                 switch ((SQLUINTEGER) (uintptr_t) ValuePtr) {
      52             :                 case SQL_CP_OFF:
      53             :                 case SQL_CP_ONE_PER_DRIVER:
      54             :                 case SQL_CP_ONE_PER_HENV:
      55             :                         break;
      56             :                 default:
      57             :                         return SQL_INVALID_HANDLE;
      58             :                 }
      59           0 :                 return SQL_SUCCESS;
      60             :         }
      61             : 
      62           2 :         if (!isValidEnv(env))
      63             :                 return SQL_INVALID_HANDLE;
      64             : 
      65           2 :         clearEnvErrors(env);
      66             : 
      67             :         /* can only set environment attributes if no connection handle
      68             :            has been allocated */
      69           2 :         if (env->FirstDbc != NULL) {
      70             :                 /* Function sequence error */
      71           0 :                 addEnvError(env, "HY010", NULL, 0);
      72           0 :                 return SQL_ERROR;
      73             :         }
      74             : 
      75           2 :         switch (Attribute) {
      76           2 :         case SQL_ATTR_ODBC_VERSION:             /* SQLINTEGER */
      77           2 :                 switch ((SQLINTEGER) (intptr_t) ValuePtr) {
      78           2 :                 case SQL_OV_ODBC3:
      79             :                 case SQL_OV_ODBC2:
      80           2 :                         env->sql_attr_odbc_version = (SQLINTEGER) (intptr_t) ValuePtr;
      81             :                         break;
      82           0 :                 default:
      83             :                         /* Invalid attribute value */
      84           0 :                         addEnvError(env, "HY024", NULL, 0);
      85           0 :                         return SQL_ERROR;
      86             :                 }
      87           2 :                 break;
      88           0 :         case SQL_ATTR_CP_MATCH:                 /* SQLUINTEGER */
      89             :                 /* Optional feature not implemented */
      90           0 :                 addEnvError(env, "HYC00", NULL, 0);
      91           0 :                 return SQL_ERROR;
      92           0 :         case SQL_ATTR_OUTPUT_NTS:               /* SQLINTEGER */
      93           0 :                 switch ((SQLINTEGER) (intptr_t) ValuePtr) {
      94             :                 case SQL_TRUE:
      95             :                         break;
      96           0 :                 case SQL_FALSE:
      97             :                         /* Optional feature not implemented */
      98           0 :                         addEnvError(env, "HYC00", NULL, 0);
      99           0 :                         return SQL_ERROR;
     100           0 :                 default:
     101             :                         /* Invalid attribute/option identifier */
     102           0 :                         addEnvError(env, "HY092", NULL, 0);
     103           0 :                         return SQL_ERROR;
     104             :                 }
     105             :                 break;
     106           0 :         case SQL_ATTR_CONNECTION_POOLING:       /* SQLUINTEGER */
     107             :                 /* not valid with non-NULL environment handle parameter */
     108             :         default:
     109             :                 /* Invalid attribute/option identifier */
     110           0 :                 addEnvError(env, "HY092", NULL, 0);
     111           0 :                 return SQL_ERROR;
     112             :         }
     113             : 
     114             :         return SQL_SUCCESS;
     115             : }

Generated by: LCOV version 1.14