PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
typename.c File Reference
#include "postgres_fe.h"
#include "ecpgtype.h"
#include "ecpglib.h"
#include "extern.h"
#include "sqltypes.h"
#include "sql3types.h"
#include "pg_type.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

#define POSTGRES_ECPG_INTERNAL

Definition at line 3 of file typename.c.

Function Documentation

int ecpg_dynamic_type ( Oid  type)

Definition at line 71 of file typename.c.

References BOOLOID, BPCHAROID, DATEOID, FLOAT4OID, FLOAT8OID, INT2OID, INT4OID, NUMERICOID, SQL3_BOOLEAN, SQL3_CHARACTER, SQL3_CHARACTER_VARYING, SQL3_DATE_TIME_TIMESTAMP, SQL3_DOUBLE_PRECISION, SQL3_INTEGER, SQL3_NUMERIC, SQL3_REAL, SQL3_SMALLINT, TEXTOID, TIMEOID, TIMESTAMPOID, and VARCHAROID.

Referenced by ecpg_is_type_an_array(), and ECPGget_desc().

72 {
73  switch (type)
74  {
75  case BOOLOID:
76  return SQL3_BOOLEAN; /* bool */
77  case INT2OID:
78  return SQL3_SMALLINT; /* int2 */
79  case INT4OID:
80  return SQL3_INTEGER; /* int4 */
81  case TEXTOID:
82  return SQL3_CHARACTER; /* text */
83  case FLOAT4OID:
84  return SQL3_REAL; /* float4 */
85  case FLOAT8OID:
86  return SQL3_DOUBLE_PRECISION; /* float8 */
87  case BPCHAROID:
88  return SQL3_CHARACTER; /* bpchar */
89  case VARCHAROID:
90  return SQL3_CHARACTER_VARYING; /* varchar */
91  case DATEOID:
92  return SQL3_DATE_TIME_TIMESTAMP; /* date */
93  case TIMEOID:
94  return SQL3_DATE_TIME_TIMESTAMP; /* time */
95  case TIMESTAMPOID:
96  return SQL3_DATE_TIME_TIMESTAMP; /* datetime */
97  case NUMERICOID:
98  return SQL3_NUMERIC; /* numeric */
99  default:
100  return 0;
101  }
102 }
#define TIMEOID
Definition: pg_type.h:502
#define BPCHAROID
Definition: pg_type.h:492
#define DATEOID
Definition: pg_type.h:499
#define TEXTOID
Definition: pg_type.h:324
#define NUMERICOID
Definition: pg_type.h:542
#define INT4OID
Definition: pg_type.h:316
#define TIMESTAMPOID
Definition: pg_type.h:507
#define INT2OID
Definition: pg_type.h:308
#define VARCHAROID
Definition: pg_type.h:495
#define FLOAT4OID
Definition: pg_type.h:408
#define FLOAT8OID
Definition: pg_type.h:411
#define BOOLOID
Definition: pg_type.h:288
const char* ecpg_type_name ( enum ECPGttype  typ)

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

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";
32  case ECPGt_unsigned_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";
51  return "char";
52  case ECPGt_decimal:
53  return "decimal";
54  case ECPGt_numeric:
55  return "numeric";
56  case ECPGt_date:
57  return "date";
58  case ECPGt_timestamp:
59  return "timestamp";
60  case ECPGt_interval:
61  return "interval";
62  case ECPGt_const:
63  return "Const";
64  default:
65  abort();
66  }
67  return ""; /* keep MSC compiler happy */
68 }
int sqlda_dynamic_type ( Oid  type,
enum COMPAT_MODE  compat 
)

Definition at line 105 of file typename.c.

References BPCHAROID, CHAROID, DATEOID, 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, FLOAT4OID, FLOAT8OID, INFORMIX_MODE, INT2OID, INT4OID, INT8OID, INTERVALOID, NUMERICOID, TEXTOID, TIMESTAMPOID, TIMESTAMPTZOID, and VARCHAROID.

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

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