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

Merge branch '10.2' into 10.2-mdev9864

This commit is contained in:
Galina Shalygina
2016-05-08 23:04:41 +03:00
parent e09b1f2a22
commit be1d06c8a5
380 changed files with 21974 additions and 6245 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@ Docs/INFO_SRC
Makefile
TAGS
Testing/
tmp/
VERSION.dep
configure
client/async_example

View File

@ -703,7 +703,7 @@ public:
DBUG_ASSERT(ds->str);
#ifdef EXTRA_DEBUG
DBUG_PRINT("QQ", ("str: %*s", (int) ds->length, ds->str));
DBUG_PRINT("extra", ("str: %*s", (int) ds->length, ds->str));
#endif
if (fwrite(ds->str, 1, ds->length, m_file) != ds->length)

View File

@ -189,6 +189,7 @@
#cmakedefine HAVE_PREAD 1
#cmakedefine HAVE_PAUSE_INSTRUCTION 1
#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
#cmakedefine HAVE_HMT_PRIORITY_INSTRUCTION 1
#cmakedefine HAVE_RDTSCLL 1
#cmakedefine HAVE_READ_REAL_TIME 1
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1

View File

@ -784,6 +784,17 @@ IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC)
}
" HAVE_FAKE_PAUSE_INSTRUCTION)
ENDIF()
IF (NOT HAVE_PAUSE_INSTRUCTION)
CHECK_C_SOURCE_COMPILES("
#include <sys/platform/ppc.h>
int main()
{
__ppc_set_ppr_low();
__ppc_set_ppr_med();
return 0;
}
" HAVE_HMT_PRIORITY_INSTRUCTION)
ENDIF()
ENDIF()
CHECK_SYMBOL_EXISTS(tcgetattr "termios.h" HAVE_TCGETATTR 1)

View File

@ -32,9 +32,11 @@
#include <my_getopt.h>
#include <my_dir.h>
#define MAX_ROWS 2000
#define MAX_ROWS 3000
#define ERRORS_PER_RANGE 1000
#define MAX_SECTIONS 4
#define HEADER_LENGTH 32 /* Length of header in errmsg.sys */
#define ERRMSG_VERSION 3 /* Version number of errmsg.sys */
#define ERRMSG_VERSION 4 /* Version number of errmsg.sys */
#define DEFAULT_CHARSET_DIR "../sql/share/charsets"
#define ER_PREFIX "ER_"
#define ER_PREFIX2 "MARIA_ER_"
@ -53,6 +55,8 @@ static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace";
uchar file_head[]= { 254, 254, 2, ERRMSG_VERSION };
/* Store positions to each error message row to store in errmsg.sys header */
uint file_pos[MAX_ROWS+1];
uint section_count,section_start;
uchar section_header[MAX_SECTIONS*2];
const char *empty_string= ""; /* For empty states */
/*
@ -131,7 +135,7 @@ static struct my_option my_long_options[]=
};
static struct errors *generate_empty_message(uint dcode);
static struct errors *generate_empty_message(uint dcode, my_bool skip);
static struct languages *parse_charset_string(char *str);
static struct errors *parse_error_string(char *ptr, int er_count);
static struct message *parse_message_string(struct message *new_message,
@ -140,8 +144,9 @@ static struct message *find_message(struct errors *err, const char *lang,
my_bool no_default);
static int check_message_format(struct errors *err,
const char* mess);
static int parse_input_file(const char *file_name, struct errors **top_error,
struct languages **top_language);
static uint parse_input_file(const char *file_name, struct errors **top_error,
struct languages **top_language,
uint *error_count);
static int get_options(int *argc, char ***argv);
static void print_version(void);
static void usage(void);
@ -158,14 +163,15 @@ static char *find_end_of_word(char *str);
static void clean_up(struct languages *lang_head, struct errors *error_head);
static int create_header_files(struct errors *error_head);
static int create_sys_files(struct languages *lang_head,
struct errors *error_head, uint row_count);
struct errors *error_head, uint max_error,
uint error_count);
int main(int argc, char *argv[])
{
MY_INIT(argv[0]);
{
uint row_count;
uint max_error, error_count;
struct errors *error_head;
struct languages *lang_head;
DBUG_ENTER("main");
@ -173,32 +179,39 @@ int main(int argc, char *argv[])
charsets_dir= DEFAULT_CHARSET_DIR;
my_umask_dir= 0777;
if (get_options(&argc, &argv))
DBUG_RETURN(1);
if (!(row_count= parse_input_file(TXTFILE, &error_head, &lang_head)))
goto err;
if (!(max_error= parse_input_file(TXTFILE, &error_head, &lang_head,
&error_count)))
{
fprintf(stderr, "Failed to parse input file %s\n", TXTFILE);
DBUG_RETURN(1);
goto err;
}
if (lang_head == NULL || error_head == NULL)
{
fprintf(stderr, "Failed to parse input file %s\n", TXTFILE);
DBUG_RETURN(1);
goto err;
}
if (create_header_files(error_head))
{
fprintf(stderr, "Failed to create header files\n");
DBUG_RETURN(1);
goto err;
}
if (create_sys_files(lang_head, error_head, row_count))
if (create_sys_files(lang_head, error_head, max_error, error_count))
{
fprintf(stderr, "Failed to create sys files\n");
DBUG_RETURN(1);
goto err;
}
clean_up(lang_head, error_head);
DBUG_LEAVE; /* Can't use dbug after my_end() */
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 0;
err:
clean_up(lang_head, error_head);
DBUG_LEAVE; /* Can't use dbug after my_end() */
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(1);
}
}
@ -226,6 +239,7 @@ static void print_escaped_string(FILE *f, const char *str)
static int create_header_files(struct errors *error_head)
{
uint er_last= 0;
uint section= 1;
FILE *er_definef, *sql_statef, *er_namef;
struct errors *tmp_error;
struct message *er_msg;
@ -266,8 +280,19 @@ static int create_header_files(struct errors *error_head)
if (!tmp_error->er_name)
continue; /* Placeholder for gap */
if (tmp_error->d_code > current_d_code + 1)
while (tmp_error->d_code > current_d_code + 1)
{
uint next_range= (((current_d_code + ERRORS_PER_RANGE) /
ERRORS_PER_RANGE) * ERRORS_PER_RANGE);
fprintf(er_definef, "#define ER_ERROR_LAST_SECTION_%d %d\n", section,
current_d_code);
fprintf(er_definef, "\n/* New section */\n\n");
fprintf(er_definef, "#define ER_ERROR_FIRST_SECTION_%d %d\n", section+1,
MY_MIN(tmp_error->d_code, next_range));
section++;
current_d_code= MY_MIN(tmp_error->d_code, next_range);
}
current_d_code= tmp_error->d_code;
fprintf(er_definef, "#define %s %u\n", tmp_error->er_name,
@ -297,17 +322,18 @@ static int create_header_files(struct errors *error_head)
static int create_sys_files(struct languages *lang_head,
struct errors *error_head, uint row_count)
struct errors *error_head,
uint max_error,
uint error_count)
{
FILE *to;
uint csnum= 0, length, i, row_nr;
uchar head[32];
uchar head[HEADER_LENGTH];
char outfile[FN_REFLEN], *outfile_end;
long start_pos;
struct message *tmp;
struct languages *tmp_lang;
struct errors *tmp_error;
MY_STAT stat_info;
DBUG_ENTER("create_sys_files");
@ -331,7 +357,7 @@ static int create_sys_files(struct languages *lang_head,
{
if (my_mkdir(outfile, 0777,MYF(0)) < 0)
{
fprintf(stderr, "Can't create output directory for %s\n",
fprintf(stderr, "Can't creqate output directory for %s\n",
outfile);
DBUG_RETURN(1);
}
@ -343,8 +369,8 @@ static int create_sys_files(struct languages *lang_head,
DBUG_RETURN(1);
/* 2 is for 2 bytes to store row position / error message */
start_pos= (long) (HEADER_LENGTH + row_count * 2);
fseek(to, start_pos, 0);
start_pos= (long) (HEADER_LENGTH + (error_count + section_count) * 2);
my_fseek(to, start_pos, 0, MYF(0));
row_nr= 0;
for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
{
@ -358,6 +384,8 @@ static int create_sys_files(struct languages *lang_head,
"language\n", tmp_error->er_name, tmp_lang->lang_short_name);
goto err;
}
if (tmp->text) /* If not skipped row */
{
if (copy_rows(to, tmp->text, row_nr, start_pos))
{
fprintf(stderr, "Failed to copy rows to %s\n", outfile);
@ -365,22 +393,29 @@ static int create_sys_files(struct languages *lang_head,
}
row_nr++;
}
}
DBUG_ASSERT(error_count == row_nr);
/* continue with header of the errmsg.sys file */
length= ftell(to) - HEADER_LENGTH - row_count * 2;
length= (my_ftell(to, MYF(0)) - HEADER_LENGTH -
(error_count + section_count) * 2);
bzero((uchar*) head, HEADER_LENGTH);
bmove((uchar *) head, (uchar *) file_head, 4);
bmove((uchar*) head, (uchar*) file_head, 4);
head[4]= 1;
int4store(head + 6, length);
int2store(head + 10, row_count);
int2store(head + 10, max_error); /* Max error */
int2store(head + 12, row_nr);
int2store(head + 14, section_count);
head[30]= csnum;
my_fseek(to, 0l, MY_SEEK_SET, MYF(0));
if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP)))
if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP)) ||
my_fwrite(to, (uchar*) section_header, section_count*2,
MYF(MY_WME | MY_FNABP)))
goto err;
file_pos[row_count]= (ftell(to) - start_pos);
for (i= 0; i < row_count; i++)
file_pos[row_nr]= (ftell(to) - start_pos);
for (i= 0; i < row_nr; i++)
{
/* Store length of each string */
int2store(head, file_pos[i+1] - file_pos[i]);
@ -437,24 +472,29 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
}
static int parse_input_file(const char *file_name, struct errors **top_error,
struct languages **top_lang)
static uint parse_input_file(const char *file_name, struct errors **top_error,
struct languages **top_lang, uint *error_count)
{
FILE *file;
char *str, buff[1000];
struct errors *current_error= 0, **tail_error= top_error;
struct message current_message;
uint rcount= 0;
uint rcount= 0, skiped_errors= 0;
my_bool er_offset_found= 0;
DBUG_ENTER("parse_input_file");
*top_error= 0;
*top_lang= 0;
*error_count= 0;
section_start= er_offset;
section_count= 0;
if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME))))
DBUG_RETURN(0);
while ((str= fgets(buff, sizeof(buff), file)))
{
my_bool skip;
if (is_prefix(str, "language"))
{
if (!(*top_lang= parse_charset_string(str)))
@ -464,18 +504,34 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
}
continue;
}
if (is_prefix(str, "start-error-number"))
skip= 0;
if (is_prefix(str, "start-error-number") ||
(skip= is_prefix(str, "skip-to-error-number")))
{
uint tmp_er_offset;
if (!(tmp_er_offset= parse_error_offset(str)))
{
fprintf(stderr, "Failed to parse the error offset string!\n");
DBUG_RETURN(0);
}
if (skip)
{
if (section_count >= MAX_SECTIONS-1)
{
fprintf(stderr, "Found too many skip-to-error-number entries. "
"We only support %d entries\n", MAX_SECTIONS);
DBUG_RETURN(0);
}
int2store(section_header + section_count*2,
er_offset +rcount - section_start);
section_count++;
section_start= tmp_er_offset;
}
if (!er_offset_found)
{
er_offset_found= 1;
er_offset= tmp_er_offset;
er_offset= section_start= tmp_er_offset;
}
else
{
@ -487,7 +543,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
}
for ( ; er_offset + rcount < tmp_er_offset ; rcount++)
{
current_error= generate_empty_message(er_offset + rcount);
skiped_errors+= skip != 0;
current_error= generate_empty_message(er_offset + rcount, skip);
*tail_error= current_error;
tail_error= &current_error->next_error;
}
@ -559,6 +616,11 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
fprintf(stderr, "Wrong input file format. Stop!\nLine: %s\n", str);
DBUG_RETURN(0);
}
int2store(section_header + section_count*2,
er_offset + rcount - section_start);
section_count++;
*error_count= rcount - skiped_errors;
*tail_error= 0; /* Mark end of list */
my_fclose(file, MYF(0));
@ -887,7 +949,7 @@ static struct message *parse_message_string(struct message *new_message,
}
static struct errors *generate_empty_message(uint d_code)
static struct errors *generate_empty_message(uint d_code, my_bool skip)
{
struct errors *new_error;
struct message message;
@ -896,7 +958,8 @@ static struct errors *generate_empty_message(uint d_code)
if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
MYF(MY_WME))))
return(0);
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1, MYF(0)))
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1,
MYF(0)))
return(0); /* OOM: Fatal error */
new_error->er_name= NULL;
@ -904,8 +967,10 @@ static struct errors *generate_empty_message(uint d_code)
new_error->sql_code1= empty_string;
new_error->sql_code2= empty_string;
message.text= 0; /* If skip set, don't generate a text */
if (!(message.lang_short_name= my_strdup(default_language, MYF(MY_WME))) ||
!(message.text= my_strdup("", MYF(MY_WME))))
(!skip && !(message.text= my_strdup("", MYF(MY_WME)))))
return(0);
/* Can't fail as msg is preallocated */
@ -1071,10 +1136,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__ ((unused)),
switch (optid) {
case 'V':
print_version();
my_end(0);
exit(0);
break;
case '?':
usage();
my_end(0);
exit(0);
break;
case '#':

View File

@ -689,7 +689,7 @@ extern void my_osmaperr(unsigned long last_error);
#endif
extern void init_glob_errs(void);
extern const char** get_global_errmsgs(void);
extern const char** get_global_errmsgs(int nr);
extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
@ -714,9 +714,9 @@ extern void my_printf_error(uint my_err, const char *format,
ATTRIBUTE_FORMAT(printf, 2, 4);
extern void my_printv_error(uint error, const char *format, myf MyFlags,
va_list ap);
extern int my_error_register(const char** (*get_errmsgs) (void),
extern int my_error_register(const char** (*get_errmsgs) (int nr),
uint first, uint last);
extern const char **my_error_unregister(uint first, uint last);
extern my_bool my_error_unregister(uint first, uint last);
extern void my_message(uint my_err, const char *str,myf MyFlags);
extern void my_message_stderr(uint my_err, const char *str, myf MyFlags);
extern my_bool my_init(void);

View File

@ -194,8 +194,10 @@ struct st_mysql_show_var {
enum enum_mysql_show_type type;
};
struct system_status_var;
#define SHOW_VAR_FUNC_BUFF_SIZE (256 * sizeof(void*))
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, void *, enum enum_var_type);
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
/*

View File

@ -281,7 +281,8 @@ struct st_mysql_show_var {
void *value;
enum enum_mysql_show_type type;
};
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type);
struct system_status_var;
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
typedef int (*mysql_var_check_func)(void* thd,

View File

@ -281,7 +281,8 @@ struct st_mysql_show_var {
void *value;
enum enum_mysql_show_type type;
};
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type);
struct system_status_var;
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
typedef int (*mysql_var_check_func)(void* thd,

View File

@ -281,7 +281,8 @@ struct st_mysql_show_var {
void *value;
enum enum_mysql_show_type type;
};
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type);
struct system_status_var;
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
typedef int (*mysql_var_check_func)(void* thd,

View File

@ -281,7 +281,8 @@ struct st_mysql_show_var {
void *value;
enum enum_mysql_show_type type;
};
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type);
struct system_status_var;
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
typedef int (*mysql_var_check_func)(void* thd,

View File

@ -281,7 +281,8 @@ struct st_mysql_show_var {
void *value;
enum enum_mysql_show_type type;
};
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type);
struct system_status_var;
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
typedef int (*mysql_var_check_func)(void* thd,

View File

@ -90,7 +90,7 @@ const char *client_errors[]=
""
};
const char** get_client_errmsgs(void)
const char** get_client_errmsgs(int nr __attribute__((unused)))
{
return client_errors;
}

View File

@ -46,7 +46,7 @@
#endif
#endif
#ifdef alpha_linux_port
#include <asm/ioctls.h> /* QQ; Fix this in configure */
#include <asm/ioctls.h>
#include <asm/termiobits.h>
#endif
#else

View File

@ -109,6 +109,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/table_cache.cc ../sql/mf_iocache_encr.cc
../sql/item_inetfunc.cc
../sql/wsrep_dummy.cc ../sql/encryption.cc
../sql/item_windowfunc.cc ../sql/sql_window.cc
../sql/sql_cte.cc
${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE}

View File

@ -517,6 +517,9 @@ int init_embedded_server(int argc, char **argv, char **groups)
if (my_thread_init())
return 1;
if (init_early_variables())
return 1;
if (argc)
{
argcp= &argc;

View File

@ -0,0 +1,18 @@
# Crash mysqld hard and wait until it's restarted
--source include/have_debug_sync.inc
--source include/not_embedded.inc
# Write file to make mysql-test-run.pl expect crash and restart
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# Setup the mysqld to crash at shutdown
SET debug_dbug="d,crash_shutdown";
--error 2013
shutdown;
# Turn on reconnect
--enable_reconnect
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc

View File

@ -37,12 +37,15 @@ if (!$_galera_port)
if ($galera_debug)
{
--disable_query_log
--echo connect($galera_connection_name,127.0.0.1,root,,test,$_galera_port,)
--enable_query_log
}
# Temporal solution to avoid concurrent IST MDEV-7178
--sleep 1
# Open a connection
--disable_query_log
--connect($galera_connection_name,127.0.0.1,root,,test,$_galera_port,)
--enable_query_log

View File

@ -492,8 +492,9 @@ ANALYZE
"select_id": 1,
"r_loops": 1,
"volatile parameter": "REPLACED",
"having_condition": "(TOP > a)",
"having_condition": "(TOP > t2.a)",
"filesort": {
"sort_key": "t2.a",
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
@ -523,6 +524,7 @@ ANALYZE
"r_loops": 1,
"volatile parameter": "REPLACED",
"filesort": {
"sort_key": "t2.a",
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
@ -563,6 +565,7 @@ ANALYZE
"r_loops": 1,
"volatile parameter": "REPLACED",
"filesort": {
"sort_key": "t2.a",
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
@ -684,18 +687,20 @@ ANALYZE
"r_loops": 1,
"volatile parameter": "REPLACED",
"filesort": {
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
"r_output_rows": 0,
"volatile parameter": "REPLACED",
"filesort": {
"sort_key": "group_concat(t3.f3 separator ',')",
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
"r_output_rows": 0,
"volatile parameter": "REPLACED",
"temporary_table": {
"filesort": {
"sort_key": "(subquery#2)",
"r_loops": 1,
"volatile parameter": "REPLACED",
"r_used_priority_queue": false,
"r_output_rows": 0,
"volatile parameter": "REPLACED",
"temporary_table": {
"table": {
"table_name": "t2",

View File

@ -172,8 +172,8 @@ EXPLAIN
"query_block": {
"select_id": 1,
"filesort": {
"sort_key": "t2.b",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t0",
"access_type": "ALL",
@ -205,6 +205,7 @@ ANALYZE
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"filesort": {
"sort_key": "t2.b",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"r_limit": 4,
@ -257,6 +258,7 @@ EXPLAIN
"select_id": 1,
"read_sorted_file": {
"filesort": {
"sort_key": "t0.a",
"table": {
"table_name": "t0",
"access_type": "ALL",
@ -290,6 +292,7 @@ ANALYZE
"read_sorted_file": {
"r_rows": 10,
"filesort": {
"sort_key": "t0.a",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"r_used_priority_queue": false,
@ -346,6 +349,7 @@ ANALYZE
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"filesort": {
"sort_key": "t2.c",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"r_used_priority_queue": false,
@ -455,18 +459,20 @@ ANALYZE
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"filesort": {
"sort_key": "count(distinct t5.b)",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"r_limit": 1,
"r_used_priority_queue": true,
"r_output_rows": 2,
"temporary_table": {
"filesort": {
"sort_key": "t5.a",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"r_used_priority_queue": false,
"r_output_rows": 6,
"r_buffer_size": "REPLACED",
"temporary_table": {
"temporary_table": {
"table": {
"table_name": "t6",
@ -511,8 +517,11 @@ EXPLAIN
"query_block": {
"select_id": 1,
"filesort": {
"sort_key": "count(distinct t5.b)",
"temporary_table": {
"filesort": {
"sort_key": "t5.a",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t6",
"access_type": "ALL",
@ -535,6 +544,8 @@ EXPLAIN
}
}
}
}
}
}
drop table t5,t6,t7;
drop table t3;

View File

@ -1,6 +1,7 @@
call mtr.add_suppression("Allocation failed");
SET @old_debug= @@session.debug;
set @old_thread_cache_size=@@global.thread_cache_size;
set @@global.thread_cache_size=0;
connect con1,localhost,root,,test,,;
select 1;
1

View File

@ -746,3 +746,16 @@ with t(f1,f1) as (select * from t1 where b >= 'c')
select t1.b from t2,t1 where t1.a = t2.c;
ERROR 42S21: Duplicate column name 'f1'
drop table t1,t2;
#
# Bug mdev-9937: View used in the specification of with table
# refers to the base table with the same name
#
create table t1 (a int);
insert into t1 values (20), (30), (10);
create view v1 as select * from t1 where a > 10;
with t1 as (select * from v1) select * from t1;
a
20
30
drop view v1;
drop table t1;

View File

@ -0,0 +1,289 @@
create table t1 (a int, b varchar(32));
insert into t1 values
(4,'aaaa' ), (7,'bb'), (1,'ccc'), (4,'dd');
insert into t1 values
(3,'eee'), (7,'bb'), (1,'fff'), (4,'ggg');
with recursive
a1(a,b) as
(select * from t1 where t1.a>3
union
select * from b1 where b1.a >3
union
select * from c1 where c1.a>3),
b1(a,b) as
(select * from a1 where a1.b > 'ccc'
union
select * from c1 where c1.b > 'ddd'),
c1(a,b) as
(select * from a1 where a1.a<6 and a1.b< 'zz'
union
select * from b1 where b1.b > 'auu')
select * from c1;
ERROR HY000: No anchors for recursive WITH element 'b1'
drop table t1;
create table folks(id int, name char(32), dob date, father int, mother int);
insert into folks values
(100, 'Vasya', '2000-01-01', 20, 30),
(20, 'Dad', '1970-02-02', 10, 9),
(30, 'Mom', '1975-03-03', 8, 7),
(10, 'Grandpa Bill', '1940-04-05', null, null),
(9, 'Grandma Ann', '1941-10-15', null, null),
(25, 'Uncle Jim', '1968-11-18', 8, 7),
(98, 'Sister Amy', '2001-06-20', 20, 30),
(8, 'Grandma Sally', '1943-08-23', 5, 6),
(6, 'Grandgrandma Martha', '1923-05-17', null, null),
(67, 'Cousin Eddie', '1992-02-28', 25, 27),
(27, 'Auntie Melinda', '1971-03-29', null, null);
with recursive
ancestors
as
(
select *
from folks
where name = 'Vasya' and dob = '2000-01-01'
union
select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a
where p.id = a.father or p.id = a.mother
)
select * from ancestors;
id name dob father mother
100 Vasya 2000-01-01 20 30
20 Dad 1970-02-02 10 9
30 Mom 1975-03-03 8 7
10 Grandpa Bill 1940-04-05 NULL NULL
9 Grandma Ann 1941-10-15 NULL NULL
8 Grandma Sally 1943-08-23 5 6
6 Grandgrandma Martha 1923-05-17 NULL NULL
with recursive
ancestors
as
(
select p.*
from folks as p, ancestors AS a
where p.id = a.father or p.id = a.mother
union
select *
from folks
where name = 'Vasya' and dob = '2000-01-01'
)
select * from ancestors;
id name dob father mother
100 Vasya 2000-01-01 20 30
20 Dad 1970-02-02 10 9
30 Mom 1975-03-03 8 7
10 Grandpa Bill 1940-04-05 NULL NULL
9 Grandma Ann 1941-10-15 NULL NULL
8 Grandma Sally 1943-08-23 5 6
6 Grandgrandma Martha 1923-05-17 NULL NULL
with recursive
ancestors
as
(
select *
from folks
where name = 'Cousin Eddie'
union
select p.*
from folks as p, ancestors as a
where p.id = a.father or p.id = a.mother
)
select * from ancestors;
id name dob father mother
67 Cousin Eddie 1992-02-28 25 27
25 Uncle Jim 1968-11-18 8 7
27 Auntie Melinda 1971-03-29 NULL NULL
8 Grandma Sally 1943-08-23 5 6
6 Grandgrandma Martha 1923-05-17 NULL NULL
with recursive
ancestors
as
(
select *
from folks
where name = 'Vasya' or name='Sister Amy'
union
select p.*
from folks as p, ancestors as a
where p.id = a.father or p.id = a.mother
)
select * from ancestors;
id name dob father mother
100 Vasya 2000-01-01 20 30
98 Sister Amy 2001-06-20 20 30
20 Dad 1970-02-02 10 9
30 Mom 1975-03-03 8 7
10 Grandpa Bill 1940-04-05 NULL NULL
9 Grandma Ann 1941-10-15 NULL NULL
8 Grandma Sally 1943-08-23 5 6
6 Grandgrandma Martha 1923-05-17 NULL NULL
with recursive
prev_gen
as
(
select folks.*
from folks, prev_gen
where folks.id=prev_gen.father or folks.id=prev_gen.mother
union
select *
from folks
where name='Vasya'
),
ancestors
as
(
select *
from folks
where name='Vasya'
union
select *
from ancestors
union
select *
from prev_gen
)
select ancestors.name, ancestors.dob from ancestors;
name dob
Vasya 2000-01-01
Dad 1970-02-02
Mom 1975-03-03
Grandpa Bill 1940-04-05
Grandma Ann 1941-10-15
Grandma Sally 1943-08-23
Grandgrandma Martha 1923-05-17
with recursive
descendants
as
(
select *
from folks
where name = 'Grandpa Bill'
union
select folks.*
from folks, descendants as d
where d.id=folks.father or d.id=folks.mother
)
select * from descendants;
id name dob father mother
10 Grandpa Bill 1940-04-05 NULL NULL
20 Dad 1970-02-02 10 9
100 Vasya 2000-01-01 20 30
98 Sister Amy 2001-06-20 20 30
with recursive
descendants
as
(
select *
from folks
where name = 'Grandma Sally'
union
select folks.*
from folks, descendants as d
where d.id=folks.father or d.id=folks.mother
)
select * from descendants;
id name dob father mother
8 Grandma Sally 1943-08-23 5 6
30 Mom 1975-03-03 8 7
25 Uncle Jim 1968-11-18 8 7
100 Vasya 2000-01-01 20 30
98 Sister Amy 2001-06-20 20 30
67 Cousin Eddie 1992-02-28 25 27
with recursive
ancestors
as
(
select *
from folks
where name = 'Vasya' and dob = '2000-01-01'
union
select p.*
from folks as p, ancestors AS a
where p.id = a.father OR p.id = a.mother
)
select *
from ancestors t1, ancestors t2
where exists (select * from ancestors a
where a.father=t1.id AND a.mother=t2.id);
id name dob father mother id name dob father mother
20 Dad 1970-02-02 10 9 30 Mom 1975-03-03 8 7
10 Grandpa Bill 1940-04-05 NULL NULL 9 Grandma Ann 1941-10-15 NULL NULL
with
ancestor_couples(husband, h_dob, wife, w_dob)
as
(
with recursive
ancestors
as
(
select *
from folks
where name = 'Vasya'
union
select p.*
from folks as p, ancestors AS a
where p.id = a.father OR p.id = a.mother
)
select t1.name, t1.dob, t2.name, t2.dob
from ancestors t1, ancestors t2
where exists (select * from ancestors a
where a.father=t1.id AND a.mother=t2.id)
)
select * from ancestor_couples;
husband h_dob wife w_dob
Dad 1970-02-02 Mom 1975-03-03
Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15
with recursive
ancestors
as
(
select *
from folks
where name = 'Vasya' and dob = '2000-01-01'
union
select p.*
from folks as p, ancestors AS a
where p.id = a.father
union
select p.*
from folks as p, ancestors AS a
where p.id = a.mother
)
select * from ancestors;
id name dob father mother
100 Vasya 2000-01-01 20 30
20 Dad 1970-02-02 10 9
30 Mom 1975-03-03 8 7
9 Grandma Ann 1941-10-15 NULL NULL
10 Grandpa Bill 1940-04-05 NULL NULL
8 Grandma Sally 1943-08-23 5 6
6 Grandgrandma Martha 1923-05-17 NULL NULL
with recursive
ancestor_couples(h_id, h_name, h_dob, h_father, h_mother,
w_id, w_name, w_dob, w_father, w_mother)
as
(
select h.*, w.*
from folks h, folks w, coupled_ancestors a
where a.father = h.id AND a.mother = w.id
union
select h.*, w.*
from folks v, folks h, folks w
where v.name = 'Vasya' and
(v.father = h.id AND v.mother= w.id)
),
coupled_ancestors (id, name, dob, father, mother)
as
(
select h_id, h_name, h_dob, h_father, h_mother
from ancestor_couples
union
select w_id, w_name, w_dob, w_father, w_mother
from ancestor_couples
)
select h_name, h_dob, w_name, w_dob
from ancestor_couples;
h_name h_dob w_name w_dob
Dad 1970-02-02 Mom 1975-03-03
Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15
drop table folks;

View File

@ -33913,3 +33913,24 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
#
# End of 10.2 tests
#
#
# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis
#
CREATE TABLE t1 (a TEXT CHARACTER SET eucjpms);
LOAD DATA INFILE '../../std_data/loaddata/mdev9823.ujis.txt' INTO TABLE t1 CHARACTER SET eucjpms IGNORE 4 LINES;
SELECT HEX(a) FROM t1;
HEX(a)
3F
78787831
3F3F
78787832
8FA1A1
78787833
3F3F
DROP TABLE t1;
#
# End of 10.2 tests
#

File diff suppressed because it is too large Load Diff

View File

@ -26218,3 +26218,24 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
#
# End of 10.2 tests
#
#
# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis
#
CREATE TABLE t1 (a TEXT CHARACTER SET ujis);
LOAD DATA INFILE '../../std_data/loaddata/mdev9823.ujis.txt' INTO TABLE t1 CHARACTER SET ujis IGNORE 4 LINES;
SELECT HEX(a) FROM t1;
HEX(a)
3F
78787831
3F3F
78787832
8FA1A1
78787833
3F3F
DROP TABLE t1;
#
# End of 10.2 tests
#

View File

@ -10426,5 +10426,38 @@ b
c
DROP TABLE t1;
#
# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis
#
CREATE TABLE t1 (a TEXT CHARACTER SET utf8);
LOAD DATA INFILE '../../std_data/loaddata/mdev9823.utf8mb4.txt' INTO TABLE t1 CHARACTER SET utf8 IGNORE 4 LINES;
Warnings:
Warning 1366 Incorrect string value: '\xD0' for column 'a' at row 1
Warning 1366 Incorrect string value: '\xE1\x80' for column 'a' at row 3
Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 5
Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 7
Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 8
SELECT HEX(a) FROM t1;
HEX(a)
3F
78787831
3F3F
78787832
3F3F3F
78787833
3F3F3F3F
3F3F3F
DROP TABLE t1;
#
# MDEV-9874 LOAD XML INFILE does not handle well broken multi-byte characters
#
CREATE TABLE t1 (a TEXT CHARACTER SET utf8);
LOAD XML INFILE '../../std_data/loaddata/mdev9874.xml' INTO TABLE t1 CHARACTER SET utf8 ROWS IDENTIFIED BY '<row>';
Warnings:
Warning 1366 Incorrect string value: '\xD0' for column 'a' at row 1
SELECT HEX(a) FROM t1;
HEX(a)
613F
DROP TABLE t1;
#
# End of 10.2 tests
#

View File

@ -3398,3 +3398,30 @@ DROP FUNCTION f1;
#
# End of 10.1 tests
#
#
# End of 10.2 tests
#
#
# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis
#
CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4);
LOAD DATA INFILE '../../std_data/loaddata/mdev9823.utf8mb4.txt' INTO TABLE t1 CHARACTER SET utf8mb4 IGNORE 4 LINES;
Warnings:
Warning 1366 Incorrect string value: '\xD0' for column 'a' at row 1
Warning 1366 Incorrect string value: '\xE1\x80' for column 'a' at row 3
Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 5
Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 8
SELECT HEX(a) FROM t1;
HEX(a)
3F
78787831
3F3F
78787832
3F3F3F
78787833
F09F988E
3F3F3F
DROP TABLE t1;
#
# End of 10.2 tests
#

View File

@ -476,3 +476,37 @@ connection con1;
disconnect con1;
connection default;
drop tables tm, t1, t2;
#
# MDEV-9621 INSERT DELAYED fails on insert for tables with many columns
#
CREATE TABLE t1 (
a int,b int,c int,d int,e int,f int,g int,h int,i int,j int,k int,l int,m int,n int,o int,p int,q int,r int,s int,t int,u int,v int,x int,y int,z int
) ENGINE=MyISAM;
INSERT DELAYED INTO t1 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z)
values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
INSERT DELAYED INTO t1 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z)
values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
drop table t1;
#
# INSERT DELAYED hangs if table was crashed
#
create table t1 (a int, b int) engine=myisam;
insert into t1 values (1,1);
SET debug_dbug="d,crash_shutdown";
shutdown;
ERROR HY000: Lost connection to MySQL server during query
call mtr.add_suppression(" marked as crashed and should be repaired");
call mtr.add_suppression("Checking table");
insert delayed into t1 values (2,2);
Warnings:
Error 145 Table './test/t1' is marked as crashed and should be repaired
Error 1194 Table 't1' is marked as crashed and should be repaired
Error 1034 1 client is using or hasn't closed the table properly
insert delayed into t1 values (3,3);
flush tables t1;
select * from t1;
a b
1 1
2 2
3 3
drop table t1;

View File

@ -231,8 +231,8 @@ CREATE VIEW v1 AS SELECT a, MIN(b) AS b FROM t2 GROUP BY a;
EXPLAIN
SELECT * FROM v1, t1 WHERE v1.b=t1.a ORDER BY v1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using filesort
1 PRIMARY <derived2> ref key0 key0 5 const 1 Using where
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY <derived2> ref key0 key0 5 const 1 Using where; Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
SELECT * FROM v1, t1 WHERE v1.b=t1.a ORDER BY v1.a;
a b a

View File

@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using temporary
1 SIMPLE t3 ref a a 5 test.t1.b 2 Using index
1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Distinct; Using join buffer (flat, BNL join)
1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Using join buffer (flat, BNL join)
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
a
1
@ -302,11 +302,11 @@ WHERE
AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index id id 4 NULL 2 Using index; Using temporary
1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct; Using join buffer (flat, BNL join)
1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct; Using join buffer (flat, BNL join)
1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer (flat, BNL join)
1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index; Distinct
1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer (flat, BNL join)
1 SIMPLE t2 index id id 8 NULL 1 Using index; Using join buffer (flat, BNL join)
1 SIMPLE t3 index id id 8 NULL 1 Using index; Using join buffer (flat, BNL join)
1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index
1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
1 SIMPLE t3_lj ref id id 4 test.j_lj_t3.id 1 Using where; Using index; Distinct
SELECT DISTINCT
t1.id
@ -518,7 +518,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1_1 ALL NULL NULL NULL NULL 3 Using temporary
1 SIMPLE t1_2 index NULL PRIMARY 4 NULL 3 Using index; Distinct; Using join buffer (flat, BNL join)
1 SIMPLE t1_2 index NULL PRIMARY 4 NULL 3 Using index; Using join buffer (flat, BNL join)
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2
WHERE t1_1.a = t1_2.a;
id select_type table type possible_keys key key_len ref rows Extra
@ -916,8 +916,8 @@ SELECT STRAIGHT_JOIN DISTINCT t1.id FROM
t1, v1, t2 WHERE v1.id = t2.i AND t1.i1 = v1.i1 AND t2.i != 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 96 100.00 Using where; Using temporary
1 PRIMARY <derived2> ref key0 key0 5 test.t1.i1 9 100.00 Using where; Distinct
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Distinct; Using join buffer (flat, BNL join)
1 PRIMARY <derived2> ref key0 key0 5 test.t1.i1 9 100.00 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 96 100.00
Warnings:
Note 1003 select straight_join distinct `test`.`t1`.`id` AS `id` from `test`.`t1` join `test`.`v1` join `test`.`t2` where ((`test`.`t2`.`i` = `v1`.`id`) and (`v1`.`i1` = `test`.`t1`.`i1`) and (`v1`.`id` <> 3))

View File

@ -486,8 +486,8 @@ EXPLAIN
"query_block": {
"select_id": 2,
"filesort": {
"sort_key": "t1.a",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t1",
"access_type": "ALL",
@ -530,8 +530,8 @@ EXPLAIN
"query_block": {
"select_id": 2,
"filesort": {
"sort_key": "t1.a",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t1",
"access_type": "ALL",
@ -576,7 +576,6 @@ EXPLAIN
"query_block": {
"select_id": 2,
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t1",
"access_type": "ALL",
@ -1132,8 +1131,8 @@ EXPLAIN
"select_id": 1,
"having_condition": "(TOP > t2.a)",
"filesort": {
"sort_key": "t2.a",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t2",
"access_type": "ALL",
@ -1151,8 +1150,8 @@ EXPLAIN
"query_block": {
"select_id": 1,
"filesort": {
"sort_key": "t2.a",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t2",
"access_type": "ALL",
@ -1181,8 +1180,8 @@ EXPLAIN
"query_block": {
"select_id": 1,
"filesort": {
"sort_key": "t2.a",
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t2",
"access_type": "ALL",
@ -1380,7 +1379,6 @@ EXPLAIN
"query_block": {
"select_id": 1,
"temporary_table": {
"function": "buffer",
"table": {
"table_name": "t1",
"access_type": "ALL",

View File

@ -19,7 +19,7 @@ test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
create table t2 select * from t1 procedure analyse();
ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'procedure analyse()' at line 1
drop table t1;
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
ERROR HY000: Incorrect usage of PROCEDURE and subquery
@ -120,7 +120,7 @@ CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1),(2);
# should not crash
CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE();
ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE()' at line 1
DROP TABLE t1;
End of 5.0 tests
#
@ -149,3 +149,25 @@ Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_
test.t2.f2 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
DROP TABLE t1, t2;
End of 5.1 tests
#
# Start of 10.2 tests
#
(SELECT 1 FROM DUAL PROCEDURE ANALYSE());
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
1 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
((SELECT 1 FROM DUAL PROCEDURE ANALYSE()));
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
1 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
SELECT * FROM t1 UNION SELECT * FROM t1 PROCEDURE analyse();
ERROR HY000: Incorrect usage of PROCEDURE and subquery
#
# MDEV-10030 sql_yacc.yy: Split table_expression and remove PROCEDURE from create_select, select_paren_derived, select_derived2, query_specification
#
SELECT * FROM (SELECT * FROM t1 PROCEDURE ANALYSE());
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE())' at line 1
SELECT * FROM t1 NATURAL JOIN (SELECT * FROM t2 PROCEDURE ANALYSE());
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE())' at line 1
SELECT (SELECT 1 FROM t1 PROCEDURE ANALYSE()) FROM t2;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE()) FROM t2' at line 1
SELECT ((SELECT 1 FROM t1 PROCEDURE ANALYSE())) FROM t2;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE())) FROM t2' at line 1

View File

@ -1519,7 +1519,7 @@ SELECT MAX(pk) as max, i
FROM t1
ORDER BY max;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
# Only 11 is correct for collumn i in this result
SELECT MAX(pk) as max, i

View File

@ -1346,12 +1346,43 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 144
#
# For this explain, the query plan is weird: if we are using
# the primary key for reasons other than doing grouping, can't
# GROUP BY code take advantage of this? Well, currently it doesnt:
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
# Here's a proof it is really doing sorting:
flush status;
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a;
show status like 'Sort_%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 144
Sort_scan 1
# Proof ends.
#
# For this explain, the query plan is weird: if we are using
# the primary key for reasons other than doing sorting, can't
# ORDER BY code take advantage of this? Well, currently it doesnt:
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
# Here's a proof it is really doing sorting:
flush status;
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
show status like 'Sort_%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 144
Sort_scan 1
# Proof ends.
#
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
a
1
@ -2678,3 +2709,17 @@ NULL
100098
100099
drop table t0,t1,t2;
#
# MDEV-9602 crash in st_key::actual_rec_per_key when group by constant
#
create table t1 (a date not null,unique (a)) engine=innodb;
Warnings:
Warning 1286 Unknown storage engine 'innodb'
Warning 1266 Using storage engine MyISAM for table 't1'
select distinct a from t1 group by 'a';
a
insert into t1 values("2001-02-02"),("2001-02-03");
select distinct a from t1 group by 'a';
a
2001-02-02
drop table t1;

View File

@ -470,10 +470,9 @@ WHERE table2.f1 = 2
GROUP BY table1.f1, table2.f2
HAVING (table2.f2 = 8 AND table1.f1 >= 6);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE table2 const PRIMARY PRIMARY 4 const 1 100.00 Using filesort
1 SIMPLE table1 ALL NULL NULL NULL NULL 4 100.00 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables
Warnings:
Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having ((7 = 8) and (`test`.`table1`.`f1` >= 6))
Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having 0
EXPLAIN EXTENDED
SELECT table1.f1, table2.f2
FROM t1 AS table1
@ -482,10 +481,9 @@ WHERE table2.f1 = 2
GROUP BY table1.f1, table2.f2
HAVING (table2.f2 = 8);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE table2 const PRIMARY PRIMARY 4 const 1 100.00 Using filesort
1 SIMPLE table1 ALL NULL NULL NULL NULL 4 100.00 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables
Warnings:
Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having (7 = 8)
Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having 0
DROP TABLE t1;
#
# Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355

View File

@ -5412,9 +5412,9 @@ WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND
t2.a BETWEEN 4 and 5
ORDER BY t2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using filesort
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY t3 system NULL NULL NULL NULL 1
1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where
1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where; Using filesort
1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary
SELECT * FROM t1,t2
WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND

View File

@ -1289,8 +1289,8 @@ SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b )
FROM t1 JOIN t2 USING( a )
GROUP BY t1.a WITH ROLLUP;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 system NULL NULL NULL NULL 1
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where; Using filesort
SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b )
FROM t1 JOIN t2 USING( a )
GROUP BY t1.a WITH ROLLUP;
@ -1429,8 +1429,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort
SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;
@ -1846,8 +1846,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort
SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;

View File

@ -1300,8 +1300,8 @@ SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b )
FROM t1 JOIN t2 USING( a )
GROUP BY t1.a WITH ROLLUP;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 system NULL NULL NULL NULL 1
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where; Using filesort
SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b )
FROM t1 JOIN t2 USING( a )
GROUP BY t1.a WITH ROLLUP;
@ -1440,8 +1440,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort
SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;
@ -1857,8 +1857,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index
1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort
SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
GROUP BY t2.f1, t2.f2;

View File

@ -80,13 +80,13 @@ create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
c
7
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
c
28

View File

@ -471,9 +471,11 @@ id select_type table type possible_keys key key_len ref rows Extra
select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 0;
c1 sum(c2)
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 2 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete.
Warning 1931 Query execution was interrupted. The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete.
select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 1;
ERROR HY000: Sort aborted:
c1 sum(c2)
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 3 rows, which exceeds LIMIT ROWS EXAMINED (1). The query result may be incomplete.
select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 20;
c1 sum(c2)
aa 3
@ -496,9 +498,11 @@ id select_type table type possible_keys key key_len ref rows Extra
select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 0;
c1 sum(c2)
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 2 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete.
Warning 1931 Query execution was interrupted. The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete.
select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 1;
ERROR HY000: Sort aborted:
c1 sum(c2)
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 3 rows, which exceeds LIMIT ROWS EXAMINED (1). The query result may be incomplete.
select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 20;
c1 sum(c2)
aa 3
@ -627,7 +631,7 @@ CREATE TABLE t4 (a int);
INSERT INTO t4 values (1), (2);
INSERT INTO t4 SELECT a + 2 FROM t4 LIMIT ROWS EXAMINED 0;
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 2 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete.
Warning 1931 Query execution was interrupted. The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete.
select * from t4;
a
1
@ -666,7 +670,7 @@ MDEV-115
SET @@optimizer_switch='in_to_exists=on,outer_join_with_cache=on';
CREATE TABLE t1 ( a VARCHAR(3) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('USA');
INSERT INTO t1 VALUES ('USA'),('CAN');
CREATE TABLE t2 ( b INT );
INSERT INTO t2 VALUES (3899),(3914),(3888);
CREATE TABLE t3 ( c VARCHAR(33), d INT );
@ -676,8 +680,8 @@ SELECT DISTINCT a AS field1 FROM t1, t2
WHERE EXISTS (SELECT c FROM t3 LEFT JOIN t2 ON b = d)
HAVING field1 > 'aaa' LIMIT ROWS EXAMINED 20;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Distinct
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
SELECT DISTINCT a AS field1 FROM t1, t2
@ -685,24 +689,27 @@ WHERE EXISTS (SELECT c FROM t3 LEFT JOIN t2 ON b = d)
HAVING field1 > 'aaa' LIMIT ROWS EXAMINED 20;
field1
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 23 rows, which exceeds LIMIT ROWS EXAMINED (20). The query result may be incomplete.
Warning 1931 Query execution was interrupted. The query examined at least 21 rows, which exceeds LIMIT ROWS EXAMINED (20). The query result may be incomplete.
EXPLAIN
SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 14;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Distinct
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 14;
a
USA
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 15 rows, which exceeds LIMIT ROWS EXAMINED (14). The query result may be incomplete.
SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 15;
a
USA
CAN
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 16 rows, which exceeds LIMIT ROWS EXAMINED (15). The query result may be incomplete.
SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 16;
a
USA
CAN
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 17 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete.
drop table t1,t2,t3;

View File

@ -7,8 +7,8 @@ explain select 1 from
(select f2, f3, val, count(id) from t4 join t2 left join t3 on 0) top
join t1 on f1 = f3 where f3 = 'aaaa' order by val;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY PRIMARY 12 const 1 Using index; Using filesort
1 PRIMARY <derived2> ref key0 key0 13 const 0 Using where
1 PRIMARY t1 const PRIMARY PRIMARY 12 const 1 Using index
1 PRIMARY <derived2> ref key0 key0 13 const 0 Using where; Using filesort
2 DERIVED t4 ALL NULL NULL NULL NULL 1
2 DERIVED t2 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
2 DERIVED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)

View File

@ -523,11 +523,11 @@ a
explain select sql_big_result distinct t1.a from t1,t2 order by t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index
explain select distinct t1.a from t1,t2 order by t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index
drop table t1,t2;
create table t1 (
c1 varchar(32),
@ -603,6 +603,10 @@ test.t2 3442722830
test.t3 NULL
Warnings:
Error 1146 Table 'test.t3' doesn't exist
alter table t1 add d int default 30, add e bigint default 300000, add f decimal(30) default 442;
checksum table t1;
Table Checksum
test.t1 2924214226
drop table t1,t2;
create table t1 (a int, key (a));
show keys from t1;

View File

@ -0,0 +1,30 @@
drop table if exists t0,t1,t2,t3;
#
# MDEV-7885: EXPLAIN shows wrong info for ORDER BY query
#
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(a int);
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
create table t2 (key1 int, col1 int, key(key1));
insert into t2 select a,a from t0;
insert into t2 select 15,15 from t1;
alter table t2 add key2 int, add key(key2);
# This must show "Using filesort":
explain
select * from t2 ignore index for order by (key1) where col1<0 order by key1 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1010 Using where; Using filesort
drop table t0, t1, t2;
#
# MDEV-8857: [Upstream too] EXPLAIN incorrectly shows Distinct for tables using join buffer
#
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int, filler char(200), key(a));
insert into t1 select A.a + B.a* 10, 'AAAAAAAAAAAAAAAAAAAA' from t0 A, t0 B where B.a in (0,1);
explain select distinct A.a from t0 A, t1 B where A.a+B.a> 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A ALL NULL NULL NULL NULL 10 Using temporary
1 SIMPLE B index NULL a 5 NULL 20 Using where; Using index; Using join buffer (flat, BNL join)
drop table t0, t1;

View File

@ -686,7 +686,7 @@ FOR UPDATE) a;
SELECT 1 FROM
(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
PROCEDURE ANALYSE() FOR UPDATE) a;
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE() FOR UPDATE) a' at line 3
SELECT 1 FROM t1
WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
FOR UPDATE);
@ -694,7 +694,7 @@ FOR UPDATE);
SELECT 1 FROM t1
WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
PROCEDURE ANALYSE() FOR UPDATE);
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE() FOR UPDATE)' at line 3
SELECT 1 FROM t1
UNION
SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1

View File

@ -83,20 +83,20 @@ UNIQUE KEY e_n (email,name)
);
EXPLAIN SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system PRIMARY,kid NULL NULL NULL 0 const row not found
1 SIMPLE t2 index NULL e_n 104 NULL 10
1 SIMPLE t1 system PRIMARY,kid NULL NULL NULL 0 const row not found; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 200
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
email
email1
email2
email3
email4
email5
email6
email7
email8
email9
email10
email100
email101
email102
email103
email104
email105
email106
email107
SELECT FOUND_ROWS();
FOUND_ROWS()
200

View File

@ -1162,7 +1162,7 @@ SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, fie
connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 system NULL NULL NULL NULL 1 Using filesort
1 SIMPLE t2 system NULL NULL NULL NULL 1
1 SIMPLE t1 range b b 6 NULL 107 Using where; Using index
1 SIMPLE t3 ref PRIMARY PRIMARY 5 test.t1.b 1 Using index
Warnings:

View File

@ -79,7 +79,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

View File

@ -19,7 +19,7 @@ SELECT 1 FROM t1
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3))
ORDER BY count(*);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index; Using temporary
1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found
# should not crash the next statement
@ -2003,8 +2003,8 @@ FROM t2 JOIN t3 ON t3.f4 = t2.f4
WHERE t3.f1 = 8
GROUP BY 1, 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1 Using filesort
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY t3 system NULL NULL NULL NULL 1
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using filesort
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
3 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
PREPARE st1 FROM "

View File

@ -83,7 +83,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

View File

@ -86,7 +86,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

View File

@ -82,7 +82,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

View File

@ -85,7 +85,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

View File

@ -82,7 +82,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

1961
mysql-test/r/win.result Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
create table t1 (
pk int primary key,
a int,
b int,
c real
);
insert into t1 values
(101 , 0, 10, 1.1),
(102 , 0, 10, 2.1),
(103 , 1, 10, 3.1),
(104 , 1, 10, 4.1),
(108 , 2, 10, 5.1),
(105 , 2, 20, 6.1),
(106 , 2, 20, 7.1),
(107 , 2, 20, 8.15),
(109 , 4, 20, 9.15),
(110 , 4, 20, 10.15),
(111 , 5, NULL, 11.15),
(112 , 5, 1, 12.25),
(113 , 5, NULL, 13.35),
(114 , 5, NULL, 14.50),
(115 , 5, NULL, 15.65),
(116 , 6, 1, NULL),
(117 , 6, 1, 10),
(118 , 6, 1, 1.1),
(119 , 6, 1, NULL),
(120 , 6, 1, NULL),
(121 , 6, 1, NULL),
(122 , 6, 1, 2.2),
(123 , 6, 1, 20.1),
(124 , 6, 1, -10.4),
(125 , 6, 1, NULL),
(126 , 6, 1, NULL),
(127 , 6, 1, NULL);
select pk, a, b, avg(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
from t1;
pk a b avg(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
101 0 10 10.0000
102 0 10 10.0000
103 1 10 10.0000
104 1 10 10.0000
105 2 20 20.0000
106 2 20 20.0000
107 2 20 16.6667
108 2 10 15.0000
109 4 20 20.0000
110 4 20 20.0000
111 5 NULL 1.0000
112 5 1 1.0000
113 5 NULL 1.0000
114 5 NULL NULL
115 5 NULL NULL
116 6 1 1.0000
117 6 1 1.0000
118 6 1 1.0000
119 6 1 1.0000
120 6 1 1.0000
121 6 1 1.0000
122 6 1 1.0000
123 6 1 1.0000
124 6 1 1.0000
125 6 1 1.0000
126 6 1 1.0000
127 6 1 1.0000
select pk, a, c, avg(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
from t1;
pk a c avg(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
101 0 1.1 1.6
102 0 2.1 1.6
103 1 3.1 3.5999999999999996
104 1 4.1 3.5999999999999996
105 2 6.1 6.6
106 2 7.1 7.116666666666667
107 2 8.15 6.783333333333334
108 2 5.1 6.625000000000001
109 4 9.15 9.65
110 4 10.15 9.65
111 5 11.15 11.7
112 5 12.25 12.25
113 5 13.35 13.366666666666667
114 5 14.5 14.5
115 5 15.65 15.075
116 6 NULL 10
117 6 10 5.55
118 6 1.1 5.55
119 6 NULL 1.0999999999999996
120 6 NULL NULL
121 6 NULL 2.1999999999999997
122 6 2.2 11.15
123 6 20.1 3.966666666666667
124 6 -10.4 4.85
125 6 NULL -10.400000000000002
126 6 NULL NULL
127 6 NULL NULL
drop table t1;

117
mysql-test/r/win_bit.result Normal file
View File

@ -0,0 +1,117 @@
create table t1 (
pk int primary key,
a int,
b int
);
create table t2 (
pk int primary key,
a int,
b int
);
insert into t1 values
( 1 , 0, 1),
( 2 , 0, 2),
( 3 , 1, 4),
( 4 , 1, 8),
( 5 , 2, 32),
( 6 , 2, 64),
( 7 , 2, 128),
( 8 , 2, 16);
insert into t2 values
( 1 , 0, 2),
( 2 , 0, 2),
( 3 , 1, 4),
( 4 , 1, 4),
( 5 , 2, 16),
( 6 , 2, 64),
( 7 , 2, 128),
( 8 , 2, 16);
# Test bit functions on only one partition.
select pk, a, b,
bit_or(b) over (order by pk) as bit_or,
bit_and(b) over (order by pk) as bit_and,
bit_xor(b) over (order by pk) as bit_xor
from t1;
pk a b bit_or bit_and bit_xor
1 0 1 1 1 1
2 0 2 3 0 3
3 1 4 7 0 7
4 1 8 15 0 15
5 2 32 47 0 47
6 2 64 111 0 111
7 2 128 239 0 239
8 2 16 255 0 255
select pk, a, b,
bit_or(b) over (order by pk) as bit_or,
bit_and(b) over (order by pk) as bit_and,
bit_xor(b) over (order by pk) as bit_xor
from t2;
pk a b bit_or bit_and bit_xor
1 0 2 2 2 2
2 0 2 2 2 0
3 1 4 6 0 4
4 1 4 6 0 0
5 2 16 22 0 16
6 2 64 86 0 80
7 2 128 214 0 208
8 2 16 214 0 192
# Test multiple partitions with bit functions.
select pk, a, b,
bit_or(b) over (partition by a order by pk) as bit_or,
bit_and(b) over (partition by a order by pk) as bit_and,
bit_xor(b) over (partition by a order by pk) as bit_xor
from t1;
pk a b bit_or bit_and bit_xor
1 0 1 1 1 1
2 0 2 3 0 3
3 1 4 4 4 4
4 1 8 12 0 12
5 2 32 32 32 32
6 2 64 96 0 96
7 2 128 224 0 224
8 2 16 240 0 240
select pk, a, b,
bit_or(b) over (partition by a order by pk) as bit_or,
bit_and(b) over (partition by a order by pk) as bit_and,
bit_xor(b) over (partition by a order by pk) as bit_xor
from t2;
pk a b bit_or bit_and bit_xor
1 0 2 2 2 2
2 0 2 2 2 0
3 1 4 4 4 4
4 1 4 4 4 0
5 2 16 16 16 16
6 2 64 80 0 80
7 2 128 208 0 208
8 2 16 208 0 192
# Test remove function for bit functions using a sliding window.
select pk, a, b,
bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as bit_or,
bit_and(b) over (partition by a order by pk) as bit_and,
bit_xor(b) over (partition by a order by pk) as bit_xor
from t1;
pk a b bit_or bit_and bit_xor
1 0 1 3 1 1
2 0 2 3 0 3
3 1 4 12 4 4
4 1 8 12 0 12
5 2 32 96 32 32
6 2 64 224 0 96
7 2 128 208 0 224
8 2 16 144 0 240
select pk, a, b,
bit_or(b) over (partition by a order by pk) as bit_or,
bit_and(b) over (partition by a order by pk) as bit_and,
bit_xor(b) over (partition by a order by pk) as bit_xor
from t2;
pk a b bit_or bit_and bit_xor
1 0 2 2 2 2
2 0 2 2 2 0
3 1 4 4 4 4
4 1 4 4 4 0
5 2 16 16 16 16
6 2 64 80 0 80
7 2 128 208 0 208
8 2 16 208 0 192
drop table t1;
drop table t2;

View File

@ -0,0 +1,435 @@
create table t1 (
pk int primary key,
a int,
b int
);
insert into t1 values
(11 , 0, 10),
(12 , 0, 10),
(13 , 1, 10),
(14 , 1, 10),
(18 , 2, 10),
(15 , 2, 20),
(16 , 2, 20),
(17 , 2, 20),
(19 , 4, 20),
(20 , 4, 20);
select pk, a, b, ntile(-1) over (order by a)
from t1;
ERROR HY000: Argument of NTILE must be greater than 0
select pk, a, b,
ntile(0) over (order by a)
from t1;
ERROR HY000: Argument of NTILE must be greater than 0
select pk, a, b,
ntile(1) over (order by pk)
from t1;
pk a b ntile(1) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 1
15 2 20 1
16 2 20 1
17 2 20 1
18 2 10 1
19 4 20 1
20 4 20 1
select pk, a, b,
ntile(2) over (order by pk)
from t1;
pk a b ntile(2) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 1
15 2 20 1
16 2 20 2
17 2 20 2
18 2 10 2
19 4 20 2
20 4 20 2
select pk, a, b,
ntile(3) over (order by pk)
from t1;
pk a b ntile(3) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 1
15 2 20 2
16 2 20 2
17 2 20 2
18 2 10 3
19 4 20 3
20 4 20 3
select pk, a, b,
ntile(4) over (order by pk)
from t1;
pk a b ntile(4) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 2
15 2 20 2
16 2 20 2
17 2 20 3
18 2 10 3
19 4 20 4
20 4 20 4
select pk, a, b,
ntile(5) over (order by pk)
from t1;
pk a b ntile(5) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 2
15 2 20 3
16 2 20 3
17 2 20 4
18 2 10 4
19 4 20 5
20 4 20 5
select pk, a, b,
ntile(6) over (order by pk)
from t1;
pk a b ntile(6) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 2
15 2 20 3
16 2 20 3
17 2 20 4
18 2 10 4
19 4 20 5
20 4 20 6
select pk, a, b,
ntile(7) over (order by pk)
from t1;
pk a b ntile(7) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 2
15 2 20 3
16 2 20 3
17 2 20 4
18 2 10 5
19 4 20 6
20 4 20 7
select pk, a, b,
ntile(8) over (order by pk)
from t1;
pk a b ntile(8) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 2
15 2 20 3
16 2 20 4
17 2 20 5
18 2 10 6
19 4 20 7
20 4 20 8
select pk, a, b,
ntile(9) over (order by pk)
from t1;
pk a b ntile(9) over (order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 3
15 2 20 4
16 2 20 5
17 2 20 6
18 2 10 7
19 4 20 8
20 4 20 9
select pk, a, b,
ntile(10) over (order by pk)
from t1;
pk a b ntile(10) over (order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
15 2 20 5
16 2 20 6
17 2 20 7
18 2 10 8
19 4 20 9
20 4 20 10
select pk, a, b,
ntile(11) over (order by pk)
from t1;
pk a b ntile(11) over (order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
15 2 20 5
16 2 20 6
17 2 20 7
18 2 10 8
19 4 20 9
20 4 20 10
select pk, a, b,
ntile(20) over (order by pk)
from t1;
pk a b ntile(20) over (order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
15 2 20 5
16 2 20 6
17 2 20 7
18 2 10 8
19 4 20 9
20 4 20 10
select pk, a, b,
ntile(1) over (partition by b order by pk)
from t1;
pk a b ntile(1) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 1
18 2 10 1
15 2 20 1
16 2 20 1
17 2 20 1
19 4 20 1
20 4 20 1
select pk, a, b,
ntile(2) over (partition by b order by pk)
from t1;
pk a b ntile(2) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 2
18 2 10 2
15 2 20 1
16 2 20 1
17 2 20 1
19 4 20 2
20 4 20 2
select pk, a, b,
ntile(3) over (partition by b order by pk)
from t1;
pk a b ntile(3) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 2
18 2 10 3
15 2 20 1
16 2 20 1
17 2 20 2
19 4 20 2
20 4 20 3
select pk, a, b,
ntile(4) over (partition by b order by pk)
from t1;
pk a b ntile(4) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 3
18 2 10 4
15 2 20 1
16 2 20 1
17 2 20 2
19 4 20 3
20 4 20 4
select pk, a, b,
ntile(5) over (partition by b order by pk)
from t1;
pk a b ntile(5) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(6) over (partition by b order by pk)
from t1;
pk a b ntile(6) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(7) over (partition by b order by pk)
from t1;
pk a b ntile(7) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(8) over (partition by b order by pk)
from t1;
pk a b ntile(8) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(9) over (partition by b order by pk)
from t1;
pk a b ntile(9) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(10) over (partition by b order by pk)
from t1;
pk a b ntile(10) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(11) over (partition by b order by pk)
from t1;
pk a b ntile(11) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(20) over (partition by b order by pk)
from t1;
pk a b ntile(20) over (partition by b order by pk)
11 0 10 1
12 0 10 2
13 1 10 3
14 1 10 4
18 2 10 5
15 2 20 1
16 2 20 2
17 2 20 3
19 4 20 4
20 4 20 5
select pk, a, b,
ntile(1 + 3) over (partition by b order by pk)
from t1;
pk a b ntile(1 + 3) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 3
18 2 10 4
15 2 20 1
16 2 20 1
17 2 20 2
19 4 20 3
20 4 20 4
select pk, a, b,
ntile((select 4)) over (partition by b order by pk)
from t1;
pk a b ntile((select 4)) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 2
14 1 10 3
18 2 10 4
15 2 20 1
16 2 20 1
17 2 20 2
19 4 20 3
20 4 20 4
select t1.a from t1 where pk = 11;
a
0
select pk, a, b,
ntile((select a from t1 where pk=11)) over (partition by b order by pk)
from t1;
ERROR HY000: Argument of NTILE must be greater than 0
select t1.a from t1 where pk = 13;
a
1
select pk, a, b,
ntile((select a from t1 where pk=13)) over (partition by b order by pk)
from t1;
pk a b ntile((select a from t1 where pk=13)) over (partition by b order by pk)
11 0 10 1
12 0 10 1
13 1 10 1
14 1 10 1
18 2 10 1
15 2 20 1
16 2 20 1
17 2 20 1
19 4 20 1
20 4 20 1
explain
select pk, a, b,
ntile((select a from t1 where pk=13)) over (partition by b order by pk)
from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using temporary
2 SUBQUERY t1 const PRIMARY PRIMARY 4 const 1
select a from t1;
a
0
0
1
1
2
2
2
2
4
4
select pk, a, b,
ntile((select a from t1)) over (partition by b order by pk)
from t1;
ERROR 21000: Subquery returns more than 1 row
drop table t1;

View File

@ -0,0 +1,26 @@
drop table if exists t0,t1;
create table t0(a int primary key);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(
pk int,
a int,
key(pk)
);
insert into t1
select
A.a + B.a* 10 + C.a * 100,
1
from t0 A, t0 B, t0 C;
select
pk,
count(a) over (order by pk rows between 2 preceding and 2 following)
from t1
where pk between 1 and 30
order by pk desc
limit 4;
pk count(a) over (order by pk rows between 2 preceding and 2 following)
30 3
29 4
28 5
27 5
drop table t0,t1;

View File

@ -0,0 +1,62 @@
create table t1 (
pk int primary key,
a int,
b int
);
insert into t1 values
( 1 , 0, 10),
( 2 , 0, 10),
( 3 , 1, 10),
( 4 , 1, 10),
( 8 , 2, 10),
( 5 , 2, 20),
( 6 , 2, 20),
( 7 , 2, 20),
( 9 , 4, 20),
(10 , 4, 20);
select pk, a, b,
percent_rank() over (order by a),
cume_dist() over (order by a)
from t1;
pk a b percent_rank() over (order by a) cume_dist() over (order by a)
1 0 10 0.0000000000 0.2000000000
2 0 10 0.0000000000 0.2000000000
3 1 10 0.2222222222 0.4000000000
4 1 10 0.2222222222 0.4000000000
8 2 10 0.4444444444 0.8000000000
5 2 20 0.4444444444 0.8000000000
6 2 20 0.4444444444 0.8000000000
7 2 20 0.4444444444 0.8000000000
9 4 20 0.8888888889 1.0000000000
10 4 20 0.8888888889 1.0000000000
select pk, a, b,
percent_rank() over (order by pk),
cume_dist() over (order by pk)
from t1 order by pk;
pk a b percent_rank() over (order by pk) cume_dist() over (order by pk)
1 0 10 0.0000000000 0.1000000000
2 0 10 0.1111111111 0.2000000000
3 1 10 0.2222222222 0.3000000000
4 1 10 0.3333333333 0.4000000000
5 2 20 0.4444444444 0.5000000000
6 2 20 0.5555555556 0.6000000000
7 2 20 0.6666666667 0.7000000000
8 2 10 0.7777777778 0.8000000000
9 4 20 0.8888888889 0.9000000000
10 4 20 1.0000000000 1.0000000000
select pk, a, b,
percent_rank() over (partition by a order by a),
cume_dist() over (partition by a order by a)
from t1;
pk a b percent_rank() over (partition by a order by a) cume_dist() over (partition by a order by a)
1 0 10 0.0000000000 1.0000000000
2 0 10 0.0000000000 1.0000000000
3 1 10 0.0000000000 1.0000000000
4 1 10 0.0000000000 1.0000000000
8 2 10 0.0000000000 1.0000000000
5 2 20 0.0000000000 1.0000000000
6 2 20 0.0000000000 1.0000000000
7 2 20 0.0000000000 1.0000000000
9 4 20 0.0000000000 1.0000000000
10 4 20 0.0000000000 1.0000000000
drop table t1;

View File

@ -0,0 +1,104 @@
#
# Try DENSE_RANK() function
#
create table t1 (
pk int primary key,
a int,
b int
);
insert into t1 values
( 1 , 0, 10),
( 2 , 0, 10),
( 3 , 1, 10),
( 4 , 1, 10),
( 8 , 2, 10),
( 5 , 2, 20),
( 6 , 2, 20),
( 7 , 2, 20),
( 9 , 4, 20),
(10 , 4, 20);
select pk, a, b, rank() over (order by a) as rank,
dense_rank() over (order by a) as dense_rank
from t1;
pk a b rank dense_rank
1 0 10 1 1
2 0 10 1 1
3 1 10 3 2
4 1 10 3 2
8 2 10 5 3
5 2 20 5 3
6 2 20 5 3
7 2 20 5 3
9 4 20 9 4
10 4 20 9 4
select pk, a, b, rank() over (partition by b order by a) as rank,
dense_rank() over (partition by b order by a) as dense_rank
from t1;
pk a b rank dense_rank
1 0 10 1 1
2 0 10 1 1
3 1 10 3 2
4 1 10 3 2
8 2 10 5 3
5 2 20 1 1
6 2 20 1 1
7 2 20 1 1
9 4 20 4 2
10 4 20 4 2
drop table t1;
#
# Test with null values in the table.
#
create table t2 (s1 int, s2 char(5));
insert into t2 values (1,'a');
insert into t2 values (null,null);
insert into t2 values (1,null);
insert into t2 values (null,'a');
insert into t2 values (null,'c');
insert into t2 values (2,'b');
insert into t2 values (-1,'');
select *, rank() over (order by s1) as rank,
dense_rank() over (order by s1) as dense_rank
from t2;
s1 s2 rank dense_rank
1 a 5 3
NULL NULL 1 1
1 NULL 5 3
NULL a 1 1
NULL c 1 1
2 b 7 4
-1 4 2
select *, rank() over (partition by s2 order by s1) as rank,
dense_rank() over (partition by s2 order by s1) as dense_rank
from t2;
s1 s2 rank dense_rank
1 a 2 2
NULL NULL 1 1
1 NULL 2 2
NULL a 1 1
NULL c 1 1
2 b 1 1
-1 1 1
select *, rank() over (order by s2) as rank,
dense_rank() over (order by s2) as dense_rank
from t2;
s1 s2 rank dense_rank
1 a 4 3
NULL NULL 1 1
1 NULL 1 1
NULL a 4 3
NULL c 7 5
2 b 6 4
-1 3 2
select *, rank() over (partition by s1 order by s2) as rank,
dense_rank() over (partition by s1 order by s2) as dense_rank
from t2;
s1 s2 rank dense_rank
1 a 2 2
NULL NULL 1 1
1 NULL 1 1
NULL a 2 2
NULL c 3 3
2 b 1 1
-1 1 1
drop table t2;

View File

@ -0,0 +1,95 @@
create table t1 (
pk int primary key,
a int,
b int,
c real
);
insert into t1 values
(101 , 0, 10, 1.1),
(102 , 0, 10, 2.1),
(103 , 1, 10, 3.1),
(104 , 1, 10, 4.1),
(108 , 2, 10, 5.1),
(105 , 2, 20, 6.1),
(106 , 2, 20, 7.1),
(107 , 2, 20, 8.15),
(109 , 4, 20, 9.15),
(110 , 4, 20, 10.15),
(111 , 5, NULL, 11.15),
(112 , 5, 1, 12.25),
(113 , 5, NULL, 13.35),
(114 , 5, NULL, 14.50),
(115 , 5, NULL, 15.65),
(116 , 6, 1, NULL),
(117 , 6, 1, 10),
(118 , 6, 1, 1.1),
(119 , 6, 1, NULL),
(120 , 6, 1, NULL),
(121 , 6, 1, NULL),
(122 , 6, 1, 2.2),
(123 , 6, 1, 20.1),
(124 , 6, 1, -10.4),
(125 , 6, 1, NULL),
(126 , 6, 1, NULL),
(127 , 6, 1, NULL);
select pk, a, b, sum(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
from t1;
pk a b sum(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
101 0 10 20
102 0 10 20
103 1 10 20
104 1 10 20
105 2 20 40
106 2 20 60
107 2 20 50
108 2 10 30
109 4 20 40
110 4 20 40
111 5 NULL 1
112 5 1 1
113 5 NULL 1
114 5 NULL NULL
115 5 NULL NULL
116 6 1 2
117 6 1 3
118 6 1 3
119 6 1 3
120 6 1 3
121 6 1 3
122 6 1 3
123 6 1 3
124 6 1 3
125 6 1 3
126 6 1 3
127 6 1 2
select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
from t1;
pk a c sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
101 0 1.1 3.2
102 0 2.1 3.2
103 1 3.1 7.199999999999999
104 1 4.1 7.199999999999999
105 2 6.1 13.2
106 2 7.1 21.35
107 2 8.15 20.35
108 2 5.1 13.250000000000002
109 4 9.15 19.3
110 4 10.15 19.3
111 5 11.15 23.4
112 5 12.25 36.75
113 5 13.35 40.1
114 5 14.5 43.5
115 5 15.65 30.15
116 6 NULL 10
117 6 10 11.1
118 6 1.1 11.1
119 6 NULL 1.0999999999999996
120 6 NULL NULL
121 6 NULL 2.1999999999999997
122 6 2.2 22.3
123 6 20.1 11.9
124 6 -10.4 9.7
125 6 NULL -10.400000000000002
126 6 NULL NULL
127 6 NULL NULL
drop table t1;

View File

@ -0,0 +1,35 @@
33
mysql-bin.000001
4
127.0.0.1
root
3310
60
0
0
1800.000
0
0
using_gtid=1
=0

View File

@ -0,0 +1,37 @@
33
mysql-bin.000001
4
127.0.0.1
root
3310
60
0
0
1800.000
0
0
using_gtid=1
0

View File

@ -0,0 +1,35 @@
33
mysql-bin.000001
4
127.0.0.1
root
3310
60
0
0
1800.000
0
0
using_gtid=1
d=1

View File

@ -0,0 +1,35 @@
33
mysql-bin.000001
4
127.0.0.1
root
3310
60
0
0
1800.000
0
0
using_gtid=1
using_gtid

View File

@ -0,0 +1,36 @@
33
mysql-bin.000001
4
127.0.0.1
root
3310
60
0
0
1800.000
0
0
using_gtid=1
END_MARKER
do_domain_ids=20 Hulubulu!!?!

View File

@ -0,0 +1,35 @@
33
mysql-bin.000001
4
127.0.0.1
root
3310
60
0
0
1800.000
0
0
using_gtid=1

View File

@ -0,0 +1,11 @@
# This file has incomplete UJIS sequences {8F}, {8FA1},
# has a valid UJIS sequence {8FA1A1},
# and has no NL at the end:
# {8F} \n xxx1 {8FA1} \n xxx2 {8FA1A1} \n xxx3 \n {8FA1} EOF
<EFBFBD>
xxx1
<EFBFBD><EFBFBD>
xxx2
<EFBFBD><EFBFBD><EFBFBD>
xxx3
<EFBFBD><EFBFBD>

View File

@ -0,0 +1,12 @@
# This file has incomplete utf8mb4 sequences {D0}, {E180}, {F09F98},
# has a valid utf8mb4 sequence {F09F988E}
# and has no NL at the end:
# {D0} \n xxx1 {E180} xxx2 \n {F09F98} \n xxx3 {F09F988E} {F09F98} EOF
<EFBFBD>
xxx1
<EFBFBD><EFBFBD>
xxx2
<EFBFBD><EFBFBD><EFBFBD>
xxx3
😎
<EFBFBD><EFBFBD><EFBFBD>

View File

@ -0,0 +1 @@
<table><row><a>a<EFBFBD></a></row></table>

View File

@ -6,6 +6,7 @@
--connection node_1
# We need a user with a password to perform SST, otherwise we hit LP #1378253
CREATE USER 'sst';
GRANT ALL PRIVILEGES ON *.* TO 'sst';
--let $wsrep_sst_auth_orig = `SELECT @@wsrep_sst_auth`

View File

@ -1,7 +1,9 @@
# On node_1
connection node_1;
SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM;
SET @@GLOBAL.BINLOG_CHECKSUM=CRC32;
# On node_2
connection node_2;
SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM;
SET @@GLOBAL.BINLOG_CHECKSUM=CRC32;
USE test;
@ -23,6 +25,7 @@ c1
5
# On node_2
connection node_2;
SELECT * FROM test.t1;
c1
1
@ -31,6 +34,10 @@ c1
4
5
DROP TABLE t1;
connection node_1;
SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved;
connection node_2;
SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved;
disconnect node_2;
disconnect node_1;
# End of test

View File

@ -25,10 +25,12 @@ SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved;
#
# MDEV-7673: CREATE TABLE SELECT fails on Galera cluster
#
connection node_1;
CREATE TABLE t1 (i INT) ENGINE=INNODB DEFAULT CHARSET=utf8 SELECT 1 as i;
SELECT * FROM t1;
i
1
connection node_2;
SELECT * FROM t1;
i
1
@ -37,6 +39,7 @@ DROP TABLE t1;
# MDEV-8166 : Adding index on new table from select crashes Galera
# cluster
#
connection node_1;
CREATE TABLE t1(i int(11) NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO t1(i) VALUES (1), (2), (3);
CREATE TABLE t2 (i INT) SELECT i FROM t1;
@ -46,6 +49,7 @@ i
1
2
3
connection node_2;
SELECT * FROM t2;
i
1

View File

@ -2,11 +2,13 @@
# MDEV-8831 : enforce_storage_engine doesn't block table creation on
# other nodes (galera cluster)
#
connection node_1;
SET @@enforce_storage_engine=INNODB;
CREATE TABLE t1(i INT) ENGINE=INNODB;
CREATE TABLE t2(i INT) ENGINE=MYISAM;
ERROR 42000: Unknown storage engine 'MyISAM'
INSERT INTO t1 VALUES(1);
connection node_2;
SHOW TABLES;
Tables_in_test
t1
@ -14,6 +16,7 @@ SELECT COUNT(*)=1 FROM t1;
COUNT(*)=1
1
CREATE TABLE t2(i INT) ENGINE=MYISAM;
connection node_1;
SHOW TABLES;
Tables_in_test
t1

View File

@ -1,6 +1,7 @@
USE test;
# On node_1
connection node_1;
CREATE TABLE networks (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
@ -60,9 +61,11 @@ INSERT INTO ipallocations VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','10.25.
select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 fa:16:3e:e3:cc:bb 1 DOWN f37aa3fe-ab99-4d0f-a566-6cd3169d7516 network:router_gateway
connection node_2;
select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 fa:16:3e:e3:cc:bb 1 DOWN f37aa3fe-ab99-4d0f-a566-6cd3169d7516 network:router_gateway
connection node_1;
DELETE FROM ports WHERE ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
select * from networks;
tenant_id id name status admin_state_up shared
@ -78,6 +81,7 @@ select * from ports;
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
# On node_2
connection node_2;
select * from networks;
tenant_id id name status admin_state_up shared
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 MyNet ACTIVE 0 0
@ -90,7 +94,10 @@ select * from ipallocations;
port_id ip_address subnet_id network_id
select * from ports;
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
connection node_1;
drop table ipallocations;
drop table subnets;
drop table ports;
drop table networks;
disconnect node_2;
disconnect node_1;

View File

@ -1,39 +1,55 @@
connection node_1;
CREATE USER user1, user2 IDENTIFIED BY 'password';
connection node_2;
SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2');
COUNT(*) = 2
1
connection node_1;
RENAME USER user2 TO user3;
connection node_2;
SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2';
COUNT(*) = 0
1
SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user3';
COUNT(*) = 1
1
connection node_1;
SET PASSWORD FOR user3 = PASSWORD('foo');
connection node_1;
SELECT password != '' FROM mysql.user WHERE user = 'user3';
password != ''
1
connection node_1;
DROP USER user1, user3;
connection node_2;
SELECT COUNT(*) = 0 FROM mysql.user WHERE user IN ('user1', 'user2');
COUNT(*) = 0
1
connection node_1;
GRANT ALL ON *.* TO user4 IDENTIFIED BY 'password';
connection node_2;
SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user4';
COUNT(*) = 1
1
SELECT Select_priv = 'Y' FROM mysql.user WHERE user = 'user4';
Select_priv = 'Y'
1
connection node_1;
CREATE USER user5;
GRANT PROXY ON user4 TO user5;
connection node_2;
SELECT COUNT(*) = 1 FROM mysql.proxies_priv WHERE user = 'user5';
COUNT(*) = 1
1
connection node_1;
REVOKE ALL PRIVILEGES ON *.* FROM user4;
connection node_2;
SELECT Select_priv = 'N' FROM mysql.user WHERE user = 'user4';
Select_priv = 'N'
1
connection node_1;
REVOKE PROXY ON user4 FROM user5;
connection node_2;
SELECT COUNT(*) = 0 FROM mysql.proxies_priv WHERE user = 'user5';
COUNT(*) = 0
1

View File

@ -1,6 +1,7 @@
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
ALTER TABLE t1 ENGINE=InnoDB;
connection node_2;
SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
ENGINE = 'InnoDB'
1

View File

@ -2,10 +2,12 @@ SET GLOBAL wsrep_replicate_myisam = TRUE;
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1);
ALTER TABLE t1 ENGINE=InnoDB;
connection node_2;
SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
ENGINE = 'InnoDB'
1
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
connection node_1;
DROP TABLE t1;

View File

@ -1,6 +1,7 @@
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
ALTER TABLE t1 FORCE;
connection node_2;
SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
ENGINE = 'InnoDB'
1

View File

@ -1,12 +1,17 @@
connection node_1;
SET SESSION wsrep_sync_wait = 0;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLE t1 WITH READ LOCK;
connection node_2;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connection node_1a;
SET SESSION wsrep_sync_wait = 0;
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
connection node_1;
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = 7;
SELECT COUNT(*) = 2 FROM t1;

View File

@ -1,10 +1,13 @@
connection node_1;
SET SESSION wsrep_sync_wait = 0;
SET SESSION lock_wait_timeout = 60;
SET SESSION innodb_lock_wait_timeout=60;
SET SESSION wait_timeout=60;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLE t1 WITH READ LOCK;
connection node_2;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
connection node_1;
SELECT 1 FROM DUAL;
1
1

View File

@ -1,4 +1,6 @@
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
START SLAVE;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
# Disable binary logging for current session
@ -10,6 +12,7 @@ CREATE TABLE test.t3 AS SELECT * from t1;
SET SQL_LOG_BIN=ON;
INSERT INTO t1 VALUES(3);
CREATE TABLE test.t4 AS SELECT * from t1;
connection node_2;
SELECT * FROM t1;
f1
1
@ -27,6 +30,7 @@ f1
1
2
3
connection node_3;
SHOW TABLES;
Tables_in_test
t1
@ -41,8 +45,10 @@ f1
2
3
# Cleanup
connection node_1;
DROP TABLE t1, t4;
SET SQL_LOG_BIN=OFF;
DROP TABLE t2, t3;
connection node_3;
STOP SLAVE;
RESET SLAVE ALL;

View File

@ -2,7 +2,9 @@
# MDEV-9044 : Getting binlog corruption on my Galera cluster (10.1.8)
# making it impossible to async slave.
#
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
START SLAVE;
connection node_1;
SELECT @@GLOBAL.BINLOG_CACHE_SIZE;
@@GLOBAL.BINLOG_CACHE_SIZE
8192
@ -12,12 +14,14 @@ START TRANSACTION;
INSERT INTO t1 VALUES(1, REPEAT('-', 10000));
COMMIT;
INSERT INTO t2 VALUES(1);
connection node_2;
SELECT c1, LENGTH(c2) FROM t1;
c1 LENGTH(c2)
1 10000
SELECT * FROM t2;
c1
1
connection node_3;
SELECT c1, LENGTH(c2) FROM t1;
c1 LENGTH(c2)
1 10000
@ -25,6 +29,8 @@ SELECT * FROM t2;
c1
1
# Cleanup
connection node_1;
DROP TABLE t1, t2;
connection node_3;
STOP SLAVE;
RESET SLAVE ALL;

View File

@ -1,15 +1,24 @@
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2;
START SLAVE;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
connection node_2;
INSERT INTO t1 VALUES (2);
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
SELECT COUNT(*) = 2 FROM t1;
COUNT(*) = 2
1
INSERT INTO t1 VALUES (3);
connection node_2;
SELECT COUNT(*) = 3 FROM t1;
COUNT(*) = 3
1
connection node_1;
DROP TABLE t1;
connection node_2;
STOP SLAVE;
RESET SLAVE ALL;
connection node_1;
RESET MASTER;

View File

@ -1,16 +1,24 @@
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2;
START SLAVE;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
SELECT LENGTH(@@global.gtid_binlog_state) > 1;
LENGTH(@@global.gtid_binlog_state) > 1
1
connection node_2;
gtid_binlog_state_equal
1
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
gtid_binlog_state_equal
1
connection node_1;
DROP TABLE t1;
connection node_3;
connection node_2;
STOP SLAVE;
RESET SLAVE ALL;

View File

@ -1,7 +1,10 @@
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
connection node_2;
SET AUTOCOMMIT=OFF;
FLUSH TABLES t1 FOR EXPORT;
connection node_1;
INSERT INTO t1 VALUES (2);
connection node_2;
SET SESSION wsrep_sync_wait = 0;
UNLOCK TABLES;
COMMIT;

View File

@ -1,7 +1,10 @@
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
connection node_2;
SET AUTOCOMMIT=OFF;
FLUSH TABLES WITH READ LOCK;;
connection node_1;
INSERT INTO t1 VALUES (1);
connection node_2;
UNLOCK TABLES;
wsrep_local_aborts_increment
1

View File

@ -1,11 +1,15 @@
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
connection node_2a;
SELECT GET_LOCK("foo", 1000);
GET_LOCK("foo", 1000)
1
connection node_2;
SET AUTOCOMMIT=OFF;
INSERT INTO t1 VALUES (1);
SELECT GET_LOCK("foo", 1000);;
connection node_1;
INSERT INTO t1 VALUES (1);
connection node_2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
wsrep_local_aborts_increment
1

View File

@ -1,7 +1,10 @@
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
connection node_2;
SET AUTOCOMMIT=OFF;
LOCK TABLE t1 WRITE;
connection node_1;
INSERT INTO t1 VALUES (2);
connection node_2;
UNLOCK TABLES;
COMMIT;
SELECT COUNT(*) = 1 FROM t1;

View File

@ -1,8 +1,11 @@
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
connection node_2;
SET AUTOCOMMIT=OFF;
INSERT INTO t1 VALUES (1);
SELECT SLEEP(1000);;
connection node_1;
INSERT INTO t1 VALUES (1);
connection node_2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
wsrep_local_aborts_increment
1

View File

@ -3,6 +3,7 @@ CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
SET GLOBAL binlog_cache_size=4096;
SET GLOBAL max_binlog_cache_size=4096;
connection node_1a;
SET AUTOCOMMIT=ON;
START TRANSACTION;
INSERT INTO t1 SELECT REPEAT('a', 767) FROM ten;

View File

@ -1,9 +1,12 @@
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connection node_2;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
connection node_1;
UPDATE t1 SET f1 = 2 WHERE f1 = 1;
connection node_2;
SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;
COUNT(*) = 1
1

View File

@ -1,5 +1,6 @@
CREATE TABLE t1 (f1 VARCHAR(1000));
INSERT INTO t1 VALUES (REPEAT('x', 1000));
connection node_2;
SELECT COUNT(*) = 1 FROM t1 WHERE f1 = REPEAT('x', 1000);
COUNT(*) = 1
1

View File

@ -1 +1,3 @@
disconnect node_2;
disconnect node_1;
# End of test

View File

@ -1,3 +1,4 @@
connection node_1;
CREATE USER 'user1';
CREATE
DEFINER = 'user1'
@ -18,12 +19,14 @@ DETERMINISTIC
NO SQL
SQL SECURITY INVOKER
RETURN 123;
connection node_1;
SHOW CREATE FUNCTION f1;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` FUNCTION `f1`(param INTEGER) RETURNS varchar(200) CHARSET latin1
MODIFIES SQL DATA
COMMENT 'f1_comment'
RETURN 'abc' latin1 latin1_swedish_ci latin1_swedish_ci
connection node_2;
SELECT 1 FROM DUAL;
1
1
@ -33,6 +36,7 @@ f1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` FUNCTIO
MODIFIES SQL DATA
COMMENT 'f1_comment'
RETURN 'abc' latin1 latin1_swedish_ci latin1_swedish_ci
connection node_1;
SHOW CREATE FUNCTION f2;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f2`(param VARCHAR(100)) RETURNS int(11)
@ -40,6 +44,7 @@ f2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost`
DETERMINISTIC
SQL SECURITY INVOKER
RETURN 123 latin1 latin1_swedish_ci latin1_swedish_ci
connection node_2;
SHOW CREATE FUNCTION f2;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f2`(param VARCHAR(100)) RETURNS int(11)
@ -53,6 +58,7 @@ f1(1) = 'abc'
SELECT f2('abc') = 123;
f2('abc') = 123
1
connection node_1;
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP USER 'user1';

View File

@ -1,3 +1,4 @@
connection node_1;
CREATE USER 'user1';
CREATE TABLE t1 (f1 INTEGER);
CREATE
@ -16,12 +17,14 @@ PROCEDURE p2 (param VARCHAR(100))
DETERMINISTIC
NO SQL
SQL SECURITY INVOKER BEGIN END ;
connection node_1;
SHOW CREATE PROCEDURE p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` PROCEDURE `p1`(IN param1 INTEGER, OUT param2 INTEGER, INOUT param3 INTEGER)
MODIFIES SQL DATA
COMMENT 'p1_comment'
INSERT INTO t1 VALUES (1) latin1 latin1_swedish_ci latin1_swedish_ci
connection node_2;
SELECT 1 FROM DUAL;
1
1
@ -31,6 +34,7 @@ p1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` PROCEDU
MODIFIES SQL DATA
COMMENT 'p1_comment'
INSERT INTO t1 VALUES (1) latin1 latin1_swedish_ci latin1_swedish_ci
connection node_1;
SHOW CREATE PROCEDURE p2;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(param VARCHAR(100))
@ -38,6 +42,7 @@ p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost`
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN END latin1 latin1_swedish_ci latin1_swedish_ci
connection node_2;
SHOW CREATE PROCEDURE p2;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(param VARCHAR(100))
@ -47,6 +52,7 @@ p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost`
BEGIN END latin1 latin1_swedish_ci latin1_swedish_ci
CALL p1(@a, @b, @c);
CALL p2('abc');
connection node_1;
DROP PROCEDURE p1;
DROP PROCEDURE p2;
DROP USER 'user1';

View File

@ -11,6 +11,7 @@ CREATE TABLE real_table3 LIKE schema1.myisam_table;
CREATE TEMPORARY TABLE temp_table1 LIKE schema1.real_table;
CREATE TEMPORARY TABLE temp_table2 LIKE schema1.temp_table;
CREATE TEMPORARY TABLE temp_table3 LIKE schema1.myisam_table;
connection node_2;
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table' AND TABLE_SCHEMA = 'schema1';
COUNT(*) = 1
1
@ -38,6 +39,7 @@ COUNT(*) = 0
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table3' AND TABLE_SCHEMA = 'schema2';
COUNT(*) = 0
1
connection node_1;
DROP TABLE schema1.real_table;
DROP TABLE schema1.myisam_table;
DROP TABLE schema2.real_table1;

View File

@ -7,6 +7,7 @@ CREATE DEFINER=root@localhost TRIGGER definer_root BEFORE INSERT ON definer_root
CREATE DEFINER=user1 TRIGGER definer_user BEFORE INSERT ON definer_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER();
CREATE DEFINER=current_user TRIGGER definer_current_user BEFORE INSERT ON definer_current_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER();
CREATE TRIGGER definer_default BEFORE INSERT ON definer_default FOR EACH ROW SET NEW.trigger_user = CURRENT_USER();
connection node_2;
INSERT INTO definer_root (f1) VALUES (1);
SELECT DEFINER = 'root@localhost' FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME = 'definer_root';
DEFINER = 'root@localhost'
@ -35,6 +36,7 @@ DEFINER = 'root@localhost'
SELECT trigger_user = 'root@localhost' FROM definer_default;
trigger_user = 'root@localhost'
1
connection node_1;
DROP TABLE definer_current_user;
DROP TABLE definer_user;
DROP TABLE definer_root;

View File

@ -1,8 +1,11 @@
connection node_1;
CREATE TABLE ten (f1 INTEGER) Engine=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB;
INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND();
connection node_2;
DELETE FROM t1 ORDER BY RAND() LIMIT 5;
connection node_1;
sum_matches
1
max_matches
@ -10,7 +13,9 @@ max_matches
DROP TABLE t1;
CREATE TABLE t2 (f1 INTEGER) Engine=InnoDB;
INSERT INTO t2 SELECT f1 FROM ten ORDER BY RAND();
connection node_2;
DELETE FROM t2 ORDER BY RAND() LIMIT 5;
connection node_1;
sum_matches
1
max_matches

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