|
| 1 | +/* Copyright (C) 2021 MariaDB Corporation |
| 2 | +
|
| 3 | + This program is free software; you can redistribute it and/or modify |
| 4 | + it under the terms of the GNU General Public License as published by |
| 5 | + the Free Software Foundation; version 2 of the License. |
| 6 | +
|
| 7 | + This program is distributed in the hope that it will be useful, |
| 8 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | + GNU General Public License for more details. |
| 11 | +
|
| 12 | + You should have received a copy of the GNU General Public License |
| 13 | + along with this program; if not, write to the Free Software |
| 14 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ |
| 15 | + |
| 16 | +#if defined(MYSQL_SERVER) && !defined MYSQL_SERVICE_SQL |
| 17 | +#define MYSQL_SERVICE_SQL |
| 18 | + |
| 19 | +#include <mysql.h> |
| 20 | + |
| 21 | +/** |
| 22 | + @file |
| 23 | + SQL service |
| 24 | +
|
| 25 | + Interface for plugins to execute SQL queries on the local server. |
| 26 | +
|
| 27 | + Functions of the service are the 'server-limited' client library: |
| 28 | + mysql_init |
| 29 | + mysql_real_connect_local |
| 30 | + mysql_real_connect |
| 31 | + mysql_errno |
| 32 | + mysql_error |
| 33 | + mysql_real_query |
| 34 | + mysql_affected_rows |
| 35 | + mysql_num_rows |
| 36 | + mysql_store_result |
| 37 | + mysql_free_result |
| 38 | + mysql_fetch_row |
| 39 | + mysql_close |
| 40 | +*/ |
| 41 | + |
| 42 | + |
| 43 | +#ifdef __cplusplus |
| 44 | +extern "C" { |
| 45 | +#endif |
| 46 | + |
| 47 | +extern struct sql_service_st { |
| 48 | + MYSQL *(STDCALL *mysql_init)(MYSQL *mysql); |
| 49 | + MYSQL *(*mysql_real_connect_local)(MYSQL *mysql, |
| 50 | + const char *host, const char *user, const char *db, |
| 51 | + unsigned long clientflag); |
| 52 | + MYSQL *(STDCALL *mysql_real_connect)(MYSQL *mysql, const char *host, |
| 53 | + const char *user, const char *passwd, const char *db, unsigned int port, |
| 54 | + const char *unix_socket, unsigned long clientflag); |
| 55 | + unsigned int(STDCALL *mysql_errno)(MYSQL *mysql); |
| 56 | + const char *(STDCALL *mysql_error)(MYSQL *mysql); |
| 57 | + int (STDCALL *mysql_real_query)(MYSQL *mysql, const char *q, |
| 58 | + unsigned long length); |
| 59 | + my_ulonglong (STDCALL *mysql_affected_rows)(MYSQL *mysql); |
| 60 | + my_ulonglong (STDCALL *mysql_num_rows)(MYSQL_RES *res); |
| 61 | + MYSQL_RES *(STDCALL *mysql_store_result)(MYSQL *mysql); |
| 62 | + void (STDCALL *mysql_free_result)(MYSQL_RES *result); |
| 63 | + MYSQL_ROW (STDCALL *mysql_fetch_row)(MYSQL_RES *result); |
| 64 | + void (STDCALL *mysql_close)(MYSQL *sock); |
| 65 | +} *sql_service; |
| 66 | + |
| 67 | +#ifdef MYSQL_DYNAMIC_PLUGIN |
| 68 | + |
| 69 | +#define mysql_init sql_service->mysql_init |
| 70 | +#define mysql_real_connect_local sql_service->mysql_real_connect_local |
| 71 | +#define mysql_real_connect sql_service->mysql_real_connect |
| 72 | +#define mysql_errno(M) sql_service->mysql_errno(M) |
| 73 | +#define mysql_error(M) sql_service->mysql_error(M) |
| 74 | +#define mysql_real_query sql_service->mysql_real_query |
| 75 | +#define mysql_affected_rows sql_service->mysql_affected_rows |
| 76 | +#define mysql_num_rows sql_service->mysql_num_rows |
| 77 | +#define mysql_store_result sql_service->mysql_store_result |
| 78 | +#define mysql_free_result sql_service->mysql_free_result |
| 79 | +#define mysql_fetch_row sql_service->mysql_fetch_row |
| 80 | +#define mysql_close sql_service->mysql_close |
| 81 | + |
| 82 | +#else |
| 83 | + |
| 84 | +MYSQL *mysql_real_connect_local(MYSQL *mysql, |
| 85 | + const char *host, const char *user, const char *db, |
| 86 | + unsigned long clientflag); |
| 87 | + |
| 88 | +/* The rest of the function declarations mest be taken from the mysql.h */ |
| 89 | + |
| 90 | +#endif /*MYSQL_DYNAMIC_PLUGIN*/ |
| 91 | + |
| 92 | + |
| 93 | +#ifdef __cplusplus |
| 94 | +} |
| 95 | +#endif |
| 96 | + |
| 97 | +#endif /*MYSQL_SERVICE_SQL */ |
| 98 | + |
| 99 | + |
0 commit comments