PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
typename.c File Reference
#include "postgres_fe.h"
#include "catalog/pg_type_d.h"
#include "ecpglib.h"
#include "ecpglib_extern.h"
#include "ecpgtype.h"
#include "sql3types.h"
#include "sqltypes.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 73 of file typename.c.

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

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

Referenced by ecpg_is_type_an_array(), and ECPGget_desc().

◆ ecpg_type_name()

const char * ecpg_type_name ( enum ECPGttype  typ)

Definition at line 17 of file typename.c.

18{
19 switch (typ)
20 {
21 case ECPGt_char:
22 case ECPGt_string:
23 return "char";
25 return "unsigned char";
26 case ECPGt_short:
27 return "short";
29 return "unsigned short";
30 case ECPGt_int:
31 return "int";
33 return "unsigned int";
34 case ECPGt_long:
35 return "long";
37 return "unsigned long";
38 case ECPGt_long_long:
39 return "long long";
41 return "unsigned long long";
42 case ECPGt_float:
43 return "float";
44 case ECPGt_double:
45 return "double";
46 case ECPGt_bool:
47 return "bool";
48 case ECPGt_varchar:
49 return "varchar";
50 case ECPGt_bytea:
51 return "bytea";
53 return "char";
54 case ECPGt_decimal:
55 return "decimal";
56 case ECPGt_numeric:
57 return "numeric";
58 case ECPGt_date:
59 return "date";
60 case ECPGt_timestamp:
61 return "timestamp";
62 case ECPGt_interval:
63 return "interval";
64 case ECPGt_const:
65 return "Const";
66 default:
67 abort();
68 }
69 return ""; /* keep MSC compiler happy */
70}
@ ECPGt_float
Definition: ecpgtype.h:47
@ ECPGt_long_long
Definition: ecpgtype.h:45
@ ECPGt_short
Definition: ecpgtype.h:43
@ ECPGt_decimal
Definition: ecpgtype.h:51
@ ECPGt_char_variable
Definition: ecpgtype.h:60
@ ECPGt_bytea
Definition: ecpgtype.h:67
@ ECPGt_numeric
Definition: ecpgtype.h:49
@ ECPGt_varchar
Definition: ecpgtype.h:48
@ ECPGt_timestamp
Definition: ecpgtype.h:54
@ ECPGt_unsigned_short
Definition: ecpgtype.h:43
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_long
Definition: ecpgtype.h:44
@ ECPGt_unsigned_char
Definition: ecpgtype.h:43
@ ECPGt_double
Definition: ecpgtype.h:47
@ ECPGt_date
Definition: ecpgtype.h:53
@ ECPGt_interval
Definition: ecpgtype.h:55
@ ECPGt_unsigned_long
Definition: ecpgtype.h:44
@ ECPGt_const
Definition: ecpgtype.h:61
@ ECPGt_bool
Definition: ecpgtype.h:46
@ ECPGt_unsigned_long_long
Definition: ecpgtype.h:45
@ ECPGt_unsigned_int
Definition: ecpgtype.h:44
@ ECPGt_char
Definition: ecpgtype.h:43
@ ECPGt_string
Definition: ecpgtype.h:65

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().

◆ sqlda_dynamic_type()

int sqlda_dynamic_type ( Oid  type,
enum COMPAT_MODE  compat 
)

Definition at line 107 of file typename.c.

108{
109 switch (type)
110 {
111 case CHAROID:
112 case VARCHAROID:
113 case BPCHAROID:
114 case TEXTOID:
115 return ECPGt_char;
116 case INT2OID:
117 return ECPGt_short;
118 case INT4OID:
119 return ECPGt_int;
120 case FLOAT8OID:
121 return ECPGt_double;
122 case FLOAT4OID:
123 return ECPGt_float;
124 case NUMERICOID:
126 case DATEOID:
127 return ECPGt_date;
128 case TIMESTAMPOID:
129 case TIMESTAMPTZOID:
130 return ECPGt_timestamp;
131 case INTERVALOID:
132 return ECPGt_interval;
133 case INT8OID:
134#if SIZEOF_LONG == 8
135 return ECPGt_long;
136#elif SIZEOF_LONG_LONG == 8
137 return ECPGt_long_long;
138#else
139#error "cannot find integer type of the same size as INT8OID"
140#endif
141 /* Unhandled types always return a string */
142 default:
143 return ECPGt_char;
144 }
145}
enum COMPAT_MODE compat
Definition: ecpg.c:26
#define INFORMIX_MODE(X)

References compat, 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, INFORMIX_MODE, and type.

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