Version: 1.0.0
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 
15 {
16  m_pInterface = pInterface;
17  m_pResult = pResult;
18 }
19 
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 
61 {
62  return m_pInterface->GetPQfsize()(m_pResult, i-1);
63 }
64 
66 {
67  wxString columnName = ConvertFromUnicodeStream(m_pInterface->GetPQfname()(m_pResult, i-1));
68  return columnName;
69 }
70 
72 {
74 }
75 
76 #endif//wxUSE_DATABASE_POSTGRESQL
77 
virtual wxString GetColumnName(int i)
Retrieve a column's name.
virtual int GetColumnCount()
Retrieve the number of columns in the result set.
wxPostgresResultSetMetaData(wxDynamicPostgresInterface *pInterface, PGresult *pResult)
virtual wxString ConvertFromUnicodeStream(const char *inputBuffer)
wxDynamicPostgresInterface * m_pInterface
virtual int GetColumnType(int i)
Retrieve a column's type.
virtual int GetColumnSize(int i)
Retrieve a column's size.