Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Functions

typename.c File Reference

#include "postgres_fe.h"
#include <stdlib.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.

Defines

#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)

Define Documentation

#define POSTGRES_ECPG_INTERNAL

Definition at line 3 of file typename.c.


Function Documentation

int ecpg_dynamic_type ( Oid  type  ) 

Definition at line 72 of file typename.c.

References BOOLOID, BPCHAROID, DATEOID, FLOAT4OID, FLOAT8OID, INT2OID, INT4OID, NUMERICOID, TEXTOID, TIMEOID, TIMESTAMPOID, and VARCHAROID.

Referenced by ecpg_is_type_an_array(), and ECPGget_desc().

{
    switch (type)
    {
        case BOOLOID:
            return SQL3_BOOLEAN;    /* bool */
        case INT2OID:
            return SQL3_SMALLINT;       /* int2 */
        case INT4OID:
            return SQL3_INTEGER;    /* int4 */
        case TEXTOID:
            return SQL3_CHARACTER;      /* text */
        case FLOAT4OID:
            return SQL3_REAL;   /* float4 */
        case FLOAT8OID:
            return SQL3_DOUBLE_PRECISION;       /* float8 */
        case BPCHAROID:
            return SQL3_CHARACTER;      /* bpchar */
        case VARCHAROID:
            return SQL3_CHARACTER_VARYING;      /* varchar */
        case DATEOID:
            return SQL3_DATE_TIME_TIMESTAMP;    /* date */
        case TIMEOID:
            return SQL3_DATE_TIME_TIMESTAMP;    /* time */
        case TIMESTAMPOID:
            return SQL3_DATE_TIME_TIMESTAMP;    /* datetime */
        case NUMERICOID:
            return SQL3_NUMERIC;    /* numeric */
        default:
            return 0;
    }
}

const char* ecpg_type_name ( enum ECPGttype  typ  ) 

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

{
    switch (typ)
    {
        case ECPGt_char:
        case ECPGt_string:
            return "char";
        case ECPGt_unsigned_char:
            return "unsigned char";
        case ECPGt_short:
            return "short";
        case ECPGt_unsigned_short:
            return "unsigned short";
        case ECPGt_int:
            return "int";
        case ECPGt_unsigned_int:
            return "unsigned int";
        case ECPGt_long:
            return "long";
        case ECPGt_unsigned_long:
            return "unsigned long";
        case ECPGt_long_long:
            return "long long";
        case ECPGt_unsigned_long_long:
            return "unsigned long long";
        case ECPGt_float:
            return "float";
        case ECPGt_double:
            return "double";
        case ECPGt_bool:
            return "bool";
        case ECPGt_varchar:
            return "varchar";
        case ECPGt_char_variable:
            return "char";
        case ECPGt_decimal:
            return "decimal";
        case ECPGt_numeric:
            return "numeric";
        case ECPGt_date:
            return "date";
        case ECPGt_timestamp:
            return "timestamp";
        case ECPGt_interval:
            return "interval";
        case ECPGt_const:
            return "Const";
        default:
            abort();
    }
    return ""; /* keep MSC compiler happy */
}

int sqlda_dynamic_type ( Oid  type,
enum COMPAT_MODE  compat 
)

Definition at line 106 of file typename.c.

References BPCHAROID, CHAROID, DATEOID, ECPGt_decimal, 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().

{
    switch (type)
    {
        case CHAROID:
        case VARCHAROID:
        case BPCHAROID:
        case TEXTOID:
            return ECPGt_char;
        case INT2OID:
            return ECPGt_short;
        case INT4OID:
            return ECPGt_int;
        case FLOAT8OID:
            return ECPGt_double;
        case FLOAT4OID:
            return ECPGt_float;
        case NUMERICOID:
            return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
        case DATEOID:
            return ECPGt_date;
        case TIMESTAMPOID:
        case TIMESTAMPTZOID:
            return ECPGt_timestamp;
        case INTERVALOID:
            return ECPGt_interval;
        case INT8OID:
#ifdef HAVE_LONG_LONG_INT_64
            return ECPGt_long_long;
#endif
#ifdef HAVE_LONG_INT_64
            return ECPGt_long;
#endif
            /* Unhandled types always return a string */
        default:
            return ECPGt_char;
    }
}