1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge tag 'mariadb-10.0.32' into 10.0-galera

This commit is contained in:
Jan Lindström
2017-08-09 08:56:11 +03:00
468 changed files with 41864 additions and 3193 deletions

24
CREDITS
View File

@ -4,17 +4,19 @@ organization registered in the USA.
The current main sponsors of the MariaDB Foundation are: The current main sponsors of the MariaDB Foundation are:
Alibaba Cloud https://intl.aliyun.com (2017) Alibaba Cloud https://intl.aliyun.com (2017)
Booking.com https://www.booking.com (2013 - 2017) Booking.com https://www.booking.com (2013)
Development Bank of Singapore https://dbs.com (2016 - 2017) Tencent Cloud https://cloud.tencent.com (2017)
MariaDB Corporation https://www.mariadb.com (2013 - 2017) Development Bank of Singapore https://dbs.com (2016)
Visma https://visma.com (2015 - 2017) IBM https://www.ibm.com (2017)
Acronis http://acronis.com (2016 - 2017) MariaDB Corporation https://www.mariadb.com (2013)
Nexedi https://www.nexedi.com (2016 - 2017) Visma https://visma.com (2015)
Automattic https://automattic.com (2014 - 2017) Acronis http://acronis.com (2016)
Tencent Game DBA http://tencentdba.com/about (2016 - 2017) Nexedi https://www.nexedi.com (2016)
Tencent TDSQL http://tdsql.org/ (2016 - 2017) Automattic https://automattic.com (2014)
Verkkokauppa.com https://www.verkkokauppa.com (2015 - 2017) Tencent Game DBA http://tencentdba.com/about (2016)
Virtuozzo https://virtuozzo.com (2016 - 2017) Tencent TDSQL http://tdsql.org (2016)
Verkkokauppa.com https://www.verkkokauppa.com (2015)
Virtuozzo https://virtuozzo.com (2016)
For a full list of sponsors, see For a full list of sponsors, see
https://mariadb.org/about/supporters/ https://mariadb.org/about/supporters/

View File

@ -149,7 +149,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
default_pager_set= 0, opt_sigint_ignore= 0, default_pager_set= 0, opt_sigint_ignore= 0,
auto_vertical_output= 0, auto_vertical_output= 0,
show_warnings= 0, executing_query= 0, show_warnings= 0, executing_query= 0,
ignore_spaces= 0, opt_progress_reports; ignore_spaces= 0, opt_binhex= 0, opt_progress_reports;
static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error; static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
static my_bool column_types_flag; static my_bool column_types_flag;
static my_bool preserve_comments= 0; static my_bool preserve_comments= 0;
@ -1494,6 +1494,8 @@ static struct my_option my_long_options[] =
{"batch", 'B', {"batch", 'B',
"Don't use history file. Disable interactive behavior. (Enables --silent.)", "Don't use history file. Disable interactive behavior. (Enables --silent.)",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"binary-as-hex", 'b', "Print binary data as hex", &opt_binhex, &opt_binhex,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory for character set files.", &charsets_dir, "Directory for character set files.", &charsets_dir,
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@ -2321,7 +2323,9 @@ static bool add_line(String &buffer, char *line, ulong line_length,
continue; continue;
} }
#endif #endif
if (!*ml_comment && inchar == '\\' && if (!*ml_comment && inchar == '\\' && *in_string != '`' &&
!(*in_string == '"' &&
(mysql.server_status & SERVER_STATUS_ANSI_QUOTES)) &&
!(*in_string && !(*in_string &&
(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES))) (mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)))
{ {
@ -3316,7 +3320,8 @@ com_go(String *buffer,char *line __attribute__((unused)))
print_table_data_html(result); print_table_data_html(result);
else if (opt_xml) else if (opt_xml)
print_table_data_xml(result); print_table_data_xml(result);
else if (vertical || (auto_vertical_output && (terminal_width < get_result_width(result)))) else if (vertical || (auto_vertical_output &&
(terminal_width < get_result_width(result))))
print_table_data_vertically(result); print_table_data_vertically(result);
else if (opt_silent && verbose <= 2 && !output_tables) else if (opt_silent && verbose <= 2 && !output_tables)
print_tab_data(result); print_tab_data(result);
@ -3535,6 +3540,41 @@ print_field_types(MYSQL_RES *result)
} }
/* Used to determine if we should invoke print_as_hex for this field */
static bool
is_binary_field(MYSQL_FIELD *field)
{
if ((field->charsetnr == 63) &&
(field->type == MYSQL_TYPE_BIT ||
field->type == MYSQL_TYPE_BLOB ||
field->type == MYSQL_TYPE_LONG_BLOB ||
field->type == MYSQL_TYPE_MEDIUM_BLOB ||
field->type == MYSQL_TYPE_TINY_BLOB ||
field->type == MYSQL_TYPE_VAR_STRING ||
field->type == MYSQL_TYPE_STRING ||
field->type == MYSQL_TYPE_VARCHAR ||
field->type == MYSQL_TYPE_GEOMETRY))
return 1;
return 0;
}
/* Print binary value as hex literal (0x ...) */
static void
print_as_hex(FILE *output_file, const char *str, ulong len, ulong total_bytes_to_send)
{
const char *ptr= str, *end= ptr+len;
ulong i;
fprintf(output_file, "0x");
for(; ptr < end; ptr++)
fprintf(output_file, "%02X", *((uchar*)ptr));
for (i= 2*len+2; i < total_bytes_to_send; i++)
tee_putc((int)' ', output_file);
}
static void static void
print_table_data(MYSQL_RES *result) print_table_data(MYSQL_RES *result)
{ {
@ -3561,6 +3601,8 @@ print_table_data(MYSQL_RES *result)
length= MY_MAX(length,field->max_length); length= MY_MAX(length,field->max_length);
if (length < 4 && !IS_NOT_NULL(field->flags)) if (length < 4 && !IS_NOT_NULL(field->flags))
length=4; // Room for "NULL" length=4; // Room for "NULL"
if (opt_binhex && is_binary_field(field))
length= 2 + length * 2;
field->max_length=length; field->max_length=length;
num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type); num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type);
separator.fill(separator.length()+length+2,'-'); separator.fill(separator.length()+length+2,'-');
@ -3628,9 +3670,11 @@ print_table_data(MYSQL_RES *result)
many extra padding-characters we should send with the printing function. many extra padding-characters we should send with the printing function.
*/ */
visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length); visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length);
extra_padding= data_length - visible_length; extra_padding= (uint) (data_length - visible_length);
if (field_max_length > MAX_COLUMN_LENGTH) if (opt_binhex && is_binary_field(field))
print_as_hex(PAGER, cur[off], lengths[off], field_max_length);
else if (field_max_length > MAX_COLUMN_LENGTH)
tee_print_sized_data(buffer, data_length, MAX_COLUMN_LENGTH+extra_padding, FALSE); tee_print_sized_data(buffer, data_length, MAX_COLUMN_LENGTH+extra_padding, FALSE);
else else
{ {
@ -3764,10 +3808,14 @@ print_table_data_html(MYSQL_RES *result)
if (interrupted_query) if (interrupted_query)
break; break;
ulong *lengths=mysql_fetch_lengths(result); ulong *lengths=mysql_fetch_lengths(result);
field= mysql_fetch_fields(result);
(void) tee_fputs("<TR>", PAGER); (void) tee_fputs("<TR>", PAGER);
for (uint i=0; i < mysql_num_fields(result); i++) for (uint i=0; i < mysql_num_fields(result); i++)
{ {
(void) tee_fputs("<TD>", PAGER); (void) tee_fputs("<TD>", PAGER);
if (opt_binhex && is_binary_field(&field[i]))
print_as_hex(PAGER, cur[i], lengths[i], lengths[i]);
else
xmlencode_print(cur[i], lengths[i]); xmlencode_print(cur[i], lengths[i]);
(void) tee_fputs("</TD>", PAGER); (void) tee_fputs("</TD>", PAGER);
} }
@ -3804,6 +3852,9 @@ print_table_data_xml(MYSQL_RES *result)
if (cur[i]) if (cur[i])
{ {
tee_fprintf(PAGER, "\">"); tee_fprintf(PAGER, "\">");
if (opt_binhex && is_binary_field(&fields[i]))
print_as_hex(PAGER, cur[i], lengths[i], lengths[i]);
else
xmlencode_print(cur[i], lengths[i]); xmlencode_print(cur[i], lengths[i]);
tee_fprintf(PAGER, "</field>\n"); tee_fprintf(PAGER, "</field>\n");
} }
@ -3851,14 +3902,20 @@ print_table_data_vertically(MYSQL_RES *result)
{ {
unsigned int i; unsigned int i;
const char *p; const char *p;
if (opt_binhex && is_binary_field(field))
fprintf(PAGER, "0x");
for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1) for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1)
{
if (opt_binhex && is_binary_field(field))
fprintf(PAGER, "%02X", *((uchar*)p));
else
{ {
if (*p == '\0') if (*p == '\0')
tee_putc((int)' ', PAGER); tee_putc((int)' ', PAGER);
else else
tee_putc((int)*p, PAGER); tee_putc((int)*p, PAGER);
} }
}
tee_putc('\n', PAGER); tee_putc('\n', PAGER);
} }
else else
@ -3867,7 +3924,6 @@ print_table_data_vertically(MYSQL_RES *result)
} }
} }
/* print_warnings should be called right after executing a statement */ /* print_warnings should be called right after executing a statement */
static void print_warnings() static void print_warnings()
@ -4004,10 +4060,18 @@ print_tab_data(MYSQL_RES *result)
while ((cur = mysql_fetch_row(result))) while ((cur = mysql_fetch_row(result)))
{ {
lengths=mysql_fetch_lengths(result); lengths=mysql_fetch_lengths(result);
field= mysql_fetch_fields(result);
if (opt_binhex && is_binary_field(&field[0]))
print_as_hex(PAGER, cur[0], lengths[0], lengths[0]);
else
safe_put_field(cur[0],lengths[0]); safe_put_field(cur[0],lengths[0]);
for (uint off=1 ; off < mysql_num_fields(result); off++) for (uint off=1 ; off < mysql_num_fields(result); off++)
{ {
(void) tee_fputs("\t", PAGER); (void) tee_fputs("\t", PAGER);
if (opt_binhex && field && is_binary_field(&field[off]))
print_as_hex(PAGER, cur[off], lengths[off], lengths[off]);
else
safe_put_field(cur[off], lengths[off]); safe_put_field(cur[off], lengths[off]);
} }
(void) tee_fputs("\n", PAGER); (void) tee_fputs("\n", PAGER);
@ -4801,10 +4865,11 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Protocol:\t\tCompressed\n"); tee_fprintf(stdout, "Protocol:\t\tCompressed\n");
#endif #endif
if ((status_str= mysql_stat(&mysql)) && !mysql_error(&mysql)[0]) const char *pos;
if ((status_str= mysql_stat(&mysql)) && !mysql_error(&mysql)[0] &&
(pos= strchr(status_str,' ')))
{ {
ulong sec; ulong sec;
const char *pos= strchr(status_str,' ');
/* print label */ /* print label */
tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status_str), status_str); tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status_str), status_str);
if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec))) if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec)))

View File

@ -1088,6 +1088,8 @@ int main(int argc, char **argv)
{ {
int fd= create_temp_file(cnf_file_path, opt_tmpdir[0] ? opt_tmpdir : NULL, int fd= create_temp_file(cnf_file_path, opt_tmpdir[0] ? opt_tmpdir : NULL,
"mysql_upgrade-", O_CREAT | O_WRONLY, MYF(MY_FAE)); "mysql_upgrade-", O_CREAT | O_WRONLY, MYF(MY_FAE));
if (fd < 0)
die(NULL);
my_write(fd, USTRING_WITH_LEN( "[client]\n"), MYF(MY_FAE)); my_write(fd, USTRING_WITH_LEN( "[client]\n"), MYF(MY_FAE));
my_write(fd, (uchar*)ds_args.str, ds_args.length, MYF(MY_FAE)); my_write(fd, (uchar*)ds_args.str, ds_args.length, MYF(MY_FAE));
my_close(fd, MYF(0)); my_close(fd, MYF(0));

View File

@ -92,8 +92,7 @@
static void add_load_option(DYNAMIC_STRING *str, const char *option, static void add_load_option(DYNAMIC_STRING *str, const char *option,
const char *option_value); const char *option_value);
static ulong find_set(TYPELIB *lib, const char *x, size_t length, static ulong find_set(TYPELIB *, const char *, size_t, char **, uint *);
char **err_pos, uint *err_len);
static char *alloc_query_str(ulong size); static char *alloc_query_str(ulong size);
static void field_escape(DYNAMIC_STRING* in, const char *from); static void field_escape(DYNAMIC_STRING* in, const char *from);
@ -5373,7 +5372,7 @@ static ulong find_set(TYPELIB *lib, const char *x, size_t length,
var_len= (uint) (pos - start); var_len= (uint) (pos - start);
strmake(buff, start, MY_MIN(sizeof(buff) - 1, var_len)); strmake(buff, start, MY_MIN(sizeof(buff) - 1, var_len));
find= find_type(buff, lib, FIND_TYPE_BASIC); find= find_type(buff, lib, FIND_TYPE_BASIC);
if (!find) if (find <= 0)
{ {
*err_pos= (char*) start; *err_pos= (char*) start;
*err_len= var_len; *err_len= var_len;

View File

@ -675,7 +675,7 @@ int main(int argc, char **argv)
MYF(0)))) MYF(0))))
return -2; return -2;
for (counter= 0; *argv != NULL; argv++) /* Loop through tables */ for (; *argv != NULL; argv++) /* Loop through tables */
{ {
pthread_mutex_lock(&counter_mutex); pthread_mutex_lock(&counter_mutex);
while (counter == opt_use_threads) while (counter == opt_use_threads)

View File

@ -600,7 +600,7 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query,
void str_to_file(const char *fname, char *str, int size); void str_to_file(const char *fname, char *str, int size);
void str_to_file2(const char *fname, char *str, int size, my_bool append); void str_to_file2(const char *fname, char *str, int size, my_bool append);
void fix_win_paths(const char *val, int len); void fix_win_paths(const char *val, size_t len);
const char *get_errname_from_code (uint error_code); const char *get_errname_from_code (uint error_code);
int multi_reg_replace(struct st_replace_regex* r,char* val); int multi_reg_replace(struct st_replace_regex* r,char* val);
@ -814,8 +814,7 @@ public:
LogFile log_file; LogFile log_file;
LogFile progress_file; LogFile progress_file;
void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, size_t len);
int len);
void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val); void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val); void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val);
void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input, void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input,
@ -1721,12 +1720,23 @@ void log_msg(const char *fmt, ...)
int cat_file(DYNAMIC_STRING* ds, const char* filename) int cat_file(DYNAMIC_STRING* ds, const char* filename)
{ {
int fd; int fd;
int len; size_t len;
char buff[16384]; char *buff;
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0) if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
return 1; return 1;
while((len= (int)my_read(fd, (uchar*)&buff, sizeof(buff)-1, MYF(0))) > 0)
len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0));
my_seek(fd, 0, SEEK_SET, MYF(0));
if (len == (size_t)MY_FILEPOS_ERROR ||
!(buff= (char*)my_malloc(len + 1, MYF(0))))
{
my_close(fd, MYF(0));
return 1;
}
len= my_read(fd, (uchar*)buff, len, MYF(0));
my_close(fd, MYF(0));
{ {
char *p= buff, *start= buff,*end=buff+len; char *p= buff, *start= buff,*end=buff+len;
while (p < end) while (p < end)
@ -1749,7 +1759,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
*p= 0; *p= 0;
replace_dynstr_append_mem(ds, start, p-start); replace_dynstr_append_mem(ds, start, p-start);
} }
my_close(fd, MYF(0)); my_free(buff);
return 0; return 0;
} }
@ -2643,6 +2653,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
if (!mysql) if (!mysql)
{ {
struct st_command command; struct st_command command;
DBUG_ASSERT(query_end);
memset(&command, 0, sizeof(command)); memset(&command, 0, sizeof(command));
command.query= (char*)query; command.query= (char*)query;
command.first_word_len= (*query_end - query); command.first_word_len= (*query_end - query);
@ -6551,6 +6562,16 @@ my_bool end_of_query(int c)
} }
static inline bool is_escape_char(char c, char in_string)
{
if (c != '\\' || in_string == '`') return false;
if (!cur_con) return true;
uint server_status= cur_con->mysql->server_status;
if (server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) return false;
return !(server_status & SERVER_STATUS_ANSI_QUOTES && in_string == '"');
}
/* /*
Read one "line" from the file Read one "line" from the file
@ -6577,7 +6598,7 @@ my_bool end_of_query(int c)
int read_line(char *buf, int size) int read_line(char *buf, int size)
{ {
char c, UNINIT_VAR(last_quote), last_char= 0; char c, last_quote=0, last_char= 0;
char *p= buf, *buf_end= buf + size - 1; char *p= buf, *buf_end= buf + size - 1;
int skip_char= 0; int skip_char= 0;
my_bool have_slash= FALSE; my_bool have_slash= FALSE;
@ -6659,7 +6680,7 @@ int read_line(char *buf, int size)
state= R_Q; state= R_Q;
} }
} }
have_slash= (c == '\\'); have_slash= is_escape_char(c, last_quote);
break; break;
case R_COMMENT: case R_COMMENT:
@ -6729,7 +6750,7 @@ int read_line(char *buf, int size)
case R_Q: case R_Q:
if (c == last_quote) if (c == last_quote)
state= R_NORMAL; state= R_NORMAL;
else if (c == '\\') else if (is_escape_char(c, last_quote))
state= R_SLASH_IN_Q; state= R_SLASH_IN_Q;
break; break;
@ -7509,7 +7530,7 @@ void free_win_path_patterns()
=> all \ from c:\mysql\m... until next space is converted into / => all \ from c:\mysql\m... until next space is converted into /
*/ */
void fix_win_paths(const char *val, int len) void fix_win_paths(const char *val, size_t len)
{ {
uint i; uint i;
char *p; char *p;
@ -11010,7 +11031,7 @@ void free_pointer_array(POINTER_ARRAY *pa)
/* Append the string to ds, with optional replace */ /* Append the string to ds, with optional replace */
void replace_dynstr_append_mem(DYNAMIC_STRING *ds, void replace_dynstr_append_mem(DYNAMIC_STRING *ds,
const char *val, int len) const char *val, size_t len)
{ {
char lower[512]; char lower[512];
#ifdef __WIN__ #ifdef __WIN__

View File

@ -26,7 +26,12 @@ SET(CPACK_COMPONENT_COMPAT_GROUP "compat")
SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts
SupportFiles Readme Test) SupportFiles Readme Test)
SET(CPACK_RPM_PACKAGE_NAME "MariaDB-Galera") SET(CPACK_RPM_PACKAGE_NAME "MariaDB-Galera")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}") IF(CMAKE_VERSION VERSION_LESS "3.6.0")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
ELSE()
SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
SET(CPACK_RPM_DEBUGINFO_PACKAGE ON)
ENDIF()
SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}") SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}")
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2") SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2")

View File

@ -1,4 +1,5 @@
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2009, 2012, Oracle and/or its affiliates.
# Copyright (c) 2011, 2017, MariaDB Corporation
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by

2
debian/compat vendored
View File

@ -1 +1 @@
5 9

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2001, 2013, Oracle and/or its affiliates. Copyright (c) 2001, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2013, Monty Program Ab. Copyright (c) 2009, 2017, MariaDB Corporation
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -439,9 +439,8 @@ extern "C" int madvise(void *addr, size_t len, int behav);
#define SIGNAL_HANDLER_RESET_ON_DELIVERY #define SIGNAL_HANDLER_RESET_ON_DELIVERY
#endif #endif
#ifndef STDERR_FILENO /* don't assume that STDERR_FILENO is 2, mysqld can freopen */
#define STDERR_FILENO fileno(stderr) #undef STDERR_FILENO
#endif
/* /*
Deprecated workaround for false-positive uninitialized variables Deprecated workaround for false-positive uninitialized variables

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. /* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2016, Monty Program Ab. Copyright (c) 2010, 2017, MariaDB Corporation
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by

View File

@ -329,6 +329,8 @@ enum enum_server_command
*/ */
#define SERVER_STATUS_IN_TRANS_READONLY 8192 #define SERVER_STATUS_IN_TRANS_READONLY 8192
#define SERVER_STATUS_ANSI_QUOTES 32768
/** /**
Server status flags that must be cleared when starting Server status flags that must be cleared when starting

View File

@ -31,4 +31,4 @@
#define VERSION_my_sha1 0x0100 #define VERSION_my_sha1 0x0100
#define VERSION_logger 0x0100 #define VERSION_logger 0x0100
#define VERSION_thd_autoinc 0x0100 #define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100 #define VERSION_thd_error_context 0x0200

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. /* Copyright (c) 2000, 2014, Oracle and/or its affiliates
Copyright (c) 2009, 2014, SkySQL Ab. Copyright (c) 2009, 2017, MariaDB Corporation
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -4927,4 +4927,3 @@ ulong STDCALL mysql_net_field_length(uchar **packet)
{ {
return net_field_length(packet); return net_field_length(packet);
} }

View File

@ -0,0 +1,8 @@
[16k]
innodb-page-size=16K
[8k]
innodb-page-size=8K
[4k]
innodb-page-size=4K

View File

@ -0,0 +1,4 @@
# The goal of including this file is to enable innodb_page_size combinations
# (see include/innodb_page_size.combinations)
--source include/have_innodb.inc

View File

@ -0,0 +1,8 @@
[16k]
innodb-page-size=16K
[8k]
innodb-page-size=8K
[4k]
innodb-page-size=4K

View File

@ -0,0 +1,4 @@
# The goal of including this file is to enable innodb_page_size combinations
# (see include/innodb_page_size.combinations)
--source include/have_innodb.inc

View File

@ -66,6 +66,13 @@ if (!$slave_skip_counter) {
} }
source include/start_slave.inc; source include/start_slave.inc;
# start_slave.inc returns when Slave_SQL_Running=Yes. But the slave
# thread sets it before clearing Last_SQL_Errno. So we have to wait
# for Last_SQL_Errno=0 separately.
let $slave_param= Last_SQL_Errno;
let $slave_param_value= 0;
source include/wait_for_slave_param.inc;
--let $include_filename= wait_for_slave_sql_error_and_skip.inc [errno=$slave_sql_errno] --let $include_filename= wait_for_slave_sql_error_and_skip.inc [errno=$slave_sql_errno]
--source include/end_include_file.inc --source include/end_include_file.inc

View File

@ -2,7 +2,7 @@
# -*- cperl -*- # -*- cperl -*-
# Copyright (c) 2004, 2014, Oracle and/or its affiliates. # Copyright (c) 2004, 2014, Oracle and/or its affiliates.
# Copyright (c) 2009, 2014, Monty Program Ab # Copyright (c) 2009, 2017, MariaDB Corporation
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -1296,10 +1296,6 @@ sub command_line_setup {
fix_vs_config_dir(); fix_vs_config_dir();
# Respect MTR_BINDIR variable, which is typically set in to the
# build directory in out-of-source builds.
$bindir=$ENV{MTR_BINDIR}||$basedir;
# Look for the client binaries directory # Look for the client binaries directory
if ($path_client_bindir) if ($path_client_bindir)
{ {
@ -3222,10 +3218,20 @@ sub mysql_server_start($) {
} }
my $mysqld_basedir= $mysqld->value('basedir'); my $mysqld_basedir= $mysqld->value('basedir');
my $extra_opts= get_extra_opts($mysqld, $tinfo);
if ( $basedir eq $mysqld_basedir ) if ( $basedir eq $mysqld_basedir )
{ {
if (! $opt_start_dirty) # If dirty, keep possibly grown system db if (! $opt_start_dirty) # If dirty, keep possibly grown system db
{ {
# Some InnoDB options are incompatible with the default bootstrap.
# If they are used, re-bootstrap
if ( $extra_opts and
"@$extra_opts" =~ /--innodb[-_](?:page[-_]size|checksum[-_]algorithm|undo[-_]tablespaces|log[-_]group[-_]home[-_]dir|data[-_]home[-_]dir)/ )
{
mysql_install_db($mysqld, undef, $extra_opts);
}
else {
# Copy datadir from installed system db # Copy datadir from installed system db
my $path= ($opt_parallel == 1) ? "$opt_vardir" : "$opt_vardir/.."; my $path= ($opt_parallel == 1) ? "$opt_vardir" : "$opt_vardir/..";
my $install_db= "$path/install.db"; my $install_db= "$path/install.db";
@ -3233,6 +3239,7 @@ sub mysql_server_start($) {
mtr_error("Failed to copy system db to '$datadir'") unless -d $datadir; mtr_error("Failed to copy system db to '$datadir'") unless -d $datadir;
} }
} }
}
else else
{ {
mysql_install_db($mysqld); # For versional testing mysql_install_db($mysqld); # For versional testing
@ -3269,7 +3276,6 @@ sub mysql_server_start($) {
if (!$opt_embedded_server) if (!$opt_embedded_server)
{ {
my $extra_opts= get_extra_opts($mysqld, $tinfo);
mysqld_start($mysqld,$extra_opts); mysqld_start($mysqld,$extra_opts);
# Save this test case information, so next can examine it # Save this test case information, so next can examine it
@ -3493,7 +3499,7 @@ sub default_mysqld {
sub mysql_install_db { sub mysql_install_db {
my ($mysqld, $datadir)= @_; my ($mysqld, $datadir, $extra_opts)= @_;
my $install_datadir= $datadir || $mysqld->value('datadir'); my $install_datadir= $datadir || $mysqld->value('datadir');
my $install_basedir= $mysqld->value('basedir'); my $install_basedir= $mysqld->value('basedir');
@ -3534,6 +3540,13 @@ sub mysql_install_db {
mtr_add_arg($args, $extra_opt); mtr_add_arg($args, $extra_opt);
} }
} }
# InnoDB options can come not only from the command line, but also
# from option files or combinations
foreach my $extra_opt ( @$extra_opts ) {
if ($extra_opt =~ /--innodb/) {
mtr_add_arg($args, $extra_opt);
}
}
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g., # If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
# configure --disable-grant-options), mysqld will not recognize the # configure --disable-grant-options), mysqld will not recognize the

View File

@ -73,3 +73,114 @@ drop table t1;
create table t1 (a int) partition by hash(a) partitions 2; create table t1 (a int) partition by hash(a) partitions 2;
alter online table t1 modify a int comment 'test'; alter online table t1 modify a int comment 'test';
drop table t1; drop table t1;
#
# MDEV-8948 ALTER ... INPLACE does work for BINARY, BLOB
#
CREATE TABLE t1 (a BINARY(10));
ALTER TABLE t1 MODIFY a BINARY(10), ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a VARBINARY(10));
ALTER TABLE t1 MODIFY a VARBINARY(10), ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a TINYBLOB);
ALTER TABLE t1 MODIFY a TINYBLOB, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMBLOB);
ALTER TABLE t1 MODIFY a MEDIUMBLOB, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a BLOB);
ALTER TABLE t1 MODIFY a BLOB, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a LONGBLOB);
ALTER TABLE t1 MODIFY a LONGBLOB, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(10));
ALTER TABLE t1 MODIFY a CHAR(10), ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10));
ALTER TABLE t1 MODIFY a VARCHAR(10), ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a TINYTEXT);
ALTER TABLE t1 MODIFY a TINYTEXT, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMTEXT);
ALTER TABLE t1 MODIFY a MEDIUMTEXT, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a TEXT);
ALTER TABLE t1 MODIFY a TEXT, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a LONGTEXT);
ALTER TABLE t1 MODIFY a LONGTEXT, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(10));
ALTER TABLE t1 MODIFY a CHAR(10) COLLATE latin1_bin, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10));
ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE latin1_bin, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a TINYTEXT);
ALTER TABLE t1 MODIFY a TINYTEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMTEXT);
ALTER TABLE t1 MODIFY a MEDIUMTEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a TEXT);
ALTER TABLE t1 MODIFY a TEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a LONGTEXT);
ALTER TABLE t1 MODIFY a LONGTEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(10) COLLATE latin1_bin);
ALTER TABLE t1 MODIFY a CHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10) COLLATE latin1_bin);
ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a TINYTEXT COLLATE latin1_bin);
ALTER TABLE t1 MODIFY a TINYTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMTEXT COLLATE latin1_bin);
ALTER TABLE t1 MODIFY a MEDIUMTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a TEXT COLLATE latin1_bin);
ALTER TABLE t1 MODIFY a TEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a LONGTEXT COLLATE latin1_bin);
ALTER TABLE t1 MODIFY a LONGTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(10) COLLATE latin1_general_ci);
ALTER TABLE t1 MODIFY a CHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10) COLLATE latin1_general_ci);
ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a TINYTEXT COLLATE latin1_general_ci);
ALTER TABLE t1 MODIFY a TINYTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMTEXT COLLATE latin1_general_ci);
ALTER TABLE t1 MODIFY a MEDIUMTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a TEXT COLLATE latin1_general_ci);
ALTER TABLE t1 MODIFY a TEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a LONGTEXT COLLATE latin1_general_ci);
ALTER TABLE t1 MODIFY a LONGTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;

View File

@ -0,0 +1,117 @@
USE test;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (c1 TINYBLOB,
c2 BLOB,
c3 MEDIUMBLOB,
c4 LONGBLOB,
c5 TEXT,
c6 BIT(1),
c7 CHAR,
c8 VARCHAR(10),
c9 GEOMETRY) CHARACTER SET = binary;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` tinyblob,
`c2` blob,
`c3` mediumblob,
`c4` longblob,
`c5` blob,
`c6` bit(1) DEFAULT NULL,
`c7` binary(1) DEFAULT NULL,
`c8` varbinary(10) DEFAULT NULL,
`c9` geometry DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=binary
INSERT INTO t1 VALUES ('tinyblob-text readable', 'blob-text readable',
'mediumblob-text readable', 'longblob-text readable',
'text readable', b'1', 'c', 'variable',
POINT(1, 1));
CREATE TABLE t2(id int, `col1` binary(10),`col2` blob);
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL,
`col1` binary(10) DEFAULT NULL,
`col2` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t2 VALUES (1, X'AB1234', X'123ABC'), (2, X'DE1234', X'123DEF');
#Print the table contents when binary-as-hex option is off.
SELECT * FROM t1;
c1 c2 c3 c4 c5 c6 c7 c8 c9
tinyblob-text readable blob-text readable mediumblob-text readable longblob-text readable text readable # c variable #
SELECT * FROM t2;
id col1 col2
1 # #
2 # #
#Print the table contents after turning on the binary-as-hex option
#Print the table contents in tab format
c1 c2 c3 c4 c5 c6 c7 c8 c9
0x74696E79626C6F622D74657874207265616461626C65 0x626C6F622D74657874207265616461626C65 0x6D656469756D626C6F622D74657874207265616461626C65 0x6C6F6E67626C6F622D74657874207265616461626C65 0x74657874207265616461626C65 0x01 0x63 0x7661726961626C65 0x000000000101000000000000000000F03F000000000000F03F
id col1 col2
1 0xAB123400000000000000 0x123ABC
2 0xDE123400000000000000 0x123DEF
#Print the table contents in table format
+------------------------------------------------+----------------------------------------+----------------------------------------------------+------------------------------------------------+------------------------------+------------+------------+--------------------+------------------------------------------------------+
| c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 |
+------------------------------------------------+----------------------------------------+----------------------------------------------------+------------------------------------------------+------------------------------+------------+------------+--------------------+------------------------------------------------------+
| 0x74696E79626C6F622D74657874207265616461626C65 | 0x626C6F622D74657874207265616461626C65 | 0x6D656469756D626C6F622D74657874207265616461626C65 | 0x6C6F6E67626C6F622D74657874207265616461626C65 | 0x74657874207265616461626C65 | 0x01 | 0x63 | 0x7661726961626C65 | 0x000000000101000000000000000000F03F000000000000F03F |
+------------------------------------------------+----------------------------------------+----------------------------------------------------+------------------------------------------------+------------------------------+------------+------------+--------------------+------------------------------------------------------+
+------+------------------------+------------+
| id | col1 | col2 |
+------+------------------------+------------+
| 1 | 0xAB123400000000000000 | 0x123ABC |
+------+------------------------+------------+
#Print the table contents vertically
*************************** 1. row ***************************
c1: 0x74696E79626C6F622D74657874207265616461626C65
c2: 0x626C6F622D74657874207265616461626C65
c3: 0x6D656469756D626C6F622D74657874207265616461626C65
c4: 0x6C6F6E67626C6F622D74657874207265616461626C65
c5: 0x74657874207265616461626C65
c6: 0x01
c7: 0x63
c8: 0x7661726961626C65
c9: 0x000000000101000000000000000000F03F000000000000F03F
#Print the table contents in xml format
<?xml version="1.0"?>
<resultset statement="SELECT * FROM t1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="c1">0x74696E79626C6F622D74657874207265616461626C65</field>
<field name="c2">0x626C6F622D74657874207265616461626C65</field>
<field name="c3">0x6D656469756D626C6F622D74657874207265616461626C65</field>
<field name="c4">0x6C6F6E67626C6F622D74657874207265616461626C65</field>
<field name="c5">0x74657874207265616461626C65</field>
<field name="c6">0x01</field>
<field name="c7">0x63</field>
<field name="c8">0x7661726961626C65</field>
<field name="c9">0x000000000101000000000000000000F03F000000000000F03F</field>
</row>
</resultset>
<?xml version="1.0"?>
<resultset statement="SELECT * FROM t2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="id">1</field>
<field name="col1">0xAB123400000000000000</field>
<field name="col2">0x123ABC</field>
</row>
<row>
<field name="id">2</field>
<field name="col1">0xDE123400000000000000</field>
<field name="col2">0x123DEF</field>
</row>
</resultset>
#Print the table contents in html format
<TABLE BORDER=1><TR><TH>c1</TH><TH>c2</TH><TH>c3</TH><TH>c4</TH><TH>c5</TH><TH>c6</TH><TH>c7</TH><TH>c8</TH><TH>c9</TH></TR><TR><TD>0x74696E79626C6F622D74657874207265616461626C65</TD><TD>0x626C6F622D74657874207265616461626C65</TD><TD>0x6D656469756D626C6F622D74657874207265616461626C65</TD><TD>0x6C6F6E67626C6F622D74657874207265616461626C65</TD><TD>0x74657874207265616461626C65</TD><TD>0x01</TD><TD>0x63</TD><TD>0x7661726961626C65</TD><TD>0x000000000101000000000000000000F03F000000000000F03F</TD></TR></TABLE><TABLE BORDER=1><TR><TH>id</TH><TH>col1</TH><TH>col2</TH></TR><TR><TD>1</TD><TD>0xAB123400000000000000</TD><TD>0x123ABC</TD></TR><TR><TD>2</TD><TD>0xDE123400000000000000</TD><TD>0x123DEF</TD></TR></TABLE>DROP TABLE t1, t2;

View File

@ -2,9 +2,11 @@ SHOW CONTRIBUTORS;
Name Location Comment Name Location Comment
Booking.com https://www.booking.com Founding member, Platinum Sponsor of the MariaDB Foundation Booking.com https://www.booking.com Founding member, Platinum Sponsor of the MariaDB Foundation
Alibaba Cloud https://intl.aliyun.com Platinum Sponsor of the MariaDB Foundation Alibaba Cloud https://intl.aliyun.com Platinum Sponsor of the MariaDB Foundation
Tencent Cloud https://cloud.tencent.com Platinum Sponsor of the MariaDB Foundation
MariaDB Corporation https://mariadb.com Founding member, Gold Sponsor of the MariaDB Foundation MariaDB Corporation https://mariadb.com Founding member, Gold Sponsor of the MariaDB Foundation
Visma https://visma.com Gold Sponsor of the MariaDB Foundation Visma https://visma.com Gold Sponsor of the MariaDB Foundation
DBS https://dbs.com Gold Sponsor of the MariaDB Foundation DBS https://dbs.com Gold Sponsor of the MariaDB Foundation
IBM https://www.ibm.com Gold Sponsor of the MariaDB Foundation
Nexedi https://www.nexedi.com Silver Sponsor of the MariaDB Foundation Nexedi https://www.nexedi.com Silver Sponsor of the MariaDB Foundation
Acronis http://www.acronis.com Silver Sponsor of the MariaDB Foundation Acronis http://www.acronis.com Silver Sponsor of the MariaDB Foundation
Auttomattic https://automattic.com Bronze Sponsor of the MariaDB Foundation Auttomattic https://automattic.com Bronze Sponsor of the MariaDB Foundation

View File

@ -94,3 +94,15 @@ count(distinct i)
2 2
drop table t1; drop table t1;
drop view v1; drop view v1;
create table t1 (user_id char(64) character set utf8);
insert t1 values(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17);
set @@tmp_table_size = 1024;
select count(distinct user_id) from t1;
count(distinct user_id)
17
alter table t1 modify user_id char(128) character set utf8;
select count(distinct user_id) from t1;
count(distinct user_id)
17
drop table t1;
set @@tmp_table_size = default;

View File

@ -5552,5 +5552,22 @@ SELECT 'a','aa';
a aa a aa
a aa a aa
# #
# MDEV-10306 Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery
#
SET NAMES utf8, character_set_connection=ucs2;
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_utf8'derived_merge=on';
CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
INSERT INTO t1 VALUES('abcdefghi');
SET NAMES utf8, character_set_connection=ucs2;
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT HEX(t) t2 FROM t1) sub;
c2
616263646566676869-616263646566676869
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT TO_BASE64(t) t2 FROM t1) sub;
c2
YWJjZGVmZ2hp-YWJjZGVmZ2hp
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests # End of 10.0 tests
# #

View File

@ -0,0 +1,6 @@
create table t1 (a int, b int);
set debug_dbug='+d,external_lock_failure';
alter table t1 add column c int;
ERROR HY000: Got error 168 'KABOOM!' from MyISAM
set debug_dbug='';
drop table t1;

View File

@ -149,3 +149,116 @@ CALL p1();
########################################40100.000 ########################################40100.000
DROP PROCEDURE p1; DROP PROCEDURE p1;
# End of 5.1 tests # End of 5.1 tests
#
# Start of 10.0 tests
#
#
# MDEV-10306 Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='derived_merge=on';
CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
INSERT INTO t1 VALUES('1234567');
SELECT CONCAT(SUBSTR(t2, 1, 3), SUBSTR(t2, 5)) c1,
CONCAT(SUBSTR(t2,1,3),'---',SUBSTR(t2,5)) c2
FROM (SELECT CONVERT(t USING latin1) t2 FROM t1) sub;
c1 c2
123567 123---567
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT CONVERT(t USING latin1) t2 FROM t1) sub;
c2
1234567-1234567
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
INSERT INTO t1 VALUES('1234567');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT CONVERT(t USING latin1) t2 FROM t1) sub;
c2
1234567-1234567
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT REVERSE(t) t2 FROM t1) sub;
c2
7654321-7654321
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT SOUNDEX(t) t2 FROM t1) sub;
c2
-
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT TO_BASE64(t) t2 FROM t1) sub;
c2
MTIzNDU2Nw==-MTIzNDU2Nw==
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT WEIGHT_STRING(t) t2 FROM t1) sub;
c2
1234567-1234567
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT HEX(t) t2 FROM t1) sub;
c2
31323334353637-31323334353637
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT QUOTE(t) t2 FROM t1) sub;
c2
'1234567'-'1234567'
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(32) CHARSET latin1);
INSERT INTO t1 VALUES(TO_BASE64('abcdefghi'));
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT FROM_BASE64(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(32) CHARSET latin1);
INSERT INTO t1 VALUES(HEX('abcdefghi'));
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UNHEX(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(30) CHARSET latin1);
INSERT INTO t1 VALUES('test');
SELECT LENGTH(CONCAT(t2)) c2 FROM (SELECT AES_ENCRYPT(t,'x') t2 FROM t1) sub;
c2
16
SELECT LENGTH(CONCAT(t2,'-',t2)) c2 FROM (SELECT AES_ENCRYPT(t,'x') t2 FROM t1) sub;
c2
33
SELECT LENGTH(CONCAT(t2,'--',t2)) c2 FROM (SELECT AES_ENCRYPT(t,'x') t2 FROM t1) sub;
c2
34
SELECT LENGTH(CONCAT(t2)) c2 FROM (SELECT AES_DECRYPT(AES_ENCRYPT(t,'x'),'x') t2 FROM t1) sub;
c2
4
SELECT LENGTH(CONCAT(t2,'-',t2)) c2 FROM (SELECT AES_DECRYPT(AES_ENCRYPT(t,'x'),'x') t2 FROM t1) sub;
c2
9
SELECT LENGTH(CONCAT(t2,'--',t2)) c2 FROM (SELECT AES_DECRYPT(AES_ENCRYPT(t,'x'),'x') t2 FROM t1) sub;
c2
10
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(64) CHARSET latin1);
INSERT INTO t1 VALUES('123456789');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT MD5(t) t2 FROM t1) sub;
c2
25f9e794323b453885f5181f1b624d0b-25f9e794323b453885f5181f1b624d0b
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT FORMAT(t,2) t2 FROM t1) sub;
c2
123,456,789.00-123,456,789.00
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(32) CHARSET latin1);
INSERT INTO t1 VALUES('abcdefghi');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT INSERT(t,3,4,'xxx') t2 FROM t1) sub;
c2
abxxxghi-abxxxghi
DROP TABLE t1;
CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
INSERT INTO t1 VALUES('abcdefghi');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LEFT(t,10) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT RIGHT(t,10) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT SUBSTR(t,1,10) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LTRIM(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT RTRIM(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT TRIM(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;

View File

@ -106,3 +106,21 @@ OLD_PASSWORD(c1) PASSWORD(c1)
77023ffe214c04ff *82E58A2C08AAFE72C8EB523069CD8ADB33F78F58 77023ffe214c04ff *82E58A2C08AAFE72C8EB523069CD8ADB33F78F58
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
#
# Start of 10.0 tests
#
#
# MDEV-10306 Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='derived_merge=on';
CREATE TABLE t1 (t VARCHAR(32) CHARSET latin1);
INSERT INTO t1 VALUES('abcdefghi');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT ENCRYPT(t,'aa') t2 FROM t1) sub;
c2
aaHHlPHAM4sjs-aaHHlPHAM4sjs
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -879,3 +879,35 @@ SELECT 1 FROM dual WHERE ('Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,StrataCentral,
CAST(0xE001 AS BINARY) REGEXP @regCheck CAST(0xE001 AS BINARY) REGEXP @regCheck
1 1
# MDEV-12420: Testing recursion overflow # MDEV-12420: Testing recursion overflow
SELECT 1 FROM dual WHERE ('Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,StrataCentral,Golf,Hotel,India,Juliet,Kilo,Lima,Mike,StrataL3,November,Oscar,StrataL2,Sand,P3,P4SwitchTest,Arsys,Poppa,ExtensionMgr,Arp,Quebec,Romeo,StrataApiV2,PtReyes,Sierra,SandAcl,Arrow,Artools,BridgeTest,Tango,SandT,PAlaska,Namespace,Agent,Qos,PatchPanel,ProjectReport,Ark,Gimp,Agent,SliceAgent,Arnet,Bgp,Ale,Tommy,Central,AsicPktTestLib,Hsc,SandL3,Abuild,Pca9555,Standby,ControllerDut,CalSys,SandLib,Sb820,PointV2,BfnLib,Evpn,BfnSdk,Sflow,ManagementActive,AutoTest,GatedTest,Bgp,Sand,xinetd,BfnAgentLib,bf-utils,Hello,BfnState,Eos,Artest,Qos,Scd,ThermoMgr,Uniform,EosUtils,Eb,FanController,Central,BfnL3,BfnL2,tcp_wrappers,Victor,Environment,Route,Failover,Whiskey,Xray,Gimp,BfnFixed,Strata,SoCal,XApi,Msrp,XpProfile,tcpdump,PatchPanel,ArosTest,FhTest,Arbus,XpAcl,MacConc,XpApi,telnet,QosTest,Alpha2,BfnVlan,Stp,VxlanControllerTest,MplsAgent,Bravo2,Lanz,BfnMbb,Intf,XCtrl,Unicast,SandTunnel,L3Unicast,Ipsec,MplsTest,Rsvp,EthIntf,StageMgr,Sol,MplsUtils,Nat,Ira,P4NamespaceDut,Counters,Charlie2,Aqlc,Mlag,Power,OpenFlow,Lag,RestApi,BfdTest,strongs,Sfa,CEosUtils,Adt746,MaintenanceMode,MlagDut,EosImage,IpEth,MultiProtocol,Launcher,Max3179,Snmp,Acl,IpEthTest,PhyEee,bf-syslibs,tacc,XpL2,p4-ar-switch,p4-bf-switch,LdpTest,BfnPhy,Mirroring,Phy6,Ptp' REGEXP '^((?!\b(Strata|StrataApi|StrataApiV2)\b).)*$');
1
Warnings:
Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp
SELECT CONCAT(REPEAT('100,',400),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$';
CONCAT(REPEAT('100,',400),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$'
1
SELECT CONCAT(REPEAT('100,',600),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$';
CONCAT(REPEAT('100,',600),'101') RLIKE '^(([1-9][0-9]*),)*[1-9][0-9]*$'
0
Warnings:
Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp
SELECT REGEXP_INSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$');
REGEXP_INSTR(CONCAT(REPEAT('100,',400),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')
1
SELECT REGEXP_INSTR(CONCAT(REPEAT('100,',600),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$');
REGEXP_INSTR(CONCAT(REPEAT('100,',600),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$')
0
Warnings:
Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp
SELECT LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',400/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'));
LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',400/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'))
535
SELECT LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',600/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'));
LENGTH(REGEXP_SUBSTR(CONCAT(REPEAT('100,',600/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$'))
0
Warnings:
Warning 1139 Got error 'pcre_exec: recursion limit of NUM exceeded' from regexp
SELECT LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',400/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', ''));
LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',400/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', ''))
0
SELECT LENGTH(REGEXP_REPLACE(CONCAT(REPEAT('100,',600/3),'101'), '^(([1-9][0-9]*),)*[1-9][0-9]*$', ''));

View File

@ -0,0 +1,51 @@
#
# Start of 10.1 tests
#
#
# MDEV-8948 ALTER ... INPLACE does work for BINARY, BLOB
#
CREATE TABLE t1 (a TINYBLOB);
ALTER TABLE t1 MODIFY a GEOMETRY, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMBLOB);
ALTER TABLE t1 MODIFY a GEOMETRY, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a BLOB);
ALTER TABLE t1 MODIFY a GEOMETRY, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a LONGBLOB);
ALTER TABLE t1 MODIFY a GEOMETRY, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a GEOMETRY);
ALTER TABLE t1 MODIFY a TINYBLOB, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a GEOMETRY);
ALTER TABLE t1 MODIFY a MEDIUMBLOB, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a GEOMETRY);
ALTER TABLE t1 MODIFY a BLOB, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a GEOMETRY);
ALTER TABLE t1 MODIFY a LONGBLOB, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a GEOMETRY);
ALTER TABLE t1 MODIFY a POLYGON, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1;
CREATE TABLE t1 (a POLYGON);
ALTER TABLE t1 MODIFY a GEOMETRY, ALGORITHM=INPLACE;
DROP TABLE t1;
CREATE TABLE t1 (a POLYGON);
ALTER TABLE t1 MODIFY a POLYGON, ALGORITHM=INPLACE;
DROP TABLE t1;
#
# End of 10.1 tests
#

View File

@ -60,3 +60,25 @@ fid AsText(g)
45 LINESTRING(51 51,60 60) 45 LINESTRING(51 51,60 60)
DROP TABLE t1; DROP TABLE t1;
End of 5.5 tests. End of 5.5 tests.
CREATE TABLE t1 (
coordinate point NOT NULL,
SPATIAL KEY coordinate (coordinate)
) ENGINE=Aria DEFAULT CHARSET=ascii PAGE_CHECKSUM=1;
SHOW COLUMNS FROM t1;
Field Type Null Key Default Extra
coordinate point NO MUL NULL
INSERT INTO t1 (coordinate) VALUES(ST_PointFromText("POINT(0 0)"));
INSERT INTO t1 (coordinate) VALUES(ST_PointFromText("POINT(10 0)"));
INSERT INTO t1 (coordinate) VALUES(ST_PointFromText("POINT(10 10)"));
INSERT INTO t1 (coordinate) VALUES(ST_PointFromText("POINT(0 10)"));
INSERT INTO t1 (coordinate) VALUES(ST_PointFromText("POINT(5 5)"));
SELECT astext(coordinate) FROM t1 WHERE ST_Intersects(ST_LineFromText("LINESTRING(0 0, 10 0, 10 10, 0 10)"), coordinate);
astext(coordinate)
POINT(0 0)
POINT(10 0)
POINT(10 10)
POINT(0 10)
SHOW COLUMNS FROM t1;
Field Type Null Key Default Extra
coordinate point NO MUL NULL
DROP TABLE t1;

View File

@ -333,8 +333,8 @@ fid IsClosed(g)
116 0 116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon; SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g)) fid AsText(Centroid(g))
117 POINT(55.58852775304245 17.426536064113982) 117 POINT(57.98031067576927 17.854754130800433)
118 POINT(55.58852775304245 17.426536064113982) 118 POINT(57.98031067576927 17.854754130800433)
119 POINT(2 2) 119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon; SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g) fid Area(g)
@ -684,11 +684,11 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998; t1 where object_id=85998;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo)) object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
85998 MULTIPOLYGON 1 POINT(115.31877315203187 -36.23747282102153) 85998 MULTIPOLYGON 1 POINT(115.2970604672862 -36.23335610879993)
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85984; t1 where object_id=85984;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo)) object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
85984 MULTIPOLYGON 1 POINT(-114.87787186923313 36.33101763469059) 85984 MULTIPOLYGON 1 POINT(-114.86854472054372 36.34725218253213)
drop table t1; drop table t1;
create table t1 (fl geometry not null); create table t1 (fl geometry not null);
insert into t1 values (1); insert into t1 values (1);
@ -1641,5 +1641,23 @@ AsText(g)
NULL NULL
POINT(1 1) POINT(1 1)
# #
# MDEV-10306 Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='derived_merge=on';
CREATE TABLE t1 (x INT, y INT);
INSERT INTO t1 VALUES(0,0);
SELECT LENGTH(t2) c2 FROM (SELECT ST_BUFFER(POINT(x,y), 0) t2 FROM t1) sub;
c2
25
SELECT LENGTH(CONCAT(t2,'-',t2)) c2 FROM (SELECT ST_BUFFER(POINT(x,y), 0) t2 FROM t1) sub;
c2
51
SELECT LENGTH(CONCAT(t2,'--',t2)) c2 FROM (SELECT ST_BUFFER(POINT(x,y), 0) t2 FROM t1) sub;
c2
52
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End 10.0 tests # End 10.0 tests
# #

View File

@ -2531,6 +2531,33 @@ select a from t1 group by a having a > 1;
a a
drop table t1; drop table t1;
set sql_mode= @save_sql_mode; set sql_mode= @save_sql_mode;
create table t1 (f1 int);
insert into t1 values (5),(9);
create table t2 (f2 int);
insert into t2 values (0),(6);
create table t3 (f3 int);
insert into t3 values (6),(3);
create table t4 (f4 int);
insert into t4 values (1),(0);
select
(select min(f1) from t1 where f1 in (select min(f4) from t2)) as field7,
(select count(*) from t3 where f3 in (select max(f4) from t2 group by field7))
from t4;
ERROR 42S22: Reference 'field7' not supported (reference to group function)
drop table t1, t2, t3, t4;
create table t1 (i1 int);
insert into t1 values (1);
create table t2 (i int);
insert into t2 values (2);
select 1 from t1 left join t2 b on b.i = (select max(b.i) from t2);
1
1
drop table t1, t2;
create table t1 (c1 int, c2 int);
create table t2 (c1 int, c2 int);
select t1.c1 as c1, t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 group by t1.c1, t2.c2 having t1.c1 < 3;
c1 c1
drop table t1, t2;
# #
# Bug #58782 # Bug #58782
# Missing rows with SELECT .. WHERE .. IN subquery # Missing rows with SELECT .. WHERE .. IN subquery

View File

@ -2248,4 +2248,99 @@ SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a
WHERE b IN (1,2,3) OR b = d; WHERE b IN (1,2,3) OR b = d;
a b c d a b c d
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
#
# MDEV-11958: LEFT JOIN with stored routine produces incorrect result
#
CREATE TABLE t (x INT);
INSERT INTO t VALUES(1),(NULL);
CREATE FUNCTION f (val INT, ret INT) RETURNS INT DETERMINISTIC RETURN IFNULL(val, ret);
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE IFNULL(t2.x,0)=0;
x x IFNULL(t2.x,0) f(t2.x,0)
NULL NULL 0 0
explain extended
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE IFNULL(t2.x,0)=0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (ifnull(`test`.`t2`.`x`,0) = 0)
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE f(t2.x,0)=0;
x x IFNULL(t2.x,0) f(t2.x,0)
NULL NULL 0 0
explain extended
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE f(t2.x,0)=0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (`f`(`test`.`t2`.`x`,0) = 0)
drop function f;
drop table t;
CREATE TABLE t1 (
col1 DECIMAL(33,5) NULL DEFAULT NULL,
col2 DECIMAL(33,5) NULL DEFAULT NULL
);
CREATE TABLE t2 (
col1 DECIMAL(33,5) NULL DEFAULT NULL,
col2 DECIMAL(33,5) NULL DEFAULT NULL,
col3 DECIMAL(33,5) NULL DEFAULT NULL
);
INSERT INTO t1 VALUES (2, 1.1), (2, 2.1);
INSERT INTO t2 VALUES (3, 3.1, 4), (1, 1, NULL);
CREATE FUNCTION f1 ( p_num DECIMAL(45,15), p_return DECIMAL(45,15))
RETURNS decimal(33,5)
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY INVOKER
BEGIN
IF p_num IS NULL THEN
RETURN p_return;
ELSE
RETURN p_num;
END IF;
END |
SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE IFNULL(t2.col3,0) = 0;
col1 col1 col3
2.00000 NULL NULL
2.00000 NULL NULL
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE IFNULL(t2.col3,0) = 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (ifnull(`test`.`t2`.`col3`,0) = 0)
SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE f1(t2.col3,0) = 0;
col1 col1 col3
2.00000 NULL NULL
2.00000 NULL NULL
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE f1(t2.col3,0) = 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (`f1`(`test`.`t2`.`col3`,0) = 0)
DROP FUNCTION f1;
DROP TABLE t1,t2;
# end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;

View File

@ -2259,6 +2259,101 @@ SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a
WHERE b IN (1,2,3) OR b = d; WHERE b IN (1,2,3) OR b = d;
a b c d a b c d
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
#
# MDEV-11958: LEFT JOIN with stored routine produces incorrect result
#
CREATE TABLE t (x INT);
INSERT INTO t VALUES(1),(NULL);
CREATE FUNCTION f (val INT, ret INT) RETURNS INT DETERMINISTIC RETURN IFNULL(val, ret);
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE IFNULL(t2.x,0)=0;
x x IFNULL(t2.x,0) f(t2.x,0)
NULL NULL 0 0
explain extended
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE IFNULL(t2.x,0)=0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (ifnull(`test`.`t2`.`x`,0) = 0)
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE f(t2.x,0)=0;
x x IFNULL(t2.x,0) f(t2.x,0)
NULL NULL 0 0
explain extended
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
FROM t t1 LEFT JOIN t t2
ON t1.x = t2.x
WHERE f(t2.x,0)=0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (`f`(`test`.`t2`.`x`,0) = 0)
drop function f;
drop table t;
CREATE TABLE t1 (
col1 DECIMAL(33,5) NULL DEFAULT NULL,
col2 DECIMAL(33,5) NULL DEFAULT NULL
);
CREATE TABLE t2 (
col1 DECIMAL(33,5) NULL DEFAULT NULL,
col2 DECIMAL(33,5) NULL DEFAULT NULL,
col3 DECIMAL(33,5) NULL DEFAULT NULL
);
INSERT INTO t1 VALUES (2, 1.1), (2, 2.1);
INSERT INTO t2 VALUES (3, 3.1, 4), (1, 1, NULL);
CREATE FUNCTION f1 ( p_num DECIMAL(45,15), p_return DECIMAL(45,15))
RETURNS decimal(33,5)
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY INVOKER
BEGIN
IF p_num IS NULL THEN
RETURN p_return;
ELSE
RETURN p_num;
END IF;
END |
SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE IFNULL(t2.col3,0) = 0;
col1 col1 col3
2.00000 NULL NULL
2.00000 NULL NULL
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE IFNULL(t2.col3,0) = 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (ifnull(`test`.`t2`.`col3`,0) = 0)
SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE f1(t2.col3,0) = 0;
col1 col1 col3
2.00000 NULL NULL
2.00000 NULL NULL
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
WHERE f1(t2.col3,0) = 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (`f1`(`test`.`t2`.`col3`,0) = 0)
DROP FUNCTION f1;
DROP TABLE t1,t2;
# end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default; set join_cache_level=default;
show variables like 'join_cache_level'; show variables like 'join_cache_level';

View File

@ -81,17 +81,17 @@ LOAD XML INFILE '../../std_data/loadxml.dat' INTO TABLE t1
ROWS IDENTIFIED BY '<row>' (a,@b) SET b=concat('!',@b); ROWS IDENTIFIED BY '<row>' (a,@b) SET b=concat('!',@b);
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a b a b
1 !b1 1 ! b1
11 !b11 11 ! b11
111 !b111 111 !b111
112 !b112 & < > " ' &unknown; -- check entities 112 !b112 & < > " ' &unknown; -- check entities
2 !b2 2 ! b2
212 !b212 212 !b212
213 !b213 213 !b213
214 !b214 214 !b214
215 !b215 215 !b215
216 !&bb b; 216 !&bb b;
3 !b3 3 ! b3
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#16171518 LOAD XML DOES NOT HANDLE EMPTY ELEMENTS # Bug#16171518 LOAD XML DOES NOT HANDLE EMPTY ELEMENTS

View File

@ -36,6 +36,6 @@ set debug_dbug='+d,mi_lock_database_failure';
unlock tables; unlock tables;
Warnings: Warnings:
Error 126 Incorrect key file for table './test/t1.MYI'; try to repair it Error 126 Incorrect key file for table './test/t1.MYI'; try to repair it
Error 1015 Can't lock file (errno: 22 "Invalid argument") Error 1030 Got error 22 "Invalid argument" from storage engine MyISAM
set debug_dbug=@old_dbug; set debug_dbug=@old_dbug;
drop table t1; drop table t1;

View File

@ -529,3 +529,61 @@ a
+-------------------+ +-------------------+
End of tests End of tests
create table `a1\``b1` (a int);
show tables;
Tables_in_test
a1\`b1
insert `a1\``b1` values (1),(2);
show create table `a1\``b1`;
Table Create Table
a1\`b1 CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `a1\``b1` VALUES (1),(2);
insert `a1\``b1` values (4),(5);
show create table `a1\``b1`;
Table Create Table
a1\`b1 CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from `a1\``b1`;
a
1
2
drop table `a1\``b1`;
set sql_mode=ansi_quotes;
create table "a1\""b1" (a int);
show tables;
Tables_in_test
a1\"b1
insert "a1\""b1" values (1),(2);
show create table "a1\""b1";
Table Create Table
a1\"b1 CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
);
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO "a1\""b1" VALUES (1),(2);
insert "a1\""b1" values (4),(5);
show create table "a1\""b1";
Table Create Table
a1\"b1 CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from "a1\""b1";
a
1
2
drop table "a1\""b1";
set sql_mode=default;

View File

@ -464,4 +464,25 @@ even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@loca
even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost
DROP USER very_long_user_name_number_1, very_long_user_name_number_2, even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost; DROP USER very_long_user_name_number_1, very_long_user_name_number_2, even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost;
DROP PROCEDURE test.pr; DROP PROCEDURE test.pr;
End of tests use test;
alter table mysql.innodb_table_stats modify last_update int not null;
create table extralongname_extralongname_extralongname_extralongname_ext (
id int(10) unsigned not null,
created_date date not null,
created timestamp not null,
primary key (created,id,created_date)
) engine=innodb stats_persistent=1 default charset=latin1
partition by range (year(created_date))
subpartition by hash (month(created_date))
subpartitions 2 (
partition p2007 values less than (2008),
partition p2008 values less than (2009)
);
select length(table_name) from mysql.innodb_table_stats;
length(table_name)
79
79
79
79
drop table extralongname_extralongname_extralongname_extralongname_ext;
End of 10.0 tests

View File

@ -960,4 +960,9 @@ con1
con2 con2
con2 con2
-closed_connection- -closed_connection-
set sql_mode=no_backslash_escapes;
select "foo\""bar";
foo\"bar
foo\"bar
set sql_mode=default;
End of tests End of tests

View File

@ -30,6 +30,8 @@ create temporary table t3 (a int);
create temporary table t4 (a int) select * from t3; create temporary table t4 (a int) select * from t3;
insert into t3 values(1); insert into t3 values(1);
insert into t4 select * from t3; insert into t4 select * from t3;
create table t3 (a int);
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a; update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a; update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;

View File

@ -7121,9 +7121,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2)); CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3); INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
3
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0; SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2 f2
3 3
@ -7131,9 +7132,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*) count(*)
1 1
delete from t1; delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
NULL
drop view v2; drop view v2;
drop table t1,t2; drop table t1,t2;
# #
@ -7147,3 +7149,40 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2 f1 f2
foo bar foo bar
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
(SELECT MAX(sq.f2) FROM t1)
NULL
#
# Disable this query till MDEV-13399 is resolved
#
# INSERT t2 VALUES (9);
# --error ER_SUBQUERY_NO_1_ROW
# SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
#
drop table t1, t2;

View File

@ -2274,6 +2274,94 @@ pk f1 sq
5 3 5 5 3 5
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# mdev-12838: scan of materialized of semi-join subquery in join
#
set @save_optimizer_switch=@@optimizer_switch;
CREATE TABLE t1 (
dispatch_group varchar(32),
assignment_group varchar(32),
sys_id char(32),
PRIMARY KEY (sys_id),
KEY idx1 (dispatch_group),
KEY idx2 (assignment_group)
) ENGINE=MyISAM;
CREATE TABLE t2 (
ugroup varchar(32),
user varchar(32),
sys_id char(32),
PRIMARY KEY (sys_id),
KEY idx3 (ugroup),
KEY idx4 (user)
) ENGINE=MyISAM;
CREATE TABLE t3 (
type mediumtext,
sys_id char(32),
PRIMARY KEY (sys_id)
) ENGINE=MyISAM;
set optimizer_switch='materialization=off';
explain SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary
1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
assignment_group
df50316637232000158bbfc8bcbe5d23
e08fad2637232000158bbfc8bcbe5d39
ec70316637232000158bbfc8bcbe5d60
7b10fd2637232000158bbfc8bcbe5d30
ebb4620037332000158bbfc8bcbe5d89
set optimizer_switch='materialization=on';
explain SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
assignment_group
df50316637232000158bbfc8bcbe5d23
e08fad2637232000158bbfc8bcbe5d39
ec70316637232000158bbfc8bcbe5d60
7b10fd2637232000158bbfc8bcbe5d30
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
# End of 5.5 tests # End of 5.5 tests
# #
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT # MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View File

@ -485,3 +485,20 @@ FROM t2 AS t2a INNER JOIN t2 t2b INNER JOIN t3
ON (f3 = t2b.f2) ); ON (f3 = t2b.f2) );
f1 f1
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
#
# MDEV-12963: min/max optimization optimizing away all tables employed
# for uncorrelated IN subquery used in a disjunct of WHERE
#
create table t1 (a int, index idx(a)) engine=myisam;
insert into t1 values (4),(7),(1),(3),(9);
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
a
3
7
9
explain
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index idx idx 5 NULL 5 Using where; Using index
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1;

View File

@ -7121,9 +7121,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2)); CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3); INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
3
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0; SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2 f2
3 3
@ -7131,9 +7132,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*) count(*)
1 1
delete from t1; delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
NULL
drop view v2; drop view v2;
drop table t1,t2; drop table t1,t2;
# #
@ -7147,6 +7149,43 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2 f1 f2
foo bar foo bar
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
(SELECT MAX(sq.f2) FROM t1)
NULL
#
# Disable this query till MDEV-13399 is resolved
#
# INSERT t2 VALUES (9);
# --error ER_SUBQUERY_NO_1_ROW
# SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
#
drop table t1, t2;
set optimizer_switch=default; set optimizer_switch=default;
select @@optimizer_switch like '%exists_to_in=off%'; select @@optimizer_switch like '%exists_to_in=off%';
@@optimizer_switch like '%exists_to_in=off%' @@optimizer_switch like '%exists_to_in=off%'

View File

@ -7114,9 +7114,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2)); CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3); INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
3
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0; SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2 f2
3 3
@ -7124,9 +7125,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*) count(*)
1 1
delete from t1; delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
NULL
drop view v2; drop view v2;
drop table t1,t2; drop table t1,t2;
# #
@ -7140,6 +7142,43 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2 f1 f2
foo bar foo bar
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
(SELECT MAX(sq.f2) FROM t1)
NULL
#
# Disable this query till MDEV-13399 is resolved
#
# INSERT t2 VALUES (9);
# --error ER_SUBQUERY_NO_1_ROW
# SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
#
drop table t1, t2;
set optimizer_switch=default; set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%'; select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%' @@optimizer_switch like '%materialization=on%'

View File

@ -7112,9 +7112,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2)); CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3); INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
3
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0; SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2 f2
3 3
@ -7122,9 +7123,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*) count(*)
1 1
delete from t1; delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
NULL
drop view v2; drop view v2;
drop table t1,t2; drop table t1,t2;
# #
@ -7138,4 +7140,41 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2 f1 f2
foo bar foo bar
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
(SELECT MAX(sq.f2) FROM t1)
NULL
#
# Disable this query till MDEV-13399 is resolved
#
# INSERT t2 VALUES (9);
# --error ER_SUBQUERY_NO_1_ROW
# SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
#
drop table t1, t2;
set @optimizer_switch_for_subselect_test=null; set @optimizer_switch_for_subselect_test=null;

View File

@ -7127,9 +7127,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2)); CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3); INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
3
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0; SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2 f2
3 3
@ -7137,9 +7138,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*) count(*)
1 1
delete from t1; delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
NULL
drop view v2; drop view v2;
drop table t1,t2; drop table t1,t2;
# #
@ -7153,6 +7155,43 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2 f1 f2
foo bar foo bar
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
(SELECT MAX(sq.f2) FROM t1)
NULL
#
# Disable this query till MDEV-13399 is resolved
#
# INSERT t2 VALUES (9);
# --error ER_SUBQUERY_NO_1_ROW
# SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
#
drop table t1, t2;
set optimizer_switch=default; set optimizer_switch=default;
select @@optimizer_switch like '%subquery_cache=on%'; select @@optimizer_switch like '%subquery_cache=on%';
@@optimizer_switch like '%subquery_cache=on%' @@optimizer_switch like '%subquery_cache=on%'

View File

@ -7112,9 +7112,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2)); CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3); INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
3
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0; SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2 f2
3 3
@ -7122,9 +7123,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*) count(*)
1 1
delete from t1; delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq; SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq ERROR 42000: Can't group on 'sq'
NULL
drop view v2; drop view v2;
drop table t1,t2; drop table t1,t2;
# #
@ -7138,5 +7140,42 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2 f1 f2
foo bar foo bar
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
INSERT t1 VALUES (4),(8);
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
(SELECT MAX(sq.f2) FROM t1)
NULL
#
# Disable this query till MDEV-13399 is resolved
#
# INSERT t2 VALUES (9);
# --error ER_SUBQUERY_NO_1_ROW
# SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
#
drop table t1, t2;
set @optimizer_switch_for_subselect_test=null; set @optimizer_switch_for_subselect_test=null;
set @join_cache_level_for_subselect_test=NULL; set @join_cache_level_for_subselect_test=NULL;

View File

@ -115,3 +115,9 @@ k d1 d2
set optimizer_switch= @tmp_subselect_nulls; set optimizer_switch= @tmp_subselect_nulls;
drop table x1; drop table x1;
drop table x2; drop table x2;
select (select 1, 2) in (select 3, 4);
(select 1, 2) in (select 3, 4)
0
select (select NULL, NULL) in (select 3, 4);
(select NULL, NULL) in (select 3, 4)
NULL

View File

@ -1612,3 +1612,25 @@ Warnings:
Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((rand() < 0)) Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((rand() < 0))
drop table t1,t2; drop table t1,t2;
set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_optimizer_switch;
#
# mdev-12855: materialization of a semi-join subquery + ORDER BY
#
CREATE TABLE t1 (f1 varchar(8), KEY(f1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('qux'),('foo');
CREATE TABLE t2 (f2 varchar(8)) ENGINE=InnoDB;
INSERT INTO t2 VALUES ('bar'),('foo'),('qux');
SELECT f1 FROM t1
WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
HAVING f1 != 'foo'
ORDER BY f1;
f1
qux
explain SELECT f1 FROM t1
WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
HAVING f1 != 'foo'
ORDER BY f1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index f1 f1 11 NULL 2 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 11 func 1
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
DROP TABLE t1,t2;

View File

@ -2314,6 +2314,94 @@ pk f1 sq
5 3 5 5 3 5
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# mdev-12838: scan of materialized of semi-join subquery in join
#
set @save_optimizer_switch=@@optimizer_switch;
CREATE TABLE t1 (
dispatch_group varchar(32),
assignment_group varchar(32),
sys_id char(32),
PRIMARY KEY (sys_id),
KEY idx1 (dispatch_group),
KEY idx2 (assignment_group)
) ENGINE=MyISAM;
CREATE TABLE t2 (
ugroup varchar(32),
user varchar(32),
sys_id char(32),
PRIMARY KEY (sys_id),
KEY idx3 (ugroup),
KEY idx4 (user)
) ENGINE=MyISAM;
CREATE TABLE t3 (
type mediumtext,
sys_id char(32),
PRIMARY KEY (sys_id)
) ENGINE=MyISAM;
set optimizer_switch='materialization=off';
explain SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary
1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
assignment_group
df50316637232000158bbfc8bcbe5d23
e08fad2637232000158bbfc8bcbe5d39
ec70316637232000158bbfc8bcbe5d60
7b10fd2637232000158bbfc8bcbe5d30
ebb4620037332000158bbfc8bcbe5d89
set optimizer_switch='materialization=on';
explain SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
assignment_group
df50316637232000158bbfc8bcbe5d23
e08fad2637232000158bbfc8bcbe5d39
ec70316637232000158bbfc8bcbe5d60
7b10fd2637232000158bbfc8bcbe5d30
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
# End of 5.5 tests # End of 5.5 tests
# #
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT # MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View File

@ -1978,3 +1978,21 @@ d
2016-06-04 00:00:00 2016-06-04 00:00:00
drop table t1; drop table t1;
End of 5.0 tests End of 5.0 tests
create table t1 (a int, b int);
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (c varchar(30), d varchar(30));
insert into t1 values ('1','1'),('2','2'),('4','4');
create table t3 (e int, f int);
insert into t3 values (1,1),(2,2),(31,31),(32,32);
select e,f, (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3;
e f sub
1 1 1
2 2 1
31 31 0
32 32 0
select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub;
avg(f) sub
31.5000 0
1.5000 1
drop table t1,t2,t3;
End of 5.5 tests

View File

@ -5619,6 +5619,20 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`f` = `test`.`t1`.`a`) and (`test`.`t2`.`d` = `test`.`t3`.`e`) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`b` is not null))) where (`test`.`t1`.`a` < 5) Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`f` = `test`.`t1`.`a`) and (`test`.`t2`.`d` = `test`.`t3`.`e`) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`b` is not null))) where (`test`.`t1`.`a` < 5)
drop view v1; drop view v1;
drop table t1,t2,t3; drop table t1,t2,t3;
#
# MDEV-11240: Server crashes in check_view_single_update or
# Assertion `derived->table' failed in mysql_derived_merge_for_insert
#
CREATE TABLE t3 (a INT);
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
EXECUTE stmt;
ERROR HY000: Can not insert into join view 'test.v2' without fields list
EXECUTE stmt;
ERROR HY000: Can not insert into join view 'test.v2' without fields list
drop view v1,v2;
drop table t3;
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# -- End of 5.5 tests. # -- End of 5.5 tests.
# ----------------------------------------------------------------- # -----------------------------------------------------------------
@ -5944,6 +5958,68 @@ use_case_id InitialDeadline
10 2015-12-18 10 2015-12-18
drop view v1; drop view v1;
drop table t1; drop table t1;
#
# MDEV-12666: CURRENT_ROLE() and DATABASE() does not work in a view
#
# DATABASE() fails only when the initial view creation features a NULL
# default database.
#
# CREATE, USE and DROP database so that we have no "default" database.
#
CREATE DATABASE temporary;
USE temporary;
DROP DATABASE temporary;
SELECT DATABASE();
DATABASE()
NULL
CREATE VIEW test.v_no_db AS SELECT DATABASE() = 'temporary_two';
SHOW CREATE VIEW test.v_no_db;
View Create View character_set_client collation_connection
v_no_db CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v_no_db` AS select (database() = 'temporary_two') AS `DATABASE() = 'temporary_two'` latin1 latin1_swedish_ci
PREPARE prepared_no_database FROM "SELECT DATABASE() = 'temporary_two'";
#
# All statements should return NULL
#
EXECUTE prepared_no_database;
DATABASE() = 'temporary_two'
NULL
SELECT DATABASE() = 'temporary_two';
DATABASE() = 'temporary_two'
NULL
SELECT * FROM test.v_no_db;
DATABASE() = 'temporary_two'
NULL
CREATE DATABASE temporary_two;
USE temporary_two;
CREATE VIEW test.v_with_db AS SELECT DATABASE() = 'temporary_two';
PREPARE prepared_with_database FROM "SELECT DATABASE() = 'temporary_two'";
#
# All statements should return 1;
#
SELECT DATABASE() = 'temporary_two';
DATABASE() = 'temporary_two'
1
SELECT * FROM test.v_no_db;
DATABASE() = 'temporary_two'
1
SELECT * FROM test.v_with_db;
DATABASE() = 'temporary_two'
1
EXECUTE prepared_with_database;
DATABASE() = 'temporary_two'
1
#
# Prepared statements maintain default database to be the same
# during on creation so this should return NULL still.
# See MySQL bug #25843
#
EXECUTE prepared_no_database;
DATABASE() = 'temporary_two'
NULL
DROP DATABASE temporary_two;
DROP VIEW test.v_no_db;
DROP VIEW test.v_with_db;
USE test;
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# -- End of 10.0 tests. # -- End of 10.0 tests.
# ----------------------------------------------------------------- # -----------------------------------------------------------------

View File

@ -9,19 +9,19 @@
<table_data name="t1"> <table_data name="t1">
<row> <row>
<field name="a">1</field> <field name="a">1</field>
<field name="b">b1</field> <field name="b"> b1</field>
</row> </row>
<row> <row>
<field name="a">2</field> <field name="a">2</field>
<field name="b">b2</field> <field name="b"> b2</field>
</row> </row>
<row> <row>
<field name="a">3</field> <field name="a">3</field>
<field name="b">b3</field> <field name="b"> b3</field>
</row> </row>
<row> <row>
<field name="a">11</field> <field name="a">11</field>
<field name="b">b11</field> <field name="b"> b11</field>
</row> </row>
<!-- Check field values as tags --> <!-- Check field values as tags -->

View File

@ -326,8 +326,8 @@ fid IsClosed(g)
116 0 116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid; SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g)) fid AsText(Centroid(g))
117 POINT(55.58852775304245 17.426536064113982) 117 POINT(57.98031067576927 17.854754130800433)
118 POINT(55.58852775304245 17.426536064113982) 118 POINT(57.98031067576927 17.854754130800433)
119 POINT(2 2) 119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid; SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g) fid Area(g)

View File

@ -1,14 +1,14 @@
#### Setup tables #### #### Setup tables ####
CREATE TABLE t0 (a CHAR(100)); CREATE TABLE t0 (a CHAR(200));
CREATE TABLE t1 (a CHAR(100)); CREATE TABLE t1 (a CHAR(200));
CREATE TABLE t2 (a CHAR(100)); CREATE TABLE t2 (a CHAR(200));
CREATE TABLE t3 (a CHAR(100)); CREATE TABLE t3 (a CHAR(200));
CREATE TABLE ta0 (a CHAR(100)); CREATE TABLE ta0 (a CHAR(200));
CREATE TABLE ta1 (a CHAR(100)); CREATE TABLE ta1 (a CHAR(200));
CREATE TABLE ta2 (a CHAR(100)); CREATE TABLE ta2 (a CHAR(200));
CREATE TABLE ta3 (a CHAR(100)); CREATE TABLE ta3 (a CHAR(200));
CREATE TABLE autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT); CREATE TABLE autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT);
CREATE TABLE data_table (a CHAR(100)); CREATE TABLE data_table (a CHAR(200));
INSERT INTO data_table VALUES ('foo'); INSERT INTO data_table VALUES ('foo');
CREATE TABLE trigger_table_1 (a INT); CREATE TABLE trigger_table_1 (a INT);
CREATE TABLE trigger_table_2 (a INT); CREATE TABLE trigger_table_2 (a INT);
@ -2392,7 +2392,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100)); CREATE TABLE t1 (a VARCHAR(200), b VARCHAR(200));
INSERT INTO t1 VALUES ('a','b'); INSERT INTO t1 VALUES ('a','b');
UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1; UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
Warnings: Warnings:
@ -2423,7 +2423,7 @@ CREATE FUNCTION fun_check_log_bin() RETURNS INT
BEGIN BEGIN
SET @@SQL_LOG_BIN = 0; SET @@SQL_LOG_BIN = 0;
INSERT INTO t1 VALUES(@@global.sync_binlog); INSERT INTO t1 VALUES(@@global.sync_binlog);
RETURN 100; RETURN 200;
END| END|
"One unsafe warning should be issued in the following statement" "One unsafe warning should be issued in the following statement"
SELECT fun_check_log_bin(); SELECT fun_check_log_bin();

View File

@ -110,16 +110,16 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state
--echo #### Setup tables #### --echo #### Setup tables ####
CREATE TABLE t0 (a CHAR(100)); CREATE TABLE t0 (a CHAR(200));
CREATE TABLE t1 (a CHAR(100)); CREATE TABLE t1 (a CHAR(200));
CREATE TABLE t2 (a CHAR(100)); CREATE TABLE t2 (a CHAR(200));
CREATE TABLE t3 (a CHAR(100)); CREATE TABLE t3 (a CHAR(200));
CREATE TABLE ta0 (a CHAR(100)); CREATE TABLE ta0 (a CHAR(200));
CREATE TABLE ta1 (a CHAR(100)); CREATE TABLE ta1 (a CHAR(200));
CREATE TABLE ta2 (a CHAR(100)); CREATE TABLE ta2 (a CHAR(200));
CREATE TABLE ta3 (a CHAR(100)); CREATE TABLE ta3 (a CHAR(200));
CREATE TABLE autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT); CREATE TABLE autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT);
CREATE TABLE data_table (a CHAR(100)); CREATE TABLE data_table (a CHAR(200));
INSERT INTO data_table VALUES ('foo'); INSERT INTO data_table VALUES ('foo');
CREATE TABLE trigger_table_1 (a INT); CREATE TABLE trigger_table_1 (a INT);
CREATE TABLE trigger_table_2 (a INT); CREATE TABLE trigger_table_2 (a INT);
@ -433,7 +433,7 @@ DROP TABLE t1;
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings --enable_warnings
CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100)); CREATE TABLE t1 (a VARCHAR(200), b VARCHAR(200));
INSERT INTO t1 VALUES ('a','b'); INSERT INTO t1 VALUES ('a','b');
UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1; UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
DROP TABLE t1; DROP TABLE t1;
@ -471,7 +471,7 @@ CREATE FUNCTION fun_check_log_bin() RETURNS INT
BEGIN BEGIN
SET @@SQL_LOG_BIN = 0; SET @@SQL_LOG_BIN = 0;
INSERT INTO t1 VALUES(@@global.sync_binlog); INSERT INTO t1 VALUES(@@global.sync_binlog);
RETURN 100; RETURN 200;
END| END|
DELIMITER ;| DELIMITER ;|
--echo "One unsafe warning should be issued in the following statement" --echo "One unsafe warning should be issued in the following statement"

View File

@ -0,0 +1,9 @@
CREATE TABLE t(c0 SERIAL, c1 INT, c2 INT, c3 INT, c4 INT,
KEY(c1), KEY(c2), KEY(c2,c1),
KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1),
KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1),
KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB;
SET DEBUG_DBUG='+d,row_drop_table_add_to_background';
DROP TABLE t;
CREATE TABLE t (a INT) ENGINE=InnoDB;
DROP TABLE t;

View File

@ -27,7 +27,7 @@ CONSTRAINT `fk_crewRoleAssigned_crewId` FOREIGN KEY (`crew_id`) REFERENCES `repr
CONSTRAINT `fk_crewRoleAssigned_pilotId` FOREIGN KEY (`crew_id`) REFERENCES `repro`.`pilot` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `fk_crewRoleAssigned_pilotId` FOREIGN KEY (`crew_id`) REFERENCES `repro`.`pilot` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB COMMENT="This is a comment about tables"; ) ENGINE=InnoDB COMMENT="This is a comment about tables";
ALTER TABLE `repro`.`crew_role_assigned` COMMENT = 'innodb_read_only'; ALTER TABLE `repro`.`crew_role_assigned` COMMENT = 'innodb_read_only';
ERROR HY000: Can't lock file (errno: 165 "Table is read only") ERROR HY000: Table 'crew_role_assigned' is read only
SHOW CREATE TABLE `repro`.`crew_role_assigned`; SHOW CREATE TABLE `repro`.`crew_role_assigned`;
Table Create Table Table Create Table
crew_role_assigned CREATE TABLE `crew_role_assigned` ( crew_role_assigned CREATE TABLE `crew_role_assigned` (

View File

@ -326,8 +326,8 @@ fid IsClosed(g)
116 0 116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid; SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g)) fid AsText(Centroid(g))
117 POINT(55.58852775304245 17.426536064113982) 117 POINT(57.98031067576927 17.854754130800433)
118 POINT(55.58852775304245 17.426536064113982) 118 POINT(57.98031067576927 17.854754130800433)
119 POINT(2 2) 119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid; SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g) fid Area(g)

View File

@ -0,0 +1,48 @@
create table t1 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156),
fulltext ftsic(c)) engine=InnoDB
row_format=redundant;
insert into t1 values(123, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(456, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(789, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf');
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
SET GLOBAL innodb_file_per_table=OFF;
create table t2 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB
row_format=redundant;
insert into t2 select * from t1;
create table t3 (a int not null, d varchar(15) not null, b varchar(198),
c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB
row_format=redundant;
insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa');
insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa');
SET GLOBAL innodb_fast_shutdown=0;
SELECT COUNT(*) FROM t1;
COUNT(*)
4096
SELECT COUNT(*) FROM t2;
COUNT(*)
4096
SELECT COUNT(*) FROM t3;
COUNT(*)
2
TRUNCATE TABLE t1;
ERROR HY000: Table 't1' is read only
TRUNCATE TABLE t2;
ERROR HY000: Table 't2' is read only
TRUNCATE TABLE t3;
ERROR HY000: Table 't3' is read only
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
DROP TABLE t1,t2,t3;

View File

@ -0,0 +1,83 @@
--- suite/innodb/r/table_flags.result
+++ suite/innodb/r/table_flags,4k.reject
@@ -13,7 +13,7 @@
header=0x01000003016e (NAME=0x696e66696d756d00)
header=0x00002815008d (NAME='SYS_DATAFILES',
DB_TRX_ID=0x000000000301,
- DB_ROLL_PTR=0x81000001320194,
+ DB_ROLL_PTR=0x81000003260194,
ID=0x000000000000000e,
N_COLS=0x00000002,
TYPE=0x00000001,
@@ -23,7 +23,7 @@
SPACE=0x00000000)
header=0x0000101500d5 (NAME='SYS_FOREIGN',
DB_TRX_ID=0x000000000300,
- DB_ROLL_PTR=0x800000012d0110,
+ DB_ROLL_PTR=0x80000003200110,
ID=0x000000000000000b,
N_COLS=0x00000004,
TYPE=0x00000001,
@@ -33,7 +33,7 @@
SPACE=0x00000000)
header=0x000018150122 (NAME='SYS_FOREIGN_COLS',
DB_TRX_ID=0x000000000300,
- DB_ROLL_PTR=0x800000012d0201,
+ DB_ROLL_PTR=0x80000003200201,
ID=0x000000000000000c,
N_COLS=0x00000004,
TYPE=0x00000001,
@@ -43,7 +43,7 @@
SPACE=0x00000000)
header=0x0400201501fc (NAME='SYS_TABLESPACES',
DB_TRX_ID=0x000000000301,
- DB_ROLL_PTR=0x81000001320110,
+ DB_ROLL_PTR=0x81000003260110,
ID=0x000000000000000d,
N_COLS=0x00000003,
TYPE=0x00000001,
@@ -53,7 +53,7 @@
SPACE=0x00000000)
header=0x000038150240 (NAME='test/tc',
DB_TRX_ID=0x000000000303,
- DB_ROLL_PTR=0x83000001360110,
+ DB_ROLL_PTR=0x830000032b0110,
ID=0x0000000000000010,
N_COLS=0x80000001,
TYPE=0x00000001,
@@ -63,7 +63,7 @@
SPACE=0x00000002)
header=0x0000401502c8 (NAME='test/td',
DB_TRX_ID=0x000000000304,
- DB_ROLL_PTR=0x84000001370110,
+ DB_ROLL_PTR=0x840000032c0110,
ID=0x0000000000000011,
N_COLS=0x80000001,
TYPE=0x00000021,
@@ -73,7 +73,7 @@
SPACE=0x00000003)
header=0x0000501501b8 (NAME='test/tp',
DB_TRX_ID=0x000000000306,
- DB_ROLL_PTR=0x86000001390110,
+ DB_ROLL_PTR=0x860000032e0110,
ID=0x0000000000000013,
N_COLS=0x80000001,
TYPE=0x00000021,
@@ -83,7 +83,7 @@
SPACE=0x00000005)
header=0x000030150284 (NAME='test/tr',
DB_TRX_ID=0x000000000302,
- DB_ROLL_PTR=0x82000001350110,
+ DB_ROLL_PTR=0x820000032a0110,
ID=0x000000000000000f,
N_COLS=0x00000001,
TYPE=0x00000001,
@@ -93,7 +93,7 @@
SPACE=0x00000001)
header=0x000048150074 (NAME='test/tz',
DB_TRX_ID=0x000000000305,
- DB_ROLL_PTR=0x85000001380110,
+ DB_ROLL_PTR=0x850000032d0110,
ID=0x0000000000000012,
N_COLS=0x80000001,
TYPE=0x00000023,

View File

@ -0,0 +1,83 @@
--- suite/innodb/r/table_flags.result
+++ suite/innodb/r/table_flags,8k.reject
@@ -13,7 +13,7 @@
header=0x01000003016e (NAME=0x696e66696d756d00)
header=0x00002815008d (NAME='SYS_DATAFILES',
DB_TRX_ID=0x000000000301,
- DB_ROLL_PTR=0x81000001320194,
+ DB_ROLL_PTR=0x81000001d70194,
ID=0x000000000000000e,
N_COLS=0x00000002,
TYPE=0x00000001,
@@ -23,7 +23,7 @@
SPACE=0x00000000)
header=0x0000101500d5 (NAME='SYS_FOREIGN',
DB_TRX_ID=0x000000000300,
- DB_ROLL_PTR=0x800000012d0110,
+ DB_ROLL_PTR=0x80000001d10110,
ID=0x000000000000000b,
N_COLS=0x00000004,
TYPE=0x00000001,
@@ -33,7 +33,7 @@
SPACE=0x00000000)
header=0x000018150122 (NAME='SYS_FOREIGN_COLS',
DB_TRX_ID=0x000000000300,
- DB_ROLL_PTR=0x800000012d0201,
+ DB_ROLL_PTR=0x80000001d10201,
ID=0x000000000000000c,
N_COLS=0x00000004,
TYPE=0x00000001,
@@ -43,7 +43,7 @@
SPACE=0x00000000)
header=0x0400201501fc (NAME='SYS_TABLESPACES',
DB_TRX_ID=0x000000000301,
- DB_ROLL_PTR=0x81000001320110,
+ DB_ROLL_PTR=0x81000001d70110,
ID=0x000000000000000d,
N_COLS=0x00000003,
TYPE=0x00000001,
@@ -53,7 +53,7 @@
SPACE=0x00000000)
header=0x000038150240 (NAME='test/tc',
DB_TRX_ID=0x000000000303,
- DB_ROLL_PTR=0x83000001360110,
+ DB_ROLL_PTR=0x83000001db0110,
ID=0x0000000000000010,
N_COLS=0x80000001,
TYPE=0x00000001,
@@ -63,7 +63,7 @@
SPACE=0x00000002)
header=0x0000401502c8 (NAME='test/td',
DB_TRX_ID=0x000000000304,
- DB_ROLL_PTR=0x84000001370110,
+ DB_ROLL_PTR=0x84000001dc0110,
ID=0x0000000000000011,
N_COLS=0x80000001,
TYPE=0x00000021,
@@ -73,7 +73,7 @@
SPACE=0x00000003)
header=0x0000501501b8 (NAME='test/tp',
DB_TRX_ID=0x000000000306,
- DB_ROLL_PTR=0x86000001390110,
+ DB_ROLL_PTR=0x86000001de0110,
ID=0x0000000000000013,
N_COLS=0x80000001,
TYPE=0x00000021,
@@ -83,7 +83,7 @@
SPACE=0x00000005)
header=0x000030150284 (NAME='test/tr',
DB_TRX_ID=0x000000000302,
- DB_ROLL_PTR=0x82000001350110,
+ DB_ROLL_PTR=0x82000001da0110,
ID=0x000000000000000f,
N_COLS=0x00000001,
TYPE=0x00000001,
@@ -93,7 +93,7 @@
SPACE=0x00000001)
header=0x000048150074 (NAME='test/tz',
DB_TRX_ID=0x000000000305,
- DB_ROLL_PTR=0x85000001380110,
+ DB_ROLL_PTR=0x85000001dd0110,
ID=0x0000000000000012,
N_COLS=0x80000001,
TYPE=0x00000023,

View File

@ -0,0 +1,175 @@
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE tr(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
CREATE TABLE tc(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPACT;
CREATE TABLE td(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
CREATE TABLE tz(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPRESSED
KEY_BLOCK_SIZE=1;
CREATE TABLE tp(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
ERROR HY000: Unknown option 'PAGE_COMPRESSED'
CREATE TABLE tp(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
SYS_TABLES clustered index root page (8):
N_RECS=9; LEVEL=0; INDEX_ID=0x0000000000000001
header=0x01000003016e (NAME=0x696e66696d756d00)
header=0x00002815008d (NAME='SYS_DATAFILES',
DB_TRX_ID=0x000000000301,
DB_ROLL_PTR=0x81000001320194,
ID=0x000000000000000e,
N_COLS=0x00000002,
TYPE=0x00000001,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000040,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000000)
header=0x0000101500d5 (NAME='SYS_FOREIGN',
DB_TRX_ID=0x000000000300,
DB_ROLL_PTR=0x800000012d0110,
ID=0x000000000000000b,
N_COLS=0x00000004,
TYPE=0x00000001,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000040,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000000)
header=0x000018150122 (NAME='SYS_FOREIGN_COLS',
DB_TRX_ID=0x000000000300,
DB_ROLL_PTR=0x800000012d0201,
ID=0x000000000000000c,
N_COLS=0x00000004,
TYPE=0x00000001,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000040,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000000)
header=0x0400201501fc (NAME='SYS_TABLESPACES',
DB_TRX_ID=0x000000000301,
DB_ROLL_PTR=0x81000001320110,
ID=0x000000000000000d,
N_COLS=0x00000003,
TYPE=0x00000001,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000040,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000000)
header=0x000038150240 (NAME='test/tc',
DB_TRX_ID=0x000000000303,
DB_ROLL_PTR=0x83000001360110,
ID=0x0000000000000010,
N_COLS=0x80000001,
TYPE=0x00000001,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000050,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000002)
header=0x0000401502c8 (NAME='test/td',
DB_TRX_ID=0x000000000304,
DB_ROLL_PTR=0x84000001370110,
ID=0x0000000000000011,
N_COLS=0x80000001,
TYPE=0x00000021,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000050,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000003)
header=0x0000501501b8 (NAME='test/tp',
DB_TRX_ID=0x000000000306,
DB_ROLL_PTR=0x86000001390110,
ID=0x0000000000000013,
N_COLS=0x80000001,
TYPE=0x00000021,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000050,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000005)
header=0x000030150284 (NAME='test/tr',
DB_TRX_ID=0x000000000302,
DB_ROLL_PTR=0x82000001350110,
ID=0x000000000000000f,
N_COLS=0x00000001,
TYPE=0x00000001,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000050,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000001)
header=0x000048150074 (NAME='test/tz',
DB_TRX_ID=0x000000000305,
DB_ROLL_PTR=0x85000001380110,
ID=0x0000000000000012,
N_COLS=0x80000001,
TYPE=0x00000023,
MIX_ID=0x0000000000000000,
MIX_LEN=0x00000050,
CLUSTER_NAME=NULL(0 bytes),
SPACE=0x00000004)
header=0x060008030000 (NAME=0x73757072656d756d00)
SHOW CREATE TABLE tr;
Table Create Table
tr CREATE TABLE `tr` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
INSERT INTO tr VALUES(42);
SHOW CREATE TABLE tc;
ERROR 42S02: Table 'test.tc' doesn't exist in engine
SHOW CREATE TABLE td;
ERROR 42S02: Table 'test.td' doesn't exist in engine
SHOW CREATE TABLE tz;
ERROR 42S02: Table 'test.tz' doesn't exist in engine
SHOW CREATE TABLE tp;
ERROR 42S02: Table 'test.tp' doesn't exist in engine
FOUND /InnoDB: Table '.test.\..t[cdzp].' in InnoDB data dictionary has unknown type (81|f21|8a1|3023)/ in mysqld.1.err
FOUND /InnoDB: Cannot open table test/t[cdzp] from the internal data dictionary of InnoDB/ in mysqld.1.err
Restoring SYS_TABLES clustered index root page (8)
SHOW CREATE TABLE tr;
Table Create Table
tr CREATE TABLE `tr` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
SHOW CREATE TABLE tc;
Table Create Table
tc CREATE TABLE `tc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
SHOW CREATE TABLE td;
Table Create Table
td CREATE TABLE `td` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
SHOW CREATE TABLE tz;
Table Create Table
tz CREATE TABLE `tz` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1
SHOW CREATE TABLE tp;
Table Create Table
tp CREATE TABLE `tp` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
BEGIN;
INSERT INTO tr VALUES(1);
INSERT INTO tc VALUES(1);
INSERT INTO td VALUES(1);
INSERT INTO tz VALUES(1);
INSERT INTO tp VALUES(1);
ROLLBACK;
SELECT * FROM tr;
a
42
SELECT * FROM tc;
a
SELECT * FROM td;
a
SELECT * FROM tz;
a
SELECT * FROM tp;
a
DROP TABLE tr,tc,td,tz,tp;
ib_logfile0
ib_logfile1
ibdata1
sys_tables.bin

View File

@ -0,0 +1,30 @@
--source include/have_innodb.inc
--source include/have_debug.inc
# Embedded server does not support restarting
--source include/not_embedded.inc
CREATE TABLE t(c0 SERIAL, c1 INT, c2 INT, c3 INT, c4 INT,
KEY(c1), KEY(c2), KEY(c2,c1),
KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1),
KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1),
KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB;
let $n= 10;
SET DEBUG_DBUG='+d,row_drop_table_add_to_background';
--disable_query_log
let $i= $n;
while ($i) {
eval CREATE TABLE t$i LIKE t;
dec $i;
}
let $i= $n;
while ($i) {
eval DROP TABLE t$i;
dec $i;
}
--enable_query_log
DROP TABLE t;
--source include/restart_mysqld.inc
CREATE TABLE t (a INT) ENGINE=InnoDB;
DROP TABLE t;

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size.inc
--source include/have_debug.inc --source include/have_debug.inc
--source include/have_debug_sync.inc --source include/have_debug_sync.inc

View File

@ -1,7 +1,7 @@
#Bug#13955083 ALLOW IN-PLACE DDL OPERATIONS ON MISSING OR DISCARDED TABLESPACES #Bug#13955083 ALLOW IN-PLACE DDL OPERATIONS ON MISSING OR DISCARDED TABLESPACES
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/have_innodb.inc --source include/innodb_page_size.inc
let $MYSQLD_DATADIR=`select @@datadir`; let $MYSQLD_DATADIR=`select @@datadir`;
SET GLOBAL innodb_file_per_table=1; SET GLOBAL innodb_file_per_table=1;

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size.inc
# Save the initial number of concurrent sessions. # Save the initial number of concurrent sessions.
--source include/count_sessions.inc --source include/count_sessions.inc

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size.inc
# #
# MMDEV-8386: MariaDB creates very big tmp file and hangs on xtradb # MMDEV-8386: MariaDB creates very big tmp file and hangs on xtradb

View File

@ -10,8 +10,7 @@
# Avoid CrashReporter popup on Mac # Avoid CrashReporter popup on Mac
--source include/not_crashrep.inc --source include/not_crashrep.inc
# InnoDB is required --source include/innodb_page_size.inc
--source include/have_innodb.inc
--echo # --echo #
--echo # Bug #18734396 INNODB IN-PLACE ALTER FAILURES BLOCK FUTURE ALTERS --echo # Bug #18734396 INNODB IN-PLACE ALTER FAILURES BLOCK FUTURE ALTERS

View File

@ -36,7 +36,7 @@ CONSTRAINT `fk_crewRoleAssigned_pilotId` FOREIGN KEY (`crew_id`) REFERENCES `rep
-- let $restart_parameters=--innodb-read-only -- let $restart_parameters=--innodb-read-only
-- source include/restart_mysqld.inc -- source include/restart_mysqld.inc
--error ER_CANT_LOCK --error ER_OPEN_AS_READONLY
ALTER TABLE `repro`.`crew_role_assigned` COMMENT = 'innodb_read_only'; ALTER TABLE `repro`.`crew_role_assigned` COMMENT = 'innodb_read_only';
SHOW CREATE TABLE `repro`.`crew_role_assigned`; SHOW CREATE TABLE `repro`.`crew_role_assigned`;

View File

@ -1,6 +1,6 @@
# Test resizing the InnoDB redo log. # Test resizing the InnoDB redo log.
--source include/have_innodb.inc --source include/innodb_page_size.inc
# Embedded server does not support crashing # Embedded server does not support crashing
--source include/not_embedded.inc --source include/not_embedded.inc
@ -37,6 +37,12 @@ call mtr.add_suppression("Attempting backtrace");
FLUSH TABLES; FLUSH TABLES;
--enable_query_log --enable_query_log
--let $restart_parameters= --innodb-thread-concurrency=1 --innodb-log-file-size=1m --innodb-log-files-in-group=2
--source include/restart_mysqld.inc
--let $restart_parameters= --innodb-thread-concurrency=100 --innodb-log-file-size=10M --innodb-log-files-in-group=2
--source include/restart_mysqld.inc
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN; BEGIN;
INSERT INTO t1 VALUES (42); INSERT INTO t1 VALUES (42);

View File

@ -0,0 +1,63 @@
--source include/have_innodb.inc
# Embedded mode doesn't allow restarting
--source include/not_embedded.inc
create table t1 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156),
fulltext ftsic(c)) engine=InnoDB
row_format=redundant;
insert into t1 values(123, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(456, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(789, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf');
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
SET GLOBAL innodb_file_per_table=OFF;
create table t2 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB
row_format=redundant;
insert into t2 select * from t1;
create table t3 (a int not null, d varchar(15) not null, b varchar(198),
c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB
row_format=redundant;
insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa');
insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa');
# read-only restart requires the change buffer to be empty; therefore we
# do a slow shutdown.
SET GLOBAL innodb_fast_shutdown=0;
--let $restart_parameters = --innodb-read-only
--source include/restart_mysqld.inc
SELECT COUNT(*) FROM t1;
SELECT COUNT(*) FROM t2;
SELECT COUNT(*) FROM t3;
--error ER_OPEN_AS_READONLY
TRUNCATE TABLE t1;
--error ER_OPEN_AS_READONLY
TRUNCATE TABLE t2;
--error ER_OPEN_AS_READONLY
TRUNCATE TABLE t3;
--let $restart_parameters =
--source include/restart_mysqld.inc
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
DROP TABLE t1,t2,t3;

View File

@ -0,0 +1,190 @@
--source include/innodb_page_size.inc
# Embedded server tests do not support restarting
--source include/not_embedded.inc
--disable_query_log
call mtr.add_suppression("InnoDB: New log files created, LSN=");
call mtr.add_suppression("InnoDB: Creating foreign key constraint system tables");
call mtr.add_suppression("InnoDB: Error: .*innodb_table_stats. not found");
call mtr.add_suppression("InnoDB: Table '.test.\\..t[cdzp].' in InnoDB data dictionary has unknown type (81|f21|8a1|3023)");
call mtr.add_suppression("InnoDB: Cannot open table test/t[cdzp] from the internal data dictionary of InnoDB");
call mtr.add_suppression("InnoDB: Error: table 'test/t[cdzp]'");
FLUSH TABLES;
--enable_query_log
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let MYSQLD_DATADIR=`select @@datadir`;
let bugdir= $MYSQLTEST_VARDIR/tmp/table_flags;
--mkdir $bugdir
--let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err
--let $d=--innodb-data-home-dir=$bugdir --innodb-log-group-home-dir=$bugdir
--let $d=$d --innodb-data-file-path=ibdata1:10M:autoextend
--let $d=$d --innodb-undo-tablespaces=0
--let $restart_parameters=$d --innodb-stats-persistent=0 --innodb-file-format=1
--source include/restart_mysqld.inc
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE tr(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
CREATE TABLE tc(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPACT;
CREATE TABLE td(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
CREATE TABLE tz(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPRESSED
KEY_BLOCK_SIZE=1;
# PAGE_COMPRESSED is supported starting with MariaDB 10.1.0
--error ER_UNKNOWN_OPTION
CREATE TABLE tp(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
CREATE TABLE tp(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
--source include/shutdown_mysqld.inc
--perl
use strict;
my $ps= $ENV{INNODB_PAGE_SIZE};
my $file= "$ENV{bugdir}/ibdata1";
open(FILE, "+<", $file) || die "Unable to open $file\n";
# Read DICT_HDR_TABLES, the root page number of CLUST_IND (SYS_TABLES.NAME).
sysseek(FILE, 7*$ps+38+32, 0) || die "Unable to seek $file";
die "Unable to read $file" unless sysread(FILE, $_, 4) == 4;
my $sys_tables_root = unpack("N", $_);
my $page;
print "SYS_TABLES clustered index root page ($sys_tables_root):\n";
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
open(BACKUP, ">$ENV{bugdir}/sys_tables.bin") || die "Unable to open backup\n";
syswrite(BACKUP, $page, $ps)==$ps || die "Unable to write backup\n";
close(BACKUP) || die "Unable to close backup\n";
print "N_RECS=", unpack("n", substr($page,38+16,2));
print "; LEVEL=", unpack("n", substr($page,38+26,2));
print "; INDEX_ID=0x", unpack("H*", substr($page,38+28,8)), "\n";
my @fields=("NAME","DB_TRX_ID","DB_ROLL_PTR",
"ID","N_COLS","TYPE","MIX_ID","MIX_LEN","CLUSTER_NAME","SPACE");
for (my $offset= 0x65; $offset;
$offset= unpack("n", substr($page,$offset-2,2)))
{
print "header=0x", unpack("H*",substr($page,$offset-6,6)), " (";
my $n_fields= unpack("n", substr($page,$offset-4,2)) >> 1 & 0x3ff;
my $start= 0;
my $name;
for (my $i= 0; $i < $n_fields; $i++) {
my $end= unpack("C", substr($page, $offset-7-$i, 1));
print ",\n " if $i;
print "$fields[$i]=";
if ($end & 0x80) {
print "NULL(", ($end & 0x7f) - $start, " bytes)"
} elsif ($n_fields > 1 && $i == 0) {
$name= substr($page,$offset+$start,$end-$start);
print "'$name'"
} else {
print "0x", unpack("H*", substr($page,$offset+$start,$end-$start))
}
# Corrupt SYS_TABLES.TYPE
if ($i == 5)
{
my $flags= 0;
if ($name eq 'test/tr') {
# $flags= 0x40 # DATA_DIR mismatch causes 10.0 crash!
} elsif ($name eq 'test/tc') {
$flags= 0x80 # 10.1 PAGE_COMPRESSED
} elsif ($name eq 'test/td') {
$flags= 0xf00 # 10.1 PAGE_COMPRESSION_LEVEL=15 (0..9 is valid)
} elsif ($name eq 'test/tz') {
$flags= 0x3000 # 10.1 ATOMIC_WRITES=3 (0..2 is valid)
} elsif ($name eq 'test/tp') {
$flags= 0x880 # 10.1 PAGE_COMPRESSED, PAGE_COMPRESSION_LEVEL=8
# (in 10.1, this leaves PAGE_COMPRESSION_LEVEL=1
# without PAGE_COMPRESSED, which should be invalid)
}
substr($page,$offset+$start,$end-$start)= pack(
"N", $flags ^
unpack("N", substr($page,$offset+$start,$end-$start)))
if $flags;
}
# Corrupt SYS_TABLES.MIX_LEN (ignored for ROW_FORMAT=REDUNDANT)
if ($i == 7 && $name eq 'test/tr')
{
substr($page,$offset+$start,$end-$start)= chr(255) x 4;
}
$start= $end & 0x7f;
}
print ")\n";
}
substr($page,0,4)=pack("N",0xdeadbeef);
substr($page,$ps-8,4)=pack("N",0xdeadbeef);
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file\n";
EOF
--source include/start_mysqld.inc
SHOW CREATE TABLE tr;
INSERT INTO tr VALUES(42);
--error ER_NO_SUCH_TABLE_IN_ENGINE
SHOW CREATE TABLE tc;
--error ER_NO_SUCH_TABLE_IN_ENGINE
SHOW CREATE TABLE td;
--error ER_NO_SUCH_TABLE_IN_ENGINE
SHOW CREATE TABLE tz;
--error ER_NO_SUCH_TABLE_IN_ENGINE
SHOW CREATE TABLE tp;
--source include/shutdown_mysqld.inc
let SEARCH_RANGE= -50000;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--let SEARCH_PATTERN= InnoDB: Table '.test.\..t[cdzp].' in InnoDB data dictionary has unknown type (81|f21|8a1|3023)
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= InnoDB: Cannot open table test/t[cdzp] from the internal data dictionary of InnoDB
--source include/search_pattern_in_file.inc
# Restore the backup of the corrupted SYS_TABLES clustered index root page
--perl
use strict;
my $ps= $ENV{INNODB_PAGE_SIZE};
my $file= "$ENV{bugdir}/ibdata1";
open(FILE, "+<", $file) || die "Unable to open $file\n";
open(BACKUP, "<$ENV{bugdir}/sys_tables.bin") || die "Unable to open backup\n";
# Read DICT_HDR_TABLES, the root page number of CLUST_IND (SYS_TABLES.NAME).
sysseek(FILE, 7*$ps+38+32, 0) || die "Unable to seek $file";
die "Unable to read $file\n" unless sysread(FILE, $_, 4) == 4;
my $sys_tables_root = unpack("N", $_);
print "Restoring SYS_TABLES clustered index root page ($sys_tables_root)\n";
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
die "Unable to read backup\n" unless sysread(BACKUP, $_, $ps) == $ps;
die "Unable to restore backup\n" unless syswrite(FILE, $_, $ps) == $ps;
close(BACKUP);
close(FILE) || die "Unable to close $file\n";
EOF
--source include/start_mysqld.inc
SHOW CREATE TABLE tr;
SHOW CREATE TABLE tc;
SHOW CREATE TABLE td;
SHOW CREATE TABLE tz;
SHOW CREATE TABLE tp;
BEGIN;
INSERT INTO tr VALUES(1);
INSERT INTO tc VALUES(1);
INSERT INTO td VALUES(1);
INSERT INTO tz VALUES(1);
INSERT INTO tp VALUES(1);
ROLLBACK;
SELECT * FROM tr;
SELECT * FROM tc;
SELECT * FROM td;
SELECT * FROM tz;
SELECT * FROM tp;
DROP TABLE tr,tc,td,tz,tp;
--source include/shutdown_mysqld.inc
--let $restart_parameters=
--source include/start_mysqld.inc
--list_files $bugdir
--remove_files_wildcard $bugdir
--rmdir $bugdir

View File

@ -1,4 +1,3 @@
DROP DATABASE IF EXISTS mysqltest_innodb_zip;
CREATE DATABASE mysqltest_innodb_zip; CREATE DATABASE mysqltest_innodb_zip;
USE mysqltest_innodb_zip; USE mysqltest_innodb_zip;
SELECT table_name, row_format, data_length, index_length SELECT table_name, row_format, data_length, index_length
@ -379,5 +378,4 @@ select @@innodb_file_format_max;
@@innodb_file_format_max @@innodb_file_format_max
Barracuda Barracuda
drop table normal_table, zip_table; drop table normal_table, zip_table;
USE test;
DROP DATABASE mysqltest_innodb_zip; DROP DATABASE mysqltest_innodb_zip;

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size_small.inc
# Tests for various combinations of ROW_FORMAT and KEY_BLOCK_SIZE # Tests for various combinations of ROW_FORMAT and KEY_BLOCK_SIZE
# Related bugs; # Related bugs;
# Bug#54679: ALTER TABLE causes compressed row_format to revert to compact # Bug#54679: ALTER TABLE causes compressed row_format to revert to compact

View File

@ -1,9 +1,4 @@
-- source include/have_innodb.inc --source include/innodb_page_size_small.inc
--disable_warnings
DROP DATABASE IF EXISTS mysqltest_innodb_zip;
--enable_warnings
CREATE DATABASE mysqltest_innodb_zip; CREATE DATABASE mysqltest_innodb_zip;
USE mysqltest_innodb_zip; USE mysqltest_innodb_zip;
@ -13,7 +8,6 @@ SELECT table_name, row_format, data_length, index_length
let $per_table=`select @@innodb_file_per_table`; let $per_table=`select @@innodb_file_per_table`;
let $format=`select @@innodb_file_format`; let $format=`select @@innodb_file_format`;
let $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`;
let $innodb_file_format_orig=`select @@innodb_file_format`; let $innodb_file_format_orig=`select @@innodb_file_format`;
let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; let $innodb_file_format_max_orig=`select @@innodb_file_format_max`;
SET @save_innodb_stats_on_metadata=@@global.innodb_stats_on_metadata; SET @save_innodb_stats_on_metadata=@@global.innodb_stats_on_metadata;
@ -363,12 +357,9 @@ drop table normal_table, zip_table;
-- disable_query_log -- disable_query_log
eval set global innodb_file_format=$format; eval set global innodb_file_format=$format;
eval set global innodb_file_per_table=$per_table; eval set global innodb_file_per_table=$per_table;
eval set session innodb_strict_mode=$innodb_strict_mode_orig;
eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; eval SET GLOBAL innodb_file_format=$innodb_file_format_orig;
eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig;
SET @@global.innodb_stats_on_metadata=@save_innodb_stats_on_metadata; SET @@global.innodb_stats_on_metadata=@save_innodb_stats_on_metadata;
--enable_query_log --enable_query_log
USE test;
DROP DATABASE mysqltest_innodb_zip; DROP DATABASE mysqltest_innodb_zip;

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size_small.inc
# #
# Bug#36169 create innodb compressed table with too large row size crashed # Bug#36169 create innodb compressed table with too large row size crashed
# http://bugs.mysql.com/36169 # http://bugs.mysql.com/36169

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size_small.inc
# #
# Test case for bug 36172 # Test case for bug 36172
# #

View File

@ -1,4 +1,4 @@
-- source include/have_innodb.inc --source include/innodb_page_size_small.inc
let $file_format=`select @@innodb_file_format`; let $file_format=`select @@innodb_file_format`;
let $file_per_table=`select @@innodb_file_per_table`; let $file_per_table=`select @@innodb_file_per_table`;

View File

@ -1,4 +1,4 @@
-- source include/have_innodb.inc --source include/innodb_page_size_small.inc
let $file_format=`select @@innodb_file_format`; let $file_format=`select @@innodb_file_format`;
let $file_per_table=`select @@innodb_file_per_table`; let $file_per_table=`select @@innodb_file_per_table`;

View File

@ -1,4 +1,4 @@
--source include/have_innodb.inc --source include/innodb_page_size_small.inc
# #
# Bug #56680 InnoDB may return wrong results from a case-insensitive index # Bug #56680 InnoDB may return wrong results from a case-insensitive index
# #

View File

@ -0,0 +1,37 @@
set names utf8;
create database mysqltest1;
select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'mysqltest1';
database_name table_name length(table_name)
CREATE TABLE mysqltest1.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
Warnings:
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'mysqltest1';
database_name table_name length(table_name)
CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
ERROR HY000: The path specified for @0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@ is too long.
drop database mysqltest1;

View File

@ -0,0 +1,6 @@
set sql_mode=ansi_quotes;
create table t1 (i int) partition by range (i) (partition flush values less than maxvalue);
set sql_mode=default;
lock tables t1 read local;
unlock tables;
drop table t1;

View File

@ -0,0 +1,32 @@
source include/have_innodb.inc;
source include/have_partition.inc;
set names utf8;
create database mysqltest1;
select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'mysqltest1';
CREATE TABLE mysqltest1.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'mysqltest1';
--error ER_PATH_LENGTH
CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
drop database mysqltest1;

View File

@ -0,0 +1,10 @@
#
# MDEV-13017 LOCK TABLE fails with irrelevant error while working with tables affected by ANSI_QUOTES
#
--source include/have_partition.inc
set sql_mode=ansi_quotes;
create table t1 (i int) partition by range (i) (partition flush values less than maxvalue);
set sql_mode=default;
lock tables t1 read local;
unlock tables;
drop table t1;

View File

@ -333,4 +333,3 @@ UPDATE performance_schema.setup_consumers SET enabled = 'YES';
UPDATE performance_schema.setup_timers SET timer_name = 'MICROSECOND' where name="idle"; UPDATE performance_schema.setup_timers SET timer_name = 'MICROSECOND' where name="idle";
UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="stage"; UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="stage";
UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="statement"; UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="statement";

View File

@ -0,0 +1,103 @@
CREATE USER has_role@'localhost';
GRANT ALL PRIVILEGES ON *.* TO has_role@'localhost';
CREATE ROLE test_role;
GRANT test_role TO has_role@'localhost';
CREATE USER no_role@'localhost';
GRANT ALL PRIVILEGES ON *.* TO no_role@'localhost';
CREATE TABLE view_role_test (
id int primary key,
role_name varchar(50)
);
INSERT INTO view_role_test VALUES (1, 'test_role');
#
# Use the same logic for stored procedures.
#
PREPARE prepared_no_current_role FROM "SELECT * from view_role_test WHERE role_name = CURRENT_ROLE()";
#
# Creating a view with no CURRENT_ROLE() set and one with CURRENT_ROLE()
# set. Both should produce the same SHOW CREATE VIEW output.
#
CREATE
DEFINER = no_role@localhost
SQL SECURITY INVOKER
VIEW v_view_role_test_no_current_role
AS
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
SHOW CREATE VIEW v_view_role_test_no_current_role;
View Create View character_set_client collation_connection
v_view_role_test_no_current_role CREATE ALGORITHM=UNDEFINED DEFINER=`no_role`@`localhost` SQL SECURITY INVOKER VIEW `v_view_role_test_no_current_role` AS select `view_role_test`.`id` AS `id`,`view_role_test`.`role_name` AS `role_name` from `view_role_test` where (`view_role_test`.`role_name` = current_role()) latin1 latin1_swedish_ci
#
# No values should be returned
#
EXECUTE prepared_no_current_role;
id role_name
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
id role_name
SELECT * FROM v_view_role_test_no_current_role;
id role_name
#
# Now let's set the role. Create identical views as before. See if
# their behaviour is different. It should not be.
#
SET ROLE test_role;
SELECT CURRENT_USER();
CURRENT_USER()
root@localhost
SELECT CURRENT_ROLE();
CURRENT_ROLE()
test_role
#
# Create the VIEW and prepared Statement with a CURRENT_ROLE() set.
#
CREATE
DEFINER = no_role@localhost
SQL SECURITY INVOKER
VIEW v_view_role_test_with_current_role
AS
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
PREPARE prepared_with_current_role FROM "SELECT * from view_role_test WHERE role_name = CURRENT_ROLE()";
SHOW CREATE VIEW v_view_role_test_with_current_role;
View Create View character_set_client collation_connection
v_view_role_test_with_current_role CREATE ALGORITHM=UNDEFINED DEFINER=`no_role`@`localhost` SQL SECURITY INVOKER VIEW `v_view_role_test_with_current_role` AS select `view_role_test`.`id` AS `id`,`view_role_test`.`role_name` AS `role_name` from `view_role_test` where (`view_role_test`.`role_name` = current_role()) latin1 latin1_swedish_ci
#
# Values should be returned for all select statements as we do have
# a CURRENT_ROLE() active;
#
EXECUTE prepared_no_current_role;
id role_name
1 test_role
EXECUTE prepared_with_current_role;
id role_name
1 test_role
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
id role_name
1 test_role
SELECT * FROM v_view_role_test_no_current_role;
id role_name
1 test_role
SELECT * FROM v_view_role_test_with_current_role;
id role_name
1 test_role
SET ROLE NONE;
#
# No values should be returned for all select statements as we do not have
# a CURRENT_ROLE() active;
#
EXECUTE prepared_no_current_role;
id role_name
EXECUTE prepared_with_current_role;
id role_name
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
id role_name
SELECT * FROM v_view_role_test_no_current_role;
id role_name
SELECT * FROM v_view_role_test_with_current_role;
id role_name
DROP USER has_role@'localhost';
DROP USER no_role@'localhost';
DROP ROLE test_role;
DROP table view_role_test;
DROP VIEW v_view_role_test_no_current_role;
DROP VIEW v_view_role_test_with_current_role;
DROP PREPARE prepared_no_current_role;
DROP PREPARE prepared_with_current_role;

View File

@ -0,0 +1,102 @@
#
# MDEV-12666 CURRENT_ROLE() does not work in a view
#
--source include/not_embedded.inc
CREATE USER has_role@'localhost';
GRANT ALL PRIVILEGES ON *.* TO has_role@'localhost';
CREATE ROLE test_role;
GRANT test_role TO has_role@'localhost';
CREATE USER no_role@'localhost';
GRANT ALL PRIVILEGES ON *.* TO no_role@'localhost';
CREATE TABLE view_role_test (
id int primary key,
role_name varchar(50)
);
INSERT INTO view_role_test VALUES (1, 'test_role');
--echo #
--echo # Use the same logic for stored procedures.
--echo #
PREPARE prepared_no_current_role FROM "SELECT * from view_role_test WHERE role_name = CURRENT_ROLE()";
--echo #
--echo # Creating a view with no CURRENT_ROLE() set and one with CURRENT_ROLE()
--echo # set. Both should produce the same SHOW CREATE VIEW output.
--echo #
CREATE
DEFINER = no_role@localhost
SQL SECURITY INVOKER
VIEW v_view_role_test_no_current_role
AS
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
SHOW CREATE VIEW v_view_role_test_no_current_role;
--echo #
--echo # No values should be returned
--echo #
EXECUTE prepared_no_current_role;
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
SELECT * FROM v_view_role_test_no_current_role;
--echo #
--echo # Now let's set the role. Create identical views as before. See if
--echo # their behaviour is different. It should not be.
--echo #
SET ROLE test_role;
SELECT CURRENT_USER();
SELECT CURRENT_ROLE();
--echo #
--echo # Create the VIEW and prepared Statement with a CURRENT_ROLE() set.
--echo #
CREATE
DEFINER = no_role@localhost
SQL SECURITY INVOKER
VIEW v_view_role_test_with_current_role
AS
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
PREPARE prepared_with_current_role FROM "SELECT * from view_role_test WHERE role_name = CURRENT_ROLE()";
SHOW CREATE VIEW v_view_role_test_with_current_role;
--echo #
--echo # Values should be returned for all select statements as we do have
--echo # a CURRENT_ROLE() active;
--echo #
EXECUTE prepared_no_current_role;
EXECUTE prepared_with_current_role;
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
SELECT * FROM v_view_role_test_no_current_role;
SELECT * FROM v_view_role_test_with_current_role;
SET ROLE NONE;
--echo #
--echo # No values should be returned for all select statements as we do not have
--echo # a CURRENT_ROLE() active;
--echo #
EXECUTE prepared_no_current_role;
EXECUTE prepared_with_current_role;
SELECT * FROM view_role_test WHERE role_name = CURRENT_ROLE();
SELECT * FROM v_view_role_test_no_current_role;
SELECT * FROM v_view_role_test_with_current_role;
DROP USER has_role@'localhost';
DROP USER no_role@'localhost';
DROP ROLE test_role;
DROP table view_role_test;
DROP VIEW v_view_role_test_no_current_role;
DROP VIEW v_view_role_test_with_current_role;
DROP PREPARE prepared_no_current_role;
DROP PREPARE prepared_with_current_role;

View File

@ -0,0 +1,65 @@
drop database if exists db;
Warnings:
Note 1008 Can't drop database 'db'; database doesn't exist
create role r1;
create user beep@'%';
create database db;
create table db.t1 (i int);
create table db.t2 (b int);
grant select on db.* to r1;
grant r1 to beep@'%';
show databases;
Database
information_schema
test
show create database db;
ERROR 42000: Access denied for user 'beep'@'localhost' to database 'db'
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
table_schema table_name
set role r1;
show databases;
Database
db
information_schema
test
show create database db;
Database Create Database
db CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 */
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
table_schema table_name
db t1
db t2
create role r2;
create user beep2@'%';
grant update on db.* to r2;
grant r2 to beep2;
show databases;
Database
information_schema
test
show create database db;
ERROR 42000: Access denied for user 'beep2'@'localhost' to database 'db'
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
table_schema table_name
set role r2;
show databases;
Database
db
information_schema
test
show create database db;
Database Create Database
db CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 */
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
table_schema table_name
db t1
db t2
drop database db;
drop role r1;
drop user beep;
drop role r2;
drop user beep2;

View File

@ -0,0 +1,55 @@
source include/not_embedded.inc;
drop database if exists db;
create role r1;
create user beep@'%';
create database db;
create table db.t1 (i int);
create table db.t2 (b int);
grant select on db.* to r1;
grant r1 to beep@'%';
--connect (con1,localhost,beep,,)
show databases;
--error ER_DBACCESS_DENIED_ERROR
show create database db;
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
set role r1;
show databases;
show create database db;
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
connection default;
create role r2;
create user beep2@'%';
grant update on db.* to r2;
grant r2 to beep2;
--connect (con2,localhost,beep2,,)
show databases;
--error ER_DBACCESS_DENIED_ERROR
show create database db;
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
set role r2;
show databases;
show create database db;
select table_schema, table_name from information_schema.tables
where table_schema = 'db';
connection default;
drop database db;
drop role r1;
drop user beep;
drop role r2;
drop user beep2;

View File

@ -0,0 +1,30 @@
include/rpl_init.inc [topology=1->2->1]
include/rpl_connect.inc [creating M4]
include/rpl_connect.inc [creating M2]
SET @old_debug= @@global.debug;
STOP SLAVE;
SET GLOBAL debug_dbug= "+d,dbug.rows_events_to_delay_relay_logging";
START SLAVE IO_THREAD;
include/wait_for_slave_io_to_start.inc
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(30000)) ENGINE=innodb;
INSERT INTO `t1` VALUES (null, repeat('a', 1024)), (null, repeat('b', 1024));
SET debug_sync='now WAIT_FOR start_sql_thread';
START SLAVE SQL_THREAD;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Gtid # # GTID #-#-#
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(30000)) ENGINE=innodb
SET debug_sync='now SIGNAL go_on_relay_logging';
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Gtid # # GTID #-#-#
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(30000)) ENGINE=innodb
slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
slave-bin.000001 # Table_map # # table_id: # (test.t1)
slave-bin.000001 # Write_rows_v1 # # table_id: #
slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
slave-bin.000001 # Xid # # COMMIT /* XID */
drop table t1;
SET GLOBAL debug_dbug= @old_debug;
SET debug_sync='RESET';
include/rpl_end.inc

View File

@ -0,0 +1,29 @@
include/master-slave.inc
[connection master]
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 (c1) VALUES (1);
include/stop_slave_sql.inc
FLUSH LOGS;
FLUSH LOGS;
INSERT INTO t1 (c1) VALUES (2);
include/sync_slave_io_with_master.inc
call mtr.add_suppression("File '.*slave-relay-bin.");
call mtr.add_suppression("Could not open log file");
call mtr.add_suppression("Failed to open the relay log");
call mtr.add_suppression("Failed to initialize the master info structure");
include/rpl_stop_server.inc [server_number=2]
# Removing file(s)
include/rpl_start_server.inc [server_number=2]
START SLAVE;
ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
START SLAVE;
ERROR HY000: Could not initialize master info structure for ''; more error messages can be found in the MariaDB error log
RESET SLAVE;
DROP TABLE t1;
START SLAVE UNTIL MASTER_LOG_FILE= 'MASTER_LOG_FILE', MASTER_LOG_POS= MASTER_LOG_POS;;
include/wait_for_slave_sql_to_stop.inc
include/stop_slave_io.inc
include/start_slave.inc
include/diff_tables.inc [master:t1, slave:t1]
DROP TABLE t1;
include/rpl_end.inc

View File

@ -0,0 +1,30 @@
!include ../my.cnf
[mysqld.1]
gtid-domain-id=4
server-id=4
#
log-slave-updates
slave-parallel-threads=0
gtid-strict-mode=1
gtid-ignore-duplicates=1
#
# Max-size row events to minimum with the idea to create
# a number of Rows_log_event per Query.
#
binlog-row-event-max-size=1024
[mysqld.2]
gtid-domain-id=2
server-id=2
#
log-slave-updates
slave-parallel-threads=0
gtid-strict-mode=1
gtid-ignore-duplicates=1
binlog-row-event-max-size=1024
# The slave will be initialized with a @@global.dbug-var value
skip-slave-start=1

View File

@ -0,0 +1,104 @@
#
# Testing chain/circular replication scenario of MDEV-9670
# The effect of the bug was that we got a commit with a GTID with server_id
#
--source include/have_binlog_format_row.inc
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--let $rpl_topology= 1->2->1
--source include/rpl_init.inc
--let $rpl_connection_name= M4
--let $rpl_server_number= 1
--source include/rpl_connect.inc
--let $rpl_connection_name= M2
--let $rpl_server_number= 2
--source include/rpl_connect.inc
# The parameter reflects binlog-row-event-max-size @cnf.
--let $row_size=1024
SET @old_debug= @@global.debug;
--connection M2
STOP SLAVE;
SET GLOBAL debug_dbug= "+d,dbug.rows_events_to_delay_relay_logging";
START SLAVE IO_THREAD;
--source include/wait_for_slave_io_to_start.inc
--connection M2
# This query also creates a Gtid event group whose Gtid will remain in
# ignored status for too long causing a following group split.
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(30000)) ENGINE=innodb;
--sync_slave_with_master M4
# This INSERT will be logged as two Write_log events which the buggy
# slave applier would split.
--connection M4
eval INSERT INTO `t1` VALUES (null, repeat('a', $row_size)), (null, repeat('b', $row_size));
# START M2 IO thread and wait for its signal to follow with the SQL
# thread start. At this moment the SQL thread shall be having 2 and
# "half" groups to execute. The "hafl" one would be committed by the
# buggy applier after which the IO is released to queue the rest of
# the 3rd group which the SQL thread commits separately to complete
# the split.
--connection M2
# wait for IO signal to start the SQL thread. IO will be hanging upon that.
SET debug_sync='now WAIT_FOR start_sql_thread';
# Now the slave server has relay log whose last group is incomplete.
# An unfixed slave server would go to "insert" a "fake"
# Gtid_list_log_event event which actually would commit the incomplete
# group. However before to actual commit do_apply_event() hits some assert.
# In the fixed server the fake Gtid_list_log_event is *not* inserted
# in the middle of a group.
START SLAVE SQL_THREAD;
# Sleep for a little time to give SQL thread a chance to commit while
# the IO thread is hanging (see
# DBUG_EXECUTE_IF("dbug.rows_events_to_delay_relay_logging"...) in
# queue_event). Alternatively to reproduce the case when buggy slave
# wait for the 1st group commit
#--let $count= 1
#--let $table= t1
#--source include/wait_until_rows_count.inc
--sleep 2
# Demonstrate either no split group in the correct slave or the 1nd
# group in the buggy one
--source include/show_binlog_events.inc
# Release the IO thread
SET debug_sync='now SIGNAL go_on_relay_logging';
# Sync servers
--sync_slave_with_master M4
--connection M4
--sync_slave_with_master M2
--connection M2
# Demonstrate replication goes correctly not to create any split, or
# the 2nd group in the buggy slave
--source include/show_binlog_events.inc
#
# Cleanup
#
--connection M4
drop table t1;
--connection M2
SET GLOBAL debug_dbug= @old_debug;
SET debug_sync='RESET';
--source include/rpl_end.inc

View File

@ -0,0 +1,91 @@
###############################################################################
# Bug#24901077: RESET SLAVE ALL DOES NOT ALWAYS RESET SLAVE
#
# Problem:
# =======
# If you have a relay log index file that has ended up with
# some relay log files that do not exists, then RESET SLAVE
# ALL is not enough to get back to a clean state.
###############################################################################
# Remove all slave-relay-bin.0* files (do not remove slave-relay-bin.index)
# During server restart rli initialization will fail as there are no
# relay logs. In case of bug RESET SLAVE will not do the required clean up
# as rli is not inited and subsequent START SLAVE will fail.
# Disable "Warning 1612 Being purged log ./slave-relay-bin.0* was not found"
# because it is different on Unix and Windows systems.
--source include/have_binlog_format_mixed.inc
--source include/master-slave.inc
--connection master
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 (c1) VALUES (1);
--sync_slave_with_master
--connection slave
--source include/stop_slave_sql.inc
--let $MYSQLD_SLAVE_DATADIR= `select @@datadir`
--connection master
# Generate more relay logs on slave.
FLUSH LOGS;
FLUSH LOGS;
INSERT INTO t1 (c1) VALUES (2);
--source include/sync_slave_io_with_master.inc
call mtr.add_suppression("File '.*slave-relay-bin.");
call mtr.add_suppression("Could not open log file");
call mtr.add_suppression("Failed to open the relay log");
call mtr.add_suppression("Failed to initialize the master info structure");
# Stop slave
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc
# Delete file(s)
--echo # Removing $remove_pattern file(s)
--let $remove_pattern= slave-relay-bin.0*
--remove_files_wildcard $MYSQLD_SLAVE_DATADIR $remove_pattern
# Start slave
--let $rpl_server_number= 2
--source include/rpl_start_server.inc
# Start slave must fail because of the removed file(s).
--error ER_MASTER_INFO
START SLAVE;
# Try a second time, it must fail again.
--error ER_MASTER_INFO
START SLAVE;
# Retrieve master executed position before reset slave.
--let $master_exec_file= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1)
--let $master_exec_pos= query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1)
# Reset slave.
# Disable "Warning 1612 Being purged log ./slave-relay-bin.0* was not found"
# because it is different on Unix and Windows systems.
--disable_warnings
RESET SLAVE;
--enable_warnings
DROP TABLE t1;
--replace_result $master_exec_file MASTER_LOG_FILE $master_exec_pos MASTER_LOG_POS
--eval START SLAVE UNTIL MASTER_LOG_FILE= '$master_exec_file', MASTER_LOG_POS= $master_exec_pos;
--source include/wait_for_slave_sql_to_stop.inc
--source include/stop_slave_io.inc
# Start slave.
--source include/start_slave.inc
--connection master
--sync_slave_with_master
# Check consistency.
--let $diff_tables= master:t1, slave:t1
--source include/diff_tables.inc
# Cleanup
--connection master
DROP TABLE t1;
--sync_slave_with_master
--source include/rpl_end.inc

View File

@ -350,8 +350,8 @@ fid IsClosed(g)
116 0 116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon; SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g)) fid AsText(Centroid(g))
117 POINT(55.58852775304245 17.426536064113982) 117 POINT(57.98031067576927 17.854754130800433)
118 POINT(55.58852775304245 17.426536064113982) 118 POINT(57.98031067576927 17.854754130800433)
119 POINT(2 2) 119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon; SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g) fid Area(g)

View File

@ -350,8 +350,8 @@ fid IsClosed(g)
116 0 116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon; SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g)) fid AsText(Centroid(g))
117 POINT(55.58852775304245 17.426536064113982) 117 POINT(57.98031067576927 17.854754130800433)
118 POINT(55.58852775304245 17.426536064113982) 118 POINT(57.98031067576927 17.854754130800433)
119 POINT(2 2) 119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon; SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g) fid Area(g)
@ -1050,8 +1050,8 @@ fid IsClosed(g)
116 0 116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon; SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g)) fid AsText(Centroid(g))
117 POINT(55.58852775304245 17.426536064113982) 117 POINT(57.98031067576927 17.854754130800433)
118 POINT(55.58852775304245 17.426536064113982) 118 POINT(57.98031067576927 17.854754130800433)
119 POINT(2 2) 119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon; SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g) fid Area(g)

View File

@ -1,4 +1,4 @@
SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner; SET GLOBAL innodb_sched_priority_cleaner=39;
SELECT @@GLOBAL.innodb_sched_priority_cleaner; SELECT @@GLOBAL.innodb_sched_priority_cleaner;
@@GLOBAL.innodb_sched_priority_cleaner @@GLOBAL.innodb_sched_priority_cleaner
19 19

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