PostgreSQL Source Code  git master
typename.c File Reference
#include "postgres_fe.h"
#include "catalog/pg_type_d.h"
#include "ecpgtype.h"
#include "ecpglib.h"
#include "extern.h"
#include "sqltypes.h"
#include "sql3types.h"
Include dependency graph for typename.c:

Go to the source code of this file.

Macros

#define POSTGRES_ECPG_INTERNAL
 

Functions

const char * ecpg_type_name (enum ECPGttype typ)
 
int ecpg_dynamic_type (Oid type)
 
int sqlda_dynamic_type (Oid type, enum COMPAT_MODE compat)
 

Macro Definition Documentation

◆ POSTGRES_ECPG_INTERNAL

#define POSTGRES_ECPG_INTERNAL

Definition at line 3 of file typename.c.

Function Documentation

◆ ecpg_dynamic_type()

int ecpg_dynamic_type ( Oid  type)

Definition at line 72 of file typename.c.

References SQL3_BOOLEAN, SQL3_CHARACTER, SQL3_CHARACTER_VARYING, SQL3_DATE_TIME_TIMESTAMP, SQL3_DOUBLE_PRECISION, SQL3_INTEGER, SQL3_NUMERIC, SQL3_REAL, and SQL3_SMALLINT.

Referenced by ecpg_is_type_an_array(), and ECPGget_desc().

73 {
74  switch (type)
75  {
76  case BOOLOID:
77  return SQL3_BOOLEAN; /* bool */
78  case INT2OID:
79  return SQL3_SMALLINT; /* int2 */
80  case INT4OID:
81  return SQL3_INTEGER; /* int4 */
82  case TEXTOID:
83  return SQL3_CHARACTER; /* text */
84  case FLOAT4OID:
85  return SQL3_REAL; /* float4 */
86  case FLOAT8OID:
87  return SQL3_DOUBLE_PRECISION; /* float8 */
88  case BPCHAROID:
89  return SQL3_CHARACTER; /* bpchar */
90  case VARCHAROID:
91  return SQL3_CHARACTER_VARYING; /* varchar */
92  case DATEOID:
93  return SQL3_DATE_TIME_TIMESTAMP; /* date */
94  case TIMEOID:
95  return SQL3_DATE_TIME_TIMESTAMP; /* time */
96  case TIMESTAMPOID:
97  return SQL3_DATE_TIME_TIMESTAMP; /* datetime */
98  case NUMERICOID:
99  return SQL3_NUMERIC; /* numeric */
100  default:
101  return 0;
102  }
103 }

◆ ecpg_type_name()

const char* ecpg_type_name ( enum ECPGttype  typ)

Definition at line 18 of file typename.c.

References ECPGt_bool, ECPGt_char, ECPGt_char_variable, ECPGt_const, ECPGt_date, ECPGt_decimal, ECPGt_double, ECPGt_float, ECPGt_int, ECPGt_interval, ECPGt_long, ECPGt_long_long, ECPGt_numeric, ECPGt_short, ECPGt_string, ECPGt_timestamp, ECPGt_unsigned_char, ECPGt_unsigned_int, ECPGt_unsigned_long, ECPGt_unsigned_long_long, ECPGt_unsigned_short, and ECPGt_varchar.

Referenced by ecpg_get_data(), ecpg_store_input(), and ECPGdump_a_simple().

19 {
20  switch (typ)
21  {
22  case ECPGt_char:
23  case ECPGt_string:
24  return "char";
26  return "unsigned char";
27  case ECPGt_short:
28  return "short";
30  return "unsigned short";
31  case ECPGt_int:
32  return "int";
33  case ECPGt_unsigned_int:
34  return "unsigned int";
35  case ECPGt_long:
36  return "long";
38  return "unsigned long";
39  case ECPGt_long_long:
40  return "long long";
42  return "unsigned long long";
43  case ECPGt_float:
44  return "float";
45  case ECPGt_double:
46  return "double";
47  case ECPGt_bool:
48  return "bool";
49  case ECPGt_varchar:
50  return "varchar";
52  return "char";
53  case ECPGt_decimal:
54  return "decimal";
55  case ECPGt_numeric:
56  return "numeric";
57  case ECPGt_date:
58  return "date";
59  case ECPGt_timestamp:
60  return "timestamp";
61  case ECPGt_interval:
62  return "interval";
63  case ECPGt_const:
64  return "Const";
65  default:
66  abort();
67  }
68  return ""; /* keep MSC compiler happy */
69 }

◆ sqlda_dynamic_type()

int sqlda_dynamic_type ( Oid  type,
enum COMPAT_MODE  compat 
)

Definition at line 106 of file typename.c.

References ECPGt_char, ECPGt_date, ECPGt_decimal, ECPGt_double, ECPGt_float, ECPGt_int, ECPGt_interval, ECPGt_long, ECPGt_long_long, ECPGt_numeric, ECPGt_short, ECPGt_timestamp, and INFORMIX_MODE.

Referenced by ecpg_build_compat_sqlda(), ecpg_build_native_sqlda(), and sqlda_common_total_size().

107 {
108  switch (type)
109  {
110  case CHAROID:
111  case VARCHAROID:
112  case BPCHAROID:
113  case TEXTOID:
114  return ECPGt_char;
115  case INT2OID:
116  return ECPGt_short;
117  case INT4OID:
118  return ECPGt_int;
119  case FLOAT8OID:
120  return ECPGt_double;
121  case FLOAT4OID:
122  return ECPGt_float;
123  case NUMERICOID:
125  case DATEOID:
126  return ECPGt_date;
127  case TIMESTAMPOID:
128  case TIMESTAMPTZOID:
129  return ECPGt_timestamp;
130  case INTERVALOID:
131  return ECPGt_interval;
132  case INT8OID:
133 #ifdef HAVE_LONG_LONG_INT_64
134  return ECPGt_long_long;
135 #endif
136 #ifdef HAVE_LONG_INT_64
137  return ECPGt_long;
138 #endif
139  /* Unhandled types always return a string */
140  default:
141  return ECPGt_char;
142  }
143 }
#define INFORMIX_MODE(X)
Definition: extern.h:23
enum COMPAT_MODE compat
Definition: ecpg.c:25