summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
-rw-r--r--VERSION2
-rw-r--r--client/mysqladmin.cc11
-rw-r--r--client/mysqlcheck.c34
-rw-r--r--client/mysqldump.c45
-rw-r--r--client/mysqlshow.c42
-rw-r--r--client/mysqltest.cc5
-rw-r--r--extra/mysql_waitpid.c7
-rw-r--r--extra/yassl/src/log.cpp3
-rw-r--r--include/CMakeLists.txt6
-rw-r--r--include/my_tree.h2
-rw-r--r--include/myisam.h3
-rw-r--r--include/violite.h2
-rw-r--r--libmysqld/CMakeLists.txt10
-rw-r--r--mysql-test/include/search_pattern_in_file.inc17
-rwxr-xr-xmysql-test/mysql-test-run.pl5
-rw-r--r--mysql-test/r/bigint.result6
-rw-r--r--mysql-test/r/ctype_recoding.result33
-rw-r--r--mysql-test/r/ctype_utf8.result39
-rw-r--r--mysql-test/r/ctype_utf8mb4.result34
-rw-r--r--mysql-test/r/fulltext3.result12
-rw-r--r--mysql-test/r/insert_innodb.result15
-rw-r--r--mysql-test/r/kill_processlist-6619.result4
-rw-r--r--mysql-test/r/locale.result28
-rw-r--r--mysql-test/r/openssl_1.result2
-rw-r--r--mysql-test/r/parser.result20
-rw-r--r--mysql-test/r/sp-threads.result9
-rw-r--r--mysql-test/r/ssl_ca.result24
-rw-r--r--mysql-test/r/type_date.result7
-rw-r--r--mysql-test/r/wait_timeout_not_windows.result3
-rw-r--r--mysql-test/suite/binlog/t/binlog_mdev342.test3
-rw-r--r--mysql-test/suite/innodb/r/innodb-fk.result44
-rw-r--r--mysql-test/suite/innodb/r/innodb_corrupt_bit.result90
-rw-r--r--mysql-test/suite/innodb/t/innodb-fk.test41
-rw-r--r--mysql-test/suite/innodb/t/innodb_corrupt_bit.test84
-rw-r--r--mysql-test/suite/plugins/r/server_audit.result2
-rw-r--r--mysql-test/suite/plugins/r/thread_pool_server_audit.result2
-rw-r--r--mysql-test/suite/rpl/t/rpl_mdev382.test3
-rw-r--r--mysql-test/suite/storage_engine/alter_tablespace.test3
-rw-r--r--mysql-test/t/bigint.test5
-rw-r--r--mysql-test/t/ctype_recoding.test28
-rw-r--r--mysql-test/t/ctype_utf8.test23
-rw-r--r--mysql-test/t/ctype_utf8mb4.test20
-rw-r--r--mysql-test/t/fulltext3.test15
-rw-r--r--mysql-test/t/insert_innodb.test21
-rw-r--r--mysql-test/t/kill_processlist-6619.test2
-rw-r--r--mysql-test/t/locale.test19
-rw-r--r--mysql-test/t/openssl_1.test1
-rw-r--r--mysql-test/t/parser.test12
-rw-r--r--mysql-test/t/partition_innodb_plugin.test6
-rw-r--r--mysql-test/t/sp-threads.test9
-rw-r--r--mysql-test/t/ssl_ca.test36
-rw-r--r--mysql-test/t/type_date.test1
-rw-r--r--mysql-test/t/wait_timeout_not_windows.test16
-rw-r--r--mysql-test/valgrind.supp89
-rw-r--r--mysys/errors.c4
-rw-r--r--mysys/mf_iocache.c1
-rw-r--r--mysys/my_context.c4
-rw-r--r--mysys/my_write.c3
-rw-r--r--mysys/testhash.c4
-rw-r--r--mysys/tree.c3
-rw-r--r--regex/split.c4
-rw-r--r--scripts/mysqld_multi.sh8
-rw-r--r--sql-common/client.c22
-rw-r--r--sql/field.cc1
-rw-r--r--sql/field.h28
-rw-r--r--sql/gen_lex_hash.cc2
-rw-r--r--sql/item.cc17
-rw-r--r--sql/item_cmpfunc.cc11
-rw-r--r--sql/item_func.cc7
-rw-r--r--sql/item_geofunc.cc5
-rw-r--r--sql/item_timefunc.cc6
-rw-r--r--sql/lex.h3
-rw-r--r--sql/log.cc2
-rw-r--r--sql/log.h4
-rw-r--r--sql/log_event.cc46
-rw-r--r--sql/log_event_old.cc52
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/slave.h4
-rw-r--r--sql/sp_head.cc10
-rw-r--r--sql/sql_connect.cc3
-rw-r--r--sql/sql_lex.cc29
-rw-r--r--sql/sql_locale.h2
-rw-r--r--sql/sql_parse.cc30
-rw-r--r--sql/sql_parse.h3
-rw-r--r--sql/sql_reload.cc3
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_yacc.yy77
-rw-r--r--sql/threadpool_unix.cc6
-rw-r--r--storage/innobase/handler/ha_innodb.cc40
-rw-r--r--storage/innobase/handler/handler0alter.cc35
-rw-r--r--storage/maria/ma_checkpoint.c18
-rw-r--r--storage/maria/ma_loghandler.c11
-rw-r--r--storage/maria/ma_pagecache.c34
-rw-r--r--storage/maria/ma_pagecache.h38
-rw-r--r--storage/maria/ma_servicethread.c51
-rw-r--r--storage/maria/ma_servicethread.h7
-rw-r--r--storage/maria/ma_sort.c346
-rw-r--r--storage/maria/maria_def.h3
-rw-r--r--storage/myisam/sort.c367
-rw-r--r--storage/tokudb/ft-index/ft/logger/recover.cc6
-rw-r--r--storage/tokudb/ft-index/ft/serialize/ft_node-serialize.cc2
-rw-r--r--storage/tokudb/ft-index/ft/txn/txn.cc8
-rw-r--r--storage/tokudb/ft-index/portability/toku_pthread.h19
-rw-r--r--storage/tokudb/ft-index/src/tests/threaded_stress_test_helpers.h2
-rw-r--r--storage/xtradb/dict/dict0crea.c4
-rw-r--r--storage/xtradb/handler/ha_innodb.cc40
-rw-r--r--storage/xtradb/handler/handler0alter.cc35
-rw-r--r--storage/xtradb/include/os0sync.h47
-rw-r--r--storage/xtradb/include/univ.i4
-rw-r--r--storage/xtradb/log/log0recv.c4
-rw-r--r--storage/xtradb/os/os0file.c48
-rw-r--r--vio/viosslfactories.c6
-rw-r--r--win/packaging/extra.wxs.in18
-rw-r--r--win/packaging/heidisql.cmake2
116 files changed, 1645 insertions, 977 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8cdced71bcf..4a3eba3d2b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -255,8 +255,10 @@ IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)
ENDIF()
MY_CHECK_C_COMPILER_FLAG(-ggdb3 HAVE_GGDB3)
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3")
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
+IF(HAVE_GGDB3)
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
+ENDIF()
OPTION(ENABLED_LOCAL_INFILE
"If we should should enable LOAD DATA LOCAL by default" ${IF_WIN})
diff --git a/VERSION b/VERSION
index ba54e70bc3e..58a6b369de9 100644
--- a/VERSION
+++ b/VERSION
@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
-MYSQL_VERSION_PATCH=49
+MYSQL_VERSION_PATCH=50
MYSQL_VERSION_EXTRA=
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 9fd8a9b36fc..e7c6410978d 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -232,8 +232,6 @@ my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
- int error = 0;
-
switch(optid) {
case 'c':
opt_count_iterations= 1;
@@ -281,8 +279,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case '?':
case 'I': /* Info */
- error++;
- break;
+ usage();
+ exit(0);
case OPT_CHARSETS_DIR:
#if MYSQL_VERSION_ID > 32300
charsets_dir = argument;
@@ -293,11 +291,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt->name);
break;
}
- if (error)
- {
- usage();
- exit(1);
- }
return 0;
}
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 45e2451bb8c..5cdcd960b08 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -238,7 +238,7 @@ static void dbDisconnect(char *host);
static void DBerror(MYSQL *mysql, const char *when);
static void safe_exit(int error);
static void print_result();
-static uint fixed_name_length(const char *name);
+static size_t fixed_name_length(const char *name);
static char *fix_table_name(char *dest, char *src);
int what_to_do = 0;
@@ -583,10 +583,10 @@ static int process_selected_tables(char *db, char **table_names, int tables)
} /* process_selected_tables */
-static uint fixed_name_length(const char *name)
+static size_t fixed_name_length(const char *name)
{
const char *p;
- uint extra_length= 2; /* count the first/last backticks */
+ size_t extra_length= 2; /* count the first/last backticks */
DBUG_ENTER("fixed_name_length");
for (p= name; *p; p++)
@@ -594,7 +594,7 @@ static uint fixed_name_length(const char *name)
if (*p == '`')
extra_length++;
}
- DBUG_RETURN((uint) ((p - name) + extra_length));
+ DBUG_RETURN((size_t) ((p - name) + extra_length));
}
@@ -653,7 +653,7 @@ static int process_all_tables_in_db(char *database)
*/
char *tables, *end;
- uint tot_length = 0;
+ size_t tot_length = 0;
char *views, *views_end;
uint tot_views_length = 0;
@@ -756,7 +756,9 @@ static int fix_table_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
- sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
+ my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE `%s` TO `%s`",
+ name, name + 9);
+
rc= run_query(qbuf);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -771,7 +773,8 @@ static int fix_database_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
- sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
+ my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY "
+ "NAME", name);
rc= run_query(qbuf);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -791,7 +794,7 @@ static int rebuild_table(char *name)
ptr= strmov(query, "ALTER TABLE ");
ptr= fix_table_name(ptr, name);
ptr= strxmov(ptr, " FORCE", NullS);
- if (mysql_real_query(sock, query, (uint)(ptr - query)))
+ if (mysql_real_query(sock, query, (ulong)(ptr - query)))
{
fprintf(stderr, "Failed to %s\n", query);
fprintf(stderr, "Error: %s\n", mysql_error(sock));
@@ -856,7 +859,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
{
char *query, *end, options[100], message[100];
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
- uint query_length= 0;
+ size_t query_length= 0, query_size= sizeof(char)*(length+110);
const char *op = 0;
const char *tab_view;
DBUG_ENTER("handle_request_for_tables");
@@ -908,10 +911,12 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
DBUG_RETURN(fix_table_storage_name(tables));
}
- if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
+ if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
DBUG_RETURN(1);
if (opt_all_in_1)
{
+ DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
+
/* No backticks here as we added them before */
query_length= sprintf(query, "%s%s%s %s", op,
tab_view, tables, options);
@@ -927,7 +932,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
(int) (ptr - org)));
table_name= table_name_buff;
ptr= strxmov(ptr, " ", options, NullS);
- query_length= (uint) (ptr - query);
+ query_length= (size_t) (ptr - query);
}
if (mysql_real_query(sock, query, query_length))
{
@@ -1046,7 +1051,10 @@ static void print_result()
prev_alter[0]= 0;
}
else
- strcpy(prev_alter, alter_txt);
+ {
+ strncpy(prev_alter, alter_txt, MAX_ALTER_STR_SIZE-1);
+ prev_alter[MAX_ALTER_STR_SIZE-1]= 0;
+ }
}
}
}
@@ -1199,7 +1207,7 @@ int main(int argc, char **argv)
process_databases(argv);
if (opt_auto_repair)
{
- uint i;
+ size_t i;
if (!opt_silent && (tables4repair.elements || tables4rebuild.elements))
puts("\nRepairing tables");
diff --git a/client/mysqldump.c b/client/mysqldump.c
index ecb4ed04271..16b39b77cf1 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -89,7 +89,7 @@
static void add_load_option(DYNAMIC_STRING *str, const char *option,
const char *option_value);
-static ulong find_set(TYPELIB *lib, const char *x, uint length,
+static ulong find_set(TYPELIB *lib, const char *x, size_t length,
char **err_pos, uint *err_len);
static char *alloc_query_str(ulong size);
@@ -862,7 +862,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_set_charset= 0;
opt_compatible_mode_str= argument;
opt_compatible_mode= find_set(&compatible_mode_typelib,
- argument, (uint) strlen(argument),
+ argument, strlen(argument),
&err_ptr, &err_len);
if (err_len)
{
@@ -872,7 +872,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
#if !defined(DBUG_OFF)
{
- uint size_for_sql_mode= 0;
+ size_t size_for_sql_mode= 0;
const char **ptr;
for (ptr= compatible_mode_names; *ptr; ptr++)
size_for_sql_mode+= strlen(*ptr);
@@ -1143,8 +1143,8 @@ static int fetch_db_collation(const char *db_name,
break;
}
- strncpy(db_cl_name, db_cl_row[0], db_cl_size);
- db_cl_name[db_cl_size - 1]= 0; /* just in case. */
+ strncpy(db_cl_name, db_cl_row[0], db_cl_size-1);
+ db_cl_name[db_cl_size - 1]= 0;
} while (FALSE);
@@ -1193,7 +1193,7 @@ check_consistent_binlog_pos(char *binlog_pos_file, char *binlog_pos_offset)
}
static char *my_case_str(const char *str,
- uint str_len,
+ size_t str_len,
const char *token,
uint token_len)
{
@@ -1409,7 +1409,7 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name)
*/
static char *cover_definer_clause(const char *stmt_str,
- uint stmt_length,
+ size_t stmt_length,
const char *definer_version_str,
uint definer_version_length,
const char *stmt_version_str,
@@ -1591,14 +1591,14 @@ static void dbDisconnect(char *host)
} /* dbDisconnect */
-static void unescape(FILE *file,char *pos,uint length)
+static void unescape(FILE *file,char *pos, size_t length)
{
char *tmp;
DBUG_ENTER("unescape");
if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME))))
die(EX_MYSQLERR, "Couldn't allocate memory");
- mysql_real_escape_string(&mysql_connection, tmp, pos, length);
+ mysql_real_escape_string(&mysql_connection, tmp, pos, (ulong)length);
fputc('\'', file);
fputs(tmp, file);
fputc('\'', file);
@@ -1712,7 +1712,7 @@ static char *quote_for_like(const char *name, char *buff)
Quote '<' '>' '&' '\"' chars and print a string to the xml_file.
*/
-static void print_quoted_xml(FILE *xml_file, const char *str, ulong len,
+static void print_quoted_xml(FILE *xml_file, const char *str, size_t len,
my_bool is_attribute_name)
{
const char *end;
@@ -1973,7 +1973,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
squeezed to a single hyphen.
*/
-static void print_xml_comment(FILE *xml_file, ulong len,
+static void print_xml_comment(FILE *xml_file, size_t len,
const char *comment_string)
{
const char* end;
@@ -2090,7 +2090,7 @@ static uint dump_events_for_db(char *db)
DBUG_ENTER("dump_events_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
- mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
+ mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db));
/* nice comments */
print_comment(sql_file, 0,
@@ -2209,6 +2209,7 @@ static uint dump_events_for_db(char *db)
(const char *) (query_str != NULL ? query_str : row[3]),
(const char *) delimiter);
+ my_free(query_str);
restore_time_zone(sql_file, delimiter);
restore_sql_mode(sql_file, delimiter);
@@ -2302,7 +2303,7 @@ static uint dump_routines_for_db(char *db)
DBUG_ENTER("dump_routines_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
- mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
+ mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db));
/* nice comments */
print_comment(sql_file, 0,
@@ -2356,9 +2357,9 @@ static uint dump_routines_for_db(char *db)
if the user has EXECUTE privilege he see routine names, but NOT the
routine body of other routines that are not the creator of!
*/
- DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
+ DBUG_PRINT("info",("length of body for %s row[2] '%s' is %zu",
routine_name, row[2] ? row[2] : "(null)",
- row[2] ? (int) strlen(row[2]) : 0));
+ row[2] ? strlen(row[2]) : 0));
if (row[2] == NULL)
{
print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n",
@@ -3918,7 +3919,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
int i;
char name_buff[NAME_LEN*2+3];
- mysql_real_escape_string(mysql, name_buff, db, strlen(db));
+ mysql_real_escape_string(mysql, name_buff, db, (ulong)strlen(db));
init_dynamic_string_checked(&where, " AND TABLESPACE_NAME IN ("
"SELECT DISTINCT TABLESPACE_NAME FROM"
@@ -3931,7 +3932,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
for (i=0 ; i<tables ; i++)
{
mysql_real_escape_string(mysql, name_buff,
- table_names[i], strlen(table_names[i]));
+ table_names[i], (ulong)strlen(table_names[i]));
dynstr_append_checked(&where, "'");
dynstr_append_checked(&where, name_buff);
@@ -3962,7 +3963,7 @@ static int dump_tablespaces_for_databases(char** databases)
{
char db_name_buff[NAME_LEN*2+3];
mysql_real_escape_string(mysql, db_name_buff,
- databases[i], strlen(databases[i]));
+ databases[i], (ulong)strlen(databases[i]));
dynstr_append_checked(&where, "'");
dynstr_append_checked(&where, db_name_buff);
dynstr_append_checked(&where, "',");
@@ -5003,7 +5004,7 @@ static int start_transaction(MYSQL *mysql_con)
}
-static ulong find_set(TYPELIB *lib, const char *x, uint length,
+static ulong find_set(TYPELIB *lib, const char *x, size_t length,
char **err_pos, uint *err_len)
{
const char *end= x + length;
@@ -5061,7 +5062,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
fputc(' ',file);
fputs(prefix, file);
if (string_value)
- unescape(file,row[0],(uint) strlen(row[0]));
+ unescape(file,row[0], strlen(row[0]));
else
fputs(row[0], file);
check_io(file);
@@ -5314,8 +5315,8 @@ static my_bool get_view_structure(char *table, char* db)
verbose_msg("-- Retrieving view structure for table %s...\n", table);
#ifdef NOT_REALLY_USED_YET
- sprintf(insert_pat, "SET SQL_QUOTE_SHOW_CREATE=%d",
- (opt_quoted || opt_keywords));
+ dynstr_append_checked(&insert_pat, "SET SQL_QUOTE_SHOW_CREATE=");
+ dynstr_append_checked(&insert_pat, (opt_quoted || opt_keywords)? "1":"0");
#endif
result_table= quote_name(table, table_buff, 1);
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 64a6a65b3cb..4349c063ee8 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -51,9 +51,9 @@ static int list_tables(MYSQL *mysql,const char *db,const char *table);
static int list_table_status(MYSQL *mysql,const char *db,const char *table);
static int list_fields(MYSQL *mysql,const char *db,const char *table,
const char *field);
-static void print_header(const char *header,uint head_length,...);
-static void print_row(const char *header,uint head_length,...);
-static void print_trailer(uint length,...);
+static void print_header(const char *header,size_t head_length,...);
+static void print_row(const char *header,size_t head_length,...);
+static void print_trailer(size_t length,...);
static void print_res_header(MYSQL_RES *result);
static void print_res_top(MYSQL_RES *result);
static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
@@ -366,7 +366,8 @@ static int
list_dbs(MYSQL *mysql,const char *wild)
{
const char *header;
- uint length, counter = 0;
+ size_t length = 0;
+ uint counter = 0;
ulong rowcount = 0L;
char tables[NAME_LEN+1], rows[NAME_LEN+1];
char query[NAME_LEN + 100];
@@ -404,7 +405,7 @@ list_dbs(MYSQL *mysql,const char *wild)
printf("Wildcard: %s\n",wild);
header="Databases";
- length=(uint) strlen(header);
+ length= strlen(header);
field=mysql_fetch_field(result);
if (length < field->max_length)
length=field->max_length;
@@ -492,7 +493,8 @@ static int
list_tables(MYSQL *mysql,const char *db,const char *table)
{
const char *header;
- uint head_length, counter = 0;
+ size_t head_length;
+ uint counter = 0;
char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
MYSQL_FIELD *field;
MYSQL_RES *result;
@@ -529,7 +531,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
putchar('\n');
header="Tables";
- head_length=(uint) strlen(header);
+ head_length= strlen(header);
field=mysql_fetch_field(result);
if (head_length < field->max_length)
head_length=field->max_length;
@@ -647,7 +649,7 @@ list_table_status(MYSQL *mysql,const char *db,const char *wild)
len= sizeof(query);
len-= my_snprintf(query, len, "show table status from `%s`", db);
if (wild && wild[0] && len)
- strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
+ strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot get status for db: %s, table: %s: %s\n",
@@ -680,7 +682,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
const char *wild)
{
char query[NAME_LEN + 100];
- int len;
+ size_t len;
MYSQL_RES *result;
MYSQL_ROW row;
ulong UNINIT_VAR(rows);
@@ -710,7 +712,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`",
table);
if (wild && wild[0] && len)
- strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
+ strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot list columns in db: %s, table: %s: %s\n",
@@ -758,10 +760,10 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
*****************************************************************************/
static void
-print_header(const char *header,uint head_length,...)
+print_header(const char *header,size_t head_length,...)
{
va_list args;
- uint length,i,str_length,pre_space;
+ size_t length,i,str_length,pre_space;
const char *field;
va_start(args,head_length);
@@ -784,10 +786,10 @@ print_header(const char *header,uint head_length,...)
putchar('|');
for (;;)
{
- str_length=(uint) strlen(field);
+ str_length= strlen(field);
if (str_length > length)
str_length=length+1;
- pre_space=(uint) (((int) length-(int) str_length)/2)+1;
+ pre_space= ((length- str_length)/2)+1;
for (i=0 ; i < pre_space ; i++)
putchar(' ');
for (i = 0 ; i < str_length ; i++)
@@ -821,11 +823,11 @@ print_header(const char *header,uint head_length,...)
static void
-print_row(const char *header,uint head_length,...)
+print_row(const char *header,size_t head_length,...)
{
va_list args;
const char *field;
- uint i,length,field_length;
+ size_t i,length,field_length;
va_start(args,head_length);
field=header; length=head_length;
@@ -834,7 +836,7 @@ print_row(const char *header,uint head_length,...)
putchar('|');
putchar(' ');
fputs(field,stdout);
- field_length=(uint) strlen(field);
+ field_length= strlen(field);
for (i=field_length ; i <= length ; i++)
putchar(' ');
if (!(field=va_arg(args,char *)))
@@ -848,10 +850,10 @@ print_row(const char *header,uint head_length,...)
static void
-print_trailer(uint head_length,...)
+print_trailer(size_t head_length,...)
{
va_list args;
- uint length,i;
+ size_t length,i;
va_start(args,head_length);
length=head_length;
@@ -894,7 +896,7 @@ static void print_res_top(MYSQL_RES *result)
mysql_field_seek(result,0);
while((field = mysql_fetch_field(result)))
{
- if ((length=(uint) strlen(field->name)) > field->max_length)
+ if ((length= strlen(field->name)) > field->max_length)
field->max_length=length;
else
length=field->max_length;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 9a1dfaa18ef..3652d1a40e2 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -5086,12 +5086,13 @@ static int my_kill(int pid, int sig)
{
#ifdef __WIN__
HANDLE proc;
- if ((proc= OpenProcess(PROCESS_TERMINATE, FALSE, pid)) == NULL)
+ if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
return -1;
if (sig == 0)
{
+ DWORD wait_result= WaitForSingleObject(proc, 0);
CloseHandle(proc);
- return 0;
+ return wait_result == WAIT_OBJECT_0?-1:0;
}
(void)TerminateProcess(proc, 201);
CloseHandle(proc);
diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c
index 7777da25aa1..5cdf1dedc27 100644
--- a/extra/mysql_waitpid.c
+++ b/extra/mysql_waitpid.c
@@ -50,10 +50,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
switch(optid) {
case 'V':
printf("%s version %s by Jani Tolonen\n", progname, VER);
- exit(-1);
+ exit(0);
case 'I':
case '?':
usage();
+ exit(0);
}
return 0;
}
@@ -69,7 +70,10 @@ int main(int argc, char *argv[])
exit(-1);
if (!argv[0] || !argv[1] || (pid= atoi(argv[0])) <= 0 ||
(t= atoi(argv[1])) <= 0)
+ {
usage();
+ exit(-1);
+ }
for (; t > 0; t--)
{
if (kill((pid_t) pid, sig))
@@ -100,5 +104,4 @@ void usage(void)
printf("integer arguments.\n\n");
printf("Options:\n");
my_print_help(my_long_options);
- exit(-1);
}
diff --git a/extra/yassl/src/log.cpp b/extra/yassl/src/log.cpp
index 13c68295747..c4be306a7b8 100644
--- a/extra/yassl/src/log.cpp
+++ b/extra/yassl/src/log.cpp
@@ -1,6 +1,5 @@
/*
- Copyright (C) 2000-2007 MySQL AB
- Use is subject to license terms
+ Copyright (c) 2000, 2016, 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
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 33eaa28ae1e..219a2917917 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -69,3 +69,9 @@ INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Developm
PATTERN CMakeFiles EXCLUDE
PATTERN mysql EXCLUDE
REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
+
+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)
diff --git a/include/my_tree.h b/include/my_tree.h
index 3dd92712af2..1069b232360 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2016, 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
diff --git a/include/myisam.h b/include/myisam.h
index d50b1dc360e..186b049b32e 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -330,7 +330,8 @@ typedef struct st_sort_info
my_off_t filelength, dupp, buff_length;
ha_rows max_records;
uint current_key, total_keys;
- uint got_error, threads_running;
+ volatile uint got_error;
+ uint threads_running;
myf myf_rw;
enum data_file_type new_data_file_type;
} MI_SORT_INFO;
diff --git a/include/violite.h b/include/violite.h
index ea7e3d7897c..da58de4373c 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -184,7 +184,7 @@ void vio_end(void);
/* shutdown(2) flags */
#ifndef SHUT_RD
-#define SHUT_RD SD_BOTH
+#define SHUT_RD SD_RECEIVE
#endif
/*
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index ee5c8875686..bd7631c1d6b 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -108,8 +108,12 @@ ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
# On Unix, it is libmysqld.a
IF(WIN32)
SET(MYSQLSERVER_OUTPUT_NAME mysqlserver)
+ SET(COMPONENT_MYSQLSERVER "Embedded")
+ SET(COMPONENT_LIBMYSQLD "Embedded")
ELSE()
SET(MYSQLSERVER_OUTPUT_NAME mysqld)
+ SET(COMPONENT_MYSQLSERVER "Development")
+ SET(COMPONENT_LIBMYSQLD "Server")
ENDIF()
@@ -134,9 +138,9 @@ FOREACH(LIB ${LIBS})
ENDFOREACH()
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
- OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Development)
+ OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT ${COMPONENT_MYSQLSERVER})
-INSTALL(FILES embedded_priv.h DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development)
+INSTALL(FILES embedded_priv.h DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT ${COMPONENT_MYSQLSERVER})
# Visual Studio users need debug static library
IF(MSVC)
@@ -163,7 +167,7 @@ ENDFOREACH()
IF(NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysqld SHARED mysqlserver EXPORTS ${EMBEDDED_API}
- COMPONENT Server)
+ COMPONENT ${COMPONENT_LIBMYSQLD})
IF(UNIX)
# Name the shared library, handle versioning (provides same api as client
# library hence the same version)
diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc
index c047b5bc499..0d09cdcd36e 100644
--- a/mysql-test/include/search_pattern_in_file.inc
+++ b/mysql-test/include/search_pattern_in_file.inc
@@ -10,6 +10,10 @@
# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
# before sourcing this routine.
#
+# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file
+# to search. If negative, it will search that many bytes at the end of the
+# file. The default is to search only the first 50000 bytes of the file.
+#
# In case of
# - SEARCH_FILE and/or SEARCH_PATTERN is not set
# - SEARCH_FILE cannot be opened
@@ -38,6 +42,7 @@
# --error 0,1
# --remove_file $error_log
# let SEARCH_FILE= $error_log;
+# let SEARCH_RANGE= -50000;
# # Stop the server
# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
# --exec echo "wait" > $restart_file
@@ -57,8 +62,18 @@ perl;
use strict;
my $search_file= $ENV{'SEARCH_FILE'} or die "SEARCH_FILE not set";
my $search_pattern= $ENV{'SEARCH_PATTERN'} or die "SEARCH_PATTERN not set";
+ my $search_range= $ENV{'SEARCH_RANGE'};
+ my $file_content;
+ $search_range= 50000 unless $search_range =~ /-?[0-9]+/;
open(FILE, "$search_file") or die("Unable to open '$search_file': $!\n");
- read(FILE, my $file_content, 50000, 0);
+ if ($search_range >= 0) {
+ read(FILE, $file_content, $search_range, 0);
+ } else {
+ my $size= -s $search_file;
+ $search_range = -$size if $size > -$search_range;
+ seek(FILE, $search_range, 2);
+ read(FILE, $file_content, -$search_range, 0);
+ }
close(FILE);
if ( not $file_content =~ m{$search_pattern} ) {
die("# ERROR: The file '$search_file' does not contain the expected pattern $search_pattern\n->$file_content<-\n");
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 9078174eb5a..cb3039f7017 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1805,9 +1805,12 @@ sub set_build_thread_ports($) {
if ( lc($opt_build_thread) eq 'auto' ) {
my $found_free = 0;
$build_thread = 300; # Start attempts from here
+ my $build_thread_upper = $build_thread + ($opt_parallel > 1500
+ ? 3000
+ : 2 * $opt_parallel) + 300;
while (! $found_free)
{
- $build_thread= mtr_get_unique_id($build_thread, 349);
+ $build_thread= mtr_get_unique_id($build_thread, $build_thread_upper);
if ( !defined $build_thread ) {
mtr_error("Could not get a unique build thread id");
}
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 505d655b6bb..b06ec5805a0 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -502,3 +502,9 @@ a
SELECT * FROM t1 WHERE a IN (0.8,0.9);
a
DROP TABLE t1;
+#
+# MDEV-9372 select 100 between 1 and 9223372036854775808 returns false
+#
+SELECT 100 BETWEEN 1 AND 9223372036854775808;
+100 BETWEEN 1 AND 9223372036854775808
+1
diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result
index c84da0d7496..2555749fa8c 100644
--- a/mysql-test/r/ctype_recoding.result
+++ b/mysql-test/r/ctype_recoding.result
@@ -277,9 +277,40 @@ CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('m'),('n');
CREATE VIEW v1 AS SELECT 'w' ;
SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v1 );
-ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<='
+a
+m
+n
drop view v1;
drop table t1;
SET character_set_connection = default;
SET optimizer_switch= default;
#End of 5.3 tests
+#
+# Start of 5.5 tests
+#
+#
+# MDEV-10181 Illegal mix of collation for a field and an ASCII string as a view field
+#
+SET NAMES utf8;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1);
+INSERT INTO t1 VALUES ('A'),('a'),('B'),('b');
+CREATE VIEW v1 AS SELECT 'a';
+SELECT * FROM v1,t1 where t1.a=v1.a;
+a a
+a A
+a a
+DROP VIEW v1;
+DROP TABLE t1;
+SET NAMES utf8;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1);
+INSERT INTO t1 VALUES ('a'),('b'),('c');
+CREATE VIEW v1 AS SELECT 'a' AS a UNION SELECT 'b';
+SELECT * FROM v1,t1 WHERE t1.a=v1.a;
+a a
+a a
+b b
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 217d3ca26d8..121168c2a2a 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -5830,5 +5830,44 @@ OCTET_LENGTH(a) a
255 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
DROP TABLE t1;
#
+# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
+#
+#
+SET NAMES utf8;
+SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data;
+data
+131072
+SELECT length(data) AS len FROM (
+SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data
+) AS sub;
+len
+131072
+SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data;
+data
+131070
+SELECT length(data) AS len FROM (
+SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data
+) AS sub;
+len
+131070
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub;
+len
+73532
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub;
+len
+73534
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub;
+len
+73556
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub;
+len
+131070
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub;
+len
+131072
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub;
+len
+131074
+#
# End of 5.5 tests
#
diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result
index 448645ebbae..17a1a2f787e 100644
--- a/mysql-test/r/ctype_utf8mb4.result
+++ b/mysql-test/r/ctype_utf8mb4.result
@@ -2622,6 +2622,40 @@ OCTET_LENGTH(a) a
252 😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎
DROP TABLE t1;
#
+# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
+#
+#
+SET NAMES utf8mb4;
+SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data;
+data
+65532
+SELECT length(data) AS len
+FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub;
+len
+65532
+SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data;
+data
+65538
+SELECT length(data) AS len
+FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub;
+len
+65538
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub;
+len
+65532
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub;
+len
+65535
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
+len
+65538
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
+len
+196605
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
+len
+196608
+#
# End of 5.5 tests
#
#
diff --git a/mysql-test/r/fulltext3.result b/mysql-test/r/fulltext3.result
index 4ec48369ad1..c0b871cd5a7 100644
--- a/mysql-test/r/fulltext3.result
+++ b/mysql-test/r/fulltext3.result
@@ -15,3 +15,15 @@ CREATE TABLE t1(a VARCHAR(2) CHARACTER SET big5 COLLATE big5_chinese_ci,
FULLTEXT(a));
INSERT INTO t1 VALUES(0xA3C2);
DROP TABLE t1;
+create table t1 (
+id varchar(255),
+business_name text null collate utf8mb4_unicode_ci,
+street_address text,
+fulltext index ft (business_name),
+fulltext index ft2 (street_address)
+);
+select * from t1 where match (business_name, street_address) against ('some business name and address here');
+ERROR HY000: Can't find FULLTEXT index matching the column list
+select * from t1 where match (business_name, street_address) against ('some business name and address here' in boolean mode);
+id business_name street_address
+drop table t1;
diff --git a/mysql-test/r/insert_innodb.result b/mysql-test/r/insert_innodb.result
index ffba9388ec4..e5e2b4b8623 100644
--- a/mysql-test/r/insert_innodb.result
+++ b/mysql-test/r/insert_innodb.result
@@ -28,3 +28,18 @@ ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`
UPDATE t1, t2 SET t1.fld1= t1.fld1 + 3;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`))
DROP TABLE t2, t1;
+#
+# BUG#22037930: INSERT IGNORE FAILS TO IGNORE FOREIGN
+# KEY CONSTRAINT
+CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= INNODB;
+CREATE TABLE t2 (fld1 VARCHAR(10), fld2 INT NOT NULL,
+CONSTRAINT fk FOREIGN KEY (fld2) REFERENCES t1(fld1)) ENGINE= INNODB;
+# Without patch, reports incorrect error.
+INSERT INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def';
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`))
+REPLACE INTO t2 VALUES('abc', 2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`))
+INSERT IGNORE INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def';
+Warnings:
+Warning 1452 Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`))
+DROP TABLE t2, t1;
diff --git a/mysql-test/r/kill_processlist-6619.result b/mysql-test/r/kill_processlist-6619.result
index a3d971e2115..f14727f1696 100644
--- a/mysql-test/r/kill_processlist-6619.result
+++ b/mysql-test/r/kill_processlist-6619.result
@@ -6,5 +6,5 @@ SHOW PROCESSLIST;
ERROR 70100: Query execution was interrupted
SHOW PROCESSLIST;
Id User Host db Command Time State Info Progress
-# root # test Sleep # # NULL 0.000
-# root # test Query # # SHOW PROCESSLIST 0.000
+# root # test # # # # 0.000
+# root # test # # # # 0.000
diff --git a/mysql-test/r/locale.result b/mysql-test/r/locale.result
index 195468c4c12..6de1d0708ca 100644
--- a/mysql-test/r/locale.result
+++ b/mysql-test/r/locale.result
@@ -101,3 +101,31 @@ Februar
SELECT monthname('2001-03-01');
monthname('2001-03-01')
März
+#
+# MDEV-10052 Illegal mix of collations with DAYNAME(date_field)<>varchar_field
+#
+SET NAMES utf8;
+CREATE TABLE t1 (c VARCHAR(8) CHARACTER SET latin1, d DATE);
+INSERT INTO t1 VALUES ('test',now());
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+SET lc_time_names=ru_RU;
+SELECT c FROM t1 WHERE DAYNAME(d)<>c;
+ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<>'
+SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
+ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<>'
+SET lc_time_names=en_US;
+SELECT c FROM t1 WHERE DAYNAME(d)<>c;
+c
+test
+SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
+c
+test
+SET NAMES latin1;
+SELECT c FROM t1 WHERE DAYNAME(d)<>c;
+c
+test
+SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
+c
+test
+DROP TABLE t1;
diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result
index 44ea5795a95..a49a12c230d 100644
--- a/mysql-test/r/openssl_1.result
+++ b/mysql-test/r/openssl_1.result
@@ -198,8 +198,6 @@ Ssl_cipher DHE-RSA-AES256-SHA
Variable_name Value
Ssl_cipher EDH-RSA-DES-CBC3-SHA
Variable_name Value
-Ssl_cipher EDH-RSA-DES-CBC-SHA
-Variable_name Value
Ssl_cipher RC4-SHA
select 'is still running; no cipher request crashed the server' as result from dual;
result
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index 915ace0c1b4..25143f97d9a 100644
--- a/mysql-test/r/parser.result
+++ b/mysql-test/r/parser.result
@@ -643,3 +643,23 @@ CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW
SET default_storage_engine = NEW.INNODB;
ERROR 42S22: Unknown column 'INNODB' in 'NEW'
DROP TABLE t1;
+select 0==0;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '=0' at line 1
+select 1=!0, 1 = ! 0;
+1=!0 1 = ! 0
+1 1
+select !!0, ! ! 0;
+!!0 ! ! 0
+0 0
+select 2>!0, 2 > ! 0;
+2>!0 2 > ! 0
+1 1
+select 0<=!0, 0 <= !0;
+0<=!0 0 <= !0
+1 1
+select 1<<!0, 1 << !0;
+1<<!0 1 << !0
+2 2
+select 0<!0, 0 < ! 0;
+0<!0 0 < ! 0
+1 1
diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result
index 4dc4d81224b..ddf709d462b 100644
--- a/mysql-test/r/sp-threads.result
+++ b/mysql-test/r/sp-threads.result
@@ -32,12 +32,9 @@ update t1, t2 set val= 1 where id1=id2;
call bug9486();
lock tables t2 write;
call bug9486();
-show processlist;
-Id User Host db Command Time State Info Progress
-# root localhost test Sleep # NULL 0.000
-# root localhost test Query # Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2 0.000
-# root localhost test Query # NULL show processlist 0.000
-# root localhost test Sleep # NULL 0.000
+SELECT state,info FROM information_schema.processlist WHERE id=con1root_id;
+state info
+Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2
unlock tables;
drop procedure bug9486;
drop table t1, t2;
diff --git a/mysql-test/r/ssl_ca.result b/mysql-test/r/ssl_ca.result
new file mode 100644
index 00000000000..ffc5671f85f
--- /dev/null
+++ b/mysql-test/r/ssl_ca.result
@@ -0,0 +1,24 @@
+#
+# Bug#21920657: SSL-CA FAILS SILENTLY IF THE PATH CANNOT BE FOUND
+#
+# try to connect with wrong '--ssl-ca' path : should fail
+ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed
+# try to connect with correct '--ssl-ca' path : should connect
+Variable_name Value
+Ssl_cipher DHE-RSA-AES256-SHA
+#
+# Bug#21920678: SSL-CA DOES NOT ACCEPT ~USER TILDE HOME DIRECTORY
+# PATH SUBSTITUTION
+#
+# try to connect with '--ssl-ca' option using tilde home directoy
+# path substitution : should connect
+Variable_name Value
+Ssl_cipher DHE-RSA-AES256-SHA
+# try to connect with '--ssl-key' option using tilde home directoy
+# path substitution : should connect
+Variable_name Value
+Ssl_cipher DHE-RSA-AES256-SHA
+# try to connect with '--ssl-cert' option using tilde home directoy
+# path substitution : should connect
+Variable_name Value
+Ssl_cipher DHE-RSA-AES256-SHA
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 7678f038862..ecbda1d13e6 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -442,6 +442,7 @@ select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
drop table t1;
#
# MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
+# MDEV-9972 Least function retuns date in date time format
#
CREATE TABLE t1 (
id BIGINT NOT NULL,
@@ -465,9 +466,9 @@ LEAST(IFNULL(t2.date_fin, IFNULL(t1.date_fin, NULL)),
IFNULL(t1.date_fin, IFNULL(t2.date_fin, NULL))) AS date_fin
FROM t1 LEFT JOIN t2 ON (t1.id=t2.id);
id date_debut date_fin
-1 2016-01-01 2016-01-31 00:00:00
-2 2016-02-01 2016-01-28 00:00:00
-3 2016-03-01 2016-03-31 00:00:00
+1 2016-01-01 2016-01-31
+2 2016-02-01 2016-01-28
+3 2016-03-01 2016-03-31
4 2016-04-01 NULL
DROP TABLE t1,t2;
SELECT
diff --git a/mysql-test/r/wait_timeout_not_windows.result b/mysql-test/r/wait_timeout_not_windows.result
new file mode 100644
index 00000000000..df70aa99221
--- /dev/null
+++ b/mysql-test/r/wait_timeout_not_windows.result
@@ -0,0 +1,3 @@
+set global log_warnings=2;
+set @@wait_timeout=1;
+set global log_warnings=@@log_warnings;
diff --git a/mysql-test/suite/binlog/t/binlog_mdev342.test b/mysql-test/suite/binlog/t/binlog_mdev342.test
index 02310b87a76..024fa884f91 100644
--- a/mysql-test/suite/binlog/t/binlog_mdev342.test
+++ b/mysql-test/suite/binlog/t/binlog_mdev342.test
@@ -44,8 +44,7 @@ connection con1;
--error 2006,2013
reap;
---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-binlog_mdev342.test
EOF
diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result
index 6c3306f5c15..7ba300b245e 100644
--- a/mysql-test/suite/innodb/r/innodb-fk.result
+++ b/mysql-test/suite/innodb/r/innodb-fk.result
@@ -68,3 +68,47 @@ Warning 150 Alter table `test`.`t2` with foreign key constraint failed. Referen
Error 1005 Can't create table '#sql-temporary' (errno: 150)
drop table t2;
drop table t1;
+CREATE DATABASE kg_test1;
+CREATE DATABASE kg_test2;
+CREATE TABLE `kg_test1`.`group` (
+Id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE `kg_test1`.`person` (
+`Id` INT(11) NOT NULL AUTO_INCREMENT,
+`Name` VARCHAR(50) NOT NULL,
+PRIMARY KEY (`Id`),
+CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+show create table `kg_test1`.`person`;
+Table Create Table
+person CREATE TABLE `person` (
+ `Id` int(11) NOT NULL AUTO_INCREMENT,
+ `Name` varchar(50) NOT NULL,
+ PRIMARY KEY (`Id`),
+ CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+CREATE TABLE `kg_test2`.`person2` (
+`Id` INT(11) NOT NULL AUTO_INCREMENT,
+`Name` VARCHAR(50) NOT NULL,
+PRIMARY KEY (`Id`),
+CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+ERROR HY000: Can't create table 'kg_test2.person2' (errno: 150)
+CREATE TABLE `kg_test2`.`person2` (
+`Id` INT(11) NOT NULL AUTO_INCREMENT,
+`Name` VARCHAR(50) NOT NULL,
+PRIMARY KEY (`Id`),
+CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+show create table `kg_test2`.`person2`;
+Table Create Table
+person2 CREATE TABLE `person2` (
+ `Id` int(11) NOT NULL AUTO_INCREMENT,
+ `Name` varchar(50) NOT NULL,
+ PRIMARY KEY (`Id`),
+ CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+SHOW WARNINGS;
+Level Code Message
+DROP DATABASE kg_test2;
+DROP DATABASE kg_test1;
diff --git a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
index 2ba79ced75f..bc4334bd219 100644
--- a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
+++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
@@ -1,83 +1,49 @@
-set names utf8;
-CREATE TABLE corrupt_bit_test_ā(
-a INT AUTO_INCREMENT PRIMARY KEY,
-b CHAR(100),
-c INT,
-z INT,
-INDEX(b))
-ENGINE=InnoDB;
-INSERT INTO corrupt_bit_test_ā VALUES(0,'x',1, 1);
-CREATE UNIQUE INDEX idxā ON corrupt_bit_test_ā(c, b);
-CREATE UNIQUE INDEX idxē ON corrupt_bit_test_ā(z, b);
-SELECT * FROM corrupt_bit_test_ā;
a b c z
1 x 1 1
-select @@unique_checks;
-@@unique_checks
-0
-select @@innodb_change_buffering_debug;
-@@innodb_change_buffering_debug
-1
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_ā;
-select count(*) from corrupt_bit_test_ā;
count(*)
-1024
-CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
-INSERT INTO corrupt_bit_test_ā VALUES(13000,'x',1,1);
-CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
-check table corrupt_bit_test_ā;
+2
Table Op Msg_type Msg_text
-test.corrupt_bit_test_ā check Warning InnoDB: The B-tree of index "idxā" is corrupted.
-test.corrupt_bit_test_ā check Warning InnoDB: The B-tree of index "idxē" is corrupted.
+test.corrupt_bit_test_ā check Warning InnoDB: Index "idx" is marked as corrupted
+test.corrupt_bit_test_ā check Warning InnoDB: Index "idxā" is marked as corrupted
+test.corrupt_bit_test_ā check Warning InnoDB: Index "idxē" is marked as corrupted
test.corrupt_bit_test_ā check error Corrupt
-select c from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
-select z from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
-show warnings;
+ERROR HY000: Index corrupt_bit_test_ā is corrupted
+ERROR HY000: Index corrupt_bit_test_ā is corrupted
Level Code Message
Warning 179 InnoDB: Index "idxē" for table "test"."corrupt_bit_test_ā" is marked as corrupted
Warning 179 Got error 179 when reading table `test`.`corrupt_bit_test_ā`
Error 1712 Index corrupt_bit_test_ā is corrupted
-insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001);
-select * from corrupt_bit_test_ā use index(primary) where a = 10001;
a b c z
10001 a 20001 20001
-begin;
-insert into corrupt_bit_test_ā values (10002, "a", 20002, 20002);
-delete from corrupt_bit_test_ā where a = 10001;
-insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001);
-rollback;
-drop index idxā on corrupt_bit_test_ā;
-check table corrupt_bit_test_ā;
Table Op Msg_type Msg_text
+test.corrupt_bit_test_ā check Warning InnoDB: Index "idx" is marked as corrupted
test.corrupt_bit_test_ā check Warning InnoDB: Index "idxē" is marked as corrupted
test.corrupt_bit_test_ā check error Corrupt
-set names utf8;
-select z from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
-drop index idxē on corrupt_bit_test_ā;
-select z from corrupt_bit_test_ā limit 10;
+Table Create Table
+corrupt_bit_test_ā CREATE TABLE `corrupt_bit_test_ā` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` char(100) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `z` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `idxē` (`z`,`b`),
+ KEY `idx` (`b`)
+) ENGINE=InnoDB AUTO_INCREMENT=10003 DEFAULT CHARSET=latin1
+ERROR HY000: Index corrupt_bit_test_ā is corrupted
+ERROR HY000: Index corrupt_bit_test_ā is corrupted
+Table Create Table
+corrupt_bit_test_ā CREATE TABLE `corrupt_bit_test_ā` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` char(100) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `z` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `idx` (`b`)
+) ENGINE=InnoDB AUTO_INCREMENT=10003 DEFAULT CHARSET=latin1
z
20001
1
-1
2
-11
-12
-21
-22
-31
-32
-drop table corrupt_bit_test_ā;
-DROP DATABASE pad;
-SET GLOBAL innodb_change_buffering_debug = 0;
diff --git a/mysql-test/suite/innodb/t/innodb-fk.test b/mysql-test/suite/innodb/t/innodb-fk.test
index 9bfd16b88e9..fd8dce7594c 100644
--- a/mysql-test/suite/innodb/t/innodb-fk.test
+++ b/mysql-test/suite/innodb/t/innodb-fk.test
@@ -124,3 +124,44 @@ show warnings;
drop table t2;
drop table t1;
+
+#
+# MDEV-9142 :Adding Constraint with no database reference
+# results in ERROR 1046 (3D000) at line 13: No database selected
+#
+CREATE DATABASE kg_test1;
+CREATE DATABASE kg_test2;
+
+CREATE TABLE `kg_test1`.`group` (
+ Id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `kg_test1`.`person` (
+`Id` INT(11) NOT NULL AUTO_INCREMENT,
+`Name` VARCHAR(50) NOT NULL,
+PRIMARY KEY (`Id`),
+CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+
+show create table `kg_test1`.`person`;
+
+--error 1005
+CREATE TABLE `kg_test2`.`person2` (
+`Id` INT(11) NOT NULL AUTO_INCREMENT,
+`Name` VARCHAR(50) NOT NULL,
+PRIMARY KEY (`Id`),
+CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `kg_test2`.`person2` (
+`Id` INT(11) NOT NULL AUTO_INCREMENT,
+`Name` VARCHAR(50) NOT NULL,
+PRIMARY KEY (`Id`),
+CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+
+show create table `kg_test2`.`person2`;
+
+SHOW WARNINGS;
+DROP DATABASE kg_test2;
+DROP DATABASE kg_test1;
diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
index 88da919bfaa..f67e2e7e047 100644
--- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
+++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
@@ -2,45 +2,23 @@
# Test for persistent corrupt bit for corrupted index and table
#
-- source include/have_innodb.inc
-
-# Issues with innodb_change_buffering_debug on Windows, so the test scenario
-# cannot be created on windows
---source include/not_windows.inc
-
+-- source include/not_embedded.inc
# This test needs debug server
---source include/have_debug.inc
+-- source include/have_debug.inc
-- disable_query_log
call mtr.add_suppression("Flagged corruption of idx.*in CHECK TABLE");
-# This test setup is extracted from bug56680.test:
-# The flag innodb_change_buffering_debug is only available in debug builds.
-# It instructs InnoDB to try to evict pages from the buffer pool when
-# change buffering is possible, so that the change buffer will be used
-# whenever possible.
-SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug;
-SET GLOBAL innodb_change_buffering_debug = 1;
-
-# Turn off Unique Check to create corrupted index with dup key
-SET UNIQUE_CHECKS=0;
-
-CREATE DATABASE pad;
-let $i=338;
-while ($i)
-{
---eval CREATE TABLE pad.t$i(a INT PRIMARY KEY)ENGINE=InnoDB;
- dec $i;
-}
-
--- enable_query_log
set names utf8;
+SET UNIQUE_CHECKS=0;
+
CREATE TABLE corrupt_bit_test_ā(
a INT AUTO_INCREMENT PRIMARY KEY,
b CHAR(100),
c INT,
z INT,
- INDEX(b))
+ INDEX idx(b))
ENGINE=InnoDB;
INSERT INTO corrupt_bit_test_ā VALUES(0,'x',1, 1);
@@ -53,38 +31,21 @@ CREATE UNIQUE INDEX idxē ON corrupt_bit_test_ā(z, b);
SELECT * FROM corrupt_bit_test_ā;
-select @@unique_checks;
-select @@innodb_change_buffering_debug;
-
-# Create enough rows for the table, so that the insert buffer will be
-# used for modifying the secondary index page. There must be multiple
-# index pages, because changes to the root page are never buffered.
-
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_ā;
-INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_ā;
select count(*) from corrupt_bit_test_ā;
-CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
-
-# Create a dup key error on index "idxē" and "idxā" by inserting a dup value
-INSERT INTO corrupt_bit_test_ā VALUES(13000,'x',1,1);
+# This will flag all secondary indexes corrupted
+SET SESSION debug_dbug="+d,dict_set_index_corrupted";
+check table corrupt_bit_test_ā;
+SET SESSION debug_dbug="-d,dict_set_index_corrupted";
-# creating an index should succeed even if other secondary indexes are corrupted
+# Cannot create new indexes while corrupted indexes exist
+--error ER_INDEX_CORRUPT
+CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
+--error ER_INDEX_CORRUPT
CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
-# Check table will find the unique indexes corrupted
-# with dup key
-check table corrupt_bit_test_ā;
-
# This selection intend to use the corrupted index. Expect to fail
-- error ER_INDEX_CORRUPT
select c from corrupt_bit_test_ā;
@@ -108,7 +69,6 @@ delete from corrupt_bit_test_ā where a = 10001;
insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001);
rollback;
-# Drop one corrupted index before reboot
drop index idxā on corrupt_bit_test_ā;
check table corrupt_bit_test_ā;
@@ -118,14 +78,26 @@ set names utf8;
-- error ER_INDEX_CORRUPT
select z from corrupt_bit_test_ā;
+show create table corrupt_bit_test_ā;
+
# Drop the corrupted index
drop index idxē on corrupt_bit_test_ā;
+# Cannot create new indexes while a corrupt index exists.
+--error ER_INDEX_CORRUPT
+CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
+--error ER_INDEX_CORRUPT
+CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
+
+show create table corrupt_bit_test_ā;
+drop index idx on corrupt_bit_test_ā;
+
+# Now that there exist no corrupted indexes, we can create new indexes.
+CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
+CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
+
# Now select back to normal
select z from corrupt_bit_test_ā limit 10;
# Drop table
drop table corrupt_bit_test_ā;
-DROP DATABASE pad;
-
-SET GLOBAL innodb_change_buffering_debug = 0;
diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result
index 67338506001..2dcfa107103 100644
--- a/mysql-test/suite/plugins/r/server_audit.result
+++ b/mysql-test/suite/plugins/r/server_audit.result
@@ -165,7 +165,7 @@ CREATE USER u1 IDENTIFIED BY 'pwd-123';
GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321";
SET PASSWORD FOR u1 = PASSWORD('pwd 098');
SET PASSWORD FOR u1=<secret>;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '=<secret>' at line 1
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '<secret>' at line 1
CREATE USER u3 IDENTIFIED BY '';
drop user u1, u2, u3;
select 2;
diff --git a/mysql-test/suite/plugins/r/thread_pool_server_audit.result b/mysql-test/suite/plugins/r/thread_pool_server_audit.result
index 67338506001..2dcfa107103 100644
--- a/mysql-test/suite/plugins/r/thread_pool_server_audit.result
+++ b/mysql-test/suite/plugins/r/thread_pool_server_audit.result
@@ -165,7 +165,7 @@ CREATE USER u1 IDENTIFIED BY 'pwd-123';
GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321";
SET PASSWORD FOR u1 = PASSWORD('pwd 098');
SET PASSWORD FOR u1=<secret>;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '=<secret>' at line 1
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '<secret>' at line 1
CREATE USER u3 IDENTIFIED BY '';
drop user u1, u2, u3;
select 2;
diff --git a/mysql-test/suite/rpl/t/rpl_mdev382.test b/mysql-test/suite/rpl/t/rpl_mdev382.test
index 21925e0e130..784617bd198 100644
--- a/mysql-test/suite/rpl/t/rpl_mdev382.test
+++ b/mysql-test/suite/rpl/t/rpl_mdev382.test
@@ -209,8 +209,7 @@ EOF
--shutdown_server 30
---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-rpl_mdev382.test
EOF
diff --git a/mysql-test/suite/storage_engine/alter_tablespace.test b/mysql-test/suite/storage_engine/alter_tablespace.test
index dec16e5a3ac..6318b410e6e 100644
--- a/mysql-test/suite/storage_engine/alter_tablespace.test
+++ b/mysql-test/suite/storage_engine/alter_tablespace.test
@@ -53,8 +53,7 @@ EOF
--replace_result $datadir <DATADIR>
--copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save
- --remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
- --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+ --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index 41f33b8a7f2..fb18d60edd9 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -409,3 +409,8 @@ SELECT * FROM t1 WHERE a=0.9;
SELECT * FROM t1 WHERE a IN (0.8,0.9);
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-9372 select 100 between 1 and 9223372036854775808 returns false
+--echo #
+SELECT 100 BETWEEN 1 AND 9223372036854775808;
diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test
index ee07ef24def..81c04fc9c30 100644
--- a/mysql-test/t/ctype_recoding.test
+++ b/mysql-test/t/ctype_recoding.test
@@ -220,7 +220,6 @@ SET character_set_connection = utf8;
CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('m'),('n');
CREATE VIEW v1 AS SELECT 'w' ;
---error ER_CANT_AGGREGATE_2COLLATIONS
SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v1 );
drop view v1;
drop table t1;
@@ -228,3 +227,30 @@ SET character_set_connection = default;
SET optimizer_switch= default;
--echo #End of 5.3 tests
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # MDEV-10181 Illegal mix of collation for a field and an ASCII string as a view field
+--echo #
+SET NAMES utf8;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1);
+INSERT INTO t1 VALUES ('A'),('a'),('B'),('b');
+CREATE VIEW v1 AS SELECT 'a';
+SELECT * FROM v1,t1 where t1.a=v1.a;
+DROP VIEW v1;
+DROP TABLE t1;
+
+SET NAMES utf8;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1);
+INSERT INTO t1 VALUES ('a'),('b'),('c');
+CREATE VIEW v1 AS SELECT 'a' AS a UNION SELECT 'b';
+SELECT * FROM v1,t1 WHERE t1.a=v1.a;
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index a9b5cee11ce..d6fdc6c6a2c 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -1659,5 +1659,28 @@ SELECT OCTET_LENGTH(a),a FROM t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
+--echo #
+--echo #
+
+SET NAMES utf8;
+SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data;
+SELECT length(data) AS len FROM (
+ SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data
+) AS sub;
+
+SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data;
+SELECT length(data) AS len FROM (
+ SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data
+) AS sub;
+
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub;
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub;
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub;
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub;
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub;
+SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub;
+
+--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test
index 66f5a3ba5ac..c240f261af4 100644
--- a/mysql-test/t/ctype_utf8mb4.test
+++ b/mysql-test/t/ctype_utf8mb4.test
@@ -1839,6 +1839,26 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
+--echo #
+--echo #
+
+SET NAMES utf8mb4;
+SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data;
+SELECT length(data) AS len
+FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub;
+
+SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data;
+SELECT length(data) AS len
+FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub;
+
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub;
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub;
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
+SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
+
+--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/fulltext3.test b/mysql-test/t/fulltext3.test
index 1b6a07c540f..66f940b495e 100644
--- a/mysql-test/t/fulltext3.test
+++ b/mysql-test/t/fulltext3.test
@@ -32,3 +32,18 @@ INSERT INTO t1 VALUES(0xA3C2);
DROP TABLE t1;
# End of 5.1 tests
+
+#
+# MDEV-9986 Full-text search of the utf8mb4 column causes crash
+#
+create table t1 (
+ id varchar(255),
+ business_name text null collate utf8mb4_unicode_ci,
+ street_address text,
+ fulltext index ft (business_name),
+ fulltext index ft2 (street_address)
+);
+--error ER_FT_MATCHING_KEY_NOT_FOUND
+select * from t1 where match (business_name, street_address) against ('some business name and address here');
+select * from t1 where match (business_name, street_address) against ('some business name and address here' in boolean mode);
+drop table t1;
diff --git a/mysql-test/t/insert_innodb.test b/mysql-test/t/insert_innodb.test
index 8c8d2690c11..68b6ca4e315 100644
--- a/mysql-test/t/insert_innodb.test
+++ b/mysql-test/t/insert_innodb.test
@@ -41,3 +41,24 @@ UPDATE t1, t2 SET t2.fld2= t2.fld2 + 3;
UPDATE t1, t2 SET t1.fld1= t1.fld1 + 3;
DROP TABLE t2, t1;
+
+--echo #
+--echo # BUG#22037930: INSERT IGNORE FAILS TO IGNORE FOREIGN
+--echo # KEY CONSTRAINT
+
+CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= INNODB;
+
+CREATE TABLE t2 (fld1 VARCHAR(10), fld2 INT NOT NULL,
+CONSTRAINT fk FOREIGN KEY (fld2) REFERENCES t1(fld1)) ENGINE= INNODB;
+
+--echo # Without patch, reports incorrect error.
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def';
+--error ER_NO_REFERENCED_ROW_2
+REPLACE INTO t2 VALUES('abc', 2);
+
+--enable_warnings
+INSERT IGNORE INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def';
+--disable_warnings
+
+DROP TABLE t2, t1;
diff --git a/mysql-test/t/kill_processlist-6619.test b/mysql-test/t/kill_processlist-6619.test
index d73859ce8cd..28f98bcbb24 100644
--- a/mysql-test/t/kill_processlist-6619.test
+++ b/mysql-test/t/kill_processlist-6619.test
@@ -11,5 +11,5 @@ eval KILL QUERY $con_id;
--connection con1
--error ER_QUERY_INTERRUPTED
SHOW PROCESSLIST;
---replace_column 1 # 3 # 6 # 7 #
+--replace_column 1 # 3 # 5 # 6 # 7 # 8 #
SHOW PROCESSLIST;
diff --git a/mysql-test/t/locale.test b/mysql-test/t/locale.test
index 899d293545d..4944dc7a228 100644
--- a/mysql-test/t/locale.test
+++ b/mysql-test/t/locale.test
@@ -63,3 +63,22 @@ SET lc_time_names=de_AT;
SELECT monthname('2001-01-01');
SELECT monthname('2001-02-01');
SELECT monthname('2001-03-01');
+
+--echo #
+--echo # MDEV-10052 Illegal mix of collations with DAYNAME(date_field)<>varchar_field
+--echo #
+SET NAMES utf8;
+CREATE TABLE t1 (c VARCHAR(8) CHARACTER SET latin1, d DATE);
+INSERT INTO t1 VALUES ('test',now());
+SET lc_time_names=ru_RU;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT c FROM t1 WHERE DAYNAME(d)<>c;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
+SET lc_time_names=en_US;
+SELECT c FROM t1 WHERE DAYNAME(d)<>c;
+SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
+SET NAMES latin1;
+SELECT c FROM t1 WHERE DAYNAME(d)<>c;
+SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
+DROP TABLE t1;
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 1b28c40c0bf..62b5c9c10e0 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -222,7 +222,6 @@ DROP TABLE t1;
# Common ciphers to openssl and yassl
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=DHE-RSA-AES256-SHA
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=EDH-RSA-DES-CBC3-SHA
---exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=EDH-RSA-DES-CBC-SHA
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=RC4-SHA
--disable_query_log
--disable_result_log
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index 6899e2876a6..c6aa8927848 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -758,3 +758,15 @@ CREATE TABLE t1 (s VARCHAR(100));
CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW
SET default_storage_engine = NEW.INNODB;
DROP TABLE t1;
+
+#
+# MDEV-8328 Evaluation of two "!" operators depends on space in beetween
+#
+--error ER_PARSE_ERROR
+select 0==0;
+select 1=!0, 1 = ! 0;
+select !!0, ! ! 0;
+select 2>!0, 2 > ! 0;
+select 0<=!0, 0 <= !0;
+select 1<<!0, 1 << !0;
+select 0<!0, 0 < ! 0;
diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test
index 4693288a4dd..a951945a87c 100644
--- a/mysql-test/t/partition_innodb_plugin.test
+++ b/mysql-test/t/partition_innodb_plugin.test
@@ -124,12 +124,8 @@ SEND;
UPDATE `t``\""e` SET a = 12 WHERE a = 0;
--echo # default connection
connection default;
-let $wait_timeout= 2;
-let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
-WHERE ID = $id_1 AND STATE = 'Searching rows for update';
+let $wait_condition= SELECT COUNT(*)=2 FROM INFORMATION_SCHEMA.INNODB_LOCKS;
--source include/wait_condition.inc
-#--echo # tested wait condition $wait_condition_reps times
-# INNODB_LOCKS only exists in innodb_plugin
--sorted_result
SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
GROUP BY lock_table;
diff --git a/mysql-test/t/sp-threads.test b/mysql-test/t/sp-threads.test
index e1012e2b72d..7a6d1258331 100644
--- a/mysql-test/t/sp-threads.test
+++ b/mysql-test/t/sp-threads.test
@@ -77,12 +77,15 @@ call bug9486();
connection con2root;
lock tables t2 write;
connection con1root;
+let $con1root_id=`SELECT CONNECTION_ID()`;
send call bug9486();
connection con2root;
---sleep 2
# There should be call statement in locked state.
---replace_column 1 # 3 localhost 6 #
-show processlist;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE
+ id=$con1root_id AND state='Waiting for table metadata lock';
+--source include/wait_condition.inc
+--replace_result $con1root_id con1root_id
+eval SELECT state,info FROM information_schema.processlist WHERE id=$con1root_id;
unlock tables;
connection con1root;
reap;
diff --git a/mysql-test/t/ssl_ca.test b/mysql-test/t/ssl_ca.test
new file mode 100644
index 00000000000..3652040dd0b
--- /dev/null
+++ b/mysql-test/t/ssl_ca.test
@@ -0,0 +1,36 @@
+--source include/have_ssl.inc
+--source include/not_embedded.inc
+
+--echo #
+--echo # Bug#21920657: SSL-CA FAILS SILENTLY IF THE PATH CANNOT BE FOUND
+--echo #
+
+--echo # try to connect with wrong '--ssl-ca' path : should fail
+--error 1
+--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/wrong-cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'" 2>&1
+
+--echo # try to connect with correct '--ssl-ca' path : should connect
+--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
+--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
+
+--echo #
+--echo # Bug#21920678: SSL-CA DOES NOT ACCEPT ~USER TILDE HOME DIRECTORY
+--echo # PATH SUBSTITUTION
+--echo #
+
+--let $mysql_test_dir_path= `SELECT IF(LENGTH('$HOME'), REPLACE('=$MYSQL_TEST_DIR', '=$HOME', '=~'), '=$MYSQL_TEST_DIR')`
+
+--echo # try to connect with '--ssl-ca' option using tilde home directoy
+--echo # path substitution : should connect
+--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
+--exec $MYSQL --ssl-ca$mysql_test_dir_path/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
+
+--echo # try to connect with '--ssl-key' option using tilde home directoy
+--echo # path substitution : should connect
+--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
+--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key$mysql_test_dir_path/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
+
+--echo # try to connect with '--ssl-cert' option using tilde home directoy
+--echo # path substitution : should connect
+--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
+--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert$mysql_test_dir_path/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 4b058171ad2..8b0c5dcf330 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -388,6 +388,7 @@ drop table t1;
--echo #
--echo # MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
+--echo # MDEV-9972 Least function retuns date in date time format
--echo #
CREATE TABLE t1 (
id BIGINT NOT NULL,
diff --git a/mysql-test/t/wait_timeout_not_windows.test b/mysql-test/t/wait_timeout_not_windows.test
new file mode 100644
index 00000000000..de4904fada2
--- /dev/null
+++ b/mysql-test/t/wait_timeout_not_windows.test
@@ -0,0 +1,16 @@
+source include/not_embedded.inc;
+source include/not_windows.inc;
+
+#
+# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout
+#
+set global log_warnings=2;
+connect (foo,localhost,root);
+set @@wait_timeout=1;
+sleep 2;
+connection default;
+let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
+let SEARCH_RANGE= -50;
+let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets;
+source include/search_pattern_in_file.inc;
+set global log_warnings=@@log_warnings;
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 29897e4bd6c..b86cbd23408 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -19,36 +19,6 @@
# Suppress some common (not fatal) errors in system libraries found by valgrind
#
-#
-# Pthread doesn't free all thread specific memory before program exists
-#
-{
- pthread allocate_tls memory loss
- Memcheck:Leak
- fun:calloc
- fun:_dl_allocate_tls
- fun:allocate_stack
- fun:pthread_create*
-}
-
-{
- pthread allocate_tls memory loss
- Memcheck:Leak
- fun:calloc
- fun:_dl_allocate_tls
- fun:pthread_create*
-
-}
-
-{
- pthread allocate_tls memory loss
- Memcheck:Leak
- fun:calloc
- obj:/lib*/ld*.so
- fun:_dl_allocate_tls
- fun:pthread_create*
-}
-
{
pthead_exit memory loss 1
Memcheck:Leak
@@ -90,34 +60,6 @@
}
{
- pthread allocate_dtv memory loss
- Memcheck:Leak
- fun:calloc
- fun:allocate_dtv
- fun:_dl_allocate_tls_storage
- fun:__GI__dl_allocate_tls
- fun:pthread_create
-}
-
-{
- pthread allocate_dtv memory loss second
- Memcheck:Leak
- fun:calloc
- fun:allocate_dtv
- fun:_dl_allocate_tls
- fun:pthread_create*
-}
-
-{
- pthread memalign memory loss
- Memcheck:Leak
- fun:memalign
- fun:_dl_allocate_tls_storage
- fun:__GI__dl_allocate_tls
- fun:pthread_create
-}
-
-{
pthread pthread_key_create
Memcheck:Leak
fun:malloc
@@ -972,18 +914,6 @@
fun:nptl_pthread_exit_hack_handler
}
-#
-# Pthread doesn't free all thread specific memory before program exists
-#
-{
- pthread allocate_tls memory loss in 2.6.1.
- Memcheck:Leak
- fun:calloc
- obj:*/ld-*.so
- fun:_dl_allocate_tls
- fun:pthread_create*
-}
-
{
memory "leak" in backtrace() of glibc 2.9 (not present in 2.13)
Memcheck:Leak
@@ -1117,3 +1047,22 @@
fun:_nss_dns_gethostbyaddr_r
fun:gethostbyaddr_r
}
+
+
+#
+# Detached threads may not complete deiniitialization by the time shutdown
+# thread calls exit. This is unfortunate property of detached threads, which
+# we currently can only ignore. Unfortunately there is no way to distinguish
+# between false positives generated by detached threads and real memory leaks
+# generated by not joined joinable threads. So we hide both cases.
+#
+# To avoid enumeration of the whole variety of possible traces we ignore all
+# "possibly lost" blocks allocated by pthread_create (and it's callees).
+#
+{
+ Detached threads memory loss
+ Memcheck:Leak
+ match-leak-kinds:possible
+ ...
+ fun:pthread_create*
+}
diff --git a/mysys/errors.c b/mysys/errors.c
index 84b406792af..0f2edbc4ae5 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -1,5 +1,5 @@
-/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2009, 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
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 02e5c5373ae..31a09e214d2 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -1874,6 +1874,7 @@ void die(const char* fmt, ...)
fprintf(stderr,"Error:");
vfprintf(stderr, fmt,va_args);
fprintf(stderr,", errno=%d\n", errno);
+ va_end(va_args);
exit(1);
}
diff --git a/mysys/my_context.c b/mysys/my_context.c
index 80156df4495..01d6f404627 100644
--- a/mysys/my_context.c
+++ b/mysys/my_context.c
@@ -206,7 +206,7 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
(
"movq %%rsp, (%[save])\n\t"
"movq %[stack], %%rsp\n\t"
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && !defined(__INTEL_COMPILER)
/*
This emits a DWARF DW_CFA_undefined directive to make the return address
undefined. This indicates that this is the top of the stack frame, and
@@ -456,7 +456,7 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
(
"movl %%esp, (%[save])\n\t"
"movl %[stack], %%esp\n\t"
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && !defined(__INTEL_COMPILER)
/*
This emits a DWARF DW_CFA_undefined directive to make the return address
undefined. This indicates that this is the top of the stack frame, and
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 10a500c3fb3..001f7296042 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2011, 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
diff --git a/mysys/testhash.c b/mysys/testhash.c
index ffdaaece770..aa78a2d8c40 100644
--- a/mysys/testhash.c
+++ b/mysys/testhash.c
@@ -169,7 +169,9 @@ static int do_test()
for (j=0 ; j < 1000 ; j++)
if (key1[j] > 1)
break;
- if (key1[j] > 1)
+ // j will be 1000 only if we have no keys in the hash. This only happens
+ // when the parameter recant is set to 0 via command line argument.
+ if (j < 1000 && key1[j] > 1)
{
HASH_SEARCH_STATE state;
printf("- Testing identical read\n");
diff --git a/mysys/tree.c b/mysys/tree.c
index 85770194f25..4184fc4634a 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2010, 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
diff --git a/regex/split.c b/regex/split.c
index bd2a53c01e3..a3a11f793ed 100644
--- a/regex/split.c
+++ b/regex/split.c
@@ -163,6 +163,10 @@ char *argv[];
}
else if (argc > 3)
for (n = atoi(argv[3]); n > 0; n--) {
+ if(sizeof(buf)-1 < strlen(argv[1]))
+ {
+ exit(EXIT_FAILURE);
+ }
(void) strcpy(buf, argv[1]);
(void) split(buf, fields, MNF, argv[2]);
}
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index 6b650aa6248..66b8c0d8e21 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -17,7 +17,7 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA
-# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2016, 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 Library General Public
@@ -711,7 +711,11 @@ sub my_which
my ($command) = @_;
my (@paths, $path);
- return $command if (-f $command && -x $command);
+ # If the argument is not 'my_print_defaults' then it would be of the format
+ # <absolute_path>/<program>
+ return $command if ($command ne 'my_print_defaults' && -f $command &&
+ -x $command);
+
@paths = split(':', $ENV{'PATH'});
foreach $path (@paths)
{
diff --git a/sql-common/client.c b/sql-common/client.c
index 09548cb58a7..c2e0cc3161a 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1197,6 +1197,20 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
my_free((OPTS)->extension->X); \
EXTENSION_SET(OPTS, X, my_strdup((STR), MYF(MY_WME)));
+#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
+static char *set_ssl_option_unpack_path(const char *arg)
+{
+ char *opt_var= NULL;
+ if (arg)
+ {
+ char buff[FN_REFLEN + 1];
+ unpack_filename(buff, (char *)arg);
+ opt_var= my_strdup(buff, MYF(MY_WME));
+ }
+ return opt_var;
+}
+#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
+
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group)
{
@@ -1796,10 +1810,10 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
my_free(mysql->options.ssl_ca);
my_free(mysql->options.ssl_capath);
my_free(mysql->options.ssl_cipher);
- mysql->options.ssl_key= strdup_if_not_null(key);
- mysql->options.ssl_cert= strdup_if_not_null(cert);
- mysql->options.ssl_ca= strdup_if_not_null(ca);
- mysql->options.ssl_capath= strdup_if_not_null(capath);
+ mysql->options.ssl_key= set_ssl_option_unpack_path(key);
+ mysql->options.ssl_cert= set_ssl_option_unpack_path(cert);
+ mysql->options.ssl_ca= set_ssl_option_unpack_path(ca);
+ mysql->options.ssl_capath= set_ssl_option_unpack_path(capath);
mysql->options.ssl_cipher= strdup_if_not_null(cipher);
mysql->options.use_ssl= TRUE;
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
diff --git a/sql/field.cc b/sql/field.cc
index ceea0893a3f..a0686fb2f19 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1701,6 +1701,7 @@ Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
if (charset_arg->state & MY_CS_BINSORT)
flags|=BINARY_FLAG;
field_derivation= DERIVATION_IMPLICIT;
+ field_repertoire= my_charset_repertoire(charset_arg);
}
diff --git a/sql/field.h b/sql/field.h
index f761aa8d3ea..f8fc7427618 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -580,11 +580,12 @@ public:
{ return binary() ? &my_charset_bin : charset(); }
virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
virtual bool has_charset(void) const { return FALSE; }
- virtual void set_charset(CHARSET_INFO *charset_arg) { }
virtual enum Derivation derivation(void) const
{ return DERIVATION_IMPLICIT; }
virtual uint repertoire(void) const { return MY_REPERTOIRE_UNICODE30; }
- virtual void set_derivation(enum Derivation derivation_arg) { }
+ virtual void set_derivation(enum Derivation derivation_arg,
+ uint repertoire_arg)
+ { }
virtual int set_time() { return 1; }
void set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
int cuted_increment);
@@ -775,8 +776,10 @@ public:
class Field_str :public Field {
protected:
+ // TODO-10.2: Reuse DTCollation instead of these three members
CHARSET_INFO *field_charset;
enum Derivation field_derivation;
+ uint field_repertoire;
public:
Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
@@ -799,15 +802,15 @@ public:
int store_decimal(const my_decimal *);
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
uint size_of() const { return sizeof(*this); }
- uint repertoire(void) const
- {
- return my_charset_repertoire(field_charset);
- }
+ uint repertoire(void) const { return field_repertoire; }
CHARSET_INFO *charset(void) const { return field_charset; }
- void set_charset(CHARSET_INFO *charset_arg) { field_charset= charset_arg; }
enum Derivation derivation(void) const { return field_derivation; }
- virtual void set_derivation(enum Derivation derivation_arg)
- { field_derivation= derivation_arg; }
+ void set_derivation(enum Derivation derivation_arg,
+ uint repertoire_arg)
+ {
+ field_derivation= derivation_arg;
+ field_repertoire= repertoire_arg;
+ }
bool binary() const { return field_charset == &my_charset_bin; }
uint32 max_display_length() { return field_length; }
friend class Create_field;
@@ -1851,10 +1854,9 @@ public:
packlength= 4;
if (set_packlength)
{
- uint32 l_char_length= len_arg/cs->mbmaxlen;
- packlength= l_char_length <= 255 ? 1 :
- l_char_length <= 65535 ? 2 :
- l_char_length <= 16777215 ? 3 : 4;
+ packlength= len_arg <= 255 ? 1 :
+ len_arg <= 65535 ? 2 :
+ len_arg <= 16777215 ? 3 : 4;
}
}
Field_blob(uint32 packlength_arg)
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index c37f4f145cf..3a3273d279b 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -310,6 +310,7 @@ void print_find_structs()
add_structs_to_map(root_by_len,max_len);
set_links(root_by_len,max_len);
print_hash_map("sql_functions_map");
+ free(hash_map);
hash_map= 0;
size_hash_map= 0;
@@ -319,6 +320,7 @@ void print_find_structs()
add_structs_to_map(root_by_len2,max_len2);
set_links(root_by_len2,max_len2);
print_hash_map("symbols_map");
+ free(hash_map);
}
diff --git a/sql/item.cc b/sql/item.cc
index 3d339334b0d..5861766371c 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -244,9 +244,6 @@ bool Item::val_bool()
*/
String *Item::val_str_ascii(String *str)
{
- if (!(collation.collation->state & MY_CS_NONASCII))
- return val_str(str);
-
DBUG_ASSERT(str != &str_value);
uint errors;
@@ -254,11 +251,15 @@ String *Item::val_str_ascii(String *str)
if (!res)
return 0;
- if ((null_value= str->copy(res->ptr(), res->length(),
- collation.collation, &my_charset_latin1,
- &errors)))
- return 0;
-
+ if (!(res->charset()->state & MY_CS_NONASCII))
+ str= res;
+ else
+ {
+ if ((null_value= str->copy(res->ptr(), res->length(), collation.collation,
+ &my_charset_latin1, &errors)))
+ return 0;
+ }
+
return str;
}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index fb75c9af794..3bd0b5b3fa2 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -160,10 +160,11 @@ static int cmp_row_type(Item* item1, Item* item2)
static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
{
- uint i;
+ uint unsigned_count= items[0]->unsigned_flag;
type[0]= items[0]->cmp_type();
- for (i= 1 ; i < nitems ; i++)
+ for (uint i= 1 ; i < nitems ; i++)
{
+ unsigned_count+= items[i]->unsigned_flag;
type[0]= item_cmp_type(type[0], items[i]->cmp_type());
/*
When aggregating types of two row expressions we have to check
@@ -175,6 +176,12 @@ static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
if (type[0] == ROW_RESULT && cmp_row_type(items[0], items[i]))
return 1; // error found: invalid usage of rows
}
+ /**
+ If all arguments are of INT type but have different unsigned_flag values,
+ switch to DECIMAL_RESULT.
+ */
+ if (type[0] == INT_RESULT && unsigned_count != nitems && unsigned_count != 0)
+ type[0]= DECIMAL_RESULT;
return 0;
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e0e1f1d94e2..5cabfe7a0ca 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2951,12 +2951,13 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
}
unpack_time(min_max, ltime);
- if (compare_as_dates->field_type() == MYSQL_TYPE_DATE)
+ enum_field_types ftype= compare_as_dates->field_type();
+ if (ftype == MYSQL_TYPE_DATE || ftype == MYSQL_TYPE_NEWDATE)
{
ltime->time_type= MYSQL_TIMESTAMP_DATE;
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
}
- else if (compare_as_dates->field_type() == MYSQL_TYPE_TIME)
+ else if (ftype == MYSQL_TYPE_TIME)
{
ltime->time_type= MYSQL_TIMESTAMP_TIME;
ltime->hour+= (ltime->month * 32 + ltime->day) * 24;
@@ -6378,6 +6379,8 @@ bool Item_func_match::fix_index()
for (i=1; i < arg_count; i++)
{
+ if (args[i]->type() != FIELD_ITEM)
+ goto err;
item=(Item_field*)args[i];
for (keynr=0 ; keynr < fts ; keynr++)
{
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 8815dace9af..131b54bef8e 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2003-2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc.
- Use is subject to license terms.
+/* Copyright (c) 2003, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2011, 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
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 873dcdac4b9..28e93683422 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -935,9 +935,8 @@ void Item_func_monthname::fix_length_and_dec()
{
THD* thd= current_thd;
CHARSET_INFO *cs= thd->variables.collation_connection;
- uint32 repertoire= my_charset_repertoire(cs);
locale= thd->variables.lc_time_names;
- collation.set(cs, DERIVATION_COERCIBLE, repertoire);
+ collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
maybe_null=1;
@@ -1082,9 +1081,8 @@ void Item_func_dayname::fix_length_and_dec()
{
THD* thd= current_thd;
CHARSET_INFO *cs= thd->variables.collation_connection;
- uint32 repertoire= my_charset_repertoire(cs);
locale= thd->variables.lc_time_names;
- collation.set(cs, DERIVATION_COERCIBLE, repertoire);
+ collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
maybe_null=1;
diff --git a/sql/lex.h b/sql/lex.h
index 65411402f6a..aec2ec29dca 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -46,12 +46,9 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
static SYMBOL symbols[] = {
{ "&&", SYM(AND_AND_SYM)},
- { "<", SYM(LT)},
{ "<=", SYM(LE)},
{ "<>", SYM(NE)},
{ "!=", SYM(NE)},
- { "=", SYM(EQ)},
- { ">", SYM(GT_SYM)},
{ ">=", SYM(GE)},
{ "<<", SYM(SHIFT_LEFT)},
{ ">>", SYM(SHIFT_RIGHT)},
diff --git a/sql/log.cc b/sql/log.cc
index 9194838d424..02915fb1325 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
This program is free software; you can redistribute it and/or modify
diff --git a/sql/log.h b/sql/log.h
index 4abefc55b90..419a64227e4 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2005, 2012, Oracle and/or its affiliates.
- Copyright (c) 2009, 2012, Monty Program Ab
+/* Copyright (c) 2005, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2016, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/sql/log_event.cc b/sql/log_event.cc
index f71b245b942..cd6b780cb0e 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
This program is free software; you can redistribute it and/or modify
@@ -8488,9 +8488,6 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
-
- We can use a down cast here since we know that every table added
- to the tables_to_lock is a RPL_TABLE_LIST.
*/
{
@@ -8509,10 +8506,37 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
NOTE: The base tables are added here are removed when
close_thread_tables is called.
*/
- RPL_TABLE_LIST *ptr= rli->tables_to_lock;
- for (uint i= 0 ; ptr && (i < rli->tables_to_lock_count);
- ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
+ TABLE_LIST *table_list_ptr= rli->tables_to_lock;
+ for (uint i=0 ; table_list_ptr && (i < rli->tables_to_lock_count);
+ table_list_ptr= table_list_ptr->next_global, i++)
{
+ /*
+ Below if condition takes care of skipping base tables that
+ make up the MERGE table (which are added by open_tables()
+ call). They are added next to the merge table in the list.
+ For eg: If RPL_TABLE_LIST is t3->t1->t2 (where t1 and t2
+ are base tables for merge table 't3'), open_tables will modify
+ the list by adding t1 and t2 again immediately after t3 in the
+ list (*not at the end of the list*). New table_to_lock list will
+ look like t3->t1'->t2'->t1->t2 (where t1' and t2' are TABLE_LIST
+ objects added by open_tables() call). There is no flag(or logic) in
+ open_tables() that can skip adding these base tables to the list.
+ So the logic here should take care of skipping them.
+
+ tables_to_lock_count logic will take care of skipping base tables
+ that are added at the end of the list.
+ For eg: If RPL_TABLE_LIST is t1->t2->t3, open_tables will modify
+ the list into t1->t2->t3->t1'->t2'. t1' and t2' will be skipped
+ because tables_to_lock_count logic in this for loop.
+ */
+ if (table_list_ptr->parent_l)
+ continue;
+ /*
+ We can use a down cast here since we know that every table added
+ to the tables_to_lock is a RPL_TABLE_LIST (or child table which is
+ skipped above).
+ */
+ RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(table_list_ptr);
DBUG_ASSERT(ptr->m_tabledef_valid);
TABLE *conv_table;
if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
@@ -8553,7 +8577,15 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
*/
TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i=0 ; ptr && (i < rli->tables_to_lock_count); ptr= ptr->next_global, i++)
+ {
+ /*
+ Please see comment in above 'for' loop to know the reason
+ for this if condition
+ */
+ if (ptr->parent_l)
+ continue;
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
+ }
#ifdef HAVE_QUERY_CACHE
#ifdef WITH_WSREP
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 70b3ec12356..51fcf902f77 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
+/* Copyright (c) 2007, 2016, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -119,16 +119,25 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
-
- We can use a down cast here since we know that every table added
- to the tables_to_lock is a RPL_TABLE_LIST.
*/
{
- RPL_TABLE_LIST *ptr= rli->tables_to_lock;
- for (uint i= 0 ; ptr&& (i< rli->tables_to_lock_count);
- ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
+ TABLE_LIST *table_list_ptr= rli->tables_to_lock;
+ for (uint i=0 ; table_list_ptr&& (i< rli->tables_to_lock_count);
+ table_list_ptr= table_list_ptr->next_global, i++)
{
+ /*
+ Please see comment in log_event.cc-Rows_log_event::do_apply_event()
+ function for the explanation of the below if condition
+ */
+ if (table_list_ptr->parent_l)
+ continue;
+ /*
+ We can use a down cast here since we know that every table added
+ to the tables_to_lock is a RPL_TABLE_LIST(or child table which is
+ skipped above).
+ */
+ RPL_TABLE_LIST *ptr=static_cast<RPL_TABLE_LIST*>(table_list_ptr);
DBUG_ASSERT(ptr->m_tabledef_valid);
TABLE *conv_table;
if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
@@ -162,7 +171,15 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
*/
TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i=0; ptr && (i < rli->tables_to_lock_count); ptr= ptr->next_global, i++)
+ {
+ /*
+ Please see comment in log_event.cc-Rows_log_event::do_apply_event()
+ function for the explanation of the below if condition
+ */
+ if (ptr->parent_l)
+ continue;
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
+ }
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
@@ -1545,16 +1562,25 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
-
- We can use a down cast here since we know that every table added
- to the tables_to_lock is a RPL_TABLE_LIST.
*/
{
- RPL_TABLE_LIST *ptr= rli->tables_to_lock;
- for (uint i= 0 ; ptr&& (i< rli->tables_to_lock_count);
- ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
+ TABLE_LIST *table_list_ptr= rli->tables_to_lock;
+ for (uint i=0; table_list_ptr&& (i< rli->tables_to_lock_count);
+ table_list_ptr= static_cast<RPL_TABLE_LIST*>(table_list_ptr->next_global), i++)
{
+ /*
+ Please see comment in log_event.cc-Rows_log_event::do_apply_event()
+ function for the explanation of the below if condition
+ */
+ if (table_list_ptr->parent_l)
+ continue;
+ /*
+ We can use a down cast here since we know that every table added
+ to the tables_to_lock is a RPL_TABLE_LIST (or child table which is
+ skipped above).
+ */
+ RPL_TABLE_LIST *ptr=static_cast<RPL_TABLE_LIST*>(table_list_ptr);
TABLE *conv_table;
if (ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
ptr->table, &conv_table))
diff --git a/sql/slave.cc b/sql/slave.cc
index 4636cb330e5..f472825b0a9 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2015, SkySQL Ab.
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2009, 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
diff --git a/sql/slave.h b/sql/slave.h
index c220f881619..ae70f0194fa 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -1,5 +1,5 @@
-/*
- Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2009, 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
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 2cd627a2a32..019e9d9a478 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2002, 2013, Oracle and/or its affiliates.
- Copyright (c) 2011, 2013, Monty Program Ab
+ Copyright (c) 2002, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2011, 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
@@ -480,8 +480,10 @@ sp_name::init_qname(THD *thd)
bool
check_routine_name(LEX_STRING *ident)
{
- if (!ident || !ident->str || !ident->str[0] ||
- ident->str[ident->length-1] == ' ')
+ DBUG_ASSERT(ident);
+ DBUG_ASSERT(ident->str);
+
+ if (!ident->str[0] || ident->str[ident->length-1] == ' ')
{
my_error(ER_SP_WRONG_NAME, MYF(0), ident->str);
return TRUE;
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 44ad0d42d47..b7cdda993d6 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1106,7 +1106,8 @@ void end_connection(THD *thd)
}
if (!thd->killed && (net->error && net->vio != 0))
- thd->print_aborted_warning(1, ER(ER_UNKNOWN_ERROR));
+ thd->print_aborted_warning(1,
+ thd->stmt_da->is_error() ? thd->stmt_da->message() : ER(ER_UNKNOWN_ERROR));
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 2d7926017c2..a6e583e5815 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1452,32 +1452,35 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
return (BIN_NUM);
case MY_LEX_CMP_OP: // Incomplete comparison operator
+ lip->next_state= MY_LEX_START; // Allow signed numbers
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
- lip->yySkip();
- if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
{
- lip->next_state= MY_LEX_START; // Allow signed numbers
- return(tokval);
+ lip->yySkip();
+ if ((tokval= find_keyword(lip, 2, 0)))
+ return(tokval);
+ lip->yyUnget();
}
- state = MY_LEX_CHAR; // Something fishy found
- break;
+ return(c);
case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator
+ lip->next_state= MY_LEX_START;
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
{
lip->yySkip();
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP)
+ {
lip->yySkip();
+ if ((tokval= find_keyword(lip, 3, 0)))
+ return(tokval);
+ lip->yyUnget();
+ }
+ if ((tokval= find_keyword(lip, 2, 0)))
+ return(tokval);
+ lip->yyUnget();
}
- if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
- {
- lip->next_state= MY_LEX_START; // Found long op
- return(tokval);
- }
- state = MY_LEX_CHAR; // Something fishy found
- break;
+ return(c);
case MY_LEX_BOOL:
if (c != lip->yyPeek())
diff --git a/sql/sql_locale.h b/sql/sql_locale.h
index 8357a9ecba4..8559bb55cd9 100644
--- a/sql/sql_locale.h
+++ b/sql/sql_locale.h
@@ -61,6 +61,8 @@ public:
grouping(grouping_par),
errmsgs(errmsgs_par)
{}
+ uint repertoire() const
+ { return is_ascii ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_EXTENDED; }
};
/* Exported variables */
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 885a5a2f42a..48addaab143 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5891,6 +5891,7 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
temporary table flag)
@param alter_info [in] Initial list of columns and indexes for the
table to be created
+ @param create_db [in] Database of the created table
@retval
false ok.
@@ -5899,7 +5900,8 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
*/
bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info,
- Alter_info *alter_info)
+ Alter_info *alter_info,
+ const char* create_db)
{
Key *key;
List_iterator<Key> key_iterator(alter_info->key_list);
@@ -5939,10 +5941,28 @@ bool check_fk_parent_table_access(THD *thd,
return true;
}
}
- else if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
- return true;
else
- is_qualified_table_name= false;
+ {
+ if (!thd->db)
+ {
+ db_name.str= (char *) thd->memdup(create_db, strlen(create_db)+1);
+ db_name.length= strlen(create_db);
+ is_qualified_table_name= true;
+
+ if(create_db && check_db_name(&db_name))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
+ return true;
+ }
+ }
+ else
+ {
+ if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
+ return true;
+ else
+ is_qualified_table_name= false;
+ }
+ }
// if lower_case_table_names is set then convert tablename to lower case.
if (lower_case_table_names)
@@ -8081,7 +8101,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
goto err;
}
- if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info))
+ if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info, create_table->db))
goto err;
error= FALSE;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index a00a1eaa192..d9d9cd412a1 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -47,7 +47,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table);
bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info,
- Alter_info *alter_info);
+ Alter_info *alter_info,
+ const char* create_db);
bool parse_sql(THD *thd,
Parser_state *parser_state,
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index dfeb544c8ed..24116238cda 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -1,4 +1,5 @@
-/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2011, 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
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 91aecadfd0a..613cbb2e086 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14586,7 +14586,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->collation.collation);
else
new_field= item->make_string_field(table);
- new_field->set_derivation(item->collation.derivation);
+ new_field->set_derivation(item->collation.derivation,
+ item->collation.repertoire);
break;
case DECIMAL_RESULT:
new_field= Field_new_decimal::create_from_item(item);
@@ -14825,7 +14826,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
modify_item, convert_blob_length);
case Item::TYPE_HOLDER:
result= ((Item_type_holder *)item)->make_field_by_type(table);
- result->set_derivation(item->collation.derivation);
+ result->set_derivation(item->collation.derivation,
+ item->collation.repertoire);
return result;
default: // Dosen't have to be stored
return 0;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 95c34ec2760..d5e3c1de124 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6365,7 +6365,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
till this point for the alter operation.
*/
if ((alter_info->flags & ALTER_FOREIGN_KEY) &&
- check_fk_parent_table_access(thd, create_info, alter_info))
+ check_fk_parent_table_access(thd, create_info, alter_info, new_db))
goto err;
/*
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 3b42fe1e74a..1adf3ce430b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -970,7 +970,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token ENGINES_SYM
%token ENGINE_SYM
%token ENUM
-%token EQ /* OPERATOR */
%token EQUAL_SYM /* OPERATOR */
%token ERROR_SYM
%token ERRORS
@@ -1016,7 +1015,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token GRANTS
%token GROUP_SYM /* SQL-2003-R */
%token GROUP_CONCAT_SYM
-%token GT_SYM /* OPERATOR */
%token HANDLER_SYM
%token HARD_SYM
%token HASH_SYM
@@ -1095,7 +1093,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token LONG_SYM
%token LOOP_SYM
%token LOW_PRIORITY
-%token LT /* OPERATOR */
%token MASTER_CONNECT_RETRY_SYM
%token MASTER_HOST_SYM
%token MASTER_LOG_FILE_SYM
@@ -1439,7 +1436,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%left XOR
%left AND_SYM AND_AND_SYM
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
-%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM
+%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM
%left '|'
%left '&'
%left SHIFT_LEFT SHIFT_RIGHT
@@ -1922,58 +1919,58 @@ master_defs:
;
master_def:
- MASTER_HOST_SYM EQ TEXT_STRING_sys
+ MASTER_HOST_SYM '=' TEXT_STRING_sys
{
Lex->mi.host = $3.str;
}
- | MASTER_USER_SYM EQ TEXT_STRING_sys
+ | MASTER_USER_SYM '=' TEXT_STRING_sys
{
Lex->mi.user = $3.str;
}
- | MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
+ | MASTER_PASSWORD_SYM '=' TEXT_STRING_sys
{
Lex->mi.password = $3.str;
}
- | MASTER_PORT_SYM EQ ulong_num
+ | MASTER_PORT_SYM '=' ulong_num
{
Lex->mi.port = $3;
}
- | MASTER_CONNECT_RETRY_SYM EQ ulong_num
+ | MASTER_CONNECT_RETRY_SYM '=' ulong_num
{
Lex->mi.connect_retry = $3;
}
- | MASTER_SSL_SYM EQ ulong_num
+ | MASTER_SSL_SYM '=' ulong_num
{
Lex->mi.ssl= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
- | MASTER_SSL_CA_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_CA_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_ca= $3.str;
}
- | MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_CAPATH_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_capath= $3.str;
}
- | MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_CERT_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_cert= $3.str;
}
- | MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_CIPHER_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_cipher= $3.str;
}
- | MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_KEY_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_key= $3.str;
}
- | MASTER_SSL_VERIFY_SERVER_CERT_SYM EQ ulong_num
+ | MASTER_SSL_VERIFY_SERVER_CERT_SYM '=' ulong_num
{
Lex->mi.ssl_verify_server_cert= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
- | MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
+ | MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal
{
Lex->mi.heartbeat_period= (float) $3->val_real();
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
@@ -2004,7 +2001,7 @@ master_def:
}
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
- | IGNORE_SERVER_IDS_SYM EQ '(' ignore_server_id_list ')'
+ | IGNORE_SERVER_IDS_SYM '=' '(' ignore_server_id_list ')'
{
Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
@@ -2025,11 +2022,11 @@ ignore_server_id:
}
master_file_def:
- MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
+ MASTER_LOG_FILE_SYM '=' TEXT_STRING_sys
{
Lex->mi.log_file_name = $3.str;
}
- | MASTER_LOG_POS_SYM EQ ulonglong_num
+ | MASTER_LOG_POS_SYM '=' ulonglong_num
{
Lex->mi.pos = $3;
/*
@@ -2045,11 +2042,11 @@ master_file_def:
*/
Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
}
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
+ | RELAY_LOG_FILE_SYM '=' TEXT_STRING_sys
{
Lex->mi.relay_log_name = $3.str;
}
- | RELAY_LOG_POS_SYM EQ ulong_num
+ | RELAY_LOG_POS_SYM '=' ulong_num
{
Lex->mi.relay_log_pos = $3;
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
@@ -3032,7 +3029,7 @@ opt_set_signal_information:
;
signal_information_item_list:
- signal_condition_information_item_name EQ signal_allowed_expr
+ signal_condition_information_item_name '=' signal_allowed_expr
{
Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info;
@@ -3041,7 +3038,7 @@ signal_information_item_list:
info->m_item[index]= $3;
}
| signal_information_item_list ','
- signal_condition_information_item_name EQ signal_allowed_expr
+ signal_condition_information_item_name '=' signal_allowed_expr
{
Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info;
@@ -4439,7 +4436,7 @@ opt_linear:
opt_key_algo:
/* empty */
{ Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;}
- | ALGORITHM_SYM EQ real_ulong_num
+ | ALGORITHM_SYM '=' real_ulong_num
{
switch ($3) {
case 1:
@@ -7082,7 +7079,7 @@ opt_place:
opt_to:
/* empty */ {}
| TO_SYM {}
- | EQ {}
+ | '=' {}
| AS {}
;
@@ -7949,13 +7946,13 @@ bool_pri:
if ($$ == NULL)
MYSQL_YYABORT;
}
- | bool_pri comp_op predicate %prec EQ
+ | bool_pri comp_op predicate %prec '='
{
$$= (*$2)(0)->create($1,$3);
if ($$ == NULL)
MYSQL_YYABORT;
}
- | bool_pri comp_op all_or_any '(' subselect ')' %prec EQ
+ | bool_pri comp_op all_or_any '(' subselect ')' %prec '='
{
$$= all_any_subquery_creator($1, $2, $3, $5);
if ($$ == NULL)
@@ -8178,11 +8175,11 @@ not2:
;
comp_op:
- EQ { $$ = &comp_eq_creator; }
+ '=' { $$ = &comp_eq_creator; }
| GE { $$ = &comp_ge_creator; }
- | GT_SYM { $$ = &comp_gt_creator; }
+ | '>' { $$ = &comp_gt_creator; }
| LE { $$ = &comp_le_creator; }
- | LT { $$ = &comp_lt_creator; }
+ | '<' { $$ = &comp_lt_creator; }
| NE { $$ = &comp_ne_creator; }
;
@@ -10203,7 +10200,7 @@ date_time_type:
table_alias:
/* empty */
| AS
- | EQ
+ | '='
;
opt_table_alias:
@@ -11106,7 +11103,7 @@ ident_eq_value:
;
equal:
- EQ {}
+ '=' {}
| SET_VAR {}
;
@@ -13974,11 +13971,11 @@ handler_rkey_function:
;
handler_rkey_mode:
- EQ { $$=HA_READ_KEY_EXACT; }
+ '=' { $$=HA_READ_KEY_EXACT; }
| GE { $$=HA_READ_KEY_OR_NEXT; }
| LE { $$=HA_READ_KEY_OR_PREV; }
- | GT_SYM { $$=HA_READ_AFTER_KEY; }
- | LT { $$=HA_READ_BEFORE_KEY; }
+ | '>' { $$=HA_READ_AFTER_KEY; }
+ | '<' { $$=HA_READ_BEFORE_KEY; }
;
/* GRANT / REVOKE */
@@ -14750,7 +14747,7 @@ no_definer:
;
definer:
- DEFINER_SYM EQ user
+ DEFINER_SYM '=' user
{
thd->lex->definer= get_current_user(thd, $3);
}
@@ -14777,11 +14774,11 @@ view_replace:
;
view_algorithm:
- ALGORITHM_SYM EQ UNDEFINED_SYM
+ ALGORITHM_SYM '=' UNDEFINED_SYM
{ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
- | ALGORITHM_SYM EQ MERGE_SYM
+ | ALGORITHM_SYM '=' MERGE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
- | ALGORITHM_SYM EQ TEMPTABLE_SYM
+ | ALGORITHM_SYM '=' TEMPTABLE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
;
diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc
index df1a05b3ebf..6075c758e40 100644
--- a/sql/threadpool_unix.cc
+++ b/sql/threadpool_unix.cc
@@ -166,6 +166,7 @@ struct pool_timer_t
volatile uint64 next_timeout_check;
int tick_interval;
bool shutdown;
+ pthread_t timer_thread_id;
};
static pool_timer_t pool_timer;
@@ -603,12 +604,12 @@ void check_stall(thread_group_t *thread_group)
static void start_timer(pool_timer_t* timer)
{
- pthread_t thread_id;
DBUG_ENTER("start_timer");
mysql_mutex_init(key_timer_mutex,&timer->mutex, NULL);
mysql_cond_init(key_timer_cond, &timer->cond, NULL);
timer->shutdown = false;
- mysql_thread_create(key_timer_thread,&thread_id, NULL, timer_thread, timer);
+ mysql_thread_create(key_timer_thread, &timer->timer_thread_id, NULL,
+ timer_thread, timer);
DBUG_VOID_RETURN;
}
@@ -620,6 +621,7 @@ static void stop_timer(pool_timer_t *timer)
timer->shutdown = true;
mysql_cond_signal(&timer->cond);
mysql_mutex_unlock(&timer->mutex);
+ pthread_join(timer->timer_thread_id, NULL);
DBUG_VOID_RETURN;
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 03385d374bf..28694c526b9 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -2163,7 +2163,6 @@ no_db_name:
A wrapper function of innobase_convert_name(), convert a table or
index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
@return pointer to the end of buf */
-static inline
void
innobase_format_name(
/*==================*/
@@ -9746,6 +9745,36 @@ ha_innobase::check(
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
+ if (prebuilt->table->corrupted) {
+ char index_name[MAX_FULL_NAME_LEN + 1];
+ /* If some previous operation has marked the table as
+ corrupted in memory, and has not propagated such to
+ clustered index, we will do so here */
+ index = dict_table_get_first_index(prebuilt->table);
+
+ if (!dict_index_is_corrupted(index)) {
+ row_mysql_lock_data_dictionary(prebuilt->trx);
+ dict_set_corrupted(index);
+ row_mysql_unlock_data_dictionary(prebuilt->trx);
+ }
+
+ innobase_format_name(index_name, sizeof index_name,
+ index->name, TRUE);
+
+ push_warning_printf(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ HA_ERR_INDEX_CORRUPT,
+ "InnoDB: Index %s is marked as"
+ " corrupted",
+ index_name);
+
+ /* Now that the table is already marked as corrupted,
+ there is no need to check any index of this table */
+ prebuilt->trx->op_info = "";
+
+ DBUG_RETURN(HA_ADMIN_CORRUPT);
+ }
+
prebuilt->trx->op_info = "checking table";
old_isolation_level = prebuilt->trx->isolation_level;
@@ -9822,6 +9851,15 @@ ha_innobase::check(
prebuilt->index_usable = row_merge_is_index_usable(
prebuilt->trx, prebuilt->index);
+ DBUG_EXECUTE_IF(
+ "dict_set_index_corrupted",
+ if (!dict_index_is_clust(index)) {
+ prebuilt->index_usable = FALSE;
+ row_mysql_lock_data_dictionary(prebuilt->trx);
+ dict_set_corrupted(index);
+ row_mysql_unlock_data_dictionary(prebuilt->trx);
+ });
+
if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
innobase_format_name(
index_name, sizeof index_name,
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 9afa840f8d8..9f0a0958912 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -658,6 +658,19 @@ public:
~ha_innobase_add_index() {}
};
+
+/*****************************************************************//**
+A wrapper function of innobase_convert_name(), convert a table or
+index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
+@return pointer to the end of buf */
+void
+innobase_format_name(
+/*==================*/
+ char* buf, /*!< out: buffer for converted identifier */
+ ulint buflen, /*!< in: length of buf, in bytes */
+ const char* name, /*!< in: index or table name to format */
+ ibool is_index_name); /*!< in: index name */
+
/*******************************************************************//**
Create indexes.
@return 0 or error number */
@@ -719,6 +732,28 @@ ha_innobase::add_index(
DBUG_RETURN(-1);
}
+ /* Check if any of the existing indexes are marked as corruption,
+ and if they are, refuse adding more indexes. */
+ for (dict_index_t* check_index = dict_table_get_first_index(indexed_table);
+ check_index != NULL;
+ check_index = dict_table_get_next_index(check_index)) {
+
+ if (dict_index_is_corrupted(check_index)) {
+ char index_name[MAX_FULL_NAME_LEN + 1];
+
+ innobase_format_name(index_name, sizeof index_name,
+ check_index->name, TRUE);
+
+ push_warning_printf(user_thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ HA_ERR_INDEX_CORRUPT,
+ "InnoDB: Index %s is marked as"
+ " corrupted",
+ index_name);
+ DBUG_RETURN(HA_ERR_INDEX_CORRUPT);
+ }
+ }
+
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table);
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index 1e8adb64981..f01af164aa6 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -46,7 +46,7 @@ static mysql_mutex_t LOCK_checkpoint;
static mysql_cond_t COND_checkpoint;
/** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL checkpoint_control=
- {THREAD_DEAD, FALSE, &LOCK_checkpoint, &COND_checkpoint};
+ {0, FALSE, FALSE, &LOCK_checkpoint, &COND_checkpoint};
/* is ulong like pagecache->blocks_changed */
static ulong pages_to_flush_before_next_checkpoint;
static PAGECACHE_FILE *dfiles, /**< data files to flush in background */
@@ -326,7 +326,6 @@ end:
int ma_checkpoint_init(ulong interval)
{
- pthread_t th;
int res= 0;
DBUG_ENTER("ma_checkpoint_init");
if (ma_service_thread_control_init(&checkpoint_control))
@@ -334,14 +333,14 @@ int ma_checkpoint_init(ulong interval)
else if (interval > 0)
{
compile_time_assert(sizeof(void *) >= sizeof(ulong));
- if (!(res= mysql_thread_create(key_thread_checkpoint,
- &th, NULL, ma_checkpoint_background,
- (void *)interval)))
- {
- /* thread lives, will have to be killed */
- checkpoint_control.status= THREAD_RUNNING;
- }
+ if ((res= mysql_thread_create(key_thread_checkpoint,
+ &checkpoint_control.thread, NULL,
+ ma_checkpoint_background,
+ (void*) interval)))
+ checkpoint_control.killed= TRUE;
}
+ else
+ checkpoint_control.killed= TRUE;
DBUG_RETURN(res);
}
@@ -717,7 +716,6 @@ pthread_handler_t ma_checkpoint_background(void *arg)
DBUG_EXECUTE_IF("maria_checkpoint_indirect", level= CHECKPOINT_INDIRECT;);
ma_checkpoint_execute(level, FALSE);
}
- my_service_thread_signal_end(&checkpoint_control);
my_thread_end();
return 0;
}
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index 54f67eb1ab3..bf2205f5a4c 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -54,7 +54,7 @@ static mysql_mutex_t LOCK_soft_sync;
static mysql_cond_t COND_soft_sync;
/** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL soft_sync_control=
- {THREAD_DEAD, FALSE, &LOCK_soft_sync, &COND_soft_sync};
+ {0, FALSE, FALSE, &LOCK_soft_sync, &COND_soft_sync};
/* transaction log file descriptor */
@@ -8819,7 +8819,6 @@ ma_soft_sync_background( void *arg __attribute__((unused)))
if (my_service_thread_sleep(&soft_sync_control, sleep))
break;
}
- my_service_thread_signal_end(&soft_sync_control);
my_thread_end();
DBUG_RETURN(0);
}
@@ -8832,7 +8831,6 @@ ma_soft_sync_background( void *arg __attribute__((unused)))
int translog_soft_sync_start(void)
{
- pthread_t th;
int res= 0;
uint32 min, max;
DBUG_ENTER("translog_soft_sync_start");
@@ -8847,9 +8845,10 @@ int translog_soft_sync_start(void)
soft_need_sync= 1;
if (!(res= ma_service_thread_control_init(&soft_sync_control)))
- if (!(res= mysql_thread_create(key_thread_soft_sync,
- &th, NULL, ma_soft_sync_background, NULL)))
- soft_sync_control.status= THREAD_RUNNING;
+ if ((res= mysql_thread_create(key_thread_soft_sync,
+ &soft_sync_control.thread, NULL,
+ ma_soft_sync_background, NULL)))
+ soft_sync_control.killed= TRUE;
DBUG_RETURN(res);
}
diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c
index 6aaccea219f..1a791d43034 100644
--- a/storage/maria/ma_pagecache.c
+++ b/storage/maria/ma_pagecache.c
@@ -500,8 +500,8 @@ static void test_key_cache(PAGECACHE *pagecache,
const char *where, my_bool lock);
#endif
-#define PAGECACHE_HASH(p, f, pos) (((ulong) (pos) + \
- (ulong) (f).file) & (p->hash_entries-1))
+#define PAGECACHE_HASH(p, f, pos) (((size_t) (pos) + \
+ (size_t) (f).file) & (p->hash_entries-1))
#define FILE_HASH(f) ((uint) (f).file & (PAGECACHE_CHANGED_BLOCKS_HASH - 1))
#define DEFAULT_PAGECACHE_DEBUG_LOG "pagecache_debug.log"
@@ -639,10 +639,10 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache,
{
char buff[80];
uint len= my_sprintf(buff,
- (buff, "fwrite: fd: %d id: %u page: %lu",
+ (buff, "fwrite: fd: %d id: %u page: %llu",
filedesc->file,
_ma_file_callback_to_id(filedesc->callback_data),
- (ulong) pageno));
+ pageno));
(void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY,
(uchar*) buff, len);
}
@@ -741,11 +741,11 @@ static inline uint next_power(uint value)
*/
-ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
+size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
uint division_limit, uint age_threshold,
uint block_size, myf my_readwrite_flags)
{
- ulong blocks, hash_links, length;
+ size_t blocks, hash_links, length;
int error;
DBUG_ENTER("init_pagecache");
DBUG_ASSERT(block_size >= 512);
@@ -782,10 +782,10 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
DBUG_PRINT("info", ("block_size: %u", block_size));
DBUG_ASSERT(((uint)(1 << pagecache->shift)) == block_size);
- blocks= (ulong) (use_mem / (sizeof(PAGECACHE_BLOCK_LINK) +
+ blocks= use_mem / (sizeof(PAGECACHE_BLOCK_LINK) +
2 * sizeof(PAGECACHE_HASH_LINK) +
sizeof(PAGECACHE_HASH_LINK*) *
- 5/4 + block_size));
+ 5/4 + block_size);
/*
We need to support page cache with just one block to be able to do
scanning of rows-in-block files
@@ -816,7 +816,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
blocks--;
/* Allocate memory for cache page buffers */
if ((pagecache->block_mem=
- my_large_malloc((ulong) blocks * pagecache->block_size,
+ my_large_malloc(blocks * pagecache->block_size,
MYF(MY_WME))))
{
/*
@@ -824,7 +824,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
For each block 2 hash links are allocated
*/
if ((pagecache->block_root=
- (PAGECACHE_BLOCK_LINK*) my_malloc((size_t) length, MYF(0))))
+ (PAGECACHE_BLOCK_LINK*) my_malloc(length, MYF(0))))
break;
my_large_free(pagecache->block_mem);
pagecache->block_mem= 0;
@@ -832,7 +832,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
blocks= blocks / 4*3;
}
pagecache->blocks_unused= blocks;
- pagecache->disk_blocks= (long) blocks;
+ pagecache->disk_blocks= blocks;
pagecache->hash_links= hash_links;
pagecache->hash_root=
(PAGECACHE_HASH_LINK**) ((char*) pagecache->block_root +
@@ -887,7 +887,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
PAGECACHE_CHANGED_BLOCKS_HASH);
pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0;
- DBUG_RETURN((ulong) pagecache->disk_blocks);
+ DBUG_RETURN((size_t)pagecache->disk_blocks);
err:
error= my_errno;
@@ -978,11 +978,11 @@ static int flush_all_key_blocks(PAGECACHE *pagecache)
So we disable it for now.
*/
#if NOT_USED /* keep disabled until code is fixed see above !! */
-ulong resize_pagecache(PAGECACHE *pagecache,
+size_t resize_pagecache(PAGECACHE *pagecache,
size_t use_mem, uint division_limit,
uint age_threshold)
{
- ulong blocks;
+ size_t blocks;
struct st_my_thread_var *thread;
WQUEUE *wqueue;
@@ -1379,7 +1379,7 @@ static void link_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block,
("linked block: %u:%1u status: %x #requests: %u #available: %u",
PCBLOCK_NUMBER(pagecache, block), at_end, block->status,
block->requests, pagecache->blocks_available));
- KEYCACHE_DBUG_ASSERT((ulong) pagecache->blocks_available <=
+ KEYCACHE_DBUG_ASSERT(pagecache->blocks_available <=
pagecache->blocks_used);
#endif
DBUG_VOID_RETURN;
@@ -2018,7 +2018,7 @@ restart:
/* There are some never used blocks, take first of them */
block= &pagecache->block_root[pagecache->blocks_used];
block->buffer= ADD_TO_PTR(pagecache->block_mem,
- ((ulong) pagecache->blocks_used*
+ (pagecache->blocks_used*
pagecache->block_size),
uchar*);
pagecache->blocks_used++;
@@ -4870,7 +4870,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LSN *min_rec_lsn)
{
my_bool error= 0;
- ulong stored_list_size= 0;
+ size_t stored_list_size= 0;
uint file_hash;
char *ptr;
LSN minimum_rec_lsn= LSN_MAX;
diff --git a/storage/maria/ma_pagecache.h b/storage/maria/ma_pagecache.h
index 8460eaddc57..cb331bae74a 100644
--- a/storage/maria/ma_pagecache.h
+++ b/storage/maria/ma_pagecache.h
@@ -117,20 +117,20 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
typedef struct st_pagecache
{
size_t mem_size; /* specified size of the cache memory */
- ulong min_warm_blocks; /* min number of warm blocks; */
- ulong age_threshold; /* age threshold for hot blocks */
+ size_t min_warm_blocks; /* min number of warm blocks; */
+ size_t age_threshold; /* age threshold for hot blocks */
ulonglong time; /* total number of block link operations */
- ulong hash_entries; /* max number of entries in the hash table */
- long hash_links; /* max number of hash links */
- long hash_links_used; /* number of hash links taken from free links pool */
- long disk_blocks; /* max number of blocks in the cache */
- ulong blocks_used; /* maximum number of concurrently used blocks */
- ulong blocks_unused; /* number of currently unused blocks */
- ulong blocks_changed; /* number of currently dirty blocks */
- ulong warm_blocks; /* number of blocks in warm sub-chain */
- ulong cnt_for_resize_op; /* counter to block resize operation */
- ulong blocks_available; /* number of blocks available in the LRU chain */
- long blocks; /* max number of blocks in the cache */
+ size_t hash_entries; /* max number of entries in the hash table */
+ ssize_t hash_links; /* max number of hash links */
+ ssize_t hash_links_used; /* number of hash links taken from free links pool */
+ ssize_t disk_blocks; /* max number of blocks in the cache */
+ size_t blocks_used; /* maximum number of concurrently used blocks */
+ size_t blocks_unused; /* number of currently unused blocks */
+ size_t blocks_changed; /* number of currently dirty blocks */
+ size_t warm_blocks; /* number of blocks in warm sub-chain */
+ size_t cnt_for_resize_op; /* counter to block resize operation */
+ size_t blocks_available; /* number of blocks available in the LRU chain */
+ ssize_t blocks; /* max number of blocks in the cache */
uint32 block_size; /* size of the page buffer of a cache block */
PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */
PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */
@@ -155,12 +155,12 @@ typedef struct st_pagecache
*/
ulonglong param_buff_size; /* size the memory allocated for the cache */
- ulong param_block_size; /* size of the blocks in the key cache */
- ulong param_division_limit; /* min. percentage of warm blocks */
- ulong param_age_threshold; /* determines when hot block is downgraded */
+ size_t param_block_size; /* size of the blocks in the key cache */
+ size_t param_division_limit; /* min. percentage of warm blocks */
+ size_t param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables. These are reset in reset_pagecache_counters(). */
- ulong global_blocks_changed; /* number of currently dirty blocks */
+ size_t global_blocks_changed; /* number of currently dirty blocks */
ulonglong global_cache_w_requests;/* number of write requests (write hits) */
ulonglong global_cache_write; /* number of writes from cache to files */
ulonglong global_cache_r_requests;/* number of read requests (read hits) */
@@ -193,10 +193,10 @@ typedef enum pagecache_flush_filter_result
/* The default key cache */
extern PAGECACHE dflt_pagecache_var, *dflt_pagecache;
-extern ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
+extern size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
uint division_limit, uint age_threshold,
uint block_size, myf my_read_flags);
-extern ulong resize_pagecache(PAGECACHE *pagecache,
+extern size_t resize_pagecache(PAGECACHE *pagecache,
size_t use_mem, uint division_limit,
uint age_threshold);
extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit,
diff --git a/storage/maria/ma_servicethread.c b/storage/maria/ma_servicethread.c
index e5c949a7571..d92c5315933 100644
--- a/storage/maria/ma_servicethread.c
+++ b/storage/maria/ma_servicethread.c
@@ -33,7 +33,7 @@ int ma_service_thread_control_init(MA_SERVICE_THREAD_CONTROL *control)
DBUG_ENTER("ma_service_thread_control_init");
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
control->inited= TRUE;
- control->status= THREAD_DEAD; /* not yet born == dead */
+ control->killed= FALSE;
res= (mysql_mutex_init(key_SERVICE_THREAD_CONTROL_lock,
control->LOCK_control, MY_MUTEX_INIT_SLOW) ||
mysql_cond_init(key_SERVICE_THREAD_CONTROL_cond,
@@ -60,20 +60,17 @@ void ma_service_thread_control_end(MA_SERVICE_THREAD_CONTROL *control)
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
DBUG_ASSERT(control->inited);
mysql_mutex_lock(control->LOCK_control);
- if (control->status != THREAD_DEAD) /* thread was started OK */
+ if (!control->killed)
{
DBUG_PRINT("info",("killing Maria background thread"));
- control->status= THREAD_DYING; /* kill it */
- do /* and wait for it to be dead */
- {
- /* wake it up if it was in a sleep */
- mysql_cond_broadcast(control->COND_control);
- DBUG_PRINT("info",("waiting for Maria background thread to die"));
- mysql_cond_wait(control->COND_control, control->LOCK_control);
- }
- while (control->status != THREAD_DEAD);
+ control->killed= TRUE; /* kill it */
+ mysql_cond_broadcast(control->COND_control);
+ mysql_mutex_unlock(control->LOCK_control);
+ DBUG_PRINT("info", ("waiting for Maria background thread to die"));
+ pthread_join(control->thread, NULL);
}
- mysql_mutex_unlock(control->LOCK_control);
+ else
+ mysql_mutex_unlock(control->LOCK_control);
mysql_mutex_destroy(control->LOCK_control);
mysql_cond_destroy(control->COND_control);
control->inited= FALSE;
@@ -100,7 +97,7 @@ my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control,
DBUG_ENTER("my_service_thread_sleep");
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
mysql_mutex_lock(control->LOCK_control);
- if (control->status == THREAD_DYING)
+ if (control->killed)
{
mysql_mutex_unlock(control->LOCK_control);
DBUG_RETURN(TRUE);
@@ -119,34 +116,8 @@ my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control,
control->LOCK_control, &abstime);
}
#endif
- if (control->status == THREAD_DYING)
+ if (control->killed)
res= TRUE;
mysql_mutex_unlock(control->LOCK_control);
DBUG_RETURN(res);
}
-
-
-/**
- inform about thread exiting
-
- @param control control block
-*/
-
-void my_service_thread_signal_end(MA_SERVICE_THREAD_CONTROL *control)
-{
- DBUG_ENTER("my_service_thread_signal_end");
- DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
- mysql_mutex_lock(control->LOCK_control);
- control->status = THREAD_DEAD; /* indicate that we are dead */
- /*
- wake up ma_service_thread_control_end which may be waiting for
- our death
- */
- mysql_cond_broadcast(control->COND_control);
- /*
- broadcast was inside unlock because ma_service_thread_control_end
- destroys mutex
- */
- mysql_mutex_unlock(control->LOCK_control);
- DBUG_VOID_RETURN;
-}
diff --git a/storage/maria/ma_servicethread.h b/storage/maria/ma_servicethread.h
index ed578d93c24..254225bd608 100644
--- a/storage/maria/ma_servicethread.h
+++ b/storage/maria/ma_servicethread.h
@@ -16,12 +16,10 @@
#include <my_pthread.h>
-enum ma_service_thread_state {THREAD_RUNNING, THREAD_DYING, THREAD_DEAD};
-
typedef struct st_ma_service_thread_control
{
- /** 'kill' flag for the background thread */
- enum ma_service_thread_state status;
+ pthread_t thread;
+ my_bool killed;
/** if thread module was inited or not */
my_bool inited;
/** for killing the background thread */
@@ -35,4 +33,3 @@ int ma_service_thread_control_init(MA_SERVICE_THREAD_CONTROL *control);
void ma_service_thread_control_end(MA_SERVICE_THREAD_CONTROL *control);
my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control,
ulonglong sleep_time);
-void my_service_thread_signal_end(MA_SERVICE_THREAD_CONTROL *control);
diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c
index 95454d88308..a49ce8fba1f 100644
--- a/storage/maria/ma_sort.c
+++ b/storage/maria/ma_sort.c
@@ -87,6 +87,27 @@ static inline int
my_var_write(MARIA_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs);
/*
+ Sets the appropriate read and write methods for the MARIA_SORT_PARAM
+ based on the variable length key flag.
+*/
+static void set_sort_param_read_write(MARIA_SORT_PARAM *sort_param)
+{
+ if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
+ {
+ sort_param->write_keys= write_keys_varlen;
+ sort_param->read_to_buffer= read_to_buffer_varlen;
+ sort_param->write_key= write_merge_key_varlen;
+ }
+ else
+ {
+ sort_param->write_keys= write_keys;
+ sort_param->read_to_buffer= read_to_buffer;
+ sort_param->write_key= write_merge_key;
+ }
+}
+
+
+/*
Creates a index of sorted keys
SYNOPSIS
@@ -115,18 +136,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
(ulong) sortbuff_size, info->key_length,
(ulong) info->sort_info->max_records));
- if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
- {
- info->write_keys= write_keys_varlen;
- info->read_to_buffer=read_to_buffer_varlen;
- info->write_key=write_merge_key_varlen;
- }
- else
- {
- info->write_keys= write_keys;
- info->read_to_buffer=read_to_buffer;
- info->write_key=write_merge_key;
- }
+ set_sort_param_read_write(info);
my_b_clear(&tempfile);
my_b_clear(&tempfile_for_exceptions);
@@ -323,181 +333,182 @@ err:
} /* find_all_keys */
-/* Search after all keys and place them in a temp. file */
-
-pthread_handler_t _ma_thr_find_all_keys(void *arg)
+static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param)
{
- MARIA_SORT_PARAM *sort_param= (MARIA_SORT_PARAM*) arg;
- int error;
- size_t memavl,old_memavl;
+ int error= 0;
+ ulonglong memavl, old_memavl;
+ uint UNINIT_VAR(keys), idx;
uint sort_length;
- ulong idx, maxbuffer, keys;
- uchar **sort_keys=0;
-
- LINT_INIT(keys);
+ uint maxbuffer;
+ uchar **sort_keys= NULL;
+ DBUG_ENTER("_ma_thr_find_all_keys");
+ DBUG_PRINT("enter", ("master: %d", sort_param->master));
- error=1;
+ if (sort_param->sort_info->got_error)
+ DBUG_RETURN(TRUE);
- if (my_thread_init())
- goto err;
-
- { /* Add extra block since DBUG_ENTER declare variables */
- DBUG_ENTER("_ma_thr_find_all_keys");
- DBUG_PRINT("enter", ("master: %d", sort_param->master));
- if (sort_param->sort_info->got_error)
- goto err;
+ set_sort_param_read_write(sort_param);
- if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
- {
- sort_param->write_keys= write_keys_varlen;
- sort_param->read_to_buffer= read_to_buffer_varlen;
- sort_param->write_key= write_merge_key_varlen;
- }
- else
- {
- sort_param->write_keys= write_keys;
- sort_param->read_to_buffer= read_to_buffer;
- sort_param->write_key= write_merge_key;
- }
- my_b_clear(&sort_param->tempfile);
- my_b_clear(&sort_param->tempfile_for_exceptions);
- bzero((char*) &sort_param->buffpek,sizeof(sort_param->buffpek));
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
+ my_b_clear(&sort_param->tempfile);
+ my_b_clear(&sort_param->tempfile_for_exceptions);
+ bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek));
+ bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
+ memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
+ idx= sort_param->sort_info->max_records;
+ sort_length= sort_param->key_length;
+ maxbuffer= 1;
- while (memavl >= MIN_SORT_MEMORY)
+ while (memavl >= MIN_SORT_MEMORY)
+ {
+ if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl)
+ keys= idx+1;
+ else
{
- if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl)
- keys= idx+1;
- else
- {
- ulong skr;
- do
- {
- skr= maxbuffer;
- if (memavl < sizeof(BUFFPEK)*maxbuffer ||
- (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
- (sort_length+sizeof(char*))) <= 1 ||
- keys < maxbuffer)
- {
- _ma_check_print_error(sort_param->sort_info->param,
- "aria_sort_buffer_size is too small");
- goto err;
- }
- }
- while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
- }
- if ((sort_keys= (uchar **)
- my_malloc(keys*(sort_length+sizeof(char*))+
- ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
- HA_FT_MAXBYTELEN : 0), MYF(0))))
+ ulong skr;
+ do
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
- maxbuffer, maxbuffer/2))
+ skr= maxbuffer;
+ if (memavl < sizeof(BUFFPEK)*maxbuffer ||
+ (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
+ (sort_length+sizeof(char*))) <= 1 ||
+ keys < maxbuffer)
{
- my_free(sort_keys);
- sort_keys= (uchar **) NULL; /* for err: label */
+ _ma_check_print_error(sort_param->sort_info->param,
+ "aria_sort_buffer_size is too small.");
+ goto err;
}
- else
- break;
}
- old_memavl= memavl;
- if ((memavl= memavl/4*3) < MIN_SORT_MEMORY &&
- old_memavl > MIN_SORT_MEMORY)
- memavl= MIN_SORT_MEMORY;
+ while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
}
- if (memavl < MIN_SORT_MEMORY)
+ if ((sort_keys= (uchar **)
+ my_malloc(keys*(sort_length+sizeof(char*))+
+ ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
+ HA_FT_MAXBYTELEN : 0), MYF(0))))
{
- _ma_check_print_error(sort_param->sort_info->param,
- "Aria sort buffer too small");
- goto err; /* purecov: tested */
+ if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
+ maxbuffer, maxbuffer / 2))
+ {
+ my_free(sort_keys);
+ sort_keys= NULL; /* Safety against double free on error. */
+ }
+ else
+ break;
}
+ old_memavl= memavl;
+ if ((memavl= memavl/4*3) < MIN_SORT_MEMORY &&
+ old_memavl > MIN_SORT_MEMORY)
+ memavl= MIN_SORT_MEMORY;
+ }
- if (sort_param->sort_info->param->testflag & T_VERBOSE)
- printf("Key %d - Allocating buffer for %lu keys\n",
- sort_param->key+1, (ulong) keys);
- sort_param->sort_keys= sort_keys;
+ if (memavl < MIN_SORT_MEMORY)
+ {
+ /* purecov: begin inspected */
+ _ma_check_print_error(sort_param->sort_info->param,
+ "aria_sort_buffer_size is too small.");
+ my_errno= ENOMEM;
+ goto err;
+ /* purecov: end inspected */
+ }
- idx= error= 0;
- sort_keys[0]= (uchar*) (sort_keys+keys);
+ if (sort_param->sort_info->param->testflag & T_VERBOSE)
+ printf("Key %d - Allocating buffer for %llu keys\n",
+ sort_param->key + 1, (ulonglong) keys);
+ sort_param->sort_keys= sort_keys;
- DBUG_PRINT("info", ("reading keys"));
- while (!(error= sort_param->sort_info->got_error) &&
- !(error= (*sort_param->key_read)(sort_param, sort_keys[idx])))
- {
- if (sort_param->real_key_length > sort_param->key_length)
- {
- if (write_key(sort_param,sort_keys[idx],
- &sort_param->tempfile_for_exceptions))
- goto err;
- continue;
- }
+ idx= error= 0;
+ sort_keys[0]= (uchar*) (sort_keys+keys);
- if (++idx == keys)
- {
- if (sort_param->write_keys(sort_param, sort_keys, idx - 1,
- (BUFFPEK *)alloc_dynamic(&sort_param->
- buffpek),
- &sort_param->tempfile))
- goto err;
- sort_keys[0]= (uchar*) (sort_keys+keys);
- memcpy(sort_keys[0], sort_keys[idx - 1],
- (size_t) sort_param->key_length);
- idx= 1;
- }
- sort_keys[idx]=sort_keys[idx - 1] + sort_param->key_length;
+ DBUG_PRINT("info", ("reading keys"));
+ while (!(error= sort_param->sort_info->got_error) &&
+ !(error= (*sort_param->key_read)(sort_param, sort_keys[idx])))
+ {
+ if (sort_param->real_key_length > sort_param->key_length)
+ {
+ if (write_key(sort_param, sort_keys[idx],
+ &sort_param->tempfile_for_exceptions))
+ goto err;
+ continue;
}
- if (error > 0)
- goto err;
- if (sort_param->buffpek.elements)
+
+ if (++idx == keys)
{
- if (sort_param->write_keys(sort_param,sort_keys, idx,
- (BUFFPEK *) alloc_dynamic(&sort_param->
- buffpek),
+ if (sort_param->write_keys(sort_param, sort_keys, idx - 1,
+ (BUFFPEK *)alloc_dynamic(&sort_param->buffpek),
&sort_param->tempfile))
goto err;
- sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx;
+ sort_keys[0]= (uchar*) (sort_keys+keys);
+ memcpy(sort_keys[0], sort_keys[idx - 1], (size_t) sort_param->key_length);
+ idx= 1;
}
- else
- sort_param->keys= idx;
+ sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length;
+ }
+ if (error > 0)
+ goto err;
+ if (sort_param->buffpek.elements)
+ {
+ if (sort_param->write_keys(sort_param,sort_keys, idx,
+ (BUFFPEK *) alloc_dynamic(&sort_param->buffpek),
+ &sort_param->tempfile))
+ goto err;
+ sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx;
+ }
+ else
+ sort_param->keys= idx;
- sort_param->sort_keys_length= keys;
- goto ok;
+ sort_param->sort_keys_length= keys;
+ DBUG_RETURN(FALSE);
err:
- DBUG_PRINT("error", ("got some error"));
- sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */
- my_free(sort_keys);
- sort_param->sort_keys=0;
- delete_dynamic(& sort_param->buffpek);
- close_cached_file(&sort_param->tempfile);
- close_cached_file(&sort_param->tempfile_for_exceptions);
-
-ok:
- free_root(&sort_param->wordroot, MYF(0));
- /*
- Detach from the share if the writer is involved. Avoid others to
- be blocked. This includes a flush of the write buffer. This will
- also indicate EOF to the readers.
- */
- if (sort_param->sort_info->info->rec_cache.share)
- remove_io_thread(&sort_param->sort_info->info->rec_cache);
-
- /* Readers detach from the share if any. Avoid others to be blocked. */
- if (sort_param->read_cache.share)
- remove_io_thread(&sort_param->read_cache);
-
- mysql_mutex_lock(&sort_param->sort_info->mutex);
- if (!--sort_param->sort_info->threads_running)
- mysql_cond_signal(&sort_param->sort_info->cond);
- mysql_mutex_unlock(&sort_param->sort_info->mutex);
- DBUG_PRINT("exit", ("======== ending thread ========"));
- }
+ DBUG_PRINT("error", ("got some error"));
+ my_free(sort_keys);
+ sort_param->sort_keys= 0;
+ delete_dynamic(& sort_param->buffpek);
+ close_cached_file(&sort_param->tempfile);
+ close_cached_file(&sort_param->tempfile_for_exceptions);
+
+ DBUG_RETURN(TRUE);
+}
+
+/* Search after all keys and place them in a temp. file */
+
+pthread_handler_t _ma_thr_find_all_keys(void *arg)
+{
+ MARIA_SORT_PARAM *sort_param= (MARIA_SORT_PARAM*) arg;
+ my_bool error= FALSE;
+ /* If my_thread_init fails */
+ if (my_thread_init() || _ma_thr_find_all_keys_exec(sort_param))
+ error= TRUE;
+
+ /*
+ Thread must clean up after itself.
+ */
+ free_root(&sort_param->wordroot, MYF(0));
+ /*
+ Detach from the share if the writer is involved. Avoid others to
+ be blocked. This includes a flush of the write buffer. This will
+ also indicate EOF to the readers.
+ That means that a writer always gets here first and readers -
+ only when they see EOF. But if a reader finishes prematurely
+ because of an error it may reach this earlier - don't allow it
+ to detach the writer thread.
+ */
+ if (sort_param->master && sort_param->sort_info->info->rec_cache.share)
+ remove_io_thread(&sort_param->sort_info->info->rec_cache);
+
+ /* Readers detach from the share if any. Avoid others to be blocked. */
+ if (sort_param->read_cache.share)
+ remove_io_thread(&sort_param->read_cache);
+
+ mysql_mutex_lock(&sort_param->sort_info->mutex);
+ if (error)
+ sort_param->sort_info->got_error= 1;
+
+ if (!--sort_param->sort_info->threads_running)
+ mysql_cond_signal(&sort_param->sort_info->cond);
+ mysql_mutex_unlock(&sort_param->sort_info->mutex);
+
my_thread_end();
return NULL;
}
@@ -507,7 +518,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
{
MARIA_SORT_INFO *sort_info=sort_param->sort_info;
HA_CHECK *param=sort_info->param;
- ulong UNINIT_VAR(length), keys;
+ size_t UNINIT_VAR(length), keys;
double *rec_per_key_part= param->new_rec_per_key_part;
int got_error=sort_info->got_error;
uint i;
@@ -564,18 +575,9 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
{
if (got_error)
continue;
- if (sinfo->keyinfo->flag & HA_VAR_LENGTH_KEY)
- {
- sinfo->write_keys=write_keys_varlen;
- sinfo->read_to_buffer=read_to_buffer_varlen;
- sinfo->write_key=write_merge_key_varlen;
- }
- else
- {
- sinfo->write_keys=write_keys;
- sinfo->read_to_buffer=read_to_buffer;
- sinfo->write_key=write_merge_key;
- }
+
+ set_sort_param_read_write(sinfo);
+
if (sinfo->buffpek.elements)
{
uint maxbuffer=sinfo->buffpek.elements-1;
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index 983e0fba7f4..473cddee190 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -67,7 +67,8 @@ typedef struct st_maria_sort_info
pgcache_page_no_t page;
ha_rows max_records;
uint current_key, total_keys;
- uint got_error, threads_running;
+ volatile uint got_error;
+ uint threads_running;
myf myf_rw;
enum data_file_type new_data_file_type, org_data_file_type;
} MARIA_SORT_INFO;
diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index 2c4639b3143..ed9267a6f1f 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -84,6 +84,28 @@ static int write_merge_key_varlen(MI_SORT_PARAM *info,
static inline int
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs);
+
+/*
+ Sets the appropriate read and write methods for the MI_SORT_PARAM
+ based on the variable length key flag.
+*/
+static void set_sort_param_read_write(MI_SORT_PARAM *sort_param)
+{
+ if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
+ {
+ sort_param->write_keys= write_keys_varlen;
+ sort_param->read_to_buffer= read_to_buffer_varlen;
+ sort_param->write_key= write_merge_key_varlen;
+ }
+ else
+ {
+ sort_param->write_keys= write_keys;
+ sort_param->read_to_buffer= read_to_buffer;
+ sort_param->write_key= write_merge_key;
+ }
+}
+
+
/*
Creates a index of sorted keys
@@ -111,18 +133,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
DBUG_ENTER("_create_index_by_sort");
DBUG_PRINT("enter",("sort_length: %d", info->key_length));
- if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
- {
- info->write_keys=write_keys_varlen;
- info->read_to_buffer=read_to_buffer_varlen;
- info->write_key= write_merge_key_varlen;
- }
- else
- {
- info->write_keys=write_keys;
- info->read_to_buffer=read_to_buffer;
- info->write_key=write_merge_key;
- }
+ set_sort_param_read_write(info);
my_b_clear(&tempfile);
my_b_clear(&tempfile_for_exceptions);
@@ -179,7 +190,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
}
if (memavl < MIN_SORT_BUFFER)
{
- mi_check_print_error(info->sort_info->param,"MyISAM sort buffer too small"); /* purecov: tested */
+ mi_check_print_error(info->sort_info->param,
+ "MyISAM sort buffer too small"); /* purecov: tested */
my_errno= ENOMEM; /* purecov: tested */
goto err; /* purecov: tested */
}
@@ -307,189 +319,187 @@ static ha_rows find_all_keys(MI_SORT_PARAM *info, uint keys,
DBUG_RETURN((*maxbuffer)*(keys-1)+idx);
} /* find_all_keys */
-
-/* Search after all keys and place them in a temp. file */
-
-pthread_handler_t thr_find_all_keys(void *arg)
+static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
{
- MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg;
- int error;
ulonglong memavl, old_memavl;
- uint keys, sort_length;
- uint idx, maxbuffer;
- uchar **sort_keys=0;
-
- LINT_INIT(keys);
-
- error=1;
-
- if (my_thread_init())
- goto err;
-
- { /* Add extra block since DBUG_ENTER declare variables */
- DBUG_ENTER("thr_find_all_keys");
- DBUG_PRINT("enter", ("master: %d", sort_param->master));
- if (sort_param->sort_info->got_error)
- goto err;
+ uint UNINIT_VAR(keys), idx;
+ uint sort_length;
+ uint maxbuffer;
+ uchar **sort_keys= NULL;
+ int error= 0;
+ DBUG_ENTER("thr_find_all_keys");
+ DBUG_PRINT("enter", ("master: %d", sort_param->master));
+
+ if (sort_param->sort_info->got_error)
+ DBUG_RETURN(TRUE);
+
+ set_sort_param_read_write(sort_param);
+
+ my_b_clear(&sort_param->tempfile);
+ my_b_clear(&sort_param->tempfile_for_exceptions);
+ bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek));
+ bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
+
+ memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
+ idx= (uint) sort_param->sort_info->max_records;
+ sort_length= sort_param->key_length;
+ maxbuffer= 1;
+
+ if ((memavl - sizeof(BUFFPEK)) / (sort_length +
+ sizeof(char *)) > UINT_MAX32)
+ memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *));
- if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
- {
- sort_param->write_keys= write_keys_varlen;
- sort_param->read_to_buffer= read_to_buffer_varlen;
- sort_param->write_key= write_merge_key_varlen;
- }
+ while (memavl >= MIN_SORT_BUFFER)
+ {
+ if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <=
+ (my_off_t) memavl)
+ keys= idx+1;
else
{
- sort_param->write_keys= write_keys;
- sort_param->read_to_buffer= read_to_buffer;
- sort_param->write_key= write_merge_key;
- }
-
- my_b_clear(&sort_param->tempfile);
- my_b_clear(&sort_param->tempfile_for_exceptions);
- bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek));
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-
- if ((memavl - sizeof(BUFFPEK)) / (sort_length +
- sizeof(char *)) > UINT_MAX32)
- memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *));
-
- while (memavl >= MIN_SORT_BUFFER)
- {
- if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <=
- (my_off_t) memavl)
- keys= idx+1;
- else
- {
- uint skr;
- do
- {
- skr= maxbuffer;
- if (memavl < sizeof(BUFFPEK)*maxbuffer ||
- (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
- (sort_length+sizeof(char*))) <= 1 ||
- keys < (uint) maxbuffer)
- {
- mi_check_print_error(sort_param->sort_info->param,
- "myisam_sort_buffer_size is too small");
- goto err;
- }
- }
- while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
- }
- if ((sort_keys= (uchar**)
- my_malloc(keys*(sort_length+sizeof(char*))+
- ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
- HA_FT_MAXBYTELEN : 0), MYF(0))))
+ uint skr;
+ do
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
- maxbuffer, maxbuffer/2))
+ skr= maxbuffer;
+ if (memavl < sizeof(BUFFPEK)*maxbuffer ||
+ (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
+ (sort_length+sizeof(char*))) <= 1 ||
+ keys < (uint) maxbuffer)
{
- my_free(sort_keys);
- sort_keys= (uchar **) NULL; /* for err: label */
+ mi_check_print_error(sort_param->sort_info->param,
+ "myisam_sort_buffer_size is too small");
+ DBUG_RETURN(TRUE);
}
- else
- break;
}
- old_memavl= memavl;
- if ((memavl= memavl / 4 * 3) < MIN_SORT_BUFFER &&
- old_memavl > MIN_SORT_BUFFER)
- memavl= MIN_SORT_BUFFER;
+ while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
}
- if (memavl < MIN_SORT_BUFFER)
+ if ((sort_keys= my_malloc(keys * (sort_length + sizeof(char *)) +
+ ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
+ HA_FT_MAXBYTELEN : 0), MYF(0))))
{
- mi_check_print_error(sort_param->sort_info->param,
- "MyISAM sort buffer too small");
- goto err; /* purecov: tested */
+ if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
+ maxbuffer, min(maxbuffer / 2, 1000)))
+ {
+ my_free(sort_keys);
+ sort_keys= NULL; /* Safety against double free on error. */
+ }
+ else
+ break;
}
+ old_memavl= memavl;
+ if ((memavl= memavl / 4 * 3) < MIN_SORT_BUFFER &&
+ old_memavl > MIN_SORT_BUFFER)
+ memavl= MIN_SORT_BUFFER;
+ }
+ if (memavl < MIN_SORT_BUFFER)
+ {
+ /* purecov: begin inspected */
+ mi_check_print_error(sort_param->sort_info->param,
+ "myisam_sort_buffer_size is too small");
+ my_errno= ENOMEM;
+ goto err;
+ /* purecov: end inspected */
+ }
- if (sort_param->sort_info->param->testflag & T_VERBOSE)
- printf("Key %d - Allocating buffer for %d keys\n",
- sort_param->key + 1, keys);
- sort_param->sort_keys= sort_keys;
+ if (sort_param->sort_info->param->testflag & T_VERBOSE)
+ printf("Key %d - Allocating buffer for %llu keys\n",
+ sort_param->key + 1, (ulonglong) keys);
+ sort_param->sort_keys= sort_keys;
- idx= error= 0;
- sort_keys[0]= (uchar*) (sort_keys+keys);
+ idx= error= 0;
+ sort_keys[0]= (uchar*) (sort_keys+keys);
- DBUG_PRINT("info", ("reading keys"));
- while (!(error= sort_param->sort_info->got_error) &&
- !(error= (*sort_param->key_read)(sort_param, sort_keys[idx])))
+ DBUG_PRINT("info", ("reading keys"));
+ while (!(error= sort_param->sort_info->got_error) &&
+ !(error= (*sort_param->key_read)(sort_param, sort_keys[idx])))
+ {
+ if (sort_param->real_key_length > sort_param->key_length)
{
- if (sort_param->real_key_length > sort_param->key_length)
- {
- if (write_key(sort_param, sort_keys[idx],
- &sort_param->tempfile_for_exceptions))
- goto err;
- continue;
- }
-
- if (++idx == keys)
- {
- if (sort_param->write_keys(sort_param, sort_keys, idx - 1,
- (BUFFPEK*) alloc_dynamic(&sort_param->buffpek),
- &sort_param->tempfile))
- goto err;
- sort_keys[0]= (uchar*) (sort_keys+keys);
- memcpy(sort_keys[0], sort_keys[idx - 1], (size_t) sort_param->key_length);
- idx= 1;
- }
- sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length;
+ if (write_key(sort_param, sort_keys[idx],
+ &sort_param->tempfile_for_exceptions))
+ goto err;
+ continue;
}
- if (error > 0)
- goto err;
- if (sort_param->buffpek.elements)
+
+ if (++idx == keys)
{
- if (sort_param->write_keys(sort_param, sort_keys, idx,
+ if (sort_param->write_keys(sort_param, sort_keys, idx - 1,
(BUFFPEK*) alloc_dynamic(&sort_param->buffpek),
&sort_param->tempfile))
goto err;
- sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx;
+ sort_keys[0]= (uchar*) (sort_keys+keys);
+ memcpy(sort_keys[0], sort_keys[idx - 1], (size_t) sort_param->key_length);
+ idx= 1;
}
- else
- sort_param->keys= idx;
+ sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length;
+ }
- sort_param->sort_keys_length= keys;
- goto ok;
+ if (error > 0)
+ goto err;
-err:
- DBUG_PRINT("error", ("got some error"));
- sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */
- my_free(sort_keys);
- sort_param->sort_keys= 0;
- delete_dynamic(& sort_param->buffpek);
- close_cached_file(&sort_param->tempfile);
- close_cached_file(&sort_param->tempfile_for_exceptions);
-
-ok:
- free_root(&sort_param->wordroot, MYF(0));
- /*
- Detach from the share if the writer is involved. Avoid others to
- be blocked. This includes a flush of the write buffer. This will
- also indicate EOF to the readers.
- That means that a writer always gets here first and readers -
- only when they see EOF. But if a reader finishes prematurely
- because of an error it may reach this earlier - don't allow it
- to detach the writer thread.
- */
- if (sort_param->master && sort_param->sort_info->info->rec_cache.share)
- remove_io_thread(&sort_param->sort_info->info->rec_cache);
-
- /* Readers detach from the share if any. Avoid others to be blocked. */
- if (sort_param->read_cache.share)
- remove_io_thread(&sort_param->read_cache);
-
- mysql_mutex_lock(&sort_param->sort_info->mutex);
- if (!--sort_param->sort_info->threads_running)
- mysql_cond_signal(&sort_param->sort_info->cond);
- mysql_mutex_unlock(&sort_param->sort_info->mutex);
- DBUG_PRINT("exit", ("======== ending thread ========"));
+ if (sort_param->buffpek.elements)
+ {
+ if (sort_param->write_keys(sort_param, sort_keys, idx,
+ (BUFFPEK*) alloc_dynamic(&sort_param->buffpek),
+ &sort_param->tempfile))
+ goto err;
+ sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx;
}
+ else
+ sort_param->keys= idx;
+
+ sort_param->sort_keys_length= keys;
+
+ DBUG_RETURN(FALSE);
+
+err:
+ DBUG_PRINT("error", ("got some error"));
+ sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */
+ my_free(sort_keys);
+ sort_param->sort_keys= 0;
+ delete_dynamic(& sort_param->buffpek);
+ close_cached_file(&sort_param->tempfile);
+ close_cached_file(&sort_param->tempfile_for_exceptions);
+
+ DBUG_RETURN(TRUE);
+}
+
+/* Search after all keys and place them in a temp. file */
+
+pthread_handler_t thr_find_all_keys(void *arg)
+{
+ MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg;
+ my_bool error= FALSE;
+ /* If my_thread_init fails */
+ if (my_thread_init() || thr_find_all_keys_exec(sort_param))
+ error= TRUE;
+
+ /*
+ Thread must clean up after itself.
+ */
+ free_root(&sort_param->wordroot, MYF(0));
+ /*
+ Detach from the share if the writer is involved. Avoid others to
+ be blocked. This includes a flush of the write buffer. This will
+ also indicate EOF to the readers.
+ That means that a writer always gets here first and readers -
+ only when they see EOF. But if a reader finishes prematurely
+ because of an error it may reach this earlier - don't allow it
+ to detach the writer thread.
+ */
+ if (sort_param->master && sort_param->sort_info->info->rec_cache.share)
+ remove_io_thread(&sort_param->sort_info->info->rec_cache);
+
+ /* Readers detach from the share if any. Avoid others to be blocked. */
+ if (sort_param->read_cache.share)
+ remove_io_thread(&sort_param->read_cache);
+
+ mysql_mutex_lock(&sort_param->sort_info->mutex);
+ if (error)
+ sort_param->sort_info->got_error= 1;
+
+ if (!--sort_param->sort_info->threads_running)
+ mysql_cond_signal(&sort_param->sort_info->cond);
+ mysql_mutex_unlock(&sort_param->sort_info->mutex);
my_thread_end();
return NULL;
}
@@ -550,18 +560,9 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
{
if (got_error)
continue;
- if (sinfo->keyinfo->flag & HA_VAR_LENGTH_KEY)
- {
- sinfo->write_keys=write_keys_varlen;
- sinfo->read_to_buffer=read_to_buffer_varlen;
- sinfo->write_key=write_merge_key_varlen;
- }
- else
- {
- sinfo->write_keys=write_keys;
- sinfo->read_to_buffer=read_to_buffer;
- sinfo->write_key=write_merge_key;
- }
+
+ set_sort_param_read_write(sinfo);
+
if (sinfo->buffpek.elements)
{
uint maxbuffer=sinfo->buffpek.elements-1;
diff --git a/storage/tokudb/ft-index/ft/logger/recover.cc b/storage/tokudb/ft-index/ft/logger/recover.cc
index 680485201da..7a5fa361e2d 100644
--- a/storage/tokudb/ft-index/ft/logger/recover.cc
+++ b/storage/tokudb/ft-index/ft/logger/recover.cc
@@ -785,7 +785,7 @@ static int toku_recover_xcommit (struct logtype_xcommit *l, RECOVER_ENV renv) {
assert(txn!=NULL);
// commit the transaction
- toku_txn_progress_extra extra = { time(NULL), l->lsn, "commit", l->xid };
+ toku_txn_progress_extra extra = { time(NULL), l->lsn, "commit", l->xid, 0 };
int r = toku_txn_commit_with_lsn(txn, true, l->lsn, toku_recover_txn_progress, &extra);
assert(r == 0);
@@ -828,7 +828,7 @@ static int toku_recover_xabort (struct logtype_xabort *l, RECOVER_ENV renv) {
assert(txn!=NULL);
// abort the transaction
- toku_txn_progress_extra extra = { time(NULL), l->lsn, "abort", l->xid };
+ toku_txn_progress_extra extra = { time(NULL), l->lsn, "abort", l->xid, 0 };
r = toku_txn_abort_with_lsn(txn, l->lsn, toku_recover_txn_progress, &extra);
assert(r == 0);
@@ -1363,7 +1363,7 @@ static void recover_abort_live_txn(TOKUTXN txn) {
// sanity check that the recursive call successfully NULLs out txn->child
invariant(txn->child == NULL);
// abort the transaction
- toku_txn_progress_extra extra = { time(NULL), ZERO_LSN, "abort live", txn->txnid };
+ toku_txn_progress_extra extra = { time(NULL), ZERO_LSN, "abort live", txn->txnid, 0 };
int r = toku_txn_abort_txn(txn, toku_recover_txn_progress, &extra);
assert(r == 0);
diff --git a/storage/tokudb/ft-index/ft/serialize/ft_node-serialize.cc b/storage/tokudb/ft-index/ft/serialize/ft_node-serialize.cc
index 6fd452aba54..84f3f98cfb5 100644
--- a/storage/tokudb/ft-index/ft/serialize/ft_node-serialize.cc
+++ b/storage/tokudb/ft-index/ft/serialize/ft_node-serialize.cc
@@ -643,7 +643,7 @@ serialize_and_compress_in_parallel(FTNODE node,
struct serialize_compress_work work[npartitions];
workset_lock(&ws);
for (int i = 0; i < npartitions; i++) {
- work[i] = (struct serialize_compress_work) { .base = {{NULL}},
+ work[i] = (struct serialize_compress_work) { .base = {{NULL, NULL}},
.node = node,
.i = i,
.compression_method = compression_method,
diff --git a/storage/tokudb/ft-index/ft/txn/txn.cc b/storage/tokudb/ft-index/ft/txn/txn.cc
index 922c955a6b5..9aa93375126 100644
--- a/storage/tokudb/ft-index/ft/txn/txn.cc
+++ b/storage/tokudb/ft-index/ft/txn/txn.cc
@@ -333,14 +333,14 @@ static txn_child_manager tcm;
.do_fsync = false,
.force_fsync_on_commit = false,
.do_fsync_lsn = ZERO_LSN,
- .xa_xid = {0},
+ .xa_xid = {0, 0, 0, {}},
.progress_poll_fun = NULL,
.progress_poll_fun_extra = NULL,
- .txn_lock = ZERO_MUTEX_INITIALIZER,
+ .txn_lock = TOKU_MUTEX_INITIALIZER,
.open_fts = open_fts,
.roll_info = roll_info,
- .state_lock = ZERO_MUTEX_INITIALIZER,
- .state_cond = ZERO_COND_INITIALIZER,
+ .state_lock = TOKU_MUTEX_INITIALIZER,
+ .state_cond = TOKU_COND_INITIALIZER,
.state = TOKUTXN_LIVE,
.num_pin = 0,
.client_id = 0,
diff --git a/storage/tokudb/ft-index/portability/toku_pthread.h b/storage/tokudb/ft-index/portability/toku_pthread.h
index a9dc660b6a7..4a564e4029b 100644
--- a/storage/tokudb/ft-index/portability/toku_pthread.h
+++ b/storage/tokudb/ft-index/portability/toku_pthread.h
@@ -125,16 +125,6 @@ typedef struct toku_mutex_aligned {
toku_mutex_t aligned_mutex __attribute__((__aligned__(64)));
} toku_mutex_aligned_t;
-// Different OSes implement mutexes as different amounts of nested structs.
-// C++ will fill out all missing values with zeroes if you provide at least one zero, but it needs the right amount of nesting.
-#if defined(__FreeBSD__)
-# define ZERO_MUTEX_INITIALIZER {0}
-#elif defined(__APPLE__)
-# define ZERO_MUTEX_INITIALIZER {{0}}
-#else // __linux__, at least
-# define ZERO_MUTEX_INITIALIZER {{{0}}}
-#endif
-
#if TOKU_PTHREAD_DEBUG
# define TOKU_MUTEX_INITIALIZER { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true }
#else
@@ -276,15 +266,6 @@ typedef struct toku_cond {
pthread_cond_t pcond;
} toku_cond_t;
-// Different OSes implement mutexes as different amounts of nested structs.
-// C++ will fill out all missing values with zeroes if you provide at least one zero, but it needs the right amount of nesting.
-#if defined(__FreeBSD__)
-# define ZERO_COND_INITIALIZER {0}
-#elif defined(__APPLE__)
-# define ZERO_COND_INITIALIZER {{0}}
-#else // __linux__, at least
-# define ZERO_COND_INITIALIZER {{{0}}}
-#endif
#define TOKU_COND_INITIALIZER {PTHREAD_COND_INITIALIZER}
static inline void
diff --git a/storage/tokudb/ft-index/src/tests/threaded_stress_test_helpers.h b/storage/tokudb/ft-index/src/tests/threaded_stress_test_helpers.h
index f9da1693847..fc4acecff10 100644
--- a/storage/tokudb/ft-index/src/tests/threaded_stress_test_helpers.h
+++ b/storage/tokudb/ft-index/src/tests/threaded_stress_test_helpers.h
@@ -1825,7 +1825,7 @@ static int run_workers(
{
int r;
const struct perf_formatter *perf_formatter = &perf_formatters[cli_args->perf_output_format];
- toku_mutex_t mutex = ZERO_MUTEX_INITIALIZER;
+ toku_mutex_t mutex = TOKU_MUTEX_INITIALIZER;
toku_mutex_init(&mutex, nullptr);
struct rwlock rwlock;
rwlock_init(&rwlock);
diff --git a/storage/xtradb/dict/dict0crea.c b/storage/xtradb/dict/dict0crea.c
index 4c1c4f1bd6b..a77acf8b577 100644
--- a/storage/xtradb/dict/dict0crea.c
+++ b/storage/xtradb/dict/dict0crea.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2016, 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
@@ -1255,7 +1255,7 @@ dict_create_index_step(
>= DICT_TF_FORMAT_ZIP);
node->index = dict_index_get_if_in_cache_low(index_id);
- ut_a((node->index == 0) == (err != DB_SUCCESS));
+ ut_a((node->index == NULL) == (err != DB_SUCCESS));
if (err != DB_SUCCESS) {
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 07714032575..1e2128f4f88 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -2466,7 +2466,6 @@ no_db_name:
A wrapper function of innobase_convert_name(), convert a table or
index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
@return pointer to the end of buf */
-static inline
void
innobase_format_name(
/*==================*/
@@ -10920,6 +10919,36 @@ ha_innobase::check(
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
+ if (prebuilt->table->corrupted) {
+ char index_name[MAX_FULL_NAME_LEN + 1];
+ /* If some previous operation has marked the table as
+ corrupted in memory, and has not propagated such to
+ clustered index, we will do so here */
+ index = dict_table_get_first_index(prebuilt->table);
+
+ if (!dict_index_is_corrupted(index)) {
+ row_mysql_lock_data_dictionary(prebuilt->trx);
+ dict_set_corrupted(index);
+ row_mysql_unlock_data_dictionary(prebuilt->trx);
+ }
+
+ innobase_format_name(index_name, sizeof index_name,
+ index->name, TRUE);
+
+ push_warning_printf(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ HA_ERR_INDEX_CORRUPT,
+ "InnoDB: Index %s is marked as"
+ " corrupted",
+ index_name);
+
+ /* Now that the table is already marked as corrupted,
+ there is no need to check any index of this table */
+ prebuilt->trx->op_info = "";
+
+ DBUG_RETURN(HA_ADMIN_CORRUPT);
+ }
+
prebuilt->trx->op_info = "checking table";
old_isolation_level = prebuilt->trx->isolation_level;
@@ -10996,6 +11025,15 @@ ha_innobase::check(
prebuilt->index_usable = row_merge_is_index_usable(
prebuilt->trx, prebuilt->index);
+ DBUG_EXECUTE_IF(
+ "dict_set_index_corrupted",
+ if (!dict_index_is_clust(index)) {
+ prebuilt->index_usable = FALSE;
+ row_mysql_lock_data_dictionary(prebuilt->trx);
+ dict_set_corrupted(index);
+ row_mysql_unlock_data_dictionary(prebuilt->trx);
+ });
+
if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
innobase_format_name(
index_name, sizeof index_name,
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index c3fef56b88a..bdb4fa0c1b6 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -659,6 +659,19 @@ public:
~ha_innobase_add_index() {}
};
+
+/*****************************************************************//**
+A wrapper function of innobase_convert_name(), convert a table or
+index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
+@return pointer to the end of buf */
+void
+innobase_format_name(
+/*==================*/
+ char* buf, /*!< out: buffer for converted identifier */
+ ulint buflen, /*!< in: length of buf, in bytes */
+ const char* name, /*!< in: index or table name to format */
+ ibool is_index_name); /*!< in: index name */
+
/*******************************************************************//**
Create indexes.
@return 0 or error number */
@@ -724,6 +737,28 @@ ha_innobase::add_index(
DBUG_RETURN(-1);
}
+ /* Check if any of the existing indexes are marked as corruption,
+ and if they are, refuse adding more indexes. */
+ for (dict_index_t* check_index = dict_table_get_first_index(indexed_table);
+ check_index != NULL;
+ check_index = dict_table_get_next_index(check_index)) {
+
+ if (dict_index_is_corrupted(check_index)) {
+ char index_name[MAX_FULL_NAME_LEN + 1];
+
+ innobase_format_name(index_name, sizeof index_name,
+ check_index->name, TRUE);
+
+ push_warning_printf(user_thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ HA_ERR_INDEX_CORRUPT,
+ "InnoDB: Index %s is marked as"
+ " corrupted",
+ index_name);
+ DBUG_RETURN(HA_ERR_INDEX_CORRUPT);
+ }
+ }
+
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table);
diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h
index a60dcbd1e75..b52c078fa54 100644
--- a/storage/xtradb/include/os0sync.h
+++ b/storage/xtradb/include/os0sync.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -41,7 +41,6 @@ Created 9/6/1995 Heikki Tuuri
|| defined _M_X64 || defined __WIN__
#define IB_STRONG_MEMORY_MODEL
-#undef HAVE_IB_GCC_ATOMIC_TEST_AND_SET // Quick-and-dirty fix for bug 1519094
#endif /* __i386__ || __x86_64__ || _M_IX86 || M_X64 || __WIN__ */
@@ -369,28 +368,7 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */
# define os_atomic_test_and_set_byte_acquire(ptr, new_val) \
__sync_lock_test_and_set(ptr, (byte) new_val)
-# if defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
-
-/** Do an atomic test-and-set.
-@param[in,out] ptr Memory location to set to non-zero
-@return the previous value */
-static inline
-lock_word_t
-os_atomic_test_and_set(volatile lock_word_t* ptr)
-{
- return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE));
-}
-
-/** Do an atomic clear.
-@param[in,out] ptr Memory location to set to zero */
-static inline
-void
-os_atomic_clear(volatile lock_word_t* ptr)
-{
- __atomic_clear(ptr, __ATOMIC_RELEASE);
-}
-
-# elif defined(IB_STRONG_MEMORY_MODEL)
+# if defined(IB_STRONG_MEMORY_MODEL)
/** Do an atomic test and set.
@param[in,out] ptr Memory location to set to non-zero
@@ -419,6 +397,27 @@ os_atomic_clear(volatile lock_word_t* ptr)
return(__sync_lock_test_and_set(ptr, 0));
}
+# elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
+
+/** Do an atomic test-and-set.
+@param[in,out] ptr Memory location to set to non-zero
+@return the previous value */
+static inline
+lock_word_t
+os_atomic_test_and_set(volatile lock_word_t* ptr)
+{
+ return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE));
+}
+
+/** Do an atomic clear.
+@param[in,out] ptr Memory location to set to zero */
+static inline
+void
+os_atomic_clear(volatile lock_word_t* ptr)
+{
+ __atomic_clear(ptr, __ATOMIC_RELEASE);
+}
+
# else
# error "Unsupported platform"
diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i
index aced1fde229..2aaabf64a4e 100644
--- a/storage/xtradb/include/univ.i
+++ b/storage/xtradb/include/univ.i
@@ -64,10 +64,10 @@ component, i.e. we show M.N.P as M.N */
(INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
#ifndef PERCONA_INNODB_VERSION
-#define PERCONA_INNODB_VERSION 37.8
+#define PERCONA_INNODB_VERSION 37.9
#endif
-#define INNODB_VERSION_STR "5.5.48-MariaDB-" IB_TO_STR(PERCONA_INNODB_VERSION)
+#define INNODB_VERSION_STR "5.5.49-MariaDB-" IB_TO_STR(PERCONA_INNODB_VERSION)
#define REFMAN "http://dev.mysql.com/doc/refman/" \
IB_TO_STR(MYSQL_MAJOR_VERSION) "." \
diff --git a/storage/xtradb/log/log0recv.c b/storage/xtradb/log/log0recv.c
index b0b481b0094..479f50d1931 100644
--- a/storage/xtradb/log/log0recv.c
+++ b/storage/xtradb/log/log0recv.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2016, 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
@@ -1844,7 +1844,7 @@ loop:
goto loop;
}
- ut_ad((allow_ibuf == 0) == (mutex_own(&log_sys->mutex) != 0));
+ ut_ad((!allow_ibuf) == mutex_own(&log_sys->mutex));
if (!allow_ibuf) {
recv_no_ibuf_operations = TRUE;
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c
index 1bedc1a490b..da31c9456c0 100644
--- a/storage/xtradb/os/os0file.c
+++ b/storage/xtradb/os/os0file.c
@@ -478,6 +478,43 @@ PIMAGE_TLS_CALLBACK p_thread_callback_base = win_tls_thread_exit;
#endif /*_WIN32 */
/***********************************************************************//**
+For an EINVAL I/O error, prints a diagnostic message if innodb_flush_method
+== ALL_O_DIRECT.
+@return TRUE if the diagnostic message was printed
+@return FALSE if the diagnostic message does not apply */
+static
+ibool
+os_diagnose_all_o_direct_einval(
+/*============================*/
+ ulint err) /*!< in: C error code */
+{
+ if ((err == EINVAL)
+ && (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT)) {
+ fprintf(stderr,
+ "InnoDB: The error might be caused by redo log I/O "
+ "not satisfying innodb_flush_method=ALL_O_DIRECT "
+ "requirements by the underlying file system.\n");
+ if (srv_log_block_size != 512)
+ fprintf(stderr,
+ "InnoDB: This might be caused by an "
+ "incompatible non-default "
+ "innodb_log_block_size value %lu.\n",
+ srv_log_block_size);
+ fprintf(stderr,
+ "InnoDB: Please file a bug at "
+ "https://bugs.percona.com and include this error "
+ "message, my.cnf settings, and information about the "
+ "file system where the redo log resides.\n");
+ fprintf(stderr,
+ "InnoDB: A possible workaround is to change "
+ "innodb_flush_method value to something else "
+ "than ALL_O_DIRECT.\n");
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/***********************************************************************//**
Retrieves the last error number if an error occurs in a file io function.
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,
@@ -602,7 +639,7 @@ os_file_get_last_error(
"InnoDB: The error means mysqld does not have"
" the access rights to\n"
"InnoDB: the directory.\n");
- } else {
+ } else if (!os_diagnose_all_o_direct_einval(err)) {
if (strerror((int)err) != NULL) {
fprintf(stderr,
"InnoDB: Error number %lu"
@@ -2642,6 +2679,9 @@ os_file_pwrite(
/* Handle partial writes and signal interruptions correctly */
for (ret = 0; ret < (ssize_t) n; ) {
n_written = pwrite(file, buf, (ssize_t)n - ret, offs);
+ DBUG_EXECUTE_IF("xb_simulate_all_o_direct_write_failure",
+ n_written = -1;
+ errno = EINVAL;);
if (n_written >= 0) {
ret += n_written;
offs += n_written;
@@ -2807,6 +2847,10 @@ try_again:
try_again:
ret = os_file_pread(file, buf, n, offset, offset_high, trx);
+ DBUG_EXECUTE_IF("xb_simulate_all_o_direct_read_failure",
+ ret = -1;
+ errno = EINVAL;);
+
if ((ulint)ret == n) {
return(TRUE);
@@ -3105,6 +3149,8 @@ retry:
"InnoDB: "
REFMAN "operating-system-error-codes.html\n");
+ os_diagnose_all_o_direct_einval(errno);
+
os_has_said_disk_full = TRUE;
}
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 11d01ea534d..2040c3432b8 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2011, 2015, MariaDB
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2011, 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
@@ -236,7 +236,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
}
/* Load certs from the trusted ca */
- if (SSL_CTX_load_verify_locations(ssl_fd->ssl_context, ca_file, ca_path) == 0)
+ if (SSL_CTX_load_verify_locations(ssl_fd->ssl_context, ca_file, ca_path) <= 0)
{
DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed"));
if (ca_file || ca_path)
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
index 48d15cbf91c..b716bbf7e88 100644
--- a/win/packaging/extra.wxs.in
+++ b/win/packaging/extra.wxs.in
@@ -66,6 +66,7 @@
<CustomAction Id="LaunchUrl" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes" />
+
<!--
User interface dialogs
-->
@@ -463,7 +464,7 @@
Key='SOFTWARE\@MANUFACTURER@\@CPACK_WIX_PACKAGE_NAME@'
Name='DATADIR' Value='[DATADIR]' Type='string' KeyPath='yes'/>
<CreateFolder>
- <util:PermissionEx User="[LogonUser]" GenericAll="yes" />
+ <util:PermissionEx User="[LogonUser]" Domain="[USER_DOMAIN]" GenericAll="yes" />
<util:PermissionEx User="NetworkService" GenericAll="yes" />
</CreateFolder>
</Component>
@@ -542,17 +543,6 @@
Value="utf8" />
</Component>
- <!--- Grant service account permission to the database folder (Windows 7 and later) -->
- <Component Id="C.serviceaccount.permission" Guid="*" Directory='DATADIR' Transitive='yes'>
- <Condition><![CDATA[SERVICENAME AND (VersionNT > 600)]]></Condition>
- <RegistryValue Root='HKLM'
- Key='SOFTWARE\@MANUFACTURER@\@CPACK_WIX_PACKAGE_NAME@'
- Name='servicepermission' Value='1' Type='string' KeyPath='yes'/>
- <CreateFolder>
- <util:PermissionEx User="NT SERVICE\[SERVICENAME]" GenericAll="yes" />
- </CreateFolder>
- </Component>
-
<!-- Shortcuts in program menu (mysql client etc) -->
<Component Id="c.shortcuts" Guid="*" Directory="ShortcutFolder">
<!-- shortcut to my.ini-->
@@ -862,6 +852,7 @@
<Property Id="ARPSYSTEMCOMPONENT" Value="1" Secure="yes" />
<Property Id="ARPINSTALLLOCATION" Secure="yes"/>
<SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="InstallValidate" Sequence="execute"/>
+ <SetProperty Id="USER_DOMAIN" Value="[%USERDOMAIN]" After="LaunchConditions" Sequence="first" />
<Feature Id='ARPRegistryEntries'
Title='Add or remove program entries'
Description='Add or remove program entries'
@@ -909,5 +900,8 @@
'Setting the ALLUSERS property is not allowed because [ProductName] is a per-machine application. Setup will now exit.'>
<![CDATA[ALLUSERS = "1"]]>
</Condition>
+ <Condition Message='This application is only supported on Windows Vista, Windows Server 2008, or higher.'>
+ <![CDATA[Installed OR (VersionNT >= 600)]]>
+ </Condition>
</Fragment>
</Wix>
diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake
index 5b0cd07cea4..e2636eb4af8 100644
--- a/win/packaging/heidisql.cmake
+++ b/win/packaging/heidisql.cmake
@@ -1,4 +1,4 @@
-SET(HEIDISQL_BASE_NAME "HeidiSQL_9.1_Portable")
+SET(HEIDISQL_BASE_NAME "HeidiSQL_9.3_Portable")
SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip")
SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}")
SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME})