LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLGetTypeInfo.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 190 0.0 %
Date: 2021-10-13 02:24:04 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       5             :  *
       6             :  * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V.
       7             :  */
       8             : 
       9             : /*
      10             :  * This code was created by Peter Harvey (mostly during Christmas 98/99).
      11             :  * This code is LGPL. Please ensure that this message remains in future
      12             :  * distributions and uses of this code (thats about all I get out of it).
      13             :  * - Peter Harvey pharvey@codebydesign.com
      14             :  *
      15             :  * This file has been modified for the MonetDB project.  See the file
      16             :  * Copyright in this directory for more information.
      17             :  */
      18             : 
      19             : /**********************************************************************
      20             :  * SQLGetTypeInfo()
      21             :  * CLI Compliance: ISO 92
      22             :  *
      23             :  * Author: Martin van Dinther, Sjoerd Mullender
      24             :  * Date  : 30 aug 2002
      25             :  *
      26             :  **********************************************************************/
      27             : 
      28             : #include "ODBCGlobal.h"
      29             : #include "ODBCStmt.h"
      30             : #include <float.h>
      31             : 
      32             : 
      33             : static const struct types {
      34             :         const char *type_name;
      35             :         const int data_type;    /* concise type */
      36             :         const int column_size;
      37             :         const char *literal_prefix;
      38             :         const char *literal_suffix;
      39             :         const char *create_params;
      40             :         const int nullable;     /* NO_NULLS, NULLABLE, NULLABLE_UNKNOWN */
      41             :         const int case_sensitive;       /* SQL_FALSE, SQL_TRUE */
      42             :         const int searchable;   /* PRED_NONE, PRED_CHAR, PRED_BASIC, SEARCHABLE */
      43             :         const int unsigned_attribute;   /* SQL_FALSE, SQL_TRUE, NULL */
      44             :         const int fixed_prec_scale;     /* SQL_FALSE, SQL_TRUE */
      45             :         const int auto_unique_value;    /* SQL_FALSE, SQL_TRUE, NULL */
      46             :         const char *local_type_name;    /* localized version of type_name */
      47             :         const int minimum_scale;
      48             :         const int maximum_scale;
      49             :         const int sql_data_type;
      50             :         const int sql_datetime_sub;
      51             :         const int num_prec_radix;
      52             :         const int interval_precision;
      53             : } types[] = {
      54             :         /* This table is sorted on the value of data_type and then on
      55             :          * how "close" the type maps to the corresponding ODBC SQL
      56             :          * type (i.e. in the order SQLGetTypeInfo wants it).
      57             :          * Except for the type_name value, the string values are ready
      58             :          * to paste into an SQL query (i.e. including quotes). */
      59             :         {
      60             :                 .type_name = "uuid",
      61             :                 .data_type = SQL_GUID,  /* -11 */
      62             :                 .column_size = 36,
      63             :                 .literal_prefix = "'uuid '''",
      64             :                 .literal_suffix = "''''",
      65             :                 .create_params = "NULL",
      66             :                 .nullable = SQL_NULLABLE,
      67             :                 .case_sensitive = SQL_FALSE,
      68             :                 .searchable = SQL_PRED_BASIC,
      69             :                 .unsigned_attribute = -1,
      70             :                 .fixed_prec_scale = SQL_FALSE,
      71             :                 .auto_unique_value = -1,
      72             :                 .local_type_name = "'uuid'",
      73             :                 .minimum_scale = -1,
      74             :                 .maximum_scale = -1,
      75             :                 .sql_data_type = SQL_GUID,
      76             :                 .sql_datetime_sub = -1,
      77             :                 .num_prec_radix = -1,
      78             :                 .interval_precision = -1,
      79             :         },
      80             :         {
      81             :                 .type_name = "character large object",
      82             :                 .data_type = SQL_WLONGVARCHAR,  /* -10 */
      83             :                 .column_size = 1000000,
      84             :                 .literal_prefix = "''''",
      85             :                 .literal_suffix = "''''",
      86             :                 .create_params = "NULL",
      87             :                 .nullable = SQL_NULLABLE,
      88             :                 .case_sensitive = SQL_TRUE,
      89             :                 .searchable = SQL_SEARCHABLE,
      90             :                 .unsigned_attribute = -1,
      91             :                 .fixed_prec_scale = SQL_FALSE,
      92             :                 .auto_unique_value = SQL_FALSE,
      93             :                 .local_type_name = "NULL",
      94             :                 .minimum_scale = -1,
      95             :                 .maximum_scale = -1,
      96             :                 .sql_data_type = SQL_WLONGVARCHAR,
      97             :                 .sql_datetime_sub = -1,
      98             :                 .num_prec_radix = -1,
      99             :                 .interval_precision = -1,
     100             :         },
     101             :         {
     102             :                 .type_name = "json",
     103             :                 .data_type = SQL_WLONGVARCHAR,  /* -10 */
     104             :                 .column_size = 1000000,
     105             :                 .literal_prefix = "'json '''",
     106             :                 .literal_suffix = "''''",
     107             :                 .create_params = "NULL",
     108             :                 .nullable = SQL_NULLABLE,
     109             :                 .case_sensitive = SQL_TRUE,
     110             :                 .searchable = SQL_SEARCHABLE,
     111             :                 .unsigned_attribute = -1,
     112             :                 .fixed_prec_scale = SQL_FALSE,
     113             :                 .auto_unique_value = SQL_FALSE,
     114             :                 .local_type_name = "'json'",
     115             :                 .minimum_scale = -1,
     116             :                 .maximum_scale = -1,
     117             :                 .sql_data_type = SQL_WLONGVARCHAR,
     118             :                 .sql_datetime_sub = -1,
     119             :                 .num_prec_radix = -1,
     120             :                 .interval_precision = -1,
     121             :         },
     122             :         {
     123             :                 .type_name = "url",
     124             :                 .data_type = SQL_WLONGVARCHAR,  /* -10 */
     125             :                 .column_size = 1000000,
     126             :                 .literal_prefix = "'url '''",
     127             :                 .literal_suffix = "''''",
     128             :                 .create_params = "NULL",
     129             :                 .nullable = SQL_NULLABLE,
     130             :                 .case_sensitive = SQL_TRUE,
     131             :                 .searchable = SQL_SEARCHABLE,
     132             :                 .unsigned_attribute = -1,
     133             :                 .fixed_prec_scale = SQL_FALSE,
     134             :                 .auto_unique_value = SQL_FALSE,
     135             :                 .local_type_name = "'url'",
     136             :                 .minimum_scale = -1,
     137             :                 .maximum_scale = -1,
     138             :                 .sql_data_type = SQL_WLONGVARCHAR,
     139             :                 .sql_datetime_sub = -1,
     140             :                 .num_prec_radix = -1,
     141             :                 .interval_precision = -1,
     142             :         },
     143             :         {
     144             :                 .type_name = "varchar",
     145             :                 .data_type = SQL_WVARCHAR,      /* -9 */
     146             :                 .column_size = 1000000,
     147             :                 .literal_prefix = "''''",
     148             :                 .literal_suffix = "''''",
     149             :                 .create_params = "'length'",
     150             :                 .nullable = SQL_NULLABLE,
     151             :                 .case_sensitive = SQL_TRUE,
     152             :                 .searchable = SQL_SEARCHABLE,
     153             :                 .unsigned_attribute = -1,
     154             :                 .fixed_prec_scale = SQL_FALSE,
     155             :                 .auto_unique_value = -1,
     156             :                 .local_type_name = "NULL",
     157             :                 .minimum_scale = -1,
     158             :                 .maximum_scale = -1,
     159             :                 .sql_data_type = SQL_WVARCHAR,
     160             :                 .sql_datetime_sub = -1,
     161             :                 .num_prec_radix = -1,
     162             :                 .interval_precision = -1,
     163             :         },
     164             :         {
     165             :                 .type_name = "character",
     166             :                 .data_type = SQL_WCHAR, /* -8 */
     167             :                 .column_size = 1000000,
     168             :                 .literal_prefix = "''''",
     169             :                 .literal_suffix = "''''",
     170             :                 .create_params = "'length'",
     171             :                 .nullable = SQL_NULLABLE,
     172             :                 .case_sensitive = SQL_TRUE,
     173             :                 .searchable = SQL_SEARCHABLE,
     174             :                 .unsigned_attribute = -1,
     175             :                 .fixed_prec_scale = SQL_FALSE,
     176             :                 .auto_unique_value = SQL_FALSE,
     177             :                 .local_type_name = "NULL",
     178             :                 .minimum_scale = -1,
     179             :                 .maximum_scale = -1,
     180             :                 .sql_data_type = SQL_WCHAR,
     181             :                 .sql_datetime_sub = -1,
     182             :                 .num_prec_radix = -1,
     183             :                 .interval_precision = -1,
     184             :         },
     185             :         {
     186             :                 .type_name = "char",
     187             :                 .data_type = SQL_WCHAR, /* -8 */
     188             :                 .column_size = 1000000,
     189             :                 .literal_prefix = "''''",
     190             :                 .literal_suffix = "''''",
     191             :                 .create_params = "'length'",
     192             :                 .nullable = SQL_NULLABLE,
     193             :                 .case_sensitive = SQL_TRUE,
     194             :                 .searchable = SQL_SEARCHABLE,
     195             :                 .unsigned_attribute = -1,
     196             :                 .fixed_prec_scale = SQL_FALSE,
     197             :                 .auto_unique_value = SQL_FALSE,
     198             :                 .local_type_name = "NULL",
     199             :                 .minimum_scale = -1,
     200             :                 .maximum_scale = -1,
     201             :                 .sql_data_type = SQL_WCHAR,
     202             :                 .sql_datetime_sub = -1,
     203             :                 .num_prec_radix = -1,
     204             :                 .interval_precision = -1,
     205             :         },
     206             :         {
     207             :                 .type_name = "boolean",
     208             :                 .data_type = SQL_BIT,   /* -7 */
     209             :                 .column_size = 1,
     210             :                 .literal_prefix = "NULL",
     211             :                 .literal_suffix = "NULL",
     212             :                 .create_params = "NULL",
     213             :                 .nullable = SQL_NULLABLE,
     214             :                 .case_sensitive = SQL_FALSE,
     215             :                 .searchable = SQL_PRED_BASIC,
     216             :                 .unsigned_attribute = SQL_TRUE,
     217             :                 .fixed_prec_scale = SQL_TRUE,
     218             :                 .auto_unique_value = SQL_FALSE,
     219             :                 .local_type_name = "'boolean'",
     220             :                 .minimum_scale = -1,
     221             :                 .maximum_scale = -1,
     222             :                 .sql_data_type = SQL_BIT,
     223             :                 .sql_datetime_sub = -1,
     224             :                 .num_prec_radix = -1,
     225             :                 .interval_precision = -1,
     226             :         },
     227             :         {
     228             :                 .type_name = "tinyint",
     229             :                 .data_type = SQL_TINYINT,       /* -6 */
     230             :                 .column_size = 3,
     231             :                 .literal_prefix = "NULL",
     232             :                 .literal_suffix = "NULL",
     233             :                 .create_params = "NULL",
     234             :                 .nullable = SQL_NULLABLE,
     235             :                 .case_sensitive = SQL_FALSE,
     236             :                 .searchable = SQL_PRED_BASIC,
     237             :                 .unsigned_attribute = SQL_FALSE,
     238             :                 .fixed_prec_scale = SQL_FALSE,
     239             :                 .auto_unique_value = SQL_FALSE,
     240             :                 .local_type_name = "NULL",
     241             :                 .minimum_scale = 0,
     242             :                 .maximum_scale = 0,
     243             :                 .sql_data_type = SQL_TINYINT,
     244             :                 .sql_datetime_sub = -1,
     245             :                 .num_prec_radix = 10,
     246             :                 .interval_precision = -1,
     247             :         },
     248             :         {
     249             :                 .type_name = "bigint",
     250             :                 .data_type = SQL_BIGINT,        /* -5 */
     251             :                 .column_size = 19,
     252             :                 .literal_prefix = "NULL",
     253             :                 .literal_suffix = "NULL",
     254             :                 .create_params = "NULL",
     255             :                 .nullable = SQL_NULLABLE,
     256             :                 .case_sensitive = SQL_FALSE,
     257             :                 .searchable = SQL_PRED_BASIC,
     258             :                 .unsigned_attribute = SQL_FALSE,
     259             :                 .fixed_prec_scale = SQL_FALSE,
     260             :                 .auto_unique_value = SQL_FALSE,
     261             :                 .local_type_name = "NULL",
     262             :                 .minimum_scale = 0,
     263             :                 .maximum_scale = 0,
     264             :                 .sql_data_type = SQL_BIGINT,
     265             :                 .sql_datetime_sub = -1,
     266             :                 .num_prec_radix = 10,
     267             :                 .interval_precision = -1,
     268             :         },
     269             :         {
     270             :                 .type_name = "bigserial",
     271             :                 .data_type = SQL_BIGINT,        /* -5 */
     272             :                 .column_size = 19,
     273             :                 .literal_prefix = "NULL",
     274             :                 .literal_suffix = "NULL",
     275             :                 .create_params = "NULL",
     276             :                 .nullable = SQL_NO_NULLS,
     277             :                 .case_sensitive = SQL_FALSE,
     278             :                 .searchable = SQL_PRED_BASIC,
     279             :                 .unsigned_attribute = SQL_FALSE,
     280             :                 .fixed_prec_scale = SQL_FALSE,
     281             :                 .auto_unique_value = SQL_TRUE,
     282             :                 .local_type_name = "'bigserial'",
     283             :                 .minimum_scale = 0,
     284             :                 .maximum_scale = 0,
     285             :                 .sql_data_type = SQL_BIGINT,
     286             :                 .sql_datetime_sub = -1,
     287             :                 .num_prec_radix = 10,
     288             :                 .interval_precision = -1,
     289             :         },
     290             :         {
     291             :                 .type_name = "binary large object",
     292             :                 .data_type = SQL_LONGVARBINARY, /* -4 */
     293             :                 .column_size = 1000000,
     294             :                 .literal_prefix = "'x'''",
     295             :                 .literal_suffix = "''''",
     296             :                 .create_params = "NULL",
     297             :                 .nullable = SQL_NULLABLE,
     298             :                 .case_sensitive = SQL_TRUE,
     299             :                 .searchable = SQL_SEARCHABLE,
     300             :                 .unsigned_attribute = -1,
     301             :                 .fixed_prec_scale = SQL_FALSE,
     302             :                 .auto_unique_value = SQL_FALSE,
     303             :                 .local_type_name = "NULL",
     304             :                 .minimum_scale = -1,
     305             :                 .maximum_scale = -1,
     306             :                 .sql_data_type = SQL_LONGVARBINARY,
     307             :                 .sql_datetime_sub = -1,
     308             :                 .num_prec_radix = -1,
     309             :                 .interval_precision = -1,
     310             :         },
     311             :         {
     312             :                 .type_name = "binary large object",
     313             :                 .data_type = SQL_VARBINARY,     /* -3 */
     314             :                 .column_size = 1000000,
     315             :                 .literal_prefix = "'x'''",
     316             :                 .literal_suffix = "''''",
     317             :                 .create_params = "'length'",
     318             :                 .nullable = SQL_NULLABLE,
     319             :                 .case_sensitive = SQL_TRUE,
     320             :                 .searchable = SQL_SEARCHABLE,
     321             :                 .unsigned_attribute = -1,
     322             :                 .fixed_prec_scale = SQL_FALSE,
     323             :                 .auto_unique_value = SQL_FALSE,
     324             :                 .local_type_name = "'blob(max_length)'",
     325             :                 .minimum_scale = -1,
     326             :                 .maximum_scale = -1,
     327             :                 .sql_data_type = SQL_VARBINARY,
     328             :                 .sql_datetime_sub = -1,
     329             :                 .num_prec_radix = -1,
     330             :                 .interval_precision = -1,
     331             :         },
     332             :         /* SQL_BINARY   -2 */
     333             :         {
     334             :                 .type_name = "character large object",
     335             :                 .data_type = SQL_LONGVARCHAR,   /* -1 */
     336             :                 .column_size = 1000000,
     337             :                 .literal_prefix = "''''",
     338             :                 .literal_suffix = "''''",
     339             :                 .create_params = "NULL",
     340             :                 .nullable = SQL_NULLABLE,
     341             :                 .case_sensitive = SQL_TRUE,
     342             :                 .searchable = SQL_SEARCHABLE,
     343             :                 .unsigned_attribute = -1,
     344             :                 .fixed_prec_scale = SQL_FALSE,
     345             :                 .auto_unique_value = SQL_FALSE,
     346             :                 .local_type_name = "NULL",
     347             :                 .minimum_scale = -1,
     348             :                 .maximum_scale = -1,
     349             :                 .sql_data_type = SQL_LONGVARCHAR,
     350             :                 .sql_datetime_sub = -1,
     351             :                 .num_prec_radix = -1,
     352             :                 .interval_precision = -1,
     353             :         },
     354             :         {
     355             :                 .type_name = "char",
     356             :                 .data_type = SQL_CHAR,  /* 1 */
     357             :                 .column_size = 1000000,
     358             :                 .literal_prefix = "''''",
     359             :                 .literal_suffix = "''''",
     360             :                 .create_params = "'length'",
     361             :                 .nullable = SQL_NULLABLE,
     362             :                 .case_sensitive = SQL_TRUE,
     363             :                 .searchable = SQL_SEARCHABLE,
     364             :                 .unsigned_attribute = -1,
     365             :                 .fixed_prec_scale = SQL_FALSE,
     366             :                 .auto_unique_value = SQL_FALSE,
     367             :                 .local_type_name = "NULL",
     368             :                 .minimum_scale = -1,
     369             :                 .maximum_scale = -1,
     370             :                 .sql_data_type = SQL_CHAR,
     371             :                 .sql_datetime_sub = -1,
     372             :                 .num_prec_radix = -1,
     373             :                 .interval_precision = -1,
     374             :         },
     375             :         {
     376             :                 .type_name = "numeric",
     377             :                 .data_type = SQL_NUMERIC,       /* 2 */
     378             :                 .column_size = 19,
     379             :                 .literal_prefix = "NULL",
     380             :                 .literal_suffix = "NULL",
     381             :                 .create_params = "'precision,scale'",
     382             :                 .nullable = SQL_NULLABLE,
     383             :                 .case_sensitive = SQL_FALSE,
     384             :                 .searchable = SQL_PRED_BASIC,
     385             :                 .unsigned_attribute = SQL_FALSE,
     386             :                 .fixed_prec_scale = SQL_FALSE,
     387             :                 .auto_unique_value = SQL_FALSE,
     388             :                 .local_type_name = "NULL",
     389             :                 .minimum_scale = 0,
     390             :                 .maximum_scale = 18,
     391             :                 .sql_data_type = SQL_NUMERIC,
     392             :                 .sql_datetime_sub = -1,
     393             :                 .num_prec_radix = 10,
     394             :                 .interval_precision = -1,
     395             :         },
     396             :         {
     397             :                 .type_name = "decimal",
     398             :                 .data_type = SQL_DECIMAL,       /* 3 */
     399             :                 .column_size = 19,
     400             :                 .literal_prefix = "NULL",
     401             :                 .literal_suffix = "NULL",
     402             :                 .create_params = "'precision,scale'",
     403             :                 .nullable = SQL_NULLABLE,
     404             :                 .case_sensitive = SQL_FALSE,
     405             :                 .searchable = SQL_PRED_BASIC,
     406             :                 .unsigned_attribute = SQL_FALSE,
     407             :                 .fixed_prec_scale = SQL_FALSE,
     408             :                 .auto_unique_value = SQL_FALSE,
     409             :                 .local_type_name = "NULL",
     410             :                 .minimum_scale = 0,
     411             :                 .maximum_scale = 18,
     412             :                 .sql_data_type = SQL_DECIMAL,
     413             :                 .sql_datetime_sub = -1,
     414             :                 .num_prec_radix = 10,
     415             :                 .interval_precision = -1,
     416             :         },
     417             :         {
     418             :                 .type_name = "integer",
     419             :                 .data_type = SQL_INTEGER,       /* 4 */
     420             :                 .column_size = 10,
     421             :                 .literal_prefix = "NULL",
     422             :                 .literal_suffix = "NULL",
     423             :                 .create_params = "NULL",
     424             :                 .nullable = SQL_NULLABLE,
     425             :                 .case_sensitive = SQL_FALSE,
     426             :                 .searchable = SQL_PRED_BASIC,
     427             :                 .unsigned_attribute = SQL_FALSE,
     428             :                 .fixed_prec_scale = SQL_FALSE,
     429             :                 .auto_unique_value = SQL_FALSE,
     430             :                 .local_type_name = "NULL",
     431             :                 .minimum_scale = 0,
     432             :                 .maximum_scale = 0,
     433             :                 .sql_data_type = SQL_INTEGER,
     434             :                 .sql_datetime_sub = -1,
     435             :                 .num_prec_radix = 10,
     436             :                 .interval_precision = -1,
     437             :         },
     438             :         {
     439             :                 .type_name = "int",
     440             :                 .data_type = SQL_INTEGER,       /* 4 */
     441             :                 .column_size = 10,
     442             :                 .literal_prefix = "NULL",
     443             :                 .literal_suffix = "NULL",
     444             :                 .create_params = "NULL",
     445             :                 .nullable = SQL_NULLABLE,
     446             :                 .case_sensitive = SQL_FALSE,
     447             :                 .searchable = SQL_PRED_BASIC,
     448             :                 .unsigned_attribute = SQL_FALSE,
     449             :                 .fixed_prec_scale = SQL_FALSE,
     450             :                 .auto_unique_value = SQL_FALSE,
     451             :                 .local_type_name = "NULL",
     452             :                 .minimum_scale = 0,
     453             :                 .maximum_scale = 0,
     454             :                 .sql_data_type = SQL_INTEGER,
     455             :                 .sql_datetime_sub = -1,
     456             :                 .num_prec_radix = 10,
     457             :                 .interval_precision = -1,
     458             :         },
     459             :         {
     460             :                 .type_name = "mediumint",
     461             :                 .data_type = SQL_INTEGER,       /* 4 */
     462             :                 .column_size = 10,
     463             :                 .literal_prefix = "NULL",
     464             :                 .literal_suffix = "NULL",
     465             :                 .create_params = "NULL",
     466             :                 .nullable = SQL_NULLABLE,
     467             :                 .case_sensitive = SQL_FALSE,
     468             :                 .searchable = SQL_PRED_BASIC,
     469             :                 .unsigned_attribute = SQL_FALSE,
     470             :                 .fixed_prec_scale = SQL_FALSE,
     471             :                 .auto_unique_value = SQL_FALSE,
     472             :                 .local_type_name = "'int'",
     473             :                 .minimum_scale = 0,
     474             :                 .maximum_scale = 0,
     475             :                 .sql_data_type = SQL_INTEGER,
     476             :                 .sql_datetime_sub = -1,
     477             :                 .num_prec_radix = 10,
     478             :                 .interval_precision = -1,
     479             :         },
     480             :         {
     481             :                 .type_name = "serial",
     482             :                 .data_type = SQL_INTEGER,       /* 4 */
     483             :                 .column_size = 10,
     484             :                 .literal_prefix = "NULL",
     485             :                 .literal_suffix = "NULL",
     486             :                 .create_params = "NULL",
     487             :                 .nullable = SQL_NO_NULLS,
     488             :                 .case_sensitive = SQL_FALSE,
     489             :                 .searchable = SQL_PRED_BASIC,
     490             :                 .unsigned_attribute = SQL_FALSE,
     491             :                 .fixed_prec_scale = SQL_FALSE,
     492             :                 .auto_unique_value = SQL_TRUE,
     493             :                 .local_type_name = "'serial'",
     494             :                 .minimum_scale = 0,
     495             :                 .maximum_scale = 0,
     496             :                 .sql_data_type = SQL_INTEGER,
     497             :                 .sql_datetime_sub = -1,
     498             :                 .num_prec_radix = 10,
     499             :                 .interval_precision = -1,
     500             :         },
     501             :         {
     502             :                 .type_name = "smallint",
     503             :                 .data_type = SQL_SMALLINT,      /* 5 */
     504             :                 .column_size = 5,
     505             :                 .literal_prefix = "NULL",
     506             :                 .literal_suffix = "NULL",
     507             :                 .create_params = "NULL",
     508             :                 .nullable = SQL_NULLABLE,
     509             :                 .case_sensitive = SQL_FALSE,
     510             :                 .searchable = SQL_PRED_BASIC,
     511             :                 .unsigned_attribute = SQL_FALSE,
     512             :                 .fixed_prec_scale = SQL_FALSE,
     513             :                 .auto_unique_value = SQL_FALSE,
     514             :                 .local_type_name = "NULL",
     515             :                 .minimum_scale = 0,
     516             :                 .maximum_scale = 0,
     517             :                 .sql_data_type = SQL_SMALLINT,
     518             :                 .sql_datetime_sub = -1,
     519             :                 .num_prec_radix = 10,
     520             :                 .interval_precision = -1,
     521             :         },
     522             :         {
     523             :                 .type_name = "float",
     524             :                 .data_type = SQL_FLOAT, /* 6 */
     525             :                 .column_size = DBL_MANT_DIG,
     526             :                 .literal_prefix = "NULL",
     527             :                 .literal_suffix = "NULL",
     528             :                 .create_params = "NULL",
     529             :                 .nullable = SQL_NULLABLE,
     530             :                 .case_sensitive = SQL_FALSE,
     531             :                 .searchable = SQL_PRED_BASIC,
     532             :                 .unsigned_attribute = SQL_FALSE,
     533             :                 .fixed_prec_scale = SQL_FALSE,
     534             :                 .auto_unique_value = SQL_FALSE,
     535             :                 .local_type_name = "NULL",
     536             :                 .minimum_scale = 0,
     537             :                 .maximum_scale = 0,
     538             :                 .sql_data_type = SQL_FLOAT,
     539             :                 .sql_datetime_sub = -1,
     540             :                 .num_prec_radix = 2,
     541             :                 .interval_precision = -1,
     542             :         },
     543             :         {
     544             :                 .type_name = "real",
     545             :                 .data_type = SQL_REAL,  /* 7 */
     546             :                 .column_size = FLT_MANT_DIG,
     547             :                 .literal_prefix = "NULL",
     548             :                 .literal_suffix = "NULL",
     549             :                 .create_params = "NULL",
     550             :                 .nullable = SQL_NULLABLE,
     551             :                 .case_sensitive = SQL_FALSE,
     552             :                 .searchable = SQL_PRED_BASIC,
     553             :                 .unsigned_attribute = SQL_FALSE,
     554             :                 .fixed_prec_scale = SQL_FALSE,
     555             :                 .auto_unique_value = SQL_FALSE,
     556             :                 .local_type_name = "NULL",
     557             :                 .minimum_scale = 0,
     558             :                 .maximum_scale = 0,
     559             :                 .sql_data_type = SQL_REAL,
     560             :                 .sql_datetime_sub = -1,
     561             :                 .num_prec_radix = 2,
     562             :                 .interval_precision = -1,
     563             :         },
     564             :         {
     565             :                 .type_name = "double",
     566             :                 .data_type = SQL_DOUBLE,        /* 8 */
     567             :                 .column_size = DBL_MANT_DIG,
     568             :                 .literal_prefix = "NULL",
     569             :                 .literal_suffix = "NULL",
     570             :                 .create_params = "NULL",
     571             :                 .nullable = SQL_NULLABLE,
     572             :                 .case_sensitive = SQL_FALSE,
     573             :                 .searchable = SQL_PRED_BASIC,
     574             :                 .unsigned_attribute = SQL_FALSE,
     575             :                 .fixed_prec_scale = SQL_FALSE,
     576             :                 .auto_unique_value = SQL_FALSE,
     577             :                 .local_type_name = "NULL",
     578             :                 .minimum_scale = 0,
     579             :                 .maximum_scale = 0,
     580             :                 .sql_data_type = SQL_DOUBLE,
     581             :                 .sql_datetime_sub = -1,
     582             :                 .num_prec_radix = 2,
     583             :                 .interval_precision = -1,
     584             :         },
     585             :         {
     586             :                 .type_name = "varchar",
     587             :                 .data_type = SQL_VARCHAR,       /* 12 */
     588             :                 .column_size = 1000000,
     589             :                 .literal_prefix = "''''",
     590             :                 .literal_suffix = "''''",
     591             :                 .create_params = "'length'",
     592             :                 .nullable = SQL_NULLABLE,
     593             :                 .case_sensitive = SQL_TRUE,
     594             :                 .searchable = SQL_SEARCHABLE,
     595             :                 .unsigned_attribute = -1,
     596             :                 .fixed_prec_scale = SQL_FALSE,
     597             :                 .auto_unique_value = -1,
     598             :                 .local_type_name = "NULL",
     599             :                 .minimum_scale = -1,
     600             :                 .maximum_scale = -1,
     601             :                 .sql_data_type = SQL_VARCHAR,
     602             :                 .sql_datetime_sub = -1,
     603             :                 .num_prec_radix = -1,
     604             :                 .interval_precision = -1,
     605             :         },
     606             :         {
     607             :                 .type_name = "date",
     608             :                 .data_type = SQL_TYPE_DATE,     /* 91 */
     609             :                 .column_size = 10,
     610             :                 .literal_prefix = "'date '''",
     611             :                 .literal_suffix = "''''",
     612             :                 .create_params = "NULL",
     613             :                 .nullable = SQL_NULLABLE,
     614             :                 .case_sensitive = SQL_FALSE,
     615             :                 .searchable = SQL_PRED_BASIC,
     616             :                 .unsigned_attribute = -1,
     617             :                 .fixed_prec_scale = SQL_FALSE,
     618             :                 .auto_unique_value = -1,
     619             :                 .local_type_name = "NULL",
     620             :                 .minimum_scale = -1,
     621             :                 .maximum_scale = -1,
     622             :                 .sql_data_type = SQL_DATETIME,
     623             :                 .sql_datetime_sub = SQL_CODE_DATE,
     624             :                 .num_prec_radix = -1,
     625             :                 .interval_precision = -1,
     626             :         },
     627             :         {
     628             :                 .type_name = "time",
     629             :                 .data_type = SQL_TYPE_TIME,     /* 92 */
     630             :                 .column_size = 8,
     631             :                 .literal_prefix = "'time '''",
     632             :                 .literal_suffix = "''''",
     633             :                 .create_params = "NULL",
     634             :                 .nullable = SQL_NULLABLE,
     635             :                 .case_sensitive = SQL_FALSE,
     636             :                 .searchable = SQL_PRED_BASIC,
     637             :                 .unsigned_attribute = -1,
     638             :                 .fixed_prec_scale = SQL_FALSE,
     639             :                 .auto_unique_value = -1,
     640             :                 .local_type_name = "NULL",
     641             :                 .minimum_scale = 0,
     642             :                 .maximum_scale = 0,
     643             :                 .sql_data_type = SQL_DATETIME,
     644             :                 .sql_datetime_sub = SQL_CODE_TIME,
     645             :                 .num_prec_radix = -1,
     646             :                 .interval_precision = -1,
     647             :         },
     648             :         {
     649             :                 .type_name = "time(precision)",
     650             :                 .data_type = SQL_TYPE_TIME,     /* 92 */
     651             :                 .column_size = 9 + 6,
     652             :                 .literal_prefix = "'time '''",
     653             :                 .literal_suffix = "''''",
     654             :                 .create_params = "'precision'",
     655             :                 .nullable = SQL_NULLABLE,
     656             :                 .case_sensitive = SQL_FALSE,
     657             :                 .searchable = SQL_PRED_BASIC,
     658             :                 .unsigned_attribute = -1,
     659             :                 .fixed_prec_scale = SQL_FALSE,
     660             :                 .auto_unique_value = -1,
     661             :                 .local_type_name = "NULL",
     662             :                 .minimum_scale = 0,
     663             :                 .maximum_scale = 6,
     664             :                 .sql_data_type = SQL_DATETIME,
     665             :                 .sql_datetime_sub = SQL_CODE_TIME,
     666             :                 .num_prec_radix = -1,
     667             :                 .interval_precision = -1,
     668             :         },
     669             :         {
     670             :                 .type_name = "timestamp",
     671             :                 .data_type = SQL_TYPE_TIMESTAMP,        /* 93 */
     672             :                 .column_size = 19,
     673             :                 .literal_prefix = "'timestamp '''",
     674             :                 .literal_suffix = "''''",
     675             :                 .create_params = "NULL",
     676             :                 .nullable = SQL_NULLABLE,
     677             :                 .case_sensitive = SQL_FALSE,
     678             :                 .searchable = SQL_PRED_BASIC,
     679             :                 .unsigned_attribute = -1,
     680             :                 .fixed_prec_scale = SQL_FALSE,
     681             :                 .auto_unique_value = -1,
     682             :                 .local_type_name = "NULL",
     683             :                 .minimum_scale = 0,
     684             :                 .maximum_scale = 0,
     685             :                 .sql_data_type = SQL_DATETIME,
     686             :                 .sql_datetime_sub = SQL_CODE_TIMESTAMP,
     687             :                 .num_prec_radix = -1,
     688             :                 .interval_precision = -1,
     689             :         },
     690             :         {
     691             :                 .type_name = "timestamp(precision)",
     692             :                 .data_type = SQL_TYPE_TIMESTAMP,        /* 93 */
     693             :                 .column_size = 20 + 6,
     694             :                 .literal_prefix = "'timestamp '''",
     695             :                 .literal_suffix = "''''",
     696             :                 .create_params = "'precision'",
     697             :                 .nullable = SQL_NULLABLE,
     698             :                 .case_sensitive = SQL_FALSE,
     699             :                 .searchable = SQL_PRED_BASIC,
     700             :                 .unsigned_attribute = -1,
     701             :                 .fixed_prec_scale = SQL_FALSE,
     702             :                 .auto_unique_value = -1,
     703             :                 .local_type_name = "NULL",
     704             :                 .minimum_scale = 0,
     705             :                 .maximum_scale = 6,
     706             :                 .sql_data_type = SQL_DATETIME,
     707             :                 .sql_datetime_sub = SQL_CODE_TIMESTAMP,
     708             :                 .num_prec_radix = -1,
     709             :                 .interval_precision = -1,
     710             :         },
     711             :         {
     712             :                 .type_name = "interval year",
     713             :                 .data_type = SQL_INTERVAL_YEAR, /* 101 */
     714             :                 .column_size = 9,
     715             :                 .literal_prefix = "''''",
     716             :                 .literal_suffix = "''''",
     717             :                 .create_params = "NULL",
     718             :                 .nullable = SQL_NULLABLE,
     719             :                 .case_sensitive = SQL_FALSE,
     720             :                 .searchable = SQL_PRED_BASIC,
     721             :                 .unsigned_attribute = -1,
     722             :                 .fixed_prec_scale = SQL_FALSE,
     723             :                 .auto_unique_value = -1,
     724             :                 .local_type_name = "NULL",
     725             :                 .minimum_scale = 0,
     726             :                 .maximum_scale = 0,
     727             :                 .sql_data_type = SQL_INTERVAL,
     728             :                 .sql_datetime_sub = SQL_CODE_YEAR,
     729             :                 .num_prec_radix = -1,
     730             :                 .interval_precision = 9,
     731             :         },
     732             :         {
     733             :                 .type_name = "interval month",
     734             :                 .data_type = SQL_INTERVAL_MONTH,        /* 102 */
     735             :                 .column_size = 10,
     736             :                 .literal_prefix = "''''",
     737             :                 .literal_suffix = "''''",
     738             :                 .create_params = "NULL",
     739             :                 .nullable = SQL_NULLABLE,
     740             :                 .case_sensitive = SQL_FALSE,
     741             :                 .searchable = SQL_PRED_BASIC,
     742             :                 .unsigned_attribute = -1,
     743             :                 .fixed_prec_scale = SQL_FALSE,
     744             :                 .auto_unique_value = -1,
     745             :                 .local_type_name = "NULL",
     746             :                 .minimum_scale = 0,
     747             :                 .maximum_scale = 0,
     748             :                 .sql_data_type = SQL_INTERVAL,
     749             :                 .sql_datetime_sub = SQL_CODE_MONTH,
     750             :                 .num_prec_radix = -1,
     751             :                 .interval_precision = 10,
     752             :         },
     753             :         {
     754             :                 .type_name = "interval day",
     755             :                 .data_type = SQL_INTERVAL_DAY,  /* 103 */
     756             :                 .column_size = 5,
     757             :                 .literal_prefix = "''''",
     758             :                 .literal_suffix = "''''",
     759             :                 .create_params = "NULL",
     760             :                 .nullable = SQL_NULLABLE,
     761             :                 .case_sensitive = SQL_FALSE,
     762             :                 .searchable = SQL_PRED_BASIC,
     763             :                 .unsigned_attribute = -1,
     764             :                 .fixed_prec_scale = SQL_FALSE,
     765             :                 .auto_unique_value = -1,
     766             :                 .local_type_name = "NULL",
     767             :                 .minimum_scale = 0,
     768             :                 .maximum_scale = 0,
     769             :                 .sql_data_type = SQL_INTERVAL,
     770             :                 .sql_datetime_sub = SQL_CODE_DAY,
     771             :                 .num_prec_radix = -1,
     772             :                 .interval_precision = 5,
     773             :         },
     774             :         {
     775             :                 .type_name = "interval hour",
     776             :                 .data_type = SQL_INTERVAL_HOUR, /* 104 */
     777             :                 .column_size = 6,
     778             :                 .literal_prefix = "''''",
     779             :                 .literal_suffix = "''''",
     780             :                 .create_params = "NULL",
     781             :                 .nullable = SQL_NULLABLE,
     782             :                 .case_sensitive = SQL_FALSE,
     783             :                 .searchable = SQL_PRED_BASIC,
     784             :                 .unsigned_attribute = -1,
     785             :                 .fixed_prec_scale = SQL_FALSE,
     786             :                 .auto_unique_value = -1,
     787             :                 .local_type_name = "NULL",
     788             :                 .minimum_scale = 0,
     789             :                 .maximum_scale = 0,
     790             :                 .sql_data_type = SQL_INTERVAL,
     791             :                 .sql_datetime_sub = SQL_CODE_HOUR,
     792             :                 .num_prec_radix = -1,
     793             :                 .interval_precision = 6,
     794             :         },
     795             :         {
     796             :                 .type_name = "interval minute",
     797             :                 .data_type = SQL_INTERVAL_MINUTE,       /* 105 */
     798             :                 .column_size = 8,
     799             :                 .literal_prefix = "''''",
     800             :                 .literal_suffix = "''''",
     801             :                 .create_params = "NULL",
     802             :                 .nullable = SQL_NULLABLE,
     803             :                 .case_sensitive = SQL_FALSE,
     804             :                 .searchable = SQL_PRED_BASIC,
     805             :                 .unsigned_attribute = -1,
     806             :                 .fixed_prec_scale = SQL_FALSE,
     807             :                 .auto_unique_value = -1,
     808             :                 .local_type_name = "NULL",
     809             :                 .minimum_scale = 0,
     810             :                 .maximum_scale = 0,
     811             :                 .sql_data_type = SQL_INTERVAL,
     812             :                 .sql_datetime_sub = SQL_CODE_MINUTE,
     813             :                 .num_prec_radix = -1,
     814             :                 .interval_precision = 8,
     815             :         },
     816             :         {
     817             :                 .type_name = "interval second",
     818             :                 .data_type = SQL_INTERVAL_SECOND,       /* 106 */
     819             :                 .column_size = 10,
     820             :                 .literal_prefix = "''''",
     821             :                 .literal_suffix = "''''",
     822             :                 .create_params = "'precision'",
     823             :                 .nullable = SQL_NULLABLE,
     824             :                 .case_sensitive = SQL_FALSE,
     825             :                 .searchable = SQL_PRED_BASIC,
     826             :                 .unsigned_attribute = -1,
     827             :                 .fixed_prec_scale = SQL_FALSE,
     828             :                 .auto_unique_value = -1,
     829             :                 .local_type_name = "NULL",
     830             :                 .minimum_scale = 0,
     831             :                 .maximum_scale = 0,
     832             :                 .sql_data_type = SQL_INTERVAL,
     833             :                 .sql_datetime_sub = SQL_CODE_SECOND,
     834             :                 .num_prec_radix = -1,
     835             :                 .interval_precision = 10,
     836             :         },
     837             :         {
     838             :                 .type_name = "interval year to month",
     839             :                 .data_type = SQL_INTERVAL_YEAR_TO_MONTH,        /* 107 */
     840             :                 .column_size = 12,
     841             :                 .literal_prefix = "''''",
     842             :                 .literal_suffix = "''''",
     843             :                 .create_params = "NULL",
     844             :                 .nullable = SQL_NULLABLE,
     845             :                 .case_sensitive = SQL_FALSE,
     846             :                 .searchable = SQL_PRED_BASIC,
     847             :                 .unsigned_attribute = -1,
     848             :                 .fixed_prec_scale = SQL_FALSE,
     849             :                 .auto_unique_value = -1,
     850             :                 .local_type_name = "NULL",
     851             :                 .minimum_scale = 0,
     852             :                 .maximum_scale = 0,
     853             :                 .sql_data_type = SQL_INTERVAL,
     854             :                 .sql_datetime_sub = SQL_CODE_YEAR_TO_MONTH,
     855             :                 .num_prec_radix = -1,
     856             :                 .interval_precision = 9,
     857             :         },
     858             :         {
     859             :                 .type_name = "interval day to hour",
     860             :                 .data_type = SQL_INTERVAL_DAY_TO_HOUR,  /* 108 */
     861             :                 .column_size = 8,
     862             :                 .literal_prefix = "''''",
     863             :                 .literal_suffix = "''''",
     864             :                 .create_params = "NULL",
     865             :                 .nullable = SQL_NULLABLE,
     866             :                 .case_sensitive = SQL_FALSE,
     867             :                 .searchable = SQL_PRED_BASIC,
     868             :                 .unsigned_attribute = -1,
     869             :                 .fixed_prec_scale = SQL_FALSE,
     870             :                 .auto_unique_value = -1,
     871             :                 .local_type_name = "NULL",
     872             :                 .minimum_scale = 0,
     873             :                 .maximum_scale = 0,
     874             :                 .sql_data_type = SQL_INTERVAL,
     875             :                 .sql_datetime_sub = SQL_CODE_DAY_TO_HOUR,
     876             :                 .num_prec_radix = -1,
     877             :                 .interval_precision = 5,
     878             :         },
     879             :         {
     880             :                 .type_name = "interval day to minute",
     881             :                 .data_type = SQL_INTERVAL_DAY_TO_MINUTE,        /* 109 */
     882             :                 .column_size = 11,
     883             :                 .literal_prefix = "''''",
     884             :                 .literal_suffix = "''''",
     885             :                 .create_params = "NULL",
     886             :                 .nullable = SQL_NULLABLE,
     887             :                 .case_sensitive = SQL_FALSE,
     888             :                 .searchable = SQL_PRED_BASIC,
     889             :                 .unsigned_attribute = -1,
     890             :                 .fixed_prec_scale = SQL_FALSE,
     891             :                 .auto_unique_value = -1,
     892             :                 .local_type_name = "NULL",
     893             :                 .minimum_scale = 0,
     894             :                 .maximum_scale = 0,
     895             :                 .sql_data_type = SQL_INTERVAL,
     896             :                 .sql_datetime_sub = SQL_CODE_DAY_TO_MINUTE,
     897             :                 .num_prec_radix = -1,
     898             :                 .interval_precision = 5,
     899             :         },
     900             :         {
     901             :                 .type_name = "interval day to second",
     902             :                 .data_type = SQL_INTERVAL_DAY_TO_SECOND,        /* 110 */
     903             :                 .column_size = 14,
     904             :                 .literal_prefix = "''''",
     905             :                 .literal_suffix = "''''",
     906             :                 .create_params = "'precision'",
     907             :                 .nullable = SQL_NULLABLE,
     908             :                 .case_sensitive = SQL_FALSE,
     909             :                 .searchable = SQL_PRED_BASIC,
     910             :                 .unsigned_attribute = -1,
     911             :                 .fixed_prec_scale = SQL_FALSE,
     912             :                 .auto_unique_value = -1,
     913             :                 .local_type_name = "NULL",
     914             :                 .minimum_scale = 0,
     915             :                 .maximum_scale = 0,
     916             :                 .sql_data_type = SQL_INTERVAL,
     917             :                 .sql_datetime_sub = SQL_CODE_DAY_TO_SECOND,
     918             :                 .num_prec_radix = -1,
     919             :                 .interval_precision = 5,
     920             :         },
     921             :         {
     922             :                 .type_name = "interval hour to minute",
     923             :                 .data_type = SQL_INTERVAL_HOUR_TO_MINUTE,       /* 111 */
     924             :                 .column_size = 9,
     925             :                 .literal_prefix = "''''",
     926             :                 .literal_suffix = "''''",
     927             :                 .create_params = "NULL",
     928             :                 .nullable = SQL_NULLABLE,
     929             :                 .case_sensitive = SQL_FALSE,
     930             :                 .searchable = SQL_PRED_BASIC,
     931             :                 .unsigned_attribute = -1,
     932             :                 .fixed_prec_scale = SQL_FALSE,
     933             :                 .auto_unique_value = -1,
     934             :                 .local_type_name = "NULL",
     935             :                 .minimum_scale = 0,
     936             :                 .maximum_scale = 0,
     937             :                 .sql_data_type = SQL_INTERVAL,
     938             :                 .sql_datetime_sub = SQL_CODE_HOUR_TO_MINUTE,
     939             :                 .num_prec_radix = -1,
     940             :                 .interval_precision = 6,
     941             :         },
     942             :         {
     943             :                 .type_name = "interval hour to second",
     944             :                 .data_type = SQL_INTERVAL_HOUR_TO_SECOND,       /* 112 */
     945             :                 .column_size = 12,
     946             :                 .literal_prefix = "''''",
     947             :                 .literal_suffix = "''''",
     948             :                 .create_params = "'precision'",
     949             :                 .nullable = SQL_NULLABLE,
     950             :                 .case_sensitive = SQL_FALSE,
     951             :                 .searchable = SQL_PRED_BASIC,
     952             :                 .unsigned_attribute = -1,
     953             :                 .fixed_prec_scale = SQL_FALSE,
     954             :                 .auto_unique_value = -1,
     955             :                 .local_type_name = "NULL",
     956             :                 .minimum_scale = 0,
     957             :                 .maximum_scale = 0,
     958             :                 .sql_data_type = SQL_INTERVAL,
     959             :                 .sql_datetime_sub = SQL_CODE_HOUR_TO_SECOND,
     960             :                 .num_prec_radix = -1,
     961             :                 .interval_precision = 6,
     962             :         },
     963             :         {
     964             :                 .type_name = "interval minute to second",
     965             :                 .data_type = SQL_INTERVAL_MINUTE_TO_SECOND,     /* 113 */
     966             :                 .column_size = 13,
     967             :                 .literal_prefix = "''''",
     968             :                 .literal_suffix = "''''",
     969             :                 .create_params = "'precision'",
     970             :                 .nullable = SQL_NULLABLE,
     971             :                 .case_sensitive = SQL_FALSE,
     972             :                 .searchable = SQL_PRED_BASIC,
     973             :                 .unsigned_attribute = -1,
     974             :                 .fixed_prec_scale = SQL_FALSE,
     975             :                 .auto_unique_value = -1,
     976             :                 .local_type_name = "NULL",
     977             :                 .minimum_scale = 0,
     978             :                 .maximum_scale = 0,
     979             :                 .sql_data_type = SQL_INTERVAL,
     980             :                 .sql_datetime_sub = SQL_CODE_MINUTE_TO_SECOND,
     981             :                 .num_prec_radix = -1,
     982             :                 .interval_precision = 10,
     983             :         },
     984             :         {
     985             :                 .type_name = "hugeint",
     986             :                 .data_type = SQL_HUGEINT,       /* 0x4000 (defined in ODBCGlobal.h) */
     987             :                 .column_size = 38,
     988             :                 .literal_prefix = "NULL",
     989             :                 .literal_suffix = "NULL",
     990             :                 .create_params = "NULL",
     991             :                 .nullable = SQL_NULLABLE,
     992             :                 .case_sensitive = SQL_FALSE,
     993             :                 .searchable = SQL_PRED_BASIC,
     994             :                 .unsigned_attribute = SQL_FALSE,
     995             :                 .fixed_prec_scale = SQL_FALSE,
     996             :                 .auto_unique_value = SQL_FALSE,
     997             :                 .local_type_name = "NULL",
     998             :                 .minimum_scale = 0,
     999             :                 .maximum_scale = 0,
    1000             :                 .sql_data_type = SQL_HUGEINT,
    1001             :                 .sql_datetime_sub = -1,
    1002             :                 .num_prec_radix = 10,
    1003             :                 .interval_precision = -1,
    1004             :         },
    1005             : };
    1006             : 
    1007             : /* find some info about a type given the concise type */
    1008             : const char *
    1009           0 : ODBCGetTypeInfo(int concise_type,
    1010             :                 int *data_type,
    1011             :                 int *sql_data_type,
    1012             :                 int *sql_datetime_sub)
    1013             : {
    1014             :         const struct types *t;
    1015             : 
    1016           0 :         for (t = types; t < &types[sizeof(types) / sizeof(types[0])]; t++) {
    1017           0 :                 if (t->data_type == concise_type) {
    1018           0 :                         if (data_type)
    1019           0 :                                 *data_type = t->data_type;
    1020           0 :                         if (sql_data_type)
    1021           0 :                                 *sql_data_type = t->sql_data_type;
    1022           0 :                         if (sql_datetime_sub)
    1023           0 :                                 *sql_datetime_sub = t->sql_datetime_sub;
    1024           0 :                         return t->type_name;
    1025             :                 }
    1026             :         }
    1027             :         return NULL;
    1028             : }
    1029             : 
    1030             : static SQLRETURN
    1031           0 : MNDBGetTypeInfo(ODBCStmt *stmt,
    1032             :                 SQLSMALLINT DataType)
    1033             : {
    1034             :         const struct types *t;
    1035             :         int i;
    1036             :         char query[4096];
    1037             : 
    1038           0 :         switch (DataType) {
    1039             :         case SQL_ALL_TYPES:
    1040             :         case SQL_CHAR:
    1041             :         case SQL_NUMERIC:
    1042             :         case SQL_DECIMAL:
    1043             :         case SQL_INTEGER:
    1044             :         case SQL_SMALLINT:
    1045             :         case SQL_FLOAT:
    1046             :         case SQL_REAL:
    1047             :         case SQL_DOUBLE:
    1048             :         case SQL_DATE:
    1049             :         case SQL_TIME:
    1050             :         case SQL_TIMESTAMP:
    1051             :         case SQL_VARCHAR:
    1052             :         case SQL_TYPE_DATE:
    1053             :         case SQL_TYPE_TIME:
    1054             :         case SQL_TYPE_TIMESTAMP:
    1055             :         case SQL_LONGVARCHAR:
    1056             :         case SQL_BINARY:
    1057             :         case SQL_VARBINARY:
    1058             :         case SQL_LONGVARBINARY:
    1059             :         case SQL_BIGINT:
    1060             :         case SQL_TINYINT:
    1061             :         case SQL_BIT:
    1062             :         case SQL_WCHAR:
    1063             :         case SQL_WVARCHAR:
    1064             :         case SQL_WLONGVARCHAR:
    1065             :         case SQL_GUID:
    1066             :         case SQL_INTERVAL_YEAR:
    1067             :         case SQL_INTERVAL_MONTH:
    1068             :         case SQL_INTERVAL_DAY:
    1069             :         case SQL_INTERVAL_HOUR:
    1070             :         case SQL_INTERVAL_MINUTE:
    1071             :         case SQL_INTERVAL_SECOND:
    1072             :         case SQL_INTERVAL_YEAR_TO_MONTH:
    1073             :         case SQL_INTERVAL_DAY_TO_HOUR:
    1074             :         case SQL_INTERVAL_DAY_TO_MINUTE:
    1075             :         case SQL_INTERVAL_DAY_TO_SECOND:
    1076             :         case SQL_INTERVAL_HOUR_TO_MINUTE:
    1077             :         case SQL_INTERVAL_HOUR_TO_SECOND:
    1078             :         case SQL_INTERVAL_MINUTE_TO_SECOND:
    1079             :                 break;
    1080             : 
    1081           0 :         case SQL_HUGEINT:
    1082             :                 /* the application shows interest in HUGEINT, so now we
    1083             :                  * enable it */
    1084           0 :                 stmt->Dbc->allow_hugeint = true;
    1085           0 :                 break;
    1086             : 
    1087             :         /* some pre ODBC 3.0 data types which can be mapped to ODBC
    1088             :          * 3.0 data types */
    1089           0 :         case -80:               /* SQL_INTERVAL_YEAR */
    1090             :                 DataType = SQL_INTERVAL_YEAR;
    1091           0 :                 break;
    1092           0 :         case -81:               /* SQL_INTERVAL_YEAR_TO_MONTH */
    1093             :                 DataType = SQL_INTERVAL_YEAR_TO_MONTH;
    1094           0 :                 break;
    1095           0 :         case -82:               /* SQL_INTERVAL_MONTH */
    1096             :                 DataType = SQL_INTERVAL_MONTH;
    1097           0 :                 break;
    1098           0 :         case -83:               /* SQL_INTERVAL_DAY */
    1099             :                 DataType = SQL_INTERVAL_DAY;
    1100           0 :                 break;
    1101           0 :         case -84:               /* SQL_INTERVAL_HOUR */
    1102             :                 DataType = SQL_INTERVAL_HOUR;
    1103           0 :                 break;
    1104           0 :         case -85:               /* SQL_INTERVAL_MINUTE */
    1105             :                 DataType = SQL_INTERVAL_MINUTE;
    1106           0 :                 break;
    1107           0 :         case -86:               /* SQL_INTERVAL_SECOND */
    1108             :                 DataType = SQL_INTERVAL_SECOND;
    1109           0 :                 break;
    1110           0 :         case -87:               /* SQL_INTERVAL_DAY_TO_HOUR */
    1111             :                 DataType = SQL_INTERVAL_DAY_TO_HOUR;
    1112           0 :                 break;
    1113           0 :         case -88:               /* SQL_INTERVAL_DAY_TO_MINUTE */
    1114             :                 DataType = SQL_INTERVAL_DAY_TO_MINUTE;
    1115           0 :                 break;
    1116           0 :         case -89:               /* SQL_INTERVAL_DAY_TO_SECOND */
    1117             :                 DataType = SQL_INTERVAL_DAY_TO_SECOND;
    1118           0 :                 break;
    1119           0 :         case -90:               /* SQL_INTERVAL_HOUR_TO_MINUTE */
    1120             :                 DataType = SQL_INTERVAL_HOUR_TO_MINUTE;
    1121           0 :                 break;
    1122           0 :         case -91:               /* SQL_INTERVAL_HOUR_TO_SECOND */
    1123             :                 DataType = SQL_INTERVAL_HOUR_TO_SECOND;
    1124           0 :                 break;
    1125           0 :         case -92:               /* SQL_INTERVAL_MINUTE_TO_SECOND */
    1126             :                 DataType = SQL_INTERVAL_MINUTE_TO_SECOND;
    1127           0 :                 break;
    1128             : 
    1129           0 :         case -95:               /* SQL_UNICODE_CHAR and SQL_UNICODE */
    1130             :                 DataType = SQL_WCHAR;
    1131           0 :                 break;
    1132           0 :         case -96:               /* SQL_UNICODE_VARCHAR */
    1133             :                 DataType = SQL_WVARCHAR;
    1134           0 :                 break;
    1135           0 :         case -97:               /* SQL_UNICODE_LONGVARCHAR */
    1136             :                 DataType = SQL_WLONGVARCHAR;
    1137           0 :                 break;
    1138           0 :         default:
    1139             :                 /* Invalid SQL data type */
    1140           0 :                 addStmtError(stmt, "HY004", NULL, 0);
    1141           0 :                 return SQL_ERROR;
    1142             :         }
    1143             : 
    1144           0 :         i = snprintf(query, sizeof(query), "select * from (values ");
    1145             : 
    1146             :         bool first = true;
    1147           0 :         for (t = types; t < &types[sizeof(types) / sizeof(types[0])]; t++) {
    1148           0 :                 assert(t == types || t->data_type >= (t-1)->data_type);
    1149           0 :                 if (DataType != SQL_ALL_TYPES && DataType != t->data_type)
    1150           0 :                         continue;
    1151           0 :                 if (DataType == SQL_ALL_TYPES &&
    1152           0 :                     t->data_type == SQL_HUGEINT &&
    1153           0 :                     !stmt->Dbc->allow_hugeint)
    1154           0 :                         continue;
    1155           0 :                 if (first) {
    1156             :                         /* specify column types in first set of values */
    1157           0 :                         i += snprintf(query + i, sizeof(query) - i,
    1158             :                                       "(cast('%s' as varchar(128))"
    1159             :                                       ",cast(%d as smallint)"
    1160             :                                       ",cast(%d as integer)"
    1161             :                                       ",cast(%s as varchar(128))"
    1162             :                                       ",cast(%s as varchar(128))"
    1163             :                                       ",cast(%s as varchar(128))"
    1164             :                                       ",cast(%d as smallint)"
    1165             :                                       ",cast(%d as smallint)"
    1166             :                                       ",cast(%d as smallint)"
    1167             :                                       ",cast(%d as smallint)"
    1168             :                                       ",cast(%d as smallint)"
    1169             :                                       ",cast(%d as smallint)"
    1170             :                                       ",cast(%s as varchar(128))"
    1171             :                                       ",cast(%d as smallint)"
    1172             :                                       ",cast(%d as smallint)"
    1173             :                                       ",cast(%d as smallint)"
    1174             :                                       ",cast(%d as smallint)"
    1175             :                                       ",cast(%d as integer)"
    1176             :                                       ",cast(%d as smallint))",
    1177             :                                       t->type_name,
    1178             :                                       t->data_type,
    1179             :                                       t->column_size,
    1180             :                                       t->literal_prefix,
    1181             :                                       t->literal_suffix,
    1182             :                                       t->create_params,
    1183             :                                       t->nullable,
    1184             :                                       t->case_sensitive,
    1185             :                                       t->searchable,
    1186             :                                       t->unsigned_attribute,
    1187             :                                       t->fixed_prec_scale,
    1188             :                                       t->auto_unique_value,
    1189             :                                       t->local_type_name,
    1190             :                                       t->minimum_scale,
    1191             :                                       t->maximum_scale,
    1192             :                                       t->sql_data_type,
    1193             :                                       t->sql_datetime_sub,
    1194             :                                       t->num_prec_radix,
    1195             :                                       t->interval_precision);
    1196             :                         first = false;
    1197             :                 } else {
    1198           0 :                         i += snprintf(query + i, sizeof(query) - i,
    1199             :                                       ",('%s',%d,%d,%s,%s,%s,%d,%d,%d"
    1200             :                                       ",%d,%d,%d,%s,%d,%d,%d,%d,%d,%d)",
    1201             :                                       t->type_name,
    1202             :                                       t->data_type,
    1203             :                                       t->column_size,
    1204             :                                       t->literal_prefix,
    1205             :                                       t->literal_suffix,
    1206             :                                       t->create_params,
    1207             :                                       t->nullable,
    1208             :                                       t->case_sensitive,
    1209             :                                       t->searchable,
    1210             :                                       t->unsigned_attribute,
    1211             :                                       t->fixed_prec_scale,
    1212             :                                       t->auto_unique_value,
    1213             :                                       t->local_type_name,
    1214             :                                       t->minimum_scale,
    1215             :                                       t->maximum_scale,
    1216             :                                       t->sql_data_type,
    1217             :                                       t->sql_datetime_sub,
    1218             :                                       t->num_prec_radix,
    1219             :                                       t->interval_precision);
    1220             :                 }
    1221             :         }
    1222           0 :         i += snprintf(query+ i, sizeof(query) - i, ") as monetdb_types "
    1223             :                       "(type_name"
    1224             :                       ",data_type"
    1225             :                       ",column_size"
    1226             :                       ",literal_prefix"
    1227             :                       ",literal_suffix"
    1228             :                       ",create_params"
    1229             :                       ",nullable"
    1230             :                       ",case_sensitive"
    1231             :                       ",searchable"
    1232             :                       ",unsigned_attribute"
    1233             :                       ",fixed_prec_scale"
    1234             :                       ",auto_unique_value"
    1235             :                       ",local_type_name"
    1236             :                       ",minimum_scale"
    1237             :                       ",maximum_scale"
    1238             :                       ",sql_data_type"
    1239             :                       ",sql_datetime_sub"
    1240             :                       ",num_prec_radix"
    1241             :                       ",interval_precision)");
    1242           0 :         assert(i < (int) sizeof(query));
    1243             : 
    1244           0 :         return MNDBExecDirect(stmt, (SQLCHAR *) query,
    1245             :                               (SQLINTEGER) i);
    1246             : }
    1247             : 
    1248             : #ifdef ODBCDEBUG
    1249             : static char *
    1250           0 : translateDataType(SQLSMALLINT DataType)
    1251             : {
    1252           0 :         switch (DataType) {
    1253             :         case SQL_ALL_TYPES:
    1254             :                 return "SQL_ALL_TYPES";
    1255           0 :         case SQL_CHAR:
    1256           0 :                 return "SQL_CHAR";
    1257           0 :         case SQL_NUMERIC:
    1258           0 :                 return "SQL_NUMERIC";
    1259           0 :         case SQL_DECIMAL:
    1260           0 :                 return "SQL_DECIMAL";
    1261           0 :         case SQL_INTEGER:
    1262           0 :                 return "SQL_INTEGER";
    1263           0 :         case SQL_SMALLINT:
    1264           0 :                 return "SQL_SMALLINT";
    1265           0 :         case SQL_FLOAT:
    1266           0 :                 return "SQL_FLOAT";
    1267           0 :         case SQL_REAL:
    1268           0 :                 return "SQL_REAL";
    1269           0 :         case SQL_DOUBLE:
    1270           0 :                 return "SQL_DOUBLE";
    1271           0 :         case SQL_DATE:
    1272           0 :                 return "SQL_DATE";
    1273           0 :         case SQL_TIME:
    1274           0 :                 return "SQL_TIME";
    1275           0 :         case SQL_TIMESTAMP:
    1276           0 :                 return "SQL_TIMESTAMP";
    1277           0 :         case SQL_VARCHAR:
    1278           0 :                 return "SQL_VARCHAR";
    1279           0 :         case SQL_TYPE_DATE:
    1280           0 :                 return "SQL_TYPE_DATE";
    1281           0 :         case SQL_TYPE_TIME:
    1282           0 :                 return "SQL_TYPE_TIME";
    1283           0 :         case SQL_TYPE_TIMESTAMP:
    1284           0 :                 return "SQL_TYPE_TIMESTAMP";
    1285           0 :         case SQL_LONGVARCHAR:
    1286           0 :                 return "SQL_LONGVARCHAR";
    1287           0 :         case SQL_BINARY:
    1288           0 :                 return "SQL_BINARY";
    1289           0 :         case SQL_VARBINARY:
    1290           0 :                 return "SQL_VARBINARY";
    1291           0 :         case SQL_LONGVARBINARY:
    1292           0 :                 return "SQL_LONGVARBINARY";
    1293           0 :         case SQL_BIGINT:
    1294           0 :                 return "SQL_BIGINT";
    1295           0 :         case SQL_HUGEINT:
    1296           0 :                 return "SQL_HUGEINT";
    1297           0 :         case SQL_TINYINT:
    1298           0 :                 return "SQL_TINYINT";
    1299           0 :         case SQL_BIT:
    1300           0 :                 return "SQL_BIT";
    1301           0 :         case SQL_WCHAR:
    1302           0 :                 return "SQL_WCHAR";
    1303           0 :         case SQL_WVARCHAR:
    1304           0 :                 return "SQL_WVARCHAR";
    1305           0 :         case SQL_WLONGVARCHAR:
    1306           0 :                 return "SQL_WLONGVARCHAR";
    1307           0 :         case SQL_GUID:
    1308           0 :                 return "SQL_GUID";
    1309           0 :         case SQL_INTERVAL_YEAR:
    1310           0 :                 return "SQL_INTERVAL_YEAR";
    1311           0 :         case SQL_INTERVAL_MONTH:
    1312           0 :                 return "SQL_INTERVAL_MONTH";
    1313           0 :         case SQL_INTERVAL_DAY:
    1314           0 :                 return "SQL_INTERVAL_DAY";
    1315           0 :         case SQL_INTERVAL_HOUR:
    1316           0 :                 return "SQL_INTERVAL_HOUR";
    1317           0 :         case SQL_INTERVAL_MINUTE:
    1318           0 :                 return "SQL_INTERVAL_MINUTE";
    1319           0 :         case SQL_INTERVAL_SECOND:
    1320           0 :                 return "SQL_INTERVAL_SECOND";
    1321           0 :         case SQL_INTERVAL_YEAR_TO_MONTH:
    1322           0 :                 return "SQL_INTERVAL_YEAR_TO_MONTH";
    1323           0 :         case SQL_INTERVAL_DAY_TO_HOUR:
    1324           0 :                 return "SQL_INTERVAL_DAY_TO_HOUR";
    1325           0 :         case SQL_INTERVAL_DAY_TO_MINUTE:
    1326           0 :                 return "SQL_INTERVAL_DAY_TO_MINUTE";
    1327           0 :         case SQL_INTERVAL_DAY_TO_SECOND:
    1328           0 :                 return "SQL_INTERVAL_DAY_TO_SECOND";
    1329           0 :         case SQL_INTERVAL_HOUR_TO_MINUTE:
    1330           0 :                 return "SQL_INTERVAL_HOUR_TO_MINUTE";
    1331           0 :         case SQL_INTERVAL_HOUR_TO_SECOND:
    1332           0 :                 return "SQL_INTERVAL_HOUR_TO_SECOND";
    1333           0 :         case SQL_INTERVAL_MINUTE_TO_SECOND:
    1334           0 :                 return "SQL_INTERVAL_MINUTE_TO_SECOND";
    1335           0 :         case -80:
    1336           0 :                 return "SQL_INTERVAL_YEAR(ODBC2)";
    1337           0 :         case -81:
    1338           0 :                 return "SQL_INTERVAL_YEAR_TO_MONTH(ODBC2)";
    1339           0 :         case -82:
    1340           0 :                 return "SQL_INTERVAL_MONTH(ODBC2)";
    1341           0 :         case -83:
    1342           0 :                 return "SQL_INTERVAL_DAY(ODBC2)";
    1343           0 :         case -84:
    1344           0 :                 return "SQL_INTERVAL_HOUR(ODBC2)";
    1345           0 :         case -85:
    1346           0 :                 return "SQL_INTERVAL_MINUTE(ODBC2)";
    1347           0 :         case -86:
    1348           0 :                 return "SQL_INTERVAL_SECOND(ODBC2)";
    1349           0 :         case -87:
    1350           0 :                 return "SQL_INTERVAL_DAY_TO_HOUR(ODBC2)";
    1351           0 :         case -88:
    1352           0 :                 return "SQL_INTERVAL_DAY_TO_MINUTE(ODBC2)";
    1353           0 :         case -89:
    1354           0 :                 return "SQL_INTERVAL_DAY_TO_SECOND(ODBC2)";
    1355           0 :         case -90:
    1356           0 :                 return "SQL_INTERVAL_HOUR_TO_MINUTE(ODBC2)";
    1357           0 :         case -91:
    1358           0 :                 return "SQL_INTERVAL_HOUR_TO_SECOND(ODBC2)";
    1359           0 :         case -92:
    1360           0 :                 return "SQL_INTERVAL_MINUTE_TO_SECOND(ODBC2)";
    1361           0 :         case -95:
    1362           0 :                 return "SQL_UNICODE_CHAR and SQL_UNICODE(ODBC2)";
    1363           0 :         case -96:
    1364           0 :                 return "SQL_UNICODE_VARCHAR(ODBC2)";
    1365           0 :         case -97:
    1366           0 :                 return "SQL_UNICODE_LONGVARCHAR(ODBC2)";
    1367           0 :         default:
    1368           0 :                 return "unknown";
    1369             :         }
    1370             : }
    1371             : #endif
    1372             : 
    1373             : SQLRETURN SQL_API
    1374             : SQLGetTypeInfo(SQLHSTMT StatementHandle,
    1375             :                SQLSMALLINT DataType)
    1376             : {
    1377             :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
    1378             : 
    1379             : #ifdef ODBCDEBUG
    1380           0 :         ODBCLOG("SQLGetTypeInfo %p %s\n",
    1381             :                 StatementHandle, translateDataType(DataType));
    1382             : #endif
    1383             : 
    1384           0 :         if (!isValidStmt(stmt))
    1385             :                  return SQL_INVALID_HANDLE;
    1386             : 
    1387           0 :         clearStmtErrors(stmt);
    1388             : 
    1389           0 :         return MNDBGetTypeInfo(stmt, DataType);
    1390             : }
    1391             : 
    1392             : SQLRETURN SQL_API
    1393             : SQLGetTypeInfoA(SQLHSTMT StatementHandle,
    1394             :                 SQLSMALLINT DataType)
    1395             : {
    1396           0 :         return SQLGetTypeInfo(StatementHandle, DataType);
    1397             : }
    1398             : 
    1399             : SQLRETURN SQL_API
    1400             : SQLGetTypeInfoW(SQLHSTMT StatementHandle,
    1401             :                 SQLSMALLINT DataType)
    1402             : {
    1403             :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
    1404             : 
    1405             : #ifdef ODBCDEBUG
    1406           0 :         ODBCLOG("SQLGetTypeInfoW %p %s\n",
    1407             :                 StatementHandle, translateDataType(DataType));
    1408             : #endif
    1409             : 
    1410           0 :         if (!isValidStmt(stmt))
    1411             :                  return SQL_INVALID_HANDLE;
    1412             : 
    1413           0 :         clearStmtErrors(stmt);
    1414             : 
    1415           0 :         return MNDBGetTypeInfo(stmt, DataType);
    1416             : }

Generated by: LCOV version 1.14