1 #ifndef SQL_COMMON_INCLUDED 2 #define SQL_COMMON_INCLUDED 3 /* Copyright (c) 2003, 2018, Oracle and/or its affiliates. 4 Copyright (c) 2010, 2018, MariaDB 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; version 2 of the License. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #include <mysql.h> 24 #include <hash.h> 25 26 extern const char *unknown_sqlstate; 27 extern const char *cant_connect_sqlstate; 28 extern const char *not_error_sqlstate; 29 30 31 struct mysql_async_context; 32 33 struct st_mysql_options_extention { 34 char *plugin_dir; 35 char *default_auth; 36 char *ssl_crl; /* PEM CRL file */ 37 char *ssl_crlpath; /* PEM directory of CRL-s? */ 38 void (*report_progress)(const MYSQL *mysql, 39 unsigned int stage, 40 unsigned int max_stage, 41 double progress, 42 const char *proc_info, 43 uint proc_info_length); 44 struct mysql_async_context *async_context; 45 HASH connection_attributes; 46 size_t connection_attributes_length; 47 }; 48 49 typedef struct st_mysql_methods 50 { 51 my_bool (*read_query_result)(MYSQL *mysql); 52 my_bool (*advanced_command)(MYSQL *mysql, 53 enum enum_server_command command, 54 const unsigned char *header, 55 unsigned long header_length, 56 const unsigned char *arg, 57 unsigned long arg_length, 58 my_bool skip_check, 59 MYSQL_STMT *stmt); 60 MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, 61 unsigned int fields); 62 MYSQL_RES * (*use_result)(MYSQL *mysql); 63 void (*fetch_lengths)(unsigned long *to, 64 MYSQL_ROW column, unsigned int field_count); 65 void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results); 66 int (*read_change_user_result)(MYSQL *mysql); 67 #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) 68 MYSQL_FIELD * (*list_fields)(MYSQL *mysql); 69 my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); 70 int (*stmt_execute)(MYSQL_STMT *stmt); 71 int (*read_binary_rows)(MYSQL_STMT *stmt); 72 int (*unbuffered_fetch)(MYSQL *mysql, char **row); 73 void (*free_embedded_thd)(MYSQL *mysql); 74 const char *(*read_statistics)(MYSQL *mysql); 75 my_bool (*next_result)(MYSQL *mysql); 76 int (*read_rows_from_cursor)(MYSQL_STMT *stmt); 77 #endif 78 } MYSQL_METHODS; 79 80 #ifdef LIBMARIADB 81 #define simple_command(mysql, command, arg, length, skip_check) ma_simple_command(mysql, command, (char *)arg, length, skip_check, NULL) 82 #else 83 #define simple_command(mysql, command, arg, length, skip_check) \ 84 (*(mysql)->methods->advanced_command)(mysql, command, 0, \ 85 0, arg, length, skip_check, NULL) 86 #endif 87 #define stmt_command(mysql, command, arg, length, stmt) \ 88 (*(mysql)->methods->advanced_command)(mysql, command, 0, \ 89 0, arg, length, 1, stmt) 90 91 extern CHARSET_INFO *default_client_charset_info; 92 MYSQL_FIELD *unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc, 93 uint fields, my_bool default_value, 94 uint server_capabilities); 95 void free_rows(MYSQL_DATA *cur); 96 void free_old_query(MYSQL *mysql); 97 void end_server(MYSQL *mysql); 98 my_bool mysql_reconnect(MYSQL *mysql); 99 void mysql_read_default_options(struct st_mysql_options *options, 100 const char *filename,const char *group); 101 my_bool 102 cli_advanced_command(MYSQL *mysql, enum enum_server_command command, 103 const unsigned char *header, ulong header_length, 104 const unsigned char *arg, ulong arg_length, 105 my_bool skip_check, MYSQL_STMT *stmt); 106 unsigned long cli_safe_read(MYSQL *mysql); 107 unsigned long cli_safe_read_reallen(MYSQL *mysql, ulong* reallen); 108 void net_clear_error(NET *net); 109 void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net); 110 void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate, 111 const char *err); 112 void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate); 113 void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate, 114 const char *format, ...); 115 116 /* client side of the pluggable authentication */ 117 struct st_vio; 118 struct st_plugin_vio_info; 119 void mpvio_info(struct st_vio *vio, struct st_plugin_vio_info *info); 120 int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, 121 const char *data_plugin, const char *db); 122 int mysql_client_plugin_init(); 123 void mysql_client_plugin_deinit(); 124 struct st_mysql_client_plugin; 125 extern struct st_mysql_client_plugin *mysql_client_builtins[]; 126 uchar * send_client_connect_attrs(MYSQL *mysql, uchar *buf); 127 128 /* Non-blocking client API. */ 129 void my_context_install_suspend_resume_hook(struct mysql_async_context *b, 130 void (*)(my_bool, void *), void *); 131 132 #ifdef __cplusplus 133 } 134 #endif 135 136 #define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41) 137 138 #endif /* SQL_COMMON_INCLUDED */ 139