~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/interfaces/ecpg/ecpglib/typename.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.10 2003-11-29 19:52:08 pgsql Exp $ */
 
2
 
 
3
#define POSTGRES_ECPG_INTERNAL
 
4
#include "postgres_fe.h"
 
5
 
 
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"
 
12
 
 
13
/*
 
14
 * This function is used to generate the correct type names.
 
15
 */
 
16
const char *
 
17
ECPGtype_name(enum ECPGttype typ)
 
18
{
 
19
        switch (typ)
 
20
        {
 
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();
 
65
        }
 
66
        return NULL;
 
67
}
 
68
 
 
69
unsigned int
 
70
ECPGDynamicType(Oid type)
 
71
{
 
72
        switch (type)
 
73
        {
 
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 -type;
 
100
        }
 
101
}