Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / interfaces / ecpg / ecpglib / typename.c
blob09be08d70adfaf967259433595b033935b1c6836
1 /* $PostgreSQL$ */
3 #define POSTGRES_ECPG_INTERNAL
4 #include "postgres_fe.h"
6 #include <stdlib.h>
7 #include "ecpgtype.h"
8 #include "ecpglib.h"
9 #include "extern.h"
10 #include "sql3types.h"
11 #include "pg_type.h"
14 * This function is used to generate the correct type names.
16 const char *
17 ecpg_type_name(enum ECPGttype typ)
19 switch (typ)
21 case ECPGt_char:
22 return "char";
23 case ECPGt_unsigned_char:
24 return "unsigned char";
25 case ECPGt_short:
26 return "short";
27 case ECPGt_unsigned_short:
28 return "unsigned short";
29 case ECPGt_int:
30 return "int";
31 case ECPGt_unsigned_int:
32 return "unsigned int";
33 case ECPGt_long:
34 return "long";
35 case ECPGt_unsigned_long:
36 return "unsigned long";
37 case ECPGt_long_long:
38 return "long long";
39 case ECPGt_unsigned_long_long:
40 return "unsigned long long";
41 case ECPGt_float:
42 return "float";
43 case ECPGt_double:
44 return "double";
45 case ECPGt_bool:
46 return "bool";
47 case ECPGt_varchar:
48 return "varchar";
49 case ECPGt_char_variable:
50 return "char";
51 case ECPGt_decimal:
52 return "decimal";
53 case ECPGt_numeric:
54 return "numeric";
55 case ECPGt_date:
56 return "date";
57 case ECPGt_timestamp:
58 return "timestamp";
59 case ECPGt_interval:
60 return "interval";
61 case ECPGt_const:
62 return "Const";
63 default:
64 abort();
66 return NULL;
69 int
70 ecpg_dynamic_type(Oid type)
72 switch (type)
74 case BOOLOID:
75 return SQL3_BOOLEAN; /* bool */
76 case INT2OID:
77 return SQL3_SMALLINT; /* int2 */
78 case INT4OID:
79 return SQL3_INTEGER; /* int4 */
80 case TEXTOID:
81 return SQL3_CHARACTER; /* text */
82 case FLOAT4OID:
83 return SQL3_REAL; /* float4 */
84 case FLOAT8OID:
85 return SQL3_DOUBLE_PRECISION; /* float8 */
86 case BPCHAROID:
87 return SQL3_CHARACTER; /* bpchar */
88 case VARCHAROID:
89 return SQL3_CHARACTER_VARYING; /* varchar */
90 case DATEOID:
91 return SQL3_DATE_TIME_TIMESTAMP; /* date */
92 case TIMEOID:
93 return SQL3_DATE_TIME_TIMESTAMP; /* time */
94 case TIMESTAMPOID:
95 return SQL3_DATE_TIME_TIMESTAMP; /* datetime */
96 case NUMERICOID:
97 return SQL3_NUMERIC; /* numeric */
98 default:
99 return -(int) type;