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 "ecpglib_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 74 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().

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

◆ ecpg_type_name()

const char* ecpg_type_name ( enum ECPGttype  typ)

Definition at line 18 of file typename.c.

References ECPGt_bool, ECPGt_bytea, 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";
51  case ECPGt_bytea:
52  return "bytea";
54  return "char";
55  case ECPGt_decimal:
56  return "decimal";
57  case ECPGt_numeric:
58  return "numeric";
59  case ECPGt_date:
60  return "date";
61  case ECPGt_timestamp:
62  return "timestamp";
63  case ECPGt_interval:
64  return "interval";
65  case ECPGt_const:
66  return "Const";
67  default:
68  abort();
69  }
70  return ""; /* keep MSC compiler happy */
71 }

◆ sqlda_dynamic_type()

int sqlda_dynamic_type ( Oid  type,
enum COMPAT_MODE  compat 
)

Definition at line 108 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().

109 {
110  switch (type)
111  {
112  case CHAROID:
113  case VARCHAROID:
114  case BPCHAROID:
115  case TEXTOID:
116  return ECPGt_char;
117  case INT2OID:
118  return ECPGt_short;
119  case INT4OID:
120  return ECPGt_int;
121  case FLOAT8OID:
122  return ECPGt_double;
123  case FLOAT4OID:
124  return ECPGt_float;
125  case NUMERICOID:
127  case DATEOID:
128  return ECPGt_date;
129  case TIMESTAMPOID:
130  case TIMESTAMPTZOID:
131  return ECPGt_timestamp;
132  case INTERVALOID:
133  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  return ECPGt_long;
140 #endif
141  /* Unhandled types always return a string */
142  default:
143  return ECPGt_char;
144  }
145 }
#define INFORMIX_MODE(X)
enum COMPAT_MODE compat
Definition: ecpg.c:25