forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgreSQLTypes.cpp
More file actions
105 lines (89 loc) · 2.05 KB
/
PostgreSQLTypes.cpp
File metadata and controls
105 lines (89 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// PostgreSQLTypes.cpp
//
// Library: Data/PostgreSQL
// Package: PostgreSQL
// Module: PostgreSQLTypes
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SQL/PostgreSQL/PostgreSQLTypes.h"
namespace Poco {
namespace SQL {
namespace PostgreSQL {
Poco::SQL::MetaColumn::ColumnDataType oidToColumnDataType(const Oid anOID)
{
Poco::SQL::MetaColumn::ColumnDataType cdt = Poco::SQL::MetaColumn::FDT_UNKNOWN;
switch (anOID)
{
// bool
case BOOLOID:
cdt = Poco::SQL::MetaColumn::FDT_BOOL;
break;
// integers
case INT2OID:
cdt = Poco::SQL::MetaColumn::FDT_INT16;
break;
case INT4OID:
cdt = Poco::SQL::MetaColumn::FDT_INT32;
break;
case INT8OID:
cdt = Poco::SQL::MetaColumn::FDT_INT64;
break;
// floating point
case FLOAT8OID:
cdt = Poco::SQL::MetaColumn::FDT_DOUBLE;
break;
case FLOAT4OID:
// cdt = Poco::SQL::MetaColumn::FDT_FLOAT; This a bug in Poco::SQL as a 4 byte "float" can't be cast/ugraded to an 8 byte "double"
cdt = Poco::SQL::MetaColumn::FDT_DOUBLE;
break;
case NUMERICOID:
cdt = Poco::SQL::MetaColumn::FDT_DOUBLE;
break;
// character strings
case CHAROID:
cdt = Poco::SQL::MetaColumn::FDT_STRING;
break;
case BPCHAROID:
cdt = Poco::SQL::MetaColumn::FDT_STRING;
break;
case VARCHAROID:
cdt = Poco::SQL::MetaColumn::FDT_STRING;
break;
// BLOB, CLOB
case BYTEAOID:
cdt = Poco::SQL::MetaColumn::FDT_BLOB;
break;
case TEXTOID:
cdt = Poco::SQL::MetaColumn::FDT_CLOB;
break;
// date
case DATEOID:
cdt = Poco::SQL::MetaColumn::FDT_DATE;
break;
// time
case TIMEOID:
cdt = Poco::SQL::MetaColumn::FDT_TIME;
break;
case TIMETZOID:
cdt = Poco::SQL::MetaColumn::FDT_TIME;
break;
//timestamp
case TIMESTAMPOID:
cdt = Poco::SQL::MetaColumn::FDT_TIMESTAMP;
break;
case TIMESTAMPZOID:
cdt = Poco::SQL::MetaColumn::FDT_TIMESTAMP;
break;
// everything else is a string
default:
cdt = Poco::SQL::MetaColumn::FDT_STRING;
break;
}
return cdt;
}
} } } // namespace Poco::SQL::PostgreSQL