summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt56
-rw-r--r--include/atomic/nolock.h54
-rw-r--r--include/atomic/x86-gcc.h6
-rw-r--r--include/byte_order_generic_x86_64.h97
-rw-r--r--include/decimal.h2
-rw-r--r--include/dur_prop.h32
-rw-r--r--include/hash.h4
-rw-r--r--include/heap.h2
-rw-r--r--include/json_lib.h432
-rw-r--r--include/lf.h7
-rw-r--r--include/m_ctype.h192
-rw-r--r--include/m_string.h8
-rw-r--r--include/maria.h2
-rw-r--r--include/my_atomic.h37
-rw-r--r--include/my_base.h251
-rw-r--r--include/my_bit.h46
-rw-r--r--include/my_bitmap.h1
-rw-r--r--include/my_compare.h4
-rw-r--r--include/my_compiler.h23
-rw-r--r--include/my_context.h6
-rw-r--r--include/my_dbug.h22
-rw-r--r--include/my_decimal_limits.h10
-rw-r--r--include/my_dir.h13
-rw-r--r--include/my_global.h37
-rw-r--r--include/my_handler_errors.h40
-rw-r--r--include/my_pthread.h55
-rw-r--r--include/my_service_manager.h2
-rw-r--r--include/my_sys.h175
-rw-r--r--include/my_time.h22
-rw-r--r--include/my_valgrind.h7
-rw-r--r--include/myisam.h13
-rw-r--r--include/myisamchk.h22
-rw-r--r--include/myisampack.h12
-rw-r--r--include/mysql.h9
-rw-r--r--include/mysql.h.pp30
-rw-r--r--include/mysql/plugin.h5
-rw-r--r--include/mysql/plugin_audit.h2
-rw-r--r--include/mysql/plugin_audit.h.pp40
-rw-r--r--include/mysql/plugin_auth.h.pp38
-rw-r--r--include/mysql/plugin_encryption.h.pp38
-rw-r--r--include/mysql/plugin_ftparser.h.pp38
-rw-r--r--include/mysql/plugin_password_validation.h.pp38
-rw-r--r--include/mysql/psi/mysql_idle.h3
-rw-r--r--include/mysql/psi/mysql_socket.h23
-rw-r--r--include/mysql/psi/mysql_statement.h3
-rw-r--r--include/mysql/psi/mysql_table.h3
-rw-r--r--include/mysql/psi/mysql_thread.h18
-rw-r--r--include/mysql/psi/psi_base.h147
-rw-r--r--include/mysql/psi/psi_memory.h155
-rw-r--r--include/mysql/service_base64.h36
-rw-r--r--include/mysql/service_thd_alloc.h20
-rw-r--r--include/mysql/service_wsrep.h10
-rw-r--r--include/mysql_async.h4
-rw-r--r--include/mysql_com.h269
-rw-r--r--include/pack.h29
-rw-r--r--include/service_versions.h2
-rw-r--r--include/sql_common.h8
-rw-r--r--include/ssl_compat.h92
-rw-r--r--include/thr_lock.h10
-rw-r--r--include/thread_pool_priv.h4
-rw-r--r--include/typelib.h5
-rw-r--r--include/violite.h32
62 files changed, 2020 insertions, 783 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 26ac7f3a832..a7b98a11050 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -25,6 +25,7 @@ SET(HEADERS
mysql.h
mysql_com.h
mysql_com_server.h
+ pack.h
my_byteorder.h
byte_order_generic.h
byte_order_generic_x86.h
@@ -60,25 +61,54 @@ SET(HEADERS
my_compiler.h
handler_state.h
handler_ername.h
+ json_lib.h
)
-INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
+# don't use C/C's (possibly outdated) copy of mysqld_error.h
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h
+ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
+
+INSTALL(FILES ${HEADERS}
+ DESTINATION ${INSTALL_INCLUDEDIR}/server COMPONENT Development)
FOREACH(f ${HEADERS_GEN_CONFIGURE})
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f}
+ DESTINATION ${INSTALL_INCLUDEDIR}/server COMPONENT Development)
ENDFOREACH(f)
-INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR}/server/mysql COMPONENT Development FILES_MATCHING PATTERN "*.h")
STRING(REPLACE "." "\\." EXCL_RE "${HEADERS};${HEADERS_GEN_CONFIGURE}")
STRING(REPLACE ";" "|" EXCL_RE "${EXCL_RE}")
-INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
- FILES_MATCHING PATTERN "*.h"
- PATTERN CMakeFiles EXCLUDE
- PATTERN mysql EXCLUDE
- REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
+MACRO(INSTALL_PRIVATE DIR)
+ INSTALL(DIRECTORY ${DIR}/.
+ DESTINATION ${INSTALL_INCLUDEDIR}/server/private COMPONENT Development
+ FILES_MATCHING PATTERN "*.h"
+ PATTERN CMakeFiles EXCLUDE
+ PATTERN mysql EXCLUDE
+ REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
+ENDMACRO()
+
+INSTALL_PRIVATE(${CMAKE_CURRENT_BINARY_DIR})
+IF(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
+ INSTALL_PRIVATE(${CMAKE_CURRENT_SOURCE_DIR})
+ENDIF()
+
+MACRO(INSTALL_COMPAT_HEADER file footer)
+ INSTALL(CODE "FILE(WRITE \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDEDIR}/${file}
+\"/* Do not edit this file directly, it was auto-generated by cmake */
+
+#warning This file should not be included by clients, include only <mysql.h>
+${footer}
+\")" COMPONENT Development)
+ENDMACRO()
-INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/. DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
- FILES_MATCHING PATTERN "*.h"
- PATTERN CMakeFiles EXCLUDE
- PATTERN mysql EXCLUDE
- REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
+INSTALL_COMPAT_HEADER(my_global.h "")
+INSTALL_COMPAT_HEADER(my_config.h "")
+INSTALL_COMPAT_HEADER(my_sys.h "")
+INSTALL_COMPAT_HEADER(mysql_version.h "
+#include <mariadb_version.h>
+#define LIBMYSQL_VERSION MARIADB_CLIENT_VERSION_STR
+")
+INSTALL_COMPAT_HEADER(mysql_com.h "
+#include <mariadb_com.h>
+")
diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h
deleted file mode 100644
index 8bbc9ca447e..00000000000
--- a/include/atomic/nolock.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef ATOMIC_NOLOCK_INCLUDED
-#define ATOMIC_NOLOCK_INCLUDED
-
-/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
-
- 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-1335 USA */
-
-#if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__) \
- || defined(HAVE_GCC_ATOMIC_BUILTINS) \
- || defined(HAVE_SOLARIS_ATOMIC)
-
-# ifdef MY_ATOMIC_MODE_DUMMY
-# define LOCK_prefix ""
-# else
-# define LOCK_prefix "lock"
-# endif
-/*
- We choose implementation as follows:
- ------------------------------------
- On Windows using Visual C++ the native implementation should be
- preferrable. When using gcc we prefer the Solaris implementation
- before the gcc because of stability preference, we choose gcc
- builtins if available, otherwise we choose the somewhat broken
- native x86 implementation. If neither Visual C++ or gcc we still
- choose the Solaris implementation on Solaris (mainly for SunStudio
- compilers).
-*/
-# if defined(_MSC_VER)
-# include "generic-msvc.h"
-# elif __GNUC__
-# if defined(HAVE_SOLARIS_ATOMIC)
-# include "solaris.h"
-# elif defined(HAVE_GCC_ATOMIC_BUILTINS)
-# include "gcc_builtins.h"
-# elif defined(__i386__) || defined(__x86_64__)
-# include "x86-gcc.h"
-# endif
-# elif defined(HAVE_SOLARIS_ATOMIC)
-# include "solaris.h"
-# endif
-#endif
-
-#endif /* ATOMIC_NOLOCK_INCLUDED */
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
index 679ecd3679e..18aa9b65c17 100644
--- a/include/atomic/x86-gcc.h
+++ b/include/atomic/x86-gcc.h
@@ -28,6 +28,12 @@
*/
#undef MY_ATOMIC_HAS_8_AND_16
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define LOCK_prefix ""
+#else
+#define LOCK_prefix "lock"
+#endif
+
#ifdef __x86_64__
# ifdef MY_ATOMIC_NO_XADD
# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
diff --git a/include/byte_order_generic_x86_64.h b/include/byte_order_generic_x86_64.h
index d235e8db3d8..68001ca941f 100644
--- a/include/byte_order_generic_x86_64.h
+++ b/include/byte_order_generic_x86_64.h
@@ -16,6 +16,7 @@
/*
Optimized function-like macros for the x86 architecture (_WIN32 included).
*/
+
#define sint2korr(A) (int16) (*((int16 *) (A)))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
(((uint32) 255L << 24) | \
@@ -31,17 +32,21 @@
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16))
#define uint4korr(A) (uint32) (*((uint32 *) (A)))
-#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16) +\
- (((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) ((uchar) (A)[4])) << 32))
-#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
- (((uint32) ((uchar) (A)[1])) << 8) + \
- (((uint32) ((uchar) (A)[2])) << 16) + \
- (((uint32) ((uchar) (A)[3])) << 24)) + \
- (((ulonglong) ((uchar) (A)[4])) << 32) + \
- (((ulonglong) ((uchar) (A)[5])) << 40))
+
+
+static inline ulonglong uint5korr(const void *p)
+{
+ ulonglong a= *(uint32 *) p;
+ ulonglong b= *(4 + (uchar *) p);
+ return a | (b << 32);
+}
+static inline ulonglong uint6korr(const void *p)
+{
+ ulonglong a= *(uint32 *) p;
+ ulonglong b= *(uint16 *) (4 + (char *) p);
+ return a | (b << 32);
+}
+
#define uint8korr(A) (ulonglong) (*((ulonglong *) (A)))
#define sint8korr(A) (longlong) (*((longlong *) (A)))
@@ -53,23 +58,67 @@
*(T+1)=(uchar) (((uint) (A) >> 8));\
*(T+2)=(uchar) (((A) >> 16));\
} while (0)
+
#define int4store(T,A) do { uchar *pT= (uchar*)(T);\
*((uint32 *) (pT))= (uint32) (A); \
} while (0)
-#define int5store(T,A) do { *(T)= (uchar)((A));\
- *((T)+1)=(uchar) (((A) >> 8));\
- *((T)+2)=(uchar) (((A) >> 16));\
- *((T)+3)=(uchar) (((A) >> 24));\
- *((T)+4)=(uchar) (((A) >> 32));\
- } while(0)
-#define int6store(T,A) do { *(T)= (uchar)((A)); \
- *((T)+1)=(uchar) (((A) >> 8)); \
- *((T)+2)=(uchar) (((A) >> 16)); \
- *((T)+3)=(uchar) (((A) >> 24)); \
- *((T)+4)=(uchar) (((A) >> 32)); \
- *((T)+5)=(uchar) (((A) >> 40)); \
- } while(0)
+#define int5store(T,A) do { uchar *pT= (uchar*)(T);\
+ *((uint32 *) (pT))= (uint32) (A); \
+ *((pT)+4)=(uchar) (((A) >> 32));\
+ } while (0)
+
+#define int6store(T,A) do { uchar *pT= (uchar*)(T);\
+ *((uint32 *) (pT))= (uint32) (A); \
+ *((uint16*)(pT+4))= (uint16) (A >> 32);\
+ } while (0)
+
#define int8store(T,A) do { uchar *pT= (uchar*)(T);\
*((ulonglong *) (pT))= (ulonglong) (A);\
} while(0)
+
+#if defined(__GNUC__)
+
+#define HAVE_mi_uint5korr
+#define HAVE_mi_uint6korr
+#define HAVE_mi_uint7korr
+#define HAVE_mi_uint78orr
+
+/* Read numbers stored in high-bytes-first order */
+
+static inline ulonglong mi_uint5korr(const void *p)
+{
+ ulonglong a= *(uint32 *) p;
+ ulonglong b= *(4 + (uchar *) p);
+ ulonglong v= (a | (b << 32)) << 24;
+ asm ("bswapq %0" : "=r" (v) : "0" (v));
+ return v;
+}
+
+static inline ulonglong mi_uint6korr(const void *p)
+{
+ ulonglong a= *(uint32 *) p;
+ ulonglong b= *(uint16 *) (4 + (char *) p);
+ ulonglong v= (a | (b << 32)) << 16;
+ asm ("bswapq %0" : "=r" (v) : "0" (v));
+ return v;
+}
+
+static inline ulonglong mi_uint7korr(const void *p)
+{
+ ulonglong a= *(uint32 *) p;
+ ulonglong b= *(uint16 *) (4 + (char *) p);
+ ulonglong c= *(6 + (uchar *) p);
+ ulonglong v= (a | (b << 32) | (c << 48)) << 8;
+ asm ("bswapq %0" : "=r" (v) : "0" (v));
+ return v;
+}
+
+static inline ulonglong mi_uint8korr(const void *p)
+{
+ ulonglong v= *(ulonglong *) p;
+ asm ("bswapq %0" : "=r" (v) : "0" (v));
+ return v;
+}
+
+#endif
diff --git a/include/decimal.h b/include/decimal.h
index 648e908f800..cab18f99348 100644
--- a/include/decimal.h
+++ b/include/decimal.h
@@ -51,7 +51,7 @@ 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 decimal_actual_fraction(const decimal_t *from);
int decimal2bin(const decimal_t *from, uchar *to, int precision, int scale);
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
diff --git a/include/dur_prop.h b/include/dur_prop.h
new file mode 100644
index 00000000000..558ce5acc01
--- /dev/null
+++ b/include/dur_prop.h
@@ -0,0 +1,32 @@
+/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+
+ 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 _my_dur_prop_h
+#define _my_dur_prop_h
+
+enum durability_properties
+{
+ /*
+ Preserves the durability properties defined by the engine
+ */
+ HA_REGULAR_DURABILITY= 0,
+ /*
+ Ignore the durability properties defined by the engine and
+ write only in-memory entries.
+ */
+ HA_IGNORE_DURABILITY= 1
+};
+
+#endif /* _my_dur_prop_h */
diff --git a/include/hash.h b/include/hash.h
index 22bd6fc4f22..1c30e973f92 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -42,7 +42,7 @@ extern "C" {
#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 uint32 my_hash_value_type;
typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
typedef my_hash_value_type (*my_hash_function)(CHARSET_INFO *,
const uchar *, size_t);
@@ -73,7 +73,7 @@ my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
uint flags);
void my_hash_free(HASH *tree);
void my_hash_reset(HASH *hash);
-uchar *my_hash_element(HASH *hash, ulong idx);
+uchar *my_hash_element(HASH *hash, size_t idx);
uchar *my_hash_search(const HASH *info, const uchar *key, size_t length);
uchar *my_hash_search_using_hash_value(const HASH *info,
my_hash_value_type hash_value,
diff --git a/include/heap.h b/include/heap.h
index dd822f4c243..d0c907a48b4 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -217,7 +217,7 @@ extern int heap_write(HP_INFO *info,const uchar *buff);
extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata);
extern int heap_rrnd(HP_INFO *info,uchar *buf,uchar *pos);
extern int heap_scan_init(HP_INFO *info);
-extern int heap_scan(register HP_INFO *info, uchar *record);
+extern int heap_scan(HP_INFO *info, uchar *record);
extern int heap_delete(HP_INFO *info,const uchar *buff);
extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
extern int heap_create(const char *name,
diff --git a/include/json_lib.h b/include/json_lib.h
new file mode 100644
index 00000000000..e9c10906502
--- /dev/null
+++ b/include/json_lib.h
@@ -0,0 +1,432 @@
+#ifndef JSON_LIB_INCLUDED
+#define JSON_LIB_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define JSON_DEPTH_LIMIT 32
+
+/*
+ When error happens, the c_next of the JSON engine contains the
+ character that caused the error, and the c_str is the position
+ in string where the error occurs.
+*/
+enum json_errors {
+ JE_BAD_CHR= -1, /* Invalid character, charset handler cannot read it. */
+
+ JE_NOT_JSON_CHR= -2, /* Character met not used in JSON. */
+ /* ASCII 00-08 for instance. */
+
+ JE_EOS= -3, /* Unexpected end of string. */
+
+ JE_SYN= -4, /* The next character breaks the JSON syntax. */
+
+ JE_STRING_CONST= -5, /* Character disallowed in string constant. */
+
+ JE_ESCAPING= -6, /* Error in the escaping. */
+
+ JE_DEPTH= -7, /* The limit on the JSON depth was overrun. */
+};
+
+
+typedef struct st_json_string_t
+{
+ const uchar *c_str; /* Current position in JSON string */
+ const uchar *str_end; /* The end on the string. */
+ my_wc_t c_next; /* UNICODE of the last read character */
+ int error; /* error code. */
+
+ CHARSET_INFO *cs; /* Character set of the JSON string. */
+
+ my_charset_conv_mb_wc wc; /* UNICODE conversion function. */
+ /* It's taken out of the cs just to speed calls. */
+} json_string_t;
+
+
+void json_string_set_cs(json_string_t *s, CHARSET_INFO *i_cs);
+void json_string_set_str(json_string_t *s,
+ const uchar *str, const uchar *end);
+#define json_next_char(j) \
+ (j)->wc((j)->cs, &(j)->c_next, (j)->c_str, (j)->str_end)
+#define json_eos(j) ((j)->c_str >= (j)->str_end)
+/*
+ read_string_const_chr() reads the next character of the string constant
+ and saves it to the js->c_next.
+ It takes into account possible escapings, so if for instance
+ the string is '\b', the read_string_const_chr() sets 8.
+*/
+int json_read_string_const_chr(json_string_t *js);
+
+
+/*
+ Various JSON-related operations expect JSON path as a parameter.
+ The path is a string like this "$.keyA[2].*"
+ The path itself is a number of steps specifying either a key or a position
+ in an array. Some of them can be wildcards.
+ So the representation of the JSON path is the json_path_t class
+ containing an array of json_path_step_t objects.
+*/
+
+
+/* Path step types - actually bitmasks to let '&' or '|' operations. */
+enum json_path_step_types
+{
+ JSON_PATH_KEY_NULL=0,
+ JSON_PATH_KEY=1, /* Must be equal to JSON_VALUE_OBJECT. */
+ JSON_PATH_ARRAY=2, /* Must be equal to JSON_VALUE_ARRAY. */
+ JSON_PATH_KEY_OR_ARRAY=3,
+ JSON_PATH_WILD=4, /* Step like .* or [*] */
+ JSON_PATH_DOUBLE_WILD=8, /* Step like **.k or **[1] */
+ JSON_PATH_KEY_WILD= 1+4,
+ JSON_PATH_KEY_DOUBLEWILD= 1+8,
+ JSON_PATH_ARRAY_WILD= 2+4,
+ JSON_PATH_ARRAY_DOUBLEWILD= 2+8
+};
+
+
+typedef struct st_json_path_step_t
+{
+ enum json_path_step_types type; /* The type of the step - */
+ /* see json_path_step_types */
+ const uchar *key; /* Pointer to the beginning of the key. */
+ const uchar *key_end; /* Pointer to the end of the key. */
+ uint n_item; /* Item number in an array. No meaning for the key step. */
+} json_path_step_t;
+
+
+typedef struct st_json_path_t
+{
+ json_string_t s; /* The string to be parsed. */
+ json_path_step_t steps[JSON_DEPTH_LIMIT]; /* Steps of the path. */
+ json_path_step_t *last_step; /* Points to the last step. */
+
+ int mode_strict; /* TRUE if the path specified as 'strict' */
+ enum json_path_step_types types_used; /* The '|' of all step's 'type'-s */
+} json_path_t;
+
+
+int json_path_setup(json_path_t *p,
+ CHARSET_INFO *i_cs, const uchar *str, const uchar *end);
+
+
+/*
+ The set of functions and structures below provides interface
+ to the JSON text parser.
+ Running the parser normally goes like this:
+
+ json_engine_t j_eng; // structure keeps parser's data
+ json_scan_start(j_eng) // begin the parsing
+
+ do
+ {
+ // The parser has read next piece of JSON
+ // and set fields of j_eng structure accordingly.
+ // So let's see what we have:
+ switch (j_eng.state)
+ {
+ case JST_KEY:
+ // Handle key name. See the json_read_keyname_chr()
+ // Probably compare it with the keyname we're looking for
+ case JST_VALUE:
+ // Handle value. It is either value of the key or an array item.
+ // see the json_read_value()
+ case JST_OBJ_START:
+ // parser found an object (the '{' in JSON)
+ case JST_OBJ_END:
+ // parser found the end of the object (the '}' in JSON)
+ case JST_ARRAY_START:
+ // parser found an array (the '[' in JSON)
+ case JST_ARRAY_END:
+ // parser found the end of the array (the ']' in JSON)
+
+ };
+ } while (json_scan_next() == 0); // parse next structure
+
+
+ if (j_eng.s.error) // we need to check why the loop ended.
+ // Did we get to the end of JSON, or came upon error.
+ {
+ signal_error_in_JSON()
+ }
+
+
+ Parts of JSON can be quickly skipped. If we are not interested
+ in a particular key, we can just skip it with json_skip_key() call.
+ Similarly json_skip_level() goes right to the end of an object
+ or an array.
+*/
+
+
+/* These are JSON parser states that user can expect and handle. */
+enum json_states {
+ JST_VALUE, /* value found */
+ JST_KEY, /* key found */
+ JST_OBJ_START, /* object */
+ JST_OBJ_END, /* object ended */
+ JST_ARRAY_START, /* array */
+ JST_ARRAY_END, /* array ended */
+ NR_JSON_USER_STATES
+};
+
+
+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
+};
+
+
+enum json_num_flags
+{
+ JSON_NUM_NEG=1, /* Number is negative. */
+ JSON_NUM_FRAC_PART=2, /* The fractional part is not empty. */
+ JSON_NUM_EXP=4, /* The number has the 'e' part. */
+};
+
+
+typedef struct st_json_engine_t
+{
+ json_string_t s; /* String to parse. */
+ int sav_c_len; /* Length of the current character.
+ Can be more than 1 for multibyte charsets */
+
+ int state; /* The state of the parser. One of 'enum json_states'.
+ It tells us what construction of JSON we've just read. */
+
+ /* These values are only set after the json_read_value() call. */
+ enum json_value_types value_type; /* type of the value.*/
+ const uchar *value; /* Points to the value. */
+ const uchar *value_begin;/* Points to where the value starts in the JSON. */
+ int value_escaped; /* Flag telling if the string value has escaping.*/
+ uint num_flags; /* the details of the JSON_VALUE_NUMBER, is it negative,
+ or if it has the fractional part.
+ See the enum json_num_flags. */
+
+ /*
+ In most cases the 'value' and 'value_begin' are equal.
+ They only differ if the value is a string constants. Then 'value_begin'
+ points to the starting quotation mark, while the 'value' - to
+ the first character of the string.
+ */
+
+ const uchar *value_end; /* Points to the next character after the value. */
+ int value_len; /* The length of the value. Does not count quotations for */
+ /* string constants. */
+
+ int stack[JSON_DEPTH_LIMIT]; /* Keeps the stack of nested JSON structures. */
+ int stack_p; /* The 'stack' pointer. */
+} json_engine_t;
+
+
+int json_scan_start(json_engine_t *je,
+ CHARSET_INFO *i_cs, const uchar *str, const uchar *end);
+int json_scan_next(json_engine_t *j);
+
+
+/*
+ json_read_keyname_chr() function assists parsing the name of an JSON key.
+ It only can be called when the json_engine is in JST_KEY.
+ The json_read_keyname_chr() reads one character of the name of the key,
+ and puts it in j_eng.s.next_c.
+ Typical usage is like this:
+
+ if (j_eng.state == JST_KEY)
+ {
+ while (json_read_keyname_chr(&j) == 0)
+ {
+ //handle next character i.e. match it against the pattern
+ }
+ }
+*/
+
+int json_read_keyname_chr(json_engine_t *j);
+
+
+/*
+ Check if the name of the current JSON key matches
+ the step of the path.
+*/
+int json_key_matches(json_engine_t *je, json_string_t *k);
+
+
+/*
+ json_read_value() function parses the JSON value syntax,
+ so that we can handle the value of a key or an array item.
+ It only returns meaningful result when the engine is in
+ the JST_VALUE state.
+
+ Typical usage is like this:
+
+ if (j_eng.state == JST_VALUE)
+ {
+ json_read_value(&j_eng);
+ switch(j_eng.value_type)
+ {
+ case JSON_VALUE_STRING:
+ // get the string
+ str= j_eng.value;
+ str_length= j_eng.value_len;
+ case JSON_VALUE_NUMBER:
+ // get the number
+ ... etc
+ }
+*/
+int json_read_value(json_engine_t *j);
+
+
+/*
+ json_skip_key() makes parser skip the content of the current
+ JSON key quickly.
+ It can be called only when the json_engine state is JST_KEY.
+ Typical usage is:
+
+ if (j_eng.state == JST_KEY)
+ {
+ if (key_does_not_match(j_eng))
+ json_skip_key(j_eng);
+ }
+*/
+
+int json_skip_key(json_engine_t *j);
+
+
+typedef const int *json_level_t;
+
+/*
+ json_skip_to_level() makes parser quickly get out of nested
+ loops and arrays. It is used when we're not interested in what is
+ there in the rest of these structures.
+ The 'level' should be remembered in advance.
+ json_level_t level= json_get_level(j);
+ .... // getting into the nested JSON structures
+ json_skip_to_level(j, level);
+*/
+#define json_get_level(j) (j->stack_p)
+
+int json_skip_to_level(json_engine_t *j, int level);
+
+/*
+ json_skip_level() works as above with just current structre.
+ So it gets to the end of the current JSON array or object.
+*/
+#define json_skip_level(json_engine) \
+ json_skip_to_level((json_engine), (json_engine)->stack_p)
+
+
+/*
+ works as json_skip_level() but also counts items on the current
+ level skipped.
+*/
+int json_skip_level_and_count(json_engine_t *j, int *n_items_skipped);
+
+#define json_skip_array_item json_skip_key
+
+/*
+ Checks if the current value is of scalar type -
+ not an OBJECT nor ARRAY.
+*/
+#define json_value_scalar(je) ((je)->value_type > JSON_VALUE_ARRAY)
+
+
+/*
+ Look for the JSON PATH in the json string.
+ Function can be called several times with same JSON/PATH to
+ find multiple matches.
+ On the first call, the json_engine_t parameter should be
+ initialized with the JSON string, and the json_path_t with the JSON path
+ appropriately. The 'p_cur_step' should point at the first
+ step of the path.
+ The 'array_counters' is the array of JSON_DEPTH_LIMIT size.
+ It stores the array counters of the parsed JSON.
+ If function returns 0, it means it found the match. The position of
+ the match is je->s.c_str. Then we can call the json_find_path()
+ with same engine/path/p_cur_step to get the next match.
+ Non-zero return means no matches found.
+ Check je->s.error to see if there was an error in JSON.
+*/
+int json_find_path(json_engine_t *je,
+ json_path_t *p, json_path_step_t **p_cur_step,
+ uint *array_counters);
+
+
+typedef struct st_json_find_paths_t
+{
+ uint n_paths;
+ json_path_t *paths;
+ uint cur_depth;
+ uint *path_depths;
+ uint array_counters[JSON_DEPTH_LIMIT];
+} json_find_paths_t;
+
+
+int json_find_paths_first(json_engine_t *je, json_find_paths_t *state,
+ uint n_paths, json_path_t *paths, uint *path_depths);
+int json_find_paths_next(json_engine_t *je, json_find_paths_t *state);
+
+
+/*
+ Converst JSON string constant into ordinary string constant
+ which can involve unpacking json escapes and changing character set.
+ Returns negative integer in the case of an error,
+ the length of the result otherwise.
+*/
+int json_unescape(CHARSET_INFO *json_cs,
+ const uchar *json_str, const uchar *json_end,
+ CHARSET_INFO *res_cs,
+ uchar *res, uchar *res_end);
+
+/*
+ Converst ordinary string constant into JSON string constant.
+ which can involve appropriate escaping and changing character set.
+ Returns negative integer in the case of an error,
+ the length of the result otherwise.
+*/
+int json_escape(CHARSET_INFO *str_cs, const uchar *str, const uchar *str_end,
+ CHARSET_INFO *json_cs, uchar *json, uchar *json_end);
+
+
+/*
+ Appends the ASCII string to the json with the charset conversion.
+*/
+int json_append_ascii(CHARSET_INFO *json_cs,
+ uchar *json, uchar *json_end,
+ const uchar *ascii, const uchar *ascii_end);
+
+
+/*
+ Scan the JSON and return paths met one-by-one.
+ json_get_path_start(&p)
+ while (json_get_path_next(&p))
+ {
+ handle_the_next_path();
+ }
+*/
+
+int json_get_path_start(json_engine_t *je, CHARSET_INFO *i_cs,
+ const uchar *str, const uchar *end,
+ json_path_t *p);
+
+
+int json_get_path_next(json_engine_t *je, json_path_t *p);
+
+
+int json_path_parts_compare(
+ const json_path_step_t *a, const json_path_step_t *a_end,
+ const json_path_step_t *b, const json_path_step_t *b_end,
+ enum json_value_types vt);
+int json_path_compare(const json_path_t *a, const json_path_t *b,
+ enum json_value_types vt);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* JSON_LIB_INCLUDED */
+
diff --git a/include/lf.h b/include/lf.h
index 9d6f77da1a1..d2538385d6f 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -68,11 +68,8 @@ typedef struct {
void *purgatory;
uint32 purgatory_count;
uint32 volatile link;
-/* we want sizeof(LF_PINS) to be 128 to avoid false sharing */
- char pad[128-sizeof(uint32)*2
- -sizeof(LF_PINBOX *)
- -sizeof(void*)
- -sizeof(void *)*(LF_PINBOX_PINS+1)];
+ /* avoid false sharing */
+ char pad[CPU_LEVEL1_DCACHE_LINESIZE];
} LF_PINS;
/* compile-time assert to make sure we have enough pins. */
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 875ff95579e..dc7b77a5756 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -181,11 +181,12 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
/* A helper macros for "need at least n bytes" */
#define MY_CS_TOOSMALLN(n) (-100-(n))
+#define MY_CS_MBMAXLEN 6 /* Maximum supported mbmaxlen */
#define MY_CS_IS_TOOSMALL(rc) ((rc) >= MY_CS_TOOSMALL6 && (rc) <= MY_CS_TOOSMALL)
-
#define MY_SEQ_INTTAIL 1
#define MY_SEQ_SPACES 2
+#define MY_SEQ_NONSPACES 3 /* Skip non-space characters, including bad bytes */
/* My charsets_list flags */
#define MY_CS_COMPILED 1 /* compiled-in sets */
@@ -329,8 +330,7 @@ struct my_collation_handler_st
int (*strnncoll)(CHARSET_INFO *,
const uchar *, size_t, const uchar *, size_t, my_bool);
int (*strnncollsp)(CHARSET_INFO *,
- const uchar *, size_t, const uchar *, size_t,
- my_bool diff_if_only_endspace_difference);
+ const uchar *, size_t, const uchar *, size_t);
size_t (*strnxfrm)(CHARSET_INFO *,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
@@ -361,6 +361,8 @@ struct my_collation_handler_st
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 */
@@ -394,7 +396,6 @@ typedef struct
*/
typedef struct
{
- MY_STRCOPY_STATUS m_native_copy_status;
const char *m_cannot_convert_error_pos;
} MY_STRCONV_STATUS;
@@ -404,14 +405,9 @@ struct my_charset_handler_st
{
my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *loader);
/* Multibyte routines */
- uint (*ismbchar)(CHARSET_INFO *, const char *, const char *);
- uint (*mbcharlen)(CHARSET_INFO *, uint c);
size_t (*numchars)(CHARSET_INFO *, const char *b, const char *e);
size_t (*charpos)(CHARSET_INFO *, const char *b, const char *e,
size_t pos);
- size_t (*well_formed_len)(CHARSET_INFO *,
- const char *b,const char *e,
- size_t nchars, int *error);
size_t (*lengthsp)(CHARSET_INFO *, const char *ptr, size_t length);
size_t (*numcells)(CHARSET_INFO *, const char *b, const char *e);
@@ -586,50 +582,87 @@ struct charset_info_st
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_bin;
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1;
+extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1_nopad;
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_filename;
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_general_ci;
extern struct charset_info_st my_charset_big5_bin;
extern struct charset_info_st my_charset_big5_chinese_ci;
+extern struct charset_info_st my_charset_big5_nopad_bin;
+extern struct charset_info_st my_charset_big5_chinese_nopad_ci;
extern struct charset_info_st my_charset_cp1250_czech_ci;
extern struct charset_info_st my_charset_cp932_bin;
extern struct charset_info_st my_charset_cp932_japanese_ci;
+extern struct charset_info_st my_charset_cp932_nopad_bin;
+extern struct charset_info_st my_charset_cp932_japanese_nopad_ci;
extern struct charset_info_st my_charset_eucjpms_bin;
extern struct charset_info_st my_charset_eucjpms_japanese_ci;
+extern struct charset_info_st my_charset_eucjpms_nopad_bin;
+extern struct charset_info_st my_charset_eucjpms_japanese_nopad_ci;
extern struct charset_info_st my_charset_euckr_bin;
extern struct charset_info_st my_charset_euckr_korean_ci;
+extern struct charset_info_st my_charset_euckr_nopad_bin;
+extern struct charset_info_st my_charset_euckr_korean_nopad_ci;
extern struct charset_info_st my_charset_gb2312_bin;
extern struct charset_info_st my_charset_gb2312_chinese_ci;
+extern struct charset_info_st my_charset_gb2312_nopad_bin;
+extern struct charset_info_st my_charset_gb2312_chinese_nopad_ci;
extern struct charset_info_st my_charset_gbk_bin;
extern struct charset_info_st my_charset_gbk_chinese_ci;
+extern struct charset_info_st my_charset_gbk_nopad_bin;
+extern struct charset_info_st my_charset_gbk_chinese_nopad_ci;
extern struct charset_info_st my_charset_latin1_bin;
+extern struct charset_info_st my_charset_latin1_nopad_bin;
extern struct charset_info_st my_charset_latin1_german2_ci;
extern struct charset_info_st my_charset_latin2_czech_ci;
extern struct charset_info_st my_charset_sjis_bin;
extern struct charset_info_st my_charset_sjis_japanese_ci;
+extern struct charset_info_st my_charset_sjis_nopad_bin;
+extern struct charset_info_st my_charset_sjis_japanese_nopad_ci;
extern struct charset_info_st my_charset_tis620_bin;
extern struct charset_info_st my_charset_tis620_thai_ci;
+extern struct charset_info_st my_charset_tis620_nopad_bin;
+extern struct charset_info_st my_charset_tis620_thai_nopad_ci;
extern struct charset_info_st my_charset_ucs2_bin;
extern struct charset_info_st my_charset_ucs2_general_ci;
+extern struct charset_info_st my_charset_ucs2_nopad_bin;
+extern struct charset_info_st my_charset_ucs2_general_nopad_ci;
extern struct charset_info_st my_charset_ucs2_general_mysql500_ci;
extern struct charset_info_st my_charset_ucs2_unicode_ci;
+extern struct charset_info_st my_charset_ucs2_unicode_nopad_ci;
extern struct charset_info_st my_charset_ucs2_general_mysql500_ci;
extern struct charset_info_st my_charset_ujis_bin;
extern struct charset_info_st my_charset_ujis_japanese_ci;
+extern struct charset_info_st my_charset_ujis_nopad_bin;
+extern struct charset_info_st my_charset_ujis_japanese_nopad_ci;
extern struct charset_info_st my_charset_utf16_bin;
extern struct charset_info_st my_charset_utf16_general_ci;
extern struct charset_info_st my_charset_utf16_unicode_ci;
+extern struct charset_info_st my_charset_utf16_unicode_nopad_ci;
extern struct charset_info_st my_charset_utf16le_bin;
extern struct charset_info_st my_charset_utf16le_general_ci;
+extern struct charset_info_st my_charset_utf16_general_nopad_ci;
+extern struct charset_info_st my_charset_utf16_nopad_bin;
+extern struct charset_info_st my_charset_utf16le_nopad_bin;
+extern struct charset_info_st my_charset_utf16le_general_nopad_ci;
extern struct charset_info_st my_charset_utf32_bin;
extern struct charset_info_st my_charset_utf32_general_ci;
extern struct charset_info_st my_charset_utf32_unicode_ci;
+extern struct charset_info_st my_charset_utf32_unicode_nopad_ci;
+extern struct charset_info_st my_charset_utf32_nopad_bin;
+extern struct charset_info_st my_charset_utf32_general_nopad_ci;
extern struct charset_info_st my_charset_utf8_bin;
+extern struct charset_info_st my_charset_utf8_nopad_bin;
+extern struct charset_info_st my_charset_utf8_general_nopad_ci;
extern struct charset_info_st my_charset_utf8_general_mysql500_ci;
extern struct charset_info_st my_charset_utf8_unicode_ci;
+extern struct charset_info_st my_charset_utf8_unicode_nopad_ci;
extern struct charset_info_st my_charset_utf8mb4_bin;
extern struct charset_info_st my_charset_utf8mb4_general_ci;
+extern struct charset_info_st my_charset_utf8mb4_nopad_bin;
+extern struct charset_info_st my_charset_utf8mb4_general_nopad_ci;
extern struct charset_info_st my_charset_utf8mb4_unicode_ci;
+extern struct charset_info_st my_charset_utf8mb4_unicode_nopad_ci;
#define MY_UTF8MB3 "utf8"
#define MY_UTF8MB4 "utf8mb4"
@@ -649,16 +682,31 @@ extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
const uchar *, size_t, my_bool);
extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t,
- const uchar *, size_t,
- my_bool diff_if_only_endspace_difference);
+ 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_simple_nopad(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);
+/**
+ Compare a string to an array of spaces, for PAD SPACE comparison.
+ The function iterates through the string and compares every byte to 0x20.
+ @param - the string
+ @param - its length
+ @return <0 - if a byte less than 0x20 was found in the string.
+ @return 0 - if all bytes in the string were 0x20, or if length was 0.
+ @return >0 - if a byte greater than 0x20 was found in the string.
+*/
+extern int my_strnncollsp_padspace_bin(const uchar *str, size_t length);
+
extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length);
extern uint my_instr_simple(CHARSET_INFO *,
@@ -766,14 +814,11 @@ int my_wildcmp_bin(CHARSET_INFO *,
size_t my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
size_t my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
size_t my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, size_t pos);
-size_t my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e,
- size_t pos, int *error);
size_t my_well_formed_char_length_8bit(CHARSET_INFO *cs,
const char *b, const char *e,
size_t nchars,
MY_STRCOPY_STATUS *status);
int my_charlen_8bit(CHARSET_INFO *, const uchar *str, const uchar *end);
-uint my_mbcharlen_8bit(CHARSET_INFO *, uint c);
/* Functions for multibyte charsets */
@@ -800,23 +845,11 @@ int my_wildcmp_mb(CHARSET_INFO *,
size_t my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
size_t my_numcells_mb(CHARSET_INFO *, const char *b, const char *e);
size_t my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, size_t pos);
-size_t my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e,
- size_t pos, int *error);
uint my_instr_mb(CHARSET_INFO *,
const char *b, size_t b_length,
const char *s, size_t s_length,
my_match_t *match, uint nmatch);
-int my_strnncoll_mb_bin(CHARSET_INFO * cs,
- const uchar *s, size_t slen,
- const uchar *t, size_t tlen,
- my_bool t_is_prefix);
-
-int my_strnncollsp_mb_bin(CHARSET_INFO *cs,
- const uchar *a, size_t a_length,
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference);
-
int my_wildcmp_mb_bin(CHARSET_INFO *cs,
const char *str,const char *str_end,
const char *wildstr,const char *wildend,
@@ -828,18 +861,38 @@ int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
const uchar *key, size_t len,ulong *nr1, ulong *nr2);
+void my_hash_sort_mb_nopad_bin(CHARSET_INFO *cs __attribute__((unused)),
+ const uchar *key, size_t len,
+ ulong *nr1, ulong *nr2);
+
size_t my_strnxfrm_mb(CHARSET_INFO *,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);
+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 *,
- uchar *dst, size_t dstlen, uint nweights,
- const uchar *src, size_t srclen, uint flags);
+ uchar *dst, size_t dstlen,
+ uint nweights, const uchar *src,
+ size_t srclen, uint flags);
+
+size_t my_strnxfrm_unicode_full_nopad_bin(CHARSET_INFO *,
+ uchar *dst, size_t dstlen,
+ uint nweights, const uchar *src,
+ size_t srclen, uint flags);
+
size_t my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t);
int my_wildcmp_unicode(CHARSET_INFO *cs,
@@ -869,7 +922,6 @@ void my_string_metadata_get(MY_STRING_METADATA *metadata,
CHARSET_INFO *cs, const char *str, size_t len);
uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len);
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
-my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
uint my_charset_repertoire(CHARSET_INFO *cs);
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
@@ -878,8 +930,10 @@ void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
size_t my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
uchar *str, uchar *frmend, uchar *strend,
uint nweights, uint flags, uint level);
-
-my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
+size_t my_strxfrm_pad_desc_and_reverse_nopad(CHARSET_INFO *cs,
+ uchar *str, uchar *frmend,
+ uchar *strend, uint nweights,
+ uint flags, uint level);
const MY_CONTRACTIONS *my_charset_get_contractions(CHARSET_INFO *cs,
int level);
@@ -933,7 +987,9 @@ uint32 my_convert_using_func(char *to, uint32 to_length, CHARSET_INFO *to_cs,
*/
size_t my_convert_fix(CHARSET_INFO *dstcs, char *dst, size_t dst_length,
CHARSET_INFO *srccs, const char *src, size_t src_length,
- size_t nchars, MY_STRCONV_STATUS *status);
+ size_t nchars,
+ MY_STRCOPY_STATUS *copy_status,
+ MY_STRCONV_STATUS *conv_status);
#define _MY_U 01 /* Upper case */
#define _MY_L 02 /* Lower case */
@@ -978,13 +1034,71 @@ size_t my_convert_fix(CHARSET_INFO *dstcs, char *dst, size_t dst_length,
#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
-#define use_mb(s) ((s)->cset->ismbchar != NULL)
-#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b)))
-#ifdef USE_MB
-#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a)))
-#else
-#define my_mbcharlen(s, a) 1
-#endif
+#define use_mb(s) ((s)->mbmaxlen > 1)
+/**
+ Detect if the leftmost character in a string is a valid multi-byte character
+ and return its length, or return 0 otherwise.
+ @param cs - character set
+ @param str - the beginning of the string
+ @param end - the string end (the next byte after the string)
+ @return >0, for a multi-byte character
+ @rerurn 0, for a single byte character, broken sequence, empty string.
+*/
+static inline
+uint my_ismbchar(CHARSET_INFO *cs, const char *str, const char *end)
+{
+ int char_length= (cs->cset->charlen)(cs, (const uchar *) str,
+ (const uchar *) end);
+ return char_length > 1 ? (uint) char_length : 0U;
+}
+
+
+/**
+ Return length of the leftmost character in a string.
+ @param cs - character set
+ @param str - the beginning of the string
+ @param end - the string end (the next byte after the string)
+ @return <=0 on errors (EOL, wrong byte sequence)
+ @return 1 on a single byte character
+ @return >1 on a multi-byte character
+
+ Note, inlike my_ismbchar(), 1 is returned for a single byte character.
+*/
+static inline
+int my_charlen(CHARSET_INFO *cs, const char *str, const char *end)
+{
+ return (cs->cset->charlen)(cs, (const uchar *) str,
+ (const uchar *) end);
+}
+
+
+/**
+ Convert broken and incomplete byte sequences to 1 byte.
+*/
+static inline
+uint my_charlen_fix(CHARSET_INFO *cs, const char *str, const char *end)
+{
+ int char_length= my_charlen(cs, str, end);
+ DBUG_ASSERT(str < end);
+ return char_length > 0 ? (uint) char_length : (uint) 1U;
+}
+
+
+/*
+ A compatibility replacement pure C function for the former
+ cs->cset->well_formed_len().
+ In C++ code please use Well_formed_prefix::length() instead.
+*/
+static inline size_t
+my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e,
+ size_t nchars, int *error)
+{
+ MY_STRCOPY_STATUS status;
+ (void) cs->cset->well_formed_char_length(cs, b, e, nchars, &status);
+ *error= status.m_well_formed_error_pos == NULL ? 0 : 1;
+ return status.m_source_end_pos - b;
+}
+
#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
diff --git a/include/m_string.h b/include/m_string.h
index e17bc697341..2f609d5e29f 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -23,6 +23,7 @@
#define _m_string_h
#include "my_global.h" /* HAVE_* */
+#include "my_decimal_limits.h"
#ifndef __USE_GNU
#define __USE_GNU /* We want to use stpcpy */
@@ -131,14 +132,13 @@ size_t my_fcvt(double x, int precision, char *to, my_bool *error);
size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
my_bool *error);
-#define NOT_FIXED_DEC 31
-
/*
The longest string my_fcvt can return is 311 + "precision" bytes.
- Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
+ Here we assume that we never cal my_fcvt() with
+ precision >= DECIMAL_NOT_SPECIFIED
(+ 1 byte for the terminating '\0').
*/
-#define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
+#define FLOATING_POINT_BUFFER (311 + DECIMAL_NOT_SPECIFIED)
/*
We want to use the 'e' format in some cases even if we have enough space
diff --git a/include/maria.h b/include/maria.h
index 4cf8c1730ac..cbc03687f1d 100644
--- a/include/maria.h
+++ b/include/maria.h
@@ -366,7 +366,7 @@ int maria_sort_index(HA_CHECK *param, MARIA_HA *info, char * name);
int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name);
int maria_repair_by_sort(HA_CHECK *param, MARIA_HA *info,
const char *name, my_bool rep_quick);
-int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
+int maria_repair_parallel(HA_CHECK *param, 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, time_t backup_time,
diff --git a/include/my_atomic.h b/include/my_atomic.h
index e226f5c5926..aa5c617e593 100644
--- a/include/my_atomic.h
+++ b/include/my_atomic.h
@@ -112,9 +112,26 @@
#undef MY_ATOMIC_HAS_8_16
/*
- * Attempt to do atomic ops without locks
- */
-#include "atomic/nolock.h"
+ We choose implementation as follows:
+ ------------------------------------
+ On Windows using Visual C++ the native implementation should be
+ preferrable. When using gcc we prefer the Solaris implementation
+ before the gcc because of stability preference, we choose gcc
+ builtins if available, otherwise we choose the somewhat broken
+ native x86 implementation. If neither Visual C++ or gcc we still
+ choose the Solaris implementation on Solaris (mainly for SunStudio
+ compilers).
+*/
+#if defined(_MSC_VER)
+#include "atomic/generic-msvc.h"
+#elif defined(HAVE_SOLARIS_ATOMIC)
+#include "atomic/solaris.h"
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+#include "atomic/gcc_builtins.h"
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+#include "atomic/x86-gcc.h"
+#endif
+
#ifndef make_atomic_cas_body
/* nolock.h was not able to generate even a CAS function, fall back */
@@ -280,6 +297,20 @@ make_atomic_store(32)
make_atomic_store(64)
make_atomic_store(ptr)
+#if SIZEOF_LONG == 4
+#define my_atomic_addlong(A,B) my_atomic_add32((int32*) (A), (B))
+#define my_atomic_loadlong(A) my_atomic_load32((int32*) (A))
+#define my_atomic_storelong(A,B) my_atomic_store32((int32*) (A), (B))
+#define my_atomic_faslong(A,B) my_atomic_fas32((int32*) (A), (B))
+#define my_atomic_caslong(A,B,C) my_atomic_cas32((int32*) (A), (int32*) (B), (C))
+#else
+#define my_atomic_addlong(A,B) my_atomic_add64((int64*) (A), (B))
+#define my_atomic_loadlong(A) my_atomic_load64((int64*) (A))
+#define my_atomic_storelong(A,B) my_atomic_store64((int64*) (A), (B))
+#define my_atomic_faslong(A,B) my_atomic_fas64((int64*) (A), (B))
+#define my_atomic_caslong(A,B,C) my_atomic_cas64((int64*) (A), (int64*) (B), (C))
+#endif
+
#ifdef _atomic_h_cleanup_
#include _atomic_h_cleanup_
#undef _atomic_h_cleanup_
diff --git a/include/my_base.h b/include/my_base.h
index 5c785adce14..e24805eee8d 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 1995, 2012 Monty Program Ab
+ Copyright (c) 1995, 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
@@ -34,25 +34,25 @@
/* The following is bits in the flag parameter to ha_open() */
-#define HA_OPEN_ABORT_IF_LOCKED 0 /* default */
-#define HA_OPEN_WAIT_IF_LOCKED 1
-#define HA_OPEN_IGNORE_IF_LOCKED 2
-#define HA_OPEN_TMP_TABLE 4 /* Table is a temp table */
-#define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */
-#define HA_OPEN_ABORT_IF_CRASHED 16
-#define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */
-#define HA_OPEN_FROM_SQL_LAYER 64
-#define HA_OPEN_MMAP 128 /* open memory mapped */
-#define HA_OPEN_COPY 256 /* Open copy (for repair) */
+#define HA_OPEN_ABORT_IF_LOCKED 0U /* default */
+#define HA_OPEN_WAIT_IF_LOCKED 1U
+#define HA_OPEN_IGNORE_IF_LOCKED 2U
+#define HA_OPEN_TMP_TABLE 4U /* Table is a temp table */
+#define HA_OPEN_DELAY_KEY_WRITE 8U /* Don't update index */
+#define HA_OPEN_ABORT_IF_CRASHED 16U
+#define HA_OPEN_FOR_REPAIR 32U /* open even if crashed */
+#define HA_OPEN_FROM_SQL_LAYER 64U
+#define HA_OPEN_MMAP 128U /* open memory mapped */
+#define HA_OPEN_COPY 256U /* Open copy (for repair) */
/* Internal temp table, used for temporary results */
-#define HA_OPEN_INTERNAL_TABLE 512
-#define HA_OPEN_NO_PSI_CALL 1024 /* Don't call/connect PSI */
-#define HA_OPEN_MERGE_TABLE 2048
+#define HA_OPEN_INTERNAL_TABLE 512U
+#define HA_OPEN_NO_PSI_CALL 1024U /* Don't call/connect PSI */
+#define HA_OPEN_MERGE_TABLE 2048U
/*
Allow opening even if table is incompatible as this is for ALTER TABLE which
will fix the table structure.
*/
-#define HA_OPEN_FOR_ALTER 4096
+#define HA_OPEN_FOR_ALTER 4096U
/* The following is parameter to ha_rkey() how to use key */
@@ -200,7 +200,13 @@ enum ha_extra_function {
HA_EXTRA_DETACH_CHILDREN,
HA_EXTRA_DETACH_CHILD,
/* Inform handler we will force a close as part of flush */
- HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
+ HA_EXTRA_PREPARE_FOR_FORCED_CLOSE,
+ /** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */
+ HA_EXTRA_BEGIN_ALTER_COPY,
+ /** Finish writing rows during ALTER TABLE...ALGORITHM=COPY. */
+ HA_EXTRA_END_ALTER_COPY,
+ /** Fake the start of a statement after wsrep_load_data_splitting hack */
+ HA_EXTRA_FAKE_START_STMT
};
/* Compatible option, to be deleted in 6.0 */
@@ -248,15 +254,15 @@ enum ha_base_keytype {
Note that these can only be up to 16 bits!
*/
-#define HA_NOSAME 1 /* Set if not dupplicated records */
-#define HA_PACK_KEY 2 /* Pack string key to previous key */
-#define HA_AUTO_KEY 16
-#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
-#define HA_FULLTEXT 128 /* For full-text search */
-#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
-#define HA_SPATIAL 1024 /* For spatial search */
-#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
-#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
+#define HA_NOSAME 1U /* Set if not dupplicated records */
+#define HA_PACK_KEY 2U /* Pack string key to previous key */
+#define HA_AUTO_KEY 16U
+#define HA_BINARY_PACK_KEY 32U /* Packing of all keys to prev key */
+#define HA_FULLTEXT 128U /* For full-text search */
+#define HA_UNIQUE_CHECK 256U /* Check the key for uniqueness */
+#define HA_SPATIAL 1024U /* For spatial search */
+#define HA_NULL_ARE_EQUAL 2048U /* NULL in key are cmp as equal */
+#define HA_GENERATED_KEY 8192U /* Automaticly generated key */
/* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
@@ -298,34 +304,30 @@ enum ha_base_keytype {
#define HA_SWAP_KEY 64
#define HA_REVERSE_SORT 128 /* Sort key in reverse order */
#define HA_NO_SORT 256 /* do not bother sorting on this keyseg */
-/*
- End space in unique/varchar are considered equal. (Like 'a' and 'a ')
- Only needed for internal temporary tables.
-*/
-#define HA_END_SPACE_ARE_EQUAL 512
+
#define HA_BIT_PART 1024
#define HA_CAN_MEMCMP 2048 /* internal, never stored in frm */
/* optionbits for database */
-#define HA_OPTION_PACK_RECORD 1
-#define HA_OPTION_PACK_KEYS 2
-#define HA_OPTION_COMPRESS_RECORD 4
-#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
-#define HA_OPTION_TMP_TABLE 16
-#define HA_OPTION_CHECKSUM 32
-#define HA_OPTION_DELAY_KEY_WRITE 64
-#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
+#define HA_OPTION_PACK_RECORD 1U
+#define HA_OPTION_PACK_KEYS 2U
+#define HA_OPTION_COMPRESS_RECORD 4U
+#define HA_OPTION_LONG_BLOB_PTR 8U /* new ISAM format */
+#define HA_OPTION_TMP_TABLE 16U
+#define HA_OPTION_CHECKSUM 32U
+#define HA_OPTION_DELAY_KEY_WRITE 64U
+#define HA_OPTION_NO_PACK_KEYS 128U /* Reserved for MySQL */
/* unused 256 */
-#define HA_OPTION_RELIES_ON_SQL_LAYER 512
-#define HA_OPTION_NULL_FIELDS 1024
-#define HA_OPTION_PAGE_CHECKSUM 2048
+#define HA_OPTION_RELIES_ON_SQL_LAYER 512U
+#define HA_OPTION_NULL_FIELDS 1024U
+#define HA_OPTION_PAGE_CHECKSUM 2048U
/*
STATS_PERSISTENT=1 has been specified in the SQL command (either CREATE
or ALTER TABLE). Table and index statistics that are collected by the
storage engine and used by the optimizer for query optimization will be
stored on disk and will not change after a server restart.
*/
-#define HA_OPTION_STATS_PERSISTENT 4096
+#define HA_OPTION_STATS_PERSISTENT 4096U
/*
STATS_PERSISTENT=0 has been specified in CREATE/ALTER TABLE. Statistics
for the table will be wiped away on server shutdown and new ones recalculated
@@ -334,31 +336,31 @@ enum ha_base_keytype {
explicitly set at table level and the corresponding table will use whatever
is the global server default.
*/
-#define HA_OPTION_NO_STATS_PERSISTENT 8192
+#define HA_OPTION_NO_STATS_PERSISTENT 8192U
/* .frm has extra create options in linked-list format */
-#define HA_OPTION_TEXT_CREATE_OPTIONS_legacy (1L << 14) /* 5.2 to 5.5, unused since 10.0 */
-#define HA_OPTION_TEMP_COMPRESS_RECORD (1L << 15) /* set by isamchk */
-#define HA_OPTION_READ_ONLY_DATA (1L << 16) /* Set by isamchk */
-#define HA_OPTION_NO_CHECKSUM (1L << 17)
-#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
+#define HA_OPTION_TEXT_CREATE_OPTIONS_legacy (1U << 14) /* 5.2 to 5.5, unused since 10.0 */
+#define HA_OPTION_TEMP_COMPRESS_RECORD (1U << 15) /* set by isamchk */
+#define HA_OPTION_READ_ONLY_DATA (1U << 16) /* Set by isamchk */
+#define HA_OPTION_NO_CHECKSUM (1U << 17)
+#define HA_OPTION_NO_DELAY_KEY_WRITE (1U << 18)
/* Bits in flag to create() */
-#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
-#define HA_PACK_RECORD 2 /* Request packed record format */
-#define HA_CREATE_TMP_TABLE 4
-#define HA_CREATE_CHECKSUM 8
-#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
-#define HA_CREATE_PAGE_CHECKSUM 32
-#define HA_CREATE_DELAY_KEY_WRITE 64
-#define HA_CREATE_RELIES_ON_SQL_LAYER 128
-#define HA_CREATE_INTERNAL_TABLE 256
-#define HA_PRESERVE_INSERT_ORDER 512
+#define HA_DONT_TOUCH_DATA 1U /* Don't empty datafile (isamchk) */
+#define HA_PACK_RECORD 2U /* Request packed record format */
+#define HA_CREATE_TMP_TABLE 4U
+#define HA_CREATE_CHECKSUM 8U
+#define HA_CREATE_KEEP_FILES 16U /* don't overwrite .MYD and MYI */
+#define HA_CREATE_PAGE_CHECKSUM 32U
+#define HA_CREATE_DELAY_KEY_WRITE 64U
+#define HA_CREATE_RELIES_ON_SQL_LAYER 128U
+#define HA_CREATE_INTERNAL_TABLE 256U
+#define HA_PRESERVE_INSERT_ORDER 512U
/* Flags used by start_bulk_insert */
-#define HA_CREATE_UNIQUE_INDEX_BY_SORT 1
+#define HA_CREATE_UNIQUE_INDEX_BY_SORT 1U
/*
@@ -370,44 +372,44 @@ enum ha_base_keytype {
*/
/* this one is not used */
-#define HA_STATUS_POS 1
+#define HA_STATUS_POS 1U
/*
assuming the table keeps shared actual copy of the 'info' and
local, possibly outdated copy, the following flag means that
it should not try to get the actual data (locking the shared structure)
slightly outdated version will suffice
*/
-#define HA_STATUS_NO_LOCK 2
+#define HA_STATUS_NO_LOCK 2U
/* update the time of the last modification (in handler::update_time) */
-#define HA_STATUS_TIME 4
+#define HA_STATUS_TIME 4U
/*
update the 'constant' part of the info:
handler::max_data_file_length, max_index_file_length, create_time
sortkey, ref_length, block_size, data_file_name, index_file_name.
handler::table->s->keys_in_use, keys_for_keyread, rec_per_key
*/
-#define HA_STATUS_CONST 8
+#define HA_STATUS_CONST 8U
/*
update the 'variable' part of the info:
handler::records, deleted, data_file_length, index_file_length,
check_time, mean_rec_length
*/
-#define HA_STATUS_VARIABLE 16
+#define HA_STATUS_VARIABLE 16U
/*
get the information about the key that caused last duplicate value error
update handler::errkey and handler::dupp_ref
see handler::get_dup_key()
*/
-#define HA_STATUS_ERRKEY 32
+#define HA_STATUS_ERRKEY 32U
/*
update handler::auto_increment_value
*/
-#define HA_STATUS_AUTO 64
+#define HA_STATUS_AUTO 64U
/*
Get also delete_length when HA_STATUS_VARIABLE is called. It's ok to set it also
when only HA_STATUS_VARIABLE but it won't be used.
*/
-#define HA_STATUS_VARIABLE_EXTRA 128
+#define HA_STATUS_VARIABLE_EXTRA 128U
/*
Errorcodes given by handler functions
@@ -501,13 +503,19 @@ enum ha_base_keytype {
#define HA_ERR_DISK_FULL 189
#define HA_ERR_INCOMPATIBLE_DEFINITION 190
#define HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE 191 /* Too many words in a phrase */
-#define HA_ERR_DECRYPTION_FAILED 192 /* Table encrypted but
- decypt failed */
-#define HA_ERR_LAST 192 /* Copy of last error nr */
+#define HA_ERR_DECRYPTION_FAILED 192 /* Table encrypted but decypt failed */
+#define HA_ERR_FK_DEPTH_EXCEEDED 193 /* FK cascade depth exceeded */
+#define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */
+#define HA_ERR_LAST 194 /* Copy of last error nr * */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
+/* aliases */
+#define HA_ERR_TABLE_CORRUPT HA_ERR_WRONG_IN_RECORD
+#define HA_ERR_QUERY_INTERRUPTED HA_ERR_ABORTED_BY_USER
+#define HA_ERR_NOT_ALLOWED_COMMAND HA_ERR_WRONG_COMMAND
+
/* Other constants */
#define HA_NAMELEN 64 /* Max length of saved filename */
@@ -519,23 +527,23 @@ typedef ulong key_part_map;
/* Intern constants in databases */
/* bits in _search */
-#define SEARCH_FIND 1
-#define SEARCH_NO_FIND 2
-#define SEARCH_SAME 4
-#define SEARCH_BIGGER 8
-#define SEARCH_SMALLER 16
-#define SEARCH_SAVE_BUFF 32
-#define SEARCH_UPDATE 64
-#define SEARCH_PREFIX 128
-#define SEARCH_LAST 256
-#define MBR_CONTAIN 512
-#define MBR_INTERSECT 1024
-#define MBR_WITHIN 2048
-#define MBR_DISJOINT 4096
-#define MBR_EQUAL 8192
-#define MBR_DATA 16384
-#define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */
-#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
+#define SEARCH_FIND 1U
+#define SEARCH_NO_FIND 2U
+#define SEARCH_SAME 4U
+#define SEARCH_BIGGER 8U
+#define SEARCH_SMALLER 16U
+#define SEARCH_SAVE_BUFF 32U
+#define SEARCH_UPDATE 64U
+#define SEARCH_PREFIX 128U
+#define SEARCH_LAST 256U
+#define MBR_CONTAIN 512U
+#define MBR_INTERSECT 1024U
+#define MBR_WITHIN 2048U
+#define MBR_DISJOINT 4096U
+#define MBR_EQUAL 8192U
+#define MBR_DATA 16384U
+#define SEARCH_NULL_ARE_EQUAL 32768U /* NULL in keys are equal */
+#define SEARCH_NULL_ARE_NOT_EQUAL 65536U/* NULL in keys are not equal */
/* Use this when inserting a key in position order */
#define SEARCH_INSERT (SEARCH_NULL_ARE_NOT_EQUAL*2)
/* Only part of the key is specified while reading */
@@ -546,27 +554,27 @@ typedef ulong key_part_map;
#define SEARCH_PAGE_KEY_HAS_TRANSID (SEARCH_USER_KEY_HAS_TRANSID*2)
/* bits in opt_flag */
-#define QUICK_USED 1
-#define READ_CACHE_USED 2
-#define READ_CHECK_USED 4
-#define KEY_READ_USED 8
-#define WRITE_CACHE_USED 16
-#define OPT_NO_ROWS 32
+#define QUICK_USED 1U
+#define READ_CACHE_USED 2U
+#define READ_CHECK_USED 4U
+#define KEY_READ_USED 8U
+#define WRITE_CACHE_USED 16U
+#define OPT_NO_ROWS 32U
/* bits in update */
-#define HA_STATE_CHANGED 1 /* Database has changed */
-#define HA_STATE_AKTIV 2 /* Has a current record */
-#define HA_STATE_WRITTEN 4 /* Record is written */
-#define HA_STATE_DELETED 8
-#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
-#define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */
-#define HA_STATE_NO_KEY 64 /* Last read didn't find record */
-#define HA_STATE_KEY_CHANGED 128
-#define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */
-#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
-#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
-#define HA_STATE_EXTEND_BLOCK 2048
-#define HA_STATE_RNEXT_SAME 4096 /* rnext_same occupied lastkey2 */
+#define HA_STATE_CHANGED 1U /* Database has changed */
+#define HA_STATE_AKTIV 2U /* Has a current record */
+#define HA_STATE_WRITTEN 4U /* Record is written */
+#define HA_STATE_DELETED 8U
+#define HA_STATE_NEXT_FOUND 16U /* Next found record (record before) */
+#define HA_STATE_PREV_FOUND 32U /* Prev found record (record after) */
+#define HA_STATE_NO_KEY 64U /* Last read didn't find record */
+#define HA_STATE_KEY_CHANGED 128U
+#define HA_STATE_WRITE_AT_END 256U /* set in _ps_find_writepos */
+#define HA_STATE_BUFF_SAVED 512U /* If current keybuff is info->buff */
+#define HA_STATE_ROW_CHANGED 1024U /* To invalidate ROW cache */
+#define HA_STATE_EXTEND_BLOCK 2048U
+#define HA_STATE_RNEXT_SAME 4096U /* rnext_same occupied lastkey2 */
/* myisampack expects no more than 32 field types. */
enum en_fieldtype {
@@ -582,15 +590,15 @@ enum data_file_type {
/* For key ranges */
-#define NO_MIN_RANGE 1
-#define NO_MAX_RANGE 2
-#define NEAR_MIN 4
-#define NEAR_MAX 8
-#define UNIQUE_RANGE 16
-#define EQ_RANGE 32
-#define NULL_RANGE 64
-#define GEOM_FLAG 128
-#define SKIP_RANGE 256
+#define NO_MIN_RANGE 1U
+#define NO_MAX_RANGE 2U
+#define NEAR_MIN 4U
+#define NEAR_MAX 8U
+#define UNIQUE_RANGE 16U
+#define EQ_RANGE 32U
+#define NULL_RANGE 64U
+#define GEOM_FLAG 128U
+#define SKIP_RANGE 256U
typedef struct st_key_range
{
@@ -636,17 +644,4 @@ C_MODE_START
typedef void (* invalidator_by_filename)(const char * filename);
C_MODE_END
-
-enum durability_properties
-{
- /*
- Preserves the durability properties defined by the engine */
- HA_REGULAR_DURABILITY= 0,
- /*
- Ignore the durability properties defined by the engine and
- write only in-memory entries.
- */
- HA_IGNORE_DURABILITY= 1
-};
-
#endif /* _my_base_h */
diff --git a/include/my_bit.h b/include/my_bit.h
index aee5240ac56..4db6efcac8c 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2007, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009-2011, Monty Program Ab
+ Copyright (c) 2009, 2017, 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
@@ -25,7 +25,6 @@
C_MODE_START
-extern const char _my_bits_nbits[256];
extern const uchar _my_bits_reverse_table[256];
/*
@@ -40,37 +39,32 @@ static inline uint my_bit_log2(ulong value)
return bit;
}
-static inline uint my_count_bits(ulonglong v)
+
+/*
+Count bits in 32bit integer
+
+ Algorithm by Sean Anderson, according to:
+ http://graphics.stanford.edu/~seander/bithacks.html
+ under "Counting bits set, in parallel"
+
+ (Orignal code public domain).
+*/
+static inline uint my_count_bits_uint32(uint32 v)
{
-#if SIZEOF_LONG_LONG > 4
- /* The following code is a bit faster on 16 bit machines than if we would
- only shift v */
- ulong v2=(ulong) (v >> 32);
- return (uint) (uchar) (_my_bits_nbits[(uchar) v] +
- _my_bits_nbits[(uchar) (v >> 8)] +
- _my_bits_nbits[(uchar) (v >> 16)] +
- _my_bits_nbits[(uchar) (v >> 24)] +
- _my_bits_nbits[(uchar) (v2)] +
- _my_bits_nbits[(uchar) (v2 >> 8)] +
- _my_bits_nbits[(uchar) (v2 >> 16)] +
- _my_bits_nbits[(uchar) (v2 >> 24)]);
-#else
- return (uint) (uchar) (_my_bits_nbits[(uchar) v] +
- _my_bits_nbits[(uchar) (v >> 8)] +
- _my_bits_nbits[(uchar) (v >> 16)] +
- _my_bits_nbits[(uchar) (v >> 24)]);
-#endif
+ v = v - ((v >> 1) & 0x55555555);
+ v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
+ return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
}
-static inline uint my_count_bits_uint32(uint32 v)
+
+static inline uint my_count_bits(ulonglong x)
{
- return (uint) (uchar) (_my_bits_nbits[(uchar) v] +
- _my_bits_nbits[(uchar) (v >> 8)] +
- _my_bits_nbits[(uchar) (v >> 16)] +
- _my_bits_nbits[(uchar) (v >> 24)]);
+ return my_count_bits_uint32((uint32)x) + my_count_bits_uint32((uint32)(x >> 32));
}
+
+
/*
Next highest power of two
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index da685ce19d1..9cd8b0ca1e8 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -58,6 +58,7 @@ extern my_bool bitmap_is_overlapping(const MY_BITMAP *map1,
extern my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit);
extern my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit);
extern my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit);
+extern my_bool bitmap_fast_test_and_clear(MY_BITMAP *map, uint bitmap_bit);
extern my_bool bitmap_union_is_set_all(const MY_BITMAP *map1,
const MY_BITMAP *map2);
extern my_bool bitmap_exists_intersection(const MY_BITMAP **bitmap_array,
diff --git a/include/my_compare.h b/include/my_compare.h
index 38a024c445e..b973664372a 100644
--- a/include/my_compare.h
+++ b/include/my_compare.h
@@ -91,7 +91,7 @@ typedef struct st_HA_KEYSEG /* Key-portion */
#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
-static inline uint16 get_rec_bits(const uchar *ptr, uchar ofs, uint len)
+static inline uchar get_rec_bits(const uchar *ptr, uchar ofs, uint len)
{
uint16 val= ptr[0];
if (ofs + len > 8)
@@ -110,7 +110,7 @@ static inline void set_rec_bits(uint16 bits, uchar *ptr, uchar ofs, uint len)
set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint,
- const uchar *, uint , my_bool, my_bool);
+ const uchar *, uint , my_bool);
extern int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
const uchar *b, uint key_length, uint nextflag,
uint *diff_pos);
diff --git a/include/my_compiler.h b/include/my_compiler.h
index 86ba250da88..12e6c1a087c 100644
--- a/include/my_compiler.h
+++ b/include/my_compiler.h
@@ -148,6 +148,29 @@ struct my_aligned_storage
#define MY_ALIGNED(size)
#endif
+#ifdef __GNUC__
+# define ATTRIBUTE_NORETURN __attribute__((noreturn))
+# if MY_GNUC_PREREQ(4,3)
+/** Starting with GCC 4.3, the "cold" attribute is used to inform the
+compiler that a function is unlikely executed. The function is
+optimized for size rather than speed and on many targets it is placed
+into special subsection of the text section so all cold functions
+appears close together improving code locality of non-cold parts of
+program. The paths leading to call of cold functions within code are
+marked as unlikely by the branch prediction mechanism. optimize a
+rarely invoked function for size instead for speed. */
+# define ATTRIBUTE_COLD __attribute__((cold))
+# endif
+#elif defined _MSC_VER
+# define ATTRIBUTE_NORETURN __declspec(noreturn)
+#else
+# define ATTRIBUTE_NORETURN /* empty */
+#endif
+
+#ifndef ATTRIBUTE_COLD
+# define ATTRIBUTE_COLD /* empty */
+#endif
+
#include <my_attribute.h>
#endif /* MY_COMPILER_INCLUDED */
diff --git a/include/my_context.h b/include/my_context.h
index c59d6ce3577..ea0e3496887 100644
--- a/include/my_context.h
+++ b/include/my_context.h
@@ -62,7 +62,7 @@ struct my_context {
ucontext_t base_context;
ucontext_t spawned_context;
int active;
-#ifdef HAVE_VALGRIND
+#ifdef HAVE_VALGRIND_MEMCHECK_H
unsigned int valgrind_stack_id;
#endif
#ifndef DBUG_OFF
@@ -79,7 +79,7 @@ struct my_context {
uint64_t save[9];
void *stack_top;
void *stack_bot;
-#ifdef HAVE_VALGRIND
+#ifdef HAVE_VALGRIND_MEMCHECK_H
unsigned int valgrind_stack_id;
#endif
#ifndef DBUG_OFF
@@ -96,7 +96,7 @@ struct my_context {
uint64_t save[7];
void *stack_top;
void *stack_bot;
-#ifdef HAVE_VALGRIND
+#ifdef HAVE_VALGRIND_MEMCHECK_H
unsigned int valgrind_stack_id;
#endif
#ifndef DBUG_OFF
diff --git a/include/my_dbug.h b/include/my_dbug.h
index 866bc619ee6..0fe40a9e8cb 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
- Copyright (C) 2000-2011 Monty Program Ab
+ Copyright (C) 2000, 2017, MariaDB Corporation 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
@@ -50,7 +50,7 @@ extern void _db_set_init_(const char *control);
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
struct _db_stack_frame_ *_stack_frame_);
extern void _db_return_(struct _db_stack_frame_ *_stack_frame_);
-extern void _db_pargs_(uint _line_,const char *keyword);
+extern int _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_(const char *format,...)
ATTRIBUTE_FORMAT(printf, 1, 2);
extern void _db_dump_(uint _line_,const char *keyword,
@@ -91,7 +91,7 @@ extern const char* _db_get_func_(void);
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
- do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
+ do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (a1)
@@ -193,8 +193,22 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
#define DBUG_SYNC_POINT(lock_name,lock_timeout)
#endif /* EXTRA_DEBUG */
-#ifdef __cplusplus
+#ifdef __cplusplus
}
+/*
+ DBUG_LOG() was initially intended for InnoDB. To be able to use it elsewhere
+ one should #include <sstream>. We intentially avoid including it here to save
+ compilation time.
+*/
+# ifdef DBUG_OFF
+# define DBUG_LOG(keyword, v) do {} while (0)
+# else
+# define DBUG_LOG(keyword, v) do { \
+ if (_db_pargs_(__LINE__, keyword)) { \
+ std::ostringstream _db_s; _db_s << v; \
+ _db_doprnt_("%s", _db_s.str().c_str()); \
+ }} while (0)
+# endif
#endif
#endif /* _my_dbug_h */
diff --git a/include/my_decimal_limits.h b/include/my_decimal_limits.h
index 34117f8c5b0..ac1df83bb62 100644
--- a/include/my_decimal_limits.h
+++ b/include/my_decimal_limits.h
@@ -31,10 +31,16 @@
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))
+
+ With normal precession we can handle 65 digits. MariaDB can store in
+ the .frm up to 63 digits. By default we use DECIMAL_NOT_SPECIFIED digits
+ when converting strings to decimal, so we don't want to set this too high.
+ To not use up all digits for the scale we limit the number of decimals to
+ 38.
*/
#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
-#define DECIMAL_MAX_SCALE 30
-#define DECIMAL_NOT_SPECIFIED 31
+#define DECIMAL_MAX_SCALE 38
+#define DECIMAL_NOT_SPECIFIED 39
/**
maximum length of string representation (number of maximum decimal
diff --git a/include/my_dir.h b/include/my_dir.h
index c92c825414e..a2e04a488f0 100644
--- a/include/my_dir.h
+++ b/include/my_dir.h
@@ -35,9 +35,16 @@ extern "C" {
#define MY_S_ISUID S_ISUID /* set user id on execution */
#define MY_S_ISGID S_ISGID /* set group id on execution */
#define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
-#define MY_S_IREAD S_IREAD /* read permission, owner */
-#define MY_S_IWRITE S_IWRITE /* write permission, owner */
-#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
+
+#ifndef S_IREAD
+#define MY_S_IREAD S_IRUSR /* read permission, owner */
+#define MY_S_IWRITE S_IWUSR /* write permission, owner */
+#define MY_S_IEXEC S_IXUSR /* execute/search permission, owner */
+#else
+#define MY_S_IREAD S_IREAD /* read permission, owner */
+#define MY_S_IWRITE S_IWRITE /* write permission, owner */
+#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
+#endif
#define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
#define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
diff --git a/include/my_global.h b/include/my_global.h
index 60249a15352..4ce4671c571 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -153,13 +153,11 @@
*/
#if defined(__APPLE__) && defined(__MACH__)
# undef SIZEOF_CHARP
-# undef SIZEOF_SHORT
# undef SIZEOF_INT
# undef SIZEOF_LONG
# undef SIZEOF_LONG_LONG
# undef SIZEOF_OFF_T
# undef WORDS_BIGENDIAN
-# define SIZEOF_SHORT 2
# define SIZEOF_INT 4
# define SIZEOF_LONG_LONG 8
# define SIZEOF_OFF_T 8
@@ -257,7 +255,9 @@
AIX includes inttypes.h from sys/types.h
Explicitly request format macros before the first inclusion of inttypes.h
*/
-#define __STDC_FORMAT_MACROS
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif // !defined(__STDC_FORMAT_MACROS)
#endif
@@ -685,7 +685,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
smaller what the disk page size. This influences the speed of the
isam btree library. eg to big to slow.
*/
-#define IO_SIZE 4096
+#define IO_SIZE 4096U
/*
How much overhead does malloc have. The code often allocates
something like 1024-MALLOC_OVERHEAD bytes
@@ -825,6 +825,7 @@ static inline bool isfinite(double x) { return std::isfinite(x); }
#ifndef HAVE_ISNAN
#define isnan(x) ((x) != (x))
#endif
+#define my_isnan(x) isnan(x)
#ifdef HAVE_ISINF
#define my_isinf(X) isinf(X)
@@ -1078,6 +1079,7 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */
#ifdef _WIN32
#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
+#define RTLD_DEFAULT GetModuleHandle(NULL)
#define dlclose(lib) FreeLibrary((HMODULE)lib)
static inline char *dlerror(void)
{
@@ -1246,4 +1248,31 @@ static inline double rint(double x)
#undef __GNUG__
#endif
+/*
+ Provide defaults for the CPU cache line size, if it has not been detected by
+ CMake using getconf
+*/
+#if !defined(CPU_LEVEL1_DCACHE_LINESIZE) || CPU_LEVEL1_DCACHE_LINESIZE == 0
+ #if CPU_LEVEL1_DCACHE_LINESIZE == 0
+ #undef CPU_LEVEL1_DCACHE_LINESIZE
+ #endif
+
+ #if defined(__s390__)
+ #define CPU_LEVEL1_DCACHE_LINESIZE 256
+ #elif defined(__powerpc__) || defined(__aarch64__)
+ #define CPU_LEVEL1_DCACHE_LINESIZE 128
+ #else
+ #define CPU_LEVEL1_DCACHE_LINESIZE 64
+ #endif
+#endif
+
+#define FLOATING_POINT_DECIMALS 31
+
+/* Keep client compatible with earlier versions */
+#ifdef MYSQL_SERVER
+#define NOT_FIXED_DEC DECIMAL_NOT_SPECIFIED
+#else
+#define NOT_FIXED_DEC FLOATING_POINT_DECIMALS
+#endif
+
#endif /* my_global_h */
diff --git a/include/my_handler_errors.h b/include/my_handler_errors.h
index 5e882da5998..87e52f141c7 100644
--- a/include/my_handler_errors.h
+++ b/include/my_handler_errors.h
@@ -23,18 +23,20 @@
static const char *handler_error_messages[]=
{
- "Didn't find key on read or update",
+ /* 120 */
+ "Didn't find the key on read or update",
"Duplicate key on write or update",
"Internal (unspecified) error in handler",
- "Someone has changed the row since it was read (while the table was locked to prevent it)",
- "Wrong index given to function",
+ "Someone has changed the row since it was read (even though the table was locked to prevent it)",
+ "Wrong index given to a function",
"Undefined handler error 125",
- "Index file is crashed",
- "Record file is crashed",
+ "Index is corrupted",
+ "Table file is corrupted",
"Out of memory in engine",
"Undefined handler error 129",
+ /* 130 */
"Incorrect file format",
- "Command not supported by database",
+ "Command not supported by the engine",
"Old database file",
"No record read before update",
"Record was already deleted (or record file crashed)",
@@ -43,8 +45,9 @@ static const char *handler_error_messages[]=
"No more records (read after end of file)",
"Unsupported extension used for table",
"Too big row",
+ /* 140 */
"Wrong create options",
- "Duplicate unique key or constraint on write or update",
+ "Duplicate unique key on write or update",
"Unknown character set used in table",
"Conflicting table definitions in sub-tables of MERGE table",
"Table is crashed and last repair failed",
@@ -53,17 +56,19 @@ static const char *handler_error_messages[]=
"Lock table is full; Restart program with a larger lock table",
"Updates are not allowed under a read only transactions",
"Lock deadlock; Retry transaction",
+ /* 150 */
"Foreign key constraint is incorrectly formed",
"Cannot add a child row",
"Cannot delete a parent row",
"No savepoint with that name",
"Non unique key block size",
- "The table does not exist in engine",
- "The table already existed in storage engine",
- "Could not connect to storage engine",
+ "The table does not exist in the storage engine",
+ "The table already existed in the storage engine",
+ "Could not connect to the storage engine",
"Unexpected null pointer found when using spatial index",
- "The table changed in storage engine",
- "There's no partition in table for the given value",
+ "The table changed in the storage engine",
+ /* 160 */
+ "There's no partition in the table for the given value",
"Row-based binary logging of row failed",
"Index needed in foreign key constraint",
"Upholding foreign key constraints would lead to a duplicate key error in some other table",
@@ -72,17 +77,19 @@ static const char *handler_error_messages[]=
"Failed to get next auto increment value",
"Failed to set row auto increment value",
"Unknown (generic) error from engine",
- "Record was not update. Original values was same as new values",
+ "Record was not updated. New values were the same as original values",
+ /* 170 */
"It is not possible to log this statement",
"The event was corrupt, leading to illegal data being read",
"The table is of a new format not supported by this version",
"The event could not be processed. No other handler error happened",
- "Got a fatal error during initialization of handler",
+ "Fatal error during initialization of handler",
"File too short; Expected more data in file",
"Read page with wrong checksum",
"Too many active concurrent transactions",
"Record not matching the given partition set",
"Index column length exceeds limit",
+ /* 180 */
"Index corrupted",
"Undo record too big",
"Invalid InnoDB FTS Doc ID",
@@ -93,9 +100,12 @@ static const char *handler_error_messages[]=
"Row is not visible by the current transaction",
"Operation was interrupted by end user (probably kill command?)",
"Disk full",
+ /* 190 */
"Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump and restore the table to fix this",
"Too many words in a FTS phrase or proximity search",
- "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match."
+ "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.",
+ "Foreign key cascade delete/update exceeds max depth",
+ "Tablespace is missing for a table"
};
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 778123976fa..2b3f4f14ea3 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, MariaDB
+ Copyright (c) 2009, 2017, 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
@@ -54,26 +54,7 @@ typedef struct st_pthread_link {
We use native conditions on Vista and later, and fallback to own
implementation on earlier OS version.
*/
-typedef union
-{
- /* Native condition (used on Vista and later) */
- CONDITION_VARIABLE native_cond;
-
- /* Own implementation (used on XP) */
- struct
- {
- uint32 waiting;
- CRITICAL_SECTION lock_waiting;
- enum
- {
- SIGNAL= 0,
- BROADCAST= 1,
- MAX_EVENTS= 2
- } EVENTS;
- HANDLE events[MAX_EVENTS];
- HANDLE broadcast_block_event;
- };
-} pthread_cond_t;
+typedef CONDITION_VARIABLE pthread_cond_t;
typedef int pthread_mutexattr_t;
@@ -81,10 +62,8 @@ typedef int pthread_mutexattr_t;
#define pthread_handler_t EXTERNC void * __cdecl
typedef void * (__cdecl *pthread_handler)(void *);
-typedef volatile LONG my_pthread_once_t;
-#define MY_PTHREAD_ONCE_INIT 0
-#define MY_PTHREAD_ONCE_INPROGRESS 1
-#define MY_PTHREAD_ONCE_DONE 2
+typedef INIT_ONCE my_pthread_once_t;
+#define MY_PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT;
#if !STRUCT_TIMESPEC_HAS_TV_SEC || !STRUCT_TIMESPEC_HAS_TV_NSEC
struct timespec {
@@ -287,7 +266,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#else /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
-#define HAVE_PTHREAD_KILL
+#define HAVE_PTHREAD_KILL 1
#endif
#endif /* defined(__WIN__) */
@@ -465,30 +444,10 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp);
#define safe_mutex_assert_not_owner(mp) do {} while (0)
#define safe_mutex_setflags(mp, F) do {} while (0)
-#if defined(MY_PTHREAD_FASTMUTEX)
-#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A), &(B)->mutex, (C))
-#define my_cond_wait(A,B) pthread_cond_wait((A), &(B)->mutex)
-#else
#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A),(B),(C))
#define my_cond_wait(A,B) pthread_cond_wait((A), (B))
-#endif /* MY_PTHREAD_FASTMUTEX */
#endif /* !SAFE_MUTEX */
-#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
-typedef struct st_my_pthread_fastmutex_t
-{
- pthread_mutex_t mutex;
- uint spins;
- uint rng_state;
-} my_pthread_fastmutex_t;
-void fastmutex_global_init(void);
-
-int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
- const pthread_mutexattr_t *attr);
-int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp);
-
-#endif /* defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) */
-
/* READ-WRITE thread locking */
#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
@@ -712,7 +671,7 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr;
#define ESRCH 1
#endif
-typedef ulong my_thread_id;
+typedef uint64 my_thread_id;
extern void my_threadattr_global_init(void);
extern my_bool my_thread_global_init(void);
@@ -756,7 +715,7 @@ struct st_my_thread_var
mysql_mutex_t * volatile current_mutex;
mysql_cond_t * volatile current_cond;
pthread_t pthread_self;
- my_thread_id id;
+ my_thread_id id, dbug_id;
int volatile abort;
my_bool init;
struct st_my_thread_var *next,**prev;
diff --git a/include/my_service_manager.h b/include/my_service_manager.h
index c8d634e498f..95b5235e755 100644
--- a/include/my_service_manager.h
+++ b/include/my_service_manager.h
@@ -24,7 +24,9 @@
sd-daemon.h may include inttypes.h. Explicitly request format macros before
the first inclusion of inttypes.h.
*/
+#if !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
+#endif // !defined(__STDC_FORMAT_MACROS)
#include <systemd/sd-daemon.h>
/** INTERVAL in seconds followed by printf style status */
#define service_manager_extend_timeout(INTERVAL, FMTSTR, ...) \
diff --git a/include/my_sys.h b/include/my_sys.h
index 1cb9572429a..c1d81108a84 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2017, MariaDB Corporation
+ Copyright (c) 2010, 2017, 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
@@ -61,68 +61,68 @@ typedef struct my_aio_result {
#define MY_FILE_ERROR ((size_t) -1)
/* General bitmaps for my_func's */
-#define MY_FFNF 1 /* Fatal if file not found */
-#define MY_FNABP 2 /* Fatal if not all bytes read/writen */
-#define MY_NABP 4 /* Error if not all bytes read/writen */
-#define MY_FAE 8 /* Fatal if any error */
-#define MY_WME 16 /* Write message on error */
-#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
-#define MY_IGNORE_BADFD 32 /* my_sync(): ignore 'bad descriptor' errors */
-#define MY_ENCRYPT 64 /* Encrypt IO_CACHE temporary files */
-#define MY_NOSYMLINKS 512 /* my_open(): don't follow symlinks */
-#define MY_FULL_IO 512 /* my_read(): loop intil I/O is complete */
-#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
-#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
-#define MY_COPYTIME 64 /* my_redel() copys time */
-#define MY_DELETE_OLD 256 /* my_create_with_symlink() */
-#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
-#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
-#define MY_REDEL_MAKE_BACKUP 256
-#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
-#define MY_SHORT_WAIT 64 /* my_lock() don't wait if can't lock */
-#define MY_FORCE_LOCK 128 /* use my_lock() even if disable_locking */
-#define MY_NO_WAIT 256 /* my_lock() don't wait at all */
+#define MY_FFNF 1U /* Fatal if file not found */
+#define MY_FNABP 2U /* Fatal if not all bytes read/writen */
+#define MY_NABP 4U /* Error if not all bytes read/writen */
+#define MY_FAE 8U /* Fatal if any error */
+#define MY_WME 16U /* Write message on error */
+#define MY_WAIT_IF_FULL 32U /* Wait and try again if disk full error */
+#define MY_IGNORE_BADFD 32U /* my_sync(): ignore 'bad descriptor' errors */
+#define MY_ENCRYPT 64U /* Encrypt IO_CACHE temporary files */
+#define MY_NOSYMLINKS 512U /* my_open(): don't follow symlinks */
+#define MY_FULL_IO 512U /* my_read(): loop until I/O is complete */
+#define MY_DONT_CHECK_FILESIZE 128U /* Option to init_io_cache() */
+#define MY_LINK_WARNING 32U /* my_redel() gives warning if links */
+#define MY_COPYTIME 64U /* my_redel() copys time */
+#define MY_DELETE_OLD 256U /* my_create_with_symlink() */
+#define MY_RESOLVE_LINK 128U /* my_realpath(); Only resolve links */
+#define MY_HOLD_ORIGINAL_MODES 128U /* my_copy() holds to file modes */
+#define MY_REDEL_MAKE_BACKUP 256U
+#define MY_SEEK_NOT_DONE 32U /* my_lock may have to do a seek */
+#define MY_SHORT_WAIT 64U /* my_lock() don't wait if can't lock */
+#define MY_FORCE_LOCK 128U /* use my_lock() even if disable_locking */
+#define MY_NO_WAIT 256U /* my_lock() don't wait at all */
/*
init_dynamic_array() has init buffer; Internal flag, not to be used by
caller.
*/
-#define MY_INIT_BUFFER_USED 256
-#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
-#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
-#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
-#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
-#define MY_DONT_OVERWRITE_FILE 2048 /* my_copy: Don't overwrite file */
-#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
-#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*/
-#define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */
-
-#define ME_BELL 4 /* Ring bell then printing message */
+#define MY_INIT_BUFFER_USED 256U
+#define MY_ZEROFILL 32U /* my_malloc(), fill array with zero */
+#define MY_ALLOW_ZERO_PTR 64U /* my_realloc() ; zero ptr -> malloc */
+#define MY_FREE_ON_ERROR 128U /* my_realloc() ; Free old ptr on error */
+#define MY_HOLD_ON_ERROR 256U /* my_realloc() ; Return old ptr on error */
+#define MY_DONT_OVERWRITE_FILE 2048U /* my_copy: Don't overwrite file */
+#define MY_THREADSAFE 2048U /* my_seek(): lock fd mutex */
+#define MY_SYNC 4096U /* my_copy(): sync dst file */
+#define MY_SYNC_DIR 32768U /* my_create/delete/rename: sync directory */
+#define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */
+#define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */
+#define MY_THREAD_MOVE 0x20000U /* realloc(); Memory can move */
+/* Tree that should delete things automaticly */
+#define MY_TREE_WITH_DELETE 0x40000U
+
+#define MY_CHECK_ERROR 1U /* Params to my_end; Check open-close */
+#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 64 /* Write the error message to error log */
+#define ME_NOREFRESH 64U /* Write the error message to error log */
#define ME_NOINPUT 0 /* Dont use the input libary */
-#define ME_JUST_INFO 1024 /**< not error but just info */
-#define ME_JUST_WARNING 2048 /**< not error but just warning */
-#define ME_FATALERROR 4096 /* Fatal statement error */
+#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 */
/* Bits in last argument to fn_format */
-#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
-#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */
-#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */
-#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */
-#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */
-#define MY_RETURN_REAL_PATH 32 /* return full path for file */
-#define MY_SAFE_PATH 64 /* Return NULL if too long path */
-#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
-#define MY_APPEND_EXT 256 /* add 'ext' as additional extension*/
+#define MY_REPLACE_DIR 1U /* replace dir in name with 'dir' */
+#define MY_REPLACE_EXT 2U /* replace extension with 'ext' */
+#define MY_UNPACK_FILENAME 4U /* Unpack name (~ -> home) */
+#define MY_PACK_FILENAME 8U /* Pack name (home -> ~) */
+#define MY_RESOLVE_SYMLINKS 16U /* Resolve all symbolic links */
+#define MY_RETURN_REAL_PATH 32U /* return full path for file */
+#define MY_SAFE_PATH 64U /* Return NULL if too long path */
+#define MY_RELATIVE_PATH 128U /* name is relative to 'dir' */
+#define MY_APPEND_EXT 256U /* add 'ext' as additional extension*/
/* My seek flags */
@@ -137,19 +137,19 @@ typedef struct my_aio_result {
#define DFLT_INIT_HITS 3
/* root_alloc flags */
-#define MY_KEEP_PREALLOC 1
-#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */
+#define MY_KEEP_PREALLOC 1U
+#define MY_MARK_BLOCKS_FREE 2U /* move used to free list and reuse them */
/* Internal error numbers (for assembler functions) */
#define MY_ERRNO_EDOM 33
#define MY_ERRNO_ERANGE 34
/* Bits for get_date timeflag */
-#define GETDATE_DATE_TIME 1
-#define GETDATE_SHORT_DATE 2
-#define GETDATE_HHMMSSTIME 4
-#define GETDATE_GMT 8
-#define GETDATE_FIXEDLENGTH 16
+#define GETDATE_DATE_TIME 1U
+#define GETDATE_SHORT_DATE 2U
+#define GETDATE_HHMMSSTIME 4U
+#define GETDATE_GMT 8U
+#define GETDATE_FIXEDLENGTH 16U
/* Extra length needed for filename if one calls my_create_backup_name */
#define MY_BACKUP_NAME_EXTRA_LENGTH 17
@@ -176,7 +176,7 @@ extern void *my_memdup(const void *from,size_t length,myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strndup(const char *from, size_t length, myf MyFlags);
-#ifdef HAVE_LARGE_PAGES
+#ifdef HAVE_LINUX_LARGE_PAGES
extern uint my_get_large_page_size(void);
extern uchar * my_large_malloc(size_t size, myf my_flags);
extern void my_large_free(uchar *ptr);
@@ -184,7 +184,15 @@ extern void my_large_free(uchar *ptr);
#define my_get_large_page_size() (0)
#define my_large_malloc(A,B) my_malloc_lock((A),(B))
#define my_large_free(A) my_free_lock((A))
-#endif /* HAVE_LARGE_PAGES */
+#endif /* HAVE_LINUX_LARGE_PAGES */
+
+void my_init_atomic_write(void);
+#ifdef __linux__
+my_bool my_test_if_atomic_write(File handle, int pagesize);
+#else
+#define my_test_if_atomic_write(A, B) 0
+#endif /* __linux__ */
+extern my_bool my_may_have_atomic_write;
#if defined(HAVE_ALLOCA) && !defined(HAVE_valgrind)
#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
@@ -234,7 +242,7 @@ extern int sf_leaking_memory; /* set to 1 to disable memleak detection */
extern void (*proc_info_hook)(void *, const PSI_stage_info *, PSI_stage_info *,
const char *, const char *, const unsigned int);
-#ifdef HAVE_LARGE_PAGES
+#ifdef HAVE_LINUX_LARGE_PAGES
extern my_bool my_use_large_pages;
extern uint my_large_page_size;
#endif
@@ -415,14 +423,6 @@ typedef struct st_io_cache /* Used when cacheing files */
uchar *write_end;
/*
- Current_pos and current_end are convenience variables used by
- my_b_tell() and other routines that need to know the current offset
- current_pos points to &write_pos, and current_end to &write_end in a
- WRITE_CACHE, and &read_pos and &read_end respectively otherwise
- */
- uchar **current_pos, **current_end;
-
- /*
The lock is for append buffer used in SEQ_READ_APPEND cache
need mutex copying from append buffer to read buffer.
*/
@@ -466,6 +466,8 @@ typedef struct st_io_cache /* Used when cacheing files */
const char *dir;
char prefix[3];
File file; /* file descriptor */
+
+ struct st_io_cache *next_file_user;
/*
seek_not_done is set by my_b_seek() to inform the upcoming read/write
operation that a seek needs to be preformed prior to the actual I/O
@@ -574,7 +576,11 @@ static inline size_t my_b_fill(IO_CACHE *info)
static inline my_off_t my_b_tell(const IO_CACHE *info)
{
- return info->pos_in_file + (*info->current_pos - info->request_pos);
+ if (info->type == WRITE_CACHE) {
+ return info->pos_in_file + (info->write_pos - info->request_pos);
+
+ }
+ return info->pos_in_file + (info->read_pos - info->request_pos);
}
static inline my_off_t my_b_write_tell(const IO_CACHE *info)
@@ -599,7 +605,10 @@ static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info)
static inline size_t my_b_bytes_in_cache(const IO_CACHE *info)
{
- return *info->current_end - *info->current_pos;
+ if (info->type == WRITE_CACHE) {
+ return info->write_end - info->write_pos;
+ }
+ return info->read_end - info->read_pos;
}
int my_b_copy_to_file (IO_CACHE *cache, FILE *file, size_t count);
@@ -618,6 +627,7 @@ extern int (*mysys_test_invalid_symlink)(const char *filename);
extern int my_copy(const char *from,const char *to,myf MyFlags);
extern int my_delete(const char *name,myf MyFlags);
+extern int my_rmtree(const char *name, myf Myflags);
extern int my_getwd(char * buf,size_t size,myf MyFlags);
extern int my_setwd(const char *dir,myf MyFlags);
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
@@ -691,14 +701,14 @@ extern void my_osmaperr(unsigned long last_error);
#endif
extern void init_glob_errs(void);
-extern const char** get_global_errmsgs(void);
+extern const char** get_global_errmsgs(int nr);
extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_vfprintf(FILE *stream, const char* format, va_list args);
-extern void my_strerror(char *buf, size_t len, int nr);
+extern const char* my_strerror(char *buf, size_t len, int nr);
extern int my_fprintf(FILE *stream, const char* format, ...);
extern File my_fileno(FILE *fd);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
@@ -710,9 +720,9 @@ extern int my_sync(File fd, myf my_flags);
extern int my_sync_dir(const char *dir_name, myf my_flags);
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
extern const char *my_get_err_msg(uint nr);
-extern int my_error_register(const char** (*get_errmsgs) (void),
+extern int my_error_register(const char** (*get_errmsgs) (int nr),
uint first, uint last);
-extern const char **my_error_unregister(uint first, uint last);
+extern my_bool my_error_unregister(uint first, uint last);
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);
@@ -795,9 +805,13 @@ extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
my_off_t seek_offset, my_bool use_async_io,
my_bool clear_cache);
-extern void setup_io_cache(IO_CACHE* info);
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
IO_CACHE *write_cache, uint num_threads);
+
+extern int init_slave_io_cache(IO_CACHE *master, IO_CACHE *slave);
+void end_slave_io_cache(IO_CACHE *cache);
+void seek_io_cache(IO_CACHE *cache, my_off_t needed_offset);
+
extern void remove_io_thread(IO_CACHE *info);
extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count);
extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count);
@@ -1023,6 +1037,7 @@ extern void add_compiled_collation(struct charset_info_st *cs);
extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
const char *from, size_t length);
+extern char *get_tty_password(const char *opt_message);
#ifdef __WIN__
#define BACKSLASH_MBTAIL
/* File system character set */
diff --git a/include/my_time.h b/include/my_time.h
index 6e4a625f2c0..80089fa2c64 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -1,5 +1,6 @@
/*
Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2017, 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
@@ -23,6 +24,7 @@
#define _my_time_h_
#include "my_global.h"
#include "mysql_time.h"
+#include "my_decimal_limits.h"
C_MODE_START
@@ -60,16 +62,16 @@ extern uchar days_in_month[];
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 1
-#define TIME_DATETIME_ONLY 2
-#define TIME_TIME_ONLY 4
+#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 MYSQL_TIME_WARN_TRUNCATED 1
-#define MYSQL_TIME_WARN_OUT_OF_RANGE 2
-#define MYSQL_TIME_NOTE_TRUNCATED 16
+#define MYSQL_TIME_WARN_TRUNCATED 1U
+#define MYSQL_TIME_WARN_OUT_OF_RANGE 2U
+#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_NOTES (MYSQL_TIME_NOTE_TRUNCATED)
@@ -170,6 +172,12 @@ static inline my_bool validate_timestamp_range(const MYSQL_TIME *t)
return TRUE;
}
+/* Can't include mysqld_error.h, it needs mysys to build, thus hardcode 2 error values here. */
+#ifndef ER_WARN_DATA_OUT_OF_RANGE
+#define ER_WARN_DATA_OUT_OF_RANGE 1264
+#define ER_WARN_INVALID_TIMESTAMP 1299
+#endif
+
my_time_t
my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, uint *error_code);
@@ -184,7 +192,7 @@ 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 */
+#define AUTO_SEC_PART_DIGITS DECIMAL_NOT_SPECIFIED
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);
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 6df8f5a772e..cd81f109455 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010 Monty Program Ab
+/* Copyright (C) 2010, 2017, 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
@@ -27,7 +27,7 @@
#define IF_VALGRIND(A,B) B
#endif
-#if defined(HAVE_VALGRIND) && defined(HAVE_valgrind)
+#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
@@ -46,12 +46,13 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
-#endif /* HAVE_VALGRIND */
+#endif /* HAVE_VALGRIND_MEMCHECK_H */
#ifndef DBUG_OFF
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
#endif
+
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
diff --git a/include/myisam.h b/include/myisam.h
index 3495cf16424..26857b4ac32 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -373,7 +373,7 @@ typedef struct st_mi_sort_param
int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(HA_CHECK *);
- int (*write_keys)(struct st_mi_sort_param *, register uchar **,
+ int (*write_keys)(struct st_mi_sort_param *, uchar **,
ulonglong , struct st_buffpek *, IO_CACHE *);
my_off_t (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *,
@@ -383,16 +383,15 @@ typedef struct st_mi_sort_param
/* functions in mi_check */
void myisamchk_init(HA_CHECK *param);
int chk_status(HA_CHECK *param, MI_INFO *info);
-int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag);
+int chk_del(HA_CHECK *param, MI_INFO *info, ulonglong test_flag);
int chk_size(HA_CHECK *param, MI_INFO *info);
int chk_key(HA_CHECK *param, MI_INFO *info);
int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend);
-int mi_repair(HA_CHECK *param, register MI_INFO *info,
- char * name, int rep_quick);
-int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name);
-int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
+int mi_repair(HA_CHECK *param, MI_INFO *info, char * name, int rep_quick);
+int mi_sort_index(HA_CHECK *param, MI_INFO *info, char * name);
+int mi_repair_by_sort(HA_CHECK *param, MI_INFO *info,
const char * name, int rep_quick);
-int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
+int mi_repair_parallel(HA_CHECK *param, MI_INFO *info,
const char * name, int rep_quick);
int change_to_newfile(const char * filename, const char * old_ext,
const char * new_ext, time_t backup_time, myf myflags);
diff --git a/include/myisamchk.h b/include/myisamchk.h
index 4ff8a86c56a..883165b78fd 100644
--- a/include/myisamchk.h
+++ b/include/myisamchk.h
@@ -1,4 +1,5 @@
/* Copyright (C) 2006 MySQL AB
+ Copyright (c) 2017, 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
@@ -16,14 +17,6 @@
/* Definitions needed for myisamchk/mariachk.c */
-/*
- Entries marked as "QQ to be removed" are NOT used to
- pass check/repair options to xxx_check.c. They are used
- internally by xxxchk.c or/and ha_xxxx.cc and should NOT
- be stored together with other flags. They should be removed
- from the following list to make addition of new flags possible.
-*/
-
#ifndef _myisamchk_h
#define _myisamchk_h
@@ -32,13 +25,13 @@
to xxxcheck.c follows:
*/
-#define TT_USEFRM 1
-#define TT_FOR_UPGRADE 2
-#define TT_FROM_MYSQL 4
+#define TT_USEFRM 1U
+#define TT_FOR_UPGRADE 2U
+#define TT_FROM_MYSQL 4U
/* Bits set in out_flag */
-#define O_NEW_DATA 2
-#define O_DATA_LOST 4
+#define O_NEW_DATA 2U
+#define O_DATA_LOST 4U
typedef struct st_sort_key_blocks /* Used when sorting */
{
@@ -66,6 +59,7 @@ typedef enum
MI_STATS_METHOD_IGNORE_NULLS
} enum_handler_stats_method;
+struct st_myisam_info;
typedef struct st_handler_check_param
{
@@ -122,6 +116,8 @@ typedef struct st_handler_check_param
uint progress_counter; /* How often to call _report_progress() */
ulonglong progress, max_progress;
+ int (*fix_record)(struct st_myisam_info *info, uchar *record, int keynum);
+
mysql_mutex_t print_msg_mutex;
my_bool need_print_msg_lock;
myf malloc_flags;
diff --git a/include/myisampack.h b/include/myisampack.h
index 22820ca7158..eb5baf5fc56 100644
--- a/include/myisampack.h
+++ b/include/myisampack.h
@@ -52,11 +52,16 @@
(((uint32) (((const uchar*) (A))[2])) << 8) +\
(((uint32) (((const uchar*) (A))[1])) << 16) +\
(((uint32) (((const uchar*) (A))[0])) << 24)))
+
+#ifndef HAVE_mi_uint5korr
#define mi_uint5korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[4])) +\
(((uint32) (((const uchar*) (A))[3])) << 8) +\
(((uint32) (((const uchar*) (A))[2])) << 16) +\
(((uint32) (((const uchar*) (A))[1])) << 24)) +\
(((ulonglong) (((const uchar*) (A))[0])) << 32))
+#endif /* HAVE_mi_uint5korr */
+
+#ifndef HAVE_mi_uint6korr
#define mi_uint6korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[5])) +\
(((uint32) (((const uchar*) (A))[4])) << 8) +\
(((uint32) (((const uchar*) (A))[3])) << 16) +\
@@ -64,6 +69,9 @@
(((ulonglong) (((uint32) (((const uchar*) (A))[1])) +\
(((uint32) (((const uchar*) (A))[0]) << 8)))) <<\
32))
+#endif /* HAVE_mi_uint6korr */
+
+#ifndef HAVE_mi_uint7korr
#define mi_uint7korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[6])) +\
(((uint32) (((const uchar*) (A))[5])) << 8) +\
(((uint32) (((const uchar*) (A))[4])) << 16) +\
@@ -72,6 +80,9 @@
(((uint32) (((const uchar*) (A))[1])) << 8) +\
(((uint32) (((const uchar*) (A))[0])) << 16))) <<\
32))
+#endif /* HAVE_mi_uint7korr */
+
+#ifndef HAVE_mi_uint8korr
#define mi_uint8korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[7])) +\
(((uint32) (((const uchar*) (A))[6])) << 8) +\
(((uint32) (((const uchar*) (A))[5])) << 16) +\
@@ -81,6 +92,7 @@
(((uint32) (((const uchar*) (A))[1])) << 16) +\
(((uint32) (((const uchar*) (A))[0])) << 24))) <<\
32))
+#endif /* HAVE_mi_uint8korr */
/* This one is for uniformity */
#define mi_int1store(T,A) *((uchar*)(T))= (uchar) (A)
diff --git a/include/mysql.h b/include/mysql.h
index 1ab727de788..07702a54dba 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -141,6 +141,13 @@ typedef unsigned long long my_ulonglong;
/* backward compatibility define - to be removed eventually */
#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
#define WARN_PLUGIN_DELETE_BUILTIN ER_PLUGIN_DELETE_BUILTIN
+#define ER_FK_DUP_NAME ER_DUP_CONSTRAINT_NAME
+#define ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+#define ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN
+#define ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
+#define ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+#define ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
+#define ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
typedef struct st_mysql_rows {
struct st_mysql_rows *next; /* list of rows */
@@ -371,7 +378,7 @@ void STDCALL mysql_server_end(void);
/*
mysql_server_init/end need to be called when using libmysqld or
libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
- you don't need to call it explicitely; but you need to call
+ you don't need to call it explicitly; but you need to call
mysql_server_end() to free memory). The names are a bit misleading
(mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
names which suit well whether you're using libmysqld or libmysqlclient. We
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 6d0d2be5a2c..73b9f9f588b 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -9,7 +9,23 @@ enum enum_server_command
COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
- COM_END
+ COM_UNIMPLEMENTED,
+ COM_RESET_CONNECTION,
+ COM_MDB_GAP_BEG,
+ COM_MDB_GAP_END=249,
+ COM_STMT_BULK_EXECUTE=250,
+ COM_SLAVE_WORKER=251,
+ COM_SLAVE_IO=252,
+ COM_SLAVE_SQL=253,
+ COM_MULTI=254,
+ COM_END=255
+};
+enum enum_indicator_type
+{
+ STMT_INDICATOR_NONE= 0,
+ STMT_INDICATOR_NULL,
+ STMT_INDICATOR_DEFAULT,
+ STMT_INDICATOR_IGNORE
};
struct st_vio;
typedef struct st_vio Vio;
@@ -81,6 +97,16 @@ enum enum_mysql_set_option
MYSQL_OPTION_MULTI_STATEMENTS_ON,
MYSQL_OPTION_MULTI_STATEMENTS_OFF
};
+enum enum_session_state_type
+{
+ SESSION_TRACK_SYSTEM_VARIABLES,
+ SESSION_TRACK_SCHEMA,
+ SESSION_TRACK_STATE_CHANGE,
+ SESSION_TRACK_GTIDS,
+ SESSION_TRACK_TRANSACTION_CHARACTERISTICS,
+ SESSION_TRACK_TRANSACTION_STATE,
+ SESSION_TRACK_always_at_the_end
+};
my_bool my_net_init(NET *net, Vio* vio, void *thd, unsigned int my_flags);
void my_net_local_init(NET *net);
void net_end(NET *net);
@@ -93,6 +119,8 @@ my_bool net_write_command(NET *net,unsigned char command,
const unsigned char *packet, size_t len);
int net_real_write(NET *net,const unsigned char *packet, size_t len);
unsigned long my_net_read_packet(NET *net, my_bool read_from_server);
+unsigned long my_net_read_packet_reallen(NET *net, my_bool read_from_server,
+ unsigned long* reallen);
struct sockaddr;
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
unsigned int timeout);
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index b098439d2c7..3a522af8a9e 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -393,6 +393,11 @@ DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
#name, comment, check, update, &varname, def, min, max, blk }
+#define MYSQL_SYSVAR_UINT64_T(name, varname, opt, comment, check, update, def, min, max, blk) \
+DECLARE_MYSQL_SYSVAR_SIMPLE(name, uint64_t) = { \
+ PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
+ #name, comment, check, update, &varname, def, min, max, blk }
+
#ifdef _WIN64
#define MYSQL_SYSVAR_SIZE_T(name, varname, opt, comment, check, update, def, min, max, blk) \
DECLARE_MYSQL_SYSVAR_SIMPLE(name, size_t) = { \
diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h
index b90d8d664eb..2a3a59eea72 100644
--- a/include/mysql/plugin_audit.h
+++ b/include/mysql/plugin_audit.h
@@ -60,7 +60,7 @@ struct mysql_event_general
unsigned int general_command_length;
const char *general_query;
unsigned int general_query_length;
- struct charset_info_st *general_charset;
+ const struct charset_info_st *general_charset;
unsigned long long general_time;
unsigned long long general_rows;
/* Added in version 0x302 */
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index d014edfedb9..410781669ba 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -9,12 +9,12 @@ extern struct base64_service_st {
int (*base64_decode_ptr)(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
} *base64_service;
-int base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
struct encryption_service_st {
@@ -167,9 +167,9 @@ int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
extern struct my_print_error_service_st {
- void(*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
- void(*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
- void(*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
} *my_print_error_service;
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
@@ -271,21 +271,21 @@ struct st_mysql_lex_string
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
+ void *(*thd_alloc_func)(void*, size_t);
+ void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ char *(*thd_strmake_func)(void*, const char *, size_t);
+ void *(*thd_memdup_func)(void*, const void*, size_t);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
+ const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
+void *thd_alloc(void* thd, size_t size);
+void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
+char *thd_strmake(void* thd, const char *str, size_t size);
+void *thd_memdup(void* thd, const void* str, size_t size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
@@ -532,7 +532,7 @@ struct mysql_event_general
unsigned int general_command_length;
const char *general_query;
unsigned int general_query_length;
- struct charset_info_st *general_charset;
+ const struct charset_info_st *general_charset;
unsigned long long general_time;
unsigned long long general_rows;
unsigned long long query_id;
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 9dd3deba8de..62061f74274 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -9,12 +9,12 @@ extern struct base64_service_st {
int (*base64_decode_ptr)(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
} *base64_service;
-int base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
struct encryption_service_st {
@@ -167,9 +167,9 @@ int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
extern struct my_print_error_service_st {
- void(*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
- void(*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
- void(*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
} *my_print_error_service;
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
@@ -271,21 +271,21 @@ struct st_mysql_lex_string
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
+ void *(*thd_alloc_func)(void*, size_t);
+ void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ char *(*thd_strmake_func)(void*, const char *, size_t);
+ void *(*thd_memdup_func)(void*, const void*, size_t);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
+ const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
+void *thd_alloc(void* thd, size_t size);
+void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
+char *thd_strmake(void* thd, const char *str, size_t size);
+void *thd_memdup(void* thd, const void* str, size_t size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 7bb81614971..1277147e55f 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -9,12 +9,12 @@ extern struct base64_service_st {
int (*base64_decode_ptr)(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
} *base64_service;
-int base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
struct encryption_service_st {
@@ -167,9 +167,9 @@ int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
extern struct my_print_error_service_st {
- void(*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
- void(*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
- void(*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
} *my_print_error_service;
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
@@ -271,21 +271,21 @@ struct st_mysql_lex_string
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
+ void *(*thd_alloc_func)(void*, size_t);
+ void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ char *(*thd_strmake_func)(void*, const char *, size_t);
+ void *(*thd_memdup_func)(void*, const void*, size_t);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
+ const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
+void *thd_alloc(void* thd, size_t size);
+void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
+char *thd_strmake(void* thd, const char *str, size_t size);
+void *thd_memdup(void* thd, const void* str, size_t size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index 43c02059874..85c6700227f 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -9,12 +9,12 @@ extern struct base64_service_st {
int (*base64_decode_ptr)(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
} *base64_service;
-int base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
struct encryption_service_st {
@@ -167,9 +167,9 @@ int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
extern struct my_print_error_service_st {
- void(*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
- void(*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
- void(*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
} *my_print_error_service;
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
@@ -271,21 +271,21 @@ struct st_mysql_lex_string
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
+ void *(*thd_alloc_func)(void*, size_t);
+ void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ char *(*thd_strmake_func)(void*, const char *, size_t);
+ void *(*thd_memdup_func)(void*, const void*, size_t);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
+ const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
+void *thd_alloc(void* thd, size_t size);
+void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
+char *thd_strmake(void* thd, const char *str, size_t size);
+void *thd_memdup(void* thd, const void* str, size_t size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index d2fe8fa8e23..25eb5425e52 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -9,12 +9,12 @@ extern struct base64_service_st {
int (*base64_decode_ptr)(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
} *base64_service;
-int base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
struct encryption_service_st {
@@ -167,9 +167,9 @@ int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
extern struct my_print_error_service_st {
- void(*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
- void(*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
- void(*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
} *my_print_error_service;
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
@@ -271,21 +271,21 @@ struct st_mysql_lex_string
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
+ void *(*thd_alloc_func)(void*, size_t);
+ void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ char *(*thd_strmake_func)(void*, const char *, size_t);
+ void *(*thd_memdup_func)(void*, const void*, size_t);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
+ const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
+void *thd_alloc(void* thd, size_t size);
+void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
+char *thd_strmake(void* thd, const char *str, size_t size);
+void *thd_memdup(void* thd, const void* str, size_t size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h
index 1d054e644ac..b37495ebb7d 100644
--- a/include/mysql/psi/mysql_idle.h
+++ b/include/mysql/psi/mysql_idle.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 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
@@ -67,7 +68,7 @@
*/
static inline struct PSI_idle_locker *
inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
- const char *src_file, int src_line)
+ const char *src_file, uint src_line)
{
struct PSI_idle_locker *locker;
locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
index bf057c661bc..bdb60c4ad57 100644
--- a/include/mysql/psi/mysql_socket.h
+++ b/include/mysql/psi/mysql_socket.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 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
@@ -19,8 +20,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
#ifndef MYSQL_SOCKET_H
#define MYSQL_SOCKET_H
-/* For strlen() */
-#include <string.h>
/* For MY_STAT */
#include <my_dir.h>
/* For my_chsize */
@@ -243,7 +242,7 @@ inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
MYSQL_SOCKET mysql_socket,
enum PSI_socket_operation op,
size_t byte_count,
- const char *src_file, int src_line)
+ const char *src_file, uint src_line)
{
struct PSI_socket_locker *locker;
if (mysql_socket.m_psi != NULL)
@@ -736,7 +735,7 @@ inline_mysql_socket_send
MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags)
{
ssize_t result;
-
+ DBUG_ASSERT(mysql_socket.fd != INVALID_SOCKET);
#ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL)
{
@@ -752,8 +751,7 @@ inline_mysql_socket_send
/* Instrumentation end */
if (locker != NULL)
{
- size_t bytes_written;
- bytes_written= (result > -1) ? result : 0;
+ size_t bytes_written= (result > 0) ? (size_t) result : 0;
PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_written);
}
@@ -778,7 +776,7 @@ inline_mysql_socket_recv
MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags)
{
ssize_t result;
-
+ DBUG_ASSERT(mysql_socket.fd != INVALID_SOCKET);
#ifdef HAVE_PSI_SOCKET_INTERFACE
if (mysql_socket.m_psi != NULL)
{
@@ -794,8 +792,7 @@ inline_mysql_socket_recv
/* Instrumentation end */
if (locker != NULL)
{
- size_t bytes_read;
- bytes_read= (result > -1) ? result : 0;
+ size_t bytes_read= (result > 0) ? (size_t) result : 0;
PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_read);
}
@@ -836,8 +833,7 @@ inline_mysql_socket_sendto
/* Instrumentation end */
if (locker != NULL)
{
- size_t bytes_written;
- bytes_written = (result > -1) ? result : 0;
+ size_t bytes_written = (result > 0) ? (size_t) result : 0;
PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_written);
}
@@ -879,8 +875,7 @@ inline_mysql_socket_recvfrom
/* Instrumentation end */
if (locker != NULL)
{
- size_t bytes_read;
- bytes_read = (result > -1) ? result : 0;
+ size_t bytes_read= (result > 0) ? (size_t) result : 0;
PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_read);
}
@@ -1020,7 +1015,7 @@ inline_mysql_socket_accept
MYSQL_SOCKET socket_listen, struct sockaddr *addr, socklen_t *addr_len)
{
#ifdef FD_CLOEXEC
- int flags;
+ int flags __attribute__ ((unused));
#endif
MYSQL_SOCKET socket_accept= MYSQL_INVALID_SOCKET;
diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h
index 767337dac9d..33c61a63505 100644
--- a/include/mysql/psi/mysql_statement.h
+++ b/include/mysql/psi/mysql_statement.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 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
@@ -146,7 +147,7 @@ inline_mysql_start_statement(PSI_statement_locker_state *state,
PSI_statement_key key,
const char *db, uint db_len,
const CHARSET_INFO *charset,
- const char *src_file, int src_line)
+ const char *src_file, uint src_line)
{
PSI_statement_locker *locker;
locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset);
diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h
index 7b9ebcedd93..7584fec2243 100644
--- a/include/mysql/psi/mysql_table.h
+++ b/include/mysql/psi/mysql_table.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 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
@@ -183,7 +184,7 @@ static inline struct PSI_table_locker *
inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
struct PSI_table *psi,
enum PSI_table_lock_operation op,
- ulong flags, const char *src_file, int src_line)
+ ulong flags, const char *src_file, uint src_line)
{
if (psi != NULL)
{
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index bea43943bb1..c9ea4251ad3 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -71,8 +71,6 @@ struct st_mysql_mutex
/** The real mutex. */
#ifdef SAFE_MUTEX
safe_mutex_t m_mutex;
-#elif defined(MY_PTHREAD_FASTMUTEX)
- my_pthread_fastmutex_t m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
@@ -619,8 +617,6 @@ static inline int inline_mysql_mutex_init(
#endif
#ifdef SAFE_MUTEX
return safe_mutex_init(&that->m_mutex, attr, src_name, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- return my_pthread_fastmutex_init(&that->m_mutex, attr);
#else
return pthread_mutex_init(&that->m_mutex, attr);
#endif
@@ -642,8 +638,6 @@ static inline int inline_mysql_mutex_destroy(
#endif
#ifdef SAFE_MUTEX
return safe_mutex_destroy(&that->m_mutex, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- return pthread_mutex_destroy(&that->m_mutex.mutex);
#else
return pthread_mutex_destroy(&that->m_mutex);
#endif
@@ -670,8 +664,6 @@ static inline int inline_mysql_mutex_lock(
/* Instrumented code */
#ifdef SAFE_MUTEX
result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= my_pthread_fastmutex_lock(&that->m_mutex);
#else
result= pthread_mutex_lock(&that->m_mutex);
#endif
@@ -687,8 +679,6 @@ static inline int inline_mysql_mutex_lock(
/* Non instrumented code */
#ifdef SAFE_MUTEX
result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= my_pthread_fastmutex_lock(&that->m_mutex);
#else
result= pthread_mutex_lock(&that->m_mutex);
#endif
@@ -717,8 +707,6 @@ static inline int inline_mysql_mutex_trylock(
/* Instrumented code */
#ifdef SAFE_MUTEX
result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= pthread_mutex_trylock(&that->m_mutex.mutex);
#else
result= pthread_mutex_trylock(&that->m_mutex);
#endif
@@ -734,8 +722,6 @@ static inline int inline_mysql_mutex_trylock(
/* Non instrumented code */
#ifdef SAFE_MUTEX
result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= pthread_mutex_trylock(&that->m_mutex.mutex);
#else
result= pthread_mutex_trylock(&that->m_mutex);
#endif
@@ -759,8 +745,6 @@ static inline int inline_mysql_mutex_unlock(
#ifdef SAFE_MUTEX
result= safe_mutex_unlock(&that->m_mutex, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= pthread_mutex_unlock(&that->m_mutex.mutex);
#else
result= pthread_mutex_unlock(&that->m_mutex);
#endif
@@ -1256,7 +1240,7 @@ static inline int inline_mysql_thread_create(
return result;
}
-static inline void inline_mysql_thread_set_psi_id(ulong id)
+static inline void inline_mysql_thread_set_psi_id(my_thread_id id)
{
struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
PSI_THREAD_CALL(set_thread_id)(psi, id);
diff --git a/include/mysql/psi/psi_base.h b/include/mysql/psi/psi_base.h
new file mode 100644
index 00000000000..2bb3061d55c
--- /dev/null
+++ b/include/mysql/psi/psi_base.h
@@ -0,0 +1,147 @@
+/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_PSI_BASE_H
+#define MYSQL_PSI_BASE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @file mysql/psi/psi_base.h
+ Performance schema instrumentation interface.
+
+ @defgroup Instrumentation_interface Instrumentation Interface
+ @ingroup Performance_schema
+ @{
+*/
+
+#define PSI_INSTRUMENT_ME 0
+
+#define PSI_NOT_INSTRUMENTED 0
+
+/**
+ Global flag.
+ This flag indicate that an instrumentation point is a global variable,
+ or a singleton.
+*/
+#define PSI_FLAG_GLOBAL (1 << 0)
+
+/**
+ Mutable flag.
+ This flag indicate that an instrumentation point is a general placeholder,
+ that can mutate into a more specific instrumentation point.
+*/
+#define PSI_FLAG_MUTABLE (1 << 1)
+
+#define PSI_FLAG_THREAD (1 << 2)
+
+/**
+ Stage progress flag.
+ This flag apply to the stage instruments only.
+ It indicates the instrumentation provides progress data.
+*/
+#define PSI_FLAG_STAGE_PROGRESS (1 << 3)
+
+/**
+ Shared Exclusive flag.
+ Indicates that rwlock support the shared exclusive state.
+*/
+#define PSI_RWLOCK_FLAG_SX (1 << 4)
+
+/**
+ Transferable flag.
+ This flag indicate that an instrumented object can
+ be created by a thread and destroyed by another thread.
+*/
+#define PSI_FLAG_TRANSFER (1 << 5)
+
+#ifdef HAVE_PSI_INTERFACE
+
+/**
+ @def PSI_VERSION_1
+ Performance Schema Interface number for version 1.
+ This version is supported.
+*/
+#define PSI_VERSION_1 1
+
+/**
+ @def PSI_VERSION_2
+ Performance Schema Interface number for version 2.
+ This version is not implemented, it's a placeholder.
+*/
+#define PSI_VERSION_2 2
+
+/**
+ @def PSI_CURRENT_VERSION
+ Performance Schema Interface number for the most recent version.
+ The most current version is @c PSI_VERSION_1
+*/
+#define PSI_CURRENT_VERSION 1
+
+/**
+ @def USE_PSI_1
+ Define USE_PSI_1 to use the interface version 1.
+*/
+
+/**
+ @def USE_PSI_2
+ Define USE_PSI_2 to use the interface version 2.
+*/
+
+/**
+ @def HAVE_PSI_1
+ Define HAVE_PSI_1 if the interface version 1 needs to be compiled in.
+*/
+
+/**
+ @def HAVE_PSI_2
+ Define HAVE_PSI_2 if the interface version 2 needs to be compiled in.
+*/
+
+#ifndef USE_PSI_2
+#ifndef USE_PSI_1
+#define USE_PSI_1
+#endif
+#endif
+
+#ifdef USE_PSI_1
+#define HAVE_PSI_1
+#endif
+
+#ifdef USE_PSI_2
+#define HAVE_PSI_2
+#endif
+
+/*
+ Allow to override PSI_XXX_CALL at compile time
+ with more efficient implementations, if available.
+ If nothing better is available,
+ make a dynamic call using the PSI_server function pointer.
+*/
+
+#define PSI_DYNAMIC_CALL(M) PSI_server->M
+
+#endif /* HAVE_PSI_INTERFACE */
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MYSQL_PSI_BASE_H */
+
diff --git a/include/mysql/psi/psi_memory.h b/include/mysql/psi/psi_memory.h
new file mode 100644
index 00000000000..3c633e6a918
--- /dev/null
+++ b/include/mysql/psi/psi_memory.h
@@ -0,0 +1,155 @@
+/* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_PSI_MEMORY_H
+#define MYSQL_PSI_MEMORY_H
+
+#include "psi_base.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @file mysql/psi/psi_memory.h
+ Performance schema instrumentation interface.
+
+ @defgroup Instrumentation_interface Instrumentation Interface
+ @ingroup Performance_schema
+ @{
+*/
+
+#ifdef HAVE_PSI_INTERFACE
+#ifndef DISABLE_ALL_PSI
+#ifndef DISABLE_PSI_MEMORY
+#define HAVE_PSI_MEMORY_INTERFACE
+#endif /* DISABLE_PSI_MEMORY */
+#endif /* DISABLE_ALL_PSI */
+#endif /* HAVE_PSI_INTERFACE */
+
+struct PSI_thread;
+
+/**
+ Instrumented memory key.
+ To instrument memory, a memory key must be obtained using @c register_memory.
+ Using a zero key always disable the instrumentation.
+*/
+typedef unsigned int PSI_memory_key;
+
+#ifdef HAVE_PSI_1
+
+/**
+ @defgroup Group_PSI_v1 Application Binary Interface, version 1
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ Memory instrument information.
+ @since PSI_VERSION_1
+ This structure is used to register instrumented memory.
+*/
+struct PSI_memory_info_v1
+{
+ /** Pointer to the key assigned to the registered memory. */
+ PSI_memory_key *m_key;
+ /** The name of the memory instrument to register. */
+ const char *m_name;
+ /**
+ The flags of the socket instrument to register.
+ @sa PSI_FLAG_GLOBAL
+ */
+ int m_flags;
+};
+typedef struct PSI_memory_info_v1 PSI_memory_info_v1;
+
+/**
+ Memory registration API.
+ @param category a category name (typically a plugin name)
+ @param info an array of memory info to register
+ @param count the size of the info array
+*/
+typedef void (*register_memory_v1_t)
+ (const char *category, struct PSI_memory_info_v1 *info, int count);
+
+/**
+ Instrument memory allocation.
+ @param key the memory instrument key
+ @param size the size of memory allocated
+ @param[out] owner the memory owner
+ @return the effective memory instrument key
+*/
+typedef PSI_memory_key (*memory_alloc_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+
+/**
+ Instrument memory re allocation.
+ @param key the memory instrument key
+ @param old_size the size of memory previously allocated
+ @param new_size the size of memory re allocated
+ @param[in, out] owner the memory owner
+ @return the effective memory instrument key
+*/
+typedef PSI_memory_key (*memory_realloc_v1_t)
+ (PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner);
+
+/**
+ Instrument memory claim.
+ @param key the memory instrument key
+ @param size the size of memory allocated
+ @param[in, out] owner the memory owner
+ @return the effective memory instrument key
+*/
+typedef PSI_memory_key (*memory_claim_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+
+/**
+ Instrument memory free.
+ @param key the memory instrument key
+ @param size the size of memory allocated
+ @param owner the memory owner
+*/
+typedef void (*memory_free_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread * owner);
+
+/** @} (end of group Group_PSI_v1) */
+
+#endif /* HAVE_PSI_1 */
+
+#ifdef HAVE_PSI_2
+struct PSI_memory_info_v2
+{
+ int placeholder;
+};
+
+#endif /* HAVE_PSI_2 */
+
+#ifdef USE_PSI_1
+typedef struct PSI_memory_info_v1 PSI_memory_info;
+#endif
+
+#ifdef USE_PSI_2
+typedef struct PSI_memory_info_v2 PSI_memory_info;
+#endif
+
+/** @} (end of group Instrumentation_interface) */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* MYSQL_PSI_MEMORY_H */
+
diff --git a/include/mysql/service_base64.h b/include/mysql/service_base64.h
index 271cf9d4f44..43b5ba323ba 100644
--- a/include/mysql/service_base64.h
+++ b/include/mysql/service_base64.h
@@ -44,32 +44,32 @@ extern struct base64_service_st {
#ifdef MYSQL_DYNAMIC_PLUGIN
-#define base64_needed_encoded_length(A) base64_service->base64_needed_encoded_length_ptr(A)
-#define base64_encode_max_arg_length() base64_service->base64_encode_max_arg_length_ptr()
-#define base64_needed_decoded_length(A) base64_service->base64_needed_decoded_length_ptr(A)
-#define base64_decode_max_arg_length() base64_service->base64_decode_max_arg_length_ptr()
-#define base64_encode(A,B,C) base64_service->base64_encode_ptr(A,B,C)
-#define base64_decode(A,B,C,D,E) base64_service->base64_decode_ptr(A,B,C,D,E)
+#define my_base64_needed_encoded_length(A) base64_service->base64_needed_encoded_length_ptr(A)
+#define my_base64_encode_max_arg_length() base64_service->base64_encode_max_arg_length_ptr()
+#define my_base64_needed_decoded_length(A) base64_service->base64_needed_decoded_length_ptr(A)
+#define my_base64_decode_max_arg_length() base64_service->base64_decode_max_arg_length_ptr()
+#define my_base64_encode(A,B,C) base64_service->base64_encode_ptr(A,B,C)
+#define my_base64_decode(A,B,C,D,E) base64_service->base64_decode_ptr(A,B,C,D,E)
#else
-/* Calculate how much memory needed for dst of base64_encode() */
-int base64_needed_encoded_length(int length_of_data);
+/* Calculate how much memory needed for dst of my_base64_encode() */
+int my_base64_needed_encoded_length(int length_of_data);
-/* Maximum length base64_encode_needed_length() can accept with no overflow. */
-int base64_encode_max_arg_length(void);
+/* Maximum length my_base64_encode_needed_length() can accept with no overflow. */
+int my_base64_encode_max_arg_length(void);
-/* Calculate how much memory needed for dst of base64_decode() */
-int base64_needed_decoded_length(int length_of_encoded_data);
+/* Calculate how much memory needed for dst of my_base64_decode() */
+int my_base64_needed_decoded_length(int length_of_encoded_data);
-/* Maximum length base64_decode_needed_length() can accept with no overflow. */
-int base64_decode_max_arg_length();
+/* Maximum length my_base64_decode_needed_length() can accept with no overflow. */
+int my_base64_decode_max_arg_length();
-/* Encode data as a base64 string */
-int base64_encode(const void *src, size_t src_len, char *dst);
+/* Encode data as a my_base64 string */
+int my_base64_encode(const void *src, size_t src_len, char *dst);
-/* Decode a base64 string into data */
-int base64_decode(const char *src, size_t src_len,
+/* Decode a my_base64 string into data */
+int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
#endif
diff --git a/include/mysql/service_thd_alloc.h b/include/mysql/service_thd_alloc.h
index 98785b90264..8b3ac707fc1 100644
--- a/include/mysql/service_thd_alloc.h
+++ b/include/mysql/service_thd_alloc.h
@@ -43,13 +43,13 @@ struct st_mysql_lex_string
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(MYSQL_THD, unsigned int);
- void *(*thd_calloc_func)(MYSQL_THD, unsigned int);
+ void *(*thd_alloc_func)(MYSQL_THD, size_t);
+ void *(*thd_calloc_func)(MYSQL_THD, size_t);
char *(*thd_strdup_func)(MYSQL_THD, const char *);
- char *(*thd_strmake_func)(MYSQL_THD, const char *, unsigned int);
- void *(*thd_memdup_func)(MYSQL_THD, const void*, unsigned int);
+ char *(*thd_strmake_func)(MYSQL_THD, const char *, size_t);
+ void *(*thd_memdup_func)(MYSQL_THD, const void*, size_t);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
+ const char *, size_t, int);
} *thd_alloc_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
@@ -84,11 +84,11 @@ extern struct thd_alloc_service_st {
@see alloc_root()
*/
-void *thd_alloc(MYSQL_THD thd, unsigned int size);
+void *thd_alloc(MYSQL_THD thd, size_t size);
/**
@see thd_alloc()
*/
-void *thd_calloc(MYSQL_THD thd, unsigned int size);
+void *thd_calloc(MYSQL_THD thd, size_t size);
/**
@see thd_alloc()
*/
@@ -96,11 +96,11 @@ char *thd_strdup(MYSQL_THD thd, const char *str);
/**
@see thd_alloc()
*/
-char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
+char *thd_strmake(MYSQL_THD thd, const char *str, size_t size);
/**
@see thd_alloc()
*/
-void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
+void *thd_memdup(MYSQL_THD thd, const void* str, size_t size);
/**
Create a LEX_STRING in this connection's local memory pool
@@ -116,7 +116,7 @@ void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
@see thd_alloc()
*/
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string);
#endif
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index 499fbf2c173..3b01d983c06 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -108,10 +108,13 @@ extern struct wsrep_service_st {
long long (*wsrep_thd_trx_seqno_func)(THD *thd);
struct wsrep_ws_handle * (*wsrep_thd_ws_handle_func)(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)();
void (*wsrep_set_data_home_dir_func)(const char *data_dir);
+ my_bool (*wsrep_thd_is_applier_func)(MYSQL_THD);
} *wsrep_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
@@ -151,10 +154,13 @@ extern struct wsrep_service_st {
#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()
@@ -204,6 +210,8 @@ 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);
@@ -214,7 +222,7 @@ void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
bool wsrep_thd_ignore_table(THD *thd);
void wsrep_unlock_rollback();
void wsrep_set_data_home_dir(const char *data_dir);
-
+my_bool wsrep_thd_is_applier(MYSQL_THD thd);
#endif
#ifdef __cplusplus
diff --git a/include/mysql_async.h b/include/mysql_async.h
index 89f263560ac..3e4cb351bb5 100644
--- a/include/mysql_async.h
+++ b/include/mysql_async.h
@@ -21,9 +21,9 @@
extern int my_connect_async(struct mysql_async_context *b, my_socket fd,
const struct sockaddr *name, uint namelen,
int vio_timeout);
-extern ssize_t my_recv_async(struct mysql_async_context *b, int fd,
+extern ssize_t my_recv_async(struct mysql_async_context *b, my_socket fd,
unsigned char *buf, size_t size, int timeout);
-extern ssize_t my_send_async(struct mysql_async_context *b, int fd,
+extern ssize_t my_send_async(struct mysql_async_context *b, my_socket fd,
const unsigned char *buf, size_t size,
int timeout);
extern my_bool my_io_wait_async(struct mysql_async_context *b,
diff --git a/include/mysql_com.h b/include/mysql_com.h
index bdbdc4246ad..a63bcc9d87e 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, 2018, MariaDB
+ Copyright (c) 2010, 2017, 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
@@ -21,10 +21,12 @@
#ifndef _mysql_com_h
#define _mysql_com_h
+#include "my_decimal_limits.h"
+
#define HOSTNAME_LENGTH 60
#define SYSTEM_CHARSET_MBMAXLEN 3
-#define NAME_CHAR_LEN 64 /* Field/table name length */
-#define USERNAME_CHAR_LENGTH 128
+#define NAME_CHAR_LEN 64U /* Field/table name length */
+#define USERNAME_CHAR_LENGTH 128U
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
#define DEFINER_CHAR_LENGTH (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 1)
@@ -71,6 +73,14 @@
#define TABLE_PARTITION_COMMENT_MAXLEN 1024
/*
+ Maximum length of protocol packet.
+ OK packet length limit also restricted to this value as any length greater
+ than this value will have first byte of OK packet to be 254 thus does not
+ provide a means to identify if this is OK or EOF packet.
+*/
+#define MAX_PACKET_LENGTH (256L*256L*256L-1)
+
+/*
USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
username and hostname parts of the user identifier with trailing zero in
MySQL standard format:
@@ -101,12 +111,39 @@ enum enum_server_command
COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
+ COM_UNIMPLEMENTED, /* COM_BINLOG_DUMP_GTID in MySQL */
+ COM_RESET_CONNECTION,
/* don't forget to update const char *command_name[] in sql_parse.cc */
-
+ COM_MDB_GAP_BEG,
+ COM_MDB_GAP_END=249,
+ COM_STMT_BULK_EXECUTE=250,
+ COM_SLAVE_WORKER=251,
+ COM_SLAVE_IO=252,
+ COM_SLAVE_SQL=253,
+ COM_MULTI=254,
/* Must be last */
- COM_END
+ COM_END=255
+};
+
+
+/*
+ Bulk PS protocol indicator value:
+*/
+enum enum_indicator_type
+{
+ STMT_INDICATOR_NONE= 0,
+ STMT_INDICATOR_NULL,
+ STMT_INDICATOR_DEFAULT,
+ STMT_INDICATOR_IGNORE
};
+/*
+ bulk PS flags
+*/
+#define STMT_BULK_FLAG_CLIENT_SEND_TYPES 128
+#define STMT_BULK_FLAG_INSERT_ID_REQUEST 64
+
+
/* sql type stored in .frm files for virtual fields */
#define MYSQL_TYPE_VIRTUAL 245
/*
@@ -120,43 +157,41 @@ enum enum_server_command
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
-#define NOT_NULL_FLAG 1 /* Field can't be NULL */
-#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
-#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
-#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
-#define BLOB_FLAG 16 /* Field is a blob */
-#define UNSIGNED_FLAG 32 /* Field is unsigned */
-#define ZEROFILL_FLAG 64 /* Field is zerofill */
-#define BINARY_FLAG 128 /* Field is binary */
+#define NOT_NULL_FLAG 1U /* Field can't be NULL */
+#define PRI_KEY_FLAG 2U /* Field is part of a primary key */
+#define UNIQUE_KEY_FLAG 4U /* Field is part of a unique key */
+#define MULTIPLE_KEY_FLAG 8U /* Field is part of a key */
+#define BLOB_FLAG 16U /* Field is a blob */
+#define UNSIGNED_FLAG 32U /* Field is unsigned */
+#define ZEROFILL_FLAG 64U /* Field is zerofill */
+#define BINARY_FLAG 128U /* Field is binary */
/* The following are only sent to new clients */
-#define ENUM_FLAG 256 /* field is an enum */
-#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
-#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
-#define SET_FLAG 2048 /* field is a set */
-#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
-#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
-#define NUM_FLAG 32768 /* Field is num (for clients) */
-#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
-#define GROUP_FLAG 32768 /* Intern: Group field */
-#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
-#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
-#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
-#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
+#define ENUM_FLAG 256U /* field is an enum */
+#define AUTO_INCREMENT_FLAG 512U /* field is a autoincrement field */
+#define TIMESTAMP_FLAG 1024U /* Field is a timestamp */
+#define SET_FLAG 2048U /* field is a set */
+#define NO_DEFAULT_VALUE_FLAG 4096U /* Field doesn't have default value */
+#define ON_UPDATE_NOW_FLAG 8192U /* Field is set to NOW on UPDATE */
+#define NUM_FLAG 32768U /* Field is num (for clients) */
+#define PART_KEY_FLAG 16384U /* Intern; Part of some key */
+#define GROUP_FLAG 32768U /* Intern: Group field */
+#define BINCMP_FLAG 131072U /* Intern: Used by sql_yacc */
+#define GET_FIXED_FIELDS_FLAG (1U << 18) /* Used to get fields in item tree */
+#define FIELD_IN_PART_FUNC_FLAG (1U << 19)/* Field part of partition func */
+#define PART_INDIRECT_KEY_FLAG (1U << 20)
/**
Intern: Field in TABLE object for new version of altered table,
which participates in a newly added index.
*/
-#define FIELD_IN_ADD_INDEX (1 << 20)
-#define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
+#define FIELD_IN_ADD_INDEX (1U << 20)
+#define FIELD_IS_RENAMED (1U << 21) /* Intern: Field is being renamed */
#define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23 */
-#define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
+#define FIELD_FLAGS_STORAGE_MEDIA_MASK (3U << FIELD_FLAGS_STORAGE_MEDIA)
#define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25 */
-#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
-#define FIELD_IS_DROPPED (1<< 26) /* Intern: Field is being dropped */
-#define HAS_EXPLICIT_VALUE (1 << 27) /* An INSERT/UPDATE operation supplied
- an explicit default value */
+#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3U << FIELD_FLAGS_COLUMN_FORMAT)
+#define FIELD_IS_DROPPED (1U << 26) /* Intern: Field is being dropped */
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
@@ -189,35 +224,44 @@ enum enum_server_command
#define REFRESH_GENERIC (1ULL << 30)
#define REFRESH_FAST (1ULL << 31) /* Intern flag */
-#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
-#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
-#define CLIENT_LONG_FLAG 4 /* Get all column flags */
-#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
-#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
-#define CLIENT_COMPRESS 32 /* Can use compression protocol */
-#define CLIENT_ODBC 64 /* Odbc client */
-#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
-#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
-#define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
-#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
-#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
-#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
-#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
-#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
-#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
-#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
-#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
-#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
-
-#define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
-#define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */
+#define CLIENT_LONG_PASSWORD 0 /* obsolete flag */
+#define CLIENT_MYSQL 1ULL /* mysql/old mariadb server/client */
+#define CLIENT_FOUND_ROWS 2ULL /* Found instead of affected rows */
+#define CLIENT_LONG_FLAG 4ULL /* Get all column flags */
+#define CLIENT_CONNECT_WITH_DB 8ULL /* One can specify db on connect */
+#define CLIENT_NO_SCHEMA 16ULL /* Don't allow database.table.column */
+#define CLIENT_COMPRESS 32ULL /* Can use compression protocol */
+#define CLIENT_ODBC 64ULL /* Odbc client */
+#define CLIENT_LOCAL_FILES 128ULL /* Can use LOAD DATA LOCAL */
+#define CLIENT_IGNORE_SPACE 256ULL /* Ignore spaces before '(' */
+#define CLIENT_PROTOCOL_41 512ULL /* New 4.1 protocol */
+#define CLIENT_INTERACTIVE 1024ULL /* This is an interactive client */
+#define CLIENT_SSL 2048ULL /* Switch to SSL after handshake */
+#define CLIENT_IGNORE_SIGPIPE 4096ULL /* IGNORE sigpipes */
+#define CLIENT_TRANSACTIONS 8192ULL /* Client knows about transactions */
+#define CLIENT_RESERVED 16384ULL /* Old flag for 4.1 protocol */
+#define CLIENT_SECURE_CONNECTION 32768ULL /* New 4.1 authentication */
+#define CLIENT_MULTI_STATEMENTS (1ULL << 16) /* Enable/disable multi-stmt support */
+#define CLIENT_MULTI_RESULTS (1ULL << 17) /* Enable/disable multi-results */
+#define CLIENT_PS_MULTI_RESULTS (1ULL << 18) /* Multi-results in PS-protocol */
+
+#define CLIENT_PLUGIN_AUTH (1ULL << 19) /* Client supports plugin authentication */
+#define CLIENT_CONNECT_ATTRS (1ULL << 20) /* Client supports connection attributes */
/* Enable authentication response packet to be larger than 255 bytes. */
-#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
+#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1ULL << 21)
/* Don't close the connection for a connection with expired password. */
-#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
+#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1ULL << 22)
+
+/**
+ Capable of handling server state change information. Its a hint to the
+ server to include the state change information in Ok packet.
+*/
+#define CLIENT_SESSION_TRACK (1ULL << 23)
+/* Client no longer needs EOF packet */
+#define CLIENT_DEPRECATE_EOF (1ULL << 24)
-#define CLIENT_PROGRESS (1UL << 29) /* Client support progress indicator */
-#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
+#define CLIENT_PROGRESS_OBSOLETE (1ULL << 29)
+#define CLIENT_SSL_VERIFY_SERVER_CERT (1ULL << 30)
/*
It used to be that if mysql_real_connect() failed, it would delete any
options set by the client, unless the CLIENT_REMEMBER_OPTIONS flag was
@@ -227,7 +271,16 @@ enum enum_server_command
always preserve any options set in case of failed connect, and this
option is effectively always set.
*/
-#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
+#define CLIENT_REMEMBER_OPTIONS (1ULL << 31)
+
+/* MariaDB extended capability flags */
+#define MARIADB_CLIENT_FLAGS_MASK 0xffffffff00000000ULL
+/* Client support progress indicator */
+#define MARIADB_CLIENT_PROGRESS (1ULL << 32)
+/* support COM_MULTI */
+#define MARIADB_CLIENT_COM_MULTI (1ULL << 33)
+/* support of array binding */
+#define MARIADB_CLIENT_STMT_BULK_OPERATIONS (1ULL << 34)
#ifdef HAVE_COMPRESS
#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
@@ -235,8 +288,12 @@ enum enum_server_command
#define CAN_CLIENT_COMPRESS 0
#endif
-/* Gather all possible capabilites (flags) supported by the server */
-#define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \
+/*
+ Gather all possible capabilites (flags) supported by the server
+
+ MARIADB_* flags supported only by MariaDB connector(s).
+*/
+#define CLIENT_ALL_FLAGS (\
CLIENT_FOUND_ROWS | \
CLIENT_LONG_FLAG | \
CLIENT_CONNECT_WITH_DB | \
@@ -257,10 +314,14 @@ enum enum_server_command
CLIENT_PS_MULTI_RESULTS | \
CLIENT_SSL_VERIFY_SERVER_CERT | \
CLIENT_REMEMBER_OPTIONS | \
- CLIENT_PROGRESS | \
+ MARIADB_CLIENT_PROGRESS | \
CLIENT_PLUGIN_AUTH | \
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
- CLIENT_CONNECT_ATTRS)
+ CLIENT_SESSION_TRACK |\
+ CLIENT_DEPRECATE_EOF |\
+ CLIENT_CONNECT_ATTRS |\
+ MARIADB_CLIENT_COM_MULTI |\
+ MARIADB_CLIENT_STMT_BULK_OPERATIONS)
/*
To be added later:
@@ -283,36 +344,36 @@ enum enum_server_command
implicitly, by the first transactional
statement, when autocommit=off.
*/
-#define SERVER_STATUS_IN_TRANS 1
-#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
-#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
-#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
-#define SERVER_QUERY_NO_INDEX_USED 32
+#define SERVER_STATUS_IN_TRANS 1U
+#define SERVER_STATUS_AUTOCOMMIT 2U /* Server in auto_commit mode */
+#define SERVER_MORE_RESULTS_EXISTS 8U /* Multi query - next query exists */
+#define SERVER_QUERY_NO_GOOD_INDEX_USED 16U
+#define SERVER_QUERY_NO_INDEX_USED 32U
/**
The server was able to fulfill the clients request and opened a
read-only non-scrollable cursor for a query. This flag comes
in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
*/
-#define SERVER_STATUS_CURSOR_EXISTS 64
+#define SERVER_STATUS_CURSOR_EXISTS 64U
/**
This flag is sent when a read-only cursor is exhausted, in reply to
COM_STMT_FETCH command.
*/
-#define SERVER_STATUS_LAST_ROW_SENT 128
-#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
-#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
+#define SERVER_STATUS_LAST_ROW_SENT 128U
+#define SERVER_STATUS_DB_DROPPED 256U /* A database was dropped */
+#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512U
/**
Sent to the client if after a prepared statement reprepare
we discovered that the new statement returns a different
number of result set columns.
*/
-#define SERVER_STATUS_METADATA_CHANGED 1024
-#define SERVER_QUERY_WAS_SLOW 2048
+#define SERVER_STATUS_METADATA_CHANGED 1024U
+#define SERVER_QUERY_WAS_SLOW 2048U
/**
To mark ResultSet containing output parameter values.
*/
-#define SERVER_PS_OUT_PARAMS 4096
+#define SERVER_PS_OUT_PARAMS 4096U
/**
Set at the same time as SERVER_STATUS_IN_TRANS if the started
@@ -321,10 +382,15 @@ enum enum_server_command
to clients in OK and EOF packets, the flag indicates the
transaction status at the end of command execution.
*/
-#define SERVER_STATUS_IN_TRANS_READONLY 8192
+#define SERVER_STATUS_IN_TRANS_READONLY 8192U
-#define SERVER_STATUS_ANSI_QUOTES 32768
+/**
+ This status flag, when on, implies that one of the state information has
+ changed on the server because of the execution of the last statement.
+*/
+#define SERVER_SESSION_STATE_CHANGED 16384U
+#define SERVER_STATUS_ANSI_QUOTES 32768U
/**
Server status flags that must be cleared when starting
@@ -341,7 +407,8 @@ enum enum_server_command
SERVER_QUERY_WAS_SLOW |\
SERVER_STATUS_DB_DROPPED |\
SERVER_STATUS_CURSOR_EXISTS|\
- SERVER_STATUS_LAST_ROW_SENT)
+ SERVER_STATUS_LAST_ROW_SENT|\
+ SERVER_SESSION_STATE_CHANGED)
#define MYSQL_ERRMSG_SIZE 512
#define NET_READ_TIMEOUT 30 /* Timeout on read */
@@ -399,7 +466,7 @@ typedef struct st_net {
} NET;
-#define packet_error (~(unsigned long) 0)
+#define packet_error ~0UL
enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
@@ -508,6 +575,26 @@ enum enum_mysql_set_option
MYSQL_OPTION_MULTI_STATEMENTS_OFF
};
+/*
+ Type of state change information that the server can include in the Ok
+ packet.
+*/
+enum enum_session_state_type
+{
+ SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
+ SESSION_TRACK_SCHEMA, /* Current schema */
+ SESSION_TRACK_STATE_CHANGE, /* track session state changes */
+ SESSION_TRACK_GTIDS,
+ SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /* Transaction chistics */
+ SESSION_TRACK_TRANSACTION_STATE, /* Transaction state */
+ SESSION_TRACK_always_at_the_end /* must be last */
+};
+
+#define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES
+
+#define IS_SESSION_STATE_TYPE(T) \
+ (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) < SESSION_TRACK_always_at_the_end))
+
#define net_new_transaction(net) ((net)->pkt_nr=0)
#ifdef __cplusplus
@@ -526,6 +613,8 @@ my_bool net_write_command(NET *net,unsigned char command,
const unsigned char *packet, size_t len);
int net_real_write(NET *net,const unsigned char *packet, size_t len);
unsigned long my_net_read_packet(NET *net, my_bool read_from_server);
+unsigned long my_net_read_packet_reallen(NET *net, my_bool read_from_server,
+ unsigned long* reallen);
#define my_net_read(A) my_net_read_packet((A), 0)
#ifdef MY_GLOBAL_INCLUDED
@@ -621,20 +710,22 @@ my_bool my_thread_init(void);
void my_thread_end(void);
#ifdef MY_GLOBAL_INCLUDED
-ulong STDCALL net_field_length(uchar **packet);
-my_ulonglong net_field_length_ll(uchar **packet);
-my_ulonglong safe_net_field_length_ll(uchar **packet, size_t packet_len);
-uchar *net_store_length(uchar *pkg, ulonglong length);
-uchar *safe_net_store_length(uchar *pkg, size_t pkg_len, ulonglong length);
+#include "pack.h"
#endif
#ifdef __cplusplus
}
#endif
-#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
-#define MYSQL_STMT_HEADER 4
-#define MYSQL_LONG_DATA_HEADER 6
+#define NULL_LENGTH ~0UL /* For net_store_length */
+#define MYSQL_STMT_HEADER 4U
+#define MYSQL_LONG_DATA_HEADER 6U
+
+/*
+ If a float or double field have more than this number of decimals,
+ it's regarded as floating point field without any specific number of
+ decimals
+*/
+
-#define NOT_FIXED_DEC 31
#endif
diff --git a/include/pack.h b/include/pack.h
new file mode 100644
index 00000000000..f991e72326b
--- /dev/null
+++ b/include/pack.h
@@ -0,0 +1,29 @@
+/* Copyright (c) 2016, MariaDB
+
+ 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 */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ulong net_field_length(uchar **packet);
+my_ulonglong net_field_length_ll(uchar **packet);
+my_ulonglong safe_net_field_length_ll(uchar **packet, size_t packet_len);
+uchar *net_store_length(uchar *pkg, ulonglong length);
+uchar *safe_net_store_length(uchar *pkg, size_t pkg_len, ulonglong length);
+unsigned int net_length_size(ulonglong num);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/include/service_versions.h b/include/service_versions.h
index a614cd715fc..6e138fab5a4 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -34,7 +34,7 @@
#define VERSION_my_sha2 0x0100
#define VERSION_my_snprintf 0x0100
#define VERSION_progress_report 0x0100
-#define VERSION_thd_alloc 0x0100
+#define VERSION_thd_alloc 0x0200
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0200
#define VERSION_thd_rnd 0x0100
diff --git a/include/sql_common.h b/include/sql_common.h
index c30ca4b1031..9836d0c1cdc 100644
--- a/include/sql_common.h
+++ b/include/sql_common.h
@@ -77,9 +77,13 @@ typedef struct st_mysql_methods
#endif
} MYSQL_METHODS;
+#ifdef LIBMARIADB
+#define simple_command(mysql, command, arg, length, skip_check) ma_simple_command(mysql, command, (char *)arg, length, skip_check, NULL)
+#else
#define simple_command(mysql, command, arg, length, skip_check) \
(*(mysql)->methods->advanced_command)(mysql, command, 0, \
0, arg, length, skip_check, NULL)
+#endif
#define stmt_command(mysql, command, arg, length, stmt) \
(*(mysql)->methods->advanced_command)(mysql, command, 0, \
0, arg, length, 1, stmt)
@@ -100,6 +104,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const unsigned char *arg, ulong arg_length,
my_bool skip_check, MYSQL_STMT *stmt);
unsigned long cli_safe_read(MYSQL *mysql);
+unsigned long cli_safe_read_reallen(MYSQL *mysql, ulong* reallen);
void net_clear_error(NET *net);
void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net);
void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate,
@@ -109,8 +114,9 @@ void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate,
const char *format, ...);
/* client side of the pluggable authentication */
+struct st_vio;
struct st_plugin_vio_info;
-void mpvio_info(Vio *vio, struct st_plugin_vio_info *info);
+void mpvio_info(struct st_vio *vio, struct st_plugin_vio_info *info);
int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
const char *data_plugin, const char *db);
int mysql_client_plugin_init();
diff --git a/include/ssl_compat.h b/include/ssl_compat.h
new file mode 100644
index 00000000000..2777ae94527
--- /dev/null
+++ b/include/ssl_compat.h
@@ -0,0 +1,92 @@
+/*
+ Copyright (c) 2016, 2017 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 St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#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 OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
+#define HAVE_OPENSSL11 1
+#define SSL_LIBRARY OpenSSL_version(OPENSSL_VERSION)
+#define ERR_remove_state(X) ERR_clear_error()
+#define EVP_CIPHER_CTX_SIZE 176
+#define EVP_MD_CTX_SIZE 48
+#undef EVP_MD_CTX_init
+#define EVP_MD_CTX_init(X) do { bzero((X), EVP_MD_CTX_SIZE); EVP_MD_CTX_reset(X); } while(0)
+#undef EVP_CIPHER_CTX_init
+#define EVP_CIPHER_CTX_init(X) do { bzero((X), EVP_CIPHER_CTX_SIZE); EVP_CIPHER_CTX_reset(X); } while(0)
+
+/*
+ Macros below are deprecated. OpenSSL 1.1 may define them or not,
+ depending on how it was built.
+*/
+#undef ERR_free_strings
+#define ERR_free_strings()
+#undef EVP_cleanup
+#define EVP_cleanup()
+#undef CRYPTO_cleanup_all_ex_data
+#define CRYPTO_cleanup_all_ex_data()
+#undef SSL_load_error_strings
+#define SSL_load_error_strings()
+
+#else
+#define HAVE_OPENSSL10 1
+#define SSL_LIBRARY SSLeay_version(SSLEAY_VERSION)
+
+#ifdef HAVE_ERR_remove_thread_state
+#define ERR_remove_state(X) ERR_remove_thread_state(NULL)
+#endif /* HAVE_ERR_remove_thread_state */
+
+#endif /* HAVE_OPENSSL11 */
+
+#elif defined(HAVE_YASSL)
+#define SSL_LIBRARY "YaSSL " YASSL_VERSION
+#define BN_free(X) do { } while(0)
+#endif /* !defined(HAVE_YASSL) */
+
+#ifndef HAVE_OPENSSL11
+#define ASN1_STRING_get0_data(X) ASN1_STRING_data(X)
+#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)
+#define X509_get0_notBefore(X) X509_get_notBefore(X)
+#define X509_get0_notAfter(X) X509_get_notAfter(X)
+#endif
+
+#ifndef TLS1_3_VERSION
+#define SSL_CTX_set_ciphersuites(X,Y) 0
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+int check_openssl_compatibility();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/include/thr_lock.h b/include/thr_lock.h
index f596e0fa437..35db9ef981b 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 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
@@ -76,10 +77,10 @@ enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
/* Priority for locks */
-#define THR_LOCK_LATE_PRIV 1 /* For locks to be merged with org lock */
-#define THR_LOCK_MERGE_PRIV 2 /* For merge tables */
+#define THR_LOCK_LATE_PRIV 1U /* For locks to be merged with org lock */
+#define THR_LOCK_MERGE_PRIV 2U /* For merge tables */
-#define THR_UNLOCK_UPDATE_STATUS 1
+#define THR_UNLOCK_UPDATE_STATUS 1U
extern ulong max_write_lock_count;
extern my_bool thr_lock_inited;
@@ -139,9 +140,10 @@ typedef struct st_thr_lock {
extern LIST *thr_lock_thread_list;
extern mysql_mutex_t THR_LOCK_lock;
+struct st_my_thread_var;
my_bool init_thr_lock(void); /* Must be called once/thread */
-void thr_lock_info_init(THR_LOCK_INFO *info);
+void thr_lock_info_init(THR_LOCK_INFO *info, struct st_my_thread_var *tmp);
void thr_lock_init(THR_LOCK *lock);
void thr_lock_delete(THR_LOCK *lock);
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h
index d8cdc58f0f6..f27391adbfa 100644
--- a/include/thread_pool_priv.h
+++ b/include/thread_pool_priv.h
@@ -98,10 +98,6 @@ void mysql_audit_release(THD *thd);
bool thd_is_connection_alive(THD *thd);
/* Close connection with possible error code */
void close_connection(THD *thd, uint errcode);
-/* End the connection before closing it */
-void end_connection(THD *thd);
-/* Cleanup the THD object */
-void thd_cleanup(THD *thd);
/* Decrement connection counter */
void dec_connection_count();
/* Destroy THD object */
diff --git a/include/typelib.h b/include/typelib.h
index 8cfb5c6bea8..530767ebe01 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 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
@@ -31,13 +32,13 @@ extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option);
#define FIND_TYPE_BASIC 0
/** makes @c find_type() require the whole name, no prefix */
-#define FIND_TYPE_NO_PREFIX (1 << 0)
+#define FIND_TYPE_NO_PREFIX (1U << 0)
/** always implicitely on, so unused, but old code may pass it */
#define FIND_TYPE_NO_OVERWRITE 0
/** makes @c find_type() accept a number. Not used either */
#define FIND_TYPE_ALLOW_NUMBER 0
/** makes @c find_type() treat ',' and '=' as terminators */
-#define FIND_TYPE_COMMA_TERM (1 << 3)
+#define FIND_TYPE_COMMA_TERM (1U << 3)
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
diff --git a/include/violite.h b/include/violite.h
index 589350a826d..45273ac5f24 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2012 Monty Program Ab
+ Copyright (c) 2012, 2017, 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
@@ -51,9 +51,9 @@ enum enum_vio_io_event
VIO_IO_EVENT_CONNECT
};
-#define VIO_LOCALHOST 1 /* a localhost connection */
-#define VIO_BUFFERED_READ 2 /* use buffered read */
-#define VIO_READ_BUFFER_SIZE 16384 /* size of read buffer */
+#define VIO_LOCALHOST 1U /* a localhost connection */
+#define VIO_BUFFERED_READ 2U /* use buffered read */
+#define VIO_READ_BUFFER_SIZE 16384U /* size of read buffer */
#define VIO_DESCRIPTION_SIZE 30 /* size of description */
Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags);
@@ -123,13 +123,6 @@ int vio_getnameinfo(const struct sockaddr *sa,
int flags);
#ifdef HAVE_OPENSSL
-#include <openssl/opensslv.h>
-#if OPENSSL_VERSION_NUMBER < 0x0090700f
-#define DES_cblock des_cblock
-#define DES_key_schedule des_key_schedule
-#define DES_set_key_unchecked(k,ks) des_set_key_unchecked((k),*(ks))
-#define DES_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e) des_ede3_cbc_encrypt((i),(o),(l),*(k1),*(k2),*(k3),(iv),(e))
-#endif
/* apple deprecated openssl in MacOSX Lion */
#ifdef __APPLE__
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -146,14 +139,10 @@ typedef my_socket YASSL_SOCKET_T;
#include <openssl/ssl.h>
#include <openssl/err.h>
-#ifdef HAVE_ERR_remove_thread_state
-#define ERR_remove_state(X) ERR_remove_thread_state(NULL)
-#endif
-
enum enum_ssl_init_error
{
- SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY,
- SSL_INITERR_NOMATCH, SSL_INITERR_BAD_PATHS, SSL_INITERR_CIPHERS,
+ SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY,
+ SSL_INITERR_NOMATCH, SSL_INITERR_BAD_PATHS, SSL_INITERR_CIPHERS,
SSL_INITERR_MEMFAIL, SSL_INITERR_DH, SSL_INITERR_LASTERR
};
const char* sslGetErrString(enum enum_ssl_init_error err);
@@ -211,14 +200,6 @@ void vio_end(void);
#define SHUT_RD SD_RECEIVE
#endif
-/*
- Set thread id for io cancellation (required on Windows XP only,
- and should to be removed if XP is no more supported)
-*/
-
-#define vio_set_thread_id(vio, tid) if(vio) vio->thread_id= tid
-#else
-#define vio_set_thread_id(vio, tid)
#endif
/* This enumerator is used in parser - should be always visible */
@@ -288,7 +269,6 @@ struct st_vio
#ifdef _WIN32
HANDLE hPipe;
OVERLAPPED overlapped;
- DWORD thread_id; /* Used on XP only by vio_shutdown() */
DWORD read_timeout_ms;
DWORD write_timeout_ms;
#endif