1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "mysql_shim/mysqlinterface.hpp"
5 using namespace icinga;
7 struct MysqlInterfaceImpl final : public MysqlInterface
9 void Destroy() override
14 my_ulonglong affected_rows(MYSQL *mysql) const override
16 return mysql_affected_rows(mysql);
19 void close(MYSQL *sock) const override
21 return mysql_close(sock);
24 const char *error(MYSQL *mysql) const override
26 return mysql_error(mysql);
29 MYSQL_FIELD *fetch_field(MYSQL_RES *result) const override
31 return mysql_fetch_field(result);
34 unsigned long *fetch_lengths(MYSQL_RES *result) const override
36 return mysql_fetch_lengths(result);
39 MYSQL_ROW fetch_row(MYSQL_RES *result) const override
41 return mysql_fetch_row(result);
44 unsigned int field_count(MYSQL *mysql) const override
46 return mysql_field_count(mysql);
49 MYSQL_FIELD_OFFSET field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset) const override
51 return mysql_field_seek(result, offset);
54 void free_result(MYSQL_RES *result) const override
56 mysql_free_result(result);
59 MYSQL *init(MYSQL *mysql) const override
61 return mysql_init(mysql);
64 my_ulonglong insert_id(MYSQL *mysql) const override
66 return mysql_insert_id(mysql);
69 int next_result(MYSQL *mysql) const override
71 return mysql_next_result(mysql);
74 int ping(MYSQL *mysql) const override
76 return mysql_ping(mysql);
79 int query(MYSQL *mysql, const char *q) const override
81 return mysql_query(mysql, q);
84 MYSQL *real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd,
85 const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag) const override
87 return mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag);
90 unsigned long real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned long length) const override
92 return mysql_real_escape_string(mysql, to, from, length);
95 my_bool ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher) const override
97 return mysql_ssl_set(mysql, key, cert, ca, capath, cipher);
100 MYSQL_RES *store_result(MYSQL *mysql) const override
102 return mysql_store_result(mysql);
105 unsigned int thread_safe() const override
107 return mysql_thread_safe();
111 MysqlInterface *create_mysql_shim()
113 return new MysqlInterfaceImpl();