summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-06-21 14:11:02 +0200
committerSergei Golubchik <serg@mariadb.org>2016-06-21 14:11:02 +0200
commitc081c978a2c83b9dc9efa84414cf40232460987d (patch)
treeb625b53c941b75d122ba21d7bf650016f78c9bd5
parent1d21b22155242f604ab8e4a7b4ed92a422f61266 (diff)
parenta482e76e65a4fee70479e877929381c86b1ec62f (diff)
downloadmariadb-git-c081c978a2c83b9dc9efa84414cf40232460987d.tar.gz
Merge branch '5.5' into bb-10.0
-rw-r--r--client/mysqladmin.cc11
-rw-r--r--client/mysqlcheck.c29
-rw-r--r--client/mysqldump.c45
-rw-r--r--client/mysqlshow.c42
-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--libmysqld/CMakeLists.txt10
-rwxr-xr-xmysql-test/mysql-test-run.pl5
-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/insert_innodb.result15
-rw-r--r--mysql-test/r/locale.result28
-rw-r--r--mysql-test/r/mysqlcheck.result5
-rw-r--r--mysql-test/r/parser.result20
-rw-r--r--mysql-test/r/ssl_ca.result24
-rw-r--r--mysql-test/r/type_date.result7
-rw-r--r--mysql-test/suite/innodb/r/innodb_corrupt_bit.result90
-rw-r--r--mysql-test/suite/innodb/t/innodb_corrupt_bit.test88
-rw-r--r--mysql-test/suite/perfschema/r/digest_table_full.result2
-rw-r--r--mysql-test/suite/perfschema/r/rpl_gtid_func.result4
-rw-r--r--mysql-test/suite/perfschema/r/start_server_low_digest.result4
-rw-r--r--mysql-test/suite/perfschema/r/statement_digest.result70
-rw-r--r--mysql-test/suite/perfschema/r/statement_digest_consumers.result70
-rw-r--r--mysql-test/suite/perfschema/r/statement_digest_long_query.result4
-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/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/insert_innodb.test21
-rw-r--r--mysql-test/t/locale.test19
-rw-r--r--mysql-test/t/mysqlcheck.test5
-rw-r--r--mysql-test/t/parser.test12
-rw-r--r--mysql-test/t/ssl_ca.test36
-rw-r--r--mysql-test/t/type_date.test1
-rw-r--r--mysql-test/valgrind.supp97
-rw-r--r--mysys/errors.c5
-rw-r--r--mysys/mf_iocache.c1
-rw-r--r--mysys/my_write.c3
-rw-r--r--mysys/testhash.c4
-rw-r--r--mysys/tree.c3
-rw-r--r--plugin/feedback/url_http.cc1
-rw-r--r--scripts/mysqld_multi.sh8
-rw-r--r--sql-common/client.c46
-rw-r--r--sql/field.cc1
-rw-r--r--sql/field.h28
-rw-r--r--sql/item.cc17
-rw-r--r--sql/item_func.cc5
-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.cc44
-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_lex.cc29
-rw-r--r--sql/sql_locale.h2
-rw-r--r--sql/sql_reload.cc3
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_yacc.yy95
-rw-r--r--sql/threadpool_unix.cc6
-rw-r--r--storage/innobase/handler/ha_innodb.cc38
-rw-r--r--storage/innobase/handler/handler0alter.cc18
-rw-r--r--storage/maria/ma_checkpoint.c18
-rw-r--r--storage/maria/ma_loghandler.c11
-rw-r--r--storage/maria/ma_pagecache.c32
-rw-r--r--storage/maria/ma_pagecache.h40
-rw-r--r--storage/maria/ma_servicethread.c51
-rw-r--r--storage/maria/ma_servicethread.h7
-rw-r--r--storage/maria/ma_sort.c376
-rw-r--r--storage/maria/maria_def.h3
-rw-r--r--storage/myisam/sort.c374
-rw-r--r--storage/xtradb/handler/ha_innodb.cc37
-rw-r--r--storage/xtradb/handler/handler0alter.cc18
-rw-r--r--vio/viosslfactories.c6
-rw-r--r--win/packaging/extra.wxs.in18
-rw-r--r--win/packaging/heidisql.cmake2
84 files changed, 1405 insertions, 1007 deletions
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index daffdefd768..56d2784a1f5 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -235,8 +235,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;
@@ -284,8 +282,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;
@@ -296,11 +294,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 fbfdedd52ed..c1fec38ca8c 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -246,7 +246,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;
@@ -594,10 +594,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++)
@@ -605,7 +605,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));
}
@@ -664,7 +664,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;
@@ -769,7 +769,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, 1);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -784,7 +786,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, 1);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -806,7 +809,7 @@ static int rebuild_table(char *name)
ptr= strxmov(ptr, " FORCE", NullS);
if (verbose >= 3)
puts(query);
- 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));
@@ -870,7 +873,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");
@@ -923,10 +926,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);
@@ -942,7 +947,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 (verbose >= 3)
puts(query);
@@ -1208,7 +1213,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 dc6798560c3..153761ed510 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -92,7 +92,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);
@@ -890,7 +890,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)
{
@@ -900,7 +900,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);
@@ -1171,8 +1171,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);
@@ -1305,7 +1305,7 @@ get_gtid_pos(char *out_gtid_pos, int master)
static char *my_case_str(const char *str,
- uint str_len,
+ size_t str_len,
const char *token,
uint token_len)
{
@@ -1521,7 +1521,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,
@@ -1721,14 +1721,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);
@@ -1842,7 +1842,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;
@@ -2103,7 +2103,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;
@@ -2220,7 +2220,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,
@@ -2340,7 +2340,6 @@ static uint dump_events_for_db(char *db)
(const char *) delimiter);
my_free(query_str);
-
restore_time_zone(sql_file, delimiter);
restore_sql_mode(sql_file, delimiter);
@@ -2433,7 +2432,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,
@@ -2491,9 +2490,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",
@@ -4076,7 +4075,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(&dynamic_where, " AND TABLESPACE_NAME IN ("
"SELECT DISTINCT TABLESPACE_NAME FROM"
@@ -4089,7 +4088,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(&dynamic_where, "'");
dynstr_append_checked(&dynamic_where, name_buff);
@@ -4119,7 +4118,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(&dynamic_where, "'");
dynstr_append_checked(&dynamic_where, db_name_buff);
dynstr_append_checked(&dynamic_where, "',");
@@ -5320,7 +5319,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;
@@ -5378,7 +5377,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);
@@ -5632,8 +5631,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 444278d40f1..eec4a8d3268 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);
@@ -379,7 +379,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];
@@ -417,7 +418,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;
@@ -505,7 +506,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;
@@ -542,7 +544,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;
@@ -660,7 +662,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",
@@ -693,7 +695,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);
@@ -723,7 +725,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",
@@ -771,10 +773,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);
@@ -797,10 +799,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++)
@@ -834,11 +836,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;
@@ -847,7 +849,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 *)))
@@ -861,10 +863,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;
@@ -907,7 +909,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/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 d7853a46ecb..d0c4768e882 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -76,3 +76,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 f8be55f84b2..02cab02b52e 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 88ce401fabc..f7a3ae8cc8a 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -331,7 +331,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/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index a244a41f4f6..7c01e4af9dc 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -118,8 +118,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()
@@ -144,9 +148,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)
@@ -173,7 +177,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/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 81001174172..f75f65f0644 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1807,9 +1807,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/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 4123b06b0a7..e5d6caf397b 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -6108,6 +6108,45 @@ 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 d8e97371294..38814bc36d6 100644
--- a/mysql-test/r/ctype_utf8mb4.result
+++ b/mysql-test/r/ctype_utf8mb4.result
@@ -2825,6 +2825,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/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/locale.result b/mysql-test/r/locale.result
index c28cedae8b1..95c1f51fd87 100644
--- a/mysql-test/r/locale.result
+++ b/mysql-test/r/locale.result
@@ -102,6 +102,34 @@ 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;
+#
# Start of 5.6 tests
#
#
diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result
index 66e23c18355..b86f3a7e1aa 100644
--- a/mysql-test/r/mysqlcheck.result
+++ b/mysql-test/r/mysqlcheck.result
@@ -376,6 +376,11 @@ Repairing views
test.v1 OK
drop view v1;
drop table t1;
+create table `#mysql50#t1``1` (a int) engine=myisam;
+show tables;
+Tables_in_test
+t1`1
+drop table `t1``1`;
#
#MDEV-7384 [PATCH] add PERSISENT FOR ALL option to mysqlanalyze/mysqlcheck
#
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index 5b0fbbcbe87..7e2593eb9c9 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/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 95b82bdef82..7e5ac85a552 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -440,6 +440,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,
@@ -463,9 +464,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/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
index 353303825e5..0ef6f65d0ff 100644
--- a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
+++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
@@ -1,82 +1,48 @@
-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 "idx" is corrupted
+ERROR HY000: Index "idx" is corrupted
ERROR HY000: Index corrupt_bit_test_ā is corrupted
-select z from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
-show warnings;
Level Code Message
Warning 180 InnoDB: Index "idxē" for table "test"."corrupt_bit_test_ā" is marked as corrupted
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 "idx" is corrupted
+ERROR HY000: Index "idx" 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_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
index d6d77076b83..ee04e8d66fc 100644
--- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
+++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
@@ -2,46 +2,24 @@
# Test for persistent corrupt bit for corrupted index and table
#
-- source include/have_innodb.inc
--- source include/have_innodb_16k.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/have_innodb_16k.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
+call mtr.add_suppression("Flagged corruption of idx.*in");
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);
@@ -54,38 +32,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="";
-# 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_ā;
@@ -109,7 +70,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_ā;
@@ -119,14 +79,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/perfschema/r/digest_table_full.result b/mysql-test/suite/perfschema/r/digest_table_full.result
index 64742d1dbe9..70e4213ffcc 100644
--- a/mysql-test/suite/perfschema/r/digest_table_full.result
+++ b/mysql-test/suite/perfschema/r/digest_table_full.result
@@ -113,7 +113,7 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARN
SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR SUM_ROWS_AFFECTED SUM_WARNINGS SUM_ERRORS
NULL NULL NULL 55 32 1 2
-statements_digest b12e7d0f2ac88c8fad9ac8dabb347b09 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 0 0 0
+statements_digest 52e3729216b72a67a671ac3b93a1f1d3 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 0 0 0
SHOW VARIABLES LIKE "performance_schema_digests_size";
Variable_name Value
performance_schema_digests_size 2
diff --git a/mysql-test/suite/perfschema/r/rpl_gtid_func.result b/mysql-test/suite/perfschema/r/rpl_gtid_func.result
index 389d21e179f..962e3e19e47 100644
--- a/mysql-test/suite/perfschema/r/rpl_gtid_func.result
+++ b/mysql-test/suite/perfschema/r/rpl_gtid_func.result
@@ -37,7 +37,7 @@ select digest, digest_text, count_star
from performance_schema.events_statements_summary_by_digest
where digest_text like "%in_%_digest%";
digest digest_text count_star
-1281ed1e23aaa2e5528e90ebf98cfbdd SELECT ? AS `in_master_digest` 1
+d4c0df8aac0e1b575629aad4534b5c7b SELECT ? AS `in_master_digest` 1
insert into test.marker values (2);
**** On Slave ****
select * from test.marker;
@@ -64,7 +64,7 @@ select digest, digest_text, count_star
from performance_schema.events_statements_summary_by_digest
where digest_text like "%in_%_digest%";
digest digest_text count_star
-e0d84aed3bfac675887b38c4902f057f SELECT ? AS `in_slave_digest` 1
+aa6b10b84ad0f249ef4fcece8da6dd77 SELECT ? AS `in_slave_digest` 1
**** On Master ****
delete from performance_schema.setup_objects
where object_schema='master';
diff --git a/mysql-test/suite/perfschema/r/start_server_low_digest.result b/mysql-test/suite/perfschema/r/start_server_low_digest.result
index aff444250e0..eebebe5af88 100644
--- a/mysql-test/suite/perfschema/r/start_server_low_digest.result
+++ b/mysql-test/suite/perfschema/r/start_server_low_digest.result
@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
####################################
SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
event_name digest digest_text sql_text
-statement/sql/truncate e1c917a43f978456fab15240f89372ca TRUNCATE TABLE truncate table events_statements_history_long
-statement/sql/select 4cc1c447d79877c4e8df0423fd0cde9a SELECT ? + ? + SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
+statement/sql/truncate c4afa12dd9165da1a5fe8b74cf43005d TRUNCATE TABLE truncate table events_statements_history_long
+statement/sql/select 719c3d02e550844d831d96809f405c39 SELECT ? + ? + SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
diff --git a/mysql-test/suite/perfschema/r/statement_digest.result b/mysql-test/suite/perfschema/r/statement_digest.result
index a48006c8ba3..13a82fb31ad 100644
--- a/mysql-test/suite/perfschema/r/statement_digest.result
+++ b/mysql-test/suite/perfschema/r/statement_digest.result
@@ -112,41 +112,41 @@ DROP TRIGGER trg;
SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR SUM_ROWS_AFFECTED SUM_WARNINGS SUM_ERRORS
-statements_digest b12e7d0f2ac88c8fad9ac8dabb347b09 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 0 0 0
-statements_digest 390f3ff3444c4de44fcbd052b11caf4e SELECT ? FROM `t1` 2 0 0 0
-statements_digest 8726524372f6e4924bbe1393b772498e SELECT ?, ... FROM `t1` 2 0 0 0
-statements_digest 5b06fb13fa9af5e8a4ec26bac8f994cd SELECT ? FROM `t2` 1 0 0 0
-statements_digest 82201946968b4baca616292f96e933a7 SELECT ?, ... FROM `t2` 2 0 0 0
-statements_digest 35d365779571257e8837f01b39dd9df5 INSERT INTO `t1` VALUES (?) 2 2 0 0
-statements_digest eaaf6c26e98130ec21cfae1389e3eb94 INSERT INTO `t2` VALUES (?) 1 1 0 0
-statements_digest 28f3cfdcfffeff3219bdd255ed15e6ac INSERT INTO `t3` VALUES (...) 4 4 0 0
-statements_digest 166a9591b81371a6ea389f27cfc1e5fd INSERT INTO `t4` VALUES (...) 1 1 0 0
-statements_digest fb25b9f9146120fb72c3c732e79dcc82 INSERT INTO `t5` VALUES (...) 1 1 0 0
-statements_digest 58bb7798d974224ff08742502eed1aae INSERT INTO `t1` VALUES (?) /* , ... */ 2 7 0 0
-statements_digest 3352b44dcaf21f59141ea76b5cace5c0 INSERT INTO `t3` VALUES (...) /* , ... */ 1 3 0 0
-statements_digest 1905c012e5d6a3a12e39b0b3ce13b22a INSERT INTO `t5` VALUES (...) /* , ... */ 1 3 0 0
-statements_digest 981d682c1e63b437c33230eb558d0f64 INSERT INTO `t6` VALUES (...) 5 5 0 0
-statements_digest aeb185ab9b6e9d5a49e47c8741b8acdf SELECT ? + ? 3 0 0 0
-statements_digest d3804664eeee11407f3fcbd5c29a1f73 SELECT ? 1 0 0 0
-statements_digest 6382c1dfc79755af2dd46113acea142b CREATE SCHEMA `statements_digest_temp` 2 2 0 0
-statements_digest 256f8dfc97d90a79103ebd6616b8d7aa DROP SCHEMA `statements_digest_temp` 2 0 0 0
-statements_digest 5315d33e7ef87b104b73912d484af6a3 SELECT ? FROM `no_such_table` 1 0 0 1
-statements_digest dcde8f720a419aa5d52246207268cf6c CREATE TABLE `dup_table` ( `c` CHARACTER (?) ) 2 0 0 1
-statements_digest b4b4abab3f030642444fb32c44f28058 DROP TABLE `dup_table` 1 0 0 0
-statements_digest a34ed519fdeb4fe4460038db92ea0c20 INSERT INTO `t11` VALUES (?) 1 1 1 0
-statements_digest d3eda26b379bd56340ce84fe395dfff7 SHOW WARNINGS 1 0 0 0
-statements_digest e6aa634cf5a630087fefe9868b018329 PREPARE `stmt` FROM ? 1 0 0 0
-statements_digest 4de34527c0dfef6ad8387d4359f78c78 EXECUTE `stmt` 2 0 0 0
-statements_digest 54592849b6cf7386568c88e7fb20f61e DEALLOCATE PREPARE `stmt` 1 0 0 0
-statements_digest ee90db91a06cedfbcccf80f951dc58cd CREATE PROCEDURE `p1` ( ) BEGIN SELECT * FROM `t12` ; END 1 0 0 0
-statements_digest f964655a0037d2f194030bd024eab748 CALL `p1` ( ) 2 0 0 0
-statements_digest 788d8223f67ba10d1b97fcaa42fec081 DROP PROCEDURE `p1` 1 0 0 0
-statements_digest 5146273ef7d98ee1954d23fd98a35d68 CREATE FUNCTION `func` ( `a` INTEGER , `b` INTEGER ) RETURNS INTEGER (?) RETURN `a` + `b` 1 0 0 0
-statements_digest 2c9b8e1e7f2ad3ca3c49abb2ea30e871 SELECT `func` (...) 2 0 0 0
-statements_digest f48e30910f8e7758b818c088916424cd DROP FUNCTION `func` 1 0 0 0
-statements_digest 53ccf1d241eeb749f1e1b7becc65006f CREATE TRIGGER `trg` BEFORE INSERT ON `t12` FOR EACH ROW SET @? := ? 1 0 0 0
-statements_digest a9722a0717a57275431575c7204d71c1 INSERT INTO `t12` VALUES (?) 2 2 0 0
-statements_digest 2d48809e6899f63ec304776466a63eef DROP TRIGGER `trg` 1 0 0 0
+statements_digest 52e3729216b72a67a671ac3b93a1f1d3 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 0 0 0
+statements_digest a76073841b59a83de0fcdb6a0158b94a SELECT ? FROM `t1` 2 0 0 0
+statements_digest d91813c4d7a128822624a55b43bab7b2 SELECT ?, ... FROM `t1` 2 0 0 0
+statements_digest 8d1d0319e2ce41e1c41455a06b8905f8 SELECT ? FROM `t2` 1 0 0 0
+statements_digest 704f1e85525022d18028b3493bf61e65 SELECT ?, ... FROM `t2` 2 0 0 0
+statements_digest 7f60599ab03830f5571b306d71e47ba3 INSERT INTO `t1` VALUES (?) 2 2 0 0
+statements_digest 103d388f122df6a6a2c9f7fa01d90d7d INSERT INTO `t2` VALUES (?) 1 1 0 0
+statements_digest f1f56fda9303c1e2555bd67d431398ab INSERT INTO `t3` VALUES (...) 4 4 0 0
+statements_digest 08fc8813613c3cd44736a4abbb0cd095 INSERT INTO `t4` VALUES (...) 1 1 0 0
+statements_digest ab209b79451b94d03d8e20374ec18795 INSERT INTO `t5` VALUES (...) 1 1 0 0
+statements_digest 4729eb58cad3b77435bcd17864cfe322 INSERT INTO `t1` VALUES (?) /* , ... */ 2 7 0 0
+statements_digest 8e543c7785feeeb3e9a1957397a1033f INSERT INTO `t3` VALUES (...) /* , ... */ 1 3 0 0
+statements_digest 3dd587a1c42991bb323cbaa4c6fb61d0 INSERT INTO `t5` VALUES (...) /* , ... */ 1 3 0 0
+statements_digest 6f2f9f471f739d16b4ff4faf256e839e INSERT INTO `t6` VALUES (...) 5 5 0 0
+statements_digest 9701bfa1fb64563334f1a52953e065f3 SELECT ? + ? 3 0 0 0
+statements_digest b0785a540ffc1743c4e0879d193a4b10 SELECT ? 1 0 0 0
+statements_digest bee0eebfc340dbd233ee8c86270ac6ea CREATE SCHEMA `statements_digest_temp` 2 2 0 0
+statements_digest a35fd3ac67e64b9ac41a53781a7f5662 DROP SCHEMA `statements_digest_temp` 2 0 0 0
+statements_digest 52ec0213cba551f38d069c94a50cd2c7 SELECT ? FROM `no_such_table` 1 0 0 1
+statements_digest 27d4298be49de7a7606fcc8122ce7cd6 CREATE TABLE `dup_table` ( `c` CHARACTER (?) ) 2 0 0 1
+statements_digest 8a9b185842f12475c7ffa350ade45408 DROP TABLE `dup_table` 1 0 0 0
+statements_digest bda68c0a1eca7b625a5158da41ebbcf9 INSERT INTO `t11` VALUES (?) 1 1 1 0
+statements_digest 196c9f451360b5e24e03aa82f86006ae SHOW WARNINGS 1 0 0 0
+statements_digest 3413dd64a34c2148e669e3283ca41ff5 PREPARE `stmt` FROM ? 1 0 0 0
+statements_digest fcec9dcf45c26dabade2c7a4ab818543 EXECUTE `stmt` 2 0 0 0
+statements_digest 9e5e4f78f8226cc853fa1ce62ae61f9d DEALLOCATE PREPARE `stmt` 1 0 0 0
+statements_digest c92f30dceb52f470a6c36400bdb372c6 CREATE PROCEDURE `p1` ( ) BEGIN SELECT * FROM `t12` ; END 1 0 0 0
+statements_digest db338b4f4a13d74acda7a7b9dae2b0b4 CALL `p1` ( ) 2 0 0 0
+statements_digest c2c92e9e7ac73741622d1f264e08c384 DROP PROCEDURE `p1` 1 0 0 0
+statements_digest c99aad5579088b31cdd53be4bfbc2b6e CREATE FUNCTION `func` ( `a` INTEGER , `b` INTEGER ) RETURNS INTEGER (?) RETURN `a` + `b` 1 0 0 0
+statements_digest 1f4ce8758787f5aa5f51f1ee7f3b8119 SELECT `func` (...) 2 0 0 0
+statements_digest ab76a0821015fa000a1df9c684072e37 DROP FUNCTION `func` 1 0 0 0
+statements_digest ce5db6554a357045978a5572c84a7655 CREATE TRIGGER `trg` BEFORE INSERT ON `t12` FOR EACH ROW SET @? := ? 1 0 0 0
+statements_digest 801f02819c67e56fe3f22cc7dda99707 INSERT INTO `t12` VALUES (?) 2 2 0 0
+statements_digest dc3b07fe8e4d5fa91b383605f18512b0 DROP TRIGGER `trg` 1 0 0 0
####################################
# CLEANUP
####################################
diff --git a/mysql-test/suite/perfschema/r/statement_digest_consumers.result b/mysql-test/suite/perfschema/r/statement_digest_consumers.result
index 351bd41159c..a1c4fbe1d25 100644
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers.result
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers.result
@@ -125,41 +125,41 @@ DROP TRIGGER trg;
####################################
SELECT schema_name, digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
schema_name digest digest_text count_star
-statements_digest b12e7d0f2ac88c8fad9ac8dabb347b09 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
-statements_digest 390f3ff3444c4de44fcbd052b11caf4e SELECT ? FROM `t1` 2
-statements_digest 8726524372f6e4924bbe1393b772498e SELECT ?, ... FROM `t1` 2
-statements_digest 5b06fb13fa9af5e8a4ec26bac8f994cd SELECT ? FROM `t2` 1
-statements_digest 82201946968b4baca616292f96e933a7 SELECT ?, ... FROM `t2` 2
-statements_digest 35d365779571257e8837f01b39dd9df5 INSERT INTO `t1` VALUES (?) 2
-statements_digest eaaf6c26e98130ec21cfae1389e3eb94 INSERT INTO `t2` VALUES (?) 1
-statements_digest 28f3cfdcfffeff3219bdd255ed15e6ac INSERT INTO `t3` VALUES (...) 4
-statements_digest 166a9591b81371a6ea389f27cfc1e5fd INSERT INTO `t4` VALUES (...) 1
-statements_digest fb25b9f9146120fb72c3c732e79dcc82 INSERT INTO `t5` VALUES (...) 1
-statements_digest 58bb7798d974224ff08742502eed1aae INSERT INTO `t1` VALUES (?) /* , ... */ 2
-statements_digest 3352b44dcaf21f59141ea76b5cace5c0 INSERT INTO `t3` VALUES (...) /* , ... */ 1
-statements_digest 1905c012e5d6a3a12e39b0b3ce13b22a INSERT INTO `t5` VALUES (...) /* , ... */ 1
-statements_digest 981d682c1e63b437c33230eb558d0f64 INSERT INTO `t6` VALUES (...) 5
-statements_digest aeb185ab9b6e9d5a49e47c8741b8acdf SELECT ? + ? 3
-statements_digest d3804664eeee11407f3fcbd5c29a1f73 SELECT ? 1
-statements_digest 6382c1dfc79755af2dd46113acea142b CREATE SCHEMA `statements_digest_temp` 2
-statements_digest 256f8dfc97d90a79103ebd6616b8d7aa DROP SCHEMA `statements_digest_temp` 2
-statements_digest 5315d33e7ef87b104b73912d484af6a3 SELECT ? FROM `no_such_table` 1
-statements_digest dcde8f720a419aa5d52246207268cf6c CREATE TABLE `dup_table` ( `c` CHARACTER (?) ) 2
-statements_digest b4b4abab3f030642444fb32c44f28058 DROP TABLE `dup_table` 1
-statements_digest a34ed519fdeb4fe4460038db92ea0c20 INSERT INTO `t11` VALUES (?) 1
-statements_digest d3eda26b379bd56340ce84fe395dfff7 SHOW WARNINGS 1
-statements_digest e6aa634cf5a630087fefe9868b018329 PREPARE `stmt` FROM ? 1
-statements_digest 4de34527c0dfef6ad8387d4359f78c78 EXECUTE `stmt` 2
-statements_digest 54592849b6cf7386568c88e7fb20f61e DEALLOCATE PREPARE `stmt` 1
-statements_digest ee90db91a06cedfbcccf80f951dc58cd CREATE PROCEDURE `p1` ( ) BEGIN SELECT * FROM `t12` ; END 1
-statements_digest f964655a0037d2f194030bd024eab748 CALL `p1` ( ) 2
-statements_digest 788d8223f67ba10d1b97fcaa42fec081 DROP PROCEDURE `p1` 1
-statements_digest 5146273ef7d98ee1954d23fd98a35d68 CREATE FUNCTION `func` ( `a` INTEGER , `b` INTEGER ) RETURNS INTEGER (?) RETURN `a` + `b` 1
-statements_digest 2c9b8e1e7f2ad3ca3c49abb2ea30e871 SELECT `func` (...) 2
-statements_digest f48e30910f8e7758b818c088916424cd DROP FUNCTION `func` 1
-statements_digest 53ccf1d241eeb749f1e1b7becc65006f CREATE TRIGGER `trg` BEFORE INSERT ON `t12` FOR EACH ROW SET @? := ? 1
-statements_digest a9722a0717a57275431575c7204d71c1 INSERT INTO `t12` VALUES (?) 2
-statements_digest 2d48809e6899f63ec304776466a63eef DROP TRIGGER `trg` 1
+statements_digest 52e3729216b72a67a671ac3b93a1f1d3 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
+statements_digest a76073841b59a83de0fcdb6a0158b94a SELECT ? FROM `t1` 2
+statements_digest d91813c4d7a128822624a55b43bab7b2 SELECT ?, ... FROM `t1` 2
+statements_digest 8d1d0319e2ce41e1c41455a06b8905f8 SELECT ? FROM `t2` 1
+statements_digest 704f1e85525022d18028b3493bf61e65 SELECT ?, ... FROM `t2` 2
+statements_digest 7f60599ab03830f5571b306d71e47ba3 INSERT INTO `t1` VALUES (?) 2
+statements_digest 103d388f122df6a6a2c9f7fa01d90d7d INSERT INTO `t2` VALUES (?) 1
+statements_digest f1f56fda9303c1e2555bd67d431398ab INSERT INTO `t3` VALUES (...) 4
+statements_digest 08fc8813613c3cd44736a4abbb0cd095 INSERT INTO `t4` VALUES (...) 1
+statements_digest ab209b79451b94d03d8e20374ec18795 INSERT INTO `t5` VALUES (...) 1
+statements_digest 4729eb58cad3b77435bcd17864cfe322 INSERT INTO `t1` VALUES (?) /* , ... */ 2
+statements_digest 8e543c7785feeeb3e9a1957397a1033f INSERT INTO `t3` VALUES (...) /* , ... */ 1
+statements_digest 3dd587a1c42991bb323cbaa4c6fb61d0 INSERT INTO `t5` VALUES (...) /* , ... */ 1
+statements_digest 6f2f9f471f739d16b4ff4faf256e839e INSERT INTO `t6` VALUES (...) 5
+statements_digest 9701bfa1fb64563334f1a52953e065f3 SELECT ? + ? 3
+statements_digest b0785a540ffc1743c4e0879d193a4b10 SELECT ? 1
+statements_digest bee0eebfc340dbd233ee8c86270ac6ea CREATE SCHEMA `statements_digest_temp` 2
+statements_digest a35fd3ac67e64b9ac41a53781a7f5662 DROP SCHEMA `statements_digest_temp` 2
+statements_digest 52ec0213cba551f38d069c94a50cd2c7 SELECT ? FROM `no_such_table` 1
+statements_digest 27d4298be49de7a7606fcc8122ce7cd6 CREATE TABLE `dup_table` ( `c` CHARACTER (?) ) 2
+statements_digest 8a9b185842f12475c7ffa350ade45408 DROP TABLE `dup_table` 1
+statements_digest bda68c0a1eca7b625a5158da41ebbcf9 INSERT INTO `t11` VALUES (?) 1
+statements_digest 196c9f451360b5e24e03aa82f86006ae SHOW WARNINGS 1
+statements_digest 3413dd64a34c2148e669e3283ca41ff5 PREPARE `stmt` FROM ? 1
+statements_digest fcec9dcf45c26dabade2c7a4ab818543 EXECUTE `stmt` 2
+statements_digest 9e5e4f78f8226cc853fa1ce62ae61f9d DEALLOCATE PREPARE `stmt` 1
+statements_digest c92f30dceb52f470a6c36400bdb372c6 CREATE PROCEDURE `p1` ( ) BEGIN SELECT * FROM `t12` ; END 1
+statements_digest db338b4f4a13d74acda7a7b9dae2b0b4 CALL `p1` ( ) 2
+statements_digest c2c92e9e7ac73741622d1f264e08c384 DROP PROCEDURE `p1` 1
+statements_digest c99aad5579088b31cdd53be4bfbc2b6e CREATE FUNCTION `func` ( `a` INTEGER , `b` INTEGER ) RETURNS INTEGER (?) RETURN `a` + `b` 1
+statements_digest 1f4ce8758787f5aa5f51f1ee7f3b8119 SELECT `func` (...) 2
+statements_digest ab76a0821015fa000a1df9c684072e37 DROP FUNCTION `func` 1
+statements_digest ce5db6554a357045978a5572c84a7655 CREATE TRIGGER `trg` BEFORE INSERT ON `t12` FOR EACH ROW SET @? := ? 1
+statements_digest 801f02819c67e56fe3f22cc7dda99707 INSERT INTO `t12` VALUES (?) 2
+statements_digest dc3b07fe8e4d5fa91b383605f18512b0 DROP TRIGGER `trg` 1
SELECT digest, digest_text FROM performance_schema.events_statements_current;
digest digest_text
####################################
diff --git a/mysql-test/suite/perfschema/r/statement_digest_long_query.result b/mysql-test/suite/perfschema/r/statement_digest_long_query.result
index dd0244475cc..a723b8e9fa5 100644
--- a/mysql-test/suite/perfschema/r/statement_digest_long_query.result
+++ b/mysql-test/suite/perfschema/r/statement_digest_long_query.result
@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
####################################
SELECT schema_name, digest, digest_text, count_star FROM events_statements_summary_by_digest;
schema_name digest digest_text count_star
-performance_schema b6650e3f746acc31ef465aede8087e93 TRUNCATE TABLE `events_statements_summary_by_digest` 1
-performance_schema 63f9aaeed7859671c6a42c75fcd43785 SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? 1
+performance_schema 2f6bc98e6ca82311b17aac2f1e7cd85d TRUNCATE TABLE `events_statements_summary_by_digest` 1
+performance_schema 6c4b347800e3aa6bd3e41e3b97b3828a SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? 1
diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result
index 2577a36cad4..83b88ed0480 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 2577a36cad4..83b88ed0480 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/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 2f34e47823b..7c0723ae82e 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -1678,6 +1678,29 @@ 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 d59c6d397fc..6b876cc5eba 100644
--- a/mysql-test/t/ctype_utf8mb4.test
+++ b/mysql-test/t/ctype_utf8mb4.test
@@ -1822,6 +1822,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/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/locale.test b/mysql-test/t/locale.test
index 5d1fd24d750..b1fbc40f0c8 100644
--- a/mysql-test/t/locale.test
+++ b/mysql-test/t/locale.test
@@ -65,6 +65,25 @@ 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;
+
+--echo #
--echo # Start of 5.6 tests
--echo #
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index 88f0d034bf0..e479a2232f0 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -350,6 +350,11 @@ create table t1(a int);
drop view v1;
drop table t1;
+create table `#mysql50#t1``1` (a int) engine=myisam;
+--exec $MYSQL_CHECK --fix-table-names --databases test
+show tables;
+drop table `t1``1`;
+
--echo #
--echo #MDEV-7384 [PATCH] add PERSISENT FOR ALL option to mysqlanalyze/mysqlcheck
--echo #
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index f59a5d01cf5..496a6829577 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/ssl_ca.test b/mysql-test/t/ssl_ca.test
new file mode 100644
index 00000000000..8e81f44e61c
--- /dev/null
+++ b/mysql-test/t/ssl_ca.test
@@ -0,0 +1,36 @@
+--source include/have_ssl_communication.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 696cfe67586..e7e53fb4c37 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -387,6 +387,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/valgrind.supp b/mysql-test/valgrind.supp
index d83bb1d206c..723b609de8f 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,43 +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 memalign memory loss2
- Memcheck:Leak
- fun:memalign
- fun:tls_get_addr_tail
- ...
- fun:*ha_initialize_handlerton*
-}
-
-{
pthread pthread_key_create
Memcheck:Leak
fun:malloc
@@ -1012,18 +945,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
@@ -1176,6 +1097,23 @@
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*
+}
{
ConnectSE: unixODBC SQLAllocEnv leaves some "still reachable" pointers
@@ -1289,3 +1227,4 @@
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
}
+
diff --git a/mysys/errors.c b/mysys/errors.c
index 11e7d04e79e..2d29740a689 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates
- Copyright (c) 1995, 2013, Monty Program 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/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 06a76c68477..f891a22b17d 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -1873,6 +1873,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_write.c b/mysys/my_write.c
index a7985997036..43735c18f0a 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 3359b5dce29..96b106bec14 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 a9fc542faf6..ab810c64c67 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/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc
index d04ff6fa9d5..cec3f60505c 100644
--- a/plugin/feedback/url_http.cc
+++ b/plugin/feedback/url_http.cc
@@ -190,6 +190,7 @@ int Url_http::send(const char* data, size_t data_length)
break;
closesocket(fd);
+ fd= INVALID_SOCKET;
}
freeaddrinfo(addrs);
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index 45ad0467163..fc375fcd765 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
@@ -621,7 +621,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 26f02734d25..9105b72d57c 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1045,28 +1045,44 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
} while (0)
-#define EXTENSION_SET_STRING(OPTS, X, STR) \
+#define EXTENSION_SET_STRING_X(OPTS, X, STR, dup) \
do { \
if ((OPTS)->extension) \
my_free((OPTS)->extension->X); \
else \
ALLOCATE_EXTENSIONS(OPTS); \
(OPTS)->extension->X= ((STR) != NULL) ? \
- my_strdup((STR), MYF(MY_WME)) : NULL; \
+ dup((STR), MYF(MY_WME)) : NULL; \
} while (0)
+#define EXTENSION_SET_STRING(OPTS, X, STR) \
+ EXTENSION_SET_STRING_X(OPTS, X, STR, my_strdup)
+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
-#define SET_SSL_OPTION(OPTS, opt_var, arg) \
- my_free((OPTS)->opt_var); \
- (OPTS)->opt_var= arg ? my_strdup(arg, MYF(MY_WME)) : NULL;
-#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) \
- EXTENSION_SET_STRING((OPTS), X, (STR));
+#define SET_SSL_OPTION_X(OPTS, opt_var, arg, dup) \
+ my_free((OPTS)->opt_var); \
+ (OPTS)->opt_var= arg ? dup(arg, MYF(MY_WME)) : NULL;
+#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) \
+ EXTENSION_SET_STRING_X((OPTS), X, (STR), dup);
+
+static char *set_ssl_option_unpack_path(const char *arg, myf flags)
+{
+ char buff[FN_REFLEN + 1];
+ unpack_filename(buff, (char *)arg);
+ return my_strdup(buff, flags);
+}
+
#else
-#define SET_SSL_OPTION(OPTS, opt_var,arg) do { } while(0)
-#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) do { } while(0)
+#define SET_SSL_OPTION_X(OPTS, opt_var,arg, dup) do { } while(0)
+#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) do { } while(0)
#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */
+#define SET_SSL_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, my_strdup)
+#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, my_strdup)
+#define SET_SSL_PATH_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, set_ssl_option_unpack_path)
+#define EXTENSION_SET_SSL_PATH_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, set_ssl_option_unpack_path)
+
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group)
{
@@ -4373,25 +4389,25 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
mysql->net.vio->async_context= ctxt;
break;
case MYSQL_OPT_SSL_KEY:
- SET_SSL_OPTION(&mysql->options,ssl_key, arg);
+ SET_SSL_PATH_OPTION(&mysql->options,ssl_key, arg);
break;
case MYSQL_OPT_SSL_CERT:
- SET_SSL_OPTION(&mysql->options, ssl_cert, arg);
+ SET_SSL_PATH_OPTION(&mysql->options, ssl_cert, arg);
break;
case MYSQL_OPT_SSL_CA:
- SET_SSL_OPTION(&mysql->options,ssl_ca, arg);
+ SET_SSL_PATH_OPTION(&mysql->options,ssl_ca, arg);
break;
case MYSQL_OPT_SSL_CAPATH:
- SET_SSL_OPTION(&mysql->options,ssl_capath, arg);
+ SET_SSL_PATH_OPTION(&mysql->options,ssl_capath, arg);
break;
case MYSQL_OPT_SSL_CIPHER:
SET_SSL_OPTION(&mysql->options,ssl_cipher, arg);
break;
case MYSQL_OPT_SSL_CRL:
- EXTENSION_SET_SSL_STRING(&mysql->options, ssl_crl, arg);
+ EXTENSION_SET_SSL_PATH_STRING(&mysql->options, ssl_crl, arg);
break;
case MYSQL_OPT_SSL_CRLPATH:
- EXTENSION_SET_SSL_STRING(&mysql->options, ssl_crlpath, arg);
+ EXTENSION_SET_SSL_PATH_STRING(&mysql->options, ssl_crlpath, arg);
break;
case MYSQL_OPT_CONNECT_ATTR_RESET:
ENSURE_EXTENSIONS_PRESENT(&mysql->options);
diff --git a/sql/field.cc b/sql/field.cc
index b356b126c16..eb017802da3 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1816,6 +1816,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 81b16606e8b..2770b8be213 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -884,11 +884,12 @@ public:
matches collation of the field (needed only for real string types).
*/
virtual bool match_collation_to_optimize_range() 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; }
bool set_warning(Sql_condition::enum_warning_level, unsigned int code,
int cuted_increment) const;
@@ -1132,8 +1133,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,
@@ -1144,15 +1147,15 @@ public:
int store(longlong nr, bool unsigned_val)=0;
int store_decimal(const my_decimal *);
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
- 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;
@@ -2468,10 +2471,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/item.cc b/sql/item.cc
index 065204dc9c3..6cdbccde729 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -272,9 +272,6 @@ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate)
*/
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;
@@ -282,11 +279,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_func.cc b/sql/item_func.cc
index a4a2782c8c4..b637213bc2d 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2939,12 +2939,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;
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 1d3dbaf9eeb..568a28e6465 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 bf3a9981943..866dbe65ecc 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -936,9 +936,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;
@@ -1083,9 +1082,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 a272504c0f2..591f0def43e 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -47,12 +47,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 efc3b120437..54f2830bef8 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 31a1d102bf7..1c5e09c5c09 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 93704e7c235..82cd82b5e7a 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
@@ -9738,9 +9738,6 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
/*
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.
*/
{
@@ -9759,10 +9756,37 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
NOTE: The base tables are added here are removed when
close_thread_tables is called.
*/
- RPL_TABLE_LIST *ptr= rgi->tables_to_lock;
- for (uint i= 0 ; ptr && (i < rgi->tables_to_lock_count);
- ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
+ TABLE_LIST *table_list_ptr= rgi->tables_to_lock;
+ for (uint i=0 ; table_list_ptr && (i < rgi->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, rgi, ptr->table, &conv_table))
@@ -9804,6 +9828,12 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
TABLE_LIST *ptr= rgi->tables_to_lock;
for (uint i=0 ; ptr && (i < rgi->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;
rgi->m_table_map.set_table(ptr->table_id, ptr->table);
/*
Following is passing flag about triggers on the server. The problem was
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index ad68275a274..22ef970dab9 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
@@ -121,16 +121,25 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi)
/*
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= rgi->tables_to_lock;
- for (uint i= 0 ; ptr&& (i< rgi->tables_to_lock_count);
- ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
+ TABLE_LIST *table_list_ptr= rgi->tables_to_lock;
+ for (uint i=0 ; table_list_ptr&& (i< rgi->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, rgi, ptr->table, &conv_table))
@@ -163,7 +172,15 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi)
*/
TABLE_LIST *ptr= rgi->tables_to_lock;
for (uint i=0; ptr && (i < rgi->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;
rgi->m_table_map.set_table(ptr->table_id, ptr->table);
+ }
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock);
#endif
@@ -1518,16 +1535,25 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
/*
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= rgi->tables_to_lock;
- for (uint i= 0 ; ptr&& (i< rgi->tables_to_lock_count);
- ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
+ TABLE_LIST *table_list_ptr= rgi->tables_to_lock;
+ for (uint i=0; table_list_ptr&& (i< rgi->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, rgi, ptr->table, &conv_table))
{
diff --git a/sql/slave.cc b/sql/slave.cc
index 651d5ba0171..5dce7feed73 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, MariaDB
+/* 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 5cc02c8a10b..c6b78b96aca 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 e181e14611b..b90108ed944 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
@@ -514,8 +514,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_lex.cc b/sql/sql_lex.cc
index bf3e38efa9e..db54dd6a8b0 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1479,32 +1479,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_reload.cc b/sql/sql_reload.cc
index 86d1e27a4ef..bcf2585ca2a 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 c2b25d812fb..063fe221403 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -15479,7 +15479,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);
@@ -15719,7 +15720,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_yacc.yy b/sql/sql_yacc.yy
index 72cb143b17b..c1cd2a94130 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2010, 2015, MariaDB
+ 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
@@ -1148,7 +1148,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
@@ -1197,7 +1196,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
@@ -1277,7 +1275,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_GTID_POS_SYM
%token MASTER_HOST_SYM
@@ -1637,7 +1634,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
@@ -2154,66 +2151,66 @@ 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_SSL_CRL_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_CRL_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_crl= $3.str;
}
- | MASTER_SSL_CRLPATH_SYM EQ TEXT_STRING_sys
+ | MASTER_SSL_CRLPATH_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_crlpath= $3.str;
}
- | 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 ||
@@ -2244,7 +2241,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;
}
@@ -2265,11 +2262,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;
/*
@@ -2285,17 +2282,17 @@ master_file_def:
*/
Lex->mi.pos= MY_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) */
Lex->mi.relay_log_pos= MY_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
}
- | MASTER_USE_GTID_SYM EQ CURRENT_POS_SYM
+ | MASTER_USE_GTID_SYM '=' CURRENT_POS_SYM
{
if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED)
{
@@ -2305,7 +2302,7 @@ master_file_def:
Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_CURRENT_POS;
}
;
- | MASTER_USE_GTID_SYM EQ SLAVE_POS_SYM
+ | MASTER_USE_GTID_SYM '=' SLAVE_POS_SYM
{
if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED)
{
@@ -2315,7 +2312,7 @@ master_file_def:
Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_SLAVE_POS;
}
;
- | MASTER_USE_GTID_SYM EQ NO_SYM
+ | MASTER_USE_GTID_SYM '=' NO_SYM
{
if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED)
{
@@ -3346,7 +3343,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;
@@ -3355,7 +3352,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;
@@ -3494,7 +3491,7 @@ statement_information:
;
statement_information_item:
- simple_target_specification EQ statement_information_item_name
+ simple_target_specification '=' statement_information_item_name
{
$$= new (thd->mem_root) Statement_information_item($3, $1);
if ($$ == NULL)
@@ -3551,7 +3548,7 @@ condition_information:
;
condition_information_item:
- simple_target_specification EQ condition_information_item_name
+ simple_target_specification '=' condition_information_item_name
{
$$= new (thd->mem_root) Condition_information_item($3, $1);
if ($$ == NULL)
@@ -4886,7 +4883,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:
@@ -7760,7 +7757,7 @@ opt_place:
opt_to:
/* empty */ {}
| TO_SYM {}
- | EQ {}
+ | '=' {}
| AS {}
;
@@ -7882,7 +7879,7 @@ slave_until:
MYSQL_YYABORT;
}
}
- | UNTIL_SYM MASTER_GTID_POS_SYM EQ TEXT_STRING_sys
+ | UNTIL_SYM MASTER_GTID_POS_SYM '=' TEXT_STRING_sys
{
Lex->mi.gtid_pos_str = $4;
}
@@ -8756,13 +8753,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)
@@ -8985,11 +8982,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; }
;
@@ -11088,7 +11085,7 @@ date_time_type:
table_alias:
/* empty */
| AS
- | EQ
+ | '='
;
opt_table_alias:
@@ -12019,7 +12016,7 @@ ident_eq_value:
;
equal:
- EQ {}
+ '=' {}
| SET_VAR {}
;
@@ -15019,11 +15016,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 */
@@ -15890,7 +15887,7 @@ no_definer:
;
definer:
- DEFINER_SYM EQ user_or_role
+ DEFINER_SYM '=' user_or_role
{
thd->lex->definer= $3;
}
@@ -15903,11 +15900,11 @@ definer:
**************************************************************************/
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 89a2036cb10..9e2ffc9aee0 100644
--- a/sql/threadpool_unix.cc
+++ b/sql/threadpool_unix.cc
@@ -169,6 +169,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;
@@ -606,12 +607,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;
}
@@ -623,6 +624,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 99ca76e2269..97827646f69 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -11936,6 +11936,35 @@ 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, prebuilt->trx, "CHECK TABLE");
+ row_mysql_unlock_data_dictionary(prebuilt->trx);
+ }
+
+ innobase_format_name(index_name, sizeof index_name,
+ index->name, TRUE);
+
+ push_warning_printf(thd,
+ Sql_condition::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;
@@ -12006,6 +12035,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, prebuilt->trx, "dict_set_index_corrupted");;
+ 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 1848ac6db4f..3e046026f50 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -3874,6 +3874,24 @@ check_if_can_drop_indexes:
drop_index = NULL;
}
+ /* Check if any of the existing indexes are marked as corruption
+ and if they are, refuse adding more indexes. */
+ if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) {
+ for (dict_index_t* index = dict_table_get_first_index(indexed_table);
+ index != NULL; index = dict_table_get_next_index(index)) {
+
+ if (!index->to_be_dropped && dict_index_is_corrupted(index)) {
+ char index_name[MAX_FULL_NAME_LEN + 1];
+
+ innobase_format_name(index_name, sizeof index_name,
+ index->name, TRUE);
+
+ my_error(ER_INDEX_CORRUPT, MYF(0), index_name);
+ DBUG_RETURN(true);
+ }
+ }
+ }
+
n_add_fk = 0;
if (ha_alter_info->handler_flags
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index de8a9610a64..a625a828b33 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);
}
@@ -721,7 +720,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 2538deeb27d..86a8970d7a7 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 b2b39598eab..d3eb687d064 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,cache) ((uint) (f).file & (cache->changed_blocks_hash_size-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,12 +741,12 @@ 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, uint changed_blocks_hash_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);
@@ -783,10 +783,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);
/* Changed blocks hash needs to be a power of 2 */
changed_blocks_hash_size= my_round_up_to_next_power(MY_MAX(changed_blocks_hash_size,
MIN_PAGECACHE_CHANGED_BLOCKS_HASH_SIZE));
@@ -822,7 +822,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))))
{
/*
@@ -853,7 +853,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_links_used= 0;
pagecache->free_hash_list= NULL;
@@ -890,7 +890,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
pagecache->hash_links, (long) pagecache->hash_link_root));
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;
@@ -981,11 +981,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, uint changed_blocks_hash_size)
{
- ulong blocks;
+ size_t blocks;
struct st_my_thread_var *thread;
WQUEUE *wqueue;
DBUG_ENTER("resize_pagecache");
@@ -1381,7 +1381,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;
@@ -2020,7 +2020,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++;
@@ -4872,7 +4872,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 f7ddb2fe716..c6314ac6d8c 100644
--- a/storage/maria/ma_pagecache.h
+++ b/storage/maria/ma_pagecache.h
@@ -119,21 +119,21 @@ 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 */
- ulong changed_blocks_hash_size; /* Number of hash buckets for file blocks */
- 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 */
+ size_t changed_blocks_hash_size;/* Number of hash buckets for file blocks */
+ 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 */
@@ -158,12 +158,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) */
@@ -196,11 +196,11 @@ 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, uint changed_blocks_hash_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, uint changed_blocks_hash_size);
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 421dc8392e3..8593264b212 100644
--- a/storage/maria/ma_sort.c
+++ b/storage/maria/ma_sort.c
@@ -90,6 +90,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
@@ -118,18 +139,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);
@@ -355,205 +365,196 @@ 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;
longlong sortbuff_size;
- ha_keys keys, idx;
+ ha_keys UNINIT_VAR(keys), idx;
uint sort_length;
uint maxbuffer;
- uchar **sort_keys=0;
+ uchar **sort_keys= NULL;
+ DBUG_ENTER("_ma_thr_find_all_keys");
+ DBUG_PRINT("enter", ("master: %d", sort_param->master));
- LINT_INIT(keys);
+ if (sort_param->sort_info->got_error)
+ DBUG_RETURN(TRUE);
- error=1;
+ set_sort_param_read_write(sort_param);
- if (my_thread_init())
- goto err;
+ 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));
- { /* 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;
+ sortbuff_size= sort_param->sortbuff_size;
+ memavl= MY_MAX(sortbuff_size, MIN_SORT_MEMORY);
+ idx= (ha_keys) sort_param->sort_info->max_records;
+ sort_length= sort_param->key_length;
+ maxbuffer= 1;
- if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
+ while (memavl >= MIN_SORT_MEMORY)
+ {
+ if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl)
+ keys= idx+1;
+ else if ((sort_param->sort_info->param->testflag &
+ (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) ==
+ T_FORCE_SORT_MEMORY)
{
- sort_param->write_keys= write_keys_varlen;
- sort_param->read_to_buffer= read_to_buffer_varlen;
- sort_param->write_key= write_merge_key_varlen;
+ /*
+ Use all of the given sort buffer for key data.
+ Allocate 1000 buffers at a start for new data. More buffers
+ will be allocated when needed.
+ */
+ keys= memavl / (sort_length+sizeof(char*));
+ maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+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));
-
- sortbuff_size= sort_param->sortbuff_size;
- memavl= MY_MAX(sortbuff_size, MIN_SORT_MEMORY);
- idx= (ha_keys) sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-
- while (memavl >= MIN_SORT_MEMORY)
- {
- if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl)
- keys= idx+1;
- else if ((sort_param->sort_info->param->testflag &
- (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) ==
- T_FORCE_SORT_MEMORY)
- {
- /*
- Use all of the given sort buffer for key data.
- Allocate 1000 buffers at a start for new data. More buffers
- will be allocated when needed.
- */
- keys= memavl / (sort_length+sizeof(char*));
- maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1);
- }
- else
- {
- uint maxbuffer_org;
- do
- {
- maxbuffer_org= 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. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u",
- sortbuff_size, (ulonglong) idx, sort_length);
- goto err;
- }
- }
- while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
- }
- if ((sort_keys= (uchar **)
- my_malloc(keys*(sort_length+sizeof(char*))+
- ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
- HA_FT_MAXBYTELEN : 0), MYF(0))))
+ uint maxbuffer_org;
+ do
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
- maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0)))
+ maxbuffer_org= 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. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u",
+ sortbuff_size, (ulonglong) idx, sort_length);
+ 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= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
}
- 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))))
{
- /* purecov: begin inspected */
- _ma_check_print_error(sort_param->sort_info->param,
- "aria_sort_buffer_size is too small. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u",
- sortbuff_size, (ulonglong) idx, sort_length);
- my_errno= ENOMEM;
- goto err;
- /* purecov: end inspected */
+ if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
+ maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0)))
+ {
+ 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 (memavl < MIN_SORT_MEMORY)
+ {
+ /* purecov: begin inspected */
+ _ma_check_print_error(sort_param->sort_info->param,
+ "aria_sort_buffer_size is too small. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u",
+ sortbuff_size, (ulonglong) idx, sort_length);
+ my_errno= ENOMEM;
+ goto err;
+ /* purecov: end inspected */
+ }
- if (sort_param->sort_info->param->testflag & T_VERBOSE)
- my_fprintf(stdout,
- "Key %d - Allocating buffer for %llu keys\n",
- sort_param->key + 1, (ulonglong) keys);
- sort_param->sort_keys= sort_keys;
+ if (sort_param->sort_info->param->testflag & T_VERBOSE)
+ my_fprintf(stdout,
+ "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,
- (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;
- goto ok;
+ 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.
- 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 ========"));
- }
+ 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;
}
@@ -563,7 +564,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;
@@ -617,18 +618,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 b878aaa0f7d..a1fff2e0e43 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 8e45ca1a3ea..b226a43d89f 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -86,6 +86,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
@@ -113,18 +135,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: %u", 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);
@@ -334,205 +345,197 @@ static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_rows 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, sortbuff_size;
- ha_keys keys, idx;
+ ha_keys UNINIT_VAR(keys), idx;
uint sort_length;
uint maxbuffer;
- uchar **sort_keys=0;
+ uchar **sort_keys= NULL;
+ int error= 0;
+ DBUG_ENTER("thr_find_all_keys");
+ DBUG_PRINT("enter", ("master: %d", sort_param->master));
- LINT_INIT(keys);
+ if (sort_param->sort_info->got_error)
+ DBUG_RETURN(TRUE);
- error=1;
+ set_sort_param_read_write(sort_param);
- if (my_thread_init())
- goto err;
+ 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));
- { /* 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;
+ sortbuff_size= sort_param->sortbuff_size;
+ memavl= MY_MAX(sortbuff_size, MIN_SORT_BUFFER);
+ idx= (ha_keys) sort_param->sort_info->max_records;
+ sort_length= sort_param->key_length;
+ maxbuffer= 1;
- if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
+ while (memavl >= MIN_SORT_BUFFER)
+ {
+ if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <=
+ (my_off_t) memavl)
+ keys= idx+1;
+ else if ((sort_param->sort_info->param->testflag &
+ (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) ==
+ T_FORCE_SORT_MEMORY)
{
- sort_param->write_keys= write_keys_varlen;
- sort_param->read_to_buffer= read_to_buffer_varlen;
- sort_param->write_key= write_merge_key_varlen;
+ /*
+ Use all of the given sort buffer for key data.
+ Allocate 1000 buffers at a start for new data. More buffers
+ will be allocated when needed.
+ */
+ keys= memavl / (sort_length+sizeof(char*));
+ maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+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;
-
- sortbuff_size= sort_param->sortbuff_size;
- memavl= MY_MAX(sortbuff_size, MIN_SORT_BUFFER);
- idx= (ha_keys) sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-
- while (memavl >= MIN_SORT_BUFFER)
- {
- if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <=
- (my_off_t) memavl)
- keys= idx+1;
- else if ((sort_param->sort_info->param->testflag &
- (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) ==
- T_FORCE_SORT_MEMORY)
- {
- /*
- Use all of the given sort buffer for key data.
- Allocate 1000 buffers at a start for new data. More buffers
- will be allocated when needed.
- */
- keys= memavl / (sort_length+sizeof(char*));
- maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1);
- }
- else
- {
- uint maxbuffer_org;
- do
- {
- maxbuffer_org= 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. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u",
- sortbuff_size, (ulonglong) idx, sort_length);
- goto err;
- }
- }
- while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
- }
- if ((sort_keys= (uchar**)
- my_malloc(keys*(sort_length+sizeof(char*))+
- ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
- HA_FT_MAXBYTELEN : 0), MYF(0))))
+ uint maxbuffer_org;
+ do
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
- maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0)))
+ maxbuffer_org= 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. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u",
+ sortbuff_size, (ulonglong) idx, sort_length);
+ 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= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
}
- if (memavl < MIN_SORT_BUFFER)
+ if ((sort_keys= (uchar**) my_malloc(keys * (sort_length + sizeof(char*)) +
+ ((sort_param->keyinfo->flag & HA_FULLTEXT) ?
+ HA_FT_MAXBYTELEN : 0), MYF(0))))
{
- /* purecov: begin inspected */
- mi_check_print_error(sort_param->sort_info->param,
- "myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u",
- sortbuff_size, (ulonglong) idx, sort_length);
- my_errno= ENOMEM;
- goto err;
- /* purecov: end inspected */
+ if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
+ maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0)))
+ {
+ 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. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u",
+ sortbuff_size, (ulonglong) idx, sort_length);
+ my_errno= ENOMEM;
+ goto err;
+ /* purecov: end inspected */
+ }
- if (sort_param->sort_info->param->testflag & T_VERBOSE)
- my_fprintf(stdout,
- "Key %d - Allocating buffer for %llu keys\n",
- sort_param->key + 1, (ulonglong) keys);
- sort_param->sort_keys= sort_keys;
+ if (sort_param->sort_info->param->testflag & T_VERBOSE)
+ my_fprintf(stdout,
+ "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;
+ }
- 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;
+
+ 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;
}
@@ -596,18 +599,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/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 0771752ba95..3dc13c906f9 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -12762,6 +12762,34 @@ 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, prebuilt->trx, "CHECK TABLE");
+ row_mysql_unlock_data_dictionary(prebuilt->trx);
+ }
+
+ innobase_format_name(index_name, sizeof index_name,
+ index->name, TRUE);
+
+ push_warning_printf(thd, Sql_condition::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;
@@ -12832,6 +12860,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, prebuilt->trx, "dict_set_index_corrupted");;
+ 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 38180902c03..17ace78d6a2 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -3884,6 +3884,24 @@ check_if_can_drop_indexes:
drop_index = NULL;
}
+ /* Check if any of the existing indexes are marked as corruption
+ and if they are, refuse adding more indexes. */
+ if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) {
+ for (dict_index_t* index = dict_table_get_first_index(indexed_table);
+ index != NULL; index = dict_table_get_next_index(index)) {
+
+ if (!index->to_be_dropped && dict_index_is_corrupted(index)) {
+ char index_name[MAX_FULL_NAME_LEN + 1];
+
+ innobase_format_name(index_name, sizeof index_name,
+ index->name, TRUE);
+
+ my_error(ER_INDEX_CORRUPT, MYF(0), index_name);
+ DBUG_RETURN(true);
+ }
+ }
+ }
+
n_add_fk = 0;
if (ha_alter_info->handler_flags
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 5d7fe60e453..b03cc1cee47 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
@@ -213,7 +213,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 3425a76427b..befe070b404 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\Monty Program AB\@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\Monty Program AB\@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})