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
105
106
107
108
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#include "pgsql_shim/pgsqlinterface.hpp"
using namespace icinga;
struct PgsqlInterfaceImpl final : public PgsqlInterface
{
void Destroy() override
{
delete this;
}
void clear(PGresult *res) const override
{
PQclear(res);
}
char *cmdTuples(PGresult *res) const override
{
return PQcmdTuples(res);
}
char *errorMessage(const PGconn *conn) const override
{
return PQerrorMessage(conn);
}
size_t escapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error) const override
{
return PQescapeStringConn(conn, to, from, length, error);
}
PGresult *exec(PGconn *conn, const char *query) const override
{
return PQexec(conn, query);
}
void finish(PGconn *conn) const override
{
PQfinish(conn);
}
char *fname(const PGresult *res, int field_num) const override
{
return PQfname(res, field_num);
}
int getisnull(const PGresult *res, int tup_num, int field_num) const override
{
return PQgetisnull(res, tup_num, field_num);
}
char *getvalue(const PGresult *res, int tup_num, int field_num) const override
{
return PQgetvalue(res, tup_num, field_num);
}
int isthreadsafe() const override
{
return PQisthreadsafe();
}
int nfields(const PGresult *res) const override
{
return PQnfields(res);
}
int ntuples(const PGresult *res) const override
{
return PQntuples(res);
}
char *resultErrorMessage(const PGresult *res) const override
{
return PQresultErrorMessage(res);
}
ExecStatusType resultStatus(const PGresult *res) const override
{
return PQresultStatus(res);
}
int serverVersion(const PGconn *conn) const override
{
return PQserverVersion(conn);
}
PGconn *setdbLogin(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName, const char *login, const char *pwd) const override
{
return PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, login, pwd);
}
PGconn *connectdb(const char *conninfo) const override
{
return PQconnectdb(conninfo);
}
ConnStatusType status(const PGconn *conn) const override
{
return PQstatus(conn);
}
};
PgsqlInterface *create_pgsql_shim()
{
return new PgsqlInterfaceImpl();
}
|