LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLGetInfo.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 633 730 86.7 %
Date: 2024-10-04 20:04:04 Functions: 2 2 100.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             :  * SQLGetInfo()
      25             :  * CLI Compliance: ISO 92
      26             :  *
      27             :  * Author: Martin van Dinther, Sjoerd Mullender
      28             :  * Date  : 30 Aug 2002
      29             :  *
      30             :  **********************************************************************/
      31             : 
      32             : #include "ODBCGlobal.h"
      33             : #include "ODBCDbc.h"
      34             : #include "ODBCUtil.h"
      35             : 
      36             : 
      37             : static SQLRETURN
      38         165 : MNDBGetInfo(ODBCDbc *dbc,
      39             :             SQLUSMALLINT InfoType,
      40             :             SQLPOINTER InfoValuePtr,
      41             :             SQLSMALLINT BufferLength,
      42             :             SQLSMALLINT *StringLengthPtr)
      43             : {
      44         165 :         int nValue = 0;
      45         165 :         char buf[64];
      46         165 :         const char *sValue = NULL;      /* iff non-NULL, return string value */
      47         165 :         int len = sizeof(SQLUINTEGER);  /* most common size to return */
      48         165 :         MapiHdl hdl = NULL;
      49             : 
      50             :         /* For some info types an active connection is needed */
      51         165 :         if (!dbc->Connected &&
      52           0 :             (InfoType == SQL_DATA_SOURCE_NAME ||
      53           0 :              InfoType == SQL_DATABASE_NAME ||
      54             :              InfoType == SQL_DBMS_VER ||
      55             :              InfoType == SQL_MAX_DRIVER_CONNECTIONS ||
      56             :              InfoType == SQL_USER_NAME ||
      57             :              InfoType == SQL_KEYWORDS)) {
      58             :                 /* Connection does not exist */
      59           0 :                 addDbcError(dbc, "08003", NULL, 0);
      60           0 :                 return SQL_ERROR;
      61             :         }
      62             : 
      63         165 :         switch (InfoType) {
      64             :         case SQL_ACCESSIBLE_PROCEDURES:
      65           2 :                 sValue = "N"; /* "Y" */
      66             :                 break;
      67             :         case SQL_ACCESSIBLE_TABLES:
      68           2 :                 sValue = "N"; /* "Y" */
      69             :                 break;
      70           0 :         case SQL_ACTIVE_ENVIRONMENTS:
      71           0 :                 nValue = 0;     /* 0 = no limit */
      72           0 :                 len = sizeof(SQLUSMALLINT);
      73           0 :                 break;
      74             :         case SQL_AGGREGATE_FUNCTIONS:
      75           2 :                 nValue = SQL_AF_ALL |
      76             :                         SQL_AF_AVG |
      77             :                         SQL_AF_COUNT |
      78             :                         SQL_AF_DISTINCT |
      79             :                         SQL_AF_MAX |
      80             :                         SQL_AF_MIN |
      81             :                         SQL_AF_SUM;
      82             :                 break;
      83             :         case SQL_ALTER_DOMAIN:
      84             :                 /* SQL_AD_ADD_CONSTRAINT_DEFERRABLE |
      85             :                  * SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED |
      86             :                  * SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE |
      87             :                  * SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE |
      88             :                  * SQL_AD_ADD_DOMAIN_CONSTRAINT |
      89             :                  * SQL_AD_ADD_DOMAIN_DEFAULT |
      90             :                  * SQL_AD_CONSTRAINT_NAME_DEFINITION |
      91             :                  * SQL_AD_DROP_DOMAIN_CONSTRAINT |
      92             :                  * SQL_AD_DROP_DOMAIN_DEFAULT */
      93             :                 break;
      94           1 :         case SQL_ALTER_TABLE:
      95           1 :                 nValue = SQL_AT_ADD_COLUMN | /* ODBC 2.0, deprecated value */
      96             :                         SQL_AT_ADD_COLUMN_DEFAULT |
      97             :                         SQL_AT_ADD_COLUMN_SINGLE |
      98             :                         SQL_AT_ADD_CONSTRAINT |
      99             :                         SQL_AT_ADD_TABLE_CONSTRAINT |
     100             :                         SQL_AT_CONSTRAINT_NAME_DEFINITION |
     101             :                         SQL_AT_DROP_COLUMN | /* ODBC 2.0, deprecated value */
     102             :                         SQL_AT_DROP_COLUMN_CASCADE |
     103             :                         SQL_AT_DROP_COLUMN_DEFAULT |
     104             :                         SQL_AT_DROP_COLUMN_RESTRICT |
     105             :                         SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE |
     106             :                         SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT |
     107             :                         SQL_AT_SET_COLUMN_DEFAULT;
     108             :                 /* SQL_AT_ADD_COLUMN_COLLATION |
     109             :                  * SQL_AT_CONSTRAINT_DEFERRABLE |
     110             :                  * SQL_AT_CONSTRAINT_INITIALLY_DEFERRED |
     111             :                  * SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE |
     112             :                  * SQL_AT_CONSTRAINT_NON_DEFERRABLE */
     113           1 :                 break;
     114             : #ifdef SQL_ASYNC_DBC_FUNCTIONS
     115             :         case SQL_ASYNC_DBC_FUNCTIONS:
     116             :                 nValue = SQL_ASYNC_DBC_NOT_CAPABLE;
     117             :                 /* SQL_ASYNC_DBC_CAPABLE */
     118             :                 break;
     119             : #endif
     120             :         case SQL_ASYNC_MODE:
     121             :                 nValue = SQL_AM_NONE;
     122             :                 /* SQL_AM_CONNECTION, SQL_AM_STATEMENT */
     123             :                 break;
     124             : #ifdef SQL_ASYNC_NOTIFICATION
     125             :         case SQL_ASYNC_NOTIFICATION:
     126             :                 nValue = SQL_ASYNC_NOTIFICATION_NOT_CAPABLE;
     127             :                 /* SQL_ASYNC_NOTIFICATION_CAPABLE */
     128             :                 break;
     129             : #endif
     130           1 :         case SQL_BATCH_ROW_COUNT:
     131           1 :                 nValue = SQL_BRC_EXPLICIT;
     132             :                 /* SQL_BRC_PROCEDURES | SQL_BRC_ROLLED_UP */
     133           1 :                 break;
     134             :         case SQL_BATCH_SUPPORT:
     135           5 :                 nValue = SQL_BS_ROW_COUNT_EXPLICIT | SQL_BS_SELECT_EXPLICIT;
     136             :                 /* SQL_BS_ROW_COUNT_PROC |
     137             :                  * SQL_BS_SELECT_PROC */
     138             :                 break;
     139             :         case SQL_BOOKMARK_PERSISTENCE:
     140             :                 /* SQL_BP_CLOSE |
     141             :                  * SQL_BP_DELETE |
     142             :                  * SQL_BP_DROP |
     143             :                  * SQL_BP_OTHER_HSTMT |
     144             :                  * SQL_BP_TRANSACTION |
     145             :                  * SQL_BP_UPDATE */
     146             :                 break;
     147           1 :         case SQL_CATALOG_LOCATION:
     148             :                 /* SQL_CL_END, SQL_CL_START */
     149           1 :                 len = sizeof(SQLUSMALLINT);
     150           1 :                 break;
     151           1 :         case SQL_CATALOG_NAME:
     152           1 :                 sValue = "N"; /* "Y" */
     153           1 :                 break;
     154           2 :         case SQL_CATALOG_NAME_SEPARATOR:
     155             :         case SQL_CATALOG_TERM:
     156           2 :                 sValue = "";
     157           2 :                 break;
     158             :         case SQL_CATALOG_USAGE:
     159             :                 /* SQL_CU_DML_STATEMENTS |
     160             :                  * SQL_CU_INDEX_DEFINITION |
     161             :                  * SQL_CU_PRIVILEGE_DEFINITION |
     162             :                  * SQL_CU_PROCEDURE_INVOCATION |
     163             :                  * SQL_CU_TABLE_DEFINITION */
     164             :                 break;
     165           1 :         case SQL_COLLATION_SEQ:
     166           1 :                 sValue = "UTF-8";
     167           1 :                 break;
     168           1 :         case SQL_COLUMN_ALIAS:
     169           1 :                 sValue = "Y"; /* "N" */
     170           1 :                 break;
     171           1 :         case SQL_CONCAT_NULL_BEHAVIOR:
     172           1 :                 nValue = SQL_CB_NULL;
     173             :                 /* SQL_CB_NON_NULL */
     174           1 :                 len = sizeof(SQLUSMALLINT);
     175           1 :                 break;
     176           4 :         case SQL_CONVERT_TINYINT:
     177             :         case SQL_CONVERT_SMALLINT:
     178             :         case SQL_CONVERT_INTEGER:
     179             :         case SQL_CONVERT_BIGINT:
     180           4 :                 nValue = SQL_CVT_BIGINT |
     181             :                         SQL_CVT_BIT |
     182             :                         SQL_CVT_CHAR |
     183             :                         SQL_CVT_DECIMAL |
     184             :                         SQL_CVT_DOUBLE |
     185             :                         SQL_CVT_FLOAT |
     186             :                         SQL_CVT_INTEGER |
     187             :                         SQL_CVT_INTERVAL_DAY_TIME |
     188             :                         SQL_CVT_INTERVAL_YEAR_MONTH |
     189             :                         SQL_CVT_LONGVARCHAR |
     190             :                         SQL_CVT_NUMERIC |
     191             :                         SQL_CVT_REAL |
     192             :                         SQL_CVT_SMALLINT |
     193             :                         SQL_CVT_TINYINT |
     194             :                         SQL_CVT_VARCHAR;
     195           4 :                 break;
     196           3 :         case SQL_CONVERT_BINARY:
     197             :         case SQL_CONVERT_LONGVARBINARY:
     198             :         case SQL_CONVERT_VARBINARY:
     199           3 :                 nValue = SQL_CVT_BINARY |
     200             :                         SQL_CVT_CHAR |
     201             :                         SQL_CVT_LONGVARBINARY |
     202             :                         SQL_CVT_LONGVARCHAR |
     203             :                         SQL_CVT_VARBINARY |
     204             :                         SQL_CVT_VARCHAR;
     205             :                 /* SQL_CVT_GUID */
     206           3 :                 break;
     207           1 :         case SQL_CONVERT_BIT:
     208           1 :                 nValue = SQL_CVT_BIGINT |
     209             :                         SQL_CVT_BIT |
     210             :                         SQL_CVT_CHAR |
     211             :                         SQL_CVT_INTEGER |
     212             :                         SQL_CVT_LONGVARCHAR |
     213             :                         SQL_CVT_SMALLINT |
     214             :                         SQL_CVT_TINYINT |
     215             :                         SQL_CVT_VARCHAR;
     216           1 :                 break;
     217           3 :         case SQL_CONVERT_CHAR:
     218             :         case SQL_CONVERT_VARCHAR:
     219             :         case SQL_CONVERT_LONGVARCHAR:
     220           3 :                 nValue = SQL_CVT_BIGINT |
     221             :                         SQL_CVT_BINARY |
     222             :                         SQL_CVT_BIT |
     223             :                         SQL_CVT_CHAR |
     224             :                         SQL_CVT_DATE |
     225             :                         SQL_CVT_DECIMAL |
     226             :                         SQL_CVT_DOUBLE |
     227             :                         SQL_CVT_FLOAT |
     228             :                         SQL_CVT_GUID |
     229             :                         SQL_CVT_INTEGER |
     230             :                         SQL_CVT_INTERVAL_DAY_TIME |
     231             :                         SQL_CVT_INTERVAL_YEAR_MONTH |
     232             :                         SQL_CVT_LONGVARBINARY |
     233             :                         SQL_CVT_LONGVARCHAR |
     234             :                         SQL_CVT_NUMERIC |
     235             :                         SQL_CVT_REAL |
     236             :                         SQL_CVT_SMALLINT |
     237             :                         SQL_CVT_TIME |
     238             :                         SQL_CVT_TIMESTAMP |
     239             :                         SQL_CVT_TINYINT |
     240             :                         SQL_CVT_VARBINARY |
     241             :                         SQL_CVT_VARCHAR;
     242           3 :                 break;
     243           1 :         case SQL_CONVERT_DATE:
     244           1 :                 nValue = SQL_CVT_CHAR |
     245             :                         SQL_CVT_DATE |
     246             :                         SQL_CVT_LONGVARCHAR |
     247             :                         SQL_CVT_TIMESTAMP |
     248             :                         SQL_CVT_VARCHAR;
     249           1 :                 break;
     250           2 :         case SQL_CONVERT_DECIMAL:
     251             :         case SQL_CONVERT_NUMERIC:
     252           2 :                 nValue = SQL_CVT_BIGINT |
     253             :                         SQL_CVT_CHAR |
     254             :                         SQL_CVT_DECIMAL |
     255             :                         SQL_CVT_DOUBLE |
     256             :                         SQL_CVT_FLOAT |
     257             :                         SQL_CVT_INTEGER |
     258             :                         SQL_CVT_INTERVAL_DAY_TIME |
     259             :                         SQL_CVT_LONGVARCHAR |
     260             :                         SQL_CVT_NUMERIC |
     261             :                         SQL_CVT_REAL |
     262             :                         SQL_CVT_SMALLINT |
     263             :                         SQL_CVT_TINYINT |
     264             :                         SQL_CVT_VARCHAR;
     265           2 :                 break;
     266           3 :         case SQL_CONVERT_DOUBLE:
     267             :         case SQL_CONVERT_REAL:
     268             :         case SQL_CONVERT_FLOAT:
     269           3 :                 nValue = SQL_CVT_BIGINT |
     270             :                         SQL_CVT_CHAR |
     271             :                         SQL_CVT_DECIMAL |
     272             :                         SQL_CVT_DOUBLE |
     273             :                         SQL_CVT_FLOAT |
     274             :                         SQL_CVT_INTEGER |
     275             :                         SQL_CVT_LONGVARCHAR |
     276             :                         SQL_CVT_NUMERIC |
     277             :                         SQL_CVT_REAL |
     278             :                         SQL_CVT_SMALLINT |
     279             :                         SQL_CVT_TINYINT |
     280             :                         SQL_CVT_VARCHAR;
     281           3 :                 break;
     282           1 :         case SQL_CONVERT_INTERVAL_DAY_TIME:
     283           1 :                 nValue = SQL_CVT_BIGINT |
     284             :                         SQL_CVT_CHAR |
     285             :                         SQL_CVT_INTEGER |
     286             :                         SQL_CVT_INTERVAL_DAY_TIME |
     287             :                         SQL_CVT_LONGVARCHAR |
     288             :                         SQL_CVT_SMALLINT |
     289             :                         SQL_CVT_TIME |
     290             :                         SQL_CVT_TINYINT |
     291             :                         SQL_CVT_VARCHAR;
     292           1 :                 break;
     293           1 :         case SQL_CONVERT_INTERVAL_YEAR_MONTH:
     294           1 :                 nValue = SQL_CVT_BIGINT |
     295             :                         SQL_CVT_CHAR |
     296             :                         SQL_CVT_INTEGER |
     297             :                         SQL_CVT_INTERVAL_YEAR_MONTH |
     298             :                         SQL_CVT_LONGVARCHAR |
     299             :                         SQL_CVT_SMALLINT |
     300             :                         SQL_CVT_TINYINT |
     301             :                         SQL_CVT_VARCHAR;
     302           1 :                 break;
     303           1 :         case SQL_CONVERT_TIME:
     304           1 :                 nValue = SQL_CVT_CHAR |
     305             :                         SQL_CVT_INTERVAL_DAY_TIME |
     306             :                         SQL_CVT_LONGVARCHAR |
     307             :                         SQL_CVT_TIME |
     308             :                         SQL_CVT_VARCHAR;
     309           1 :                 break;
     310           1 :         case SQL_CONVERT_TIMESTAMP:
     311           1 :                 nValue = SQL_CVT_CHAR |
     312             :                         SQL_CVT_DATE |
     313             :                         SQL_CVT_LONGVARCHAR |
     314             :                         SQL_CVT_TIME |
     315             :                         SQL_CVT_TIMESTAMP |
     316             :                         SQL_CVT_VARCHAR;
     317           1 :                 break;
     318           0 :         case SQL_CONVERT_GUID:
     319           0 :                 nValue =SQL_CVT_CHAR |
     320             :                         SQL_CVT_GUID |
     321             :                         SQL_CVT_LONGVARCHAR |
     322             :                         SQL_CVT_VARCHAR;
     323           0 :                 break;
     324             :         case SQL_CONVERT_FUNCTIONS:
     325           5 :                 nValue = SQL_FN_CVT_CAST | SQL_FN_CVT_CONVERT;
     326             :                 break;
     327             :         case SQL_CORRELATION_NAME:
     328           3 :                 nValue = SQL_CN_ANY;
     329             :                 /* SQL_CN_DIFFERENT, SQL_CN_NONE */
     330           3 :                 len = sizeof(SQLUSMALLINT);
     331             :                 break;
     332             :         case SQL_CREATE_ASSERTION:
     333             :                 /* SQL_CA_CREATE_ASSERTION |
     334             :                  * SQL_CA_CONSTRAINT_DEFERRABLE |
     335             :                  * SQL_CA_CONSTRAINT_INITIALLY_DEFERRED |
     336             :                  * SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE |
     337             :                  * SQL_CA_CONSTRAINT_NON_DEFERRABLE */
     338             :         case SQL_CREATE_CHARACTER_SET:
     339             :                 /* SQL_CCS_CREATE_CHARACTER_SET |
     340             :                  * SQL_CCS_COLLATE_CLAUSE |
     341             :                  * SQL_CCS_LIMITED_COLLATION */
     342             :         case SQL_CREATE_COLLATION:
     343             :                 /* SQL_CCOL_CREATE_COLLATION */
     344             :         case SQL_CREATE_DOMAIN:
     345             :                 /* SQL_CDO_CREATE_DOMAIN |
     346             :                  * SQL_CDO_CONSTRAINT_NAME_DEFINITION |
     347             :                  * SQL_CDO_DEFAULT |
     348             :                  * SQL_CDO_CONSTRAINT |
     349             :                  * SQL_CDO_COLLATION |
     350             :                  * SQL_CDO_CONSTRAINT_DEFERRABLE |
     351             :                  * SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED |
     352             :                  * SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE |
     353             :                  * SQL_CDO_CONSTRAINT_NON_DEFERRABLE */
     354             :         case SQL_CREATE_TRANSLATION:
     355             :                 /* SQL_CTR_CREATE_TRANSLATION */
     356             :                 break;
     357             :         case SQL_CREATE_SCHEMA:
     358           5 :                 nValue = SQL_CS_CREATE_SCHEMA | SQL_CS_AUTHORIZATION;
     359             :                 /* SQL_CS_DEFAULT_CHARACTER_SET */
     360             :                 break;
     361           1 :         case SQL_CREATE_TABLE:
     362           1 :                 nValue = SQL_CT_COLUMN_CONSTRAINT |
     363             :                         SQL_CT_COLUMN_DEFAULT |
     364             :                         SQL_CT_COMMIT_DELETE |
     365             :                         SQL_CT_COMMIT_PRESERVE |
     366             :                         SQL_CT_CONSTRAINT_NAME_DEFINITION |
     367             :                         SQL_CT_CREATE_TABLE |
     368             :                         SQL_CT_GLOBAL_TEMPORARY |
     369             :                         SQL_CT_LOCAL_TEMPORARY |
     370             :                         SQL_CT_TABLE_CONSTRAINT;
     371             :                 /* SQL_CT_COLUMN_COLLATION |
     372             :                  * SQL_CT_CONSTRAINT_DEFERRABLE |
     373             :                  * SQL_CT_CONSTRAINT_INITIALLY_DEFERRED |
     374             :                  * SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE |
     375             :                  * SQL_CT_CONSTRAINT_NON_DEFERRABLE */
     376           1 :                 break;
     377             :         case SQL_CREATE_VIEW:
     378           5 :                 nValue = SQL_CV_CREATE_VIEW | SQL_CV_CHECK_OPTION;
     379             :                 /* SQL_CV_CASCADE | SQL_CV_LOCAL */
     380             :                 break;
     381           6 :         case SQL_CURSOR_COMMIT_BEHAVIOR:
     382             :         case SQL_CURSOR_ROLLBACK_BEHAVIOR:
     383           6 :                 nValue = SQL_CB_DELETE;
     384             :                 /* SQL_CB_CLOSE, SQL_CB_DELETE, SQL_CB_PRESERVE */
     385           6 :                 len = sizeof(SQLUSMALLINT);
     386           6 :                 break;
     387           1 :         case SQL_CURSOR_SENSITIVITY:
     388           1 :                 nValue = SQL_INSENSITIVE;
     389             :                 /* SQL_SENSITIVE, SQL_UNSPECIFIED */
     390           1 :                 break;
     391           0 :         case SQL_DATA_SOURCE_NAME:
     392           0 :                 sValue = dbc->dsn ? dbc->dsn : "";
     393             :                 break;
     394           1 :         case SQL_DATA_SOURCE_READ_ONLY:
     395           1 :                 sValue = "N"; /* "Y" */
     396           1 :                 break;
     397           1 :         case SQL_DATABASE_NAME:
     398           1 :                 sValue = msetting_string(dbc->settings, MP_DATABASE);
     399           1 :                 break;
     400           1 :         case SQL_DATETIME_LITERALS:
     401           1 :                 nValue = SQL_DL_SQL92_DATE |
     402             :                         SQL_DL_SQL92_TIME |
     403             :                         SQL_DL_SQL92_TIMESTAMP |
     404             :                         SQL_DL_SQL92_INTERVAL_YEAR |
     405             :                         SQL_DL_SQL92_INTERVAL_MONTH |
     406             :                         SQL_DL_SQL92_INTERVAL_DAY |
     407             :                         SQL_DL_SQL92_INTERVAL_HOUR |
     408             :                         SQL_DL_SQL92_INTERVAL_MINUTE |
     409             :                         SQL_DL_SQL92_INTERVAL_SECOND |
     410             :                         SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH |
     411             :                         SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR |
     412             :                         SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE |
     413             :                         SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND |
     414             :                         SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE |
     415             :                         SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND |
     416             :                         SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND;
     417           1 :                 len = sizeof(SQLINTEGER);
     418           1 :                 break;
     419           1 :         case SQL_DBMS_NAME:
     420           1 :                 sValue = "MonetDB";
     421           1 :                 break;
     422           1 :         case SQL_DBMS_VER:
     423           1 :                 snprintf(buf, sizeof(buf), "%02d.%02d.%04d",
     424           1 :                          dbc->major, dbc->minor, dbc->patch);
     425           1 :                 sValue = buf;
     426           1 :                 break;
     427             :         case SQL_DDL_INDEX:
     428           5 :                 nValue = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX;
     429             :                 break;
     430             :         case SQL_DEFAULT_TXN_ISOLATION:
     431           3 :                 nValue = SQL_TXN_SERIALIZABLE;
     432             :                 break;
     433           2 :         case SQL_DESCRIBE_PARAMETER:
     434           2 :                 sValue = "N"; /* "Y" */
     435           2 :                 break;
     436             : #ifdef SQL_DRIVER_AWARE_POOLING_SUPPORTED
     437             :         case SQL_DRIVER_AWARE_POOLING_SUPPORTED:
     438             :                 nValue = SQL_DRIVER_AWARE_POOLING_NOT_CAPABLE;
     439             :                 /* SQL_DRIVER_AWARE_POOLING_CAPABLE */
     440             :                 break;
     441             : #endif
     442           1 :         case SQL_DRIVER_NAME:
     443           1 :                 sValue = MONETDB_DRIVER_NAME;
     444           1 :                 break;
     445           2 :         case SQL_DRIVER_ODBC_VER:
     446           2 :                 sValue = MONETDB_ODBC_VER;
     447           2 :                 break;
     448           1 :         case SQL_DRIVER_VER:
     449           1 :                 snprintf(buf, sizeof(buf), "%02d.%02d.%04d %s",
     450             :                          MONETDB_VERSION_MAJOR, MONETDB_VERSION_MINOR,
     451             :                          MONETDB_VERSION_PATCH,
     452             : #ifdef MONETDB_RELEASE
     453             :                          MONETDB_RELEASE
     454             : #else
     455             :                          "unreleased"
     456             : #endif
     457             :                         );
     458           1 :                 sValue = buf;
     459           1 :                 break;
     460             :         case SQL_DROP_ASSERTION:
     461             :                 /* SQL_DA_DROP_ASSERION */
     462             :                 break;
     463             :         case SQL_DROP_CHARACTER_SET:
     464             :                 /* SQL_DCS_DROP_CHARACTER_SET */
     465             :                 break;
     466             :         case SQL_DROP_COLLATION:
     467             :                 /* SQL_DC_DROP_COLLATION */
     468             :                 break;
     469             :         case SQL_DROP_DOMAIN:
     470             :                 /* SQL_DD_DROP_DOMAIN | SQL_DD_CASCADE | SQL_DD_RESTRICT */
     471             :                 break;
     472             :         case SQL_DROP_SCHEMA:
     473           8 :                 nValue = SQL_DS_DROP_SCHEMA | SQL_DS_CASCADE | SQL_DS_RESTRICT;
     474             :                 break;
     475             :         case SQL_DROP_TABLE:
     476           8 :                 nValue = SQL_DT_DROP_TABLE | SQL_DT_CASCADE | SQL_DT_RESTRICT;
     477             :                 break;
     478             :         case SQL_DROP_TRANSLATION:
     479             :                 /* SQL_DTR_DROP_TRANSLATION */
     480             :                 break;
     481             :         case SQL_DROP_VIEW:
     482           8 :                 nValue = SQL_DV_DROP_VIEW | SQL_DV_CASCADE | SQL_DV_RESTRICT;
     483             :                 break;
     484             :         case SQL_DYNAMIC_CURSOR_ATTRIBUTES1:
     485           8 :                 nValue = SQL_CA1_ABSOLUTE | SQL_CA1_NEXT | SQL_CA1_RELATIVE;
     486             :                 /* SQL_CA1_BOOKMARK |
     487             :                  * SQL_CA1_BULK_ADD |
     488             :                  * SQL_CA1_BULK_DELETE_BY_BOOKMARK |
     489             :                  * SQL_CA1_BULK_FETCH_BY_BOOKMARK |
     490             :                  * SQL_CA1_BULK_UPDATE_BY_BOOKMARK |
     491             :                  * SQL_CA1_LOCK_EXCLUSIVE |
     492             :                  * SQL_CA1_LOCK_NO_CHANGE |
     493             :                  * SQL_CA1_LOCK_UNLOCK |
     494             :                  * SQL_CA1_POS_DELETE |
     495             :                  * SQL_CA1_POSITIONED_DELETE |
     496             :                  * SQL_CA1_POSITIONED_UPDATE |
     497             :                  * SQL_CA1_POS_POSITION |
     498             :                  * SQL_CA1_POS_REFRESH |
     499             :                  * SQL_CA1_POS_UPDATE |
     500             :                  * SQL_CA1_SELECT_FOR_UPDATE */
     501             :                 break;
     502             :         case SQL_DYNAMIC_CURSOR_ATTRIBUTES2:
     503             :                 /* SQL_CA2_CRC_APPROXIMATE |
     504             :                  * SQL_CA2_CRC_EXACT |
     505             :                  * SQL_CA2_LOCK_CONCURRENCY |
     506             :                  * SQL_CA2_MAX_ROWS_AFFECTS_ALL |
     507             :                  * SQL_CA2_MAX_ROWS_CATALOG |
     508             :                  * SQL_CA2_MAX_ROWS_DELETE |
     509             :                  * SQL_CA2_MAX_ROWS_INSERT |
     510             :                  * SQL_CA2_MAX_ROWS_SELECT |
     511             :                  * SQL_CA2_MAX_ROWS_UPDATE |
     512             :                  * SQL_CA2_OPT_ROWVER_CONCURRENCY |
     513             :                  * SQL_CA2_OPT_VALUES_CONCURRENCY |
     514             :                  * SQL_CA2_READ_ONLY_CONCURRENCY |
     515             :                  * SQL_CA2_SENSITIVITY_ADDITIONS |
     516             :                  * SQL_CA2_SENSITIVITY_DELETIONS |
     517             :                  * SQL_CA2_SENSITIVITY_UPDATES |
     518             :                  * SQL_CA2_SIMULATE_NON_UNIQUE |
     519             :                  * SQL_CA2_SIMULATE_TRY_UNIQUE |
     520             :                  * SQL_CA2_SIMULATE_UNIQUE */
     521             :                 break;
     522           1 :         case SQL_EXPRESSIONS_IN_ORDERBY:
     523           1 :                 sValue = "Y"; /* "N" */
     524           1 :                 break;
     525           1 :         case SQL_FILE_USAGE:
     526           1 :                 nValue = SQL_FILE_NOT_SUPPORTED;
     527             :                 /* SQL_FILE_TABLE, SQL_FILE_CATALOG */
     528           1 :                 len = sizeof(SQLUSMALLINT);
     529           1 :                 break;
     530             :         case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1:
     531           1 :                 nValue = SQL_CA1_NEXT;
     532             :                 /* SQL_CA1_BULK_ADD |
     533             :                  * SQL_CA1_BULK_DELETE_BY_BOOKMARK |
     534             :                  * SQL_CA1_BULK_FETCH_BY_BOOKMARK |
     535             :                  * SQL_CA1_BULK_UPDATE_BY_BOOKMARK |
     536             :                  * SQL_CA1_LOCK_EXCLUSIVE |
     537             :                  * SQL_CA1_LOCK_NO_CHANGE |
     538             :                  * SQL_CA1_LOCK_UNLOCK |
     539             :                  * SQL_CA1_POS_DELETE |
     540             :                  * SQL_CA1_POSITIONED_DELETE |
     541             :                  * SQL_CA1_POSITIONED_UPDATE |
     542             :                  * SQL_CA1_POS_POSITION |
     543             :                  * SQL_CA1_POS_REFRESH |
     544             :                  * SQL_CA1_POS_UPDATE |
     545             :                  * SQL_CA1_SELECT_FOR_UPDATE */
     546             :                 break;
     547             :         case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2:
     548             :                 /* SQL_CA2_CRC_APPROXIMATE |
     549             :                  * SQL_CA2_CRC_EXACT |
     550             :                  * SQL_CA2_LOCK_CONCURRENCY |
     551             :                  * SQL_CA2_MAX_ROWS_AFFECTS_ALL |
     552             :                  * SQL_CA2_MAX_ROWS_CATALOG |
     553             :                  * SQL_CA2_MAX_ROWS_DELETE |
     554             :                  * SQL_CA2_MAX_ROWS_INSERT |
     555             :                  * SQL_CA2_MAX_ROWS_SELECT |
     556             :                  * SQL_CA2_MAX_ROWS_UPDATE |
     557             :                  * SQL_CA2_OPT_ROWVER_CONCURRENCY |
     558             :                  * SQL_CA2_OPT_VALUES_CONCURRENCY |
     559             :                  * SQL_CA2_READ_ONLY_CONCURRENCY |
     560             :                  * SQL_CA2_SENSITIVITY_ADDITIONS |
     561             :                  * SQL_CA2_SENSITIVITY_DELETIONS |
     562             :                  * SQL_CA2_SENSITIVITY_UPDATES |
     563             :                  * SQL_CA2_SIMULATE_NON_UNIQUE |
     564             :                  * SQL_CA2_SIMULATE_TRY_UNIQUE |
     565             :                  * SQL_CA2_SIMULATE_UNIQUE */
     566             :                 break;
     567             :         case SQL_GETDATA_EXTENSIONS:
     568           5 :                 nValue = SQL_GD_ANY_COLUMN |
     569             :                         SQL_GD_ANY_ORDER |
     570             :                         SQL_GD_BLOCK |
     571             :                         SQL_GD_BOUND;
     572             :                 /* SQL_GD_OUTPUT_PARAMS */
     573             :                 break;
     574           1 :         case SQL_GROUP_BY:
     575           1 :                 nValue = SQL_GB_NO_RELATION;
     576             :                 /* SQL_GB_COLLATE, SQL_GB_NOT_SUPPORTED,
     577             :                  * SQL_GB_BROUP_BY_EQUALS_SELECT,
     578             :                  * SQL_GB_GROUP_BY_CONTAINS_SELECT */
     579           1 :                 len = sizeof(SQLUSMALLINT);
     580           1 :                 break;
     581             :         case SQL_IDENTIFIER_CASE:
     582           3 :                 nValue = SQL_IC_LOWER;
     583             :                 /* SQL_IC_UPPER, SQL_IC_SENSITIVE, SQL_IC_MIXED */
     584           3 :                 len = sizeof(SQLUSMALLINT);
     585             :                 break;
     586           1 :         case SQL_IDENTIFIER_QUOTE_CHAR:
     587           1 :                 sValue = "\"";   /* the " (double quote) */
     588           1 :                 break;
     589             :         case SQL_INDEX_KEYWORDS:
     590             :                 nValue = SQL_IK_NONE;
     591             :                 /* SQL_IK_ASC | SQL_IK_DESC | SQL_IK_ALL */
     592             :                 break;
     593           1 :         case SQL_INFO_SCHEMA_VIEWS:
     594           1 :                 nValue = SQL_ISV_CHARACTER_SETS |
     595             :                         SQL_ISV_CHECK_CONSTRAINTS |
     596             :                         SQL_ISV_COLUMNS |
     597             :                         SQL_ISV_REFERENTIAL_CONSTRAINTS |
     598             :                         SQL_ISV_SCHEMATA |
     599             :                         SQL_ISV_TABLE_CONSTRAINTS |
     600             :                         SQL_ISV_TABLES |
     601             :                         SQL_ISV_VIEWS;
     602             :                 /* SQL_ISV_ASSERTIONS |
     603             :                  * SQL_ISV_COLLATIONS |
     604             :                  * SQL_ISV_COLUMN_DOMAIN_USAGE |
     605             :                  * SQL_ISV_COLUMN_PRIVILEGES |
     606             :                  * SQL_ISV_CONSTRAINT_COLUMN_USAGE |
     607             :                  * SQL_ISV_CONSTRAINT_TABLE_USAGE |
     608             :                  * SQL_ISV_DOMAIN_CONSTRAINTS |
     609             :                  * SQL_ISV_DOMAINS |
     610             :                  * SQL_ISV_KEY_COLUMN_USAGE |
     611             :                  * SQL_ISV_SQL_LANGUAGES |
     612             :                  * SQL_ISV_TABLE_PRIVILEGES |
     613             :                  * SQL_ISV_TRANSLATIONS |
     614             :                  * SQL_ISV_USAGE_PRIVILEGES |
     615             :                  * SQL_ISV_VIEW_COLUMN_USAGE |
     616             :                  * SQL_ISV_VIEW_TABLE_USAGE */
     617           1 :                 break;
     618             :         case SQL_INSERT_STATEMENT:
     619           8 :                 nValue = SQL_IS_INSERT_LITERALS |
     620             :                         SQL_IS_INSERT_SEARCHED |
     621             :                         SQL_IS_SELECT_INTO;
     622             :                 break;
     623           1 :         case SQL_INTEGRITY:
     624             :                 /* N because we currently do not support CHECK constraints (see bug 3568) nor deferrable FK constraints. */
     625           1 :                 sValue = "N"; /* "Y" */
     626           1 :                 break;
     627             :         case SQL_KEYSET_CURSOR_ATTRIBUTES1:
     628             :                 /* SQL_CA1_ABSOLUTE |
     629             :                  * SQL_CA1_BOOKMARK |
     630             :                  * SQL_CA1_BULK_ADD |
     631             :                  * SQL_CA1_BULK_DELETE_BY_BOOKMARK |
     632             :                  * SQL_CA1_BULK_FETCH_BY_BOOKMARK |
     633             :                  * SQL_CA1_BULK_UPDATE_BY_BOOKMARK |
     634             :                  * SQL_CA1_LOCK_EXCLUSIVE |
     635             :                  * SQL_CA1_LOCK_NO_CHANGE |
     636             :                  * SQL_CA1_LOCK_UNLOCK |
     637             :                  * SQL_CA1_NEXT |
     638             :                  * SQL_CA1_POS_DELETE |
     639             :                  * SQL_CA1_POSITIONED_DELETE |
     640             :                  * SQL_CA1_POSITIONED_UPDATE |
     641             :                  * SQL_CA1_POS_POSITION |
     642             :                  * SQL_CA1_POS_REFRESH |
     643             :                  * SQL_CA1_POS_UPDATE |
     644             :                  * SQL_CA1_RELATIVE |
     645             :                  * SQL_CA1_SELECT_FOR_UPDATE */
     646             :                 break;
     647             :         case SQL_KEYSET_CURSOR_ATTRIBUTES2:
     648             :                 /* SQL_CA2_CRC_APPROXIMATE |
     649             :                  * SQL_CA2_CRC_EXACT |
     650             :                  * SQL_CA2_LOCK_CONCURRENCY |
     651             :                  * SQL_CA2_MAX_ROWS_AFFECTS_ALL |
     652             :                  * SQL_CA2_MAX_ROWS_CATALOG |
     653             :                  * SQL_CA2_MAX_ROWS_DELETE |
     654             :                  * SQL_CA2_MAX_ROWS_INSERT |
     655             :                  * SQL_CA2_MAX_ROWS_SELECT |
     656             :                  * SQL_CA2_MAX_ROWS_UPDATE |
     657             :                  * SQL_CA2_OPT_ROWVER_CONCURRENCY |
     658             :                  * SQL_CA2_OPT_VALUES_CONCURRENCY |
     659             :                  * SQL_CA2_READ_ONLY_CONCURRENCY |
     660             :                  * SQL_CA2_SENSITIVITY_ADDITIONS |
     661             :                  * SQL_CA2_SENSITIVITY_DELETIONS |
     662             :                  * SQL_CA2_SENSITIVITY_UPDATES |
     663             :                  * SQL_CA2_SIMULATE_NON_UNIQUE |
     664             :                  * SQL_CA2_SIMULATE_TRY_UNIQUE |
     665             :                  * SQL_CA2_SIMULATE_UNIQUE */
     666             :                 break;
     667           1 :         case SQL_KEYWORDS:
     668             :                 /* A character string that contains a comma-separated list of all data source-specific keywords.
     669             :                  * This list does not contain keywords specific to ODBC or keywords used by both the data source and ODBC.
     670             :                  * This list represents all the reserved keywords; interoperable applications should not use these words in object names.
     671             :                  * Returns the MonetDB sys.keywords minus the ODBC keywords: https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/reserved-keywords */
     672           1 :                 hdl = mapi_query(dbc->mid,
     673             :                         "WITH x(k) AS (SELECT keyword FROM sys.keywords WHERE keyword NOT IN ("
     674             :                         "'ABSOLUTE','ACTION','ADA','ADD','ALL','ALLOCATE','ALTER','AND','ANY',"
     675             :                         "'ARE','AS','ASC','ASSERTION','AT','AUTHORIZATION','AVG',"
     676             :                         "'BEGIN','BETWEEN','BIT','BIT_LENGTH','BOTH','BY',"
     677             :                         "'CASCADE','CASCADED','CASE','CAST','CATALOG','CHAR','CHAR_LENGTH',"
     678             :                         "'CHARACTER','CHARACTER_LENGTH','CHECK','CLOSE','COALESCE',"
     679             :                         "'COLLATE','COLLATION','COLUMN','COMMIT','CONNECT','CONNECTION','CONSTRAINT',"
     680             :                         "'CONSTRAINTS','CONTINUE','CONVERT','CORRESPONDING','COUNT','CREATE','CROSS',"
     681             :                         "'CURRENT','CURRENT_DATE','CURRENT_TIME','CURRENT_TIMESTAMP','CURRENT_USER','CURSOR',"
     682             :                         "'DATE','DAY','DEALLOCATE','DEC','DECIMAL','DECLARE','DEFAULT','DEFERRABLE',"
     683             :                         "'DEFERRED','DELETE','DESC','DESCRIBE','DESCRIPTOR','DIAGNOSTICS','DISCONNECT',"
     684             :                         "'DISTINCT','DOMAIN','DOUBLE','DROP',"
     685             :                         "'ELSE','END','END-EXEC','ESCAPE','EXCEPT','EXCEPTION','EXEC','EXECUTE',"
     686             :                         "'EXISTS','EXTERNAL','EXTRACT',"
     687             :                         "'FALSE','FETCH','FIRST','FLOAT','FOR','FOREIGN','FORTRAN','FOUND','FROM','FULL',"
     688             :                         "'GET','GLOBAL','GO','GOTO','GRANT','GROUP','HAVING','HOUR',"
     689             :                         "'IDENTITY','IMMEDIATE','IN','INCLUDE','INDEX','INDICATOR','INITIALLY','INNER','INPUT',"
     690             :                         "'INSENSITIVE','INSERT','INT','INTEGER','INTERSECT','INTERVAL','INTO','IS','ISOLATION',"
     691             :                         "'JOIN','KEY','LANGUAGE','LAST','LEADING','LEFT','LEVEL','LIKE','LOCAL','LOWER',"
     692             :                         "'MATCH','MAX','MIN','MINUTE','MODULE','MONTH',"
     693             :                         "'NAMES','NATIONAL','NATURAL','NCHAR','NEXT','NO','NONE','NOT','NULL','NULLIF','NUMERIC',"
     694             :                         "'OCTET_LENGTH','OF','ON','ONLY','OPEN','OPTION','OR','ORDER','OUTER','OUTPUT','OVERLAPS',"
     695             :                         "'PAD','PARTIAL','PASCAL','PLI','POSITION','PRECISION','PREPARE','PRESERVE',"
     696             :                         "'PRIMARY','PRIOR','PRIVILEGES','PROCEDURE','PUBLIC',"
     697             :                         "'READ','REAL','REFERENCES','RELATIVE','RESTRICT','REVOKE','RIGHT','ROLLBACK','ROWS',"
     698             :                         "'SCHEMA','SCROLL','SECOND','SECTION','SELECT','SESSION','SESSION_USER','SET',"
     699             :                         "'SIZE','SMALLINT','SOME','SPACE','SQL','SQLCA','SQLCODE','SQLERROR',"
     700             :                         "'SQLSTATE','SQLWARNING','SUBSTRING','SUM','SYSTEM_USER',"
     701             :                         "'TABLE','TEMPORARY','THEN','TIME','TIMESTAMP','TIMEZONE_HOUR','TIMEZONE_MINUTE',"
     702             :                         "'TO','TRAILING','TRANSACTION','TRANSLATE','TRANSLATION','TRIM','TRUE',"
     703             :                         "'UNION','UNIQUE','UNKNOWN','UPDATE','UPPER','USAGE','USER','USING',"
     704             :                         "'VALUE','VALUES','VARCHAR','VARYING','VIEW',"
     705             :                         "'WHEN','WHENEVER','WHERE','WITH','WORK','WRITE',"
     706             :                         "'YEAR','ZONE') ORDER BY keyword) SELECT group_concat(k, ',') FROM x");
     707           1 :                 if (hdl != NULL && mapi_fetch_row(hdl)) {
     708           1 :                         sValue = mapi_fetch_field(hdl, 0);
     709             :                 } else {
     710           0 :                         addDbcError(dbc, mapi_error(dbc->mid) == MTIMEOUT ? "HYT01" : "HY000", NULL, 0);
     711             :                 }
     712             :                 break;
     713           1 :         case SQL_LIKE_ESCAPE_CLAUSE:
     714           1 :                 sValue = "Y"; /* "N" */
     715           1 :                 break;
     716             :         case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS:
     717             :                 break;
     718             :         case SQL_MAX_BINARY_LITERAL_LEN:
     719             :                 break;
     720             :         case SQL_MAX_CATALOG_NAME_LEN:
     721           7 :                 len = sizeof(SQLUSMALLINT);
     722             :                 break;
     723             :         case SQL_MAX_CHAR_LITERAL_LEN:
     724             :                 break;
     725             :         case SQL_MAX_COLUMN_NAME_LEN:
     726           5 :                 nValue = 1024;  /* max length of column sys._columns.name is defined as 1024 */
     727           5 :                 len = sizeof(SQLUSMALLINT);
     728             :                 break;
     729             :         case SQL_MAX_COLUMNS_IN_GROUP_BY:
     730             :         case SQL_MAX_COLUMNS_IN_INDEX:
     731             :         case SQL_MAX_COLUMNS_IN_ORDER_BY:
     732             :         case SQL_MAX_COLUMNS_IN_SELECT:
     733             :         case SQL_MAX_COLUMNS_IN_TABLE:
     734             :         case SQL_MAX_CONCURRENT_ACTIVITIES:
     735             :         case SQL_MAX_CURSOR_NAME_LEN:
     736           7 :                 len = sizeof(SQLUSMALLINT);
     737             :                 break;
     738           1 :         case SQL_MAX_DRIVER_CONNECTIONS:
     739           1 :                 nValue = dbc->maxclients;
     740           1 :                 len = sizeof(SQLUSMALLINT);
     741           1 :                 break;
     742             :         case SQL_MAX_IDENTIFIER_LEN:
     743           5 :                 nValue = 1024;  /* max length of columns sys.*.name is defined as 1024 */
     744           5 :                 len = sizeof(SQLUSMALLINT);
     745             :                 break;
     746             :         case SQL_MAX_INDEX_SIZE:
     747             :                 break;
     748           1 :         case SQL_MAX_PROCEDURE_NAME_LEN:
     749           1 :                 nValue = 256;   /* max length of column sys.functions.name is defined as 256 */
     750           1 :                 len = sizeof(SQLUSMALLINT);
     751           1 :                 break;
     752             :         case SQL_MAX_ROW_SIZE:
     753             :                 break;
     754           1 :         case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
     755           1 :                 sValue = "Y"; /* "N" */
     756           1 :                 break;
     757             :         case SQL_MAX_SCHEMA_NAME_LEN:
     758           5 :                 nValue = 1024;  /* max length of column sys.schemas.name is defined as 1024 */
     759           5 :                 len = sizeof(SQLUSMALLINT);
     760             :                 break;
     761             :         case SQL_MAX_STATEMENT_LEN:
     762             :                 break;
     763             :         case SQL_MAX_TABLE_NAME_LEN:
     764           5 :                 nValue = 1024;  /* max length of column sys._tables.name is defined as 1024 */
     765           5 :                 len = sizeof(SQLUSMALLINT);
     766             :                 break;
     767           1 :         case SQL_MAX_TABLES_IN_SELECT:
     768           1 :                 len = sizeof(SQLUSMALLINT);
     769           1 :                 break;
     770             :         case SQL_MAX_USER_NAME_LEN:
     771           5 :                 nValue = 1024;  /* max length of sys.db_user_info.name is defined as 1024 */
     772           5 :                 len = sizeof(SQLUSMALLINT);
     773             :                 break;
     774             :         case SQL_MULT_RESULT_SETS:
     775           2 :                 sValue = "Y"; /* "N" */
     776             :                 break;
     777             :         case SQL_MULTIPLE_ACTIVE_TXN:
     778           2 :                 sValue = "Y"; /* "N" */
     779             :                 break;
     780             :         case SQL_NEED_LONG_DATA_LEN:
     781           3 :                 sValue = "N"; /* "Y" */
     782             :                 break;
     783             :         case SQL_NON_NULLABLE_COLUMNS:
     784           2 :                 nValue = SQL_NNC_NON_NULL;
     785             :                 /* SQL_NNC_NULL */
     786           2 :                 len = sizeof(SQLUSMALLINT);
     787             :                 break;
     788             :         case SQL_NULL_COLLATION:
     789           2 :                 nValue = SQL_NC_LOW;
     790             :                 /* SQL_NC_END, SQL_NC_HIGH, SQL_NC_START */
     791           2 :                 len = sizeof(SQLUSMALLINT);
     792             :                 break;
     793           1 :         case SQL_NUMERIC_FUNCTIONS:
     794           1 :                 nValue = SQL_FN_NUM_ABS |
     795             :                         SQL_FN_NUM_ACOS |
     796             :                         SQL_FN_NUM_ASIN |
     797             :                         SQL_FN_NUM_ATAN |
     798             :                         SQL_FN_NUM_ATAN2 |
     799             :                         SQL_FN_NUM_CEILING |
     800             :                         SQL_FN_NUM_COS |
     801             :                         SQL_FN_NUM_COT |
     802             :                         SQL_FN_NUM_DEGREES |
     803             :                         SQL_FN_NUM_EXP |
     804             :                         SQL_FN_NUM_FLOOR |
     805             :                         SQL_FN_NUM_LOG |
     806             :                         SQL_FN_NUM_LOG10 |
     807             :                         SQL_FN_NUM_MOD |
     808             :                         SQL_FN_NUM_PI |
     809             :                         SQL_FN_NUM_POWER |
     810             :                         SQL_FN_NUM_RADIANS |
     811             :                         SQL_FN_NUM_RAND |
     812             :                         SQL_FN_NUM_ROUND |
     813             :                         SQL_FN_NUM_SIGN |
     814             :                         SQL_FN_NUM_SIN |
     815             :                         SQL_FN_NUM_SQRT |
     816             :                         SQL_FN_NUM_TAN |
     817             :                         SQL_FN_NUM_TRUNCATE;    /* is mapped to ms_trunc() */
     818           1 :                 break;
     819             :         case SQL_ODBC_INTERFACE_CONFORMANCE:
     820           2 :                 nValue = SQL_OIC_CORE;
     821             :                 /* SQL_OIC_LEVEL1, SQL_OIC_LEVEL2 */
     822             :                 break;
     823             :         case SQL_OJ_CAPABILITIES:
     824           2 :                 nValue = SQL_OJ_LEFT |
     825             :                         SQL_OJ_RIGHT |
     826             :                         SQL_OJ_FULL |
     827             :                         SQL_OJ_NESTED |
     828             :                         SQL_OJ_NOT_ORDERED |
     829             :                         SQL_OJ_INNER |
     830             :                         SQL_OJ_ALL_COMPARISON_OPS;
     831             :                 break;
     832             :         case SQL_ORDER_BY_COLUMNS_IN_SELECT:
     833           3 :                 sValue = "N"; /* "Y" */
     834             :                 break;
     835             :         case SQL_PARAM_ARRAY_ROW_COUNTS:
     836           2 :                 nValue = SQL_PARC_BATCH; /* ? */
     837             :                 /* SQL_PARC_NO_BATCH */
     838             :                 break;
     839             :         case SQL_PARAM_ARRAY_SELECTS:
     840           1 :                 nValue = SQL_PAS_NO_SELECT;
     841             :                 /* SQL_PAS_BATCH, SQL_PAS_NO_BATCH */
     842             :                 break;
     843           1 :         case SQL_PROCEDURE_TERM:
     844           1 :                 sValue = "procedure";
     845           1 :                 break;
     846           1 :         case SQL_PROCEDURES:
     847           1 :                 sValue = "Y"; /* "N" */
     848           1 :                 break;
     849           1 :         case SQL_QUOTED_IDENTIFIER_CASE:
     850           1 :                 nValue = SQL_IC_SENSITIVE;
     851             :                 /* SQL_IC_LOWER, SQL_IC_MIXED, SQL_IC_UPPER */
     852           1 :                 len = sizeof(SQLUSMALLINT);
     853           1 :                 break;
     854           1 :         case SQL_ROW_UPDATES:
     855           1 :                 sValue = "N"; /* "Y" */
     856           1 :                 break;
     857           1 :         case SQL_SCHEMA_TERM:
     858           1 :                 sValue = "schema";
     859           1 :                 break;
     860             :         case SQL_SCHEMA_USAGE:
     861           2 :                 nValue = SQL_SU_DML_STATEMENTS |
     862             :                         SQL_SU_PROCEDURE_INVOCATION |
     863             :                         SQL_SU_TABLE_DEFINITION |
     864             :                         SQL_SU_INDEX_DEFINITION |
     865             :                         SQL_SU_PRIVILEGE_DEFINITION;
     866             :                 break;
     867           1 :         case SQL_SCROLL_OPTIONS:
     868           1 :                 nValue = SQL_SO_STATIC;
     869             :                 /* SQL_SO_DYNAMIC,
     870             :                  * SQL_SO_FORWARD_ONLY,
     871             :                  * SQL_SO_KEYSET_DRIVEN,
     872             :                  * SQL_SO_MIXED */
     873           1 :                 break;
     874           1 :         case SQL_SEARCH_PATTERN_ESCAPE:
     875           1 :                 sValue = "\\";
     876           1 :                 break;
     877           1 :         case SQL_SERVER_NAME:
     878           1 :                 sValue = MONETDB_SERVER_NAME;
     879           1 :                 break;
     880           1 :         case SQL_SPECIAL_CHARACTERS:
     881           1 :                 sValue = "!#$%&'()*+,-./:;<=>?@[]^`{|}~";
     882           1 :                 break;
     883             :         case SQL_SQL_CONFORMANCE:
     884           3 :                 nValue = SQL_SC_SQL92_FULL;
     885             :                 break;
     886             :         case SQL_SQL92_DATETIME_FUNCTIONS:
     887           8 :                 nValue = SQL_SDF_CURRENT_DATE |
     888             :                         SQL_SDF_CURRENT_TIME |
     889             :                         SQL_SDF_CURRENT_TIMESTAMP;
     890             :                 break;
     891             :         case SQL_SQL92_FOREIGN_KEY_DELETE_RULE:
     892           5 :                 nValue = SQL_SFKD_CASCADE |
     893             :                         SQL_SFKD_NO_ACTION |
     894             :                         SQL_SFKD_SET_DEFAULT |
     895             :                         SQL_SFKD_SET_NULL;
     896             :                 break;
     897             :         case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE:
     898           5 :                 nValue = SQL_SFKU_CASCADE |
     899             :                         SQL_SFKU_NO_ACTION |
     900             :                         SQL_SFKU_SET_DEFAULT |
     901             :                         SQL_SFKU_SET_NULL;
     902             :                 break;
     903           1 :         case SQL_SQL92_GRANT:
     904           1 :                 nValue = SQL_SG_DELETE_TABLE |
     905             :                         SQL_SG_INSERT_COLUMN |
     906             :                         SQL_SG_INSERT_TABLE |
     907             :                         SQL_SG_REFERENCES_COLUMN |
     908             :                         SQL_SG_REFERENCES_TABLE |
     909             :                         SQL_SG_SELECT_TABLE |
     910             :                         SQL_SG_UPDATE_COLUMN |
     911             :                         SQL_SG_UPDATE_TABLE |
     912             :                         SQL_SG_WITH_GRANT_OPTION;
     913             :                 /* SQL_SG_USAGE_ON_CHARACTER_SET |
     914             :                  * SQL_SG_USAGE_ON_COLLATION |
     915             :                  * SQL_SG_USAGE_ON_DOMAIN |
     916             :                  * SQL_SG_USAGE_ON_TRANSLATION */
     917           1 :                 break;
     918           1 :         case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS:
     919           1 :                 nValue = SQL_SNVF_CHAR_LENGTH |
     920             :                         SQL_SNVF_CHARACTER_LENGTH |
     921             :                         SQL_SNVF_EXTRACT |
     922             :                         SQL_SNVF_OCTET_LENGTH |
     923             :                         SQL_SNVF_POSITION;
     924             :                 /* SQL_SNVF_BIT_LENGTH */
     925           1 :                 break;
     926           1 :         case SQL_SQL92_PREDICATES: /* ? */
     927           1 :                 nValue = SQL_SP_BETWEEN |
     928             :                         SQL_SP_COMPARISON |
     929             :                         SQL_SP_EXISTS |
     930             :                         SQL_SP_IN |
     931             :                         SQL_SP_ISNOTNULL |
     932             :                         SQL_SP_ISNULL |
     933             :                         SQL_SP_LIKE |
     934             :                         SQL_SP_MATCH_FULL |
     935             :                         SQL_SP_MATCH_PARTIAL|
     936             :                         SQL_SP_MATCH_UNIQUE_FULL |
     937             :                         SQL_SP_MATCH_UNIQUE_PARTIAL |
     938             :                         SQL_SP_OVERLAPS |
     939             :                         SQL_SP_QUANTIFIED_COMPARISON |
     940             :                         SQL_SP_UNIQUE;
     941           1 :                 break;
     942           1 :         case SQL_SQL92_RELATIONAL_JOIN_OPERATORS:
     943           1 :                 nValue = SQL_SRJO_CORRESPONDING_CLAUSE |
     944             :                         SQL_SRJO_CROSS_JOIN |
     945             :                         SQL_SRJO_EXCEPT_JOIN |
     946             :                         SQL_SRJO_FULL_OUTER_JOIN |
     947             :                         SQL_SRJO_INNER_JOIN |
     948             :                         SQL_SRJO_INTERSECT_JOIN |
     949             :                         SQL_SRJO_LEFT_OUTER_JOIN |
     950             :                         SQL_SRJO_NATURAL_JOIN |
     951             :                         SQL_SRJO_RIGHT_OUTER_JOIN |
     952             :                         SQL_SRJO_UNION_JOIN;
     953           1 :                 break;
     954           1 :         case SQL_SQL92_REVOKE:
     955           1 :                 nValue = SQL_SR_DELETE_TABLE |
     956             :                         SQL_SR_GRANT_OPTION_FOR |
     957             :                         SQL_SR_INSERT_COLUMN |
     958             :                         SQL_SR_INSERT_TABLE |
     959             :                         SQL_SR_REFERENCES_COLUMN |
     960             :                         SQL_SR_REFERENCES_TABLE |
     961             :                         SQL_SR_SELECT_TABLE |
     962             :                         SQL_SR_UPDATE_COLUMN |
     963             :                         SQL_SR_UPDATE_TABLE;
     964             :                 /* SQL_SR_CASCADE |
     965             :                  * SQL_SR_RESTRICT |
     966             :                  * SQL_SR_USAGE_ON_DOMAIN |
     967             :                  * SQL_SR_USAGE_ON_CHARACTER_SET |
     968             :                  * SQL_SR_USAGE_ON_COLLATION |
     969             :                  * SQL_SR_USAGE_ON_TRANSLATION */
     970           1 :                 break;
     971             :         case SQL_SQL92_ROW_VALUE_CONSTRUCTOR: /* ? */
     972           5 :                 nValue = SQL_SRVC_VALUE_EXPRESSION |
     973             :                         SQL_SRVC_NULL |
     974             :                         SQL_SRVC_DEFAULT |
     975             :                         SQL_SRVC_ROW_SUBQUERY;
     976             :                 break;
     977           1 :         case SQL_SQL92_STRING_FUNCTIONS:
     978           1 :                 nValue = SQL_SSF_CONVERT |
     979             :                         SQL_SSF_LOWER |
     980             :                         SQL_SSF_UPPER |
     981             :                         SQL_SSF_SUBSTRING |
     982             :                         SQL_SSF_TRIM_BOTH |
     983             :                         SQL_SSF_TRIM_LEADING |
     984             :                         SQL_SSF_TRIM_TRAILING;
     985           1 :                 break;
     986             :                 /* SQL_SSF_TRANSLATE */
     987             :         case SQL_SQL92_VALUE_EXPRESSIONS:
     988           5 :                 nValue = SQL_SVE_CASE |
     989             :                         SQL_SVE_CAST |
     990             :                         SQL_SVE_COALESCE |
     991             :                         SQL_SVE_NULLIF;
     992             :                 break;
     993           1 :         case SQL_STANDARD_CLI_CONFORMANCE: /* ? */
     994           1 :                 nValue = SQL_SCC_XOPEN_CLI_VERSION1 | SQL_SCC_ISO92_CLI;
     995           1 :                 break;
     996             :         case SQL_STATIC_CURSOR_ATTRIBUTES1:
     997           8 :                 nValue = SQL_CA1_ABSOLUTE |
     998             :                         SQL_CA1_NEXT |
     999             :                         SQL_CA1_RELATIVE;
    1000             :                 /* SQL_CA1_BOOKMARK |
    1001             :                  * SQL_CA1_BULK_ADD |
    1002             :                  * SQL_CA1_BULK_DELETE_BY_BOOKMARK |
    1003             :                  * SQL_CA1_BULK_FETCH_BY_BOOKMARK |
    1004             :                  * SQL_CA1_BULK_UPDATE_BY_BOOKMARK |
    1005             :                  * SQL_CA1_LOCK_EXCLUSIVE |
    1006             :                  * SQL_CA1_LOCK_NO_CHANGE |
    1007             :                  * SQL_CA1_LOCK_UNLOCK |
    1008             :                  * SQL_CA1_POS_DELETE |
    1009             :                  * SQL_CA1_POSITIONED_DELETE |
    1010             :                  * SQL_CA1_POSITIONED_UPDATE |
    1011             :                  * SQL_CA1_POS_POSITION |
    1012             :                  * SQL_CA1_POS_REFRESH |
    1013             :                  * SQL_CA1_POS_UPDATE |
    1014             :                  * SQL_CA1_SELECT_FOR_UPDATE */
    1015             :                 break;
    1016             :         case SQL_STATIC_CURSOR_ATTRIBUTES2:
    1017             :                 /* SQL_CA2_CRC_APPROXIMATE |
    1018             :                  * SQL_CA2_CRC_EXACT |
    1019             :                  * SQL_CA2_LOCK_CONCURRENCY |
    1020             :                  * SQL_CA2_MAX_ROWS_AFFECTS_ALL |
    1021             :                  * SQL_CA2_MAX_ROWS_CATALOG |
    1022             :                  * SQL_CA2_MAX_ROWS_DELETE |
    1023             :                  * SQL_CA2_MAX_ROWS_INSERT |
    1024             :                  * SQL_CA2_MAX_ROWS_SELECT |
    1025             :                  * SQL_CA2_MAX_ROWS_UPDATE |
    1026             :                  * SQL_CA2_OPT_ROWVER_CONCURRENCY |
    1027             :                  * SQL_CA2_OPT_VALUES_CONCURRENCY |
    1028             :                  * SQL_CA2_READ_ONLY_CONCURRENCY |
    1029             :                  * SQL_CA2_SENSITIVITY_ADDITIONS |
    1030             :                  * SQL_CA2_SENSITIVITY_DELETIONS |
    1031             :                  * SQL_CA2_SENSITIVITY_UPDATES |
    1032             :                  * SQL_CA2_SIMULATE_NON_UNIQUE |
    1033             :                  * SQL_CA2_SIMULATE_TRY_UNIQUE |
    1034             :                  * SQL_CA2_SIMULATE_UNIQUE */
    1035             :                 break;
    1036           1 :         case SQL_STRING_FUNCTIONS:
    1037           1 :                 nValue = SQL_FN_STR_ASCII |
    1038             :                         SQL_FN_STR_CHAR |
    1039             :                         SQL_FN_STR_CHARACTER_LENGTH |
    1040             :                         SQL_FN_STR_CHAR_LENGTH |
    1041             :                         SQL_FN_STR_CONCAT |
    1042             :                         SQL_FN_STR_DIFFERENCE |
    1043             :                         SQL_FN_STR_INSERT |
    1044             :                         SQL_FN_STR_LCASE |
    1045             :                         SQL_FN_STR_LEFT |
    1046             :                         SQL_FN_STR_LENGTH |
    1047             :                         SQL_FN_STR_LOCATE |
    1048             :                         SQL_FN_STR_LOCATE_2 |
    1049             :                         SQL_FN_STR_LTRIM |
    1050             :                         SQL_FN_STR_OCTET_LENGTH |
    1051             :                         SQL_FN_STR_POSITION |
    1052             :                         SQL_FN_STR_REPEAT |
    1053             :                         SQL_FN_STR_REPLACE |
    1054             :                         SQL_FN_STR_RIGHT |
    1055             :                         SQL_FN_STR_RTRIM |
    1056             :                         SQL_FN_STR_SOUNDEX |
    1057             :                         SQL_FN_STR_SPACE |
    1058             :                         SQL_FN_STR_SUBSTRING |
    1059             :                         SQL_FN_STR_UCASE;
    1060             :                 /* SQL_FN_STR_BIT_LENGTH */
    1061           1 :                 break;
    1062             :         case SQL_SUBQUERIES:
    1063           2 :                 nValue = SQL_SQ_CORRELATED_SUBQUERIES |
    1064             :                         SQL_SQ_COMPARISON |
    1065             :                         SQL_SQ_EXISTS |
    1066             :                         SQL_SQ_IN |
    1067             :                         SQL_SQ_QUANTIFIED;
    1068             :                 break;
    1069             :         case SQL_SYSTEM_FUNCTIONS:
    1070           8 :                 nValue = SQL_FN_SYS_DBNAME |
    1071             :                         SQL_FN_SYS_IFNULL |
    1072             :                         SQL_FN_SYS_USERNAME;
    1073             :                 break;
    1074           1 :         case SQL_TABLE_TERM:
    1075           1 :                 sValue = "table";
    1076           1 :                 break;
    1077           2 :         case SQL_TIMEDATE_ADD_INTERVALS:
    1078             :         case SQL_TIMEDATE_DIFF_INTERVALS:
    1079             :                 /* when server is 11.46 or higher */
    1080           2 :                 nValue = SQL_FN_TSI_FRAC_SECOND |
    1081             :                         SQL_FN_TSI_SECOND |
    1082             :                         SQL_FN_TSI_MINUTE |
    1083             :                         SQL_FN_TSI_HOUR |
    1084             :                         SQL_FN_TSI_DAY |
    1085             :                         SQL_FN_TSI_WEEK |
    1086             :                         SQL_FN_TSI_MONTH |
    1087             :                         SQL_FN_TSI_QUARTER |
    1088             :                         SQL_FN_TSI_YEAR;
    1089           2 :                 break;
    1090           1 :         case SQL_TIMEDATE_FUNCTIONS:
    1091           1 :                 nValue = SQL_FN_TD_CURRENT_DATE |
    1092             :                         SQL_FN_TD_CURRENT_TIME |
    1093             :                         SQL_FN_TD_CURRENT_TIMESTAMP |
    1094             :                         SQL_FN_TD_CURDATE |
    1095             :                         SQL_FN_TD_CURTIME |
    1096             :                         SQL_FN_TD_DAYNAME |     /* when server is 11.46 or higher */
    1097             :                         SQL_FN_TD_DAYOFMONTH |
    1098             :                         SQL_FN_TD_DAYOFWEEK |
    1099             :                         SQL_FN_TD_DAYOFYEAR |
    1100             :                         SQL_FN_TD_EXTRACT |
    1101             :                         SQL_FN_TD_HOUR |
    1102             :                         SQL_FN_TD_MINUTE |
    1103             :                         SQL_FN_TD_MONTH |
    1104             :                         SQL_FN_TD_MONTHNAME |   /* when server is 11.46 or higher */
    1105             :                         SQL_FN_TD_NOW |
    1106             :                         SQL_FN_TD_QUARTER |
    1107             :                         SQL_FN_TD_SECOND |
    1108             :                         SQL_FN_TD_TIMESTAMPADD |        /* when server is 11.46 or higher */
    1109             :                         SQL_FN_TD_TIMESTAMPDIFF |       /* when server is 11.46 or higher */
    1110             :                         SQL_FN_TD_WEEK |
    1111             :                         SQL_FN_TD_YEAR;
    1112           1 :                 break;
    1113             :         case SQL_TXN_CAPABLE:
    1114           3 :                 nValue = SQL_TC_ALL;
    1115           3 :                 len = sizeof(SQLUSMALLINT);
    1116             :                 break;
    1117             :         case SQL_TXN_ISOLATION_OPTION:
    1118           3 :                 nValue = SQL_TXN_SERIALIZABLE;
    1119             :                 break;
    1120             :         case SQL_UNION:
    1121           1 :                 nValue = SQL_U_UNION | SQL_U_UNION_ALL;
    1122             :                 break;
    1123           1 :         case SQL_USER_NAME:
    1124           1 :                 sValue = msetting_string(dbc->settings, MP_USER);
    1125           1 :                 break;
    1126           0 :         case SQL_XOPEN_CLI_YEAR: /* ? */
    1127           0 :                 sValue = "";
    1128           0 :                 break;
    1129             : 
    1130             :         /* deprecated info types */
    1131           0 :         case SQL_FETCH_DIRECTION:
    1132           0 :                 nValue = SQL_FD_FETCH_ABSOLUTE |
    1133             :                         SQL_FD_FETCH_FIRST |
    1134             :                         SQL_FD_FETCH_LAST |
    1135             :                         SQL_FD_FETCH_NEXT |
    1136             :                         SQL_FD_FETCH_PRIOR |
    1137             :                         SQL_FD_FETCH_RELATIVE;
    1138             :                 /* SQL_FD_FETCH_BOOKMARK */
    1139           0 :                 len = sizeof(SQLUSMALLINT);
    1140           0 :                 break;
    1141             :         case SQL_LOCK_TYPES:
    1142           1 :                 nValue = SQL_LCK_NO_CHANGE;
    1143             :                 /*  SQL_LCK_EXCLUSIVE | SQL_LCK_UNLOCK */
    1144             :                 break;
    1145             :         case SQL_ODBC_API_CONFORMANCE:
    1146           3 :                 nValue = SQL_OAC_LEVEL2;
    1147             :                 /* SQL_OAC_CORE, SQL_OAC_LEVEL1 */
    1148           3 :                 len = sizeof(SQLUSMALLINT);
    1149             :                 break;
    1150           0 :         case SQL_ODBC_SQL_CONFORMANCE:
    1151           0 :                 nValue = SQL_OSC_CORE;
    1152             :                 /* SQL_OSC_MINIMUM, SQL_OSC_EXTENDED */
    1153           0 :                 len = sizeof(SQLUSMALLINT);
    1154           0 :                 break;
    1155           1 :         case SQL_POS_OPERATIONS:
    1156           1 :                 nValue = SQL_POS_POSITION;
    1157             :                 /* SQL_POS_ADD |
    1158             :                  * SQL_POS_DELETE |
    1159             :                  * SQL_POS_REFRESH |
    1160             :                  * SQL_POS_UPDATE */
    1161           1 :                 break;
    1162           0 :         case SQL_POSITIONED_STATEMENTS:
    1163           0 :                 nValue = SQL_PS_SELECT_FOR_UPDATE;
    1164             :                 /* SQL_PS_POSITIONED_DELETE |
    1165             :                  * SQL_PS_POSITIONED_UPDATE |
    1166             :                  * SQL_PS_SELECT_FOR_UPDATE */
    1167           0 :                 break;
    1168           0 :         case SQL_SCROLL_CONCURRENCY:
    1169           0 :                 nValue = SQL_SCCO_READ_ONLY;
    1170             :                 /* SQL_SCCO_LOCK |
    1171             :                  * SQL_SCCO_OPT_ROWVER |
    1172             :                  * SQL_SCCO_OPT_VALUES */
    1173           0 :                 len = sizeof(SQLUSMALLINT);
    1174           0 :                 break;
    1175             :         case SQL_STATIC_SENSITIVITY:
    1176             :                 /* SQL_SS_ADDITIONS |
    1177             :                  * SQL_SS_DELETIONS |
    1178             :                  * SQL_SS_UPDATES */
    1179             :                 len = sizeof(SQLINTEGER);
    1180             :                 break;
    1181             : 
    1182           0 :         case SQL_ODBC_SAG_CLI_CONFORMANCE:
    1183           0 :                 nValue = SQL_OSCC_COMPLIANT;
    1184           0 :                 len = sizeof(SQLUSMALLINT);
    1185           0 :                 break;
    1186           0 :         case SQL_OUTER_JOINS:
    1187           0 :                 sValue = "Y"; /* "N" */
    1188           0 :                 break;
    1189             : 
    1190           0 :         default:
    1191             :                 /* Invalid information type */
    1192           0 :                 addDbcError(dbc, "HY096", NULL, 0);
    1193           0 :                 return SQL_ERROR;
    1194             :         }
    1195             : 
    1196             :         /* copy the data to the supplied output parameters */
    1197         165 :         if (sValue) {
    1198          37 :                 copyString(sValue, strlen(sValue), InfoValuePtr, BufferLength, StringLengthPtr, SQLSMALLINT, addDbcError, dbc, return SQL_ERROR);
    1199         128 :         } else if (InfoValuePtr) {
    1200         128 :                 if (len == sizeof(SQLUINTEGER))
    1201          97 :                         *(SQLUINTEGER *) InfoValuePtr = (SQLUINTEGER) nValue;
    1202             : #ifndef SQLULEN
    1203             :                 /* if SQLULEN is defined, it's defined as SQLUINTEGER
    1204             :                  * which we've handled */
    1205          31 :                 else if (len == sizeof(SQLULEN))
    1206             :                         *(SQLULEN *) InfoValuePtr = (SQLULEN) nValue;
    1207             : #endif
    1208          31 :                 else if (len == sizeof(SQLUSMALLINT))
    1209          31 :                         *(SQLUSMALLINT *) InfoValuePtr = (SQLUSMALLINT) nValue;
    1210         128 :                 if (StringLengthPtr)
    1211         128 :                         *StringLengthPtr = len;
    1212             :         }
    1213             : 
    1214         165 :         if (hdl)
    1215           1 :                 mapi_close_handle(hdl);
    1216             : 
    1217         165 :         return dbc->Error ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
    1218             : }
    1219             : 
    1220             : #ifdef ODBCDEBUG
    1221             : static char *
    1222         165 : translateInfoType(SQLUSMALLINT InfoType)
    1223             : {
    1224         165 :         static char unknown[32];
    1225             : 
    1226         165 :         switch (InfoType) {
    1227             :         case SQL_ACCESSIBLE_PROCEDURES:
    1228             :                 return "SQL_ACCESSIBLE_PROCEDURES";
    1229           1 :         case SQL_ACCESSIBLE_TABLES:
    1230           1 :                 return "SQL_ACCESSIBLE_TABLES";
    1231           0 :         case SQL_ACTIVE_ENVIRONMENTS:
    1232           0 :                 return "SQL_ACTIVE_ENVIRONMENTS";
    1233           1 :         case SQL_AGGREGATE_FUNCTIONS:
    1234           1 :                 return "SQL_AGGREGATE_FUNCTIONS";
    1235           1 :         case SQL_ALTER_DOMAIN:
    1236           1 :                 return "SQL_ALTER_DOMAIN";
    1237             : #ifdef SQL_ALTER_SCHEMA
    1238             :         case SQL_ALTER_SCHEMA:
    1239             :                 return "SQL_ALTER_SCHEMA";
    1240             : #endif
    1241           1 :         case SQL_ALTER_TABLE:
    1242           1 :                 return "SQL_ALTER_TABLE";
    1243             : #ifdef SQL_ANSI_SQL_DATETIME_LITERALS
    1244             :         case SQL_ANSI_SQL_DATETIME_LITERALS:
    1245             :                 return "SQL_ANSI_SQL_DATETIME_LITERALS";
    1246             : #endif
    1247             : #ifdef SQL_ASYNC_DBC_FUNCTIONS
    1248             :         case SQL_ASYNC_DBC_FUNCTIONS:
    1249             :                 return "SQL_ASYNC_DBC_FUNCTIONS";
    1250             : #endif
    1251           1 :         case SQL_ASYNC_MODE:
    1252           1 :                 return "SQL_ASYNC_MODE";
    1253             : #ifdef SQL_ASYNC_NOTIFICATION
    1254             :         case SQL_ASYNC_NOTIFICATION:
    1255             :                 return "SQL_ASYNC_NOTIFICATION";
    1256             : #endif
    1257           1 :         case SQL_BATCH_ROW_COUNT:
    1258           1 :                 return "SQL_BATCH_ROW_COUNT";
    1259           1 :         case SQL_BATCH_SUPPORT:
    1260           1 :                 return "SQL_BATCH_SUPPORT";
    1261           1 :         case SQL_BOOKMARK_PERSISTENCE:
    1262           1 :                 return "SQL_BOOKMARK_PERSISTENCE";
    1263           1 :         case SQL_CATALOG_LOCATION:
    1264           1 :                 return "SQL_CATALOG_LOCATION";
    1265           1 :         case SQL_CATALOG_NAME:
    1266           1 :                 return "SQL_CATALOG_NAME";
    1267           1 :         case SQL_CATALOG_NAME_SEPARATOR:
    1268           1 :                 return "SQL_CATALOG_NAME_SEPARATOR";
    1269           1 :         case SQL_CATALOG_TERM:
    1270           1 :                 return "SQL_CATALOG_TERM";
    1271           1 :         case SQL_CATALOG_USAGE:
    1272           1 :                 return "SQL_CATALOG_USAGE";
    1273           1 :         case SQL_COLLATION_SEQ:
    1274           1 :                 return "SQL_COLLATION_SEQ";
    1275           1 :         case SQL_COLUMN_ALIAS:
    1276           1 :                 return "SQL_COLUMN_ALIAS";
    1277           1 :         case SQL_CONCAT_NULL_BEHAVIOR:
    1278           1 :                 return "SQL_CONCAT_NULL_BEHAVIOR";
    1279           1 :         case SQL_CONVERT_BIGINT:
    1280           1 :                 return "SQL_CONVERT_BIGINT";
    1281           1 :         case SQL_CONVERT_BINARY:
    1282           1 :                 return "SQL_CONVERT_BINARY";
    1283           1 :         case SQL_CONVERT_BIT:
    1284           1 :                 return "SQL_CONVERT_BIT";
    1285           1 :         case SQL_CONVERT_CHAR:
    1286           1 :                 return "SQL_CONVERT_CHAR";
    1287           1 :         case SQL_CONVERT_DATE:
    1288           1 :                 return "SQL_CONVERT_DATE";
    1289           1 :         case SQL_CONVERT_DECIMAL:
    1290           1 :                 return "SQL_CONVERT_DECIMAL";
    1291           1 :         case SQL_CONVERT_DOUBLE:
    1292           1 :                 return "SQL_CONVERT_DOUBLE";
    1293           1 :         case SQL_CONVERT_FLOAT:
    1294           1 :                 return "SQL_CONVERT_FLOAT";
    1295           1 :         case SQL_CONVERT_FUNCTIONS:
    1296           1 :                 return "SQL_CONVERT_FUNCTIONS";
    1297           1 :         case SQL_CONVERT_INTEGER:
    1298           1 :                 return "SQL_CONVERT_INTEGER";
    1299           1 :         case SQL_CONVERT_INTERVAL_DAY_TIME:
    1300           1 :                 return "SQL_CONVERT_INTERVAL_DAY_TIME";
    1301           1 :         case SQL_CONVERT_INTERVAL_YEAR_MONTH:
    1302           1 :                 return "SQL_CONVERT_INTERVAL_YEAR_MONTH";
    1303           1 :         case SQL_CONVERT_LONGVARBINARY:
    1304           1 :                 return "SQL_CONVERT_LONGVARBINARY";
    1305           1 :         case SQL_CONVERT_LONGVARCHAR:
    1306           1 :                 return "SQL_CONVERT_LONGVARCHAR";
    1307           1 :         case SQL_CONVERT_NUMERIC:
    1308           1 :                 return "SQL_CONVERT_NUMERIC";
    1309           1 :         case SQL_CONVERT_REAL:
    1310           1 :                 return "SQL_CONVERT_REAL";
    1311           1 :         case SQL_CONVERT_SMALLINT:
    1312           1 :                 return "SQL_CONVERT_SMALLINT";
    1313           1 :         case SQL_CONVERT_TIME:
    1314           1 :                 return "SQL_CONVERT_TIME";
    1315           1 :         case SQL_CONVERT_TIMESTAMP:
    1316           1 :                 return "SQL_CONVERT_TIMESTAMP";
    1317           1 :         case SQL_CONVERT_TINYINT:
    1318           1 :                 return "SQL_CONVERT_TINYINT";
    1319           1 :         case SQL_CONVERT_VARBINARY:
    1320           1 :                 return "SQL_CONVERT_VARBINARY";
    1321           1 :         case SQL_CONVERT_VARCHAR:
    1322           1 :                 return "SQL_CONVERT_VARCHAR";
    1323           1 :         case SQL_CORRELATION_NAME:
    1324           1 :                 return "SQL_CORRELATION_NAME";
    1325           1 :         case SQL_CREATE_ASSERTION:
    1326           1 :                 return "SQL_CREATE_ASSERTION";
    1327           1 :         case SQL_CREATE_CHARACTER_SET:
    1328           1 :                 return "SQL_CREATE_CHARACTER_SET";
    1329           1 :         case SQL_CREATE_COLLATION:
    1330           1 :                 return "SQL_CREATE_COLLATION";
    1331           1 :         case SQL_CREATE_DOMAIN:
    1332           1 :                 return "SQL_CREATE_DOMAIN";
    1333           1 :         case SQL_CREATE_SCHEMA:
    1334           1 :                 return "SQL_CREATE_SCHEMA";
    1335           1 :         case SQL_CREATE_TABLE:
    1336           1 :                 return "SQL_CREATE_TABLE";
    1337           1 :         case SQL_CREATE_TRANSLATION:
    1338           1 :                 return "SQL_CREATE_TRANSLATION";
    1339           1 :         case SQL_CREATE_VIEW:
    1340           1 :                 return "SQL_CREATE_VIEW";
    1341           3 :         case SQL_CURSOR_COMMIT_BEHAVIOR:
    1342           3 :                 return "SQL_CURSOR_COMMIT_BEHAVIOR";
    1343           3 :         case SQL_CURSOR_ROLLBACK_BEHAVIOR:
    1344           3 :                 return "SQL_CURSOR_ROLLBACK_BEHAVIOR";
    1345           1 :         case SQL_CURSOR_SENSITIVITY:
    1346           1 :                 return "SQL_CURSOR_SENSITIVITY";
    1347           1 :         case SQL_DATABASE_NAME:
    1348           1 :                 return "SQL_DATABASE_NAME";
    1349           0 :         case SQL_DATA_SOURCE_NAME:
    1350           0 :                 return "SQL_DATA_SOURCE_NAME";
    1351           1 :         case SQL_DATA_SOURCE_READ_ONLY:
    1352           1 :                 return "SQL_DATA_SOURCE_READ_ONLY";
    1353           1 :         case SQL_DATETIME_LITERALS:
    1354           1 :                 return "SQL_DATETIME_LITERALS";
    1355           1 :         case SQL_DBMS_NAME:
    1356           1 :                 return "SQL_DBMS_NAME";
    1357           1 :         case SQL_DBMS_VER:
    1358           1 :                 return "SQL_DBMS_VER";
    1359           1 :         case SQL_DDL_INDEX:
    1360           1 :                 return "SQL_DDL_INDEX";
    1361           1 :         case SQL_DEFAULT_TXN_ISOLATION:
    1362           1 :                 return "SQL_DEFAULT_TXN_ISOLATION";
    1363           2 :         case SQL_DESCRIBE_PARAMETER:
    1364           2 :                 return "SQL_DESCRIBE_PARAMETER";
    1365           0 :         case SQL_DM_VER:
    1366           0 :                 return "SQL_DM_VER";
    1367             : #ifdef SQL_DRIVER_AWARE_POOLING_SUPPORTED
    1368           1 :         case SQL_DRIVER_AWARE_POOLING_SUPPORTED:
    1369           1 :                 return "SQL_DRIVER_AWARE_POOLING_SUPPORTED";
    1370             : #endif
    1371           0 :         case SQL_DRIVER_HDBC:
    1372           0 :                 return "SQL_DRIVER_HDBC";
    1373           0 :         case SQL_DRIVER_HDESC:
    1374           0 :                 return "SQL_DRIVER_HDESC";
    1375           0 :         case SQL_DRIVER_HENV:
    1376           0 :                 return "SQL_DRIVER_HENV";
    1377           0 :         case SQL_DRIVER_HLIB:
    1378           0 :                 return "SQL_DRIVER_HLIB";
    1379           0 :         case SQL_DRIVER_HSTMT:
    1380           0 :                 return "SQL_DRIVER_HSTMT";
    1381           1 :         case SQL_DRIVER_NAME:
    1382           1 :                 return "SQL_DRIVER_NAME";
    1383           2 :         case SQL_DRIVER_ODBC_VER:
    1384           2 :                 return "SQL_DRIVER_ODBC_VER";
    1385           1 :         case SQL_DRIVER_VER:
    1386           1 :                 return "SQL_DRIVER_VER";
    1387           1 :         case SQL_DROP_ASSERTION:
    1388           1 :                 return "SQL_DROP_ASSERTION";
    1389           1 :         case SQL_DROP_CHARACTER_SET:
    1390           1 :                 return "SQL_DROP_CHARACTER_SET";
    1391           1 :         case SQL_DROP_COLLATION:
    1392           1 :                 return "SQL_DROP_COLLATION";
    1393           1 :         case SQL_DROP_DOMAIN:
    1394           1 :                 return "SQL_DROP_DOMAIN";
    1395           1 :         case SQL_DROP_SCHEMA:
    1396           1 :                 return "SQL_DROP_SCHEMA";
    1397           1 :         case SQL_DROP_TABLE:
    1398           1 :                 return "SQL_DROP_TABLE";
    1399           1 :         case SQL_DROP_TRANSLATION:
    1400           1 :                 return "SQL_DROP_TRANSLATION";
    1401           1 :         case SQL_DROP_VIEW:
    1402           1 :                 return "SQL_DROP_VIEW";
    1403           1 :         case SQL_DYNAMIC_CURSOR_ATTRIBUTES1:
    1404           1 :                 return "SQL_DYNAMIC_CURSOR_ATTRIBUTES1";
    1405           1 :         case SQL_DYNAMIC_CURSOR_ATTRIBUTES2:
    1406           1 :                 return "SQL_DYNAMIC_CURSOR_ATTRIBUTES2";
    1407           1 :         case SQL_EXPRESSIONS_IN_ORDERBY:
    1408           1 :                 return "SQL_EXPRESSIONS_IN_ORDERBY";
    1409           0 :         case SQL_FETCH_DIRECTION:
    1410           0 :                 return "SQL_FETCH_DIRECTION";
    1411           1 :         case SQL_FILE_USAGE:
    1412           1 :                 return "SQL_FILE_USAGE";
    1413           1 :         case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1:
    1414           1 :                 return "SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1";
    1415           1 :         case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2:
    1416           1 :                 return "SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2";
    1417           1 :         case SQL_GETDATA_EXTENSIONS:
    1418           1 :                 return "SQL_GETDATA_EXTENSIONS";
    1419           1 :         case SQL_GROUP_BY:
    1420           1 :                 return "SQL_GROUP_BY";
    1421           1 :         case SQL_IDENTIFIER_CASE:
    1422           1 :                 return "SQL_IDENTIFIER_CASE";
    1423           1 :         case SQL_IDENTIFIER_QUOTE_CHAR:
    1424           1 :                 return "SQL_IDENTIFIER_QUOTE_CHAR";
    1425           1 :         case SQL_INDEX_KEYWORDS:
    1426           1 :                 return "SQL_INDEX_KEYWORDS";
    1427           1 :         case SQL_INFO_SCHEMA_VIEWS:
    1428           1 :                 return "SQL_INFO_SCHEMA_VIEWS";
    1429           1 :         case SQL_INSERT_STATEMENT:
    1430           1 :                 return "SQL_INSERT_STATEMENT";
    1431           1 :         case SQL_INTEGRITY:
    1432           1 :                 return "SQL_INTEGRITY";
    1433           1 :         case SQL_KEYSET_CURSOR_ATTRIBUTES1:
    1434           1 :                 return "SQL_KEYSET_CURSOR_ATTRIBUTES1";
    1435           1 :         case SQL_KEYSET_CURSOR_ATTRIBUTES2:
    1436           1 :                 return "SQL_KEYSET_CURSOR_ATTRIBUTES2";
    1437           1 :         case SQL_KEYWORDS:
    1438           1 :                 return "SQL_KEYWORDS";
    1439           1 :         case SQL_LIKE_ESCAPE_CLAUSE:
    1440           1 :                 return "SQL_LIKE_ESCAPE_CLAUSE";
    1441           0 :         case SQL_LOCK_TYPES:
    1442           0 :                 return "SQL_LOCK_TYPES";
    1443           1 :         case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS:
    1444           1 :                 return "SQL_MAX_ASYNC_CONCURRENT_STATEMENTS";
    1445           1 :         case SQL_MAX_BINARY_LITERAL_LEN:
    1446           1 :                 return "SQL_MAX_BINARY_LITERAL_LEN";
    1447           1 :         case SQL_MAX_CATALOG_NAME_LEN:
    1448           1 :                 return "SQL_MAX_CATALOG_NAME_LEN";
    1449           1 :         case SQL_MAX_CHAR_LITERAL_LEN:
    1450           1 :                 return "SQL_MAX_CHAR_LITERAL_LEN";
    1451           1 :         case SQL_MAX_COLUMN_NAME_LEN:
    1452           1 :                 return "SQL_MAX_COLUMN_NAME_LEN";
    1453           1 :         case SQL_MAX_COLUMNS_IN_GROUP_BY:
    1454           1 :                 return "SQL_MAX_COLUMNS_IN_GROUP_BY";
    1455           1 :         case SQL_MAX_COLUMNS_IN_INDEX:
    1456           1 :                 return "SQL_MAX_COLUMNS_IN_INDEX";
    1457           1 :         case SQL_MAX_COLUMNS_IN_ORDER_BY:
    1458           1 :                 return "SQL_MAX_COLUMNS_IN_ORDER_BY";
    1459           1 :         case SQL_MAX_COLUMNS_IN_SELECT:
    1460           1 :                 return "SQL_MAX_COLUMNS_IN_SELECT";
    1461           1 :         case SQL_MAX_COLUMNS_IN_TABLE:
    1462           1 :                 return "SQL_MAX_COLUMNS_IN_TABLE";
    1463           0 :         case SQL_MAX_CONCURRENT_ACTIVITIES:
    1464           0 :                 return "SQL_MAX_CONCURRENT_ACTIVITIES";
    1465           1 :         case SQL_MAX_CURSOR_NAME_LEN:
    1466           1 :                 return "SQL_MAX_CURSOR_NAME_LEN";
    1467           1 :         case SQL_MAX_DRIVER_CONNECTIONS:
    1468           1 :                 return "SQL_MAX_DRIVER_CONNECTIONS";
    1469           1 :         case SQL_MAX_IDENTIFIER_LEN:
    1470           1 :                 return "SQL_MAX_IDENTIFIER_LEN";
    1471           1 :         case SQL_MAX_INDEX_SIZE:
    1472           1 :                 return "SQL_MAX_INDEX_SIZE";
    1473           1 :         case SQL_MAX_PROCEDURE_NAME_LEN:
    1474           1 :                 return "SQL_MAX_PROCEDURE_NAME_LEN";
    1475           1 :         case SQL_MAX_ROW_SIZE:
    1476           1 :                 return "SQL_MAX_ROW_SIZE";
    1477           1 :         case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
    1478           1 :                 return "SQL_MAX_ROW_SIZE_INCLUDES_LONG";
    1479           1 :         case SQL_MAX_SCHEMA_NAME_LEN:
    1480           1 :                 return "SQL_MAX_SCHEMA_NAME_LEN";
    1481           1 :         case SQL_MAX_STATEMENT_LEN:
    1482           1 :                 return "SQL_MAX_STATEMENT_LEN";
    1483           1 :         case SQL_MAX_TABLE_NAME_LEN:
    1484           1 :                 return "SQL_MAX_TABLE_NAME_LEN";
    1485           1 :         case SQL_MAX_TABLES_IN_SELECT:
    1486           1 :                 return "SQL_MAX_TABLES_IN_SELECT";
    1487           1 :         case SQL_MAX_USER_NAME_LEN:
    1488           1 :                 return "SQL_MAX_USER_NAME_LEN";
    1489           1 :         case SQL_MULTIPLE_ACTIVE_TXN:
    1490           1 :                 return "SQL_MULTIPLE_ACTIVE_TXN";
    1491           1 :         case SQL_MULT_RESULT_SETS:
    1492           1 :                 return "SQL_MULT_RESULT_SETS";
    1493           2 :         case SQL_NEED_LONG_DATA_LEN:
    1494           2 :                 return "SQL_NEED_LONG_DATA_LEN";
    1495           1 :         case SQL_NON_NULLABLE_COLUMNS:
    1496           1 :                 return "SQL_NON_NULLABLE_COLUMNS";
    1497           1 :         case SQL_NULL_COLLATION:
    1498           1 :                 return "SQL_NULL_COLLATION";
    1499           1 :         case SQL_NUMERIC_FUNCTIONS:
    1500           1 :                 return "SQL_NUMERIC_FUNCTIONS";
    1501           0 :         case SQL_ODBC_API_CONFORMANCE:
    1502           0 :                 return "SQL_ODBC_API_CONFORMANCE";
    1503           1 :         case SQL_ODBC_INTERFACE_CONFORMANCE:
    1504           1 :                 return "SQL_ODBC_INTERFACE_CONFORMANCE";
    1505           0 :         case SQL_ODBC_SAG_CLI_CONFORMANCE:
    1506           0 :                 return "SQL_ODBC_SAG_CLI_CONFORMANCE";
    1507           0 :         case SQL_ODBC_SQL_CONFORMANCE:
    1508           0 :                 return "SQL_ODBC_SQL_CONFORMANCE";
    1509             : #ifdef SQL_ODBC_STANDARD_CLI_CONFORMANCE
    1510             :         case SQL_ODBC_STANDARD_CLI_CONFORMANCE:
    1511             :                 return "SQL_ODBC_STANDARD_CLI_CONFORMANCE";
    1512             : #endif
    1513           0 :         case SQL_ODBC_VER:
    1514           0 :                 return "SQL_ODBC_VER";
    1515           1 :         case SQL_OJ_CAPABILITIES:
    1516           1 :                 return "SQL_OJ_CAPABILITIES";
    1517           1 :         case SQL_ORDER_BY_COLUMNS_IN_SELECT:
    1518           1 :                 return "SQL_ORDER_BY_COLUMNS_IN_SELECT";
    1519           0 :         case SQL_OUTER_JOINS:
    1520           0 :                 return "SQL_OUTER_JOINS";
    1521           1 :         case SQL_PARAM_ARRAY_ROW_COUNTS:
    1522           1 :                 return "SQL_PARAM_ARRAY_ROW_COUNTS";
    1523           0 :         case SQL_PARAM_ARRAY_SELECTS:
    1524           0 :                 return "SQL_PARAM_ARRAY_SELECTS";
    1525           0 :         case SQL_POSITIONED_STATEMENTS:
    1526           0 :                 return "SQL_POSITIONED_STATEMENTS";
    1527           1 :         case SQL_POS_OPERATIONS:
    1528           1 :                 return "SQL_POS_OPERATIONS";
    1529           1 :         case SQL_PROCEDURES:
    1530           1 :                 return "SQL_PROCEDURES";
    1531           1 :         case SQL_PROCEDURE_TERM:
    1532           1 :                 return "SQL_PROCEDURE_TERM";
    1533           1 :         case SQL_QUOTED_IDENTIFIER_CASE:
    1534           1 :                 return "SQL_QUOTED_IDENTIFIER_CASE";
    1535           1 :         case SQL_ROW_UPDATES:
    1536           1 :                 return "SQL_ROW_UPDATES";
    1537           1 :         case SQL_SCHEMA_TERM:
    1538           1 :                 return "SQL_SCHEMA_TERM";
    1539           1 :         case SQL_SCHEMA_USAGE:
    1540           1 :                 return "SQL_SCHEMA_USAGE";
    1541           0 :         case SQL_SCROLL_CONCURRENCY:
    1542           0 :                 return "SQL_SCROLL_CONCURRENCY";
    1543           1 :         case SQL_SCROLL_OPTIONS:
    1544           1 :                 return "SQL_SCROLL_OPTIONS";
    1545           1 :         case SQL_SEARCH_PATTERN_ESCAPE:
    1546           1 :                 return "SQL_SEARCH_PATTERN_ESCAPE";
    1547           1 :         case SQL_SERVER_NAME:
    1548           1 :                 return "SQL_SERVER_NAME";
    1549           1 :         case SQL_SPECIAL_CHARACTERS:
    1550           1 :                 return "SQL_SPECIAL_CHARACTERS";
    1551           1 :         case SQL_SQL92_DATETIME_FUNCTIONS:
    1552           1 :                 return "SQL_SQL92_DATETIME_FUNCTIONS";
    1553           1 :         case SQL_SQL92_FOREIGN_KEY_DELETE_RULE:
    1554           1 :                 return "SQL_SQL92_FOREIGN_KEY_DELETE_RULE";
    1555           1 :         case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE:
    1556           1 :                 return "SQL_SQL92_FOREIGN_KEY_UPDATE_RULE";
    1557           1 :         case SQL_SQL92_GRANT:
    1558           1 :                 return "SQL_SQL92_GRANT";
    1559           1 :         case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS:
    1560           1 :                 return "SQL_SQL92_NUMERIC_VALUE_FUNCTIONS";
    1561           1 :         case SQL_SQL92_PREDICATES:
    1562           1 :                 return "SQL_SQL92_PREDICATES";
    1563           1 :         case SQL_SQL92_RELATIONAL_JOIN_OPERATORS:
    1564           1 :                 return "SQL_SQL92_RELATIONAL_JOIN_OPERATORS";
    1565           1 :         case SQL_SQL92_REVOKE:
    1566           1 :                 return "SQL_SQL92_REVOKE";
    1567           1 :         case SQL_SQL92_ROW_VALUE_CONSTRUCTOR:
    1568           1 :                 return "SQL_SQL92_ROW_VALUE_CONSTRUCTOR";
    1569           1 :         case SQL_SQL92_STRING_FUNCTIONS:
    1570           1 :                 return "SQL_SQL92_STRING_FUNCTIONS";
    1571           1 :         case SQL_SQL92_VALUE_EXPRESSIONS:
    1572           1 :                 return "SQL_SQL92_VALUE_EXPRESSIONS";
    1573           1 :         case SQL_SQL_CONFORMANCE:
    1574           1 :                 return "SQL_SQL_CONFORMANCE";
    1575           1 :         case SQL_STANDARD_CLI_CONFORMANCE:
    1576           1 :                 return "SQL_STANDARD_CLI_CONFORMANCE";
    1577           1 :         case SQL_STATIC_CURSOR_ATTRIBUTES1:
    1578           1 :                 return "SQL_STATIC_CURSOR_ATTRIBUTES1";
    1579           1 :         case SQL_STATIC_CURSOR_ATTRIBUTES2:
    1580           1 :                 return "SQL_STATIC_CURSOR_ATTRIBUTES2";
    1581           0 :         case SQL_STATIC_SENSITIVITY:
    1582           0 :                 return "SQL_STATIC_SENSITIVITY";
    1583           1 :         case SQL_STRING_FUNCTIONS:
    1584           1 :                 return "SQL_STRING_FUNCTIONS";
    1585           1 :         case SQL_SUBQUERIES:
    1586           1 :                 return "SQL_SUBQUERIES";
    1587           1 :         case SQL_SYSTEM_FUNCTIONS:
    1588           1 :                 return "SQL_SYSTEM_FUNCTIONS";
    1589           1 :         case SQL_TABLE_TERM:
    1590           1 :                 return "SQL_TABLE_TERM";
    1591           1 :         case SQL_TIMEDATE_ADD_INTERVALS:
    1592           1 :                 return "SQL_TIMEDATE_ADD_INTERVALS";
    1593           1 :         case SQL_TIMEDATE_DIFF_INTERVALS:
    1594           1 :                 return "SQL_TIMEDATE_DIFF_INTERVALS";
    1595           1 :         case SQL_TIMEDATE_FUNCTIONS:
    1596           1 :                 return "SQL_TIMEDATE_FUNCTIONS";
    1597           1 :         case SQL_TXN_CAPABLE:
    1598           1 :                 return "SQL_TXN_CAPABLE";
    1599           1 :         case SQL_TXN_ISOLATION_OPTION:
    1600           1 :                 return "SQL_TXN_ISOLATION_OPTION";
    1601           1 :         case SQL_UNION:
    1602           1 :                 return "SQL_UNION";
    1603           1 :         case SQL_USER_NAME:
    1604           1 :                 return "SQL_USER_NAME";
    1605           0 :         case SQL_XOPEN_CLI_YEAR:
    1606           0 :                 return "SQL_XOPEN_CLI_YEAR";
    1607           0 :         default:
    1608           0 :                 snprintf(unknown, sizeof(unknown), "unknown (%u)",
    1609             :                          (unsigned int) InfoType);
    1610           0 :                 return unknown;
    1611             :         }
    1612             : }
    1613             : #endif
    1614             : 
    1615             : SQLRETURN SQL_API
    1616             : SQLGetInfo(SQLHDBC ConnectionHandle,
    1617             :            SQLUSMALLINT InfoType,
    1618             :            SQLPOINTER InfoValuePtr,
    1619             :            SQLSMALLINT BufferLength,
    1620             :            SQLSMALLINT *StringLengthPtr)
    1621             : {
    1622         160 :         ODBCDbc *dbc = (ODBCDbc *) ConnectionHandle;
    1623             : 
    1624             : #ifdef ODBCDEBUG
    1625         160 :         ODBCLOG("SQLGetInfo %p %s %p %d %p\n",
    1626             :                 ConnectionHandle, translateInfoType(InfoType),
    1627             :                 InfoValuePtr, (int) BufferLength,
    1628             :                 StringLengthPtr);
    1629             : #endif
    1630             : 
    1631         160 :         if (!isValidDbc(dbc))
    1632             :                 return SQL_INVALID_HANDLE;
    1633             : 
    1634         160 :         clearDbcErrors(dbc);
    1635             : 
    1636         160 :         return MNDBGetInfo(dbc,
    1637             :                            InfoType,
    1638             :                            InfoValuePtr,
    1639             :                            BufferLength,
    1640             :                            StringLengthPtr);
    1641             : }
    1642             : 
    1643             : SQLRETURN SQL_API
    1644             : SQLGetInfoA(SQLHDBC ConnectionHandle,
    1645             :             SQLUSMALLINT InfoType,
    1646             :             SQLPOINTER InfoValuePtr,
    1647             :             SQLSMALLINT BufferLength,
    1648             :             SQLSMALLINT *StringLengthPtr)
    1649             : {
    1650           0 :         return SQLGetInfo(ConnectionHandle,
    1651             :                           InfoType,
    1652             :                           InfoValuePtr,
    1653             :                           BufferLength,
    1654             :                           StringLengthPtr);
    1655             : }
    1656             : 
    1657             : SQLRETURN SQL_API
    1658             : SQLGetInfoW(SQLHDBC ConnectionHandle,
    1659             :             SQLUSMALLINT InfoType,
    1660             :             SQLPOINTER InfoValuePtr,
    1661             :             SQLSMALLINT BufferLength,
    1662             :             SQLSMALLINT *StringLengthPtr)
    1663             : {
    1664           5 :         ODBCDbc *dbc = (ODBCDbc *) ConnectionHandle;
    1665           5 :         SQLRETURN rc;
    1666           5 :         SQLPOINTER ptr;
    1667           5 :         SQLSMALLINT n;
    1668             : 
    1669             : #ifdef ODBCDEBUG
    1670           5 :         ODBCLOG("SQLGetInfoW %p %s %p %d %p\n",
    1671             :                 ConnectionHandle, translateInfoType(InfoType),
    1672             :                 InfoValuePtr, (int) BufferLength,
    1673             :                 StringLengthPtr);
    1674             : #endif
    1675             : 
    1676           5 :         if (!isValidDbc(dbc))
    1677             :                 return SQL_INVALID_HANDLE;
    1678             : 
    1679           5 :         clearDbcErrors(dbc);
    1680             : 
    1681           5 :         switch (InfoType) {
    1682             :         /* all string attributes */
    1683           3 :         case SQL_ACCESSIBLE_PROCEDURES:
    1684             :         case SQL_ACCESSIBLE_TABLES:
    1685             :         case SQL_CATALOG_NAME:
    1686             :         case SQL_CATALOG_NAME_SEPARATOR:
    1687             :         case SQL_CATALOG_TERM:
    1688             :         case SQL_COLLATION_SEQ:
    1689             :         case SQL_COLUMN_ALIAS:
    1690             :         case SQL_DATABASE_NAME:
    1691             :         case SQL_DATA_SOURCE_NAME:
    1692             :         case SQL_DATA_SOURCE_READ_ONLY:
    1693             :         case SQL_DBMS_NAME:
    1694             :         case SQL_DBMS_VER:
    1695             :         case SQL_DESCRIBE_PARAMETER:
    1696             :         case SQL_DM_VER:
    1697             :         case SQL_DRIVER_NAME:
    1698             :         case SQL_DRIVER_ODBC_VER:
    1699             :         case SQL_DRIVER_VER:
    1700             :         case SQL_EXPRESSIONS_IN_ORDERBY:
    1701             :         case SQL_IDENTIFIER_QUOTE_CHAR:
    1702             :         case SQL_INTEGRITY:
    1703             :         case SQL_KEYWORDS:
    1704             :         case SQL_LIKE_ESCAPE_CLAUSE:
    1705             :         case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
    1706             :         case SQL_MULTIPLE_ACTIVE_TXN:
    1707             :         case SQL_MULT_RESULT_SETS:
    1708             :         case SQL_NEED_LONG_DATA_LEN:
    1709             :         case SQL_ODBC_VER:
    1710             :         case SQL_ORDER_BY_COLUMNS_IN_SELECT:
    1711             :         case SQL_OUTER_JOINS:
    1712             :         case SQL_PROCEDURES:
    1713             :         case SQL_PROCEDURE_TERM:
    1714             :         case SQL_ROW_UPDATES:
    1715             :         case SQL_SCHEMA_TERM:
    1716             :         case SQL_SEARCH_PATTERN_ESCAPE:
    1717             :         case SQL_SERVER_NAME:
    1718             :         case SQL_SPECIAL_CHARACTERS:
    1719             :         case SQL_TABLE_TERM:
    1720             :         case SQL_USER_NAME:
    1721             :         case SQL_XOPEN_CLI_YEAR:
    1722           3 :                 ptr = malloc(BufferLength);
    1723           3 :                 if (ptr == NULL) {
    1724             :                         /* Memory allocation error */
    1725           0 :                         addDbcError(dbc, "HY001", NULL, 0);
    1726           0 :                         return SQL_ERROR;
    1727             :                 }
    1728             :                 break;
    1729             :         default:
    1730             :                 ptr = InfoValuePtr;
    1731             :                 break;
    1732             :         }
    1733             : 
    1734           5 :         rc = MNDBGetInfo(dbc, InfoType, ptr, BufferLength, &n);
    1735             : 
    1736           5 :         if (ptr != InfoValuePtr) {
    1737           3 :                 if (rc == SQL_SUCCESS_WITH_INFO) {
    1738           0 :                         clearDbcErrors(dbc);
    1739           0 :                         free(ptr);
    1740           0 :                         ptr = malloc(++n); /* add one for NULL byte */
    1741           0 :                         if (ptr == NULL) {
    1742             :                                 /* Memory allocation error */
    1743           0 :                                 addDbcError(dbc, "HY001", NULL, 0);
    1744           0 :                                 return SQL_ERROR;
    1745             :                         }
    1746           0 :                         rc = MNDBGetInfo(dbc, InfoType, ptr, n, &n);
    1747             :                 }
    1748           3 :                 if (SQL_SUCCEEDED(rc)) {
    1749           3 :                         fixWcharOut(rc, ptr, n, InfoValuePtr, BufferLength,
    1750             :                                     StringLengthPtr, 2, addDbcError, dbc);
    1751             :                 }
    1752           3 :                 free(ptr);
    1753           2 :         } else if (StringLengthPtr)
    1754           2 :                 *StringLengthPtr = n;
    1755             : 
    1756             :         return rc;
    1757             : }

Generated by: LCOV version 1.14