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