LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/ecpglib - typename.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 16 53 30.2 %
Date: 2019-08-24 15:07:19 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* src/interfaces/ecpg/ecpglib/typename.c */
       2             : 
       3             : #define POSTGRES_ECPG_INTERNAL
       4             : #include "postgres_fe.h"
       5             : 
       6             : #include "catalog/pg_type_d.h"
       7             : 
       8             : #include "ecpgtype.h"
       9             : #include "ecpglib.h"
      10             : #include "ecpglib_extern.h"
      11             : #include "sqltypes.h"
      12             : #include "sql3types.h"
      13             : 
      14             : /*
      15             :  * This function is used to generate the correct type names.
      16             :  */
      17             : const char *
      18           0 : ecpg_type_name(enum ECPGttype typ)
      19             : {
      20           0 :     switch (typ)
      21             :     {
      22             :         case ECPGt_char:
      23             :         case ECPGt_string:
      24           0 :             return "char";
      25             :         case ECPGt_unsigned_char:
      26           0 :             return "unsigned char";
      27             :         case ECPGt_short:
      28           0 :             return "short";
      29             :         case ECPGt_unsigned_short:
      30           0 :             return "unsigned short";
      31             :         case ECPGt_int:
      32           0 :             return "int";
      33             :         case ECPGt_unsigned_int:
      34           0 :             return "unsigned int";
      35             :         case ECPGt_long:
      36           0 :             return "long";
      37             :         case ECPGt_unsigned_long:
      38           0 :             return "unsigned long";
      39             :         case ECPGt_long_long:
      40           0 :             return "long long";
      41             :         case ECPGt_unsigned_long_long:
      42           0 :             return "unsigned long long";
      43             :         case ECPGt_float:
      44           0 :             return "float";
      45             :         case ECPGt_double:
      46           0 :             return "double";
      47             :         case ECPGt_bool:
      48           0 :             return "bool";
      49             :         case ECPGt_varchar:
      50           0 :             return "varchar";
      51             :         case ECPGt_bytea:
      52           0 :             return "bytea";
      53             :         case ECPGt_char_variable:
      54           0 :             return "char";
      55             :         case ECPGt_decimal:
      56           0 :             return "decimal";
      57             :         case ECPGt_numeric:
      58           0 :             return "numeric";
      59             :         case ECPGt_date:
      60           0 :             return "date";
      61             :         case ECPGt_timestamp:
      62           0 :             return "timestamp";
      63             :         case ECPGt_interval:
      64           0 :             return "interval";
      65             :         case ECPGt_const:
      66           0 :             return "Const";
      67             :         default:
      68           0 :             abort();
      69             :     }
      70             :     return "";                    /* keep MSC compiler happy */
      71             : }
      72             : 
      73             : int
      74         152 : ecpg_dynamic_type(Oid type)
      75             : {
      76         152 :     switch (type)
      77             :     {
      78             :         case BOOLOID:
      79          16 :             return SQL3_BOOLEAN;    /* bool */
      80             :         case INT2OID:
      81           0 :             return SQL3_SMALLINT;   /* int2 */
      82             :         case INT4OID:
      83          16 :             return SQL3_INTEGER;    /* int4 */
      84             :         case TEXTOID:
      85          16 :             return SQL3_CHARACTER;  /* text */
      86             :         case FLOAT4OID:
      87           0 :             return SQL3_REAL;   /* float4 */
      88             :         case FLOAT8OID:
      89          16 :             return SQL3_DOUBLE_PRECISION;   /* float8 */
      90             :         case BPCHAROID:
      91          16 :             return SQL3_CHARACTER;  /* bpchar */
      92             :         case VARCHAROID:
      93           0 :             return SQL3_CHARACTER_VARYING;  /* varchar */
      94             :         case DATEOID:
      95          16 :             return SQL3_DATE_TIME_TIMESTAMP;    /* date */
      96             :         case TIMEOID:
      97           0 :             return SQL3_DATE_TIME_TIMESTAMP;    /* time */
      98             :         case TIMESTAMPOID:
      99           0 :             return SQL3_DATE_TIME_TIMESTAMP;    /* datetime */
     100             :         case NUMERICOID:
     101           0 :             return SQL3_NUMERIC;    /* numeric */
     102             :         default:
     103          56 :             return 0;
     104             :     }
     105             : }
     106             : 
     107             : int
     108         992 : sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
     109             : {
     110         992 :     switch (type)
     111             :     {
     112             :         case CHAROID:
     113             :         case VARCHAROID:
     114             :         case BPCHAROID:
     115             :         case TEXTOID:
     116         368 :             return ECPGt_char;
     117             :         case INT2OID:
     118           0 :             return ECPGt_short;
     119             :         case INT4OID:
     120         208 :             return ECPGt_int;
     121             :         case FLOAT8OID:
     122         160 :             return ECPGt_double;
     123             :         case FLOAT4OID:
     124           0 :             return ECPGt_float;
     125             :         case NUMERICOID:
     126         160 :             return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
     127             :         case DATEOID:
     128           0 :             return ECPGt_date;
     129             :         case TIMESTAMPOID:
     130             :         case TIMESTAMPTZOID:
     131           0 :             return ECPGt_timestamp;
     132             :         case INTERVALOID:
     133           0 :             return ECPGt_interval;
     134             :         case INT8OID:
     135             : #ifdef HAVE_LONG_LONG_INT_64
     136             :             return ECPGt_long_long;
     137             : #endif
     138             : #ifdef HAVE_LONG_INT_64
     139          96 :             return ECPGt_long;
     140             : #endif
     141             :             /* Unhandled types always return a string */
     142             :         default:
     143           0 :             return ECPGt_char;
     144             :     }
     145             : }

Generated by: LCOV version 1.13