Version: 1.0.0
src
database
postgresql
postgresql_resultset_metadata.cpp
Go to the documentation of this file.
1
#include "
wx/database/wxprec.h
"
2
3
#if wxUSE_DATABASE_POSTGRESQL
4
5
//#include "server/catalog/pg_type.h"
6
7
/*
8
SPECIAL NOTE:
9
The PQf* functions are 0-based, but the JDBC wxResultSetMetaData
10
functions are 1-based. To be consistent with the 1-based JDBC (and also
11
wxPreparedStatement paramters, we are using a 1-based system here.)
12
*/
13
14
wxPostgresResultSetMetaData::wxPostgresResultSetMetaData
(
wxDynamicPostgresInterface
* pInterface, PGresult* pResult)
15
{
16
m_pInterface
= pInterface;
17
m_pResult
= pResult;
18
}
19
20
int
wxPostgresResultSetMetaData::GetColumnType
(
int
i)
21
{
22
int
columnType =
m_pInterface
->
GetPQftype
()(
m_pResult
, i-1);
23
int
returnType =
COLUMN_UNKNOWN
;
24
switch
(columnType)
25
{
26
case
20:
//INT8OID:
27
case
21:
//INT2OID:
28
case
23:
//INT4OID:
29
case
26:
//OIDOID:
30
returnType =
COLUMN_INTEGER
;
31
break
;
32
case
16:
//BOOLOID:
33
returnType =
COLUMN_BOOL
;
34
break
;
35
case
1043:
//VARCHAROID:
36
case
25:
//TEXTOID:
37
case
2275:
//CSTRINGOID:
38
returnType =
COLUMN_STRING
;
39
break
;
40
case
700:
//FLOAT4OID:
41
case
701:
//FLOAT8OID:
42
returnType =
COLUMN_DOUBLE
;
43
break
;
44
case
17:
//BYTEAOID:
45
returnType =
COLUMN_BLOB
;
46
break
;
47
case
1082:
//DATEOID:
48
case
1083:
//TIMEOID:
49
case
1114:
//TIMESTAMPOID:
50
case
1184:
//TIMESTAMPTZOID:
51
returnType =
COLUMN_DATE
;
52
break
;
53
default
:
54
returnType =
COLUMN_UNKNOWN
;
55
break
;
56
};
57
return
returnType;
58
}
59
60
int
wxPostgresResultSetMetaData::GetColumnSize
(
int
i)
61
{
62
return
m_pInterface
->
GetPQfsize
()(
m_pResult
, i-1);
63
}
64
65
wxString
wxPostgresResultSetMetaData::GetColumnName
(
int
i)
66
{
67
wxString columnName =
ConvertFromUnicodeStream
(
m_pInterface
->
GetPQfname
()(
m_pResult
, i-1));
68
return
columnName;
69
}
70
71
int
wxPostgresResultSetMetaData::GetColumnCount
()
72
{
73
return
m_pInterface
->
GetPQnfields
()(
m_pResult
);
74
}
75
76
#endif//wxUSE_DATABASE_POSTGRESQL
77
wxprec.h
wxPostgresResultSetMetaData::GetColumnName
virtual wxString GetColumnName(int i)
Retrieve a column's name.
wxResultSetMetaData::COLUMN_INTEGER
Definition:
resultset_metadata.h:21
wxPostgresResultSetMetaData::GetColumnCount
virtual int GetColumnCount()
Retrieve the number of columns in the result set.
wxPostgresResultSetMetaData::m_pResult
PGresult * m_pResult
Definition:
postgresql_resultset_metadata.h:22
wxResultSetMetaData::COLUMN_STRING
Definition:
resultset_metadata.h:22
wxDynamicPostgresInterface
Definition:
postgresql_interface.h:37
wxResultSetMetaData::COLUMN_DATE
Definition:
resultset_metadata.h:26
wxResultSetMetaData::COLUMN_DOUBLE
Definition:
resultset_metadata.h:23
wxResultSetMetaData::COLUMN_BLOB
Definition:
resultset_metadata.h:25
wxPostgresResultSetMetaData::wxPostgresResultSetMetaData
wxPostgresResultSetMetaData(wxDynamicPostgresInterface *pInterface, PGresult *pResult)
wxResultSetMetaData::COLUMN_UNKNOWN
Definition:
resultset_metadata.h:19
wxDynamicPostgresInterface::GetPQfname
PQfnameType GetPQfname()
Definition:
postgresql_interface.h:59
wxDynamicPostgresInterface::GetPQfsize
PQfsizeType GetPQfsize()
Definition:
postgresql_interface.h:66
wxDatabaseStringConverter::ConvertFromUnicodeStream
virtual wxString ConvertFromUnicodeStream(const char *inputBuffer)
Definition:
string_converter.cpp:61
wxDynamicPostgresInterface::GetPQftype
PQftypeType GetPQftype()
Definition:
postgresql_interface.h:65
wxPostgresResultSetMetaData::m_pInterface
wxDynamicPostgresInterface * m_pInterface
Definition:
postgresql_resultset_metadata.h:21
wxPostgresResultSetMetaData::GetColumnType
virtual int GetColumnType(int i)
Retrieve a column's type.
wxResultSetMetaData::COLUMN_BOOL
Definition:
resultset_metadata.h:24
wxPostgresResultSetMetaData::GetColumnSize
virtual int GetColumnSize(int i)
Retrieve a column's size.
wxDynamicPostgresInterface::GetPQnfields
PQnfieldsType GetPQnfields()
Definition:
postgresql_interface.h:67
Generated on Mon Aug 19 2019 16:14:37 for wxDatabase by
Doxygen
1.8.15