1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00

Merge tag 'mariadb-5.5.50' into 5.5-galera

This commit is contained in:
Nirbhay Choubey
2016-06-23 12:54:38 -04:00
116 changed files with 1679 additions and 1011 deletions

View File

@@ -255,8 +255,10 @@ IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)
ENDIF()
MY_CHECK_C_COMPILER_FLAG(-ggdb3 HAVE_GGDB3)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
IF(HAVE_GGDB3)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
ENDIF()
OPTION(ENABLED_LOCAL_INFILE
"If we should should enable LOAD DATA LOCAL by default" ${IF_WIN})

View File

@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=49
MYSQL_VERSION_PATCH=50
MYSQL_VERSION_EXTRA=

View File

@@ -232,8 +232,6 @@ my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
int error = 0;
switch(optid) {
case 'c':
opt_count_iterations= 1;
@@ -281,8 +279,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case '?':
case 'I': /* Info */
error++;
break;
usage();
exit(0);
case OPT_CHARSETS_DIR:
#if MYSQL_VERSION_ID > 32300
charsets_dir = argument;
@@ -293,11 +291,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt->name);
break;
}
if (error)
{
usage();
exit(1);
}
return 0;
}

View File

@@ -238,7 +238,7 @@ static void dbDisconnect(char *host);
static void DBerror(MYSQL *mysql, const char *when);
static void safe_exit(int error);
static void print_result();
static uint fixed_name_length(const char *name);
static size_t fixed_name_length(const char *name);
static char *fix_table_name(char *dest, char *src);
int what_to_do = 0;
@@ -583,10 +583,10 @@ static int process_selected_tables(char *db, char **table_names, int tables)
} /* process_selected_tables */
static uint fixed_name_length(const char *name)
static size_t fixed_name_length(const char *name)
{
const char *p;
uint extra_length= 2; /* count the first/last backticks */
size_t extra_length= 2; /* count the first/last backticks */
DBUG_ENTER("fixed_name_length");
for (p= name; *p; p++)
@@ -594,7 +594,7 @@ static uint fixed_name_length(const char *name)
if (*p == '`')
extra_length++;
}
DBUG_RETURN((uint) ((p - name) + extra_length));
DBUG_RETURN((size_t) ((p - name) + extra_length));
}
@@ -653,7 +653,7 @@ static int process_all_tables_in_db(char *database)
*/
char *tables, *end;
uint tot_length = 0;
size_t tot_length = 0;
char *views, *views_end;
uint tot_views_length = 0;
@@ -756,7 +756,9 @@ static int fix_table_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE `%s` TO `%s`",
name, name + 9);
rc= run_query(qbuf);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -771,7 +773,8 @@ static int fix_database_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY "
"NAME", name);
rc= run_query(qbuf);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -791,7 +794,7 @@ static int rebuild_table(char *name)
ptr= strmov(query, "ALTER TABLE ");
ptr= fix_table_name(ptr, name);
ptr= strxmov(ptr, " FORCE", NullS);
if (mysql_real_query(sock, query, (uint)(ptr - query)))
if (mysql_real_query(sock, query, (ulong)(ptr - query)))
{
fprintf(stderr, "Failed to %s\n", query);
fprintf(stderr, "Error: %s\n", mysql_error(sock));
@@ -856,7 +859,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
{
char *query, *end, options[100], message[100];
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
uint query_length= 0;
size_t query_length= 0, query_size= sizeof(char)*(length+110);
const char *op = 0;
const char *tab_view;
DBUG_ENTER("handle_request_for_tables");
@@ -908,10 +911,12 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
DBUG_RETURN(fix_table_storage_name(tables));
}
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
DBUG_RETURN(1);
if (opt_all_in_1)
{
DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
/* No backticks here as we added them before */
query_length= sprintf(query, "%s%s%s %s", op,
tab_view, tables, options);
@@ -927,7 +932,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
(int) (ptr - org)));
table_name= table_name_buff;
ptr= strxmov(ptr, " ", options, NullS);
query_length= (uint) (ptr - query);
query_length= (size_t) (ptr - query);
}
if (mysql_real_query(sock, query, query_length))
{
@@ -1046,7 +1051,10 @@ static void print_result()
prev_alter[0]= 0;
}
else
strcpy(prev_alter, alter_txt);
{
strncpy(prev_alter, alter_txt, MAX_ALTER_STR_SIZE-1);
prev_alter[MAX_ALTER_STR_SIZE-1]= 0;
}
}
}
}
@@ -1199,7 +1207,7 @@ int main(int argc, char **argv)
process_databases(argv);
if (opt_auto_repair)
{
uint i;
size_t i;
if (!opt_silent && (tables4repair.elements || tables4rebuild.elements))
puts("\nRepairing tables");

View File

@@ -89,7 +89,7 @@
static void add_load_option(DYNAMIC_STRING *str, const char *option,
const char *option_value);
static ulong find_set(TYPELIB *lib, const char *x, uint length,
static ulong find_set(TYPELIB *lib, const char *x, size_t length,
char **err_pos, uint *err_len);
static char *alloc_query_str(ulong size);
@@ -862,7 +862,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_set_charset= 0;
opt_compatible_mode_str= argument;
opt_compatible_mode= find_set(&compatible_mode_typelib,
argument, (uint) strlen(argument),
argument, strlen(argument),
&err_ptr, &err_len);
if (err_len)
{
@@ -872,7 +872,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
#if !defined(DBUG_OFF)
{
uint size_for_sql_mode= 0;
size_t size_for_sql_mode= 0;
const char **ptr;
for (ptr= compatible_mode_names; *ptr; ptr++)
size_for_sql_mode+= strlen(*ptr);
@@ -1143,8 +1143,8 @@ static int fetch_db_collation(const char *db_name,
break;
}
strncpy(db_cl_name, db_cl_row[0], db_cl_size);
db_cl_name[db_cl_size - 1]= 0; /* just in case. */
strncpy(db_cl_name, db_cl_row[0], db_cl_size-1);
db_cl_name[db_cl_size - 1]= 0;
} while (FALSE);
@@ -1193,7 +1193,7 @@ check_consistent_binlog_pos(char *binlog_pos_file, char *binlog_pos_offset)
}
static char *my_case_str(const char *str,
uint str_len,
size_t str_len,
const char *token,
uint token_len)
{
@@ -1409,7 +1409,7 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name)
*/
static char *cover_definer_clause(const char *stmt_str,
uint stmt_length,
size_t stmt_length,
const char *definer_version_str,
uint definer_version_length,
const char *stmt_version_str,
@@ -1591,14 +1591,14 @@ static void dbDisconnect(char *host)
} /* dbDisconnect */
static void unescape(FILE *file,char *pos,uint length)
static void unescape(FILE *file,char *pos, size_t length)
{
char *tmp;
DBUG_ENTER("unescape");
if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME))))
die(EX_MYSQLERR, "Couldn't allocate memory");
mysql_real_escape_string(&mysql_connection, tmp, pos, length);
mysql_real_escape_string(&mysql_connection, tmp, pos, (ulong)length);
fputc('\'', file);
fputs(tmp, file);
fputc('\'', file);
@@ -1712,7 +1712,7 @@ static char *quote_for_like(const char *name, char *buff)
Quote '<' '>' '&' '\"' chars and print a string to the xml_file.
*/
static void print_quoted_xml(FILE *xml_file, const char *str, ulong len,
static void print_quoted_xml(FILE *xml_file, const char *str, size_t len,
my_bool is_attribute_name)
{
const char *end;
@@ -1973,7 +1973,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
squeezed to a single hyphen.
*/
static void print_xml_comment(FILE *xml_file, ulong len,
static void print_xml_comment(FILE *xml_file, size_t len,
const char *comment_string)
{
const char* end;
@@ -2090,7 +2090,7 @@ static uint dump_events_for_db(char *db)
DBUG_ENTER("dump_events_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db));
/* nice comments */
print_comment(sql_file, 0,
@@ -2209,6 +2209,7 @@ static uint dump_events_for_db(char *db)
(const char *) (query_str != NULL ? query_str : row[3]),
(const char *) delimiter);
my_free(query_str);
restore_time_zone(sql_file, delimiter);
restore_sql_mode(sql_file, delimiter);
@@ -2302,7 +2303,7 @@ static uint dump_routines_for_db(char *db)
DBUG_ENTER("dump_routines_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db));
/* nice comments */
print_comment(sql_file, 0,
@@ -2356,9 +2357,9 @@ static uint dump_routines_for_db(char *db)
if the user has EXECUTE privilege he see routine names, but NOT the
routine body of other routines that are not the creator of!
*/
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %zu",
routine_name, row[2] ? row[2] : "(null)",
row[2] ? (int) strlen(row[2]) : 0));
row[2] ? strlen(row[2]) : 0));
if (row[2] == NULL)
{
print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n",
@@ -3918,7 +3919,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
int i;
char name_buff[NAME_LEN*2+3];
mysql_real_escape_string(mysql, name_buff, db, strlen(db));
mysql_real_escape_string(mysql, name_buff, db, (ulong)strlen(db));
init_dynamic_string_checked(&where, " AND TABLESPACE_NAME IN ("
"SELECT DISTINCT TABLESPACE_NAME FROM"
@@ -3931,7 +3932,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
for (i=0 ; i<tables ; i++)
{
mysql_real_escape_string(mysql, name_buff,
table_names[i], strlen(table_names[i]));
table_names[i], (ulong)strlen(table_names[i]));
dynstr_append_checked(&where, "'");
dynstr_append_checked(&where, name_buff);
@@ -3962,7 +3963,7 @@ static int dump_tablespaces_for_databases(char** databases)
{
char db_name_buff[NAME_LEN*2+3];
mysql_real_escape_string(mysql, db_name_buff,
databases[i], strlen(databases[i]));
databases[i], (ulong)strlen(databases[i]));
dynstr_append_checked(&where, "'");
dynstr_append_checked(&where, db_name_buff);
dynstr_append_checked(&where, "',");
@@ -5003,7 +5004,7 @@ static int start_transaction(MYSQL *mysql_con)
}
static ulong find_set(TYPELIB *lib, const char *x, uint length,
static ulong find_set(TYPELIB *lib, const char *x, size_t length,
char **err_pos, uint *err_len)
{
const char *end= x + length;
@@ -5061,7 +5062,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
fputc(' ',file);
fputs(prefix, file);
if (string_value)
unescape(file,row[0],(uint) strlen(row[0]));
unescape(file,row[0], strlen(row[0]));
else
fputs(row[0], file);
check_io(file);
@@ -5314,8 +5315,8 @@ static my_bool get_view_structure(char *table, char* db)
verbose_msg("-- Retrieving view structure for table %s...\n", table);
#ifdef NOT_REALLY_USED_YET
sprintf(insert_pat, "SET SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords));
dynstr_append_checked(&insert_pat, "SET SQL_QUOTE_SHOW_CREATE=");
dynstr_append_checked(&insert_pat, (opt_quoted || opt_keywords)? "1":"0");
#endif
result_table= quote_name(table, table_buff, 1);

View File

@@ -51,9 +51,9 @@ static int list_tables(MYSQL *mysql,const char *db,const char *table);
static int list_table_status(MYSQL *mysql,const char *db,const char *table);
static int list_fields(MYSQL *mysql,const char *db,const char *table,
const char *field);
static void print_header(const char *header,uint head_length,...);
static void print_row(const char *header,uint head_length,...);
static void print_trailer(uint length,...);
static void print_header(const char *header,size_t head_length,...);
static void print_row(const char *header,size_t head_length,...);
static void print_trailer(size_t length,...);
static void print_res_header(MYSQL_RES *result);
static void print_res_top(MYSQL_RES *result);
static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
@@ -366,7 +366,8 @@ static int
list_dbs(MYSQL *mysql,const char *wild)
{
const char *header;
uint length, counter = 0;
size_t length = 0;
uint counter = 0;
ulong rowcount = 0L;
char tables[NAME_LEN+1], rows[NAME_LEN+1];
char query[NAME_LEN + 100];
@@ -404,7 +405,7 @@ list_dbs(MYSQL *mysql,const char *wild)
printf("Wildcard: %s\n",wild);
header="Databases";
length=(uint) strlen(header);
length= strlen(header);
field=mysql_fetch_field(result);
if (length < field->max_length)
length=field->max_length;
@@ -492,7 +493,8 @@ static int
list_tables(MYSQL *mysql,const char *db,const char *table)
{
const char *header;
uint head_length, counter = 0;
size_t head_length;
uint counter = 0;
char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
MYSQL_FIELD *field;
MYSQL_RES *result;
@@ -529,7 +531,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
putchar('\n');
header="Tables";
head_length=(uint) strlen(header);
head_length= strlen(header);
field=mysql_fetch_field(result);
if (head_length < field->max_length)
head_length=field->max_length;
@@ -647,7 +649,7 @@ list_table_status(MYSQL *mysql,const char *db,const char *wild)
len= sizeof(query);
len-= my_snprintf(query, len, "show table status from `%s`", db);
if (wild && wild[0] && len)
strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot get status for db: %s, table: %s: %s\n",
@@ -680,7 +682,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
const char *wild)
{
char query[NAME_LEN + 100];
int len;
size_t len;
MYSQL_RES *result;
MYSQL_ROW row;
ulong UNINIT_VAR(rows);
@@ -710,7 +712,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`",
table);
if (wild && wild[0] && len)
strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot list columns in db: %s, table: %s: %s\n",
@@ -758,10 +760,10 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
*****************************************************************************/
static void
print_header(const char *header,uint head_length,...)
print_header(const char *header,size_t head_length,...)
{
va_list args;
uint length,i,str_length,pre_space;
size_t length,i,str_length,pre_space;
const char *field;
va_start(args,head_length);
@@ -784,10 +786,10 @@ print_header(const char *header,uint head_length,...)
putchar('|');
for (;;)
{
str_length=(uint) strlen(field);
str_length= strlen(field);
if (str_length > length)
str_length=length+1;
pre_space=(uint) (((int) length-(int) str_length)/2)+1;
pre_space= ((length- str_length)/2)+1;
for (i=0 ; i < pre_space ; i++)
putchar(' ');
for (i = 0 ; i < str_length ; i++)
@@ -821,11 +823,11 @@ print_header(const char *header,uint head_length,...)
static void
print_row(const char *header,uint head_length,...)
print_row(const char *header,size_t head_length,...)
{
va_list args;
const char *field;
uint i,length,field_length;
size_t i,length,field_length;
va_start(args,head_length);
field=header; length=head_length;
@@ -834,7 +836,7 @@ print_row(const char *header,uint head_length,...)
putchar('|');
putchar(' ');
fputs(field,stdout);
field_length=(uint) strlen(field);
field_length= strlen(field);
for (i=field_length ; i <= length ; i++)
putchar(' ');
if (!(field=va_arg(args,char *)))
@@ -848,10 +850,10 @@ print_row(const char *header,uint head_length,...)
static void
print_trailer(uint head_length,...)
print_trailer(size_t head_length,...)
{
va_list args;
uint length,i;
size_t length,i;
va_start(args,head_length);
length=head_length;
@@ -894,7 +896,7 @@ static void print_res_top(MYSQL_RES *result)
mysql_field_seek(result,0);
while((field = mysql_fetch_field(result)))
{
if ((length=(uint) strlen(field->name)) > field->max_length)
if ((length= strlen(field->name)) > field->max_length)
field->max_length=length;
else
length=field->max_length;

View File

@@ -5086,12 +5086,13 @@ static int my_kill(int pid, int sig)
{
#ifdef __WIN__
HANDLE proc;
if ((proc= OpenProcess(PROCESS_TERMINATE, FALSE, pid)) == NULL)
if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
return -1;
if (sig == 0)
{
DWORD wait_result= WaitForSingleObject(proc, 0);
CloseHandle(proc);
return 0;
return wait_result == WAIT_OBJECT_0?-1:0;
}
(void)TerminateProcess(proc, 201);
CloseHandle(proc);

View File

@@ -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);
}

View File

@@ -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

View File

@@ -69,3 +69,9 @@ INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Developm
PATTERN CMakeFiles EXCLUDE
PATTERN mysql EXCLUDE
REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/. DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
FILES_MATCHING PATTERN "*.h"
PATTERN CMakeFiles EXCLUDE
PATTERN mysql EXCLUDE
REGEX "\\./(${EXCL_RE}$)" EXCLUDE)

View File

@@ -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

View File

@@ -330,7 +330,8 @@ typedef struct st_sort_info
my_off_t filelength, dupp, buff_length;
ha_rows max_records;
uint current_key, total_keys;
uint got_error, threads_running;
volatile uint got_error;
uint threads_running;
myf myf_rw;
enum data_file_type new_data_file_type;
} MI_SORT_INFO;

View File

@@ -184,7 +184,7 @@ void vio_end(void);
/* shutdown(2) flags */
#ifndef SHUT_RD
#define SHUT_RD SD_BOTH
#define SHUT_RD SD_RECEIVE
#endif
/*

View File

@@ -108,8 +108,12 @@ ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
# On Unix, it is libmysqld.a
IF(WIN32)
SET(MYSQLSERVER_OUTPUT_NAME mysqlserver)
SET(COMPONENT_MYSQLSERVER "Embedded")
SET(COMPONENT_LIBMYSQLD "Embedded")
ELSE()
SET(MYSQLSERVER_OUTPUT_NAME mysqld)
SET(COMPONENT_MYSQLSERVER "Development")
SET(COMPONENT_LIBMYSQLD "Server")
ENDIF()
@@ -134,9 +138,9 @@ FOREACH(LIB ${LIBS})
ENDFOREACH()
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Development)
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT ${COMPONENT_MYSQLSERVER})
INSTALL(FILES embedded_priv.h DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development)
INSTALL(FILES embedded_priv.h DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT ${COMPONENT_MYSQLSERVER})
# Visual Studio users need debug static library
IF(MSVC)
@@ -163,7 +167,7 @@ ENDFOREACH()
IF(NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysqld SHARED mysqlserver EXPORTS ${EMBEDDED_API}
COMPONENT Server)
COMPONENT ${COMPONENT_LIBMYSQLD})
IF(UNIX)
# Name the shared library, handle versioning (provides same api as client
# library hence the same version)

View File

@@ -10,6 +10,10 @@
# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
# before sourcing this routine.
#
# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file
# to search. If negative, it will search that many bytes at the end of the
# file. The default is to search only the first 50000 bytes of the file.
#
# In case of
# - SEARCH_FILE and/or SEARCH_PATTERN is not set
# - SEARCH_FILE cannot be opened
@@ -38,6 +42,7 @@
# --error 0,1
# --remove_file $error_log
# let SEARCH_FILE= $error_log;
# let SEARCH_RANGE= -50000;
# # Stop the server
# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
# --exec echo "wait" > $restart_file
@@ -57,8 +62,18 @@ perl;
use strict;
my $search_file= $ENV{'SEARCH_FILE'} or die "SEARCH_FILE not set";
my $search_pattern= $ENV{'SEARCH_PATTERN'} or die "SEARCH_PATTERN not set";
my $search_range= $ENV{'SEARCH_RANGE'};
my $file_content;
$search_range= 50000 unless $search_range =~ /-?[0-9]+/;
open(FILE, "$search_file") or die("Unable to open '$search_file': $!\n");
read(FILE, my $file_content, 50000, 0);
if ($search_range >= 0) {
read(FILE, $file_content, $search_range, 0);
} else {
my $size= -s $search_file;
$search_range = -$size if $size > -$search_range;
seek(FILE, $search_range, 2);
read(FILE, $file_content, -$search_range, 0);
}
close(FILE);
if ( not $file_content =~ m{$search_pattern} ) {
die("# ERROR: The file '$search_file' does not contain the expected pattern $search_pattern\n->$file_content<-\n");

View File

@@ -1805,9 +1805,12 @@ sub set_build_thread_ports($) {
if ( lc($opt_build_thread) eq 'auto' ) {
my $found_free = 0;
$build_thread = 300; # Start attempts from here
my $build_thread_upper = $build_thread + ($opt_parallel > 1500
? 3000
: 2 * $opt_parallel) + 300;
while (! $found_free)
{
$build_thread= mtr_get_unique_id($build_thread, 349);
$build_thread= mtr_get_unique_id($build_thread, $build_thread_upper);
if ( !defined $build_thread ) {
mtr_error("Could not get a unique build thread id");
}

View File

@@ -502,3 +502,9 @@ a
SELECT * FROM t1 WHERE a IN (0.8,0.9);
a
DROP TABLE t1;
#
# MDEV-9372 select 100 between 1 and 9223372036854775808 returns false
#
SELECT 100 BETWEEN 1 AND 9223372036854775808;
100 BETWEEN 1 AND 9223372036854775808
1

View File

@@ -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
#

View File

@@ -5830,5 +5830,44 @@ OCTET_LENGTH(a) a
255
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
#

View File

@@ -2622,6 +2622,40 @@ OCTET_LENGTH(a) a
252 😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎
DROP TABLE t1;
#
# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
#
#
SET NAMES utf8mb4;
SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data;
data
65532
SELECT length(data) AS len
FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub;
len
65532
SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data;
data
65538
SELECT length(data) AS len
FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub;
len
65538
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub;
len
65532
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub;
len
65535
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
len
65538
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
len
196605
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
len
196608
#
# End of 5.5 tests
#
#

View File

@@ -15,3 +15,15 @@ CREATE TABLE t1(a VARCHAR(2) CHARACTER SET big5 COLLATE big5_chinese_ci,
FULLTEXT(a));
INSERT INTO t1 VALUES(0xA3C2);
DROP TABLE t1;
create table t1 (
id varchar(255),
business_name text null collate utf8mb4_unicode_ci,
street_address text,
fulltext index ft (business_name),
fulltext index ft2 (street_address)
);
select * from t1 where match (business_name, street_address) against ('some business name and address here');
ERROR HY000: Can't find FULLTEXT index matching the column list
select * from t1 where match (business_name, street_address) against ('some business name and address here' in boolean mode);
id business_name street_address
drop table t1;

View File

@@ -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;

View File

@@ -6,5 +6,5 @@ SHOW PROCESSLIST;
ERROR 70100: Query execution was interrupted
SHOW PROCESSLIST;
Id User Host db Command Time State Info Progress
# root # test Sleep # # NULL 0.000
# root # test Query # # SHOW PROCESSLIST 0.000
# root # test # # # # 0.000
# root # test # # # # 0.000

View File

@@ -101,3 +101,31 @@ Februar
SELECT monthname('2001-03-01');
monthname('2001-03-01')
März
#
# MDEV-10052 Illegal mix of collations with DAYNAME(date_field)<>varchar_field
#
SET NAMES utf8;
CREATE TABLE t1 (c VARCHAR(8) CHARACTER SET latin1, d DATE);
INSERT INTO t1 VALUES ('test',now());
Warnings:
Note 1265 Data truncated for column 'd' at row 1
SET lc_time_names=ru_RU;
SELECT c FROM t1 WHERE DAYNAME(d)<>c;
ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<>'
SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<>'
SET lc_time_names=en_US;
SELECT c FROM t1 WHERE DAYNAME(d)<>c;
c
test
SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
c
test
SET NAMES latin1;
SELECT c FROM t1 WHERE DAYNAME(d)<>c;
c
test
SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
c
test
DROP TABLE t1;

View File

@@ -198,8 +198,6 @@ Ssl_cipher DHE-RSA-AES256-SHA
Variable_name Value
Ssl_cipher EDH-RSA-DES-CBC3-SHA
Variable_name Value
Ssl_cipher EDH-RSA-DES-CBC-SHA
Variable_name Value
Ssl_cipher RC4-SHA
select 'is still running; no cipher request crashed the server' as result from dual;
result

View File

@@ -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

View File

@@ -32,12 +32,9 @@ update t1, t2 set val= 1 where id1=id2;
call bug9486();
lock tables t2 write;
call bug9486();
show processlist;
Id User Host db Command Time State Info Progress
# root localhost test Sleep # NULL 0.000
# root localhost test Query # Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2 0.000
# root localhost test Query # NULL show processlist 0.000
# root localhost test Sleep # NULL 0.000
SELECT state,info FROM information_schema.processlist WHERE id=con1root_id;
state info
Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2
unlock tables;
drop procedure bug9486;
drop table t1, t2;

View File

@@ -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

View File

@@ -442,6 +442,7 @@ select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
drop table t1;
#
# MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
# MDEV-9972 Least function retuns date in date time format
#
CREATE TABLE t1 (
id BIGINT NOT NULL,
@@ -465,9 +466,9 @@ LEAST(IFNULL(t2.date_fin, IFNULL(t1.date_fin, NULL)),
IFNULL(t1.date_fin, IFNULL(t2.date_fin, NULL))) AS date_fin
FROM t1 LEFT JOIN t2 ON (t1.id=t2.id);
id date_debut date_fin
1 2016-01-01 2016-01-31 00:00:00
2 2016-02-01 2016-01-28 00:00:00
3 2016-03-01 2016-03-31 00:00:00
1 2016-01-01 2016-01-31
2 2016-02-01 2016-01-28
3 2016-03-01 2016-03-31
4 2016-04-01 NULL
DROP TABLE t1,t2;
SELECT

View File

@@ -0,0 +1,3 @@
set global log_warnings=2;
set @@wait_timeout=1;
set global log_warnings=@@log_warnings;

View File

@@ -44,8 +44,7 @@ connection con1;
--error 2006,2013
reap;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-binlog_mdev342.test
EOF

View File

@@ -68,3 +68,47 @@ Warning 150 Alter table `test`.`t2` with foreign key constraint failed. Referen
Error 1005 Can't create table '#sql-temporary' (errno: 150)
drop table t2;
drop table t1;
CREATE DATABASE kg_test1;
CREATE DATABASE kg_test2;
CREATE TABLE `kg_test1`.`group` (
Id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `kg_test1`.`person` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
show create table `kg_test1`.`person`;
Table Create Table
person CREATE TABLE `person` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `kg_test2`.`person2` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
ERROR HY000: Can't create table 'kg_test2.person2' (errno: 150)
CREATE TABLE `kg_test2`.`person2` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
show create table `kg_test2`.`person2`;
Table Create Table
person2 CREATE TABLE `person2` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
SHOW WARNINGS;
Level Code Message
DROP DATABASE kg_test2;
DROP DATABASE kg_test1;

View File

@@ -1,83 +1,49 @@
set names utf8;
CREATE TABLE corrupt_bit_test_ā(
a INT AUTO_INCREMENT PRIMARY KEY,
b CHAR(100),
c INT,
z INT,
INDEX(b))
ENGINE=InnoDB;
INSERT INTO corrupt_bit_test_ā VALUES(0,'x',1, 1);
CREATE UNIQUE INDEX idxā ON corrupt_bit_test_ā(c, b);
CREATE UNIQUE INDEX idxē ON corrupt_bit_test_ā(z, b);
SELECT * FROM corrupt_bit_test_ā;
a b c z
1 x 1 1
select @@unique_checks;
@@unique_checks
0
select @@innodb_change_buffering_debug;
@@innodb_change_buffering_debug
1
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_ā;
INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_ā;
select count(*) from corrupt_bit_test_ā;
count(*)
1024
CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
INSERT INTO corrupt_bit_test_ā VALUES(13000,'x',1,1);
CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
check table corrupt_bit_test_ā;
2
Table Op Msg_type Msg_text
test.corrupt_bit_test_ā check Warning InnoDB: The B-tree of index "idxā" is corrupted.
test.corrupt_bit_test_ā check Warning InnoDB: The B-tree of index "idxē" is corrupted.
test.corrupt_bit_test_ā check Warning InnoDB: Index "idx" is marked as corrupted
test.corrupt_bit_test_ā check Warning InnoDB: Index "idxā" is marked as corrupted
test.corrupt_bit_test_ā check Warning InnoDB: Index "idxē" is marked as corrupted
test.corrupt_bit_test_ā check error Corrupt
select c from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
select z from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
show warnings;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
ERROR HY000: Index corrupt_bit_test_ā is corrupted
Level Code Message
Warning 179 InnoDB: Index "idxē" for table "test"."corrupt_bit_test_ā" is marked as corrupted
Warning 179 Got error 179 when reading table `test`.`corrupt_bit_test_ā`
Error 1712 Index corrupt_bit_test_ā is corrupted
insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001);
select * from corrupt_bit_test_ā use index(primary) where a = 10001;
a b c z
10001 a 20001 20001
begin;
insert into corrupt_bit_test_ā values (10002, "a", 20002, 20002);
delete from corrupt_bit_test_ā where a = 10001;
insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001);
rollback;
drop index idxā on corrupt_bit_test_ā;
check table corrupt_bit_test_ā;
Table Op Msg_type Msg_text
test.corrupt_bit_test_ā check Warning InnoDB: Index "idx" is marked as corrupted
test.corrupt_bit_test_ā check Warning InnoDB: Index "idxē" is marked as corrupted
test.corrupt_bit_test_ā check error Corrupt
set names utf8;
select z from corrupt_bit_test_ā;
ERROR HY000: Index corrupt_bit_test_ā is corrupted
drop index idxē on corrupt_bit_test_ā;
select z from corrupt_bit_test_ā limit 10;
Table Create Table
corrupt_bit_test_ā CREATE TABLE `corrupt_bit_test_ā` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` char(100) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`z` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `idxē` (`z`,`b`),
KEY `idx` (`b`)
) ENGINE=InnoDB AUTO_INCREMENT=10003 DEFAULT CHARSET=latin1
ERROR HY000: Index corrupt_bit_test_ā is corrupted
ERROR HY000: Index corrupt_bit_test_ā is corrupted
Table Create Table
corrupt_bit_test_ā CREATE TABLE `corrupt_bit_test_ā` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` char(100) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`z` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `idx` (`b`)
) ENGINE=InnoDB AUTO_INCREMENT=10003 DEFAULT CHARSET=latin1
z
20001
1
1
2
11
12
21
22
31
32
drop table corrupt_bit_test_ā;
DROP DATABASE pad;
SET GLOBAL innodb_change_buffering_debug = 0;

View File

@@ -124,3 +124,44 @@ show warnings;
drop table t2;
drop table t1;
#
# MDEV-9142 :Adding Constraint with no database reference
# results in ERROR 1046 (3D000) at line 13: No database selected
#
CREATE DATABASE kg_test1;
CREATE DATABASE kg_test2;
CREATE TABLE `kg_test1`.`group` (
Id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `kg_test1`.`person` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
show create table `kg_test1`.`person`;
--error 1005
CREATE TABLE `kg_test2`.`person2` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `kg_test2`.`person2` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
show create table `kg_test2`.`person2`;
SHOW WARNINGS;
DROP DATABASE kg_test2;
DROP DATABASE kg_test1;

View File

@@ -2,45 +2,23 @@
# Test for persistent corrupt bit for corrupted index and table
#
-- source include/have_innodb.inc
# Issues with innodb_change_buffering_debug on Windows, so the test scenario
# cannot be created on windows
--source include/not_windows.inc
-- source include/not_embedded.inc
# This test needs debug server
--source include/have_debug.inc
-- source include/have_debug.inc
-- disable_query_log
call mtr.add_suppression("Flagged corruption of idx.*in CHECK TABLE");
# This test setup is extracted from bug56680.test:
# The flag innodb_change_buffering_debug is only available in debug builds.
# It instructs InnoDB to try to evict pages from the buffer pool when
# change buffering is possible, so that the change buffer will be used
# whenever possible.
SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug;
SET GLOBAL innodb_change_buffering_debug = 1;
# Turn off Unique Check to create corrupted index with dup key
SET UNIQUE_CHECKS=0;
CREATE DATABASE pad;
let $i=338;
while ($i)
{
--eval CREATE TABLE pad.t$i(a INT PRIMARY KEY)ENGINE=InnoDB;
dec $i;
}
-- enable_query_log
set names utf8;
SET UNIQUE_CHECKS=0;
CREATE TABLE corrupt_bit_test_ā(
a INT AUTO_INCREMENT PRIMARY KEY,
b CHAR(100),
c INT,
z INT,
INDEX(b))
INDEX idx(b))
ENGINE=InnoDB;
INSERT INTO corrupt_bit_test_ā VALUES(0,'x',1, 1);
@@ -53,37 +31,20 @@ 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);
# creating an index should succeed even if other secondary indexes are corrupted
CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
# Check table will find the unique indexes corrupted
# with dup key
# This will flag all secondary indexes corrupted
SET SESSION debug_dbug="+d,dict_set_index_corrupted";
check table corrupt_bit_test_ā;
SET SESSION debug_dbug="-d,dict_set_index_corrupted";
# 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);
# This selection intend to use the corrupted index. Expect to fail
-- error ER_INDEX_CORRUPT
@@ -108,7 +69,6 @@ delete from corrupt_bit_test_ā where a = 10001;
insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001);
rollback;
# Drop one corrupted index before reboot
drop index idxā on corrupt_bit_test_ā;
check table corrupt_bit_test_ā;
@@ -118,14 +78,26 @@ set names utf8;
-- error ER_INDEX_CORRUPT
select z from corrupt_bit_test_ā;
show create table corrupt_bit_test_ā;
# Drop the corrupted index
drop index idxē on corrupt_bit_test_ā;
# Cannot create new indexes while a corrupt index exists.
--error ER_INDEX_CORRUPT
CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
--error ER_INDEX_CORRUPT
CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
show create table corrupt_bit_test_ā;
drop index idx on corrupt_bit_test_ā;
# Now that there exist no corrupted indexes, we can create new indexes.
CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c);
CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z);
# Now select back to normal
select z from corrupt_bit_test_ā limit 10;
# Drop table
drop table corrupt_bit_test_ā;
DROP DATABASE pad;
SET GLOBAL innodb_change_buffering_debug = 0;

View File

@@ -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;

View File

@@ -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;

View File

@@ -209,8 +209,7 @@ EOF
--shutdown_server 30
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-rpl_mdev382.test
EOF

View File

@@ -53,8 +53,7 @@ EOF
--replace_result $datadir <DATADIR>
--copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF

View File

@@ -409,3 +409,8 @@ SELECT * FROM t1 WHERE a=0.9;
SELECT * FROM t1 WHERE a IN (0.8,0.9);
DROP TABLE t1;
--echo #
--echo # MDEV-9372 select 100 between 1 and 9223372036854775808 returns false
--echo #
SELECT 100 BETWEEN 1 AND 9223372036854775808;

View File

@@ -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 #

View File

@@ -1658,6 +1658,29 @@ ALTER TABLE t1 MODIFY a TINYTEXT CHARACTER SET utf8;
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 #

View File

@@ -1838,6 +1838,26 @@ 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 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 #

View File

@@ -32,3 +32,18 @@ INSERT INTO t1 VALUES(0xA3C2);
DROP TABLE t1;
# End of 5.1 tests
#
# MDEV-9986 Full-text search of the utf8mb4 column causes crash
#
create table t1 (
id varchar(255),
business_name text null collate utf8mb4_unicode_ci,
street_address text,
fulltext index ft (business_name),
fulltext index ft2 (street_address)
);
--error ER_FT_MATCHING_KEY_NOT_FOUND
select * from t1 where match (business_name, street_address) against ('some business name and address here');
select * from t1 where match (business_name, street_address) against ('some business name and address here' in boolean mode);
drop table t1;

View File

@@ -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;

View File

@@ -11,5 +11,5 @@ eval KILL QUERY $con_id;
--connection con1
--error ER_QUERY_INTERRUPTED
SHOW PROCESSLIST;
--replace_column 1 # 3 # 6 # 7 #
--replace_column 1 # 3 # 5 # 6 # 7 # 8 #
SHOW PROCESSLIST;

View File

@@ -63,3 +63,22 @@ SET lc_time_names=de_AT;
SELECT monthname('2001-01-01');
SELECT monthname('2001-02-01');
SELECT monthname('2001-03-01');
--echo #
--echo # MDEV-10052 Illegal mix of collations with DAYNAME(date_field)<>varchar_field
--echo #
SET NAMES utf8;
CREATE TABLE t1 (c VARCHAR(8) CHARACTER SET latin1, d DATE);
INSERT INTO t1 VALUES ('test',now());
SET lc_time_names=ru_RU;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM t1 WHERE DAYNAME(d)<>c;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
SET lc_time_names=en_US;
SELECT c FROM t1 WHERE DAYNAME(d)<>c;
SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
SET NAMES latin1;
SELECT c FROM t1 WHERE DAYNAME(d)<>c;
SELECT c FROM t1 WHERE MONTHNAME(d)<>c;
DROP TABLE t1;

View File

@@ -222,7 +222,6 @@ DROP TABLE t1;
# Common ciphers to openssl and yassl
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=DHE-RSA-AES256-SHA
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=EDH-RSA-DES-CBC3-SHA
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=EDH-RSA-DES-CBC-SHA
--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=RC4-SHA
--disable_query_log
--disable_result_log

View File

@@ -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;

View File

@@ -124,12 +124,8 @@ SEND;
UPDATE `t``\""e` SET a = 12 WHERE a = 0;
--echo # default connection
connection default;
let $wait_timeout= 2;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE ID = $id_1 AND STATE = 'Searching rows for update';
let $wait_condition= SELECT COUNT(*)=2 FROM INFORMATION_SCHEMA.INNODB_LOCKS;
--source include/wait_condition.inc
#--echo # tested wait condition $wait_condition_reps times
# INNODB_LOCKS only exists in innodb_plugin
--sorted_result
SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
GROUP BY lock_table;

View File

@@ -77,12 +77,15 @@ call bug9486();
connection con2root;
lock tables t2 write;
connection con1root;
let $con1root_id=`SELECT CONNECTION_ID()`;
send call bug9486();
connection con2root;
--sleep 2
# There should be call statement in locked state.
--replace_column 1 # 3 localhost 6 #
show processlist;
let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE
id=$con1root_id AND state='Waiting for table metadata lock';
--source include/wait_condition.inc
--replace_result $con1root_id con1root_id
eval SELECT state,info FROM information_schema.processlist WHERE id=$con1root_id;
unlock tables;
connection con1root;
reap;

36
mysql-test/t/ssl_ca.test Normal file
View File

@@ -0,0 +1,36 @@
--source include/have_ssl.inc
--source include/not_embedded.inc
--echo #
--echo # Bug#21920657: SSL-CA FAILS SILENTLY IF THE PATH CANNOT BE FOUND
--echo #
--echo # try to connect with wrong '--ssl-ca' path : should fail
--error 1
--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/wrong-cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'" 2>&1
--echo # try to connect with correct '--ssl-ca' path : should connect
--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
--echo #
--echo # Bug#21920678: SSL-CA DOES NOT ACCEPT ~USER TILDE HOME DIRECTORY
--echo # PATH SUBSTITUTION
--echo #
--let $mysql_test_dir_path= `SELECT IF(LENGTH('$HOME'), REPLACE('=$MYSQL_TEST_DIR', '=$HOME', '=~'), '=$MYSQL_TEST_DIR')`
--echo # try to connect with '--ssl-ca' option using tilde home directoy
--echo # path substitution : should connect
--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
--exec $MYSQL --ssl-ca$mysql_test_dir_path/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
--echo # try to connect with '--ssl-key' option using tilde home directoy
--echo # path substitution : should connect
--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key$mysql_test_dir_path/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"
--echo # try to connect with '--ssl-cert' option using tilde home directoy
--echo # path substitution : should connect
--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA
--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert$mysql_test_dir_path/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_cipher'"

View File

@@ -388,6 +388,7 @@ drop table t1;
--echo #
--echo # MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
--echo # MDEV-9972 Least function retuns date in date time format
--echo #
CREATE TABLE t1 (
id BIGINT NOT NULL,

View File

@@ -0,0 +1,16 @@
source include/not_embedded.inc;
source include/not_windows.inc;
#
# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout
#
set global log_warnings=2;
connect (foo,localhost,root);
set @@wait_timeout=1;
sleep 2;
connection default;
let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_RANGE= -50;
let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets;
source include/search_pattern_in_file.inc;
set global log_warnings=@@log_warnings;

View File

@@ -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
@@ -89,34 +59,6 @@
fun:_dl_map_object_from_fd
}
{
pthread allocate_dtv memory loss
Memcheck:Leak
fun:calloc
fun:allocate_dtv
fun:_dl_allocate_tls_storage
fun:__GI__dl_allocate_tls
fun:pthread_create
}
{
pthread allocate_dtv memory loss second
Memcheck:Leak
fun:calloc
fun:allocate_dtv
fun:_dl_allocate_tls
fun:pthread_create*
}
{
pthread memalign memory loss
Memcheck:Leak
fun:memalign
fun:_dl_allocate_tls_storage
fun:__GI__dl_allocate_tls
fun:pthread_create
}
{
pthread pthread_key_create
Memcheck:Leak
@@ -972,18 +914,6 @@
fun:nptl_pthread_exit_hack_handler
}
#
# Pthread doesn't free all thread specific memory before program exists
#
{
pthread allocate_tls memory loss in 2.6.1.
Memcheck:Leak
fun:calloc
obj:*/ld-*.so
fun:_dl_allocate_tls
fun:pthread_create*
}
{
memory "leak" in backtrace() of glibc 2.9 (not present in 2.13)
Memcheck:Leak
@@ -1117,3 +1047,22 @@
fun:_nss_dns_gethostbyaddr_r
fun:gethostbyaddr_r
}
#
# Detached threads may not complete deiniitialization by the time shutdown
# thread calls exit. This is unfortunate property of detached threads, which
# we currently can only ignore. Unfortunately there is no way to distinguish
# between false positives generated by detached threads and real memory leaks
# generated by not joined joinable threads. So we hide both cases.
#
# To avoid enumeration of the whole variety of possible traces we ignore all
# "possibly lost" blocks allocated by pthread_create (and it's callees).
#
{
Detached threads memory loss
Memcheck:Leak
match-leak-kinds:possible
...
fun:pthread_create*
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2000, 2013, Oracle and/or its affiliates
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1874,6 +1874,7 @@ void die(const char* fmt, ...)
fprintf(stderr,"Error:");
vfprintf(stderr, fmt,va_args);
fprintf(stderr,", errno=%d\n", errno);
va_end(va_args);
exit(1);
}

View File

@@ -206,7 +206,7 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
(
"movq %%rsp, (%[save])\n\t"
"movq %[stack], %%rsp\n\t"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && !defined(__INTEL_COMPILER)
/*
This emits a DWARF DW_CFA_undefined directive to make the return address
undefined. This indicates that this is the top of the stack frame, and
@@ -456,7 +456,7 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
(
"movl %%esp, (%[save])\n\t"
"movl %[stack], %%esp\n\t"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && !defined(__INTEL_COMPILER)
/*
This emits a DWARF DW_CFA_undefined directive to make the return address
undefined. This indicates that this is the top of the stack frame, and

View File

@@ -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

View File

@@ -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");

View File

@@ -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

View File

@@ -163,6 +163,10 @@ char *argv[];
}
else if (argc > 3)
for (n = atoi(argv[3]); n > 0; n--) {
if(sizeof(buf)-1 < strlen(argv[1]))
{
exit(EXIT_FAILURE);
}
(void) strcpy(buf, argv[1]);
(void) split(buf, fields, MNF, argv[2]);
}

View File

@@ -17,7 +17,7 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA
# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -711,7 +711,11 @@ sub my_which
my ($command) = @_;
my (@paths, $path);
return $command if (-f $command && -x $command);
# If the argument is not 'my_print_defaults' then it would be of the format
# <absolute_path>/<program>
return $command if ($command ne 'my_print_defaults' && -f $command &&
-x $command);
@paths = split(':', $ENV{'PATH'});
foreach $path (@paths)
{

View File

@@ -1197,6 +1197,20 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
my_free((OPTS)->extension->X); \
EXTENSION_SET(OPTS, X, my_strdup((STR), MYF(MY_WME)));
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
static char *set_ssl_option_unpack_path(const char *arg)
{
char *opt_var= NULL;
if (arg)
{
char buff[FN_REFLEN + 1];
unpack_filename(buff, (char *)arg);
opt_var= my_strdup(buff, MYF(MY_WME));
}
return opt_var;
}
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group)
{
@@ -1796,10 +1810,10 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
my_free(mysql->options.ssl_ca);
my_free(mysql->options.ssl_capath);
my_free(mysql->options.ssl_cipher);
mysql->options.ssl_key= strdup_if_not_null(key);
mysql->options.ssl_cert= strdup_if_not_null(cert);
mysql->options.ssl_ca= strdup_if_not_null(ca);
mysql->options.ssl_capath= strdup_if_not_null(capath);
mysql->options.ssl_key= set_ssl_option_unpack_path(key);
mysql->options.ssl_cert= set_ssl_option_unpack_path(cert);
mysql->options.ssl_ca= set_ssl_option_unpack_path(ca);
mysql->options.ssl_capath= set_ssl_option_unpack_path(capath);
mysql->options.ssl_cipher= strdup_if_not_null(cipher);
mysql->options.use_ssl= TRUE;
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */

View File

@@ -1701,6 +1701,7 @@ Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
if (charset_arg->state & MY_CS_BINSORT)
flags|=BINARY_FLAG;
field_derivation= DERIVATION_IMPLICIT;
field_repertoire= my_charset_repertoire(charset_arg);
}

View File

@@ -580,11 +580,12 @@ public:
{ return binary() ? &my_charset_bin : charset(); }
virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
virtual bool has_charset(void) const { return FALSE; }
virtual void set_charset(CHARSET_INFO *charset_arg) { }
virtual enum Derivation derivation(void) const
{ return DERIVATION_IMPLICIT; }
virtual uint repertoire(void) const { return MY_REPERTOIRE_UNICODE30; }
virtual void set_derivation(enum Derivation derivation_arg) { }
virtual void set_derivation(enum Derivation derivation_arg,
uint repertoire_arg)
{ }
virtual int set_time() { return 1; }
void set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
int cuted_increment);
@@ -775,8 +776,10 @@ public:
class Field_str :public Field {
protected:
// TODO-10.2: Reuse DTCollation instead of these three members
CHARSET_INFO *field_charset;
enum Derivation field_derivation;
uint field_repertoire;
public:
Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
@@ -799,15 +802,15 @@ public:
int store_decimal(const my_decimal *);
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
uint size_of() const { return sizeof(*this); }
uint repertoire(void) const
{
return my_charset_repertoire(field_charset);
}
uint repertoire(void) const { return field_repertoire; }
CHARSET_INFO *charset(void) const { return field_charset; }
void set_charset(CHARSET_INFO *charset_arg) { field_charset= charset_arg; }
enum Derivation derivation(void) const { return field_derivation; }
virtual void set_derivation(enum Derivation derivation_arg)
{ field_derivation= derivation_arg; }
void set_derivation(enum Derivation derivation_arg,
uint repertoire_arg)
{
field_derivation= derivation_arg;
field_repertoire= repertoire_arg;
}
bool binary() const { return field_charset == &my_charset_bin; }
uint32 max_display_length() { return field_length; }
friend class Create_field;
@@ -1851,10 +1854,9 @@ public:
packlength= 4;
if (set_packlength)
{
uint32 l_char_length= len_arg/cs->mbmaxlen;
packlength= l_char_length <= 255 ? 1 :
l_char_length <= 65535 ? 2 :
l_char_length <= 16777215 ? 3 : 4;
packlength= len_arg <= 255 ? 1 :
len_arg <= 65535 ? 2 :
len_arg <= 16777215 ? 3 : 4;
}
}
Field_blob(uint32 packlength_arg)

View File

@@ -310,6 +310,7 @@ void print_find_structs()
add_structs_to_map(root_by_len,max_len);
set_links(root_by_len,max_len);
print_hash_map("sql_functions_map");
free(hash_map);
hash_map= 0;
size_hash_map= 0;
@@ -319,6 +320,7 @@ void print_find_structs()
add_structs_to_map(root_by_len2,max_len2);
set_links(root_by_len2,max_len2);
print_hash_map("symbols_map");
free(hash_map);
}

View File

@@ -244,9 +244,6 @@ bool Item::val_bool()
*/
String *Item::val_str_ascii(String *str)
{
if (!(collation.collation->state & MY_CS_NONASCII))
return val_str(str);
DBUG_ASSERT(str != &str_value);
uint errors;
@@ -254,11 +251,15 @@ String *Item::val_str_ascii(String *str)
if (!res)
return 0;
if ((null_value= str->copy(res->ptr(), res->length(),
collation.collation, &my_charset_latin1,
&errors)))
return 0;
if (!(res->charset()->state & MY_CS_NONASCII))
str= res;
else
{
if ((null_value= str->copy(res->ptr(), res->length(), collation.collation,
&my_charset_latin1, &errors)))
return 0;
}
return str;
}

View File

@@ -160,10 +160,11 @@ static int cmp_row_type(Item* item1, Item* item2)
static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
{
uint i;
uint unsigned_count= items[0]->unsigned_flag;
type[0]= items[0]->cmp_type();
for (i= 1 ; i < nitems ; i++)
for (uint i= 1 ; i < nitems ; i++)
{
unsigned_count+= items[i]->unsigned_flag;
type[0]= item_cmp_type(type[0], items[i]->cmp_type());
/*
When aggregating types of two row expressions we have to check
@@ -175,6 +176,12 @@ static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
if (type[0] == ROW_RESULT && cmp_row_type(items[0], items[i]))
return 1; // error found: invalid usage of rows
}
/**
If all arguments are of INT type but have different unsigned_flag values,
switch to DECIMAL_RESULT.
*/
if (type[0] == INT_RESULT && unsigned_count != nitems && unsigned_count != 0)
type[0]= DECIMAL_RESULT;
return 0;
}

View File

@@ -2951,12 +2951,13 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
}
unpack_time(min_max, ltime);
if (compare_as_dates->field_type() == MYSQL_TYPE_DATE)
enum_field_types ftype= compare_as_dates->field_type();
if (ftype == MYSQL_TYPE_DATE || ftype == MYSQL_TYPE_NEWDATE)
{
ltime->time_type= MYSQL_TIMESTAMP_DATE;
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
}
else if (compare_as_dates->field_type() == MYSQL_TYPE_TIME)
else if (ftype == MYSQL_TYPE_TIME)
{
ltime->time_type= MYSQL_TIMESTAMP_TIME;
ltime->hour+= (ltime->month * 32 + ltime->day) * 24;
@@ -6378,6 +6379,8 @@ bool Item_func_match::fix_index()
for (i=1; i < arg_count; i++)
{
if (args[i]->type() != FIELD_ITEM)
goto err;
item=(Item_field*)args[i];
for (keynr=0 ; keynr < fts ; keynr++)
{

View File

@@ -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

View File

@@ -935,9 +935,8 @@ void Item_func_monthname::fix_length_and_dec()
{
THD* thd= current_thd;
CHARSET_INFO *cs= thd->variables.collation_connection;
uint32 repertoire= my_charset_repertoire(cs);
locale= thd->variables.lc_time_names;
collation.set(cs, DERIVATION_COERCIBLE, repertoire);
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
maybe_null=1;
@@ -1082,9 +1081,8 @@ void Item_func_dayname::fix_length_and_dec()
{
THD* thd= current_thd;
CHARSET_INFO *cs= thd->variables.collation_connection;
uint32 repertoire= my_charset_repertoire(cs);
locale= thd->variables.lc_time_names;
collation.set(cs, DERIVATION_COERCIBLE, repertoire);
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
maybe_null=1;

View File

@@ -46,12 +46,9 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
static SYMBOL symbols[] = {
{ "&&", SYM(AND_AND_SYM)},
{ "<", SYM(LT)},
{ "<=", SYM(LE)},
{ "<>", SYM(NE)},
{ "!=", SYM(NE)},
{ "=", SYM(EQ)},
{ ">", SYM(GT_SYM)},
{ ">=", SYM(GE)},
{ "<<", SYM(SHIFT_LEFT)},
{ ">>", SYM(SHIFT_RIGHT)},

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
This program is free software; you can redistribute it and/or modify
@@ -8488,9 +8488,6 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
We can use a down cast here since we know that every table added
to the tables_to_lock is a RPL_TABLE_LIST.
*/
{
@@ -8509,10 +8506,37 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
NOTE: The base tables are added here are removed when
close_thread_tables is called.
*/
RPL_TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i= 0 ; ptr && (i < rli->tables_to_lock_count);
ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
TABLE_LIST *table_list_ptr= rli->tables_to_lock;
for (uint i=0 ; table_list_ptr && (i < rli->tables_to_lock_count);
table_list_ptr= table_list_ptr->next_global, i++)
{
/*
Below if condition takes care of skipping base tables that
make up the MERGE table (which are added by open_tables()
call). They are added next to the merge table in the list.
For eg: If RPL_TABLE_LIST is t3->t1->t2 (where t1 and t2
are base tables for merge table 't3'), open_tables will modify
the list by adding t1 and t2 again immediately after t3 in the
list (*not at the end of the list*). New table_to_lock list will
look like t3->t1'->t2'->t1->t2 (where t1' and t2' are TABLE_LIST
objects added by open_tables() call). There is no flag(or logic) in
open_tables() that can skip adding these base tables to the list.
So the logic here should take care of skipping them.
tables_to_lock_count logic will take care of skipping base tables
that are added at the end of the list.
For eg: If RPL_TABLE_LIST is t1->t2->t3, open_tables will modify
the list into t1->t2->t3->t1'->t2'. t1' and t2' will be skipped
because tables_to_lock_count logic in this for loop.
*/
if (table_list_ptr->parent_l)
continue;
/*
We can use a down cast here since we know that every table added
to the tables_to_lock is a RPL_TABLE_LIST (or child table which is
skipped above).
*/
RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(table_list_ptr);
DBUG_ASSERT(ptr->m_tabledef_valid);
TABLE *conv_table;
if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
@@ -8553,7 +8577,15 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
*/
TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i=0 ; ptr && (i < rli->tables_to_lock_count); ptr= ptr->next_global, i++)
{
/*
Please see comment in above 'for' loop to know the reason
for this if condition
*/
if (ptr->parent_l)
continue;
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
#ifdef WITH_WSREP

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
/* Copyright (c) 2007, 2016, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -119,16 +119,25 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
We can use a down cast here since we know that every table added
to the tables_to_lock is a RPL_TABLE_LIST.
*/
{
RPL_TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i= 0 ; ptr&& (i< rli->tables_to_lock_count);
ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
TABLE_LIST *table_list_ptr= rli->tables_to_lock;
for (uint i=0 ; table_list_ptr&& (i< rli->tables_to_lock_count);
table_list_ptr= table_list_ptr->next_global, i++)
{
/*
Please see comment in log_event.cc-Rows_log_event::do_apply_event()
function for the explanation of the below if condition
*/
if (table_list_ptr->parent_l)
continue;
/*
We can use a down cast here since we know that every table added
to the tables_to_lock is a RPL_TABLE_LIST(or child table which is
skipped above).
*/
RPL_TABLE_LIST *ptr=static_cast<RPL_TABLE_LIST*>(table_list_ptr);
DBUG_ASSERT(ptr->m_tabledef_valid);
TABLE *conv_table;
if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
@@ -162,7 +171,15 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
*/
TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i=0; ptr && (i < rli->tables_to_lock_count); ptr= ptr->next_global, i++)
{
/*
Please see comment in log_event.cc-Rows_log_event::do_apply_event()
function for the explanation of the below if condition
*/
if (ptr->parent_l)
continue;
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
@@ -1545,16 +1562,25 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
We can use a down cast here since we know that every table added
to the tables_to_lock is a RPL_TABLE_LIST.
*/
{
RPL_TABLE_LIST *ptr= rli->tables_to_lock;
for (uint i= 0 ; ptr&& (i< rli->tables_to_lock_count);
ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
TABLE_LIST *table_list_ptr= rli->tables_to_lock;
for (uint i=0; table_list_ptr&& (i< rli->tables_to_lock_count);
table_list_ptr= static_cast<RPL_TABLE_LIST*>(table_list_ptr->next_global), i++)
{
/*
Please see comment in log_event.cc-Rows_log_event::do_apply_event()
function for the explanation of the below if condition
*/
if (table_list_ptr->parent_l)
continue;
/*
We can use a down cast here since we know that every table added
to the tables_to_lock is a RPL_TABLE_LIST (or child table which is
skipped above).
*/
RPL_TABLE_LIST *ptr=static_cast<RPL_TABLE_LIST*>(table_list_ptr);
TABLE *conv_table;
if (ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
ptr->table, &conv_table))

View File

@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2008, 2015, SkySQL Ab.
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -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

View File

@@ -1,6 +1,6 @@
/*
Copyright (c) 2002, 2013, Oracle and/or its affiliates.
Copyright (c) 2011, 2013, Monty Program Ab
Copyright (c) 2002, 2016, Oracle and/or its affiliates.
Copyright (c) 2011, 2016, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -480,8 +480,10 @@ sp_name::init_qname(THD *thd)
bool
check_routine_name(LEX_STRING *ident)
{
if (!ident || !ident->str || !ident->str[0] ||
ident->str[ident->length-1] == ' ')
DBUG_ASSERT(ident);
DBUG_ASSERT(ident->str);
if (!ident->str[0] || ident->str[ident->length-1] == ' ')
{
my_error(ER_SP_WRONG_NAME, MYF(0), ident->str);
return TRUE;

View File

@@ -1106,7 +1106,8 @@ void end_connection(THD *thd)
}
if (!thd->killed && (net->error && net->vio != 0))
thd->print_aborted_warning(1, ER(ER_UNKNOWN_ERROR));
thd->print_aborted_warning(1,
thd->stmt_da->is_error() ? thd->stmt_da->message() : ER(ER_UNKNOWN_ERROR));
}

View File

@@ -1452,32 +1452,35 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
return (BIN_NUM);
case MY_LEX_CMP_OP: // Incomplete comparison operator
lip->next_state= MY_LEX_START; // Allow signed numbers
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
lip->yySkip();
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
{
lip->next_state= MY_LEX_START; // Allow signed numbers
return(tokval);
lip->yySkip();
if ((tokval= find_keyword(lip, 2, 0)))
return(tokval);
lip->yyUnget();
}
state = MY_LEX_CHAR; // Something fishy found
break;
return(c);
case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator
lip->next_state= MY_LEX_START;
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
{
lip->yySkip();
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP)
{
lip->yySkip();
if ((tokval= find_keyword(lip, 3, 0)))
return(tokval);
lip->yyUnget();
}
if ((tokval= find_keyword(lip, 2, 0)))
return(tokval);
lip->yyUnget();
}
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
{
lip->next_state= MY_LEX_START; // Found long op
return(tokval);
}
state = MY_LEX_CHAR; // Something fishy found
break;
return(c);
case MY_LEX_BOOL:
if (c != lip->yyPeek())

View File

@@ -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 */

View File

@@ -5891,6 +5891,7 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
temporary table flag)
@param alter_info [in] Initial list of columns and indexes for the
table to be created
@param create_db [in] Database of the created table
@retval
false ok.
@@ -5899,7 +5900,8 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
*/
bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info,
Alter_info *alter_info)
Alter_info *alter_info,
const char* create_db)
{
Key *key;
List_iterator<Key> key_iterator(alter_info->key_list);
@@ -5939,10 +5941,28 @@ bool check_fk_parent_table_access(THD *thd,
return true;
}
}
else if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
return true;
else
is_qualified_table_name= false;
{
if (!thd->db)
{
db_name.str= (char *) thd->memdup(create_db, strlen(create_db)+1);
db_name.length= strlen(create_db);
is_qualified_table_name= true;
if(create_db && check_db_name(&db_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
return true;
}
}
else
{
if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
return true;
else
is_qualified_table_name= false;
}
}
// if lower_case_table_names is set then convert tablename to lower case.
if (lower_case_table_names)
@@ -8081,7 +8101,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
goto err;
}
if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info))
if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info, create_table->db))
goto err;
error= FALSE;

View File

@@ -47,7 +47,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table);
bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info,
Alter_info *alter_info);
Alter_info *alter_info,
const char* create_db);
bool parse_sql(THD *thd,
Parser_state *parser_state,

View File

@@ -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

View File

@@ -14586,7 +14586,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->collation.collation);
else
new_field= item->make_string_field(table);
new_field->set_derivation(item->collation.derivation);
new_field->set_derivation(item->collation.derivation,
item->collation.repertoire);
break;
case DECIMAL_RESULT:
new_field= Field_new_decimal::create_from_item(item);
@@ -14825,7 +14826,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
modify_item, convert_blob_length);
case Item::TYPE_HOLDER:
result= ((Item_type_holder *)item)->make_field_by_type(table);
result->set_derivation(item->collation.derivation);
result->set_derivation(item->collation.derivation,
item->collation.repertoire);
return result;
default: // Dosen't have to be stored
return 0;

View File

@@ -6365,7 +6365,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
till this point for the alter operation.
*/
if ((alter_info->flags & ALTER_FOREIGN_KEY) &&
check_fk_parent_table_access(thd, create_info, alter_info))
check_fk_parent_table_access(thd, create_info, alter_info, new_db))
goto err;
/*

View File

@@ -970,7 +970,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token ENGINES_SYM
%token ENGINE_SYM
%token ENUM
%token EQ /* OPERATOR */
%token EQUAL_SYM /* OPERATOR */
%token ERROR_SYM
%token ERRORS
@@ -1016,7 +1015,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token GRANTS
%token GROUP_SYM /* SQL-2003-R */
%token GROUP_CONCAT_SYM
%token GT_SYM /* OPERATOR */
%token HANDLER_SYM
%token HARD_SYM
%token HASH_SYM
@@ -1095,7 +1093,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token LONG_SYM
%token LOOP_SYM
%token LOW_PRIORITY
%token LT /* OPERATOR */
%token MASTER_CONNECT_RETRY_SYM
%token MASTER_HOST_SYM
%token MASTER_LOG_FILE_SYM
@@ -1439,7 +1436,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%left XOR
%left AND_SYM AND_AND_SYM
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM
%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM
%left '|'
%left '&'
%left SHIFT_LEFT SHIFT_RIGHT
@@ -1922,58 +1919,58 @@ master_defs:
;
master_def:
MASTER_HOST_SYM EQ TEXT_STRING_sys
MASTER_HOST_SYM '=' TEXT_STRING_sys
{
Lex->mi.host = $3.str;
}
| MASTER_USER_SYM EQ TEXT_STRING_sys
| MASTER_USER_SYM '=' TEXT_STRING_sys
{
Lex->mi.user = $3.str;
}
| MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
| MASTER_PASSWORD_SYM '=' TEXT_STRING_sys
{
Lex->mi.password = $3.str;
}
| MASTER_PORT_SYM EQ ulong_num
| MASTER_PORT_SYM '=' ulong_num
{
Lex->mi.port = $3;
}
| MASTER_CONNECT_RETRY_SYM EQ ulong_num
| MASTER_CONNECT_RETRY_SYM '=' ulong_num
{
Lex->mi.connect_retry = $3;
}
| MASTER_SSL_SYM EQ ulong_num
| MASTER_SSL_SYM '=' ulong_num
{
Lex->mi.ssl= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
| MASTER_SSL_CA_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CA_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_ca= $3.str;
}
| MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CAPATH_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_capath= $3.str;
}
| MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CERT_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_cert= $3.str;
}
| MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CIPHER_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_cipher= $3.str;
}
| MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys
| MASTER_SSL_KEY_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_key= $3.str;
}
| MASTER_SSL_VERIFY_SERVER_CERT_SYM EQ ulong_num
| MASTER_SSL_VERIFY_SERVER_CERT_SYM '=' ulong_num
{
Lex->mi.ssl_verify_server_cert= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
| MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
| MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal
{
Lex->mi.heartbeat_period= (float) $3->val_real();
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
@@ -2004,7 +2001,7 @@ master_def:
}
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
| IGNORE_SERVER_IDS_SYM EQ '(' ignore_server_id_list ')'
| IGNORE_SERVER_IDS_SYM '=' '(' ignore_server_id_list ')'
{
Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
@@ -2025,11 +2022,11 @@ ignore_server_id:
}
master_file_def:
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
MASTER_LOG_FILE_SYM '=' TEXT_STRING_sys
{
Lex->mi.log_file_name = $3.str;
}
| MASTER_LOG_POS_SYM EQ ulonglong_num
| MASTER_LOG_POS_SYM '=' ulonglong_num
{
Lex->mi.pos = $3;
/*
@@ -2045,11 +2042,11 @@ master_file_def:
*/
Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
}
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
| RELAY_LOG_FILE_SYM '=' TEXT_STRING_sys
{
Lex->mi.relay_log_name = $3.str;
}
| RELAY_LOG_POS_SYM EQ ulong_num
| RELAY_LOG_POS_SYM '=' ulong_num
{
Lex->mi.relay_log_pos = $3;
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
@@ -3032,7 +3029,7 @@ opt_set_signal_information:
;
signal_information_item_list:
signal_condition_information_item_name EQ signal_allowed_expr
signal_condition_information_item_name '=' signal_allowed_expr
{
Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info;
@@ -3041,7 +3038,7 @@ signal_information_item_list:
info->m_item[index]= $3;
}
| signal_information_item_list ','
signal_condition_information_item_name EQ signal_allowed_expr
signal_condition_information_item_name '=' signal_allowed_expr
{
Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info;
@@ -4439,7 +4436,7 @@ opt_linear:
opt_key_algo:
/* empty */
{ Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;}
| ALGORITHM_SYM EQ real_ulong_num
| ALGORITHM_SYM '=' real_ulong_num
{
switch ($3) {
case 1:
@@ -7082,7 +7079,7 @@ opt_place:
opt_to:
/* empty */ {}
| TO_SYM {}
| EQ {}
| '=' {}
| AS {}
;
@@ -7949,13 +7946,13 @@ bool_pri:
if ($$ == NULL)
MYSQL_YYABORT;
}
| bool_pri comp_op predicate %prec EQ
| bool_pri comp_op predicate %prec '='
{
$$= (*$2)(0)->create($1,$3);
if ($$ == NULL)
MYSQL_YYABORT;
}
| bool_pri comp_op all_or_any '(' subselect ')' %prec EQ
| bool_pri comp_op all_or_any '(' subselect ')' %prec '='
{
$$= all_any_subquery_creator($1, $2, $3, $5);
if ($$ == NULL)
@@ -8178,11 +8175,11 @@ not2:
;
comp_op:
EQ { $$ = &comp_eq_creator; }
'=' { $$ = &comp_eq_creator; }
| GE { $$ = &comp_ge_creator; }
| GT_SYM { $$ = &comp_gt_creator; }
| '>' { $$ = &comp_gt_creator; }
| LE { $$ = &comp_le_creator; }
| LT { $$ = &comp_lt_creator; }
| '<' { $$ = &comp_lt_creator; }
| NE { $$ = &comp_ne_creator; }
;
@@ -10203,7 +10200,7 @@ date_time_type:
table_alias:
/* empty */
| AS
| EQ
| '='
;
opt_table_alias:
@@ -11106,7 +11103,7 @@ ident_eq_value:
;
equal:
EQ {}
'=' {}
| SET_VAR {}
;
@@ -13974,11 +13971,11 @@ handler_rkey_function:
;
handler_rkey_mode:
EQ { $$=HA_READ_KEY_EXACT; }
'=' { $$=HA_READ_KEY_EXACT; }
| GE { $$=HA_READ_KEY_OR_NEXT; }
| LE { $$=HA_READ_KEY_OR_PREV; }
| GT_SYM { $$=HA_READ_AFTER_KEY; }
| LT { $$=HA_READ_BEFORE_KEY; }
| '>' { $$=HA_READ_AFTER_KEY; }
| '<' { $$=HA_READ_BEFORE_KEY; }
;
/* GRANT / REVOKE */
@@ -14750,7 +14747,7 @@ no_definer:
;
definer:
DEFINER_SYM EQ user
DEFINER_SYM '=' user
{
thd->lex->definer= get_current_user(thd, $3);
}
@@ -14777,11 +14774,11 @@ view_replace:
;
view_algorithm:
ALGORITHM_SYM EQ UNDEFINED_SYM
ALGORITHM_SYM '=' UNDEFINED_SYM
{ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
| ALGORITHM_SYM EQ MERGE_SYM
| ALGORITHM_SYM '=' MERGE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
| ALGORITHM_SYM EQ TEMPTABLE_SYM
| ALGORITHM_SYM '=' TEMPTABLE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
;

View File

@@ -166,6 +166,7 @@ struct pool_timer_t
volatile uint64 next_timeout_check;
int tick_interval;
bool shutdown;
pthread_t timer_thread_id;
};
static pool_timer_t pool_timer;
@@ -603,12 +604,12 @@ void check_stall(thread_group_t *thread_group)
static void start_timer(pool_timer_t* timer)
{
pthread_t thread_id;
DBUG_ENTER("start_timer");
mysql_mutex_init(key_timer_mutex,&timer->mutex, NULL);
mysql_cond_init(key_timer_cond, &timer->cond, NULL);
timer->shutdown = false;
mysql_thread_create(key_timer_thread,&thread_id, NULL, timer_thread, timer);
mysql_thread_create(key_timer_thread, &timer->timer_thread_id, NULL,
timer_thread, timer);
DBUG_VOID_RETURN;
}
@@ -620,6 +621,7 @@ static void stop_timer(pool_timer_t *timer)
timer->shutdown = true;
mysql_cond_signal(&timer->cond);
mysql_mutex_unlock(&timer->mutex);
pthread_join(timer->timer_thread_id, NULL);
DBUG_VOID_RETURN;
}

View File

@@ -2163,7 +2163,6 @@ no_db_name:
A wrapper function of innobase_convert_name(), convert a table or
index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
@return pointer to the end of buf */
static inline
void
innobase_format_name(
/*==================*/
@@ -9746,6 +9745,36 @@ ha_innobase::check(
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
if (prebuilt->table->corrupted) {
char index_name[MAX_FULL_NAME_LEN + 1];
/* If some previous operation has marked the table as
corrupted in memory, and has not propagated such to
clustered index, we will do so here */
index = dict_table_get_first_index(prebuilt->table);
if (!dict_index_is_corrupted(index)) {
row_mysql_lock_data_dictionary(prebuilt->trx);
dict_set_corrupted(index);
row_mysql_unlock_data_dictionary(prebuilt->trx);
}
innobase_format_name(index_name, sizeof index_name,
index->name, TRUE);
push_warning_printf(thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
HA_ERR_INDEX_CORRUPT,
"InnoDB: Index %s is marked as"
" corrupted",
index_name);
/* Now that the table is already marked as corrupted,
there is no need to check any index of this table */
prebuilt->trx->op_info = "";
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
prebuilt->trx->op_info = "checking table";
old_isolation_level = prebuilt->trx->isolation_level;
@@ -9822,6 +9851,15 @@ ha_innobase::check(
prebuilt->index_usable = row_merge_is_index_usable(
prebuilt->trx, prebuilt->index);
DBUG_EXECUTE_IF(
"dict_set_index_corrupted",
if (!dict_index_is_clust(index)) {
prebuilt->index_usable = FALSE;
row_mysql_lock_data_dictionary(prebuilt->trx);
dict_set_corrupted(index);
row_mysql_unlock_data_dictionary(prebuilt->trx);
});
if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
innobase_format_name(
index_name, sizeof index_name,

View File

@@ -658,6 +658,19 @@ public:
~ha_innobase_add_index() {}
};
/*****************************************************************//**
A wrapper function of innobase_convert_name(), convert a table or
index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
@return pointer to the end of buf */
void
innobase_format_name(
/*==================*/
char* buf, /*!< out: buffer for converted identifier */
ulint buflen, /*!< in: length of buf, in bytes */
const char* name, /*!< in: index or table name to format */
ibool is_index_name); /*!< in: index name */
/*******************************************************************//**
Create indexes.
@return 0 or error number */
@@ -719,6 +732,28 @@ ha_innobase::add_index(
DBUG_RETURN(-1);
}
/* Check if any of the existing indexes are marked as corruption,
and if they are, refuse adding more indexes. */
for (dict_index_t* check_index = dict_table_get_first_index(indexed_table);
check_index != NULL;
check_index = dict_table_get_next_index(check_index)) {
if (dict_index_is_corrupted(check_index)) {
char index_name[MAX_FULL_NAME_LEN + 1];
innobase_format_name(index_name, sizeof index_name,
check_index->name, TRUE);
push_warning_printf(user_thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
HA_ERR_INDEX_CORRUPT,
"InnoDB: Index %s is marked as"
" corrupted",
index_name);
DBUG_RETURN(HA_ERR_INDEX_CORRUPT);
}
}
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table);

View File

@@ -46,7 +46,7 @@ static mysql_mutex_t LOCK_checkpoint;
static mysql_cond_t COND_checkpoint;
/** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL checkpoint_control=
{THREAD_DEAD, FALSE, &LOCK_checkpoint, &COND_checkpoint};
{0, FALSE, FALSE, &LOCK_checkpoint, &COND_checkpoint};
/* is ulong like pagecache->blocks_changed */
static ulong pages_to_flush_before_next_checkpoint;
static PAGECACHE_FILE *dfiles, /**< data files to flush in background */
@@ -326,7 +326,6 @@ end:
int ma_checkpoint_init(ulong interval)
{
pthread_t th;
int res= 0;
DBUG_ENTER("ma_checkpoint_init");
if (ma_service_thread_control_init(&checkpoint_control))
@@ -334,14 +333,14 @@ int ma_checkpoint_init(ulong interval)
else if (interval > 0)
{
compile_time_assert(sizeof(void *) >= sizeof(ulong));
if (!(res= mysql_thread_create(key_thread_checkpoint,
&th, NULL, ma_checkpoint_background,
(void *)interval)))
{
/* thread lives, will have to be killed */
checkpoint_control.status= THREAD_RUNNING;
}
if ((res= mysql_thread_create(key_thread_checkpoint,
&checkpoint_control.thread, NULL,
ma_checkpoint_background,
(void*) interval)))
checkpoint_control.killed= TRUE;
}
else
checkpoint_control.killed= TRUE;
DBUG_RETURN(res);
}
@@ -717,7 +716,6 @@ pthread_handler_t ma_checkpoint_background(void *arg)
DBUG_EXECUTE_IF("maria_checkpoint_indirect", level= CHECKPOINT_INDIRECT;);
ma_checkpoint_execute(level, FALSE);
}
my_service_thread_signal_end(&checkpoint_control);
my_thread_end();
return 0;
}

View File

@@ -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);
}

View File

@@ -500,8 +500,8 @@ static void test_key_cache(PAGECACHE *pagecache,
const char *where, my_bool lock);
#endif
#define PAGECACHE_HASH(p, f, pos) (((ulong) (pos) + \
(ulong) (f).file) & (p->hash_entries-1))
#define PAGECACHE_HASH(p, f, pos) (((size_t) (pos) + \
(size_t) (f).file) & (p->hash_entries-1))
#define FILE_HASH(f) ((uint) (f).file & (PAGECACHE_CHANGED_BLOCKS_HASH - 1))
#define DEFAULT_PAGECACHE_DEBUG_LOG "pagecache_debug.log"
@@ -639,10 +639,10 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache,
{
char buff[80];
uint len= my_sprintf(buff,
(buff, "fwrite: fd: %d id: %u page: %lu",
(buff, "fwrite: fd: %d id: %u page: %llu",
filedesc->file,
_ma_file_callback_to_id(filedesc->callback_data),
(ulong) pageno));
pageno));
(void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY,
(uchar*) buff, len);
}
@@ -741,11 +741,11 @@ static inline uint next_power(uint value)
*/
ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
uint division_limit, uint age_threshold,
uint block_size, myf my_readwrite_flags)
{
ulong blocks, hash_links, length;
size_t blocks, hash_links, length;
int error;
DBUG_ENTER("init_pagecache");
DBUG_ASSERT(block_size >= 512);
@@ -782,10 +782,10 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
DBUG_PRINT("info", ("block_size: %u", block_size));
DBUG_ASSERT(((uint)(1 << pagecache->shift)) == block_size);
blocks= (ulong) (use_mem / (sizeof(PAGECACHE_BLOCK_LINK) +
blocks= use_mem / (sizeof(PAGECACHE_BLOCK_LINK) +
2 * sizeof(PAGECACHE_HASH_LINK) +
sizeof(PAGECACHE_HASH_LINK*) *
5/4 + block_size));
5/4 + block_size);
/*
We need to support page cache with just one block to be able to do
scanning of rows-in-block files
@@ -816,7 +816,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
blocks--;
/* Allocate memory for cache page buffers */
if ((pagecache->block_mem=
my_large_malloc((ulong) blocks * pagecache->block_size,
my_large_malloc(blocks * pagecache->block_size,
MYF(MY_WME))))
{
/*
@@ -824,7 +824,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
For each block 2 hash links are allocated
*/
if ((pagecache->block_root=
(PAGECACHE_BLOCK_LINK*) my_malloc((size_t) length, MYF(0))))
(PAGECACHE_BLOCK_LINK*) my_malloc(length, MYF(0))))
break;
my_large_free(pagecache->block_mem);
pagecache->block_mem= 0;
@@ -832,7 +832,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
blocks= blocks / 4*3;
}
pagecache->blocks_unused= blocks;
pagecache->disk_blocks= (long) blocks;
pagecache->disk_blocks= blocks;
pagecache->hash_links= hash_links;
pagecache->hash_root=
(PAGECACHE_HASH_LINK**) ((char*) pagecache->block_root +
@@ -887,7 +887,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
PAGECACHE_CHANGED_BLOCKS_HASH);
pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0;
DBUG_RETURN((ulong) pagecache->disk_blocks);
DBUG_RETURN((size_t)pagecache->disk_blocks);
err:
error= my_errno;
@@ -978,11 +978,11 @@ static int flush_all_key_blocks(PAGECACHE *pagecache)
So we disable it for now.
*/
#if NOT_USED /* keep disabled until code is fixed see above !! */
ulong resize_pagecache(PAGECACHE *pagecache,
size_t resize_pagecache(PAGECACHE *pagecache,
size_t use_mem, uint division_limit,
uint age_threshold)
{
ulong blocks;
size_t blocks;
struct st_my_thread_var *thread;
WQUEUE *wqueue;
@@ -1379,7 +1379,7 @@ static void link_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block,
("linked block: %u:%1u status: %x #requests: %u #available: %u",
PCBLOCK_NUMBER(pagecache, block), at_end, block->status,
block->requests, pagecache->blocks_available));
KEYCACHE_DBUG_ASSERT((ulong) pagecache->blocks_available <=
KEYCACHE_DBUG_ASSERT(pagecache->blocks_available <=
pagecache->blocks_used);
#endif
DBUG_VOID_RETURN;
@@ -2018,7 +2018,7 @@ restart:
/* There are some never used blocks, take first of them */
block= &pagecache->block_root[pagecache->blocks_used];
block->buffer= ADD_TO_PTR(pagecache->block_mem,
((ulong) pagecache->blocks_used*
(pagecache->blocks_used*
pagecache->block_size),
uchar*);
pagecache->blocks_used++;
@@ -4870,7 +4870,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LSN *min_rec_lsn)
{
my_bool error= 0;
ulong stored_list_size= 0;
size_t stored_list_size= 0;
uint file_hash;
char *ptr;
LSN minimum_rec_lsn= LSN_MAX;

View File

@@ -117,20 +117,20 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
typedef struct st_pagecache
{
size_t mem_size; /* specified size of the cache memory */
ulong min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */
size_t min_warm_blocks; /* min number of warm blocks; */
size_t age_threshold; /* age threshold for hot blocks */
ulonglong time; /* total number of block link operations */
ulong hash_entries; /* max number of entries in the hash table */
long hash_links; /* max number of hash links */
long hash_links_used; /* number of hash links taken from free links pool */
long disk_blocks; /* max number of blocks in the cache */
ulong blocks_used; /* maximum number of concurrently used blocks */
ulong blocks_unused; /* number of currently unused blocks */
ulong blocks_changed; /* number of currently dirty blocks */
ulong warm_blocks; /* number of blocks in warm sub-chain */
ulong cnt_for_resize_op; /* counter to block resize operation */
ulong blocks_available; /* number of blocks available in the LRU chain */
long blocks; /* max number of blocks in the cache */
size_t hash_entries; /* max number of entries in the hash table */
ssize_t hash_links; /* max number of hash links */
ssize_t hash_links_used; /* number of hash links taken from free links pool */
ssize_t disk_blocks; /* max number of blocks in the cache */
size_t blocks_used; /* maximum number of concurrently used blocks */
size_t blocks_unused; /* number of currently unused blocks */
size_t blocks_changed; /* number of currently dirty blocks */
size_t warm_blocks; /* number of blocks in warm sub-chain */
size_t cnt_for_resize_op; /* counter to block resize operation */
size_t blocks_available; /* number of blocks available in the LRU chain */
ssize_t blocks; /* max number of blocks in the cache */
uint32 block_size; /* size of the page buffer of a cache block */
PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */
PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */
@@ -155,12 +155,12 @@ typedef struct st_pagecache
*/
ulonglong param_buff_size; /* size the memory allocated for the cache */
ulong param_block_size; /* size of the blocks in the key cache */
ulong param_division_limit; /* min. percentage of warm blocks */
ulong param_age_threshold; /* determines when hot block is downgraded */
size_t param_block_size; /* size of the blocks in the key cache */
size_t param_division_limit; /* min. percentage of warm blocks */
size_t param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables. These are reset in reset_pagecache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */
size_t global_blocks_changed; /* number of currently dirty blocks */
ulonglong global_cache_w_requests;/* number of write requests (write hits) */
ulonglong global_cache_write; /* number of writes from cache to files */
ulonglong global_cache_r_requests;/* number of read requests (read hits) */
@@ -193,10 +193,10 @@ typedef enum pagecache_flush_filter_result
/* The default key cache */
extern PAGECACHE dflt_pagecache_var, *dflt_pagecache;
extern ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
extern size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
uint division_limit, uint age_threshold,
uint block_size, myf my_read_flags);
extern ulong resize_pagecache(PAGECACHE *pagecache,
extern size_t resize_pagecache(PAGECACHE *pagecache,
size_t use_mem, uint division_limit,
uint age_threshold);
extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit,

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -86,6 +86,27 @@ static int write_merge_key_varlen(MARIA_SORT_PARAM *info,
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
@@ -115,18 +136,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
(ulong) sortbuff_size, info->key_length,
(ulong) info->sort_info->max_records));
if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
{
info->write_keys= write_keys_varlen;
info->read_to_buffer=read_to_buffer_varlen;
info->write_key=write_merge_key_varlen;
}
else
{
info->write_keys= write_keys;
info->read_to_buffer=read_to_buffer;
info->write_key=write_merge_key;
}
set_sort_param_read_write(info);
my_b_clear(&tempfile);
my_b_clear(&tempfile_for_exceptions);
@@ -323,181 +333,182 @@ err:
} /* find_all_keys */
static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param)
{
int error= 0;
ulonglong memavl, old_memavl;
uint UNINIT_VAR(keys), idx;
uint sort_length;
uint maxbuffer;
uchar **sort_keys= NULL;
DBUG_ENTER("_ma_thr_find_all_keys");
DBUG_PRINT("enter", ("master: %d", sort_param->master));
if (sort_param->sort_info->got_error)
DBUG_RETURN(TRUE);
set_sort_param_read_write(sort_param);
my_b_clear(&sort_param->tempfile);
my_b_clear(&sort_param->tempfile_for_exceptions);
bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek));
bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
idx= 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
{
ulong skr;
do
{
skr= maxbuffer;
if (memavl < sizeof(BUFFPEK)*maxbuffer ||
(keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
(sort_length+sizeof(char*))) <= 1 ||
keys < maxbuffer)
{
_ma_check_print_error(sort_param->sort_info->param,
"aria_sort_buffer_size is too small.");
goto err;
}
}
while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
}
if ((sort_keys= (uchar **)
my_malloc(keys*(sort_length+sizeof(char*))+
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
HA_FT_MAXBYTELEN : 0), MYF(0))))
{
if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
maxbuffer, maxbuffer / 2))
{
my_free(sort_keys);
sort_keys= NULL; /* Safety against double free on error. */
}
else
break;
}
old_memavl= memavl;
if ((memavl= memavl/4*3) < MIN_SORT_MEMORY &&
old_memavl > MIN_SORT_MEMORY)
memavl= MIN_SORT_MEMORY;
}
if (memavl < MIN_SORT_MEMORY)
{
/* purecov: begin inspected */
_ma_check_print_error(sort_param->sort_info->param,
"aria_sort_buffer_size is too small.");
my_errno= ENOMEM;
goto err;
/* purecov: end inspected */
}
if (sort_param->sort_info->param->testflag & T_VERBOSE)
printf("Key %d - Allocating buffer for %llu keys\n",
sort_param->key + 1, (ulonglong) keys);
sort_param->sort_keys= sort_keys;
idx= error= 0;
sort_keys[0]= (uchar*) (sort_keys+keys);
DBUG_PRINT("info", ("reading keys"));
while (!(error= sort_param->sort_info->got_error) &&
!(error= (*sort_param->key_read)(sort_param, sort_keys[idx])))
{
if (sort_param->real_key_length > sort_param->key_length)
{
if (write_key(sort_param, sort_keys[idx],
&sort_param->tempfile_for_exceptions))
goto err;
continue;
}
if (++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 (error > 0)
goto err;
if (sort_param->buffpek.elements)
{
if (sort_param->write_keys(sort_param,sort_keys, idx,
(BUFFPEK *) alloc_dynamic(&sort_param->buffpek),
&sort_param->tempfile))
goto err;
sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx;
}
else
sort_param->keys= idx;
sort_param->sort_keys_length= keys;
DBUG_RETURN(FALSE);
err:
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;
int error;
size_t memavl,old_memavl;
uint sort_length;
ulong idx, maxbuffer, keys;
uchar **sort_keys=0;
my_bool error= FALSE;
/* If my_thread_init fails */
if (my_thread_init() || _ma_thr_find_all_keys_exec(sort_param))
error= TRUE;
LINT_INIT(keys);
/*
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);
error=1;
/* 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);
if (my_thread_init())
goto err;
mysql_mutex_lock(&sort_param->sort_info->mutex);
if (error)
sort_param->sort_info->got_error= 1;
{ /* 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;
if (!--sort_param->sort_info->threads_running)
mysql_cond_signal(&sort_param->sort_info->cond);
mysql_mutex_unlock(&sort_param->sort_info->mutex);
if (sort_param->keyinfo->flag & HA_VAR_LENGTH_KEY)
{
sort_param->write_keys= write_keys_varlen;
sort_param->read_to_buffer= read_to_buffer_varlen;
sort_param->write_key= write_merge_key_varlen;
}
else
{
sort_param->write_keys= write_keys;
sort_param->read_to_buffer= read_to_buffer;
sort_param->write_key= write_merge_key;
}
my_b_clear(&sort_param->tempfile);
my_b_clear(&sort_param->tempfile_for_exceptions);
bzero((char*) &sort_param->buffpek,sizeof(sort_param->buffpek));
bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
idx= (uint)sort_param->sort_info->max_records;
sort_length= sort_param->key_length;
maxbuffer= 1;
while (memavl >= MIN_SORT_MEMORY)
{
if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl)
keys= idx+1;
else
{
ulong skr;
do
{
skr= maxbuffer;
if (memavl < sizeof(BUFFPEK)*maxbuffer ||
(keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
(sort_length+sizeof(char*))) <= 1 ||
keys < maxbuffer)
{
_ma_check_print_error(sort_param->sort_info->param,
"aria_sort_buffer_size is too small");
goto err;
}
}
while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
}
if ((sort_keys= (uchar **)
my_malloc(keys*(sort_length+sizeof(char*))+
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
HA_FT_MAXBYTELEN : 0), MYF(0))))
{
if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
maxbuffer, maxbuffer/2))
{
my_free(sort_keys);
sort_keys= (uchar **) NULL; /* for err: label */
}
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)
{
_ma_check_print_error(sort_param->sort_info->param,
"Aria sort buffer too small");
goto err; /* purecov: tested */
}
if (sort_param->sort_info->param->testflag & T_VERBOSE)
printf("Key %d - Allocating buffer for %lu keys\n",
sort_param->key+1, (ulong) keys);
sort_param->sort_keys= sort_keys;
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])))
{
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 (error > 0)
goto err;
if (sort_param->buffpek.elements)
{
if (sort_param->write_keys(sort_param,sort_keys, idx,
(BUFFPEK *) alloc_dynamic(&sort_param->
buffpek),
&sort_param->tempfile))
goto err;
sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx;
}
else
sort_param->keys= idx;
sort_param->sort_keys_length= keys;
goto ok;
err:
DBUG_PRINT("error", ("got some error"));
sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */
my_free(sort_keys);
sort_param->sort_keys=0;
delete_dynamic(& sort_param->buffpek);
close_cached_file(&sort_param->tempfile);
close_cached_file(&sort_param->tempfile_for_exceptions);
ok:
free_root(&sort_param->wordroot, MYF(0));
/*
Detach from the share if the writer is involved. Avoid others to
be blocked. This includes a flush of the write buffer. This will
also indicate EOF to the readers.
*/
if (sort_param->sort_info->info->rec_cache.share)
remove_io_thread(&sort_param->sort_info->info->rec_cache);
/* Readers detach from the share if any. Avoid others to be blocked. */
if (sort_param->read_cache.share)
remove_io_thread(&sort_param->read_cache);
mysql_mutex_lock(&sort_param->sort_info->mutex);
if (!--sort_param->sort_info->threads_running)
mysql_cond_signal(&sort_param->sort_info->cond);
mysql_mutex_unlock(&sort_param->sort_info->mutex);
DBUG_PRINT("exit", ("======== ending thread ========"));
}
my_thread_end();
return NULL;
}
@@ -507,7 +518,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
{
MARIA_SORT_INFO *sort_info=sort_param->sort_info;
HA_CHECK *param=sort_info->param;
ulong UNINIT_VAR(length), keys;
size_t UNINIT_VAR(length), keys;
double *rec_per_key_part= param->new_rec_per_key_part;
int got_error=sort_info->got_error;
uint i;
@@ -564,18 +575,9 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
{
if (got_error)
continue;
if (sinfo->keyinfo->flag & HA_VAR_LENGTH_KEY)
{
sinfo->write_keys=write_keys_varlen;
sinfo->read_to_buffer=read_to_buffer_varlen;
sinfo->write_key=write_merge_key_varlen;
}
else
{
sinfo->write_keys=write_keys;
sinfo->read_to_buffer=read_to_buffer;
sinfo->write_key=write_merge_key;
}
set_sort_param_read_write(sinfo);
if (sinfo->buffpek.elements)
{
uint maxbuffer=sinfo->buffpek.elements-1;

View File

@@ -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;

Some files were not shown because too many files have changed in this diff Show More