diff options
Diffstat (limited to 'include')
35 files changed, 788 insertions, 310 deletions
diff --git a/include/aria_backup.h b/include/aria_backup.h new file mode 100644 index 00000000000..1a1c437d0b9 --- /dev/null +++ b/include/aria_backup.h @@ -0,0 +1,37 @@ +/* Copyright (C) 2018 MariaDB corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + +/* Interfaces for doing backups of Aria tables */ + +C_MODE_START + +typedef struct st_aria_table_capabilities +{ + my_off_t header_size; + ulong bitmap_pages_covered; + uint block_size; + uint keypage_header; + my_bool checksum; + my_bool transactional; + /* This is true if the table can be copied without any locks */ + my_bool online_backup_safe; +} ARIA_TABLE_CAPABILITIES; + +int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap); +int aria_read_index(File kfile, ARIA_TABLE_CAPABILITIES *cap, ulonglong block, + uchar *buffer); +int aria_read_data(File dfile, ARIA_TABLE_CAPABILITIES *cap, ulonglong block, + uchar *buffer, size_t *bytes_read); +C_MODE_END diff --git a/include/json_lib.h b/include/json_lib.h index fed85b516d9..b6add6d13a3 100644 --- a/include/json_lib.h +++ b/include/json_lib.h @@ -174,11 +174,11 @@ enum json_value_types { JSON_VALUE_OBJECT=1, JSON_VALUE_ARRAY=2, - JSON_VALUE_STRING, - JSON_VALUE_NUMBER, - JSON_VALUE_TRUE, - JSON_VALUE_FALSE, - JSON_VALUE_NULL + JSON_VALUE_STRING=3, + JSON_VALUE_NUMBER=4, + JSON_VALUE_TRUE=5, + JSON_VALUE_FALSE=6, + JSON_VALUE_NULL=7 }; @@ -423,10 +423,15 @@ int json_path_parts_compare( int json_path_compare(const json_path_t *a, const json_path_t *b, enum json_value_types vt); +int json_valid(const char *js, size_t js_len, CHARSET_INFO *cs); + +int json_locate_key(const char *js, const char *js_end, + const char *kname, + const char **key_start, const char **key_end, + int *comma_pos); #ifdef __cplusplus } #endif #endif /* JSON_LIB_INCLUDED */ - diff --git a/include/lf.h b/include/lf.h index e4cad7eabb3..fa8c2d3570c 100644 --- a/include/lf.h +++ b/include/lf.h @@ -167,6 +167,8 @@ void *lf_hash_search_using_hash_value(LF_HASH *hash, LF_PINS *pins, int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen); int lf_hash_iterate(LF_HASH *hash, LF_PINS *pins, my_hash_walk_action action, void *argument); +#define lf_hash_size(hash) \ + my_atomic_load32_explicit(&(hash)->count, MY_MEMORY_ORDER_RELAXED) /* shortcut macros to access underlying pinbox functions from an LF_HASH see lf_pinbox_get_pins() and lf_pinbox_put_pins() diff --git a/include/m_ctype.h b/include/m_ctype.h index 1cdff1f54cc..0f6e6a11666 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -362,7 +362,6 @@ extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler; extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; extern MY_COLLATION_HANDLER my_collation_8bit_nopad_bin_handler; extern MY_COLLATION_HANDLER my_collation_8bit_simple_nopad_ci_handler; -extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; /* Some typedef to make it easy for C++ to make function pointers */ typedef int (*my_charset_conv_mb_wc)(CHARSET_INFO *, my_wc_t *, @@ -872,14 +871,6 @@ size_t my_strnxfrm_mb_nopad(CHARSET_INFO *, uchar *dst, size_t dstlen, uint nweights, const uchar *src, size_t srclen, uint flags); -size_t my_strnxfrm_unicode(CHARSET_INFO *, - uchar *dst, size_t dstlen, uint nweights, - const uchar *src, size_t srclen, uint flags); - -size_t my_strnxfrm_unicode_nopad(CHARSET_INFO *, - uchar *dst, size_t dstlen, uint nweights, - const uchar *src, size_t srclen, uint flags); - size_t my_strnxfrmlen_unicode(CHARSET_INFO *, size_t); size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *, diff --git a/include/m_string.h b/include/m_string.h index e967f140dc4..2747a9a7a9f 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -99,7 +99,7 @@ extern char *strmake(char *dst,const char *src,size_t length); #define strmake_buf(D,S) strmake(D, S, sizeof(D) - 1) #else #define strmake_buf(D,S) ({ \ - typeof (D) __x __attribute__((unused)) = { 2 }; \ + __typeof__ (D) __x __attribute__((unused)) = { 2 }; \ strmake(D, S, sizeof(D) - 1); \ }) #endif diff --git a/include/my_base.h b/include/my_base.h index 4c5b00649cc..68b3aaa6a13 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -99,7 +99,8 @@ enum ha_key_alg { HA_KEY_ALG_BTREE= 1, /* B-tree, default one */ HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */ HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */ - HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */ + HA_KEY_ALG_FULLTEXT= 4, /* FULLTEXT (MyISAM tables) */ + HA_KEY_ALG_LONG_HASH= 5 /* long BLOB keys */ }; /* Storage media types */ diff --git a/include/my_bit.h b/include/my_bit.h index 74469b5b899..7a408bd0535 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -122,6 +122,14 @@ static inline uint64 my_set_bits(int n) return (((1ULL << (n - 1)) - 1) << 1) | 1; } +/* Create a mask of the significant bits for the last byte (1,3,7,..255) */ +static inline uchar last_byte_mask(uint bits) +{ + /* Get the number of used bits-1 (0..7) in the last byte */ + unsigned int const used = (bits - 1U) & 7U; + /* Return bitmask for the significant bits */ + return ((2U << used) - 1); +} C_MODE_END #endif /* MY_BIT_INCLUDED */ diff --git a/include/my_compare.h b/include/my_compare.h index bd1a7bd1f34..6568e5f2f27 100644 --- a/include/my_compare.h +++ b/include/my_compare.h @@ -152,5 +152,6 @@ typedef enum icp_result { } ICP_RESULT; typedef ICP_RESULT (*index_cond_func_t)(void *param); +typedef int (*rowid_filter_func_t)(void *param); #endif /* _my_compare_h */ diff --git a/include/my_counter.h b/include/my_counter.h new file mode 100644 index 00000000000..c5cbe296df0 --- /dev/null +++ b/include/my_counter.h @@ -0,0 +1,49 @@ +#ifndef MY_COUNTER_H_INCLUDED +#define MY_COUNTER_H_INCLUDED +/* + Copyright (C) 2018 MariaDB Foundation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <atomic> + + +template <typename Type> class Atomic_counter +{ + std::atomic<Type> m_counter; + + Type add(Type i) { return m_counter.fetch_add(i, std::memory_order_relaxed); } + Type sub(Type i) { return m_counter.fetch_sub(i, std::memory_order_relaxed); } + +public: + Atomic_counter(const Atomic_counter<Type> &rhs) + { m_counter.store(rhs, std::memory_order_relaxed); } + Atomic_counter(Type val): m_counter(val) {} + Atomic_counter() {} + + Type operator++(int) { return add(1); } + Type operator--(int) { return sub(1); } + + Type operator++() { return add(1) + 1; } + Type operator--() { return sub(1) - 1; } + + Type operator+=(const Type i) { return add(i) + i; } + Type operator-=(const Type i) { return sub(i) - i; } + + operator Type() const { return m_counter.load(std::memory_order_relaxed); } + Type operator=(const Type val) + { m_counter.store(val, std::memory_order_relaxed); return val; } +}; +#endif /* MY_COUNTER_H_INCLUDED */ diff --git a/include/my_global.h b/include/my_global.h index da3ce121fb0..248320e301f 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -133,11 +133,6 @@ #define F_UNLCK 3 #define F_TO_EOF 0x3FFFFFFF -/* Shared memory and named pipe connections are supported. */ -#define HAVE_SMEM 1 -#define HAVE_NAMED_PIPE 1 -#define shared_memory_buffer_length 16000 -#define default_shared_memory_base_name "MYSQL" #endif /* _WIN32*/ @@ -994,7 +989,6 @@ typedef struct st_mysql_lex_string LEX_STRING; #if defined(__WIN__) #define socket_errno WSAGetLastError() #define SOCKET_EINTR WSAEINTR -#define SOCKET_EAGAIN WSAEINPROGRESS #define SOCKET_ETIMEDOUT WSAETIMEDOUT #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK #define SOCKET_EADDRINUSE WSAEADDRINUSE @@ -1189,8 +1183,6 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info; /* Things we don't need in the embedded version of MySQL */ /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ -#undef HAVE_SMEM /* No shared memory */ - #else #define HAVE_REPLICATION #define HAVE_EXTERNAL_CLIENT diff --git a/include/my_pthread.h b/include/my_pthread.h index 9802e43e97d..1b35d0fdd0d 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -191,7 +191,19 @@ extern int my_pthread_create_detached; int sigwait(sigset_t *set, int *sig); #endif -#define my_sigwait(A,B) sigwait((A),(B)) +static inline int my_sigwait(sigset_t *set, int *sig, int *code) +{ +#ifdef HAVE_SIGWAITINFO + siginfo_t siginfo; + *sig= sigwaitinfo(set, &siginfo); + *code= siginfo.si_code; + return *sig < 0 ? errno : 0; +#else +#define SI_KERNEL 128 + *code= 0; + return sigwait(set, sig); +#endif +} #if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK) #define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C)) diff --git a/include/my_sys.h b/include/my_sys.h index 3fc36bdd75b..f224431ce3f 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -104,13 +104,12 @@ typedef struct my_aio_result { #define MY_GIVE_INFO 2U /* Give time info about process*/ #define MY_DONT_FREE_DBUG 4U /* Do not call DBUG_END() in my_end() */ -#define ME_BELL 4U /* Ring bell then printing message */ -#define ME_WAITTANG 0 /* Wait for a user action */ -#define ME_NOREFRESH 64U /* Write the error message to error log */ -#define ME_NOINPUT 0 /* Don't use the input library */ -#define ME_JUST_INFO 1024U /**< not error but just info */ -#define ME_JUST_WARNING 2048U /**< not error but just warning */ -#define ME_FATALERROR 4096U /* Fatal statement error */ +#define ME_BELL 4U /* Ring bell then printing message */ +#define ME_ERROR_LOG 64 /**< write the error message to error log */ +#define ME_ERROR_LOG_ONLY 128 /**< write the error message to error log only */ +#define ME_NOTE 1024 /**< not error but just info */ +#define ME_WARNING 2048 /**< not error but just warning */ +#define ME_FATAL 4096 /**< fatal statement error */ /* Bits in last argument to fn_format */ #define MY_REPLACE_DIR 1U /* replace dir in name with 'dir' */ @@ -330,7 +329,7 @@ typedef struct st_record_cache /* Used when caching records */ enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, - FILE_BY_MKSTEMP, FILE_BY_DUP + FILE_BY_O_TMPFILE, FILE_BY_MKSTEMP, FILE_BY_DUP }; struct st_my_file_info @@ -908,6 +907,7 @@ static inline char *safe_strdup_root(MEM_ROOT *root, const char *str) } extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len); extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len); +extern LEX_CSTRING safe_lexcstrdup_root(MEM_ROOT *root, const LEX_CSTRING str); extern my_bool my_compress(uchar *, size_t *, size_t *); extern my_bool my_uncompress(uchar *, size_t , size_t *); extern uchar *my_compress_alloc(const uchar *packet, size_t *len, diff --git a/include/my_time.h b/include/my_time.h index e18e6eb1259..02e2b01efca 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -57,22 +57,20 @@ extern uchar days_in_month[]; /* Flags to str_to_datetime */ -/* - TIME_FUZZY_DATES is used for the result will only be used for comparison - purposes. Conversion is as relaxed as possible. -*/ -#define TIME_FUZZY_DATES 1U -#define TIME_DATETIME_ONLY 2U -#define TIME_TIME_ONLY 4U -#define TIME_NO_ZERO_IN_DATE (1UL << 23) /* == MODE_NO_ZERO_IN_DATE */ -#define TIME_NO_ZERO_DATE (1UL << 24) /* == MODE_NO_ZERO_DATE */ -#define TIME_INVALID_DATES (1UL << 25) /* == MODE_INVALID_DATES */ +#define C_TIME_NO_ZERO_IN_DATE (1UL << 23) /* == MODE_NO_ZERO_IN_DATE */ +#define C_TIME_NO_ZERO_DATE (1UL << 24) /* == MODE_NO_ZERO_DATE */ +#define C_TIME_INVALID_DATES (1UL << 25) /* == MODE_INVALID_DATES */ #define MYSQL_TIME_WARN_TRUNCATED 1U #define MYSQL_TIME_WARN_OUT_OF_RANGE 2U +#define MYSQL_TIME_WARN_EDOM 4U +#define MYSQL_TIME_WARN_ZERO_DATE 8U #define MYSQL_TIME_NOTE_TRUNCATED 16U -#define MYSQL_TIME_WARN_WARNINGS (MYSQL_TIME_WARN_TRUNCATED|MYSQL_TIME_WARN_OUT_OF_RANGE) +#define MYSQL_TIME_WARN_WARNINGS (MYSQL_TIME_WARN_TRUNCATED|\ + MYSQL_TIME_WARN_OUT_OF_RANGE|\ + MYSQL_TIME_WARN_EDOM|\ + MYSQL_TIME_WARN_ZERO_DATE) #define MYSQL_TIME_WARN_NOTES (MYSQL_TIME_NOTE_TRUNCATED) #define MYSQL_TIME_WARN_HAVE_WARNINGS(x) MY_TEST((x) & MYSQL_TIME_WARN_WARNINGS) @@ -81,6 +79,16 @@ extern uchar days_in_month[]; /* Useful constants */ #define SECONDS_IN_24H 86400L +/* Limits for the INTERVAL data type */ + + /* Number of hours between '0001-01-01 00h' and '9999-12-31 23h' */ +#define TIME_MAX_INTERVAL_HOUR 87649415 +#define TIME_MAX_INTERVAL_HOUR_CHAR_LENGTH 8 + +/* Number of full days between '0001-01-01' and '9999-12-31'*/ +#define TIME_MAX_INTERVAL_DAY 3652058 /*87649415/24*/ +#define TIME_MAX_INTERVAL_DAY_CHAR_LENGTH 7 + /* Limits for the TIME data type */ #define TIME_MAX_HOUR 838 #define TIME_MAX_MINUTE 59 @@ -100,35 +108,46 @@ typedef struct st_mysql_time_status { int warnings; uint precision; + uint nanoseconds; } MYSQL_TIME_STATUS; static inline void my_time_status_init(MYSQL_TIME_STATUS *status) { status->warnings= 0; status->precision= 0; + status->nanoseconds= 0; } my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, ulonglong flags, int *was_cut); -my_bool str_to_time(const char *str, size_t length, MYSQL_TIME *l_time, - ulonglong flag, MYSQL_TIME_STATUS *status); -my_bool str_to_datetime(const char *str, size_t length, MYSQL_TIME *l_time, - ulonglong flags, MYSQL_TIME_STATUS *status); -longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res, - ulonglong flags, int *was_cut); - -static inline -longlong double_to_datetime(double nr, MYSQL_TIME *ltime, ulonglong flags, int *cut) -{ - if (nr < 0 || nr > LONGLONG_MAX) - nr= (double)LONGLONG_MAX; - return number_to_datetime((longlong) floor(nr), - (ulong)((nr-floor(nr))*TIME_SECOND_PART_FACTOR), - ltime, flags, cut); -} +my_bool str_to_DDhhmmssff(const char *str, size_t length, MYSQL_TIME *l_time, + ulong max_hour, MYSQL_TIME_STATUS *status); +my_bool str_to_datetime_or_date_or_time(const char *str, size_t length, + MYSQL_TIME *to, ulonglong flag, + MYSQL_TIME_STATUS *status, + ulong time_max_hour, + ulong time_err_hour); +my_bool +str_to_datetime_or_date_or_interval_hhmmssff(const char *str, size_t length, + MYSQL_TIME *to, ulonglong flag, + MYSQL_TIME_STATUS *status, + ulong time_max_hour, + ulong time_err_hour); +my_bool +str_to_datetime_or_date_or_interval_day(const char *str, size_t length, + MYSQL_TIME *to, ulonglong flag, + MYSQL_TIME_STATUS *status, + ulong time_max_hour, + ulong time_err_hour); +my_bool str_to_datetime_or_date(const char *str, size_t length, MYSQL_TIME *to, + ulonglong flags, MYSQL_TIME_STATUS *status); + +longlong number_to_datetime_or_date(longlong nr, ulong sec_part, + MYSQL_TIME *time_res, + ulonglong flags, int *was_cut); +int number_to_time_only(my_bool neg, ulonglong nr, ulong sec_part, + ulong max_hour, MYSQL_TIME *to, int *was_cut); -int number_to_time(my_bool neg, ulonglong nr, ulong sec_part, - MYSQL_TIME *ltime, int *was_cut); ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *); ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *); ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *); @@ -191,6 +210,7 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type); #define MAX_DATE_STRING_REP_LENGTH 30 #define AUTO_SEC_PART_DIGITS DECIMAL_NOT_SPECIFIED +int my_interval_DDhhmmssff_to_str(const MYSQL_TIME *, char *to, uint digits); int my_time_to_str(const MYSQL_TIME *l_time, char *to, uint digits); int my_date_to_str(const MYSQL_TIME *l_time, char *to); int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits); diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index e084b6becec..484287db98d 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -75,7 +75,7 @@ typedef struct st_mysql_xid MYSQL_XID; #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104 /* MariaDB plugin interface version */ -#define MARIA_PLUGIN_INTERFACE_VERSION 0x010d +#define MARIA_PLUGIN_INTERFACE_VERSION 0x010e /* The allowable types of plugins diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 89f7dcc36c4..c5ae678e82a 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -374,6 +374,51 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); +enum json_types +{ + JSV_BAD_JSON=-1, + JSV_NOTHING=0, + JSV_OBJECT=1, + JSV_ARRAY=2, + JSV_STRING=3, + JSV_NUMBER=4, + JSV_TRUE=5, + JSV_FALSE=6, + JSV_NULL=7 +}; +extern struct json_service_st { + enum json_types (*json_type)(const char *js, const char *js_end, + const char **value, int *value_len); + enum json_types (*json_get_array_item)(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); + enum json_types (*json_get_object_key)(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); + enum json_types (*json_get_object_nkey)(const char *js,const char *js_end, + int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); + int (*json_escape_string)(const char *str,const char *str_end, + char *json, char *json_end); + int (*json_unescape_json)(const char *json_str, const char *json_end, + char *res, char *res_end); +} *json_service; +enum json_types json_type(const char *js, const char *js_end, + const char **value, int *value_len); +enum json_types json_get_array_item(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); +enum json_types json_get_object_key(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); +enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); +int json_escape_string(const char *str,const char *str_end, + char *json, char *json_end); +int json_unescape_json(const char *json_str, const char *json_end, + char *res, char *res_end); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_auth.h b/include/mysql/plugin_auth.h index 6741283d5bd..ae9c9368f15 100644 --- a/include/mysql/plugin_auth.h +++ b/include/mysql/plugin_auth.h @@ -27,7 +27,7 @@ #include <mysql/plugin.h> -#define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0201 +#define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0202 #include <mysql/plugin_auth_common.h> @@ -60,7 +60,8 @@ typedef struct st_mysql_server_auth_info /** A corresponding column value from the mysql.user table for the - matching account name + matching account name or the preprocessed value, if preprocess_hash + method is not NULL */ const char *auth_string; @@ -130,6 +131,47 @@ struct st_mysql_auth used for authorization. */ int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info); + /** + Create a password hash (or digest) out of a plain-text password + + Used in SET PASSWORD, GRANT, and CREATE USER to convert user specified + plain-text password into a value that will be stored in mysql.user table. + + @see preprocess_hash + + @param password plain-text password + @param password_length plain-text password length + @param hash the digest will be stored there + @param hash_length in: hash buffer size + out: the actual length of the hash + + @return 0 for ok, 1 for error + + Can be NULL. + */ + int (*hash_password)(const char *password, size_t password_length, + char *hash, size_t *hash_length); + + /** + Prepare the password hash for authentication. + + Password hash is stored in the authentication_string column of the + mysql.user table in a text form. If a plugin needs to preprocess the + value somehow before the authentication (e.g. convert from hex or base64 + to binary), it can do it in this method. This way the conversion + will happen only once, not for every authentication attempt. + + The value written to the out buffer will be cached and later made + available to the authenticate_user() method in the + MYSQL_SERVER_AUTH_INFO::auth_string[] buffer. + + @return 0 for ok, 1 for error + + Can be NULL, in this case the mysql.user.authentication_string value will + be given to the authenticate_user() method as is, unconverted. + */ + int (*preprocess_hash)(const char *hash, size_t hash_length, + unsigned char *out, size_t *out_length); }; #ifdef __cplusplus diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index e515699cad6..41cb7d075c4 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -374,6 +374,51 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); +enum json_types +{ + JSV_BAD_JSON=-1, + JSV_NOTHING=0, + JSV_OBJECT=1, + JSV_ARRAY=2, + JSV_STRING=3, + JSV_NUMBER=4, + JSV_TRUE=5, + JSV_FALSE=6, + JSV_NULL=7 +}; +extern struct json_service_st { + enum json_types (*json_type)(const char *js, const char *js_end, + const char **value, int *value_len); + enum json_types (*json_get_array_item)(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); + enum json_types (*json_get_object_key)(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); + enum json_types (*json_get_object_nkey)(const char *js,const char *js_end, + int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); + int (*json_escape_string)(const char *str,const char *str_end, + char *json, char *json_end); + int (*json_unescape_json)(const char *json_str, const char *json_end, + char *res, char *res_end); +} *json_service; +enum json_types json_type(const char *js, const char *js_end, + const char **value, int *value_len); +enum json_types json_get_array_item(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); +enum json_types json_get_object_key(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); +enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); +int json_escape_string(const char *str,const char *str_end, + char *json, char *json_end); +int json_unescape_json(const char *json_str, const char *json_end, + char *res, char *res_end); struct st_mysql_xid { long formatID; long gtrid_length; @@ -561,4 +606,8 @@ struct st_mysql_auth int interface_version; const char *client_auth_plugin; int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info); + int (*hash_password)(const char *password, size_t password_length, + char *hash, size_t *hash_length); + int (*preprocess_hash)(const char *hash, size_t hash_length, + unsigned char *out, size_t *out_length); }; diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index 7defe0aec2c..6597decfbef 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -374,6 +374,51 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); +enum json_types +{ + JSV_BAD_JSON=-1, + JSV_NOTHING=0, + JSV_OBJECT=1, + JSV_ARRAY=2, + JSV_STRING=3, + JSV_NUMBER=4, + JSV_TRUE=5, + JSV_FALSE=6, + JSV_NULL=7 +}; +extern struct json_service_st { + enum json_types (*json_type)(const char *js, const char *js_end, + const char **value, int *value_len); + enum json_types (*json_get_array_item)(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); + enum json_types (*json_get_object_key)(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); + enum json_types (*json_get_object_nkey)(const char *js,const char *js_end, + int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); + int (*json_escape_string)(const char *str,const char *str_end, + char *json, char *json_end); + int (*json_unescape_json)(const char *json_str, const char *json_end, + char *res, char *res_end); +} *json_service; +enum json_types json_type(const char *js, const char *js_end, + const char **value, int *value_len); +enum json_types json_get_array_item(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); +enum json_types json_get_object_key(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); +enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); +int json_escape_string(const char *str,const char *str_end, + char *json, char *json_end); +int json_unescape_json(const char *json_str, const char *json_end, + char *res, char *res_end); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index a36f51e74e1..bd1cfc7b68b 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -374,6 +374,51 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); +enum json_types +{ + JSV_BAD_JSON=-1, + JSV_NOTHING=0, + JSV_OBJECT=1, + JSV_ARRAY=2, + JSV_STRING=3, + JSV_NUMBER=4, + JSV_TRUE=5, + JSV_FALSE=6, + JSV_NULL=7 +}; +extern struct json_service_st { + enum json_types (*json_type)(const char *js, const char *js_end, + const char **value, int *value_len); + enum json_types (*json_get_array_item)(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); + enum json_types (*json_get_object_key)(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); + enum json_types (*json_get_object_nkey)(const char *js,const char *js_end, + int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); + int (*json_escape_string)(const char *str,const char *str_end, + char *json, char *json_end); + int (*json_unescape_json)(const char *json_str, const char *json_end, + char *res, char *res_end); +} *json_service; +enum json_types json_type(const char *js, const char *js_end, + const char **value, int *value_len); +enum json_types json_get_array_item(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); +enum json_types json_get_object_key(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); +enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); +int json_escape_string(const char *str,const char *str_end, + char *json, char *json_end); +int json_unescape_json(const char *json_str, const char *json_end, + char *res, char *res_end); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_password_validation.h b/include/mysql/plugin_password_validation.h index ddc9387c72e..23d2c884012 100644 --- a/include/mysql/plugin_password_validation.h +++ b/include/mysql/plugin_password_validation.h @@ -42,8 +42,8 @@ struct st_mariadb_password_validation Function provided by the plugin which should perform password validation and return 0 if the password has passed the validation. */ - int (*validate_password)(MYSQL_CONST_LEX_STRING *username, - MYSQL_CONST_LEX_STRING *password); + int (*validate_password)(const MYSQL_CONST_LEX_STRING *username, + const MYSQL_CONST_LEX_STRING *password); }; #ifdef __cplusplus diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 9701ad1b92f..2f9d2299c1f 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -374,6 +374,51 @@ extern struct thd_wait_service_st { } *thd_wait_service; void thd_wait_begin(void* thd, int wait_type); void thd_wait_end(void* thd); +enum json_types +{ + JSV_BAD_JSON=-1, + JSV_NOTHING=0, + JSV_OBJECT=1, + JSV_ARRAY=2, + JSV_STRING=3, + JSV_NUMBER=4, + JSV_TRUE=5, + JSV_FALSE=6, + JSV_NULL=7 +}; +extern struct json_service_st { + enum json_types (*json_type)(const char *js, const char *js_end, + const char **value, int *value_len); + enum json_types (*json_get_array_item)(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); + enum json_types (*json_get_object_key)(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); + enum json_types (*json_get_object_nkey)(const char *js,const char *js_end, + int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); + int (*json_escape_string)(const char *str,const char *str_end, + char *json, char *json_end); + int (*json_unescape_json)(const char *json_str, const char *json_end, + char *res, char *res_end); +} *json_service; +enum json_types json_type(const char *js, const char *js_end, + const char **value, int *value_len); +enum json_types json_get_array_item(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); +enum json_types json_get_object_key(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); +enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); +int json_escape_string(const char *str,const char *str_end, + char *json, char *json_end); +int json_unescape_json(const char *json_str, const char *json_end, + char *res, char *res_end); struct st_mysql_xid { long formatID; long gtrid_length; @@ -531,6 +576,6 @@ void thd_wakeup_subsequent_commits(void* thd, int wakeup_error); struct st_mariadb_password_validation { int interface_version; - int (*validate_password)(MYSQL_CONST_LEX_STRING *username, - MYSQL_CONST_LEX_STRING *password); + int (*validate_password)(const MYSQL_CONST_LEX_STRING *username, + const MYSQL_CONST_LEX_STRING *password); }; diff --git a/include/mysql/service_json.h b/include/mysql/service_json.h new file mode 100644 index 00000000000..141b76279a5 --- /dev/null +++ b/include/mysql/service_json.h @@ -0,0 +1,117 @@ +/* Copyright (C) 2018 MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + +#ifndef MYSQL_SERVICE_JSON +#define MYSQL_SERVICE_JSON + +/** + @file + json service + + Esports JSON parsing methods for plugins to use. + + Fuctions of the service: + js_type - returns the type of the JSON argument, + and the parsed value if it's scalar (not object or array) + + js_get_array_item - expecs JSON array as an argument, + and returns the n_item's item's type and value + Returns JSV_NOTHING type if the array is shorter + than n_item and the actual length of the array in v_len. + + js_get_object_key - expects JSON object as an argument, + searches for a key in the object, return it's type and value. + JSV_NOTHING if no such key found, the number of keys + in v_len. + + js_get_object_nkey - expects JSON object as an argument. + finds n_key's key in the object, returns it's name, type and value. + JSV_NOTHING if object has less keys than n_key. +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +enum json_types +{ + JSV_BAD_JSON=-1, + JSV_NOTHING=0, + JSV_OBJECT=1, + JSV_ARRAY=2, + JSV_STRING=3, + JSV_NUMBER=4, + JSV_TRUE=5, + JSV_FALSE=6, + JSV_NULL=7 +}; + +extern struct json_service_st { + enum json_types (*json_type)(const char *js, const char *js_end, + const char **value, int *value_len); + enum json_types (*json_get_array_item)(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); + enum json_types (*json_get_object_key)(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); + enum json_types (*json_get_object_nkey)(const char *js,const char *js_end, + int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); + int (*json_escape_string)(const char *str,const char *str_end, + char *json, char *json_end); + int (*json_unescape_json)(const char *json_str, const char *json_end, + char *res, char *res_end); +} *json_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define json_type json_service->json_type +#define json_get_array_item json_service->json_get_array_item +#define json_get_object_key json_service->json_get_object_key +#define json_get_object_nkey json_service->json_get_object_nkey +#define json_escape_string json_service->json_escape_string +#define json_unescape_json json_service->json_unescape_json + +#else + +enum json_types json_type(const char *js, const char *js_end, + const char **value, int *value_len); +enum json_types json_get_array_item(const char *js, const char *js_end, + int n_item, + const char **value, int *value_len); +enum json_types json_get_object_key(const char *js, const char *js_end, + const char *key, + const char **value, int *value_len); +enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, + const char **keyname, const char **keyname_end, + const char **value, int *value_len); +int json_escape_string(const char *str,const char *str_end, + char *json, char *json_end); +int json_unescape_json(const char *json_str, const char *json_end, + char *res, char *res_end); + +#endif /*MYSQL_DYNAMIC_PLUGIN*/ + + +#ifdef __cplusplus +} +#endif + +#endif /*MYSQL_SERVICE_JSON */ + + diff --git a/include/mysql/service_my_crypt.h b/include/mysql/service_my_crypt.h index de4a8bb69da..039125066ca 100644 --- a/include/mysql/service_my_crypt.h +++ b/include/mysql/service_my_crypt.h @@ -45,7 +45,7 @@ extern "C" { /* The max key length of all supported algorithms */ #define MY_AES_MAX_KEY_LENGTH 32 -#define MY_AES_CTX_SIZE 512 +#define MY_AES_CTX_SIZE 600 enum my_aes_mode { MY_AES_ECB, MY_AES_CBC diff --git a/include/mysql/service_my_print_error.h b/include/mysql/service_my_print_error.h index 64e875d83ca..e9af51c20cc 100644 --- a/include/mysql/service_my_print_error.h +++ b/include/mysql/service_my_print_error.h @@ -32,10 +32,11 @@ extern "C" { #include <stdlib.h> #endif -#define ME_ERROR_LOG 64 /* Write the message to the error log */ -#define ME_NOTE 1024 /* Not an error, just a note */ -#define ME_WARNING 2048 /* Not an error, just a warning */ -#define ME_FATAL 4096 /* Fatal statement error */ +#define ME_ERROR_LOG 64 /* Write the message to the error log */ +#define ME_ERROR_LOG_ONLY 128 /* Write the error message to error log only */ +#define ME_NOTE 1024 /* Not an error, just a note */ +#define ME_WARNING 2048 /* Not an error, just a warning */ +#define ME_FATAL 4096 /* Fatal statement error */ extern struct my_print_error_service_st { void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...); diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h index 31de4ff6e5d..e7ac5e159cf 100644 --- a/include/mysql/service_wsrep.h +++ b/include/mysql/service_wsrep.h @@ -1,5 +1,20 @@ #ifndef MYSQL_SERVICE_WSREP_INCLUDED +#define MYSQL_SERVICE_WSREP_INCLUDED + +enum Wsrep_service_key_type +{ + WSREP_SERVICE_KEY_SHARED, + WSREP_SERVICE_KEY_REFERENCE, + WSREP_SERVICE_KEY_UPDATE, + WSREP_SERVICE_KEY_EXCLUSIVE +}; + +#if (defined (MYSQL_DYNAMIC_PLUGIN) && defined(MYSQL_SERVICE_WSREP_DYNAMIC_INCLUDED)) || (!defined(MYSQL_DYNAMIC_PLUGIN) && defined(MYSQL_SERVICE_WSREP_STATIC_INCLUDED)) + +#else + /* Copyright (c) 2015 MariaDB Corporation Ab + 2018 Codership Oy <info@codership.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,162 +36,99 @@ Interface to WSREP functionality in the server. For engines that want to support galera. */ - +#include <my_pthread.h> #ifdef __cplusplus -extern "C" { #endif -enum wsrep_conflict_state { - NO_CONFLICT, - MUST_ABORT, - ABORTING, - ABORTED, - MUST_REPLAY, - REPLAYING, - RETRY_AUTOCOMMIT, - CERT_FAILURE, -}; - -enum wsrep_exec_mode { - /* Transaction processing before replication. */ - LOCAL_STATE, - /* Slave thread applying write sets from other nodes or replaying thread. */ - REPL_RECV, - /* Total-order-isolation mode. */ - TOTAL_ORDER, - /* - Transaction procession after it has been replicated in prepare stage and - has passed certification. - */ - LOCAL_COMMIT -}; - -enum wsrep_query_state { - QUERY_IDLE, - QUERY_EXEC, - QUERY_COMMITTING, - QUERY_EXITING, - QUERY_ROLLINGBACK, -}; - -enum wsrep_trx_status { - WSREP_TRX_OK, - WSREP_TRX_CERT_FAIL, /* certification failure, must abort */ - WSREP_TRX_SIZE_EXCEEDED, /* trx size exceeded */ - WSREP_TRX_ERROR, /* native mysql error */ -}; - struct xid_t; -struct wsrep; struct wsrep_ws_handle; struct wsrep_buf; +/* Must match to definition in sql/mysqld.h */ +typedef int64 query_id_t; + + extern struct wsrep_service_st { - struct wsrep * (*get_wsrep_func)(); - my_bool (*get_wsrep_certify_nonPK_func)(); - my_bool (*get_wsrep_debug_func)(); - my_bool (*get_wsrep_drupal_282555_workaround_func)(); my_bool (*get_wsrep_recovery_func)(); - my_bool (*get_wsrep_load_data_splitting_func)(); - my_bool (*get_wsrep_log_conflicts_func)(); - long (*get_wsrep_protocol_version_func)(); - my_bool (*wsrep_aborting_thd_contains_func)(THD *thd); - void (*wsrep_aborting_thd_enqueue_func)(THD *thd); - bool (*wsrep_consistency_check_func)(THD *thd); - int (*wsrep_is_wsrep_xid_func)(const struct xid_t *xid); + bool (*wsrep_consistency_check_func)(MYSQL_THD thd); + int (*wsrep_is_wsrep_xid_func)(const void *xid); long long (*wsrep_xid_seqno_func)(const struct xid_t *xid); const unsigned char* (*wsrep_xid_uuid_func)(const struct xid_t *xid); - void (*wsrep_lock_rollback_func)(); - int (*wsrep_on_func)(MYSQL_THD); - void (*wsrep_post_commit_func)(THD* thd, bool all); - bool (*wsrep_prepare_key_func)(const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*); - enum wsrep_trx_status (*wsrep_run_wsrep_commit_func)(THD *thd, bool all); - void (*wsrep_thd_LOCK_func)(THD *thd); - void (*wsrep_thd_UNLOCK_func)(THD *thd); - void (*wsrep_thd_awake_func)(THD *thd, my_bool signal); - enum wsrep_conflict_state (*wsrep_thd_conflict_state_func)(MYSQL_THD, my_bool); - const char * (*wsrep_thd_conflict_state_str_func)(THD *thd); - enum wsrep_exec_mode (*wsrep_thd_exec_mode_func)(THD *thd); - const char * (*wsrep_thd_exec_mode_str_func)(THD *thd); - enum wsrep_conflict_state (*wsrep_thd_get_conflict_state_func)(MYSQL_THD); - my_bool (*wsrep_thd_is_BF_func)(MYSQL_THD , my_bool); - my_bool (*wsrep_thd_is_wsrep_func)(MYSQL_THD thd); - char * (*wsrep_thd_query_func)(THD *thd); - enum wsrep_query_state (*wsrep_thd_query_state_func)(THD *thd); - const char * (*wsrep_thd_query_state_str_func)(THD *thd); - int (*wsrep_thd_retry_counter_func)(THD *thd); - void (*wsrep_thd_set_conflict_state_func)(THD *thd, enum wsrep_conflict_state state); - bool (*wsrep_thd_ignore_table_func)(THD *thd); - long long (*wsrep_thd_trx_seqno_func)(THD *thd); - struct wsrep_ws_handle * (*wsrep_thd_ws_handle_func)(THD *thd); + my_bool (*wsrep_on_func)(const MYSQL_THD thd); + bool (*wsrep_prepare_key_for_innodb_func)(MYSQL_THD thd, const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*); + void (*wsrep_thd_LOCK_func)(const MYSQL_THD thd); + void (*wsrep_thd_UNLOCK_func)(const MYSQL_THD thd); + const char * (*wsrep_thd_query_func)(const MYSQL_THD thd); + int (*wsrep_thd_retry_counter_func)(const MYSQL_THD thd); + bool (*wsrep_thd_ignore_table_func)(MYSQL_THD thd); + long long (*wsrep_thd_trx_seqno_func)(const MYSQL_THD thd); void (*wsrep_thd_auto_increment_variables_func)(THD *thd, unsigned long long *offset, unsigned long long *increment); - void (*wsrep_set_load_multi_commit_func)(THD *thd, bool split); - bool (*wsrep_is_load_multi_commit_func)(THD *thd); - int (*wsrep_trx_is_aborting_func)(MYSQL_THD thd); - int (*wsrep_trx_order_before_func)(MYSQL_THD, MYSQL_THD); - void (*wsrep_unlock_rollback_func)(); + my_bool (*wsrep_thd_is_aborting_func)(const MYSQL_THD thd); void (*wsrep_set_data_home_dir_func)(const char *data_dir); - my_bool (*wsrep_thd_is_applier_func)(MYSQL_THD); + my_bool (*wsrep_thd_is_BF_func)(const MYSQL_THD thd, my_bool sync); + my_bool (*wsrep_thd_is_local_func)(const MYSQL_THD thd); + void (*wsrep_thd_self_abort_func)(MYSQL_THD thd); + int (*wsrep_thd_append_key_func)(MYSQL_THD thd, const struct wsrep_key* key, + int n_keys, enum Wsrep_service_key_type); + const char* (*wsrep_thd_client_state_str_func)(const MYSQL_THD thd); + const char* (*wsrep_thd_client_mode_str_func)(const MYSQL_THD thd); + const char* (*wsrep_thd_transaction_state_str_func)(const MYSQL_THD thd); + query_id_t (*wsrep_thd_transaction_id_func)(const MYSQL_THD thd); + my_bool (*wsrep_thd_bf_abort_func)(const MYSQL_THD bf_thd, + MYSQL_THD victim_thd, + my_bool signal); + my_bool (*wsrep_thd_order_before_func)(const MYSQL_THD left, const MYSQL_THD right); + void (*wsrep_handle_SR_rollback_func)(MYSQL_THD BF_thd, MYSQL_THD victim_thd); + my_bool (*wsrep_thd_skip_locking_func)(const MYSQL_THD thd); + const char* (*wsrep_get_sr_table_name_func)(); + my_bool (*wsrep_get_debug_func)(); + void (*wsrep_commit_ordered_func)(MYSQL_THD thd); + my_bool (*wsrep_thd_is_applying_func)(const MYSQL_THD thd); } *wsrep_service; +#define MYSQL_SERVICE_WSREP_INCLUDED +#endif + #ifdef MYSQL_DYNAMIC_PLUGIN -#define get_wsrep() wsrep_service->get_wsrep_func() -#define get_wsrep_certify_nonPK() wsrep_service->get_wsrep_certify_nonPK_func() -#define get_wsrep_debug() wsrep_service->get_wsrep_debug_func() -#define get_wsrep_drupal_282555_workaround() wsrep_service->get_wsrep_drupal_282555_workaround_func() + +#define MYSQL_SERVICE_WSREP_DYNAMIC_INCLUDED #define get_wsrep_recovery() wsrep_service->get_wsrep_recovery_func() -#define get_wsrep_load_data_splitting() wsrep_service->get_wsrep_load_data_splitting_func() -#define get_wsrep_log_conflicts() wsrep_service->get_wsrep_log_conflicts_func() -#define get_wsrep_protocol_version() wsrep_service->get_wsrep_protocol_version_func() -#define wsrep_aborting_thd_contains(T) wsrep_service->wsrep_aborting_thd_contains_func(T) -#define wsrep_aborting_thd_enqueue(T) wsrep_service->wsrep_aborting_thd_enqueue_func(T) #define wsrep_consistency_check(T) wsrep_service->wsrep_consistency_check_func(T) #define wsrep_is_wsrep_xid(X) wsrep_service->wsrep_is_wsrep_xid_func(X) #define wsrep_xid_seqno(X) wsrep_service->wsrep_xid_seqno_func(X) #define wsrep_xid_uuid(X) wsrep_service->wsrep_xid_uuid_func(X) -#define wsrep_lock_rollback() wsrep_service->wsrep_lock_rollback_func() #define wsrep_on(X) wsrep_service->wsrep_on_func(X) -#define wsrep_post_commit(T,A) wsrep_service->wsrep_post_commit_func(T,A) -#define wsrep_prepare_key(A,B,C,D,E,F) wsrep_service->wsrep_prepare_key_func(A,B,C,D,E,F) -#define wsrep_run_wsrep_commit(T,A) wsrep_service->wsrep_run_wsrep_commit_func(T,A) +#define wsrep_prepare_key_for_innodb(A,B,C,D,E,F,G) wsrep_service->wsrep_prepare_key_for_innodb_func(A,B,C,D,E,F,G) #define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T) #define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T) -#define wsrep_thd_awake(T,S) wsrep_service->wsrep_thd_awake_func(T,S) -#define wsrep_thd_conflict_state(T,S) wsrep_service->wsrep_thd_conflict_state_func(T,S) -#define wsrep_thd_conflict_state_str(T) wsrep_service->wsrep_thd_conflict_state_str_func(T) -#define wsrep_thd_exec_mode(T) wsrep_service->wsrep_thd_exec_mode_func(T) -#define wsrep_thd_exec_mode_str(T) wsrep_service->wsrep_thd_exec_mode_str_func(T) -#define wsrep_thd_get_conflict_state(T) wsrep_service->wsrep_thd_get_conflict_state_func(T) -#define wsrep_thd_is_BF(T,S) wsrep_service->wsrep_thd_is_BF_func(T,S) -#define wsrep_thd_is_wsrep(T) wsrep_service->wsrep_thd_is_wsrep_func(T) #define wsrep_thd_query(T) wsrep_service->wsrep_thd_query_func(T) -#define wsrep_thd_query_state(T) wsrep_service->wsrep_thd_query_state_func(T) -#define wsrep_thd_query_state_str(T) wsrep_service->wsrep_thd_query_state_str_func(T) #define wsrep_thd_retry_counter(T) wsrep_service->wsrep_thd_retry_counter_func(T) -#define wsrep_thd_set_conflict_state(T,S) wsrep_service->wsrep_thd_set_conflict_state_func(T,S) #define wsrep_thd_ignore_table(T) wsrep_service->wsrep_thd_ignore_table_func(T) #define wsrep_thd_trx_seqno(T) wsrep_service->wsrep_thd_trx_seqno_func(T) -#define wsrep_thd_ws_handle(T) wsrep_service->wsrep_thd_ws_handle_func(T) #define wsrep_thd_auto_increment_variables(T,O,I) wsrep_service->wsrep_thd_auto_increment_variables_func(T,O,I) -#define wsrep_set_load_multi_commit(T,S) wsrep_service->wsrep_set_load_multi_commit_func(T,S) -#define wsrep_is_load_multi_commit(T) wsrep_service->wsrep_is_load_multi_commit_func(T) -#define wsrep_trx_is_aborting(T) wsrep_service->wsrep_trx_is_aborting_func(T) -#define wsrep_trx_order_before(T1,T2) wsrep_service->wsrep_trx_order_before_func(T1,T2) -#define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func() #define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A) -#define wsrep_thd_is_applier(T) wsrep_service->wsrep_thd_is_applier_func(T) - -#define wsrep_debug get_wsrep_debug() -#define wsrep_log_conflicts get_wsrep_log_conflicts() -#define wsrep_certify_nonPK get_wsrep_certify_nonPK() -#define wsrep_load_data_splitting get_wsrep_load_data_splitting() -#define wsrep_drupal_282555_workaround get_wsrep_drupal_282555_workaround() -#define wsrep_recovery get_wsrep_recovery() -#define wsrep_protocol_version get_wsrep_protocol_version() +#define wsrep_thd_is_BF(T,S) wsrep_service->wsrep_thd_is_BF_func(T,S) +#define wsrep_thd_is_aborting(T) wsrep_service->wsrep_thd_is_aborting_func(T) +#define wsrep_thd_is_local(T) wsrep_service->wsrep_thd_is_local_func(T) +#define wsrep_thd_self_abort(T) wsrep_service->wsrep_thd_self_abort_func(T) +#define wsrep_thd_append_key(T,W,N,K) wsrep_service->wsrep_thd_append_key_func(T,W,N,K) +#define wsrep_thd_client_state_str(T) wsrep_service->wsrep_thd_client_state_str_func(T) +#define wsrep_thd_client_mode_str(T) wsrep_service->wsrep_thd_client_mode_str_func(T) +#define wsrep_thd_transaction_state_str(T) wsrep_service->wsrep_thd_transaction_state_str_func(T) +#define wsrep_thd_transaction_id(T) wsrep_service->wsrep_thd_transaction_id_func(T) +#define wsrep_thd_bf_abort(T,T2,S) wsrep_service->wsrep_thd_bf_abort_func(T,T2,S) +#define wsrep_thd_order_before(L,R) wsrep_service->wsrep_thd_order_before_func(L,R) +#define wsrep_handle_SR_rollback(B,V) wsrep_service->wsrep_handle_SR_rollback_func(B,V) +#define wsrep_thd_skip_locking(T) wsrep_service->wsrep_thd_skip_locking_func(T) +#define wsrep_get_sr_table_name() wsrep_service->wsrep_get_sr_table_name_func() +#define wsrep_get_debug() wsrep_service->wsrep_get_debug_func() +#define wsrep_commit_ordered(T) wsrep_service->wsrep_commit_ordered_func(T) +#define wsrep_thd_is_applying(T) wsrep_service->wsrep_thd_is_applying_func(T) #else -extern my_bool wsrep_debug; +#define MYSQL_SERVICE_WSREP_STATIC_INCLUDED +extern ulong wsrep_debug; extern my_bool wsrep_log_conflicts; extern my_bool wsrep_certify_nonPK; extern my_bool wsrep_load_data_splitting; @@ -184,57 +136,86 @@ extern my_bool wsrep_drupal_282555_workaround; extern my_bool wsrep_recovery; extern long wsrep_protocol_version; -bool wsrep_consistency_check(THD *thd); -bool wsrep_prepare_key(const unsigned char* cache_key, size_t cache_key_len, const unsigned char* row_id, size_t row_id_len, struct wsrep_buf* key, size_t* key_len); -char *wsrep_thd_query(THD *thd); -const char *wsrep_thd_conflict_state_str(THD *thd); -const char *wsrep_thd_exec_mode_str(THD *thd); -const char *wsrep_thd_query_state_str(THD *thd); -enum wsrep_conflict_state wsrep_thd_conflict_state(MYSQL_THD thd, my_bool sync); -enum wsrep_conflict_state wsrep_thd_get_conflict_state(MYSQL_THD thd); -enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd); -enum wsrep_query_state wsrep_thd_query_state(THD *thd); -enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, bool all); -int wsrep_is_wsrep_xid(const struct xid_t* xid); -long long wsrep_xid_seqno(const struct xid_t* xid); +extern "C" bool wsrep_consistency_check(MYSQL_THD thd); +bool wsrep_prepare_key_for_innodb(MYSQL_THD thd, const unsigned char* cache_key, size_t cache_key_len, const unsigned char* row_id, size_t row_id_len, struct wsrep_buf* key, size_t* key_len); +extern "C" const char *wsrep_thd_query(const MYSQL_THD thd); +extern "C" int wsrep_is_wsrep_xid(const void* xid); +extern "C" long long wsrep_xid_seqno(const struct xid_t* xid); const unsigned char* wsrep_xid_uuid(const struct xid_t* xid); -int wsrep_on(MYSQL_THD thd); -int wsrep_thd_retry_counter(THD *thd); -int wsrep_trx_is_aborting(MYSQL_THD thd); -int wsrep_trx_order_before(MYSQL_THD thd1, MYSQL_THD thd2); -long get_wsrep_protocol_version(); -long long wsrep_thd_trx_seqno(THD *thd); -my_bool get_wsrep_certify_nonPK(); -my_bool get_wsrep_debug(); -my_bool get_wsrep_drupal_282555_workaround(); +extern "C" long long wsrep_thd_trx_seqno(const MYSQL_THD thd); my_bool get_wsrep_recovery(); -my_bool get_wsrep_load_data_splitting(); -my_bool get_wsrep_log_conflicts(); -my_bool wsrep_aborting_thd_contains(THD *thd); -my_bool wsrep_thd_is_BF(MYSQL_THD thd, my_bool sync); -my_bool wsrep_thd_is_wsrep(MYSQL_THD thd); -struct wsrep *get_wsrep(); -struct wsrep_ws_handle *wsrep_thd_ws_handle(THD *thd); void wsrep_thd_auto_increment_variables(THD *thd, unsigned long long *offset, unsigned long long *increment); -void wsrep_set_load_multi_commit(THD *thd, bool split); -bool wsrep_is_load_multi_commit(THD *thd); -void wsrep_aborting_thd_enqueue(THD *thd); -void wsrep_lock_rollback(); -void wsrep_post_commit(THD* thd, bool all); -void wsrep_thd_LOCK(THD *thd); -void wsrep_thd_UNLOCK(THD *thd); -void wsrep_thd_awake(THD *thd, my_bool signal); -void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state); -bool wsrep_thd_ignore_table(THD *thd); -void wsrep_unlock_rollback(); +bool wsrep_thd_ignore_table(MYSQL_THD thd); void wsrep_set_data_home_dir(const char *data_dir); -my_bool wsrep_thd_is_applier(MYSQL_THD thd); -#endif -#ifdef __cplusplus -} -#endif +/* from mysql wsrep-lib */ +#include "my_global.h" +#include "my_pthread.h" + +/* Return true if wsrep is enabled for a thd. This means that + wsrep is enabled globally and the thd has wsrep on */ +extern "C" my_bool wsrep_on(const MYSQL_THD thd); +/* Lock thd wsrep lock */ +extern "C" void wsrep_thd_LOCK(const MYSQL_THD thd); +/* Unlock thd wsrep lock */ +extern "C" void wsrep_thd_UNLOCK(const MYSQL_THD thd); + +/* Return thd client state string */ +extern "C" const char* wsrep_thd_client_state_str(const MYSQL_THD thd); +/* Return thd client mode string */ +extern "C" const char* wsrep_thd_client_mode_str(const MYSQL_THD thd); +/* Return thd transaction state string */ +extern "C" const char* wsrep_thd_transaction_state_str(const MYSQL_THD thd); + +/* Return current transaction id */ +extern "C" query_id_t wsrep_thd_transaction_id(const MYSQL_THD thd); +/* Mark thd own transaction as aborted */ +extern "C" void wsrep_thd_self_abort(MYSQL_THD thd); +/* Return true if thd is in replicating mode */ +extern "C" my_bool wsrep_thd_is_local(const MYSQL_THD thd); +/* Return true if thd is in high priority mode */ +/* todo: rename to is_high_priority() */ +extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd); +/* Return true if thd is in TOI mode */ +extern "C" my_bool wsrep_thd_is_toi(const MYSQL_THD thd); +/* Return true if thd is in replicating TOI mode */ +extern "C" my_bool wsrep_thd_is_local_toi(const MYSQL_THD thd); +/* Return true if thd is in RSU mode */ +extern "C" my_bool wsrep_thd_is_in_rsu(const MYSQL_THD thd); +/* Return true if thd is in BF mode, either high_priority or TOI */ +extern "C" my_bool wsrep_thd_is_BF(const MYSQL_THD thd, my_bool sync); +/* Return true if thd is streaming */ +extern "C" my_bool wsrep_thd_is_SR(const MYSQL_THD thd); +extern "C" void wsrep_handle_SR_rollback(MYSQL_THD BF_thd, MYSQL_THD victim_thd); +/* Return thd retry counter */ +extern "C" int wsrep_thd_retry_counter(const MYSQL_THD thd); +/* BF abort victim_thd */ +extern "C" my_bool wsrep_thd_bf_abort(const MYSQL_THD bf_thd, + MYSQL_THD victim_thd, + my_bool signal); +/* Return true if left thd is ordered before right thd */ +extern "C" my_bool wsrep_thd_order_before(const MYSQL_THD left, const MYSQL_THD right); +/* Return true if thd should skip locking. This means that the thd + is operating on shared resource inside commit order critical section. */ +extern "C" my_bool wsrep_thd_skip_locking(const MYSQL_THD thd); +/* Return true if thd is aborting */ +extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd); + +struct wsrep_key; +struct wsrep_key_array; +extern "C" int wsrep_thd_append_key(MYSQL_THD thd, + const struct wsrep_key* key, + int n_keys, + enum Wsrep_service_key_type); + +extern const char* wsrep_sr_table_name_full; + +extern "C" const char* wsrep_get_sr_table_name(); + +extern "C" my_bool wsrep_get_debug(); + +extern "C" void wsrep_commit_ordered(MYSQL_THD thd); +extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd); -#define MYSQL_SERVICE_WSREP_INCLUDED #endif - +#endif /* MYSQL_SERVICE_WSREP_INCLUDED */ diff --git a/include/mysql/services.h b/include/mysql/services.h index 986d430dbf1..2c3a0ae421b 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -39,6 +39,7 @@ extern "C" { #include <mysql/service_thd_specifics.h> #include <mysql/service_thd_timezone.h> #include <mysql/service_thd_wait.h> +#include <mysql/service_json.h> /*#include <mysql/service_wsrep.h>*/ #ifdef __cplusplus diff --git a/include/mysql_com.h b/include/mysql_com.h index 77b98294f87..9e5215f29b3 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -203,6 +203,8 @@ enum enum_indicator_type #define VERS_UPDATE_UNVERSIONED_FLAG (1 << 29) /* column that doesn't support system versioning when table itself supports it*/ +#define LONG_UNIQUE_HASH_FIELD (1<< 30) /* This field will store hash for unique + column */ #define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */ #define REFRESH_LOG (1ULL << 1) /* Start on new log file */ @@ -231,6 +233,7 @@ enum enum_indicator_type #define REFRESH_DES_KEY_FILE (1ULL << 18) #define REFRESH_USER_RESOURCES (1ULL << 19) #define REFRESH_FOR_EXPORT (1ULL << 20) /* FLUSH TABLES ... FOR EXPORT */ +#define REFRESH_SSL (1ULL << 21) #define REFRESH_GENERIC (1ULL << 30) #define REFRESH_FAST (1ULL << 31) /* Intern flag */ @@ -332,12 +335,8 @@ enum enum_indicator_type CLIENT_DEPRECATE_EOF |\ CLIENT_CONNECT_ATTRS |\ MARIADB_CLIENT_COM_MULTI |\ - MARIADB_CLIENT_STMT_BULK_OPERATIONS) - -/* - To be added later: - CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS -*/ + MARIADB_CLIENT_STMT_BULK_OPERATIONS |\ + CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS) /* Switch off the flags that are optional and depending on build flags diff --git a/include/mysql_embed.h b/include/mysql_embed.h index e9cbdb6a275..775040ac9d1 100644 --- a/include/mysql_embed.h +++ b/include/mysql_embed.h @@ -25,7 +25,6 @@ /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ #undef HAVE_DLOPEN /* No udf functions */ -#undef HAVE_SMEM /* No shared memory */ #endif /* EMBEDDED_LIBRARY */ #endif /* MYSQL_EMBED_INCLUDED */ diff --git a/include/service_versions.h b/include/service_versions.h index 6e138fab5a4..16d21ac40d3 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -42,3 +42,4 @@ #define VERSION_thd_timezone 0x0100 #define VERSION_thd_wait 0x0100 #define VERSION_wsrep 0x0202 +#define VERSION_json 0x0100 diff --git a/include/ssl_compat.h b/include/ssl_compat.h index c94b9671d5f..9b63c24399a 100644 --- a/include/ssl_compat.h +++ b/include/ssl_compat.h @@ -17,11 +17,7 @@ #include <openssl/opensslv.h> /* OpenSSL version specific definitions */ -#if !defined(HAVE_YASSL) && defined(OPENSSL_VERSION_NUMBER) - -#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER) -#define HAVE_X509_check_host 1 -#endif +#if defined(OPENSSL_VERSION_NUMBER) #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) #define HAVE_OPENSSL11 1 @@ -49,27 +45,39 @@ #else #define HAVE_OPENSSL10 1 +#ifdef HAVE_WOLFSSL +#define SSL_LIBRARY "WolfSSL " WOLFSSL_VERSION +#else #define SSL_LIBRARY SSLeay_version(SSLEAY_VERSION) +#endif -#ifdef HAVE_ERR_remove_thread_state +#ifdef HAVE_WOLFSSL +#undef ERR_remove_state +#define ERR_remove_state(x) do {} while(0) +#elif defined (HAVE_ERR_remove_thread_state) #define ERR_remove_state(X) ERR_remove_thread_state(NULL) #endif /* HAVE_ERR_remove_thread_state */ #endif /* HAVE_OPENSSL11 */ +#endif -#elif defined(HAVE_YASSL) -#define SSL_LIBRARY "YaSSL " YASSL_VERSION -#define BN_free(X) do { } while(0) -#endif /* !defined(HAVE_YASSL) */ +#ifdef HAVE_WOLFSSL +#define EVP_MD_CTX_SIZE sizeof(wc_Md5) +#endif #ifndef HAVE_OPENSSL11 +#ifndef ASN1_STRING_get0_data #define ASN1_STRING_get0_data(X) ASN1_STRING_data(X) +#endif +#ifndef EVP_MD_CTX_SIZE +#define EVP_MD_CTX_SIZE sizeof(EVP_MD_CTX) +#endif + #define OPENSSL_init_ssl(X,Y) SSL_library_init() #define DH_set0_pqg(D,P,Q,G) ((D)->p= (P), (D)->g= (G)) #define EVP_CIPHER_CTX_buf_noconst(ctx) ((ctx)->buf) #define EVP_CIPHER_CTX_encrypting(ctx) ((ctx)->encrypt) #define EVP_CIPHER_CTX_SIZE sizeof(EVP_CIPHER_CTX) -#define EVP_MD_CTX_SIZE sizeof(EVP_MD_CTX) #define EVP_MD_CTX_reset(X) EVP_MD_CTX_cleanup(X) #define EVP_CIPHER_CTX_reset(X) EVP_CIPHER_CTX_cleanup(X) diff --git a/include/sslopt-case.h b/include/sslopt-case.h index fe53088e89b..87eeff28231 100644 --- a/include/sslopt-case.h +++ b/include/sslopt-case.h @@ -29,8 +29,8 @@ One can disable SSL later by using --skip-ssl or --ssl=0 */ opt_use_ssl= 1; - /* crl has no effect in yaSSL */ -#ifdef HAVE_YASSL +#ifdef HAVE_WOLFSSL + /* CRL does not work with WolfSSL */ opt_ssl_crl= NULL; opt_ssl_crlpath= NULL; #endif diff --git a/include/thr_lock.h b/include/thr_lock.h index 35db9ef981b..aa207eaf2c1 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -168,9 +168,9 @@ void thr_set_lock_wait_callback(void (*before_wait)(void), void (*after_wait)(void)); #ifdef WITH_WSREP - typedef my_bool (* wsrep_thd_is_brute_force_fun)(void *, my_bool); - typedef int (* wsrep_abort_thd_fun)(void *, void *, my_bool); - typedef int (* wsrep_on_fun)(void *); + typedef my_bool (* wsrep_thd_is_brute_force_fun)(const MYSQL_THD, my_bool); + typedef my_bool(* wsrep_abort_thd_fun)(const MYSQL_THD, MYSQL_THD, my_bool); + typedef my_bool (* wsrep_on_fun)(const MYSQL_THD); void wsrep_thr_lock_init( wsrep_thd_is_brute_force_fun bf_fun, wsrep_abort_thd_fun abort_fun, my_bool debug, my_bool convert_LOCK_to_trx, wsrep_on_fun on_fun); diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h index f7d2da0b082..47f281192e9 100644 --- a/include/thread_pool_priv.h +++ b/include/thread_pool_priv.h @@ -61,9 +61,6 @@ void thd_set_mysys_var(THD *thd, st_my_thread_var *mysys_var); my_socket thd_get_fd(THD *thd); int thd_store_globals(THD* thd); -THD *first_global_thread(); -THD *next_global_thread(THD *thd); - /* Print to the MySQL error log */ void sql_print_error(const char *format, ...); diff --git a/include/violite.h b/include/violite.h index 208d33b2879..7ee00912837 100644 --- a/include/violite.h +++ b/include/violite.h @@ -38,7 +38,7 @@ typedef struct st_vio Vio; enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, - VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY + VIO_TYPE_SSL }; /** @@ -68,13 +68,6 @@ Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags); Vio* mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags); #ifdef __WIN__ Vio* vio_new_win32pipe(HANDLE hPipe); -Vio* vio_new_win32shared_memory(HANDLE handle_file_map, - HANDLE handle_map, - HANDLE event_server_wrote, - HANDLE event_server_read, - HANDLE event_client_wrote, - HANDLE event_client_read, - HANDLE event_conn_closed); #else #define HANDLE void * #endif /* __WIN__ */ @@ -89,6 +82,7 @@ size_t vio_write(Vio *vio, const uchar * buf, size_t size); int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); my_bool vio_is_blocking(Vio *vio); /* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */ +int vio_nodelay(Vio *vio, my_bool on); int vio_fastsend(Vio *vio); /* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */ int vio_keepalive(Vio *vio, my_bool onoff); @@ -264,22 +258,9 @@ struct st_vio #ifdef HAVE_OPENSSL void *ssl_arg; #endif -#ifdef HAVE_SMEM - HANDLE handle_file_map; - char *handle_map; - HANDLE event_server_wrote; - HANDLE event_server_read; - HANDLE event_client_wrote; - HANDLE event_client_read; - HANDLE event_conn_closed; - size_t shared_memory_remain; - char *shared_memory_pos; -#endif /* HAVE_SMEM */ #ifdef _WIN32 HANDLE hPipe; OVERLAPPED overlapped; - DWORD read_timeout_ms; - DWORD write_timeout_ms; #endif }; #endif /* vio_violite_h_ */ diff --git a/include/wsrep.h b/include/wsrep.h index a3a58324f3e..fde5c5226e7 100644 --- a/include/wsrep.h +++ b/include/wsrep.h @@ -13,11 +13,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ -#include <my_config.h> - #ifndef WSREP_INCLUDED #define WSREP_INCLUDED +#include <my_config.h> + #ifdef WITH_WSREP #define IF_WSREP(A,B) A #define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A) @@ -28,12 +28,14 @@ goto wsrep_error_label; #define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_) \ - if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, \ - table_list_, alter_info_)) \ + if (WSREP(thd) && wsrep_thd_is_local(thd) && \ + wsrep_to_isolation_begin(thd, db_, table_, \ + table_list_, alter_info_)) \ goto wsrep_error_label; -#define WSREP_TO_ISOLATION_END \ - if (WSREP_ON && (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER))) \ +#define WSREP_TO_ISOLATION_END \ + if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \ + wsrep_thd_is_in_rsu(thd)) \ wsrep_to_isolation_end(thd); /* @@ -50,24 +52,26 @@ #define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) #define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) -#define WSREP_SYNC_WAIT(thd_, before_) \ - do { if (WSREP_CLIENT(thd_) && \ - wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } while(0) -#define WSREP_ERROR_LABEL wsrep_error_label -#else +#define WSREP_SYNC_WAIT(thd_, before_) \ + { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } + +#else /* !WITH_WSREP */ + +/* These macros are needed to compile MariaDB without WSREP support + * (e.g. embedded) */ + #define IF_WSREP(A,B) B -#define DBUG_ASSERT_IF_WSREP(A) +//#define DBUG_ASSERT_IF_WSREP(A) #define WSREP_DEBUG(...) -#define WSREP_INFO(...) -#define WSREP_WARN(...) +//#define WSREP_INFO(...) +//#define WSREP_WARN(...) #define WSREP_ERROR(...) -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0) #define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_) #define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) -#define WSREP_SYNC_WAIT(thd_, before_) do { } while(0) -#define WSREP_ERROR_LABEL goto wsrep_error_label; wsrep_error_label - +#define WSREP_SYNC_WAIT(thd_, before_) #endif /* WITH_WSREP */ #endif /* WSREP_INCLUDED */ |