diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/hash.h | 1 | ||||
-rw-r--r-- | include/heap.h | 1 | ||||
-rw-r--r-- | include/ma_dyncol.h | 102 | ||||
-rw-r--r-- | include/my_dir.h | 5 | ||||
-rw-r--r-- | include/my_global.h | 2 | ||||
-rw-r--r-- | include/my_pthread.h | 6 | ||||
-rw-r--r-- | include/my_sys.h | 44 | ||||
-rw-r--r-- | include/my_tree.h | 6 | ||||
-rw-r--r-- | include/myisamchk.h | 1 | ||||
-rw-r--r-- | include/mysql.h.pp | 4 | ||||
-rw-r--r-- | include/mysql/plugin.h | 19 | ||||
-rw-r--r-- | include/mysql/plugin_audit.h.pp | 11 | ||||
-rw-r--r-- | include/mysql/plugin_auth.h.pp | 11 | ||||
-rw-r--r-- | include/mysql/plugin_ftparser.h.pp | 11 | ||||
-rw-r--r-- | include/mysql/service_kill_statement.h | 71 | ||||
-rw-r--r-- | include/mysql/services.h | 1 | ||||
-rw-r--r-- | include/mysql_com.h | 70 | ||||
-rw-r--r-- | include/service_versions.h | 14 |
18 files changed, 280 insertions, 100 deletions
diff --git a/include/hash.h b/include/hash.h index 98bcf911db2..2ecfe0891d7 100644 --- a/include/hash.h +++ b/include/hash.h @@ -39,6 +39,7 @@ extern "C" { /* flags for hash_init */ #define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */ +#define HASH_THREAD_SPECIFIC 2 /* Mark allocated memory THREAD_SPECIFIC */ typedef uint my_hash_value_type; typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool); diff --git a/include/heap.h b/include/heap.h index 10b165d89c6..149f9ed5f56 100644 --- a/include/heap.h +++ b/include/heap.h @@ -153,6 +153,7 @@ typedef struct st_heap_share THR_LOCK lock; mysql_mutex_t intern_lock; /* Locking for use with _locking */ my_bool delete_on_close; + my_bool internal; /* Internal temporary table */ LIST open_list; uint auto_key; uint auto_key_type; /* real type of the auto key segment */ diff --git a/include/ma_dyncol.h b/include/ma_dyncol.h index 6174328d62a..ed5eb1e6bae 100644 --- a/include/ma_dyncol.h +++ b/include/ma_dyncol.h @@ -34,10 +34,10 @@ #include <mysql_time.h> /* - Max length for data in a dynamic colums. This comes from how the - how the offset are stored. + Limits of implementation */ -#define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL +#define MAX_TOTAL_NAME_LENGTH 65535 +#define MAX_NAME_LENGTH (MAX_TOTAL_NAME_LENGTH/4) /* NO and OK is the same used just to show semantics */ #define ER_DYNCOL_NO ER_DYNCOL_OK @@ -50,7 +50,8 @@ enum enum_dyncol_func_result ER_DYNCOL_LIMIT= -2, /* Some limit reached */ ER_DYNCOL_RESOURCE= -3, /* Out of resourses */ ER_DYNCOL_DATA= -4, /* Incorrect input data */ - ER_DYNCOL_UNKNOWN_CHARSET= -5 /* Unknown character set */ + ER_DYNCOL_UNKNOWN_CHARSET= -5, /* Unknown character set */ + ER_DYNCOL_TRUNCATED= 2 /* OK, but data was truncated */ }; typedef DYNAMIC_STRING DYNAMIC_COLUMN; @@ -65,7 +66,8 @@ enum enum_dynamic_column_type DYN_COL_DECIMAL, DYN_COL_DATETIME, DYN_COL_DATE, - DYN_COL_TIME + DYN_COL_TIME, + DYN_COL_DYNCOL }; typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE; @@ -79,7 +81,7 @@ struct st_dynamic_column_value unsigned long long ulong_value; double double_value; struct { - LEX_STRING value; + MYSQL_LEX_STRING value; CHARSET_INFO *charset; } string; struct { @@ -92,6 +94,7 @@ struct st_dynamic_column_value typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE; +#ifdef MADYNCOL_DEPRECATED enum enum_dyncol_func_result dynamic_column_create(DYNAMIC_COLUMN *str, uint column_nr, DYNAMIC_COLUMN_VALUE *value); @@ -101,7 +104,6 @@ dynamic_column_create_many(DYNAMIC_COLUMN *str, uint column_count, uint *column_numbers, DYNAMIC_COLUMN_VALUE *values); - enum enum_dyncol_func_result dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr, DYNAMIC_COLUMN_VALUE *value); @@ -112,36 +114,102 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, DYNAMIC_COLUMN_VALUE *values); enum enum_dyncol_func_result -dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr); +dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr); enum enum_dyncol_func_result -dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr); +dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint); + +enum enum_dyncol_func_result +dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr, + DYNAMIC_COLUMN_VALUE *store_it_here); +#endif + +/* new functions */ +enum enum_dyncol_func_result +mariadb_dyncol_create_many(DYNAMIC_COLUMN *str, + uint column_count, + uint *column_numbers, + DYNAMIC_COLUMN_VALUE *values, + my_bool new_string); +enum enum_dyncol_func_result +mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str, + uint column_count, + MYSQL_LEX_STRING *column_keys, + DYNAMIC_COLUMN_VALUE *values, + my_bool new_string); + + +enum enum_dyncol_func_result +mariadb_dyncol_update_many(DYNAMIC_COLUMN *str, + uint add_column_count, + uint *column_keys, + DYNAMIC_COLUMN_VALUE *values); +enum enum_dyncol_func_result +mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str, + uint add_column_count, + MYSQL_LEX_STRING *column_keys, + DYNAMIC_COLUMN_VALUE *values); + + +enum enum_dyncol_func_result +mariadb_dyncol_exists(DYNAMIC_COLUMN *org, uint column_nr); +enum enum_dyncol_func_result +mariadb_dyncol_exists_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name); /* List of not NULL columns */ enum enum_dyncol_func_result -dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint); +mariadb_dyncol_list(DYNAMIC_COLUMN *str, uint *count, uint **nums); +enum enum_dyncol_func_result +mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count, + MYSQL_LEX_STRING **names); /* if the column do not exists it is NULL */ enum enum_dyncol_func_result -dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr, +mariadb_dyncol_get(DYNAMIC_COLUMN *org, uint column_nr, DYNAMIC_COLUMN_VALUE *store_it_here); +enum enum_dyncol_func_result +mariadb_dyncol_get_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name, + DYNAMIC_COLUMN_VALUE *store_it_here); + +my_bool mariadb_dyncol_has_names(DYNAMIC_COLUMN *str); + +enum enum_dyncol_func_result +mariadb_dyncol_check(DYNAMIC_COLUMN *str); + +enum enum_dyncol_func_result +mariadb_dyncol_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json); #define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A))) #define dynamic_column_column_free(V) dynstr_free(V) -/*************************************************************************** - Internal functions, don't use if you don't know what you are doing... -***************************************************************************/ +/* conversion of values to 3 base types */ +enum enum_dyncol_func_result +mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val, + CHARSET_INFO *cs, my_bool quote); +enum enum_dyncol_func_result +mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val); +enum enum_dyncol_func_result +mariadb_dyncol_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val); + + +enum enum_dyncol_func_result +mariadb_dyncol_unpack(DYNAMIC_COLUMN *str, + uint *count, + MYSQL_LEX_STRING **names, DYNAMIC_COLUMN_VALUE **vals); -#define dynamic_column_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A)) +int mariadb_dyncol_column_cmp_named(const MYSQL_LEX_STRING *s1, + const MYSQL_LEX_STRING *s2); + +enum enum_dyncol_func_result +mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count); -#define dynamic_column_value_init(V) (V)->type= DYN_COL_NULL +#define mariadb_dyncol_value_init(V) (V)->type= DYN_COL_NULL /* Prepare value for using as decimal */ -void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value); +void mariadb_dyncol_prepare_decimal(DYNAMIC_COLUMN_VALUE *value); #endif diff --git a/include/my_dir.h b/include/my_dir.h index 1ee002cc380..6a941b37d79 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -45,8 +45,9 @@ extern "C" { #define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG) #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO) -#define MY_DONT_SORT 512 /* my_lib; Don't sort files */ -#define MY_WANT_STAT 1024 /* my_lib; stat files */ +/* Ensure these dosn't clash with anything in my_sys.h */ +#define MY_DONT_SORT 8192 /* my_lib; Don't sort files */ +#define MY_WANT_STAT 16384 /* my_lib; stat files */ /* typedefs for my_dir & my_stat */ diff --git a/include/my_global.h b/include/my_global.h index ed9ac83cfe6..7c133268f59 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -994,7 +994,7 @@ typedef struct st_mysql_lex_string LEX_STRING; #define SOCKET_EMFILE EMFILE #endif -typedef int myf; /* Type of MyFlags in my_funcs */ +typedef ulong myf; /* Type of MyFlags in my_funcs */ typedef char my_bool; /* Small bool */ /* Macros for converting *constants* to the right type */ diff --git a/include/my_pthread.h b/include/my_pthread.h index 5872f7c5904..8c16a112eac 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -350,9 +350,9 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #ifndef set_timespec_time_nsec #define set_timespec_time_nsec(ABSTIME,NSEC) do { \ - ulonglong now= (NSEC); \ - (ABSTIME).MY_tv_sec= (now / 1000000000ULL); \ - (ABSTIME).MY_tv_nsec= (now % 1000000000ULL); \ + ulonglong _now_= (NSEC); \ + (ABSTIME).MY_tv_sec= (_now_ / 1000000000ULL); \ + (ABSTIME).MY_tv_nsec= (_now_ % 1000000000ULL); \ } while(0) #endif /* !set_timespec_time_nsec */ diff --git a/include/my_sys.h b/include/my_sys.h index 30513d17e0a..48459c3fb83 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -86,6 +86,10 @@ typedef struct my_aio_result { #define MY_SYNC 4096 /* my_copy(): sync dst file */ #define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */ #define MY_SYNC_FILESIZE 65536 /* my_sync(): safe sync when file is extended */ +#define MY_THREAD_SPECIFIC 0x10000 /* my_malloc(): thread specific */ +#define MY_THREAD_MOVE 0x20000 /* realloc(); Memory can move */ +/* Tree that should delete things automaticly */ +#define MY_TREE_WITH_DELETE 0x40000 #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ @@ -148,6 +152,18 @@ typedef struct my_aio_result { /* Extra length needed for filename if one calls my_create_backup_name */ #define MY_BACKUP_NAME_EXTRA_LENGTH 17 +/* If we have our own safemalloc (for debugging) */ +#if defined(SAFEMALLOC) +void sf_report_leaked_memory(my_thread_id id); +extern my_thread_id (*sf_malloc_dbug_id)(void); +#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X) +#else +#define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0) +#endif + +typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific); +extern void set_malloc_size_cb(MALLOC_SIZE_CB func); + /* defines when allocating data */ extern void *my_malloc(size_t Size,myf MyFlags); extern void *my_multi_malloc(myf MyFlags, ...); @@ -183,7 +199,7 @@ extern void my_large_free(uchar *ptr); #define my_alloca(SZ) alloca((size_t) (SZ)) #define my_afree(PTR) ((void)0) #else -#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE)) +#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE|MY_THREAD_SPECIFIC)) #define my_afree(PTR) my_free(PTR) #endif /* HAVE_ALLOCA */ @@ -323,6 +339,7 @@ typedef struct st_dynamic_array uint elements,max_element; uint alloc_increment; uint size_of_element; + myf malloc_flags; } DYNAMIC_ARRAY; typedef struct st_my_tmpdir @@ -773,16 +790,10 @@ extern my_bool real_open_cached_file(IO_CACHE *cache); extern void close_cached_file(IO_CACHE *cache); File create_temp_file(char *to, const char *dir, const char *pfx, int mode, myf MyFlags); -#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D) -#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D) -#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E) -#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E) -extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, +#define my_init_dynamic_array(A,B,C,D,E) my_init_dynamic_array2(A,B,NULL,C,D,E) +extern my_bool my_init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, void *init_buffer, uint init_alloc, - uint alloc_increment); -/* init_dynamic_array() function is deprecated */ -extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, - uint init_alloc, uint alloc_increment); + uint alloc_increment, myf my_flags); extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element); extern void *alloc_dynamic(DYNAMIC_ARRAY *array); extern void *pop_dynamic(DYNAMIC_ARRAY*); @@ -807,12 +818,23 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, size_t length); extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...); +extern my_bool dynstr_append_quoted(DYNAMIC_STRING *str, + const char *append, size_t len, + char quote); extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n); extern void dynstr_free(DYNAMIC_STRING *str); +extern uint32 copy_and_convert_extended(char *to, uint32 to_length, + CHARSET_INFO *to_cs, + const char *from, uint32 from_length, + CHARSET_INFO *from_cs, uint *errors); extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length, size_t *alloc_length); +extern uint32 copy_and_convert_extended(char *to, uint32 to_length, + CHARSET_INFO *to_cs, + const char *from, uint32 from_length, + CHARSET_INFO *from_cs, uint *errors); #ifdef HAVE_MLOCK extern void *my_malloc_lock(size_t length,myf flags); extern void my_free_lock(void *ptr); @@ -824,7 +846,7 @@ extern void my_free_lock(void *ptr); #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, - size_t pre_alloc_size); + size_t pre_alloc_size, myf my_flags); extern void *alloc_root(MEM_ROOT *mem_root, size_t Size); extern void *multi_alloc_root(MEM_ROOT *mem_root, ...); extern void free_root(MEM_ROOT *root, myf MyFLAGS); diff --git a/include/my_tree.h b/include/my_tree.h index 3dd92712af2..f8be55f84b2 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -68,13 +68,15 @@ typedef struct st_tree { MEM_ROOT mem_root; my_bool with_delete; tree_element_free free; + myf my_flags; uint flag; } TREE; /* Functions on whole tree */ void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit, - int size, qsort_cmp2 compare, my_bool with_delete, - tree_element_free free_element, void *custom_arg); + int size, qsort_cmp2 compare, + tree_element_free free_element, void *custom_arg, + myf my_flags); void delete_tree(TREE*); void reset_tree(TREE*); diff --git a/include/myisamchk.h b/include/myisamchk.h index 789e95572b3..7e7b685a88a 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -164,6 +164,7 @@ typedef struct st_handler_check_param mysql_mutex_t print_msg_mutex; my_bool need_print_msg_lock; + myf malloc_flags; } HA_CHECK; diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 361f1a323ae..f2bb110a3e7 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -28,7 +28,7 @@ typedef struct st_net { unsigned char reading_or_writing; char save_char; char net_skip_rest_factor; - my_bool unused1; + my_bool thread_specific_malloc; my_bool compress; my_bool unused3; unsigned char *unused; @@ -80,7 +80,7 @@ enum enum_mysql_set_option MYSQL_OPTION_MULTI_STATEMENTS_ON, MYSQL_OPTION_MULTI_STATEMENTS_OFF }; -my_bool my_net_init(NET *net, Vio* vio); +my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags); void my_net_local_init(NET *net); void net_end(NET *net); void net_clear(NET *net, my_bool clear_buffer); diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index b8e90f764bd..38573180232 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -72,7 +72,7 @@ typedef struct st_mysql_xid MYSQL_XID; #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103 /* MariaDB plugin interface version */ -#define MARIA_PLUGIN_INTERFACE_VERSION 0x0103 +#define MARIA_PLUGIN_INTERFACE_VERSION 0x0104 /* The allowable types of plugins @@ -626,23 +626,6 @@ void thd_inc_row_count(MYSQL_THD thd); int mysql_tmpfile(const char *prefix); /** - Check the killed state of a connection - - @details - In MySQL support for the KILL statement is cooperative. The KILL - statement only sets a "killed" flag. This function returns the value - of that flag. A thread should check it often, especially inside - time-consuming loops, and gracefully abort the operation if it is - non-zero. - - @param thd user thread connection handle - @retval 0 the connection is active - @retval 1 the connection has been killed -*/ -int thd_killed(const MYSQL_THD thd); - - -/** Return the thread id of a user thread @param thd user thread connection handle diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index dea2446ac9c..fbd4ec2dd3f 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -82,6 +82,16 @@ const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); #include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); +#include <mysql/service_kill_statement.h> +enum thd_kill_levels { + THD_IS_NOT_KILLED=0, + THD_ABORT_SOFTLY=50, + THD_ABORT_ASAP=100, +}; +extern struct kill_statement_service_st { + enum thd_kill_levels (*thd_kill_level_func)(const void*); +} *thd_kill_statement_service; +enum thd_kill_levels thd_kill_level(const void*); struct st_mysql_xid { long formatID; long gtrid_length; @@ -226,7 +236,6 @@ char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index f1213a73bc6..46811825142 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -82,6 +82,16 @@ const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); #include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); +#include <mysql/service_kill_statement.h> +enum thd_kill_levels { + THD_IS_NOT_KILLED=0, + THD_ABORT_SOFTLY=50, + THD_ABORT_ASAP=100, +}; +extern struct kill_statement_service_st { + enum thd_kill_levels (*thd_kill_level_func)(const void*); +} *thd_kill_statement_service; +enum thd_kill_levels thd_kill_level(const void*); struct st_mysql_xid { long formatID; long gtrid_length; @@ -226,7 +236,6 @@ char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 74b298098dd..49cf7e5b931 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -82,6 +82,16 @@ const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); #include <mysql/service_debug_sync.h> extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); +#include <mysql/service_kill_statement.h> +enum thd_kill_levels { + THD_IS_NOT_KILLED=0, + THD_ABORT_SOFTLY=50, + THD_ABORT_ASAP=100, +}; +extern struct kill_statement_service_st { + enum thd_kill_levels (*thd_kill_level_func)(const void*); +} *thd_kill_statement_service; +enum thd_kill_levels thd_kill_level(const void*); struct st_mysql_xid { long formatID; long gtrid_length; @@ -179,7 +189,6 @@ char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, diff --git a/include/mysql/service_kill_statement.h b/include/mysql/service_kill_statement.h new file mode 100644 index 00000000000..995b21f0a9f --- /dev/null +++ b/include/mysql/service_kill_statement.h @@ -0,0 +1,71 @@ +/* Copyright (c) 2013, Monty Program Ab. + + 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 */ + +#ifndef MYSQL_SERVICE_KILL_STATEMENT_INCLUDED +#define MYSQL_SERVICE_KILL_STATEMENT_INCLUDED + +/** + @file + This service provides functions that allow plugins to support + the KILL statement. + + In MySQL support for the KILL statement is cooperative. The KILL + statement only sets a "killed" flag. This function returns the value + of that flag. A thread should check it often, especially inside + time-consuming loops, and gracefully abort the operation if it is + non-zero. + + thd_is_killed(thd) + @return 0 - no KILL statement was issued, continue normally + @return 1 - there was a KILL statement, abort the execution. + + thd_kill_level(thd) + @return thd_kill_levels_enum values +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +enum thd_kill_levels { + THD_IS_NOT_KILLED=0, + THD_ABORT_SOFTLY=50, /**< abort when possible, don't leave tables corrupted */ + THD_ABORT_ASAP=100, /**< abort asap */ +}; + +extern struct kill_statement_service_st { + enum thd_kill_levels (*thd_kill_level_func)(const MYSQL_THD); +} *thd_kill_statement_service; + +/* backward compatibility helper */ +#define thd_killed(THD) (thd_kill_level(THD) == THD_ABORT_ASAP) + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define thd_kill_level(THD) \ + thd_kill_statement_service->thd_kill_level_func(THD) + +#else + +enum thd_kill_levels thd_kill_level(const MYSQL_THD); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/mysql/services.h b/include/mysql/services.h index 8eb506e1c37..b5b331d4923 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -24,6 +24,7 @@ extern "C" { #include <mysql/service_thread_scheduler.h> #include <mysql/service_progress_report.h> #include <mysql/service_debug_sync.h> +#include <mysql/service_kill_statement.h> #ifdef __cplusplus } diff --git a/include/mysql_com.h b/include/mysql_com.h index b5b4dc585b8..63b95bb5295 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2010, 2011, Monty Program Ab + Copyright (c) 2010, 2013, Monty Program Ab 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 @@ -128,39 +128,39 @@ enum enum_server_command #define HAS_EXPLICIT_VALUE (1 << 26) /* An INSERT/UPDATE operation supplied an explicit default value */ -#define REFRESH_GRANT 1 /* Refresh grant tables */ -#define REFRESH_LOG 2 /* Start on new log file */ -#define REFRESH_TABLES 4 /* close all tables */ -#define REFRESH_HOSTS 8 /* Flush host cache */ -#define REFRESH_STATUS 16 /* Flush status variables */ -#define REFRESH_THREADS 32 /* Flush thread cache */ -#define REFRESH_SLAVE 64 /* Reset master info and restart slave - thread */ -#define REFRESH_MASTER 128 /* Remove all bin logs in the index - and truncate the index */ +#define REFRESH_GRANT (1UL << 0) /* Refresh grant tables */ +#define REFRESH_LOG (1UL << 1) /* Start on new log file */ +#define REFRESH_TABLES (1UL << 2) /* close all tables */ +#define REFRESH_HOSTS (1UL << 3) /* Flush host cache */ +#define REFRESH_STATUS (1UL << 4) /* Flush status variables */ +#define REFRESH_THREADS (1UL << 5) /* Flush thread cache */ +#define REFRESH_SLAVE (1UL << 6) /* Reset master info and restart slave + thread */ +#define REFRESH_MASTER (1UL << 7) /* Remove all bin logs in the index + and truncate the index */ /* The following can't be set with mysql_refresh() */ -#define REFRESH_ERROR_LOG 256 /* Rotate only the erorr log */ -#define REFRESH_ENGINE_LOG 512 /* Flush all storage engine logs */ -#define REFRESH_BINARY_LOG 1024 /* Flush the binary log */ -#define REFRESH_RELAY_LOG 2048 /* Flush the relay log */ -#define REFRESH_GENERAL_LOG 4096 /* Flush the general log */ -#define REFRESH_SLOW_LOG 8192 /* Flush the slow query log */ - -#define REFRESH_READ_LOCK 16384 /* Lock tables for read */ -#define REFRESH_FAST 32768 /* Intern flag */ - -/* RESET (remove all queries) from query cache */ -#define REFRESH_QUERY_CACHE 65536 -#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */ -#define REFRESH_DES_KEY_FILE 0x40000L -#define REFRESH_USER_RESOURCES 0x80000L -#define REFRESH_CHECKPOINT 0x100000L /* Don't do checkpoints */ - -#define REFRESH_TABLE_STATS (1L << 20) /* Refresh table stats hash table */ -#define REFRESH_INDEX_STATS (1L << 21) /* Refresh index stats hash table */ -#define REFRESH_USER_STATS (1L << 22) /* Refresh user stats hash table */ -#define REFRESH_CLIENT_STATS (1L << 23) /* Refresh client stats hash table */ +#define REFRESH_ERROR_LOG (1UL << 8) /* Rotate only the erorr log */ +#define REFRESH_ENGINE_LOG (1UL << 9) /* Flush all storage engine logs */ +#define REFRESH_BINARY_LOG (1UL << 10) /* Flush the binary log */ +#define REFRESH_RELAY_LOG (1UL << 11) /* Flush the relay log */ +#define REFRESH_GENERAL_LOG (1UL << 12) /* Flush the general log */ +#define REFRESH_SLOW_LOG (1UL << 13) /* Flush the slow query log */ + +#define REFRESH_READ_LOCK (1UL << 14) /* Lock tables for read */ +#define REFRESH_CHECKPOINT (1UL << 15) /* With REFRESH_READ_LOCK: block checkpoints too */ + +#define REFRESH_QUERY_CACHE (1UL << 16) /* clear the query cache */ +#define REFRESH_QUERY_CACHE_FREE (1UL << 17) /* pack query cache */ +#define REFRESH_DES_KEY_FILE (1UL << 18) +#define REFRESH_USER_RESOURCES (1UL << 19) + +#define REFRESH_TABLE_STATS (1UL << 20) /* Refresh table stats hash table */ +#define REFRESH_INDEX_STATS (1UL << 21) /* Refresh index stats hash table */ +#define REFRESH_USER_STATS (1UL << 22) /* Refresh user stats hash table */ +#define REFRESH_CLIENT_STATS (1UL << 23) /* Refresh client stats hash table */ + +#define REFRESH_FAST (1UL << 31) /* Intern flag */ #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ @@ -340,7 +340,7 @@ typedef struct st_net { unsigned char reading_or_writing; char save_char; char net_skip_rest_factor; - my_bool unused1; /* Please remove with the next incompatible ABI change */ + my_bool thread_specific_malloc; my_bool compress; my_bool unused3; /* Please remove with the next incompatible ABI change. */ /* @@ -475,10 +475,10 @@ enum enum_mysql_set_option extern "C" { #endif -my_bool my_net_init(NET *net, Vio* vio); +my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags); void my_net_local_init(NET *net); void net_end(NET *net); - void net_clear(NET *net, my_bool clear_buffer); +void net_clear(NET *net, my_bool clear_buffer); my_bool net_realloc(NET *net, size_t length); my_bool net_flush(NET *net); my_bool my_net_write(NET *net,const unsigned char *packet, size_t len); diff --git a/include/service_versions.h b/include/service_versions.h index 436941643ec..9b41da7440e 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -19,9 +19,11 @@ #define SERVICE_VERSION void * #endif -#define VERSION_my_snprintf 0x0100 -#define VERSION_thd_alloc 0x0100 -#define VERSION_thd_wait 0x0100 -#define VERSION_my_thread_scheduler 0x0100 -#define VERSION_progress_report 0x0100 -#define VERSION_debug_sync 0x1000 +#define VERSION_my_snprintf 0x0100 +#define VERSION_thd_alloc 0x0100 +#define VERSION_thd_wait 0x0100 +#define VERSION_my_thread_scheduler 0x0100 +#define VERSION_progress_report 0x0100 +#define VERSION_debug_sync 0x1000 +#define VERSION_kill_statement 0x1000 + |