diff options
Diffstat (limited to 'include')
38 files changed, 535 insertions, 199 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index d8bac7532cc..773c26f9d0a 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -30,6 +30,8 @@ SET(HEADERS_ABI mysql/plugin.h mysql/plugin_audit.h mysql/plugin_ftparser.h + mysql/plugin_auth.h + mysql/client_plugin.h ) SET(HEADERS diff --git a/include/decimal.h b/include/decimal.h index 90946f65ac6..bc948125f22 100644 --- a/include/decimal.h +++ b/include/decimal.h @@ -32,14 +32,14 @@ int internal_str2dec(const char *from, decimal_t *to, char **end, int decimal2string(const decimal_t *from, char *to, int *to_len, int fixed_precision, int fixed_decimals, char filler); -int decimal2ulonglong(decimal_t *from, ulonglong *to); +int decimal2ulonglong(const decimal_t *from, ulonglong *to); int ulonglong2decimal(ulonglong from, decimal_t *to); -int decimal2longlong(decimal_t *from, longlong *to); +int decimal2longlong(const decimal_t *from, longlong *to); int longlong2decimal(longlong from, decimal_t *to); int decimal2double(const decimal_t *from, double *to); int double2decimal(double from, decimal_t *to); int decimal_actual_fraction(decimal_t *from); -int decimal2bin(decimal_t *from, uchar *to, int precision, int scale); +int decimal2bin(const decimal_t *from, uchar *to, int precision, int scale); int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale); int decimal_size(int precision, int scale); diff --git a/include/ft_global.h b/include/ft_global.h index 5e10cb09598..eb1f84d307b 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -25,6 +25,8 @@ extern "C" { #endif +#include <my_compare.h> + #define HA_FT_MAXBYTELEN 254 #define HA_FT_MAXCHARLEN (HA_FT_MAXBYTELEN/3) diff --git a/include/heap.h b/include/heap.h index 74851c7b454..b23ec47db67 100644 --- a/include/heap.h +++ b/include/heap.h @@ -136,6 +136,8 @@ typedef struct st_heap_share ulong min_records,max_records; /* Params to open */ ulonglong data_length,index_length,max_table_size; uint key_stat_version; /* version to indicate insert/delete */ + uint key_version; /* Updated on key change */ + uint file_version; /* Update on clear */ uint records; /* records */ uint blength; /* records rounded up to 2^n */ uint deleted; /* Deleted records in database */ @@ -171,6 +173,8 @@ typedef struct st_heap_info enum ha_rkey_function last_find_flag; TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1]; TREE_ELEMENT **last_pos; + uint key_version; /* Version at last read */ + uint file_version; /* Version at scan */ uint lastkey_len; my_bool implicit_emptied; THR_LOCK_DATA lock; diff --git a/include/m_ctype.h b/include/m_ctype.h index e02f5d84d4e..ff0a870b268 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -163,7 +163,8 @@ enum my_lex_states MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR, MY_LEX_IDENT_OR_KEYWORD, MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR, - MY_LEX_STRING_OR_DELIMITER + MY_LEX_STRING_OR_DELIMITER, MY_LEX_MINUS_OR_COMMENT, MY_LEX_PLACEHOLDER, + MY_LEX_COMMA }; struct charset_info_st; @@ -389,6 +390,9 @@ extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t, extern void my_hash_sort_simple(CHARSET_INFO *cs, const uchar *key, size_t len, ulong *nr1, ulong *nr2); +extern void my_hash_sort_bin(CHARSET_INFO *cs, + const uchar *key, size_t len, ulong *nr1, + ulong *nr2); extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length); diff --git a/include/m_string.h b/include/m_string.h index 9eb0e1e13ff..ba906e2e62c 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -90,6 +90,12 @@ extern const char _dig_vec_lower[]; extern char *strmov_overlapp(char *dest, const char *src); +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) +#define LINT_INIT_STRUCT(var) bzero(&var, sizeof(var)) /* No uninitialize-warning */ +#else +#define LINT_INIT_STRUCT(var) +#endif + /* Prototypes for string functions */ extern void bmove_upp(uchar *dst,const uchar *src,size_t len); @@ -215,75 +221,6 @@ struct st_mysql_const_unsigned_lex_string }; typedef struct st_mysql_const_unsigned_lex_string LEX_CUSTRING; -/* SPACE_INT is a word that contains only spaces */ -#if SIZEOF_INT == 4 -#define SPACE_INT 0x20202020 -#elif SIZEOF_INT == 8 -#define SPACE_INT 0x2020202020202020 -#else -#error define the appropriate constant for a word full of spaces -#endif - -/** - Skip trailing space. - - On most systems reading memory in larger chunks (ideally equal to the size of - the chinks that the machine physically reads from memory) causes fewer memory - access loops and hence increased performance. - This is why the 'int' type is used : it's closest to that (according to how - it's defined in C). - So when we determine the amount of whitespace at the end of a string we do - the following : - 1. We divide the string into 3 zones : - a) from the start of the string (__start) to the first multiple - of sizeof(int) (__start_words) - b) from the end of the string (__end) to the last multiple of sizeof(int) - (__end_words) - c) a zone that is aligned to sizeof(int) and can be safely accessed - through an int * - 2. We start comparing backwards from (c) char-by-char. If all we find is - space then we continue - 3. If there are elements in zone (b) we compare them as unsigned ints to a - int mask (SPACE_INT) consisting of all spaces - 4. Finally we compare the remaining part (a) of the string char by char. - This covers for the last non-space unsigned int from 3. (if any) - - This algorithm works well for relatively larger strings, but it will slow - the things down for smaller strings (because of the additional calculations - and checks compared to the naive method). Thus the barrier of length 20 - is added. - - @param ptr pointer to the input string - @param len the length of the string - @return the last non-space character -*/ - -static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len) -{ - const uchar *end= ptr + len; - - if (len > 20) - { - const uchar *end_words= (const uchar *)(intptr) - (((ulonglong)(intptr)end) / SIZEOF_INT * SIZEOF_INT); - const uchar *start_words= (const uchar *)(intptr) - ((((ulonglong)(intptr)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT); - - DBUG_ASSERT(((ulonglong)(intptr)ptr) >= SIZEOF_INT); - if (end_words > ptr) - { - while (end > end_words && end[-1] == 0x20) - end--; - if (end[-1] == 0x20 && start_words < end_words) - while (end > start_words && ((unsigned *)end)[-1] == SPACE_INT) - end -= SIZEOF_INT; - } - } - while (end > ptr && end[-1] == 0x20) - end--; - return (end); -} - static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str) { lex_str->str= (char *) c_str; diff --git a/include/ma_dyncol.h b/include/ma_dyncol.h new file mode 100644 index 00000000000..687823a4e73 --- /dev/null +++ b/include/ma_dyncol.h @@ -0,0 +1,147 @@ +/* Copyright (c) 2011, Monty Program Ab + Copyright (c) 2011, Oleksandr Byelkin + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#ifndef ma_dyncol_h +#define ma_dyncol_h + +#include <decimal.h> +#include <my_decimal_limits.h> +#include <mysql_time.h> + +/* + Max length for data in a dynamic colums. This comes from how the + how the offset are stored. +*/ +#define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL + +/* NO and OK is the same used just to show semantics */ +#define ER_DYNCOL_NO ER_DYNCOL_OK + +enum enum_dyncol_func_result +{ + ER_DYNCOL_OK= 0, + ER_DYNCOL_YES= 1, /* For functions returning 0/1 */ + ER_DYNCOL_FORMAT= -1, /* Wrong format of the encoded string */ + 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 */ +}; + +typedef DYNAMIC_STRING DYNAMIC_COLUMN; + +enum enum_dynamic_column_type +{ + DYN_COL_NULL= 0, + DYN_COL_INT, + DYN_COL_UINT, + DYN_COL_DOUBLE, + DYN_COL_STRING, + DYN_COL_DECIMAL, + DYN_COL_DATETIME, + DYN_COL_DATE, + DYN_COL_TIME +}; + +typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE; + +struct st_dynamic_column_value +{ + DYNAMIC_COLUMN_TYPE type; + union + { + long long long_value; + unsigned long long ulong_value; + double double_value; + struct { + LEX_STRING string_value; + CHARSET_INFO *charset; + }; + struct { + decimal_digit_t decimal_buffer[DECIMAL_BUFF_LENGTH]; + decimal_t decimal_value; + }; + MYSQL_TIME time_value; + }; +}; + +typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE; + +enum enum_dyncol_func_result +dynamic_column_create(DYNAMIC_COLUMN *str, + uint column_nr, DYNAMIC_COLUMN_VALUE *value); + +enum enum_dyncol_func_result +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); +enum enum_dyncol_func_result +dynamic_column_update_many(DYNAMIC_COLUMN *str, + uint add_column_count, + uint *column_numbers, + DYNAMIC_COLUMN_VALUE *values); + +enum enum_dyncol_func_result +dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr); + +enum enum_dyncol_func_result +dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr); + +/* List of not NULL columns */ +enum enum_dyncol_func_result +dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint); + +/* + if the column do not exists it is NULL +*/ +enum enum_dyncol_func_result +dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr, + DYNAMIC_COLUMN_VALUE *store_it_here); + +#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... +***************************************************************************/ + +#define dynamic_column_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A)) + +#define dynamic_column_value_init(V) (V)->type= DYN_COL_NULL + +/* + Prepare value for using as decimal +*/ +void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value); + +#endif diff --git a/include/maria.h b/include/maria.h index f3d75214095..08febdb1a40 100644 --- a/include/maria.h +++ b/include/maria.h @@ -430,7 +430,8 @@ int maria_repair_by_sort(HA_CHECK *param, MARIA_HA *info, int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, const char *name, my_bool rep_quick); int maria_change_to_newfile(const char *filename, const char *old_ext, - const char *new_ext, myf myflags); + const char *new_ext, time_t backup_time, + myf myflags); void maria_lock_memory(HA_CHECK *param); int maria_update_state_info(HA_CHECK *param, MARIA_HA *info, uint update); void maria_update_key_parts(MARIA_KEYDEF *keyinfo, double *rec_per_key_part, diff --git a/include/my_attribute.h b/include/my_attribute.h index d35b3013bdd..13d1dc42fc1 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -36,10 +36,15 @@ #ifndef __attribute__ # if !defined(__GNUC__) # define __attribute__(A) -# elif GCC_VERSION < 2008 -# define __attribute__(A) -# elif defined(__cplusplus) && GCC_VERSION < 3004 -# define __attribute__(A) +# else +# ifndef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +# endif +# if GCC_VERSION < 2008 +# define __attribute__(A) +# elif defined(__cplusplus) && GCC_VERSION < 3004 +# define __attribute__(A) +# endif # endif #endif diff --git a/include/my_base.h b/include/my_base.h index 408a57a7d70..fad2cd99d55 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -461,7 +461,9 @@ enum ha_base_keytype { #define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */ #define HA_ERR_INDEX_COL_TOO_LONG 178 /* Index column length exceeds limit */ #define HA_ERR_ROW_NOT_VISIBLE 179 -#define HA_ERR_LAST 179 /* Copy of last error nr */ +#define HA_ERR_ABORTED_BY_USER 180 +#define HA_ERR_DISK_FULL 181 +#define HA_ERR_LAST 181 /* Copy of last error nr */ /* Number of different errors */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) @@ -535,7 +537,7 @@ enum en_fieldtype { }; enum data_file_type { - STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD + STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD, NO_RECORD }; /* For key ranges */ @@ -558,11 +560,13 @@ typedef struct st_key_range enum ha_rkey_function flag; } key_range; +typedef void *range_id_t; + typedef struct st_key_multi_range { key_range start_key; key_range end_key; - char *ptr; /* Free to use by caller (ptr to row etc) */ + range_id_t ptr; /* Free to use by caller (ptr to row etc) */ uint range_flag; /* key range flags see above */ } KEY_MULTI_RANGE; diff --git a/include/my_bit.h b/include/my_bit.h index 50dd7eb438a..174e0f70083 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. + Copyright (c) 2009-2011, 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 diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 2b173e7627c..0edda50de05 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2009-2011, 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 diff --git a/include/my_compare.h b/include/my_compare.h index 53e5aa94c3c..39186e40a15 100644 --- a/include/my_compare.h +++ b/include/my_compare.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, Oracle and/or its affiliates. + Copyright (c) Monty Program Ab; 1991-2011 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 @@ -61,22 +62,22 @@ typedef struct st_HA_KEYSEG /* Key-portion */ } HA_KEYSEG; #define get_key_length(length,key) \ -{ if (*(uchar*) (key) != 255) \ - length= (uint) *(uchar*) ((key)++); \ +{ if (*(const uchar*) (key) != 255) \ + length= (uint) *(const uchar*) ((key)++); \ else \ { length= mi_uint2korr((key)+1); (key)+=3; } \ } #define get_key_length_rdonly(length,key) \ -{ if (*(uchar*) (key) != 255) \ - length= ((uint) *(uchar*) ((key))); \ +{ if (*(const uchar*) (key) != 255) \ + length= ((uint) *(const uchar*) ((key))); \ else \ { length= mi_uint2korr((key)+1); } \ } #define get_key_pack_length(length,length_pack,key) \ -{ if (*(uchar*) (key) != 255) \ - { length= (uint) *(uchar*) ((key)++); length_pack= 1; }\ +{ if (*(const uchar*) (key) != 255) \ + { length= (uint) *(const uchar*) ((key)++); length_pack= 1; }\ else \ { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \ } diff --git a/include/my_compiler.h b/include/my_compiler.h index e3ff80fad40..9fe8de574a7 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -1,7 +1,7 @@ #ifndef MY_COMPILER_INCLUDED #define MY_COMPILER_INCLUDED -/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. 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 diff --git a/include/my_dbug.h b/include/my_dbug.h index 9c81b0cf919..e4de723e1d7 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000 MySQL AB & 2009 Monty Program Ab +/* Copyright (c) 2009-2011 Monty Program Ab Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify @@ -14,16 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MY_DBUG_INCLUDED -#define MY_DBUG_INCLUDED +#ifndef _my_dbug_h +#define _my_dbug_h #ifndef __WIN__ -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif #include <signal.h> #endif /* not __WIN__ */ @@ -96,7 +90,7 @@ extern void _db_free_(void *ptr); #define DBUG_END() _db_end_ () #define DBUG_LOCK_FILE _db_lock_file_() #define DBUG_UNLOCK_FILE _db_unlock_file_() -#define DBUG_ASSERT(A) assert(A) +#define DBUG_ASSERT(A) do { _db_flush_(); assert(A); } while(0) #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len)) #define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len)) #define DEBUGGER_OFF do { _dbug_on_= 0; } while(0) @@ -104,6 +98,7 @@ extern void _db_free_(void *ptr); #define DBUG_MALLOC(SIZE) _db_malloc_(SIZE) #define DBUG_REALLOC(PTR,SIZE) _db_realloc_(PTR,SIZE) #define DBUG_FREE(PTR) _db_free_(PTR) +#define IF_DBUG(A,B) A #ifndef __WIN__ #define DBUG_ABORT() (_db_flush_(), abort()) @@ -118,15 +113,6 @@ extern void _db_free_(void *ptr); (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\ _exit(3)) #endif -#define DBUG_CHECK_CRASH(func, op) \ - do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \ - DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0) -#define DBUG_CRASH_ENTER(func) \ - DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter") -#define DBUG_CRASH_RETURN(val) \ - DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return") -#define DBUG_CRASH_VOID_RETURN \ - DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return") /* Make the program fail, without creating a core file. @@ -173,6 +159,7 @@ extern void _db_suicide_(); #define DBUG_MALLOC(SIZE) malloc(SIZE) #define DBUG_REALLOC(PTR,SIZE) realloc(PTR,SIZE) #define DBUG_FREE(PTR) free(PTR) +#define IF_DBUG(A,B) B #define DBUG_ABORT() do { } while(0) #define DBUG_CRASH_ENTER(func) #define DBUG_CRASH_RETURN(val) do { return(val); } while(0) @@ -200,4 +187,4 @@ void debug_sync_point(const char* lock_name, uint lock_timeout); } #endif -#endif /* MY_DBUG_INCLUDED */ +#endif /* _my_dbug_h */ diff --git a/include/my_decimal_limits.h b/include/my_decimal_limits.h new file mode 100644 index 00000000000..b395a2ed144 --- /dev/null +++ b/include/my_decimal_limits.h @@ -0,0 +1,45 @@ +#ifndef MY_DECIMAL_LIMITS_INCLUDED +#define MY_DECIMAL_LIMITS_INCLUDED +/* Copyright (c) 2011 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define DECIMAL_LONGLONG_DIGITS 22 +#define DECIMAL_LONG_DIGITS 10 +#define DECIMAL_LONG3_DIGITS 8 + +/** maximum length of buffer in our big digits (uint32). */ +#define DECIMAL_BUFF_LENGTH 9 + +/* the number of digits that my_decimal can possibly contain */ +#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9) + + +/** + maximum guaranteed precision of number in decimal digits (number of our + digits * number of decimal digits in one our big digit - number of decimal + digits in one our big digit decreased by 1 (because we always put decimal + point on the border of our big digits)) +*/ +#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2) +#define DECIMAL_MAX_SCALE 30 +#define DECIMAL_NOT_SPECIFIED 31 + +/** + maximum length of string representation (number of maximum decimal + digits + 1 position for sign + 1 position for decimal point) +*/ +#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2) + +#endif /* MY_DECIMAL_LIMITS_INCLUDED */ diff --git a/include/my_global.h b/include/my_global.h index 4a7535e1c4d..e08719fd988 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -753,10 +753,10 @@ inline unsigned long long my_double2ulonglong(double d) #define strtok_r(A,B,C) strtok((A),(B)) #endif -/* This is from the old m-machine.h file */ - -#if SIZEOF_LONG_LONG > 4 +#if SIZEOF_LONG_LONG >= 8 #define HAVE_LONG_LONG 1 +#else +#error WHAT? sizeof(long long) < 8 ??? #endif /* diff --git a/include/my_pthread.h b/include/my_pthread.h index c0321cde6ed..40b939f8fc7 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (C) 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc, + 2010-2011 Oracle and/or its affiliates, 2009-2010 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 @@ -85,37 +86,11 @@ typedef volatile LONG my_pthread_once_t; #define MY_PTHREAD_ONCE_INPROGRESS 1 #define MY_PTHREAD_ONCE_DONE 2 -/* - Struct and macros to be used in combination with the - windows implementation of pthread_cond_timedwait -*/ - -/* - Declare a union to make sure FILETIME is properly aligned - so it can be used directly as a 64 bit value. The value - stored is in 100ns units. - */ -union ft64 { - FILETIME ft; - __int64 i64; -}; - struct timespec { - union ft64 tv; - /* The max timeout value in millisecond for pthread_cond_timedwait */ - long max_timeout_msec; + time_t tv_sec; + long tv_nsec; }; -#define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \ - (ABSTIME).tv.i64= (TIME)+(__int64)(NSEC)/100; \ - (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ -} while(0) - -#define set_timespec_nsec(ABSTIME,NSEC) do { \ - union ft64 tv; \ - GetSystemTimeAsFileTime(&tv.ft); \ - set_timespec_time_nsec((ABSTIME), tv.i64, (NSEC)); \ -} while(0) /** Compare two timespec structs. @@ -413,7 +388,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #ifndef set_timespec_nsec #define set_timespec_nsec(ABSTIME,NSEC) \ - set_timespec_time_nsec((ABSTIME),my_getsystime(),(NSEC)) + set_timespec_time_nsec((ABSTIME), my_hrtime().val*1000 + (NSEC)) #endif /* !set_timespec_nsec */ /* adapt for two different flavors of struct timespec */ @@ -443,11 +418,10 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif /* !cmp_timespec */ #ifndef set_timespec_time_nsec -#define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \ - ulonglong nsec= (NSEC); \ - ulonglong now= (TIME) + (nsec/100); \ - (ABSTIME).MY_tv_sec= (now / ULL(10000000)); \ - (ABSTIME).MY_tv_nsec= (now % ULL(10000000) * 100 + (nsec % 100)); \ +#define set_timespec_time_nsec(ABSTIME,NSEC) do { \ + 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 0fdae2eb5df..ca27e0f76a5 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (C) 2000-2003 MySQL 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 @@ -38,6 +38,7 @@ typedef struct my_aio_result { #ifdef _WIN32 #include <malloc.h> /*for alloca*/ #endif +#include <mysql/plugin.h> #define MY_INIT(name) { my_progname= name; my_init(); } @@ -142,6 +143,9 @@ typedef struct my_aio_result { #define GETDATE_GMT 8 #define GETDATE_FIXEDLENGTH 16 +/* Extra length needed for filename if one calls my_create_backup_name */ +#define MY_BACKUP_NAME_EXTRA_LENGTH 17 + /* defines when allocating data */ extern void *my_malloc(size_t Size,myf MyFlags); extern void *my_multi_malloc(myf MyFlags, ...); @@ -171,7 +175,7 @@ extern void my_large_free(uchar *ptr); #define my_large_free(A) my_free_lock((A)) #endif /* HAVE_LARGE_PAGES */ -#ifdef HAVE_ALLOCA +#if defined(HAVE_ALLOCA) && !defined(HAVE_valgrind) #if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) #pragma alloca #endif /* _AIX */ @@ -209,7 +213,7 @@ extern void (*fatal_error_handler_hook)(uint my_err, const char *str, extern uint my_file_limit; extern ulong my_thread_stack_size; -extern const char *(*proc_info_hook)(void *, const char *, const char *, +extern const char *(*proc_info_hook)(MYSQL_THD, const char *, const char *, const char *, const unsigned int); #ifdef HAVE_LARGE_PAGES @@ -314,9 +318,6 @@ struct st_my_file_info int oflag; /* open flags, e.g O_APPEND */ #endif enum file_type type; -#if !defined(HAVE_PREAD) && !defined(_WIN32) - mysql_mutex_t mutex; -#endif }; extern struct st_my_file_info *my_file_info; @@ -528,6 +529,8 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); #define my_b_tell(info) ((info)->pos_in_file + \ (size_t) (*(info)->current_pos - (info)->request_pos)) +#define my_b_write_tell(info) ((info)->pos_in_file + \ + ((info)->write_pos - (info)->write_buffer)) #define my_b_get_buffer_start(info) (info)->request_pos #define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \ @@ -651,7 +654,10 @@ extern void my_message(uint my_err, const char *str,myf MyFlags); extern void my_message_stderr(uint my_err, const char *str, myf MyFlags); extern my_bool my_init(void); extern void my_end(int infoflag); -extern int my_redel(const char *from, const char *to, int MyFlags); +extern int my_redel(const char *from, const char *to, time_t backup_time_stamp, + myf MyFlags); +void my_create_backup_name(char *to, const char *from, + time_t backup_time_stamp); extern int my_copystat(const char *from, const char *to, int MyFlags); extern char * my_filename(File fd); @@ -796,6 +802,8 @@ 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 void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length, + size_t *alloc_length); #ifdef HAVE_MLOCK extern void *my_malloc_lock(size_t length,myf flags); extern void my_free_lock(void *ptr); @@ -861,15 +869,23 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len); extern uint my_set_max_open_files(uint files); void my_free_open_file_info(void); -extern time_t my_time(myf flags); -extern ulonglong my_getsystime(void); -extern ulonglong my_getcputime(void); -extern ulonglong my_micro_time(); -extern ulonglong my_micro_time_and_time(time_t *time_arg); -time_t my_time_possible_from_micro(ulonglong microtime); extern my_bool my_gethwaddr(uchar *to); extern int my_getncpus(); +#define HRTIME_RESOLUTION 1000000ULL /* microseconds */ +typedef struct {ulonglong val;} my_hrtime_t; +void my_time_init(); +extern my_hrtime_t my_hrtime(); +extern ulonglong my_interval_timer(void); +extern ulonglong my_getcputime(void); + +#define microsecond_interval_timer() (my_interval_timer()/1000) +#define hrtime_to_time(X) ((X).val/HRTIME_RESOLUTION) +#define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION)) +#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION) +#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION)) +#define my_time(X) hrtime_to_time(my_hrtime()) + #ifdef HAVE_SYS_MMAN_H #include <sys/mman.h> diff --git a/include/my_time.h b/include/my_time.h index 68f9c2e739f..e747e9d55db 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -45,7 +45,7 @@ typedef long my_time_t; #define TIMESTAMP_MAX_YEAR 2038 #define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1) #define TIMESTAMP_MAX_VALUE INT_MAX32 -#define TIMESTAMP_MIN_VALUE 1 +#define TIMESTAMP_MIN_VALUE 0 /* two-digit years < this are 20..; >= this are 19.. */ #define YY_PART_YEAR 70 @@ -66,6 +66,7 @@ typedef long my_time_t; /* Flags to str_to_datetime */ #define TIME_FUZZY_DATE 1 #define TIME_DATETIME_ONLY 2 +#define TIME_TIME_ONLY 4 /* Must be same as MODE_NO_ZERO_IN_DATE */ #define TIME_NO_ZERO_IN_DATE (65536L*2*2*2*2*2*2*2) /* Must be same as MODE_NO_ZERO_DATE */ @@ -79,28 +80,46 @@ typedef long my_time_t; #define TIME_MAX_HOUR 838 #define TIME_MAX_MINUTE 59 #define TIME_MAX_SECOND 59 -#define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + \ - TIME_MAX_SECOND) +#define TIME_MAX_SECOND_PART 999999 +#define TIME_SECOND_PART_FACTOR (TIME_MAX_SECOND_PART+1) +#define TIME_SECOND_PART_DIGITS 6 +#define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + TIME_MAX_SECOND) #define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \ TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND) my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, ulonglong flags, int *was_cut); enum enum_mysql_timestamp_type +str_to_time(const char *str, uint length, MYSQL_TIME *l_time, + ulong flag, int *warning); +enum enum_mysql_timestamp_type str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, ulonglong flags, int *was_cut); -longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, +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, uint 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); +} + +int number_to_time(my_bool neg, longlong 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 *); ulonglong TIME_to_ulonglong(const MYSQL_TIME *); +double TIME_to_double(const MYSQL_TIME *my_time); +longlong pack_time(MYSQL_TIME *my_time); +MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time); -my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time, - int *warning); - -int check_time_range(struct st_mysql_time *, int *warning); +int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning); long calc_daynr(uint year,uint month,uint day); uint calc_days_in_year(uint year); @@ -133,8 +152,7 @@ static inline my_bool validate_timestamp_range(const MYSQL_TIME *t) } my_time_t -my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, - my_bool *in_dst_time_gap); +my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, uint *error_code); void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type); @@ -147,11 +165,28 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type); sent using binary protocol fit in this buffer. */ #define MAX_DATE_STRING_REP_LENGTH 30 +#define AUTO_SEC_PART_DIGITS 31 /* same as NOT_FIXED_DEC */ -int my_time_to_str(const MYSQL_TIME *l_time, char *to); +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); -int my_TIME_to_str(const MYSQL_TIME *l_time, char *to); +int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits); +int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits); + +static inline longlong sec_part_shift(longlong second_part, uint digits) +{ + return second_part / (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; +} +static inline longlong sec_part_unshift(longlong second_part, uint digits) +{ + return second_part * (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; +} +static inline ulong sec_part_truncate(ulong second_part, uint digits) +{ + /* the cast here should be unnecessary! */ + return second_part - second_part % (ulong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; +} + +#define hrtime_to_my_time(X) ((my_time_t)hrtime_to_time(X)) /* Available interval types used in any statement. diff --git a/include/my_tree.h b/include/my_tree.h index b4f2c07c794..3524c82a2bc 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -31,7 +31,17 @@ extern "C" { #define tree_set_pointer(element,ptr) *((uchar **) (element+1))=((uchar*) (ptr)) +/* + A tree with its flag set to TREE_ONLY_DUPS behaves differently on inserting + an element that is not in the tree: + the element is not added at all, but instead tree_insert() returns a special + address TREE_ELEMENT_UNIQUE as an indication that the function has not failed + due to lack of memory. +*/ + +#define TREE_ELEMENT_UNIQUE ((TREE_ELEMENT *) 1) #define TREE_NO_DUPS 1 +#define TREE_ONLY_DUPS 2 typedef enum { left_root_right, right_root_left } TREE_WALK; typedef uint32 element_count; diff --git a/include/myisam.h b/include/myisam.h index fb4f2e260e6..0fd87839057 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -290,6 +290,8 @@ extern int mi_is_changed(struct st_myisam_info *info); extern int mi_delete_all_rows(struct st_myisam_info *info); extern ulong _mi_calc_blob_length(uint length , const uchar *pos); extern uint mi_get_pointer_length(ulonglong file_length, uint def); +extern int mi_make_backup_of_index(struct st_myisam_info *info, + time_t backup_time, myf flags); #define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for mmap file */ /* this is used to pass to mysql_myisamchk_table */ @@ -382,7 +384,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, const char * name, int rep_quick); int change_to_newfile(const char * filename, const char * old_ext, - const char * new_ext, myf myflags); + const char * new_ext, time_t backup_time, myf myflags); int lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type, const char *filetype, const char *filename); void lock_memory(HA_CHECK *param); diff --git a/include/myisamchk.h b/include/myisamchk.h index 57a015238e0..bd184c75e7e 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -74,7 +74,7 @@ #define TT_USEFRM 1 #define TT_FOR_UPGRADE 2 -#define O_NEW_INDEX 1 /* Bits set in out_flag */ +/* Bits set in out_flag */ #define O_NEW_DATA 2 #define O_DATA_LOST 4 @@ -141,6 +141,7 @@ typedef struct st_handler_check_param ulonglong use_buffers; /* Used as param to getopt() */ size_t read_buffer_length, write_buffer_length; size_t sort_buffer_length, sort_key_blocks; + time_t backup_time; /* To sign backup files */ ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; double new_rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; uint out_flag, warning_printed, error_printed, verbose; @@ -154,6 +155,11 @@ typedef struct st_handler_check_param char temp_filename[FN_REFLEN]; IO_CACHE read_cache; enum_handler_stats_method stats_method; + /* For reporting progress */ + uint stage, max_stage; + uint progress_counter; /* How often to call _report_progress() */ + ulonglong progress, max_progress; + mysql_mutex_t print_msg_mutex; my_bool need_print_msg_lock; } HA_CHECK; diff --git a/include/mysql.h b/include/mysql.h index 28def52e422..2b1c90b0fd9 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -166,7 +166,8 @@ enum mysql_option MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT, - MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH + MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, + MYSQL_PROGRESS_CALLBACK }; /** diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 821e7b26454..eed977aff50 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -100,7 +100,8 @@ int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, struct my_rnd_struct; enum Item_result { - STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT + STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT, + TIME_RESULT,IMPOSSIBLE_RESULT }; typedef struct st_udf_args { @@ -261,7 +262,8 @@ enum mysql_option MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT, - MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH + MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, + MYSQL_PROGRESS_CALLBACK }; struct st_mysql_options_extention; struct st_mysql_options { diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index f77dfbcc8d5..32228b63428 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -1,4 +1,5 @@ /* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc. + Copyright (C) 2009-2011 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 @@ -75,7 +76,7 @@ typedef struct st_mysql_xid MYSQL_XID; #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0102 /* MariaDB plugin interface version */ -#define MARIA_PLUGIN_INTERFACE_VERSION 0x0100 +#define MARIA_PLUGIN_INTERFACE_VERSION 0x0101 /* The allowable types of plugins @@ -590,10 +591,6 @@ char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length, /* Increments the row counter, see THD::row_count */ void thd_inc_row_count(MYSQL_THD thd); -#define thd_proc_info(thd, msg) set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__) -const char *set_thd_proc_info(void *, const char * info, const char *func, - const char *file, const unsigned int line); - /** Create a temporary file. diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 42d44b9dae0..a435c7c64b2 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -59,6 +59,27 @@ extern struct my_thread_scheduler_service { } *my_thread_scheduler_service; int my_thread_scheduler_set(struct scheduler_functions *scheduler); int my_thread_scheduler_reset(); +#include <mysql/service_progress_report.h> +extern struct progress_report_service_st { + void (*thd_progress_init_func)(void* thd, unsigned int max_stage); + void (*thd_progress_report_func)(void* thd, + unsigned long long progress, + unsigned long long max_progress); + void (*thd_progress_next_stage_func)(void* thd); + void (*thd_progress_end_func)(void* thd); + const char *(*set_thd_proc_info_func)(void*, const char *info, + const char *func, + const char *file, + unsigned int line); +} *progress_report_service; +void thd_progress_init(void* thd, unsigned int max_stage); +void thd_progress_report(void* thd, + unsigned long long progress, + unsigned long long max_progress); +void thd_progress_next_stage(void* thd); +void thd_progress_end(void* thd); +const char *set_thd_proc_info(void*, const char * info, const char *func, + const char *file, unsigned int line); struct st_mysql_xid { long formatID; long gtrid_length; @@ -200,8 +221,6 @@ int thd_tx_isolation(const void* thd); char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); -const char *set_thd_proc_info(void*, const char * info, const char *func, - const char *file, const unsigned int line); int mysql_tmpfile(const char *prefix); int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 9bf16181273..7a40ee5b9f7 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -59,6 +59,27 @@ extern struct my_thread_scheduler_service { } *my_thread_scheduler_service; int my_thread_scheduler_set(struct scheduler_functions *scheduler); int my_thread_scheduler_reset(); +#include <mysql/service_progress_report.h> +extern struct progress_report_service_st { + void (*thd_progress_init_func)(void* thd, unsigned int max_stage); + void (*thd_progress_report_func)(void* thd, + unsigned long long progress, + unsigned long long max_progress); + void (*thd_progress_next_stage_func)(void* thd); + void (*thd_progress_end_func)(void* thd); + const char *(*set_thd_proc_info_func)(void*, const char *info, + const char *func, + const char *file, + unsigned int line); +} *progress_report_service; +void thd_progress_init(void* thd, unsigned int max_stage); +void thd_progress_report(void* thd, + unsigned long long progress, + unsigned long long max_progress); +void thd_progress_next_stage(void* thd); +void thd_progress_end(void* thd); +const char *set_thd_proc_info(void*, const char * info, const char *func, + const char *file, unsigned int line); struct st_mysql_xid { long formatID; long gtrid_length; @@ -200,8 +221,6 @@ int thd_tx_isolation(const void* thd); char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); -const char *set_thd_proc_info(void *, const char * info, const char *func, - const char *file, const unsigned int line); int mysql_tmpfile(const char *prefix); int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 0067732d4fc..527be747cb4 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -43,7 +43,7 @@ typedef enum _thd_wait_type_e { THD_WAIT_BINLOG= 8, THD_WAIT_GROUP_COMMIT= 9, THD_WAIT_SYNC= 10, - THD_WAIT_LAST= 11 + THD_WAIT_LAST= 11 } thd_wait_type; extern struct thd_wait_service_st { void (*thd_wait_begin_func)(void*, int); @@ -59,6 +59,27 @@ extern struct my_thread_scheduler_service { } *my_thread_scheduler_service; int my_thread_scheduler_set(struct scheduler_functions *scheduler); int my_thread_scheduler_reset(); +#include <mysql/service_progress_report.h> +extern struct progress_report_service_st { + void (*thd_progress_init_func)(void* thd, unsigned int max_stage); + void (*thd_progress_report_func)(void* thd, + unsigned long long progress, + unsigned long long max_progress); + void (*thd_progress_next_stage_func)(void* thd); + void (*thd_progress_end_func)(void* thd); + const char *(*set_thd_proc_info_func)(void*, const char *info, + const char *func, + const char *file, + unsigned int line); +} *progress_report_service; +void thd_progress_init(void* thd, unsigned int max_stage); +void thd_progress_report(void* thd, + unsigned long long progress, + unsigned long long max_progress); +void thd_progress_next_stage(void* thd); +void thd_progress_end(void* thd); +const char *set_thd_proc_info(void*, const char * info, const char *func, + const char *file, unsigned int line); struct st_mysql_xid { long formatID; long gtrid_length; @@ -153,8 +174,6 @@ int thd_tx_isolation(const void* thd); char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); -const char *set_thd_proc_info(void*, const char * info, const char *func, - const char *file, const unsigned int line); int mysql_tmpfile(const char *prefix); int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); diff --git a/include/mysql/service_progress_report.h b/include/mysql/service_progress_report.h new file mode 100644 index 00000000000..670b1c37630 --- /dev/null +++ b/include/mysql/service_progress_report.h @@ -0,0 +1,82 @@ +#ifndef MYSQL_SERVICE_PROGRESS_REPORT_INCLUDED +/* Copyright (C) 2011 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/** + @file + This service allows plugins to report progress of long running operations + to the server. The progress report is visible in SHOW PROCESSLIST, + INFORMATION_SCHEMA.PROCESSLIST, and is sent to the client + if requested. + + The functions are documented at + http://kb.askmonty.org/en/progress-reporting#how-to-add-support-for-progress-reporting-to-a-storage-engine +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define thd_proc_info(thd, msg) set_thd_proc_info(thd, msg, \ + __func__, __FILE__, __LINE__) + +extern struct progress_report_service_st { + void (*thd_progress_init_func)(MYSQL_THD thd, unsigned int max_stage); + void (*thd_progress_report_func)(MYSQL_THD thd, + unsigned long long progress, + unsigned long long max_progress); + void (*thd_progress_next_stage_func)(MYSQL_THD thd); + void (*thd_progress_end_func)(MYSQL_THD thd); + const char *(*set_thd_proc_info_func)(MYSQL_THD, const char *info, + const char *func, + const char *file, + unsigned int line); +} *progress_report_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN + +#define thd_progress_init(thd,max_stage) (progress_report_service->thd_progress_init_func((thd),(max_stage))) +#define thd_progress_report(thd, progress, max_progress) (progress_report_service->thd_progress_report_func((thd), (progress), (max_progress))) +#define thd_progress_next_stage(thd) (progress_report_service->thd_progress_next_stage_func(thd)) +#define thd_progress_end(thd) (progress_report_service->thd_progress_end_func(thd)) +#define set_thd_proc_info(thd,info,func,file,line) (progress_report_service->set_thd_proc_info_func((thd),(info),(func),(file),(line))) + +#else + +/** + Report progress for long running operations + + @param thd User thread connection handle + @param progress Where we are now + @param max_progress Progress will continue up to this +*/ +void thd_progress_init(MYSQL_THD thd, unsigned int max_stage); +void thd_progress_report(MYSQL_THD thd, + unsigned long long progress, + unsigned long long max_progress); +void thd_progress_next_stage(MYSQL_THD thd); +void thd_progress_end(MYSQL_THD thd); +const char *set_thd_proc_info(MYSQL_THD, const char * info, const char *func, + const char *file, unsigned int line); + +#endif + +#ifdef __cplusplus +} +#endif + +#define MYSQL_SERVICE_PROGRESS_REPORT_INCLUDED +#endif + diff --git a/include/mysql/services.h b/include/mysql/services.h index 6c67a582fb8..bd029e55b78 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -22,6 +22,7 @@ extern "C" { #include <mysql/service_thd_alloc.h> #include <mysql/service_thd_wait.h> #include <mysql/service_thread_scheduler.h> +#include <mysql/service_progress_report.h> #ifdef __cplusplus } diff --git a/include/mysql/thread_pool_priv.h b/include/mysql/thread_pool_priv.h index 97d0cbfab6a..f56242fd74f 100644 --- a/include/mysql/thread_pool_priv.h +++ b/include/mysql/thread_pool_priv.h @@ -51,7 +51,6 @@ void thd_lock_thread_count(THD *thd); void thd_unlock_thread_count(THD *thd); void thd_close_connection(THD *thd); THD *thd_get_current_thd(); -void thd_new_connection_setup(THD *thd, char *stack_start); void thd_lock_data(THD *thd); void thd_unlock_data(THD *thd); bool thd_is_transaction_active(THD *thd); diff --git a/include/mysql_com.h b/include/mysql_com.h index 7f2b4d53ec0..e4f065e3e93 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (C) 2000 MySQL 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 @@ -152,6 +152,7 @@ enum enum_server_command #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 */ @@ -179,6 +180,7 @@ enum enum_server_command #define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */ #define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */ +#define CLIENT_PROGRESS (1UL << 29) /* Client support progress indicator */ #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) #define CLIENT_REMEMBER_OPTIONS (1UL << 31) @@ -211,6 +213,7 @@ enum enum_server_command CLIENT_PS_MULTI_RESULTS | \ CLIENT_SSL_VERIFY_SERVER_CERT | \ CLIENT_REMEMBER_OPTIONS | \ + CLIENT_PROGRESS | \ CLIENT_PLUGIN_AUTH) /* @@ -481,7 +484,8 @@ struct my_rnd_struct; enum Item_result { - STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT + STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT, + TIME_RESULT,IMPOSSIBLE_RESULT }; typedef struct st_udf_args diff --git a/include/mysys_err.h b/include/mysys_err.h index 620b43bb317..1308c645d16 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -66,9 +66,10 @@ extern const char *globerrs[]; /* my_error_messages is here */ #define EE_CHANGE_OWNERSHIP 31 #define EE_CHANGE_PERMISSIONS 32 #define EE_CANT_SEEK 33 -#define EE_CANT_CHMOD 34 +#define EE_CANT_CHMOD 34 #define EE_CANT_COPY_OWNERSHIP 35 #define EE_ERROR_LAST 35 /* Copy last error nr */ + /* Add error numbers before EE_ERROR_LAST and change it accordingly. */ /* exit codes for all MySQL programs */ @@ -87,9 +88,7 @@ extern const char *globerrs[]; /* my_error_messages is here */ #define EXIT_OPTION_DISABLED 12 #define EXIT_ARGUMENT_INVALID 13 - #ifdef __cplusplus } #endif #endif - diff --git a/include/service_versions.h b/include/service_versions.h index 4fd886c8a83..135243593f9 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -23,3 +23,4 @@ #define VERSION_thd_alloc 0x0100 #define VERSION_thd_wait 0x0100 #define VERSION_my_thread_scheduler 0x0100 +#define VERSION_progress_report 0x0100 diff --git a/include/sql_common.h b/include/sql_common.h index 2fc66a559ba..2ea6c05d717 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -28,6 +28,12 @@ extern const char *not_error_sqlstate; struct st_mysql_options_extention { char *plugin_dir; char *default_auth; + void (*report_progress)(const MYSQL *mysql, + unsigned int stage, + unsigned int max_stage, + double progress, + const char *proc_info, + uint proc_info_length); }; typedef struct st_mysql_methods diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 351041ac042..15df74c1588 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -88,6 +88,7 @@ typedef struct st_alarm { extern uint thr_client_alarm; extern pthread_t alarm_thread; +extern my_bool my_disable_thr_alarm; #define thr_alarm_init(A) (*(A))=0 #define thr_alarm_in_use(A) (*(A)!= 0) diff --git a/include/thr_lock.h b/include/thr_lock.h index 531575e9e9f..a744fab8aec 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -104,9 +104,10 @@ typedef struct st_thr_lock_data { struct st_thr_lock *lock; mysql_cond_t *cond; void *status_param; /* Param to status functions */ - void *debug_print_param; + void *debug_print_param; /* For error messages */ struct PSI_table *m_psi; enum thr_lock_type type; + enum thr_lock_type org_type; /* Cache for MariaDB */ uint priority; } THR_LOCK_DATA; @@ -131,6 +132,7 @@ typedef struct st_thr_lock { my_bool (*start_trans)(void*); /* When all locks are taken */ my_bool (*check_status)(void *); void (*fix_status)(void *, void *);/* For thr_merge_locks() */ + const char *name; /* Used for error reporting */ my_bool allow_multiple_concurrent_insert; } THR_LOCK; |