mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge branch '10.4' into mariadb-10.4.32
This commit is contained in:
2
VERSION
2
VERSION
@ -1,4 +1,4 @@
|
|||||||
MYSQL_VERSION_MAJOR=10
|
MYSQL_VERSION_MAJOR=10
|
||||||
MYSQL_VERSION_MINOR=4
|
MYSQL_VERSION_MINOR=4
|
||||||
MYSQL_VERSION_PATCH=32
|
MYSQL_VERSION_PATCH=33
|
||||||
SERVER_MATURITY=stable
|
SERVER_MATURITY=stable
|
||||||
|
@ -122,7 +122,8 @@ int sd_notifyf() { return 0; }
|
|||||||
int sys_var_init();
|
int sys_var_init();
|
||||||
|
|
||||||
/* === xtrabackup specific options === */
|
/* === xtrabackup specific options === */
|
||||||
char xtrabackup_real_target_dir[FN_REFLEN] = "./xtrabackup_backupfiles/";
|
#define DEFAULT_TARGET_DIR "./xtrabackup_backupfiles/"
|
||||||
|
char xtrabackup_real_target_dir[FN_REFLEN] = DEFAULT_TARGET_DIR;
|
||||||
char *xtrabackup_target_dir= xtrabackup_real_target_dir;
|
char *xtrabackup_target_dir= xtrabackup_real_target_dir;
|
||||||
static my_bool xtrabackup_version;
|
static my_bool xtrabackup_version;
|
||||||
static my_bool verbose;
|
static my_bool verbose;
|
||||||
@ -421,6 +422,9 @@ uint opt_safe_slave_backup_timeout = 0;
|
|||||||
|
|
||||||
const char *opt_history = NULL;
|
const char *opt_history = NULL;
|
||||||
|
|
||||||
|
/* Whether xtrabackup_binlog_info should be created on recovery */
|
||||||
|
static bool recover_binlog_info;
|
||||||
|
|
||||||
|
|
||||||
char mariabackup_exe[FN_REFLEN];
|
char mariabackup_exe[FN_REFLEN];
|
||||||
char orig_argv1[FN_REFLEN];
|
char orig_argv1[FN_REFLEN];
|
||||||
@ -1226,22 +1230,25 @@ struct my_option xb_client_options[]= {
|
|||||||
|
|
||||||
{"compress", OPT_XTRA_COMPRESS,
|
{"compress", OPT_XTRA_COMPRESS,
|
||||||
"Compress individual backup files using the "
|
"Compress individual backup files using the "
|
||||||
"specified compression algorithm. Currently the only supported algorithm "
|
"specified compression algorithm. It uses no longer maintained QuickLZ "
|
||||||
"is 'quicklz'. It is also the default algorithm, i.e. the one used when "
|
"library hence this option was deprecated with MariaDB 10.1.31 and 10.2.13.",
|
||||||
"--compress is used without an argument.",
|
|
||||||
(G_PTR *) &xtrabackup_compress_alg, (G_PTR *) &xtrabackup_compress_alg, 0,
|
(G_PTR *) &xtrabackup_compress_alg, (G_PTR *) &xtrabackup_compress_alg, 0,
|
||||||
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
|
||||||
{"compress-threads", OPT_XTRA_COMPRESS_THREADS,
|
{"compress-threads", OPT_XTRA_COMPRESS_THREADS,
|
||||||
"Number of threads for parallel data compression. The default value is "
|
"Number of threads for parallel data compression. The default value is "
|
||||||
"1.",
|
"1. "
|
||||||
|
"This option was deprecated as it relies on the no longer "
|
||||||
|
"maintained QuickLZ library.",
|
||||||
(G_PTR *) &xtrabackup_compress_threads,
|
(G_PTR *) &xtrabackup_compress_threads,
|
||||||
(G_PTR *) &xtrabackup_compress_threads, 0, GET_UINT, REQUIRED_ARG, 1, 1,
|
(G_PTR *) &xtrabackup_compress_threads, 0, GET_UINT, REQUIRED_ARG, 1, 1,
|
||||||
UINT_MAX, 0, 0, 0},
|
UINT_MAX, 0, 0, 0},
|
||||||
|
|
||||||
{"compress-chunk-size", OPT_XTRA_COMPRESS_CHUNK_SIZE,
|
{"compress-chunk-size", OPT_XTRA_COMPRESS_CHUNK_SIZE,
|
||||||
"Size of working buffer(s) for compression threads in bytes. The default "
|
"Size of working buffer(s) for compression threads in bytes. The default "
|
||||||
"value is 64K.",
|
"value is 64K. "
|
||||||
|
"This option was deprecated as it relies on the no longer "
|
||||||
|
"maintained QuickLZ library.",
|
||||||
(G_PTR *) &xtrabackup_compress_chunk_size,
|
(G_PTR *) &xtrabackup_compress_chunk_size,
|
||||||
(G_PTR *) &xtrabackup_compress_chunk_size, 0, GET_ULL, REQUIRED_ARG,
|
(G_PTR *) &xtrabackup_compress_chunk_size, 0, GET_ULL, REQUIRED_ARG,
|
||||||
(1 << 16), 1024, ULONGLONG_MAX, 0, 0, 0},
|
(1 << 16), 1024, ULONGLONG_MAX, 0, 0, 0},
|
||||||
@ -1362,7 +1369,9 @@ struct my_option xb_client_options[]= {
|
|||||||
|
|
||||||
{"decompress", OPT_DECOMPRESS,
|
{"decompress", OPT_DECOMPRESS,
|
||||||
"Decompresses all files with the .qp "
|
"Decompresses all files with the .qp "
|
||||||
"extension in a backup previously made with the --compress option.",
|
"extension in a backup previously made with the --compress option. "
|
||||||
|
"This option was deprecated as it relies on the no longer "
|
||||||
|
"maintained QuickLZ library.",
|
||||||
(uchar *) &opt_decompress, (uchar *) &opt_decompress, 0, GET_BOOL, NO_ARG,
|
(uchar *) &opt_decompress, (uchar *) &opt_decompress, 0, GET_BOOL, NO_ARG,
|
||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, 0, 0, 0},
|
||||||
|
|
||||||
@ -2335,6 +2344,7 @@ xtrabackup_read_metadata(char *filename)
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
my_bool r = TRUE;
|
my_bool r = TRUE;
|
||||||
|
int t;
|
||||||
|
|
||||||
fp = fopen(filename,"r");
|
fp = fopen(filename,"r");
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
@ -2365,6 +2375,9 @@ xtrabackup_read_metadata(char *filename)
|
|||||||
}
|
}
|
||||||
/* Optional fields */
|
/* Optional fields */
|
||||||
|
|
||||||
|
if (fscanf(fp, "recover_binlog_info = %d\n", &t) == 1) {
|
||||||
|
recover_binlog_info = (t == 1);
|
||||||
|
}
|
||||||
end:
|
end:
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
@ -2383,11 +2396,13 @@ xtrabackup_print_metadata(char *buf, size_t buf_len)
|
|||||||
"backup_type = %s\n"
|
"backup_type = %s\n"
|
||||||
"from_lsn = " UINT64PF "\n"
|
"from_lsn = " UINT64PF "\n"
|
||||||
"to_lsn = " UINT64PF "\n"
|
"to_lsn = " UINT64PF "\n"
|
||||||
"last_lsn = " UINT64PF "\n",
|
"last_lsn = " UINT64PF "\n"
|
||||||
|
"recover_binlog_info = %d\n",
|
||||||
metadata_type,
|
metadata_type,
|
||||||
metadata_from_lsn,
|
metadata_from_lsn,
|
||||||
metadata_to_lsn,
|
metadata_to_lsn,
|
||||||
metadata_last_lsn);
|
metadata_last_lsn,
|
||||||
|
MY_TEST(opt_binlog_info == BINLOG_INFO_LOCKLESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
@ -6031,6 +6046,26 @@ static ibool prepare_handle_del_files(const char *datadir, const char *db, const
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
Store the current binary log coordinates in a specified file.
|
||||||
|
@return 'false' on error. */
|
||||||
|
static bool
|
||||||
|
store_binlog_info(const char *filename, const char* name, ulonglong pos)
|
||||||
|
{
|
||||||
|
FILE *fp = fopen(filename, "w");
|
||||||
|
|
||||||
|
if (!fp) {
|
||||||
|
msg("mariabackup: failed to open '%s'\n", filename);
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fp, "%s\t%llu\n", name, pos);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
/** Implement --prepare
|
/** Implement --prepare
|
||||||
@return whether the operation succeeded */
|
@return whether the operation succeeded */
|
||||||
static bool xtrabackup_prepare_func(char** argv)
|
static bool xtrabackup_prepare_func(char** argv)
|
||||||
@ -6270,6 +6305,20 @@ static bool xtrabackup_prepare_func(char** argv)
|
|||||||
msg("Last binlog file %s, position %lld",
|
msg("Last binlog file %s, position %lld",
|
||||||
trx_sys.recovered_binlog_filename,
|
trx_sys.recovered_binlog_filename,
|
||||||
longlong(trx_sys.recovered_binlog_offset));
|
longlong(trx_sys.recovered_binlog_offset));
|
||||||
|
|
||||||
|
/* output to xtrabackup_binlog_pos_innodb and (if
|
||||||
|
backup_safe_binlog_info was available on the server) to
|
||||||
|
xtrabackup_binlog_info. In the latter case
|
||||||
|
xtrabackup_binlog_pos_innodb becomes redundant and is created
|
||||||
|
only for compatibility. */
|
||||||
|
ok = store_binlog_info(
|
||||||
|
"xtrabackup_binlog_pos_innodb",
|
||||||
|
trx_sys.recovered_binlog_filename,
|
||||||
|
trx_sys.recovered_binlog_offset)
|
||||||
|
&& (!recover_binlog_info || store_binlog_info(
|
||||||
|
XTRABACKUP_BINLOG_INFO,
|
||||||
|
trx_sys.recovered_binlog_filename,
|
||||||
|
trx_sys.recovered_binlog_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether the log is applied enough or not. */
|
/* Check whether the log is applied enough or not. */
|
||||||
@ -6708,9 +6757,10 @@ void handle_options(int argc, char **argv, char ***argv_server,
|
|||||||
server_default_groups.push_back(NULL);
|
server_default_groups.push_back(NULL);
|
||||||
snprintf(conf_file, sizeof(conf_file), "my");
|
snprintf(conf_file, sizeof(conf_file), "my");
|
||||||
|
|
||||||
if (prepare && target_dir) {
|
if (prepare) {
|
||||||
snprintf(conf_file, sizeof(conf_file),
|
snprintf(conf_file, sizeof(conf_file),
|
||||||
"%s/backup-my.cnf", target_dir);
|
"%s/backup-my.cnf", target_dir ? target_dir:
|
||||||
|
DEFAULT_TARGET_DIR);
|
||||||
if (!strncmp(argv[1], "--defaults-file=", 16)) {
|
if (!strncmp(argv[1], "--defaults-file=", 16)) {
|
||||||
/* Remove defaults-file*/
|
/* Remove defaults-file*/
|
||||||
for (int i = 2; ; i++) {
|
for (int i = 2; ; i++) {
|
||||||
|
@ -171,7 +171,7 @@ extern uint opt_safe_slave_backup_timeout;
|
|||||||
|
|
||||||
extern const char *opt_history;
|
extern const char *opt_history;
|
||||||
|
|
||||||
enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_ON,
|
enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_LOCKLESS, BINLOG_INFO_ON,
|
||||||
BINLOG_INFO_AUTO};
|
BINLOG_INFO_AUTO};
|
||||||
|
|
||||||
extern ulong opt_binlog_info;
|
extern ulong opt_binlog_info;
|
||||||
|
@ -83,7 +83,7 @@ static inline ulonglong uint6korr(const void *p)
|
|||||||
#define HAVE_mi_uint5korr
|
#define HAVE_mi_uint5korr
|
||||||
#define HAVE_mi_uint6korr
|
#define HAVE_mi_uint6korr
|
||||||
#define HAVE_mi_uint7korr
|
#define HAVE_mi_uint7korr
|
||||||
#define HAVE_mi_uint78orr
|
#define HAVE_mi_uint8korr
|
||||||
|
|
||||||
/* Read numbers stored in high-bytes-first order */
|
/* Read numbers stored in high-bytes-first order */
|
||||||
|
|
||||||
|
@ -324,7 +324,8 @@ enum my_lex_states
|
|||||||
MY_LEX_IDENT_OR_KEYWORD,
|
MY_LEX_IDENT_OR_KEYWORD,
|
||||||
MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
|
MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
|
||||||
MY_LEX_STRING_OR_DELIMITER, MY_LEX_MINUS_OR_COMMENT, MY_LEX_PLACEHOLDER,
|
MY_LEX_STRING_OR_DELIMITER, MY_LEX_MINUS_OR_COMMENT, MY_LEX_PLACEHOLDER,
|
||||||
MY_LEX_COMMA
|
MY_LEX_COMMA,
|
||||||
|
MY_LEX_IDENT_OR_QUALIFIED_SPECIAL_FUNC
|
||||||
};
|
};
|
||||||
|
|
||||||
struct charset_info_st;
|
struct charset_info_st;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef MARIADB_CAPI_RENAME_INCLUDED
|
#ifndef MARIADB_CAPI_RENAME_INCLUDED
|
||||||
#define MARIADB_CAPI_RENAME_INCLUDED
|
#define MARIADB_CAPI_RENAME_INCLUDED
|
||||||
|
|
||||||
#if !defined(EMBEDDED_LIBRARY)
|
#if !defined(EMBEDDED_LIBRARY) && !defined(MYSQL_DYNAMIC_PLUGIN)
|
||||||
|
|
||||||
#define MARIADB_ADD_PREFIX(_SYMBOL) server_##_SYMBOL
|
#define MARIADB_ADD_PREFIX(_SYMBOL) server_##_SYMBOL
|
||||||
#define mysql_real_connect MARIADB_ADD_PREFIX(mysql_real_connect)
|
#define mysql_real_connect MARIADB_ADD_PREFIX(mysql_real_connect)
|
||||||
|
@ -117,6 +117,7 @@ typedef struct st_handler_check_param
|
|||||||
uint progress_counter; /* How often to call _report_progress() */
|
uint progress_counter; /* How often to call _report_progress() */
|
||||||
ulonglong progress, max_progress;
|
ulonglong progress, max_progress;
|
||||||
|
|
||||||
|
void (*init_fix_record)(void *);
|
||||||
int (*fix_record)(struct st_myisam_info *info, uchar *record, int keynum);
|
int (*fix_record)(struct st_myisam_info *info, uchar *record, int keynum);
|
||||||
|
|
||||||
mysql_mutex_t print_msg_mutex;
|
mysql_mutex_t print_msg_mutex;
|
||||||
|
@ -331,7 +331,7 @@ typedef struct st_mysql_res {
|
|||||||
} MYSQL_RES;
|
} MYSQL_RES;
|
||||||
|
|
||||||
|
|
||||||
#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
|
#if !defined(MYSQL_SERVICE_SQL) && !defined(MYSQL_CLIENT)
|
||||||
#define MYSQL_CLIENT
|
#define MYSQL_CLIENT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ typedef struct st_mysql_parameters
|
|||||||
*/
|
*/
|
||||||
#define MYSQL_WAIT_TIMEOUT 8
|
#define MYSQL_WAIT_TIMEOUT 8
|
||||||
|
|
||||||
#if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
|
#if !defined(MYSQL_SERVICE_SQL)
|
||||||
#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
|
#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
|
||||||
#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
|
#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
|
||||||
#endif
|
#endif
|
||||||
|
@ -419,6 +419,33 @@ int json_escape_string(const char *str,const char *str_end,
|
|||||||
char *json, char *json_end);
|
char *json, char *json_end);
|
||||||
int json_unescape_json(const char *json_str, const char *json_end,
|
int json_unescape_json(const char *json_str, const char *json_end,
|
||||||
char *res, char *res_end);
|
char *res, char *res_end);
|
||||||
|
extern struct sql_service_st {
|
||||||
|
MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd, const char *db, unsigned int port,
|
||||||
|
const char *unix_socket, unsigned long clientflag);
|
||||||
|
unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql);
|
||||||
|
const char *(STDCALL *mysql_error_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q,
|
||||||
|
unsigned long length);
|
||||||
|
my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql);
|
||||||
|
my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res);
|
||||||
|
MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql);
|
||||||
|
void (STDCALL *mysql_free_result_func)(MYSQL_RES *result);
|
||||||
|
MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result);
|
||||||
|
void (STDCALL *mysql_close_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_options_func)(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
unsigned long *(STDCALL *mysql_fetch_lengths_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_set_character_set_func)(MYSQL *mysql, const char *cs_name);
|
||||||
|
unsigned int (STDCALL *mysql_num_fields_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_select_db_func)(MYSQL *mysql, const char *db);
|
||||||
|
my_bool (STDCALL *mysql_ssl_set_func)(MYSQL *mysql, const char *key,
|
||||||
|
const char *cert, const char *ca,
|
||||||
|
const char *capath, const char *cipher);
|
||||||
|
} *sql_service;
|
||||||
|
MYSQL *mysql_real_connect_local(MYSQL *mysql);
|
||||||
struct st_mysql_xid {
|
struct st_mysql_xid {
|
||||||
long formatID;
|
long formatID;
|
||||||
long gtrid_length;
|
long gtrid_length;
|
||||||
|
@ -419,6 +419,33 @@ int json_escape_string(const char *str,const char *str_end,
|
|||||||
char *json, char *json_end);
|
char *json, char *json_end);
|
||||||
int json_unescape_json(const char *json_str, const char *json_end,
|
int json_unescape_json(const char *json_str, const char *json_end,
|
||||||
char *res, char *res_end);
|
char *res, char *res_end);
|
||||||
|
extern struct sql_service_st {
|
||||||
|
MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd, const char *db, unsigned int port,
|
||||||
|
const char *unix_socket, unsigned long clientflag);
|
||||||
|
unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql);
|
||||||
|
const char *(STDCALL *mysql_error_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q,
|
||||||
|
unsigned long length);
|
||||||
|
my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql);
|
||||||
|
my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res);
|
||||||
|
MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql);
|
||||||
|
void (STDCALL *mysql_free_result_func)(MYSQL_RES *result);
|
||||||
|
MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result);
|
||||||
|
void (STDCALL *mysql_close_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_options_func)(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
unsigned long *(STDCALL *mysql_fetch_lengths_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_set_character_set_func)(MYSQL *mysql, const char *cs_name);
|
||||||
|
unsigned int (STDCALL *mysql_num_fields_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_select_db_func)(MYSQL *mysql, const char *db);
|
||||||
|
my_bool (STDCALL *mysql_ssl_set_func)(MYSQL *mysql, const char *key,
|
||||||
|
const char *cert, const char *ca,
|
||||||
|
const char *capath, const char *cipher);
|
||||||
|
} *sql_service;
|
||||||
|
MYSQL *mysql_real_connect_local(MYSQL *mysql);
|
||||||
struct st_mysql_xid {
|
struct st_mysql_xid {
|
||||||
long formatID;
|
long formatID;
|
||||||
long gtrid_length;
|
long gtrid_length;
|
||||||
|
@ -419,6 +419,33 @@ int json_escape_string(const char *str,const char *str_end,
|
|||||||
char *json, char *json_end);
|
char *json, char *json_end);
|
||||||
int json_unescape_json(const char *json_str, const char *json_end,
|
int json_unescape_json(const char *json_str, const char *json_end,
|
||||||
char *res, char *res_end);
|
char *res, char *res_end);
|
||||||
|
extern struct sql_service_st {
|
||||||
|
MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd, const char *db, unsigned int port,
|
||||||
|
const char *unix_socket, unsigned long clientflag);
|
||||||
|
unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql);
|
||||||
|
const char *(STDCALL *mysql_error_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q,
|
||||||
|
unsigned long length);
|
||||||
|
my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql);
|
||||||
|
my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res);
|
||||||
|
MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql);
|
||||||
|
void (STDCALL *mysql_free_result_func)(MYSQL_RES *result);
|
||||||
|
MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result);
|
||||||
|
void (STDCALL *mysql_close_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_options_func)(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
unsigned long *(STDCALL *mysql_fetch_lengths_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_set_character_set_func)(MYSQL *mysql, const char *cs_name);
|
||||||
|
unsigned int (STDCALL *mysql_num_fields_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_select_db_func)(MYSQL *mysql, const char *db);
|
||||||
|
my_bool (STDCALL *mysql_ssl_set_func)(MYSQL *mysql, const char *key,
|
||||||
|
const char *cert, const char *ca,
|
||||||
|
const char *capath, const char *cipher);
|
||||||
|
} *sql_service;
|
||||||
|
MYSQL *mysql_real_connect_local(MYSQL *mysql);
|
||||||
struct st_mysql_xid {
|
struct st_mysql_xid {
|
||||||
long formatID;
|
long formatID;
|
||||||
long gtrid_length;
|
long gtrid_length;
|
||||||
|
@ -419,6 +419,33 @@ int json_escape_string(const char *str,const char *str_end,
|
|||||||
char *json, char *json_end);
|
char *json, char *json_end);
|
||||||
int json_unescape_json(const char *json_str, const char *json_end,
|
int json_unescape_json(const char *json_str, const char *json_end,
|
||||||
char *res, char *res_end);
|
char *res, char *res_end);
|
||||||
|
extern struct sql_service_st {
|
||||||
|
MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd, const char *db, unsigned int port,
|
||||||
|
const char *unix_socket, unsigned long clientflag);
|
||||||
|
unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql);
|
||||||
|
const char *(STDCALL *mysql_error_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q,
|
||||||
|
unsigned long length);
|
||||||
|
my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql);
|
||||||
|
my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res);
|
||||||
|
MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql);
|
||||||
|
void (STDCALL *mysql_free_result_func)(MYSQL_RES *result);
|
||||||
|
MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result);
|
||||||
|
void (STDCALL *mysql_close_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_options_func)(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
unsigned long *(STDCALL *mysql_fetch_lengths_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_set_character_set_func)(MYSQL *mysql, const char *cs_name);
|
||||||
|
unsigned int (STDCALL *mysql_num_fields_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_select_db_func)(MYSQL *mysql, const char *db);
|
||||||
|
my_bool (STDCALL *mysql_ssl_set_func)(MYSQL *mysql, const char *key,
|
||||||
|
const char *cert, const char *ca,
|
||||||
|
const char *capath, const char *cipher);
|
||||||
|
} *sql_service;
|
||||||
|
MYSQL *mysql_real_connect_local(MYSQL *mysql);
|
||||||
struct st_mysql_xid {
|
struct st_mysql_xid {
|
||||||
long formatID;
|
long formatID;
|
||||||
long gtrid_length;
|
long gtrid_length;
|
||||||
|
@ -419,6 +419,33 @@ int json_escape_string(const char *str,const char *str_end,
|
|||||||
char *json, char *json_end);
|
char *json, char *json_end);
|
||||||
int json_unescape_json(const char *json_str, const char *json_end,
|
int json_unescape_json(const char *json_str, const char *json_end,
|
||||||
char *res, char *res_end);
|
char *res, char *res_end);
|
||||||
|
extern struct sql_service_st {
|
||||||
|
MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd, const char *db, unsigned int port,
|
||||||
|
const char *unix_socket, unsigned long clientflag);
|
||||||
|
unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql);
|
||||||
|
const char *(STDCALL *mysql_error_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q,
|
||||||
|
unsigned long length);
|
||||||
|
my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql);
|
||||||
|
my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res);
|
||||||
|
MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql);
|
||||||
|
void (STDCALL *mysql_free_result_func)(MYSQL_RES *result);
|
||||||
|
MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result);
|
||||||
|
void (STDCALL *mysql_close_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_options_func)(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
unsigned long *(STDCALL *mysql_fetch_lengths_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_set_character_set_func)(MYSQL *mysql, const char *cs_name);
|
||||||
|
unsigned int (STDCALL *mysql_num_fields_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_select_db_func)(MYSQL *mysql, const char *db);
|
||||||
|
my_bool (STDCALL *mysql_ssl_set_func)(MYSQL *mysql, const char *key,
|
||||||
|
const char *cert, const char *ca,
|
||||||
|
const char *capath, const char *cipher);
|
||||||
|
} *sql_service;
|
||||||
|
MYSQL *mysql_real_connect_local(MYSQL *mysql);
|
||||||
struct st_mysql_xid {
|
struct st_mysql_xid {
|
||||||
long formatID;
|
long formatID;
|
||||||
long gtrid_length;
|
long gtrid_length;
|
||||||
|
119
include/mysql/service_sql.h
Normal file
119
include/mysql/service_sql.h
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/* Copyright (C) 2021 MariaDB Corporation
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
|
||||||
|
|
||||||
|
#ifndef MYSQL_SERVICE_SQL
|
||||||
|
#define MYSQL_SERVICE_SQL
|
||||||
|
|
||||||
|
#ifndef MYSQL_ABI_CHECK
|
||||||
|
#include <mysql.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
SQL service
|
||||||
|
|
||||||
|
Interface for plugins to execute SQL queries on the local server.
|
||||||
|
|
||||||
|
Functions of the service are the 'server-limited' client library:
|
||||||
|
mysql_init
|
||||||
|
mysql_real_connect_local
|
||||||
|
mysql_real_connect
|
||||||
|
mysql_errno
|
||||||
|
mysql_error
|
||||||
|
mysql_real_query
|
||||||
|
mysql_affected_rows
|
||||||
|
mysql_num_rows
|
||||||
|
mysql_store_result
|
||||||
|
mysql_free_result
|
||||||
|
mysql_fetch_row
|
||||||
|
mysql_close
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern struct sql_service_st {
|
||||||
|
MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql);
|
||||||
|
MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host,
|
||||||
|
const char *user, const char *passwd, const char *db, unsigned int port,
|
||||||
|
const char *unix_socket, unsigned long clientflag);
|
||||||
|
unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql);
|
||||||
|
const char *(STDCALL *mysql_error_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q,
|
||||||
|
unsigned long length);
|
||||||
|
my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql);
|
||||||
|
my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res);
|
||||||
|
MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql);
|
||||||
|
void (STDCALL *mysql_free_result_func)(MYSQL_RES *result);
|
||||||
|
MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result);
|
||||||
|
void (STDCALL *mysql_close_func)(MYSQL *mysql);
|
||||||
|
int (STDCALL *mysql_options_func)(MYSQL *mysql, enum mysql_option option,
|
||||||
|
const void *arg);
|
||||||
|
unsigned long *(STDCALL *mysql_fetch_lengths_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_set_character_set_func)(MYSQL *mysql, const char *cs_name);
|
||||||
|
unsigned int (STDCALL *mysql_num_fields_func)(MYSQL_RES *res);
|
||||||
|
int (STDCALL *mysql_select_db_func)(MYSQL *mysql, const char *db);
|
||||||
|
my_bool (STDCALL *mysql_ssl_set_func)(MYSQL *mysql, const char *key,
|
||||||
|
const char *cert, const char *ca,
|
||||||
|
const char *capath, const char *cipher);
|
||||||
|
} *sql_service;
|
||||||
|
|
||||||
|
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||||
|
|
||||||
|
#define mysql_init(M) sql_service->mysql_init_func(M)
|
||||||
|
#define mysql_real_connect_local(M) sql_service->mysql_real_connect_local_func(M)
|
||||||
|
#define mysql_real_connect(M,H,U,PW,D,P,S,F) sql_service->mysql_real_connect_func(M,H,U,PW,D,P,S,F)
|
||||||
|
#define mysql_errno(M) sql_service->mysql_errno_func(M)
|
||||||
|
#define mysql_error(M) sql_service->mysql_error_func(M)
|
||||||
|
#define mysql_real_query sql_service->mysql_real_query_func
|
||||||
|
#define mysql_affected_rows(M) sql_service->mysql_affected_rows_func(M)
|
||||||
|
#define mysql_num_rows(R) sql_service->mysql_num_rows_func(R)
|
||||||
|
#define mysql_store_result(M) sql_service->mysql_store_result_func(M)
|
||||||
|
#define mysql_free_result(R) sql_service->mysql_free_result_func(R)
|
||||||
|
#define mysql_fetch_row(R) sql_service->mysql_fetch_row_func(R)
|
||||||
|
#define mysql_close(M) sql_service->mysql_close_func(M)
|
||||||
|
#define mysql_options(M,O,V) sql_service->mysql_options_func(M,O,V)
|
||||||
|
#define mysql_fetch_lengths(R) sql_service->mysql_fetch_lengths_func(R)
|
||||||
|
#define mysql_set_character_set(M,C) sql_service->mysql_set_character_set_func(M,C)
|
||||||
|
#define mysql_num_fields(R) sql_service->mysql_num_fields_func(R)
|
||||||
|
#define mysql_select_db(M,D) sql_service->mysql_select_db_func(M,D)
|
||||||
|
#define mysql_ssl_set(M,K,C,A,P,H) sql_service->mysql_ssl_set_func(M,K,C,A,P,H)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/*
|
||||||
|
Establishes the connection to the 'local' server that started the plugin.
|
||||||
|
Like the mysql_real_connect() does for the remote server.
|
||||||
|
The established connection has no user/host associated to it,
|
||||||
|
neither it has the current db, so the queries should have
|
||||||
|
database/table name specified.
|
||||||
|
*/
|
||||||
|
MYSQL *mysql_real_connect_local(MYSQL *mysql);
|
||||||
|
|
||||||
|
/* The rest of the function declarations must be taken from the mysql.h */
|
||||||
|
|
||||||
|
#endif /*MYSQL_DYNAMIC_PLUGIN*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*MYSQL_SERVICE_SQL */
|
||||||
|
|
||||||
|
|
@ -41,6 +41,7 @@ extern "C" {
|
|||||||
#include <mysql/service_thd_wait.h>
|
#include <mysql/service_thd_wait.h>
|
||||||
#include <mysql/service_json.h>
|
#include <mysql/service_json.h>
|
||||||
/*#include <mysql/service_wsrep.h>*/
|
/*#include <mysql/service_wsrep.h>*/
|
||||||
|
#include <mysql/service_sql.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -43,3 +43,4 @@
|
|||||||
#define VERSION_thd_wait 0x0100
|
#define VERSION_thd_wait 0x0100
|
||||||
#define VERSION_wsrep 0x0400
|
#define VERSION_wsrep 0x0400
|
||||||
#define VERSION_json 0x0100
|
#define VERSION_json 0x0100
|
||||||
|
#define VERSION_sql_service 0x0100
|
||||||
|
@ -65,13 +65,13 @@ typedef struct st_mysql_methods
|
|||||||
MYSQL_ROW column, unsigned int field_count);
|
MYSQL_ROW column, unsigned int field_count);
|
||||||
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
|
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
|
||||||
int (*read_change_user_result)(MYSQL *mysql);
|
int (*read_change_user_result)(MYSQL *mysql);
|
||||||
|
void (*on_close_free)(MYSQL *mysql);
|
||||||
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
|
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
|
||||||
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
|
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
|
||||||
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
||||||
int (*stmt_execute)(MYSQL_STMT *stmt);
|
int (*stmt_execute)(MYSQL_STMT *stmt);
|
||||||
int (*read_binary_rows)(MYSQL_STMT *stmt);
|
int (*read_binary_rows)(MYSQL_STMT *stmt);
|
||||||
int (*unbuffered_fetch)(MYSQL *mysql, char **row);
|
int (*unbuffered_fetch)(MYSQL *mysql, char **row);
|
||||||
void (*free_embedded_thd)(MYSQL *mysql);
|
|
||||||
const char *(*read_statistics)(MYSQL *mysql);
|
const char *(*read_statistics)(MYSQL *mysql);
|
||||||
my_bool (*next_result)(MYSQL *mysql);
|
my_bool (*next_result)(MYSQL *mysql);
|
||||||
int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
|
int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
|
||||||
|
@ -490,7 +490,7 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)
|
|||||||
*prev_row= NULL;
|
*prev_row= NULL;
|
||||||
data->embedded_info->prev_ptr= prev_row;
|
data->embedded_info->prev_ptr= prev_row;
|
||||||
return_ok:
|
return_ok:
|
||||||
net_send_eof(thd, thd->server_status,
|
thd->protocol->net_send_eof(thd, thd->server_status,
|
||||||
thd->get_stmt_da()->current_statement_warn_count());
|
thd->get_stmt_da()->current_statement_warn_count());
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
err:
|
err:
|
||||||
|
@ -43,7 +43,7 @@ C_MODE_START
|
|||||||
extern unsigned int mysql_server_last_errno;
|
extern unsigned int mysql_server_last_errno;
|
||||||
extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
|
extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
|
||||||
static my_bool emb_read_query_result(MYSQL *mysql);
|
static my_bool emb_read_query_result(MYSQL *mysql);
|
||||||
static void emb_free_embedded_thd(MYSQL *mysql);
|
static void free_embedded_thd(MYSQL *mysql);
|
||||||
static bool embedded_print_errors= 0;
|
static bool embedded_print_errors= 0;
|
||||||
|
|
||||||
extern "C" void unireg_clear(int exit_code)
|
extern "C" void unireg_clear(int exit_code)
|
||||||
@ -121,7 +121,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
|||||||
thd->killed= NOT_KILLED;
|
thd->killed= NOT_KILLED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emb_free_embedded_thd(mysql);
|
free_embedded_thd(mysql);
|
||||||
thd= 0;
|
thd= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ int emb_unbuffered_fetch(MYSQL *mysql, char **row)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emb_free_embedded_thd(MYSQL *mysql)
|
static void free_embedded_thd(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
THD *thd= (THD*)mysql->thd;
|
THD *thd= (THD*)mysql->thd;
|
||||||
server_threads.erase(thd);
|
server_threads.erase(thd);
|
||||||
@ -454,12 +454,25 @@ static MYSQL_RES * emb_store_result(MYSQL *mysql)
|
|||||||
return mysql_store_result(mysql);
|
return mysql_store_result(mysql);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emb_read_change_user_result(MYSQL *mysql)
|
static int emb_read_change_user_result(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
mysql->net.read_pos= (uchar*)""; // fake an OK packet
|
mysql->net.read_pos= (uchar*)""; // fake an OK packet
|
||||||
return mysql_errno(mysql) ? (int)packet_error : 1 /* length of the OK packet */;
|
return mysql_errno(mysql) ? (int)packet_error : 1 /* length of the OK packet */;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void emb_on_close_free(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
my_free(mysql->info_buffer);
|
||||||
|
mysql->info_buffer= 0;
|
||||||
|
if (mysql->thd)
|
||||||
|
{
|
||||||
|
free_embedded_thd(mysql);
|
||||||
|
mysql->thd= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MYSQL_METHODS embedded_methods=
|
MYSQL_METHODS embedded_methods=
|
||||||
{
|
{
|
||||||
emb_read_query_result,
|
emb_read_query_result,
|
||||||
@ -469,12 +482,12 @@ MYSQL_METHODS embedded_methods=
|
|||||||
emb_fetch_lengths,
|
emb_fetch_lengths,
|
||||||
emb_flush_use_result,
|
emb_flush_use_result,
|
||||||
emb_read_change_user_result,
|
emb_read_change_user_result,
|
||||||
|
emb_on_close_free,
|
||||||
emb_list_fields,
|
emb_list_fields,
|
||||||
emb_read_prepare_result,
|
emb_read_prepare_result,
|
||||||
emb_stmt_execute,
|
emb_stmt_execute,
|
||||||
emb_read_binary_rows,
|
emb_read_binary_rows,
|
||||||
emb_unbuffered_fetch,
|
emb_unbuffered_fetch,
|
||||||
emb_free_embedded_thd,
|
|
||||||
emb_read_statistics,
|
emb_read_statistics,
|
||||||
emb_read_query_result,
|
emb_read_query_result,
|
||||||
emb_read_rows_from_cursor
|
emb_read_rows_from_cursor
|
||||||
@ -695,8 +708,7 @@ void *create_embedded_thd(int client_flag)
|
|||||||
|
|
||||||
if (thd->variables.max_join_size == HA_POS_ERROR)
|
if (thd->variables.max_join_size == HA_POS_ERROR)
|
||||||
thd->variables.option_bits |= OPTION_BIG_SELECTS;
|
thd->variables.option_bits |= OPTION_BIG_SELECTS;
|
||||||
thd->proc_info=0; // Remove 'login'
|
thd->mark_connection_idle();
|
||||||
thd->set_command(COM_SLEEP);
|
|
||||||
thd->set_time();
|
thd->set_time();
|
||||||
thd->init_for_queries();
|
thd->init_for_queries();
|
||||||
thd->client_capabilities= client_flag;
|
thd->client_capabilities= client_flag;
|
||||||
@ -1112,7 +1124,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
|
|||||||
|
|
||||||
for (uint pos= 0 ; (item= it++); pos++)
|
for (uint pos= 0 ; (item= it++); pos++)
|
||||||
{
|
{
|
||||||
if (prot.store_field_metadata(thd, item, pos))
|
if (prot.store_item_metadata(thd, item, pos))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1227,8 +1239,7 @@ bool Protocol_binary::write()
|
|||||||
@retval FALSE Success
|
@retval FALSE Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool Protocol::net_send_ok(THD *thd,
|
||||||
net_send_ok(THD *thd,
|
|
||||||
uint server_status, uint statement_warn_count,
|
uint server_status, uint statement_warn_count,
|
||||||
ulonglong affected_rows, ulonglong id, const char *message,
|
ulonglong affected_rows, ulonglong id, const char *message,
|
||||||
bool, bool)
|
bool, bool)
|
||||||
@ -1263,7 +1274,7 @@ net_send_ok(THD *thd,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
net_send_eof(THD *thd, uint server_status, uint statement_warn_count)
|
Protocol::net_send_eof(THD *thd, uint server_status, uint statement_warn_count)
|
||||||
{
|
{
|
||||||
bool error= write_eof_packet(thd, server_status, statement_warn_count);
|
bool error= write_eof_packet(thd, server_status, statement_warn_count);
|
||||||
thd->cur_data= 0;
|
thd->cur_data= 0;
|
||||||
@ -1271,8 +1282,8 @@ net_send_eof(THD *thd, uint server_status, uint statement_warn_count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool net_send_error_packet(THD *thd, uint sql_errno, const char *err,
|
bool Protocol::net_send_error_packet(THD *thd, uint sql_errno, const char *err,
|
||||||
const char *sqlstate)
|
const char *sqlstate)
|
||||||
{
|
{
|
||||||
uint error;
|
uint error;
|
||||||
char converted_err[MYSQL_ERRMSG_SIZE];
|
char converted_err[MYSQL_ERRMSG_SIZE];
|
||||||
|
@ -1064,11 +1064,6 @@ unsigned int STDCALL mysql_field_count(MYSQL *mysql)
|
|||||||
return mysql->field_count;
|
return mysql->field_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
|
|
||||||
{
|
|
||||||
return mysql->affected_rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
|
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
return mysql->insert_id;
|
return mysql->insert_id;
|
||||||
|
@ -38,6 +38,7 @@ SET(MYSQLSERVICES_SOURCES
|
|||||||
thd_wait_service.c
|
thd_wait_service.c
|
||||||
wsrep_service.c
|
wsrep_service.c
|
||||||
json_service.c
|
json_service.c
|
||||||
|
sql_service.c
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_CONVENIENCE_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
|
ADD_CONVENIENCE_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
|
||||||
|
19
libservices/sql_service.c
Normal file
19
libservices/sql_service.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
/* Copyright (c) 2018, Monty Program Ab
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <service_versions.h>
|
||||||
|
SERVICE_VERSION sql_service= (void*)VERSION_sql_service;
|
@ -814,7 +814,7 @@ show create table t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`a` int(11) DEFAULT NULL,
|
`a` int(11) DEFAULT NULL,
|
||||||
`b` char(5) GENERATED ALWAYS AS (cast('a' as char(10) charset latin1) + `a`) VIRTUAL
|
`b` char(5) GENERATED ALWAYS AS (cast('a' as char(10) charset latin1 binary) + `a`) VIRTUAL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
drop table t1;
|
drop table t1;
|
||||||
select collation(cast("a" as char(10) binary));
|
select collation(cast("a" as char(10) binary));
|
||||||
|
@ -158,10 +158,9 @@ select cast(1 as double(64,63));
|
|||||||
#
|
#
|
||||||
set names binary;
|
set names binary;
|
||||||
select cast(_latin1'test' as char character set latin2);
|
select cast(_latin1'test' as char character set latin2);
|
||||||
#enable after MDEV-32461 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251);
|
select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251);
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
create table t1 select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251) as t;
|
create table t1 select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251) as t;
|
||||||
show create table t1;
|
show create table t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
@ -169,8 +168,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# CAST to CHAR with/without length
|
# CAST to CHAR with/without length
|
||||||
#
|
#
|
||||||
#enable after MDEV-32461 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select
|
select
|
||||||
cast(_latin1'ab' AS char) as c1,
|
cast(_latin1'ab' AS char) as c1,
|
||||||
cast(_latin1'a ' AS char) as c2,
|
cast(_latin1'a ' AS char) as c2,
|
||||||
@ -178,7 +176,7 @@ select
|
|||||||
cast(_latin1'a ' AS char(2)) as c4,
|
cast(_latin1'a ' AS char(2)) as c4,
|
||||||
hex(cast(_latin1'a' AS char(2))) as c5;
|
hex(cast(_latin1'a' AS char(2))) as c5;
|
||||||
select cast(1000 as CHAR(3));
|
select cast(1000 as CHAR(3));
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
|
|
||||||
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
|
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
|
||||||
create table t1 select
|
create table t1 select
|
||||||
@ -239,15 +237,14 @@ select cast("1:2:3" as TIME) = "1:02:03";
|
|||||||
#
|
#
|
||||||
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
|
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
|
||||||
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
|
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
|
||||||
#enable after MDEV-32461 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
# these two should be in enum order
|
# these two should be in enum order
|
||||||
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
|
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
|
||||||
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
|
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
|
||||||
# these two should be in alphabetic order
|
# these two should be in alphabetic order
|
||||||
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
|
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
|
||||||
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
|
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -349,12 +346,11 @@ select cast(NULL as decimal(6)) as t1;
|
|||||||
# Bug #17903: cast to char results in binary
|
# Bug #17903: cast to char results in binary
|
||||||
#
|
#
|
||||||
set names latin1;
|
set names latin1;
|
||||||
#enable after MDEV-32461 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select hex(cast('a' as char(2) binary));
|
select hex(cast('a' as char(2) binary));
|
||||||
select hex(cast('a' as binary(2)));
|
select hex(cast('a' as binary(2)));
|
||||||
select hex(cast('a' as char(2) binary));
|
select hex(cast('a' as char(2) binary));
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag.
|
# Bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag.
|
||||||
@ -484,14 +480,13 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# CAST (... BINARY)
|
# CAST (... BINARY)
|
||||||
#
|
#
|
||||||
#enable after MDEV-32461 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select collation(cast("a" as char(10) binary));
|
select collation(cast("a" as char(10) binary));
|
||||||
select collation(cast("a" as char(10) charset utf8 binary));
|
select collation(cast("a" as char(10) charset utf8 binary));
|
||||||
select collation(cast("a" as char(10) ascii binary));
|
select collation(cast("a" as char(10) ascii binary));
|
||||||
select collation(cast("a" as char(10) binary charset utf8));
|
select collation(cast("a" as char(10) binary charset utf8));
|
||||||
select collation(cast("a" as char(10) binary ascii));
|
select collation(cast("a" as char(10) binary ascii));
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # MDEV-11030 Assertion `precision > 0' failed in decimal_bin_size
|
--echo # MDEV-11030 Assertion `precision > 0' failed in decimal_bin_size
|
||||||
@ -773,14 +768,14 @@ INSERT INTO t1 VALUES (-1.0);
|
|||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
#enable after MDEV-32461 fix
|
#enable after MDEV-32645 is fixed
|
||||||
--disable_view_protocol
|
--disable_view_protocol
|
||||||
SELECT CAST(-1e0 AS UNSIGNED);
|
SELECT CAST(-1e0 AS UNSIGNED);
|
||||||
--enable_view_protocol
|
|
||||||
CREATE TABLE t1 (a BIGINT UNSIGNED);
|
CREATE TABLE t1 (a BIGINT UNSIGNED);
|
||||||
INSERT INTO t1 VALUES (-1e0);
|
INSERT INTO t1 VALUES (-1e0);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
--enable_view_protocol
|
||||||
|
|
||||||
SELECT CAST(-1e308 AS UNSIGNED);
|
SELECT CAST(-1e308 AS UNSIGNED);
|
||||||
CREATE TABLE t1 (a BIGINT UNSIGNED);
|
CREATE TABLE t1 (a BIGINT UNSIGNED);
|
||||||
|
@ -2339,4 +2339,289 @@ set sql_mode="oracle";
|
|||||||
with data as (select 1 as id)
|
with data as (select 1 as id)
|
||||||
select id into @myid from data;
|
select id into @myid from data;
|
||||||
set sql_mode= @save_sql_mode;
|
set sql_mode= @save_sql_mode;
|
||||||
|
#
|
||||||
|
# MDEV-31995 CTE column name specification inconsistency
|
||||||
|
#
|
||||||
|
create table t1 (a int, b int);
|
||||||
|
insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
|
||||||
|
create table t2 (a int, b int);
|
||||||
|
insert into t2 values (3,1),(3,2),(3,3),(4,1),(4,2);
|
||||||
|
with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 group by col1)
|
||||||
|
select * from cte;
|
||||||
|
c1 c2
|
||||||
|
1 6
|
||||||
|
2 3
|
||||||
|
prepare st from "with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 group by col1)
|
||||||
|
select * from cte";
|
||||||
|
execute st;
|
||||||
|
c1 c2
|
||||||
|
1 6
|
||||||
|
2 3
|
||||||
|
execute st;
|
||||||
|
c1 c2
|
||||||
|
1 6
|
||||||
|
2 3
|
||||||
|
drop prepare st;
|
||||||
|
create procedure sp() with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 group by col1)
|
||||||
|
select * from cte;
|
||||||
|
call sp();
|
||||||
|
c1 c2
|
||||||
|
1 6
|
||||||
|
2 3
|
||||||
|
call sp();
|
||||||
|
c1 c2
|
||||||
|
1 6
|
||||||
|
2 3
|
||||||
|
drop procedure sp;
|
||||||
|
with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 order by col1)
|
||||||
|
select * from cte;
|
||||||
|
c1 c2
|
||||||
|
1 9
|
||||||
|
prepare st from "with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 order by col1)
|
||||||
|
select * from cte";
|
||||||
|
execute st;
|
||||||
|
c1 c2
|
||||||
|
1 9
|
||||||
|
execute st;
|
||||||
|
c1 c2
|
||||||
|
1 9
|
||||||
|
drop prepare st;
|
||||||
|
create procedure sp() with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 order by col1)
|
||||||
|
select * from cte;
|
||||||
|
call sp();
|
||||||
|
c1 c2
|
||||||
|
1 9
|
||||||
|
call sp();
|
||||||
|
c1 c2
|
||||||
|
1 9
|
||||||
|
drop procedure sp;
|
||||||
|
with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1
|
||||||
|
union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3),
|
||||||
|
cte2 (c3, c4) as
|
||||||
|
(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5
|
||||||
|
union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7)
|
||||||
|
select * from cte where c1=1 union select * from cte2 where c3=3;
|
||||||
|
c1 c2
|
||||||
|
3 3
|
||||||
|
prepare st from "with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1
|
||||||
|
union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3),
|
||||||
|
cte2 (c3, c4) as
|
||||||
|
(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5
|
||||||
|
union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7)
|
||||||
|
select * from cte where c1=1 union select * from cte2 where c3=3";
|
||||||
|
execute st;
|
||||||
|
c1 c2
|
||||||
|
3 3
|
||||||
|
execute st;
|
||||||
|
c1 c2
|
||||||
|
3 3
|
||||||
|
drop prepare st;
|
||||||
|
create procedure sp() with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1
|
||||||
|
union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3),
|
||||||
|
cte2 (c3, c4) as
|
||||||
|
(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5
|
||||||
|
union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7)
|
||||||
|
select * from cte where c1=1 union select * from cte2 where c3=3;
|
||||||
|
call sp();
|
||||||
|
c1 c2
|
||||||
|
3 3
|
||||||
|
call sp();
|
||||||
|
c1 c2
|
||||||
|
3 3
|
||||||
|
drop procedure sp;
|
||||||
|
with cte (c1,c2) as (select * from t1)
|
||||||
|
select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1
|
||||||
|
union
|
||||||
|
select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0;
|
||||||
|
col1 col2
|
||||||
|
3 1
|
||||||
|
3 2
|
||||||
|
prepare st from "with cte (c1,c2) as (select * from t1)
|
||||||
|
select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1
|
||||||
|
union
|
||||||
|
select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0";
|
||||||
|
execute st;
|
||||||
|
col1 col2
|
||||||
|
3 1
|
||||||
|
3 2
|
||||||
|
execute st;
|
||||||
|
col1 col2
|
||||||
|
3 1
|
||||||
|
3 2
|
||||||
|
save this to the end to test errors >drop prepare st;
|
||||||
|
create procedure sp() with cte (c1,c2) as (select * from t1)
|
||||||
|
select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1
|
||||||
|
union
|
||||||
|
select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0;
|
||||||
|
call sp();
|
||||||
|
col1 col2
|
||||||
|
3 1
|
||||||
|
3 2
|
||||||
|
call sp();
|
||||||
|
col1 col2
|
||||||
|
3 1
|
||||||
|
3 2
|
||||||
|
drop procedure sp;
|
||||||
|
insert into t1 select * from t2;
|
||||||
|
with cte (c1, c2)
|
||||||
|
as (select a, sum(b) from t1 where b > 1 group by a having sum(b) < 5)
|
||||||
|
select * from cte where c1 < 4 and c2 > 1;
|
||||||
|
c1 c2
|
||||||
|
2 2
|
||||||
|
# Check pushdown conditions in JSON output
|
||||||
|
explain format=json with cte (c1, c2)
|
||||||
|
as (select a, sum(b) from t1 where b > 1 group by a having sum(b) < 5)
|
||||||
|
select * from cte where c1 < 4 and c2 > 1;
|
||||||
|
EXPLAIN
|
||||||
|
{
|
||||||
|
"query_block": {
|
||||||
|
"select_id": 1,
|
||||||
|
"table": {
|
||||||
|
"table_name": "<derived2>",
|
||||||
|
"access_type": "ALL",
|
||||||
|
"rows": 10,
|
||||||
|
"filtered": 100,
|
||||||
|
"attached_condition": "cte.c1 < 4 and cte.c2 > 1",
|
||||||
|
"materialized": {
|
||||||
|
"query_block": {
|
||||||
|
"select_id": 2,
|
||||||
|
"having_condition": "sum(t1.b) < 5 and c2 > 1",
|
||||||
|
"filesort": {
|
||||||
|
"sort_key": "t1.a",
|
||||||
|
"temporary_table": {
|
||||||
|
"table": {
|
||||||
|
"table_name": "t1",
|
||||||
|
"access_type": "ALL",
|
||||||
|
"rows": 10,
|
||||||
|
"filtered": 100,
|
||||||
|
"attached_condition": "t1.b > 1 and t1.a < 4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alter table t1 add column c int;
|
||||||
|
execute st;
|
||||||
|
ERROR HY000: WITH column list and SELECT field list have different column counts
|
||||||
|
drop prepare st;
|
||||||
|
drop table t1,t2;
|
||||||
|
Test out recursive CTEs
|
||||||
|
create table distances (src char(1), dest char(1), distance int);
|
||||||
|
create table city_population (city char(1), population int);
|
||||||
|
INSERT INTO `distances` VALUES ('A','A',0),('B','A',593),('C','A',800),
|
||||||
|
('D','A',221),('E','A',707),('F','A',869),('G','A',225),('H','A',519),
|
||||||
|
('A','B',919),('B','B',0),('C','B',440),('D','B',79),('E','B',79),
|
||||||
|
('F','B',154),('G','B',537),('H','B',220),('A','C',491),('B','C',794),
|
||||||
|
('C','C',0),('D','C',100),('E','C',350),('F','C',748),('G','C',712),
|
||||||
|
('H','C',315),('A','D',440),('B','D',256),('C','D',958),('D','D',0),
|
||||||
|
('E','D',255),('F','D',161),('G','D',63),('H','D',831),('A','E',968),
|
||||||
|
('B','E',345),('C','E',823),('D','E',81),('E','E',0),('F','E',436),
|
||||||
|
('G','E',373),('H','E',558),('A','F',670),('B','F',677),('C','F',375),
|
||||||
|
('D','F',843),('E','F',90),('F','F',0),('G','F',328),('H','F',881),
|
||||||
|
('A','G',422),('B','G',467),('C','G',67),('D','G',936),('E','G',480),
|
||||||
|
('F','G',592),('G','G',0),('H','G',819),('A','H',537),('B','H',229),
|
||||||
|
('C','H',534),('D','H',984),('E','H',319),('F','H',643),('G','H',257),
|
||||||
|
('H','H',0);
|
||||||
|
insert into city_population values ('A', 5000), ('B', 6000), ('C', 100000),
|
||||||
|
('D', 80000), ('E', 7000), ('F', 1000), ('G', 100), ('H', -80000);
|
||||||
|
#find the biggest city within 300 kellikams of 'E'
|
||||||
|
with recursive travel (src, path, dest, distance, population) as (
|
||||||
|
select city, cast('' as varchar(10)), city,
|
||||||
|
0, population
|
||||||
|
from city_population where city='E'
|
||||||
|
union all
|
||||||
|
select src.src, concat(src.path, dst.dest), dst.dest,
|
||||||
|
src.distance + dst.distance, dstc.population
|
||||||
|
from travel src
|
||||||
|
join distances dst on src.dest != dst.dest
|
||||||
|
join city_population dstc on dst.dest = dstc.city
|
||||||
|
where dst.src = src.dest and src.distance + dst.distance < 300
|
||||||
|
and length(path) < 10
|
||||||
|
)
|
||||||
|
select * from travel where dest != 'E' order by population desc, distance
|
||||||
|
limit 1;
|
||||||
|
src path dest distance population
|
||||||
|
E FD D 251 80000
|
||||||
|
prepare st from "with recursive travel (src, path, dest, distance, population) as (
|
||||||
|
select city, cast('' as varchar(10)), city,
|
||||||
|
0, population
|
||||||
|
from city_population where city='E'
|
||||||
|
union all
|
||||||
|
select src.src, concat(src.path, dst.dest), dst.dest,
|
||||||
|
src.distance + dst.distance, dstc.population
|
||||||
|
from travel src
|
||||||
|
join distances dst on src.dest != dst.dest
|
||||||
|
join city_population dstc on dst.dest = dstc.city
|
||||||
|
where dst.src = src.dest and src.distance + dst.distance < 300
|
||||||
|
and length(path) < 10
|
||||||
|
)
|
||||||
|
select * from travel where dest != 'E' order by population desc, distance
|
||||||
|
limit 1";
|
||||||
|
execute st;
|
||||||
|
src path dest distance population
|
||||||
|
E FD D 251 80000
|
||||||
|
execute st;
|
||||||
|
src path dest distance population
|
||||||
|
E FD D 251 80000
|
||||||
|
drop prepare st;
|
||||||
|
create procedure sp() with recursive travel (src, path, dest, distance, population) as (
|
||||||
|
select city, cast('' as varchar(10)), city,
|
||||||
|
0, population
|
||||||
|
from city_population where city='E'
|
||||||
|
union all
|
||||||
|
select src.src, concat(src.path, dst.dest), dst.dest,
|
||||||
|
src.distance + dst.distance, dstc.population
|
||||||
|
from travel src
|
||||||
|
join distances dst on src.dest != dst.dest
|
||||||
|
join city_population dstc on dst.dest = dstc.city
|
||||||
|
where dst.src = src.dest and src.distance + dst.distance < 300
|
||||||
|
and length(path) < 10
|
||||||
|
)
|
||||||
|
select * from travel where dest != 'E' order by population desc, distance
|
||||||
|
limit 1;
|
||||||
|
call sp();
|
||||||
|
src path dest distance population
|
||||||
|
E FD D 251 80000
|
||||||
|
call sp();
|
||||||
|
src path dest distance population
|
||||||
|
E FD D 251 80000
|
||||||
|
drop procedure sp;
|
||||||
|
drop table distances, city_population;
|
||||||
|
#
|
||||||
|
# MDEV-28615: Multi-table UPDATE over derived table containing
|
||||||
|
# row that uses subquery with hanging CTE
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a int) ENGINE=MYISAM;
|
||||||
|
INSERT INTO t1 VALUES (3), (7), (1);
|
||||||
|
UPDATE
|
||||||
|
(SELECT (5, (WITH cte AS (SELECT 1) SELECT a FROM t1))) dt
|
||||||
|
JOIN t1 t
|
||||||
|
ON t.a=dt.a
|
||||||
|
SET t.a = 1;
|
||||||
|
ERROR 21000: Operand should contain 1 column(s)
|
||||||
|
UPDATE
|
||||||
|
(SELECT a FROM t1
|
||||||
|
WHERE (5, (WITH cte AS (SELECT 1) SELECT a FROM t1 WHERE a > 4)) <=
|
||||||
|
(5,a)) dt
|
||||||
|
JOIN t1 t
|
||||||
|
ON t.a=dt.a
|
||||||
|
SET t.a = 1;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
a
|
||||||
|
3
|
||||||
|
1
|
||||||
|
1
|
||||||
|
DROP TABLE t1;
|
||||||
# End of 10.4 tests
|
# End of 10.4 tests
|
||||||
|
@ -1784,4 +1784,187 @@ with data as (select 1 as id)
|
|||||||
select id into @myid from data;
|
select id into @myid from data;
|
||||||
set sql_mode= @save_sql_mode;
|
set sql_mode= @save_sql_mode;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-31995 CTE column name specification inconsistency
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
create table t1 (a int, b int);
|
||||||
|
insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
|
||||||
|
create table t2 (a int, b int);
|
||||||
|
insert into t2 values (3,1),(3,2),(3,3),(4,1),(4,2);
|
||||||
|
|
||||||
|
let $q=
|
||||||
|
with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 group by col1)
|
||||||
|
select * from cte;
|
||||||
|
|
||||||
|
eval $q;
|
||||||
|
|
||||||
|
eval prepare st from "$q";
|
||||||
|
execute st;
|
||||||
|
execute st;
|
||||||
|
drop prepare st;
|
||||||
|
|
||||||
|
eval create procedure sp() $q;
|
||||||
|
call sp();
|
||||||
|
call sp();
|
||||||
|
drop procedure sp;
|
||||||
|
|
||||||
|
let $q=
|
||||||
|
with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 order by col1)
|
||||||
|
select * from cte;
|
||||||
|
|
||||||
|
eval $q;
|
||||||
|
|
||||||
|
eval prepare st from "$q";
|
||||||
|
execute st;
|
||||||
|
execute st;
|
||||||
|
drop prepare st;
|
||||||
|
|
||||||
|
eval create procedure sp() $q;
|
||||||
|
call sp();
|
||||||
|
call sp();
|
||||||
|
drop procedure sp;
|
||||||
|
|
||||||
|
let $q=
|
||||||
|
with cte (c1,c2) as
|
||||||
|
(select a as col1, sum(b) as col2 from t1 where a > 1 group by col1
|
||||||
|
union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3),
|
||||||
|
cte2 (c3, c4) as
|
||||||
|
(select a as col5, sum(b) as col6 from t1 where a <= 1 group by col5
|
||||||
|
union select a as col7, sum(b) as col8 from t2 where b <= 2 group by col7)
|
||||||
|
select * from cte where c1=1 union select * from cte2 where c3=3;
|
||||||
|
|
||||||
|
eval $q;
|
||||||
|
|
||||||
|
eval prepare st from "$q";
|
||||||
|
execute st;
|
||||||
|
execute st;
|
||||||
|
drop prepare st;
|
||||||
|
|
||||||
|
eval create procedure sp() $q;
|
||||||
|
call sp();
|
||||||
|
call sp();
|
||||||
|
drop procedure sp;
|
||||||
|
|
||||||
|
let $q=
|
||||||
|
with cte (c1,c2) as (select * from t1)
|
||||||
|
select cte.c1+1 as col1 , cte.c2 as col2 from cte where cte.c1 > 1
|
||||||
|
union
|
||||||
|
select cte.c1 as col3, cte.c2+1 as col4 from cte where cte.c1 < 0;
|
||||||
|
|
||||||
|
eval $q;
|
||||||
|
|
||||||
|
eval prepare st from "$q";
|
||||||
|
execute st;
|
||||||
|
execute st;
|
||||||
|
--echo save this to the end to test errors >drop prepare st;
|
||||||
|
|
||||||
|
eval create procedure sp() $q;
|
||||||
|
call sp();
|
||||||
|
call sp();
|
||||||
|
drop procedure sp;
|
||||||
|
|
||||||
|
insert into t1 select * from t2;
|
||||||
|
|
||||||
|
let $q=
|
||||||
|
with cte (c1, c2)
|
||||||
|
as (select a, sum(b) from t1 where b > 1 group by a having sum(b) < 5)
|
||||||
|
select * from cte where c1 < 4 and c2 > 1;
|
||||||
|
|
||||||
|
eval $q;
|
||||||
|
|
||||||
|
--echo # Check pushdown conditions in JSON output
|
||||||
|
--source include/analyze-format.inc
|
||||||
|
eval explain format=json $q;
|
||||||
|
|
||||||
|
alter table t1 add column c int;
|
||||||
|
|
||||||
|
--error ER_WITH_COL_WRONG_LIST
|
||||||
|
execute st;
|
||||||
|
|
||||||
|
drop prepare st;
|
||||||
|
drop table t1,t2;
|
||||||
|
|
||||||
|
--echo Test out recursive CTEs
|
||||||
|
|
||||||
|
create table distances (src char(1), dest char(1), distance int);
|
||||||
|
create table city_population (city char(1), population int);
|
||||||
|
INSERT INTO `distances` VALUES ('A','A',0),('B','A',593),('C','A',800),
|
||||||
|
('D','A',221),('E','A',707),('F','A',869),('G','A',225),('H','A',519),
|
||||||
|
('A','B',919),('B','B',0),('C','B',440),('D','B',79),('E','B',79),
|
||||||
|
('F','B',154),('G','B',537),('H','B',220),('A','C',491),('B','C',794),
|
||||||
|
('C','C',0),('D','C',100),('E','C',350),('F','C',748),('G','C',712),
|
||||||
|
('H','C',315),('A','D',440),('B','D',256),('C','D',958),('D','D',0),
|
||||||
|
('E','D',255),('F','D',161),('G','D',63),('H','D',831),('A','E',968),
|
||||||
|
('B','E',345),('C','E',823),('D','E',81),('E','E',0),('F','E',436),
|
||||||
|
('G','E',373),('H','E',558),('A','F',670),('B','F',677),('C','F',375),
|
||||||
|
('D','F',843),('E','F',90),('F','F',0),('G','F',328),('H','F',881),
|
||||||
|
('A','G',422),('B','G',467),('C','G',67),('D','G',936),('E','G',480),
|
||||||
|
('F','G',592),('G','G',0),('H','G',819),('A','H',537),('B','H',229),
|
||||||
|
('C','H',534),('D','H',984),('E','H',319),('F','H',643),('G','H',257),
|
||||||
|
('H','H',0);
|
||||||
|
insert into city_population values ('A', 5000), ('B', 6000), ('C', 100000),
|
||||||
|
('D', 80000), ('E', 7000), ('F', 1000), ('G', 100), ('H', -80000);
|
||||||
|
|
||||||
|
--echo #find the biggest city within 300 kellikams of 'E'
|
||||||
|
let $q=
|
||||||
|
with recursive travel (src, path, dest, distance, population) as (
|
||||||
|
select city, cast('' as varchar(10)), city,
|
||||||
|
0, population
|
||||||
|
from city_population where city='E'
|
||||||
|
union all
|
||||||
|
select src.src, concat(src.path, dst.dest), dst.dest,
|
||||||
|
src.distance + dst.distance, dstc.population
|
||||||
|
from travel src
|
||||||
|
join distances dst on src.dest != dst.dest
|
||||||
|
join city_population dstc on dst.dest = dstc.city
|
||||||
|
where dst.src = src.dest and src.distance + dst.distance < 300
|
||||||
|
and length(path) < 10
|
||||||
|
)
|
||||||
|
select * from travel where dest != 'E' order by population desc, distance
|
||||||
|
limit 1;
|
||||||
|
|
||||||
|
eval $q;
|
||||||
|
|
||||||
|
eval prepare st from "$q";
|
||||||
|
execute st;
|
||||||
|
execute st;
|
||||||
|
drop prepare st;
|
||||||
|
|
||||||
|
eval create procedure sp() $q;
|
||||||
|
call sp();
|
||||||
|
call sp();
|
||||||
|
drop procedure sp;
|
||||||
|
|
||||||
|
drop table distances, city_population;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-28615: Multi-table UPDATE over derived table containing
|
||||||
|
--echo # row that uses subquery with hanging CTE
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a int) ENGINE=MYISAM;
|
||||||
|
INSERT INTO t1 VALUES (3), (7), (1);
|
||||||
|
|
||||||
|
--error ER_OPERAND_COLUMNS
|
||||||
|
UPDATE
|
||||||
|
(SELECT (5, (WITH cte AS (SELECT 1) SELECT a FROM t1))) dt
|
||||||
|
JOIN t1 t
|
||||||
|
ON t.a=dt.a
|
||||||
|
SET t.a = 1;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
(SELECT a FROM t1
|
||||||
|
WHERE (5, (WITH cte AS (SELECT 1) SELECT a FROM t1 WHERE a > 4)) <=
|
||||||
|
(5,a)) dt
|
||||||
|
JOIN t1 t
|
||||||
|
ON t.a=dt.a
|
||||||
|
SET t.a = 1;
|
||||||
|
|
||||||
|
SELECT * FROM t1;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # End of 10.4 tests
|
--echo # End of 10.4 tests
|
||||||
|
@ -670,18 +670,16 @@ SELECT COLUMN_GET(`x`, 'y' AS DECIMAL(5,50));
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # creation test (names)
|
--echo # creation test (names)
|
||||||
set names utf8;
|
set names utf8;
|
||||||
#enable after MDEV-32465 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select hex(column_create("адын", 1212));
|
select hex(column_create("адын", 1212));
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
select hex(column_create("1212", 1212));
|
select hex(column_create("1212", 1212));
|
||||||
select hex(column_create(1212, 2, "www", 3));
|
select hex(column_create(1212, 2, "www", 3));
|
||||||
select hex(column_create("1212", 2, "www", 3));
|
select hex(column_create("1212", 2, "www", 3));
|
||||||
select hex(column_create("1212", 2, 3, 3));
|
select hex(column_create("1212", 2, 3, 3));
|
||||||
#enable after MDEV-32465 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select hex(column_create("1212", 2, "адын", 1, 3, 3));
|
select hex(column_create("1212", 2, "адын", 1, 3, 3));
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
set names latin1;
|
set names latin1;
|
||||||
|
|
||||||
--echo # fetching column test (names)
|
--echo # fetching column test (names)
|
||||||
@ -708,15 +706,14 @@ select column_exists(column_create("1212", 2, "адын", 1, 3, 3), "4") as ex;
|
|||||||
set names latin1;
|
set names latin1;
|
||||||
|
|
||||||
--echo # column changing test (names)
|
--echo # column changing test (names)
|
||||||
#enable after MDEV-32465 fix
|
--disable_service_connection
|
||||||
--disable_view_protocol
|
|
||||||
select hex(column_add(column_create(1, "AAA"), "b", "BBB")) as ex;
|
select hex(column_add(column_create(1, "AAA"), "b", "BBB")) as ex;
|
||||||
select hex(column_add(column_create("1", "AAA"), "b", "BBB")) as ex;
|
select hex(column_add(column_create("1", "AAA"), "b", "BBB")) as ex;
|
||||||
select column_get(column_add(column_create(1, "AAA"), "b", "BBB"), 1 as char) as ex;
|
select column_get(column_add(column_create(1, "AAA"), "b", "BBB"), 1 as char) as ex;
|
||||||
select column_get(column_add(column_create(1, "AAA"), "b", "BBB"), "b" as char) as ex;
|
select column_get(column_add(column_create(1, "AAA"), "b", "BBB"), "b" as char) as ex;
|
||||||
select hex(column_add(column_create("a", "AAA"), 1, "BBB")) as ex;
|
select hex(column_add(column_create("a", "AAA"), 1, "BBB")) as ex;
|
||||||
select hex(column_add(column_create("a", "AAA"), "1", "BBB")) as ex;
|
select hex(column_add(column_create("a", "AAA"), "1", "BBB")) as ex;
|
||||||
--enable_view_protocol
|
--enable_service_connection
|
||||||
select hex(column_add(column_create("a", 1212 as integer), "b", "1212" as integer)) as ex;
|
select hex(column_add(column_create("a", 1212 as integer), "b", "1212" as integer)) as ex;
|
||||||
select hex(column_add(column_create("a", 1212 as integer), "a", "1212" as integer)) as ex;
|
select hex(column_add(column_create("a", 1212 as integer), "a", "1212" as integer)) as ex;
|
||||||
select hex(column_add(column_create("a", 1212 as integer), "a", NULL as integer)) as ex;
|
select hex(column_add(column_create("a", 1212 as integer), "a", NULL as integer)) as ex;
|
||||||
|
@ -500,21 +500,21 @@ SELECT @@global.rpad(); -- Unknown system variable 'rpad'
|
|||||||
--------
|
--------
|
||||||
SELECT @@global.adddate(); -- Unknown system variable 'adddate'
|
SELECT @@global.adddate(); -- Unknown system variable 'adddate'
|
||||||
--------
|
--------
|
||||||
SELECT @@global.substr(); -- Unknown system variable 'substr'
|
SELECT @@global.substr(); -- ..syntax.. near 'substr()' at line 1
|
||||||
--------
|
--------
|
||||||
SELECT @@global.substring(); -- Unknown system variable 'substring'
|
SELECT @@global.substring(); -- ..syntax.. near 'substring()' at line 1
|
||||||
--------
|
--------
|
||||||
SELECT @@global.trim_oracle(); -- Unknown system variable 'trim_oracle'
|
SELECT @@global.trim_oracle(); -- Unknown system variable 'trim_oracle'
|
||||||
--------
|
--------
|
||||||
SELECT @@global.ascii(); -- Unknown system variable 'ascii'
|
SELECT @@global.ascii(); -- Unknown system variable 'ascii'
|
||||||
--------
|
--------
|
||||||
SELECT @@global.replace(); -- Unknown system variable 'replace'
|
SELECT @@global.replace(); -- ..syntax.. near 'replace()' at line 1
|
||||||
--------
|
--------
|
||||||
SELECT @@global.weight_string(); -- Unknown system variable 'weight_string'
|
SELECT @@global.weight_string(); -- Unknown system variable 'weight_string'
|
||||||
--------
|
--------
|
||||||
SELECT @@global.char(); -- Unknown system variable 'char'
|
SELECT @@global.char(); -- Unknown system variable 'char'
|
||||||
--------
|
--------
|
||||||
SELECT @@global.trim(); -- Unknown system variable 'trim'
|
SELECT @@global.trim(); -- ..syntax.. near 'trim()' at line 1
|
||||||
--------
|
--------
|
||||||
SELECT @@global.year(); -- Unknown system variable 'year'
|
SELECT @@global.year(); -- Unknown system variable 'year'
|
||||||
--------
|
--------
|
||||||
@ -732,21 +732,21 @@ CREATE FUNCTION test.rpad() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
|||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.adddate() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.adddate() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.substr() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.substr() RETURNS OOPS; -- ..syntax.. near 'substr() RETURNS OOPS'
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.substring() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.substring() RETURNS OOPS; -- ..syntax.. near 'substring() RETURNS OOP
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.trim_oracle() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.trim_oracle() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.ascii() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.ascii() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.replace() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.replace() RETURNS OOPS; -- ..syntax.. near 'replace() RETURNS OOPS'
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.weight_string() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.weight_string() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.char() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.char() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.trim() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.trim() RETURNS OOPS; -- ..syntax.. near 'trim() RETURNS OOPS' at
|
||||||
--------
|
--------
|
||||||
CREATE FUNCTION test.year() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
CREATE FUNCTION test.year() RETURNS OOPS; -- ..syntax.. near 'OOPS' at line 1
|
||||||
--------
|
--------
|
||||||
|
@ -231,15 +231,18 @@ SET @old_dbug= @@GLOBAL.debug_dbug;
|
|||||||
SET GLOBAL log_output= "TABLE";
|
SET GLOBAL log_output= "TABLE";
|
||||||
SET GLOBAL slow_query_log= ON;
|
SET GLOBAL slow_query_log= ON;
|
||||||
SET SESSION long_query_time= 0;
|
SET SESSION long_query_time= 0;
|
||||||
SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows";
|
SET debug_dbug="+d,debug_huge_number_of_examined_rows";
|
||||||
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
|
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
|
||||||
ID A
|
ID A
|
||||||
1 0
|
1 0
|
||||||
2 0
|
2 0
|
||||||
SET GLOBAL debug_dbug=@old_dbug;
|
SET debug_dbug=@old_dbug;
|
||||||
SET @@long_query_time= @old_long_query_time;
|
SET @@long_query_time= @old_long_query_time;
|
||||||
SET @@global.log_output= @old_log_output;
|
SET @@global.log_output= @old_log_output;
|
||||||
SET @@global.slow_query_log= @old_slow_query_log;
|
SET @@global.slow_query_log= @old_slow_query_log;
|
||||||
|
SELECT rows_examined, sql_text from mysql.slow_log where sql_text like "SELECT%FROM tab_MDEV_30820%";
|
||||||
|
rows_examined sql_text
|
||||||
|
18446744073708551615 SELECT * FROM tab_MDEV_30820 ORDER BY 1
|
||||||
drop table tab_MDEV_30820;
|
drop table tab_MDEV_30820;
|
||||||
#
|
#
|
||||||
# End of 10.4 test
|
# End of 10.4 test
|
||||||
|
@ -104,16 +104,21 @@ SET GLOBAL log_output= "TABLE";
|
|||||||
SET GLOBAL slow_query_log= ON;
|
SET GLOBAL slow_query_log= ON;
|
||||||
SET SESSION long_query_time= 0;
|
SET SESSION long_query_time= 0;
|
||||||
|
|
||||||
SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows";
|
SET debug_dbug="+d,debug_huge_number_of_examined_rows";
|
||||||
|
--disable_ps_protocol
|
||||||
|
--disable_view_protocol
|
||||||
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
|
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
|
||||||
SET GLOBAL debug_dbug=@old_dbug;
|
--enable_view_protocol
|
||||||
|
--enable_ps_protocol
|
||||||
|
SET debug_dbug=@old_dbug;
|
||||||
|
|
||||||
## Reset to initial values
|
## Reset to initial values
|
||||||
SET @@long_query_time= @old_long_query_time;
|
SET @@long_query_time= @old_long_query_time;
|
||||||
SET @@global.log_output= @old_log_output;
|
SET @@global.log_output= @old_log_output;
|
||||||
SET @@global.slow_query_log= @old_slow_query_log;
|
SET @@global.slow_query_log= @old_slow_query_log;
|
||||||
|
|
||||||
|
SELECT rows_examined, sql_text from mysql.slow_log where sql_text like "SELECT%FROM tab_MDEV_30820%";
|
||||||
|
|
||||||
drop table tab_MDEV_30820;
|
drop table tab_MDEV_30820;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -511,9 +511,8 @@ The following specify which files/extra groups are read (specified before remain
|
|||||||
when binary log is disabled).
|
when binary log is disabled).
|
||||||
--log-tc-size=# Size of transaction coordinator log.
|
--log-tc-size=# Size of transaction coordinator log.
|
||||||
-W, --log-warnings[=#]
|
-W, --log-warnings[=#]
|
||||||
Log some not critical warnings to the general log
|
Log some non critical warnings to the error log.Value can
|
||||||
file.Value can be between 0 and 11. Higher values mean
|
be between 0 and 11. Higher values mean more verbosity
|
||||||
more verbosity
|
|
||||||
--long-query-time=# Log all queries that have taken more than long_query_time
|
--long-query-time=# Log all queries that have taken more than long_query_time
|
||||||
seconds to execute to the slow query log file. The
|
seconds to execute to the slow query log file. The
|
||||||
argument will be treated as a decimal value with
|
argument will be treated as a decimal value with
|
||||||
|
@ -3725,4 +3725,124 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||||
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.t2.b 1 Using where
|
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.t2.b 1 Using where
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
#
|
||||||
|
# MDEV-29681 Server crashes when optimizing SQL with ORDER BY
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (b INT);
|
||||||
|
CREATE TABLE t2 (a INT, c INT);
|
||||||
|
# First test empty tables
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a+1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 Const row not found
|
||||||
|
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from ((/* select#2 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from `test`.`t1` join `test`.`t2` where 0 limit 3)) `__2` order by NULL + 1
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 Const row not found
|
||||||
|
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from ((/* select#2 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from `test`.`t1` join `test`.`t2` where 0 limit 3)) `__2` order by NULL = 2
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3)
|
||||||
|
ORDER BY a+1, a-b DESC, c<>a;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 Const row not found
|
||||||
|
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from ((/* select#2 */ select NULL AS `b`,NULL AS `a`,NULL AS `c` from `test`.`t1` join `test`.`t2` where 0 limit 3)) `__2` order by NULL + 1,NULL - NULL desc,NULL <> NULL
|
||||||
|
# Insert some data
|
||||||
|
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
||||||
|
INSERT INTO t2 VALUES (1,1),(2,2),(3,3),(4,4);
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=b, a-10 DESC, b+a, c+a+a+b;
|
||||||
|
b a c
|
||||||
|
1 1 1
|
||||||
|
2 2 2
|
||||||
|
3 3 3
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2;
|
||||||
|
b a c
|
||||||
|
1 1 1
|
||||||
|
2 2 2
|
||||||
|
3 3 3
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3)
|
||||||
|
ORDER BY a=b, a-10, b+a, c+a+a+b;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 Using filesort
|
||||||
|
2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00
|
||||||
|
2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select `__2`.`b` AS `b`,`__2`.`a` AS `a`,`__2`.`c` AS `c` from ((/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` limit 3)) `__2` order by `__2`.`a` = `__2`.`b`,`__2`.`a` - 10,`__2`.`b` + `__2`.`a`,`__2`.`c` + `__2`.`a` + `__2`.`a` + `__2`.`b`
|
||||||
|
# When there is no LIMIT clause the derived table must be merged
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16, b+a, c<>b;
|
||||||
|
b a c
|
||||||
|
1 1 1
|
||||||
|
2 2 2
|
||||||
|
3 3 3
|
||||||
|
4 4 4
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16 DESC, b+a, c<>b;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
|
||||||
|
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||||
|
Warnings:
|
||||||
|
Note 1003 (select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` order by `test`.`t2`.`a` + 16 desc,`test`.`t1`.`b` + `test`.`t2`.`a`,`test`.`t2`.`c` <> `test`.`t1`.`b`)
|
||||||
|
# Test UNIONs:
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT * FROM t1 JOIN t2 ON a!=b
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY a+16, b+a, c<>b;
|
||||||
|
b a c
|
||||||
|
1 1 1
|
||||||
|
2 2 2
|
||||||
|
3 3 3
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT * FROM t1 JOIN t2 ON a!=b
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY a+16, b+a, c<>b;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 32 100.00 Using filesort
|
||||||
|
2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00
|
||||||
|
2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||||
|
3 UNION t1 ALL NULL NULL NULL NULL 4 100.00
|
||||||
|
3 UNION t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||||
|
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select `__3`.`b` AS `b`,`__3`.`a` AS `a`,`__3`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` union /* select#3 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` <> `test`.`t1`.`b` limit 3) `__3` order by `__3`.`a` + 16,`__3`.`b` + `__3`.`a`,`__3`.`c` <> `__3`.`b`
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY b-a-c;
|
||||||
|
b a c
|
||||||
|
1 1 1
|
||||||
|
2 2 2
|
||||||
|
3 3 3
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY b-a-c;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using filesort
|
||||||
|
2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00
|
||||||
|
2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||||
|
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
|
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select `__3`.`b` AS `b`,`__3`.`a` AS `a`,`__3`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` union /* select#3 */ select NULL AS `NULL`,NULL AS `NULL`,NULL AS `NULL` limit 3) `__3` order by `__3`.`b` - `__3`.`a` - `__3`.`c`
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
ORDER BY a LIMIT 3)
|
||||||
|
ORDER BY b-a-c LIMIT 1;
|
||||||
|
b a c
|
||||||
|
NULL NULL NULL
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
ORDER BY a LIMIT 3)
|
||||||
|
ORDER BY b-a-c LIMIT 1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using filesort
|
||||||
|
2 DERIVED t1 ALL NULL NULL NULL NULL 4 100.00
|
||||||
|
2 DERIVED t2 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||||
|
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
|
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Using filesort
|
||||||
|
Warnings:
|
||||||
|
Note 1003 /* select#1 */ select `__3`.`b` AS `b`,`__3`.`a` AS `a`,`__3`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`b` union /* select#3 */ select NULL AS `NULL`,NULL AS `NULL`,NULL AS `NULL` order by `a` limit 3) `__3` order by `__3`.`b` - `__3`.`a` - `__3`.`c` limit 1
|
||||||
|
DROP TABLE t1, t2;
|
||||||
# End of 10.4 tests
|
# End of 10.4 tests
|
||||||
|
@ -2468,4 +2468,63 @@ EXPLAIN SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.b ORDER BY t1.b LIMIT 1) AS c FRO
|
|||||||
|
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-29681 Server crashes when optimizing SQL with ORDER BY
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (b INT);
|
||||||
|
CREATE TABLE t2 (a INT, c INT);
|
||||||
|
|
||||||
|
--echo # First test empty tables
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a+1;
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2;
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3)
|
||||||
|
ORDER BY a+1, a-b DESC, c<>a;
|
||||||
|
|
||||||
|
--echo # Insert some data
|
||||||
|
INSERT INTO t1 VALUES (1),(2),(3),(4);
|
||||||
|
INSERT INTO t2 VALUES (1,1),(2,2),(3,3),(4,4);
|
||||||
|
|
||||||
|
--sorted_result
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=b, a-10 DESC, b+a, c+a+a+b;
|
||||||
|
--sorted_result
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3) ORDER BY a=2;
|
||||||
|
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b LIMIT 3)
|
||||||
|
ORDER BY a=b, a-10, b+a, c+a+a+b;
|
||||||
|
|
||||||
|
--echo # When there is no LIMIT clause the derived table must be merged
|
||||||
|
--sorted_result
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16, b+a, c<>b;
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b) ORDER BY a+16 DESC, b+a, c<>b;
|
||||||
|
|
||||||
|
--echo # Test UNIONs:
|
||||||
|
--sorted_result
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT * FROM t1 JOIN t2 ON a!=b
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY a+16, b+a, c<>b;
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT * FROM t1 JOIN t2 ON a!=b
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY a+16, b+a, c<>b;
|
||||||
|
--sorted_result
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY b-a-c;
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
LIMIT 3)
|
||||||
|
ORDER BY b-a-c;
|
||||||
|
--sorted_result
|
||||||
|
(SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
ORDER BY a LIMIT 3)
|
||||||
|
ORDER BY b-a-c LIMIT 1;
|
||||||
|
EXPLAIN EXTENDED (SELECT * FROM t1 JOIN t2 ON a=b UNION
|
||||||
|
SELECT NULL, NULL, NULL
|
||||||
|
ORDER BY a LIMIT 3)
|
||||||
|
ORDER BY b-a-c LIMIT 1;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
--echo # End of 10.4 tests
|
--echo # End of 10.4 tests
|
||||||
|
@ -3,6 +3,20 @@
|
|||||||
#
|
#
|
||||||
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
|
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
|
||||||
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
||||||
|
INSERT INTO t1 VALUES ('b'), ('a'), ('c');
|
||||||
|
INSERT INTO t2 VALUES ('c'), ('d'), ('b');
|
||||||
|
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
||||||
|
EXECUTE stmt;
|
||||||
|
a
|
||||||
|
c
|
||||||
|
b
|
||||||
|
EXECUTE stmt;
|
||||||
|
a
|
||||||
|
c
|
||||||
|
b
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
DELETE FROM t1;
|
||||||
|
DELETE FROM t2;
|
||||||
INSERT INTO t1 VALUES ('b');
|
INSERT INTO t1 VALUES ('b');
|
||||||
INSERT INTO t2 VALUES ('b');
|
INSERT INTO t2 VALUES ('b');
|
||||||
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
||||||
@ -14,3 +28,21 @@ a
|
|||||||
b
|
b
|
||||||
DEALLOCATE PREPARE stmt;
|
DEALLOCATE PREPARE stmt;
|
||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
|
#
|
||||||
|
# MDEV-32569: Failure when executing PS for query using IN subquery
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
|
||||||
|
CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
||||||
|
INSERT INTO t1 VALUES ('b');
|
||||||
|
INSERT INTO t2 VALUES ('b');
|
||||||
|
PREPARE stmt FROM
|
||||||
|
"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
||||||
|
EXECUTE stmt;
|
||||||
|
a
|
||||||
|
b
|
||||||
|
EXECUTE stmt;
|
||||||
|
a
|
||||||
|
b
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
# End of 10.4 tests
|
||||||
|
@ -13,6 +13,19 @@
|
|||||||
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
|
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
|
||||||
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
||||||
|
|
||||||
|
INSERT INTO t1 VALUES ('b'), ('a'), ('c');
|
||||||
|
INSERT INTO t2 VALUES ('c'), ('d'), ('b');
|
||||||
|
|
||||||
|
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
||||||
|
|
||||||
|
EXECUTE stmt;
|
||||||
|
EXECUTE stmt;
|
||||||
|
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
DELETE FROM t1;
|
||||||
|
DELETE FROM t2;
|
||||||
|
|
||||||
INSERT INTO t1 VALUES ('b');
|
INSERT INTO t1 VALUES ('b');
|
||||||
INSERT INTO t2 VALUES ('b');
|
INSERT INTO t2 VALUES ('b');
|
||||||
|
|
||||||
@ -25,3 +38,24 @@ DEALLOCATE PREPARE stmt;
|
|||||||
|
|
||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-32569: Failure when executing PS for query using IN subquery
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
|
||||||
|
CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
||||||
|
|
||||||
|
INSERT INTO t1 VALUES ('b');
|
||||||
|
INSERT INTO t2 VALUES ('b');
|
||||||
|
|
||||||
|
PREPARE stmt FROM
|
||||||
|
"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
||||||
|
|
||||||
|
EXECUTE stmt;
|
||||||
|
EXECUTE stmt;
|
||||||
|
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
|
||||||
|
--echo # End of 10.4 tests
|
||||||
|
@ -7163,6 +7163,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# MDEV-7565: Server crash with Signal 6 (part 2)
|
# MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
#
|
#
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -1172,8 +1172,10 @@ create table t1 (a int, b decimal(13, 3));
|
|||||||
insert into t1 values (1, 0.123);
|
insert into t1 values (1, 0.123);
|
||||||
let $outfile_abs= $MYSQLTEST_VARDIR/tmp/subselect.out.file.1;
|
let $outfile_abs= $MYSQLTEST_VARDIR/tmp/subselect.out.file.1;
|
||||||
let $outfile_rel= ../../tmp/subselect.out.file.1;
|
let $outfile_rel= ../../tmp/subselect.out.file.1;
|
||||||
|
--disable_warnings
|
||||||
--error 0,1
|
--error 0,1
|
||||||
--remove_file $outfile_abs
|
--remove_file $outfile_abs
|
||||||
|
--enable_warnings
|
||||||
eval select a, (select max(b) from t1) into outfile "$outfile_rel" from t1;
|
eval select a, (select max(b) from t1) into outfile "$outfile_rel" from t1;
|
||||||
delete from t1;
|
delete from t1;
|
||||||
eval load data infile "$outfile_rel" into table t1;
|
eval load data infile "$outfile_rel" into table t1;
|
||||||
@ -5992,6 +5994,8 @@ drop table t1;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # MDEV-7565: Server crash with Signal 6 (part 2)
|
--echo # MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -7163,6 +7163,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# MDEV-7565: Server crash with Signal 6 (part 2)
|
# MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
#
|
#
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -7156,6 +7156,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# MDEV-7565: Server crash with Signal 6 (part 2)
|
# MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
#
|
#
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -7154,6 +7154,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# MDEV-7565: Server crash with Signal 6 (part 2)
|
# MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
#
|
#
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -7169,6 +7169,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# MDEV-7565: Server crash with Signal 6 (part 2)
|
# MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
#
|
#
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -7154,6 +7154,7 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
# MDEV-7565: Server crash with Signal 6 (part 2)
|
# MDEV-7565: Server crash with Signal 6 (part 2)
|
||||||
#
|
#
|
||||||
|
truncate table mysql.slow_log;
|
||||||
Select
|
Select
|
||||||
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
(Select Sum(`TestCase`.Revenue) From mysql.slow_log E
|
||||||
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
|
||||||
|
@ -3,12 +3,12 @@ EXPLAIN EXTENDED SELECT 'a'||'b'||'c';
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(concat_operator_oracle('a','b'),'c') AS "'a'||'b'||'c'"
|
Note 1003 select concat(concat('a','b'),'c') AS "'a'||'b'||'c'"
|
||||||
EXPLAIN EXTENDED SELECT CONCAT('a'||'b'||'c');
|
EXPLAIN EXTENDED SELECT CONCAT('a'||'b'||'c');
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(concat_operator_oracle(concat_operator_oracle('a','b'),'c')) AS "CONCAT('a'||'b'||'c')"
|
Note 1003 select concat(concat(concat('a','b'),'c')) AS "CONCAT('a'||'b'||'c')"
|
||||||
SELECT '' || '';
|
SELECT '' || '';
|
||||||
'' || ''
|
'' || ''
|
||||||
|
|
||||||
@ -211,14 +211,14 @@ SET sql_mode=ORACLE;
|
|||||||
CREATE VIEW v1 AS SELECT 'foo'||NULL||'bar' AS test;
|
CREATE VIEW v1 AS SELECT 'foo'||NULL||'bar' AS test;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select concat_operator_oracle(concat_operator_oracle('foo',NULL),'bar') AS "test" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select concat(concat('foo',NULL),'bar') AS "test" latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
test
|
test
|
||||||
foobar
|
foobar
|
||||||
SET sql_mode=DEFAULT;
|
SET sql_mode=DEFAULT;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select concat_operator_oracle(concat_operator_oracle('foo',NULL),'bar') AS `test` latin1 latin1_swedish_ci
|
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select oracle_schema.concat(oracle_schema.concat('foo',NULL),'bar') AS `test` latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
test
|
test
|
||||||
foobar
|
foobar
|
||||||
@ -234,7 +234,7 @@ NULL
|
|||||||
SET sql_mode=ORACLE;
|
SET sql_mode=ORACLE;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select concat('foo',NULL,'bar') AS "test" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select mariadb_schema.concat('foo',NULL,'bar') AS "test" latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
test
|
test
|
||||||
NULL
|
NULL
|
||||||
@ -268,12 +268,12 @@ EXPLAIN EXTENDED SELECT -1<<1||1 AS a FROM DUAL;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select -1 << concat_operator_oracle(1,1) AS "a"
|
Note 1003 select -1 << concat(1,1) AS "a"
|
||||||
EXPLAIN EXTENDED SELECT -1||0<<1 AS a FROM DUAL;
|
EXPLAIN EXTENDED SELECT -1||0<<1 AS a FROM DUAL;
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(-1,0) << 1 AS "a"
|
Note 1003 select concat(-1,0) << 1 AS "a"
|
||||||
SELECT -1+1||1 AS a FROM DUAL;
|
SELECT -1+1||1 AS a FROM DUAL;
|
||||||
a
|
a
|
||||||
01
|
01
|
||||||
@ -284,12 +284,12 @@ EXPLAIN EXTENDED SELECT -1+1||1 AS a FROM DUAL;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(-1 + 1,1) AS "a"
|
Note 1003 select concat(-1 + 1,1) AS "a"
|
||||||
EXPLAIN EXTENDED SELECT -1||0+1 AS a FROM DUAL;
|
EXPLAIN EXTENDED SELECT -1||0+1 AS a FROM DUAL;
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(-1,0) + 1 AS "a"
|
Note 1003 select concat(-1,0) + 1 AS "a"
|
||||||
SELECT 1*1||-1 AS a FROM DUAL;
|
SELECT 1*1||-1 AS a FROM DUAL;
|
||||||
a
|
a
|
||||||
1-1
|
1-1
|
||||||
@ -300,12 +300,12 @@ EXPLAIN EXTENDED SELECT 1*1||-1 AS a FROM DUAL;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(1 * 1,-1) AS "a"
|
Note 1003 select concat(1 * 1,-1) AS "a"
|
||||||
EXPLAIN EXTENDED SELECT 1||1*-1 AS a FROM DUAL;
|
EXPLAIN EXTENDED SELECT 1||1*-1 AS a FROM DUAL;
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(1,1 * -1) AS "a"
|
Note 1003 select concat(1,1 * -1) AS "a"
|
||||||
SELECT -1^1||1 AS a FROM DUAL;
|
SELECT -1^1||1 AS a FROM DUAL;
|
||||||
a
|
a
|
||||||
184467440737095516141
|
184467440737095516141
|
||||||
@ -316,12 +316,12 @@ EXPLAIN EXTENDED SELECT -1^1||1 AS a FROM DUAL;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(-1 ^ 1,1) AS "a"
|
Note 1003 select concat(-1 ^ 1,1) AS "a"
|
||||||
EXPLAIN EXTENDED SELECT -1||0^1 AS a FROM DUAL;
|
EXPLAIN EXTENDED SELECT -1||0^1 AS a FROM DUAL;
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select concat_operator_oracle(-1,0 ^ 1) AS "a"
|
Note 1003 select concat(-1,0 ^ 1) AS "a"
|
||||||
#
|
#
|
||||||
# MDEV-17359 Concatenation operator || in like expression failed in sql_mode=ORACLE
|
# MDEV-17359 Concatenation operator || in like expression failed in sql_mode=ORACLE
|
||||||
#
|
#
|
||||||
@ -332,7 +332,7 @@ EXPLAIN EXTENDED SELECT 'abc' LIKE 'a'||'%';
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select 'abc' like concat_operator_oracle('a','%') AS "'abc' LIKE 'a'||'%'"
|
Note 1003 select 'abc' like concat('a','%') AS "'abc' LIKE 'a'||'%'"
|
||||||
SELECT 'x' FROM DUAL WHERE 11 LIKE 1||1;
|
SELECT 'x' FROM DUAL WHERE 11 LIKE 1||1;
|
||||||
x
|
x
|
||||||
x
|
x
|
||||||
@ -353,7 +353,7 @@ EXPLAIN EXTENDED SELECT c1 FROM t1 WHERE c1 LIKE '%'||'b' ORDER BY ord;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select "test"."t1"."c1" AS "c1" from "test"."t1" where "test"."t1"."c1" like <cache>(concat_operator_oracle('%','b')) order by "test"."t1"."ord"
|
Note 1003 select "test"."t1"."c1" AS "c1" from "test"."t1" where "test"."t1"."c1" like <cache>(concat('%','b')) order by "test"."t1"."ord"
|
||||||
SELECT c1 FROM t1 WHERE c1 LIKE c2||'%'||'c' ORDER BY ord;
|
SELECT c1 FROM t1 WHERE c1 LIKE c2||'%'||'c' ORDER BY ord;
|
||||||
c1
|
c1
|
||||||
abc
|
abc
|
||||||
@ -361,7 +361,7 @@ EXPLAIN EXTENDED SELECT c1 FROM t1 WHERE c1 LIKE c2||'%'||'c' ORDER BY ord;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select "test"."t1"."c1" AS "c1" from "test"."t1" where "test"."t1"."c1" like concat_operator_oracle(concat_operator_oracle("test"."t1"."c2",'%'),'c') order by "test"."t1"."ord"
|
Note 1003 select "test"."t1"."c1" AS "c1" from "test"."t1" where "test"."t1"."c1" like concat(concat("test"."t1"."c2",'%'),'c') order by "test"."t1"."ord"
|
||||||
SELECT 'x' FROM t1 WHERE c1||c2 LIKE 'aa%';
|
SELECT 'x' FROM t1 WHERE c1||c2 LIKE 'aa%';
|
||||||
x
|
x
|
||||||
x
|
x
|
||||||
@ -369,7 +369,7 @@ EXPLAIN EXTENDED SELECT 'x' FROM t1 WHERE c1||c2 LIKE 'aa%';
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select 'x' AS "x" from "test"."t1" where concat_operator_oracle("test"."t1"."c1","test"."t1"."c2") like 'aa%'
|
Note 1003 select 'x' AS "x" from "test"."t1" where concat("test"."t1"."c1","test"."t1"."c2") like 'aa%'
|
||||||
SELECT 'x' FROM t1 WHERE c1||c2 LIKE c2||c1;
|
SELECT 'x' FROM t1 WHERE c1||c2 LIKE c2||c1;
|
||||||
x
|
x
|
||||||
x
|
x
|
||||||
@ -377,7 +377,7 @@ EXPLAIN EXTENDED SELECT 'x' FROM t1 WHERE c1||c2 LIKE c2||c1;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select 'x' AS "x" from "test"."t1" where concat_operator_oracle("test"."t1"."c1","test"."t1"."c2") like concat_operator_oracle("test"."t1"."c2","test"."t1"."c1")
|
Note 1003 select 'x' AS "x" from "test"."t1" where concat("test"."t1"."c1","test"."t1"."c2") like concat("test"."t1"."c2","test"."t1"."c1")
|
||||||
CREATE VIEW v1 AS SELECT c1, c2, c1 LIKE c2||'_' FROM t1 ORDER BY ord;
|
CREATE VIEW v1 AS SELECT c1, c2, c1 LIKE c2||'_' FROM t1 ORDER BY ord;
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
c1 c2 c1 LIKE c2||'_'
|
c1 c2 c1 LIKE c2||'_'
|
||||||
@ -388,6 +388,6 @@ EXPLAIN EXTENDED SELECT * FROM v1;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using filesort
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using filesort
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select "test"."t1"."c1" AS "c1","test"."t1"."c2" AS "c2","test"."t1"."c1" like concat_operator_oracle("test"."t1"."c2",'_') AS "c1 LIKE c2||'_'" from "test"."t1" order by "test"."t1"."ord"
|
Note 1003 select "test"."t1"."c1" AS "c1","test"."t1"."c2" AS "c2","test"."t1"."c1" like concat("test"."t1"."c2",'_') AS "c1 LIKE c2||'_'" from "test"."t1" order by "test"."t1"."ord"
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
@ -28,7 +28,7 @@ EXPLAIN EXTENDED SELECT DECODE(12,10,'x10',11,'x11','def');
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select decode_oracle(12,10,'x10',11,'x11','def') AS "DECODE(12,10,'x10',11,'x11','def')"
|
Note 1003 select decode(12,10,'x10',11,'x11','def') AS "DECODE(12,10,'x10',11,'x11','def')"
|
||||||
CREATE TABLE decode (decode int);
|
CREATE TABLE decode (decode int);
|
||||||
DROP TABLE decode;
|
DROP TABLE decode;
|
||||||
#
|
#
|
||||||
@ -46,22 +46,22 @@ EXPLAIN EXTENDED SELECT DECODE(12,10,'x10',11,'x11');
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select decode_oracle(12,10,'x10',11,'x11') AS "DECODE(12,10,'x10',11,'x11')"
|
Note 1003 select decode(12,10,'x10',11,'x11') AS "DECODE(12,10,'x10',11,'x11')"
|
||||||
EXPLAIN EXTENDED SELECT DECODE(12,10,'x10',11,'x11','def');
|
EXPLAIN EXTENDED SELECT DECODE(12,10,'x10',11,'x11','def');
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select decode_oracle(12,10,'x10',11,'x11','def') AS "DECODE(12,10,'x10',11,'x11','def')"
|
Note 1003 select decode(12,10,'x10',11,'x11','def') AS "DECODE(12,10,'x10',11,'x11','def')"
|
||||||
EXPLAIN EXTENDED SELECT DECODE_ORACLE(12,10,'x10',11,'x11');
|
EXPLAIN EXTENDED SELECT DECODE_ORACLE(12,10,'x10',11,'x11');
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select decode_oracle(12,10,'x10',11,'x11') AS "DECODE_ORACLE(12,10,'x10',11,'x11')"
|
Note 1003 select decode(12,10,'x10',11,'x11') AS "DECODE_ORACLE(12,10,'x10',11,'x11')"
|
||||||
EXPLAIN EXTENDED SELECT DECODE_ORACLE(12,10,'x10',11,'x11','def');
|
EXPLAIN EXTENDED SELECT DECODE_ORACLE(12,10,'x10',11,'x11','def');
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select decode_oracle(12,10,'x10',11,'x11','def') AS "DECODE_ORACLE(12,10,'x10',11,'x11','def')"
|
Note 1003 select decode(12,10,'x10',11,'x11','def') AS "DECODE_ORACLE(12,10,'x10',11,'x11','def')"
|
||||||
CREATE TABLE t1 (a INT);
|
CREATE TABLE t1 (a INT);
|
||||||
CREATE VIEW v1 AS
|
CREATE VIEW v1 AS
|
||||||
SELECT
|
SELECT
|
||||||
@ -72,7 +72,7 @@ DECODE_ORACLE(a,1,'x1',NULL,'xNULL','xELSE') AS d4
|
|||||||
FROM t1;
|
FROM t1;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select decode_oracle("t1"."a",1,'x1',NULL,'xNULL') AS "d1",decode_oracle("t1"."a",1,'x1',NULL,'xNULL','xELSE') AS "d2",decode_oracle("t1"."a",1,'x1',NULL,'xNULL') AS "d3",decode_oracle("t1"."a",1,'x1',NULL,'xNULL','xELSE') AS "d4" from "t1" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select decode("t1"."a",1,'x1',NULL,'xNULL') AS "d1",decode("t1"."a",1,'x1',NULL,'xNULL','xELSE') AS "d2",decode("t1"."a",1,'x1',NULL,'xNULL') AS "d3",decode("t1"."a",1,'x1',NULL,'xNULL','xELSE') AS "d4" from "t1" latin1 latin1_swedish_ci
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SELECT DECODE(TIME'10:20:31','10:20:31','then1','10:20:32','then2','def');
|
SELECT DECODE(TIME'10:20:31','10:20:31','then1','10:20:32','then2','def');
|
||||||
|
@ -44,11 +44,11 @@ EXPLAIN EXTENDED SELECT RPAD('a',0,'.'), LPAD('a',0,'.'), LPAD(c1,c2,c3), LPAD(c
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using filesort
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using filesort
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select rpad_oracle('a',0,'.') AS "RPAD('a',0,'.')",lpad_oracle('a',0,'.') AS "LPAD('a',0,'.')",lpad_oracle("test"."t1"."c1","test"."t1"."c2","test"."t1"."c3") AS "LPAD(c1,c2,c3)",lpad_oracle("test"."t1"."c1","test"."t1"."c2") AS "LPAD(c1,c2)",rpad_oracle("test"."t1"."c1","test"."t1"."c2","test"."t1"."c3") AS "RPAD(c1,c2,c3)",rpad_oracle("test"."t1"."c1","test"."t1"."c2") AS "RPAD(c1,c2)" from "test"."t1" order by "test"."t1"."ord"
|
Note 1003 select rpad('a',0,'.') AS "RPAD('a',0,'.')",lpad('a',0,'.') AS "LPAD('a',0,'.')",lpad("test"."t1"."c1","test"."t1"."c2","test"."t1"."c3") AS "LPAD(c1,c2,c3)",lpad("test"."t1"."c1","test"."t1"."c2") AS "LPAD(c1,c2)",rpad("test"."t1"."c1","test"."t1"."c2","test"."t1"."c3") AS "RPAD(c1,c2,c3)",rpad("test"."t1"."c1","test"."t1"."c2") AS "RPAD(c1,c2)" from "test"."t1" order by "test"."t1"."ord"
|
||||||
CREATE VIEW v1 AS SELECT RPAD('a',0,'.') AS "C1", LPAD('a',0,'.') AS "C2", LPAD(c1,c2,c3) AS "C3", LPAD(c1,c2) AS "C4", RPAD(c1,c2,c3) AS "C5", RPAD(c1,c2) AS "C6" FROM t1 ORDER BY ord;
|
CREATE VIEW v1 AS SELECT RPAD('a',0,'.') AS "C1", LPAD('a',0,'.') AS "C2", LPAD(c1,c2,c3) AS "C3", LPAD(c1,c2) AS "C4", RPAD(c1,c2,c3) AS "C5", RPAD(c1,c2) AS "C6" FROM t1 ORDER BY ord;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select rpad_oracle('a',0,'.') AS "C1",lpad_oracle('a',0,'.') AS "C2",lpad_oracle("t1"."c1","t1"."c2","t1"."c3") AS "C3",lpad_oracle("t1"."c1","t1"."c2") AS "C4",rpad_oracle("t1"."c1","t1"."c2","t1"."c3") AS "C5",rpad_oracle("t1"."c1","t1"."c2") AS "C6" from "t1" order by "t1"."ord" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select rpad('a',0,'.') AS "C1",lpad('a',0,'.') AS "C2",lpad("t1"."c1","t1"."c2","t1"."c3") AS "C3",lpad("t1"."c1","t1"."c2") AS "C4",rpad("t1"."c1","t1"."c2","t1"."c3") AS "C5",rpad("t1"."c1","t1"."c2") AS "C6" from "t1" order by "t1"."ord" latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
C1 C2 C3 C4 C5 C6
|
C1 C2 C3 C4 C5 C6
|
||||||
NULL NULL NULL a NULL a
|
NULL NULL NULL a NULL a
|
||||||
|
2468
mysql-test/suite/compat/oracle/r/func_qualified.result
Normal file
2468
mysql-test/suite/compat/oracle/r/func_qualified.result
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,11 +21,11 @@ EXPLAIN EXTENDED SELECT REPLACE('ab','a',null) ;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select replace_oracle('ab','a',NULL) AS "REPLACE('ab','a',null)"
|
Note 1003 select replace('ab','a',NULL) AS "REPLACE('ab','a',null)"
|
||||||
CREATE VIEW v1 AS SELECT REPLACE('ab','a',null) ;
|
CREATE VIEW v1 AS SELECT REPLACE('ab','a',null) ;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select replace_oracle('ab','a',NULL) AS "REPLACE('ab','a',null)" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select replace('ab','a',NULL) AS "REPLACE('ab','a',null)" latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
REPLACE('ab','a',null)
|
REPLACE('ab','a',null)
|
||||||
b
|
b
|
||||||
|
@ -76,11 +76,11 @@ EXPLAIN EXTENDED SELECT SUBSTR('abc',2,1) ;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select substr_oracle('abc',2,1) AS "SUBSTR('abc',2,1)"
|
Note 1003 select substr('abc',2,1) AS "SUBSTR('abc',2,1)"
|
||||||
CREATE VIEW v1 AS SELECT SUBSTR('abc',2,1) ;
|
CREATE VIEW v1 AS SELECT SUBSTR('abc',2,1) ;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select substr_oracle('abc',2,1) AS "SUBSTR('abc',2,1)" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select substr('abc',2,1) AS "SUBSTR('abc',2,1)" latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
SUBSTR('abc',2,1)
|
SUBSTR('abc',2,1)
|
||||||
b
|
b
|
||||||
|
@ -116,13 +116,13 @@ TRIM(TRAILING 'a' FROM 'abc') ;
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select trim_oracle('abc') AS "TRIM('abc')",trim_oracle(both 'a' from 'abc') AS "TRIM(BOTH 'a' FROM 'abc')",trim_oracle(leading 'a' from 'abc') AS "TRIM(LEADING 'a' FROM 'abc')",trim_oracle(trailing 'a' from 'abc') AS "TRIM(TRAILING 'a' FROM 'abc')"
|
Note 1003 select trim('abc') AS "TRIM('abc')",trim(both 'a' from 'abc') AS "TRIM(BOTH 'a' FROM 'abc')",trim(leading 'a' from 'abc') AS "TRIM(LEADING 'a' FROM 'abc')",trim(trailing 'a' from 'abc') AS "TRIM(TRAILING 'a' FROM 'abc')"
|
||||||
EXPLAIN EXTENDED SELECT RTRIM('abc'),
|
EXPLAIN EXTENDED SELECT RTRIM('abc'),
|
||||||
LTRIM('abc');
|
LTRIM('abc');
|
||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select rtrim_oracle('abc') AS "RTRIM('abc')",ltrim_oracle('abc') AS "LTRIM('abc')"
|
Note 1003 select rtrim('abc') AS "RTRIM('abc')",ltrim('abc') AS "LTRIM('abc')"
|
||||||
CREATE VIEW v1 AS SELECT ord,TRIM('abc'),RTRIM('abc'),LTRIM('abc'),
|
CREATE VIEW v1 AS SELECT ord,TRIM('abc'),RTRIM('abc'),LTRIM('abc'),
|
||||||
'['||c1||']',
|
'['||c1||']',
|
||||||
TRIM(LEADING 'a' FROM c1),
|
TRIM(LEADING 'a' FROM c1),
|
||||||
@ -133,7 +133,7 @@ RTRIM(c1)
|
|||||||
FROM t1 ORDER BY ord ;
|
FROM t1 ORDER BY ord ;
|
||||||
SHOW CREATE VIEW v1;
|
SHOW CREATE VIEW v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE VIEW "v1" AS select "t1"."ord" AS "ord",trim_oracle('abc') AS "TRIM('abc')",rtrim_oracle('abc') AS "RTRIM('abc')",ltrim_oracle('abc') AS "LTRIM('abc')",concat_operator_oracle(concat_operator_oracle('[',"t1"."c1"),']') AS "'['||c1||']'",trim_oracle(leading 'a' from "t1"."c1") AS "TRIM(LEADING 'a' FROM c1)",trim_oracle(trailing 'a' from "t1"."c1") AS "TRIM(TRAILING 'a' FROM c1)",trim_oracle(both 'a' from "t1"."c1") AS "TRIM(BOTH 'a' FROM c1)",ltrim_oracle("t1"."c1") AS "LTRIM(c1)",rtrim_oracle("t1"."c1") AS "RTRIM(c1)" from "t1" order by "t1"."ord" latin1 latin1_swedish_ci
|
v1 CREATE VIEW "v1" AS select "t1"."ord" AS "ord",trim('abc') AS "TRIM('abc')",rtrim('abc') AS "RTRIM('abc')",ltrim('abc') AS "LTRIM('abc')",concat(concat('[',"t1"."c1"),']') AS "'['||c1||']'",trim(leading 'a' from "t1"."c1") AS "TRIM(LEADING 'a' FROM c1)",trim(trailing 'a' from "t1"."c1") AS "TRIM(TRAILING 'a' FROM c1)",trim(both 'a' from "t1"."c1") AS "TRIM(BOTH 'a' FROM c1)",ltrim("t1"."c1") AS "LTRIM(c1)",rtrim("t1"."c1") AS "RTRIM(c1)" from "t1" order by "t1"."ord" latin1 latin1_swedish_ci
|
||||||
SELECT * FROM v1;
|
SELECT * FROM v1;
|
||||||
ord TRIM('abc') RTRIM('abc') LTRIM('abc') '['||c1||']' TRIM(LEADING 'a' FROM c1) TRIM(TRAILING 'a' FROM c1) TRIM(BOTH 'a' FROM c1) LTRIM(c1) RTRIM(c1)
|
ord TRIM('abc') RTRIM('abc') LTRIM('abc') '['||c1||']' TRIM(LEADING 'a' FROM c1) TRIM(TRAILING 'a' FROM c1) TRIM(BOTH 'a' FROM c1) LTRIM(c1) RTRIM(c1)
|
||||||
1 abc abc abc [abc] bc abc bc abc abc
|
1 abc abc abc [abc] bc abc bc abc abc
|
||||||
|
@ -0,0 +1,112 @@
|
|||||||
|
#
|
||||||
|
# Start of 10.4 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
|
||||||
|
#
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a0 VARCHAR(64) NOT NULL DEFAULT LTRIM(now()),
|
||||||
|
a1 VARCHAR(64) AS (LTRIM(a0)) PERSISTENT,
|
||||||
|
b0 VARCHAR(64) NOT NULL DEFAULT LPAD(now(),10),
|
||||||
|
b1 VARCHAR(64) AS (LPAD(b0,10)) PERSISTENT
|
||||||
|
);
|
||||||
|
CREATE VIEW v1 AS SELECT
|
||||||
|
LTRIM(now()) AS a0,
|
||||||
|
LPAD(now(),10) AS b0;
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
a0 VARCHAR(64) NOT NULL DEFAULT LTRIM(now()),
|
||||||
|
a1 VARCHAR(64) AS (LTRIM(a0)) PERSISTENT,
|
||||||
|
b0 VARCHAR(64) NOT NULL DEFAULT LPAD(now(),10),
|
||||||
|
b1 VARCHAR(64) AS (LPAD(b0,10)) PERSISTENT
|
||||||
|
);
|
||||||
|
CREATE VIEW v2 AS SELECT
|
||||||
|
LTRIM(now()) AS a0,
|
||||||
|
LPAD(now(),10) AS b0;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t1` (
|
||||||
|
`a0` varchar(64) NOT NULL DEFAULT ltrim(current_timestamp()),
|
||||||
|
`a1` varchar(64) GENERATED ALWAYS AS (ltrim(`a0`)) STORED,
|
||||||
|
`b0` varchar(64) NOT NULL DEFAULT lpad(current_timestamp(),10),
|
||||||
|
`b1` varchar(64) GENERATED ALWAYS AS (lpad(`b0`,10)) STORED
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t2` (
|
||||||
|
`a0` varchar(64) NOT NULL DEFAULT ltrim_oracle(current_timestamp()),
|
||||||
|
`a1` varchar(64) GENERATED ALWAYS AS (ltrim_oracle(`a0`)) STORED,
|
||||||
|
`b0` varchar(64) NOT NULL DEFAULT lpad_oracle(current_timestamp(),10),
|
||||||
|
`b1` varchar(64) GENERATED ALWAYS AS (lpad_oracle(`b0`,10)) STORED
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
SET @saved_cs_client = @@character_set_client;
|
||||||
|
SET character_set_client = utf8;
|
||||||
|
/*!50001 CREATE VIEW `v1` AS SELECT
|
||||||
|
1 AS `a0`,
|
||||||
|
1 AS `b0` */;
|
||||||
|
SET character_set_client = @saved_cs_client;
|
||||||
|
SET @saved_cs_client = @@character_set_client;
|
||||||
|
SET character_set_client = utf8;
|
||||||
|
/*!50001 CREATE VIEW `v2` AS SELECT
|
||||||
|
1 AS `a0`,
|
||||||
|
1 AS `b0` */;
|
||||||
|
SET character_set_client = @saved_cs_client;
|
||||||
|
/*!50001 DROP VIEW IF EXISTS `v1`*/;
|
||||||
|
/*!50001 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50001 SET @saved_cs_results = @@character_set_results */;
|
||||||
|
/*!50001 SET @saved_col_connection = @@collation_connection */;
|
||||||
|
/*!50001 SET character_set_client = latin1 */;
|
||||||
|
/*!50001 SET character_set_results = latin1 */;
|
||||||
|
/*!50001 SET collation_connection = latin1_swedish_ci */;
|
||||||
|
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
||||||
|
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
|
||||||
|
/*!50001 VIEW `v1` AS select ltrim(current_timestamp()) AS `a0`,lpad(current_timestamp(),10) AS `b0` */;
|
||||||
|
/*!50001 SET character_set_client = @saved_cs_client */;
|
||||||
|
/*!50001 SET character_set_results = @saved_cs_results */;
|
||||||
|
/*!50001 SET collation_connection = @saved_col_connection */;
|
||||||
|
/*!50001 DROP VIEW IF EXISTS `v2`*/;
|
||||||
|
/*!50001 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50001 SET @saved_cs_results = @@character_set_results */;
|
||||||
|
/*!50001 SET @saved_col_connection = @@collation_connection */;
|
||||||
|
/*!50001 SET character_set_client = latin1 */;
|
||||||
|
/*!50001 SET character_set_results = latin1 */;
|
||||||
|
/*!50001 SET collation_connection = latin1_swedish_ci */;
|
||||||
|
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
||||||
|
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
|
||||||
|
/*!50001 VIEW `v2` AS select oracle_schema.ltrim(current_timestamp()) AS `a0`,oracle_schema.lpad(current_timestamp(),10) AS `b0` */;
|
||||||
|
/*!50001 SET character_set_client = @saved_cs_client */;
|
||||||
|
/*!50001 SET character_set_results = @saved_cs_results */;
|
||||||
|
/*!50001 SET collation_connection = @saved_col_connection */;
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
DROP VIEW v1,v2;
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a0` varchar(64) NOT NULL DEFAULT ltrim(current_timestamp()),
|
||||||
|
`a1` varchar(64) GENERATED ALWAYS AS (ltrim(`a0`)) STORED,
|
||||||
|
`b0` varchar(64) NOT NULL DEFAULT lpad(current_timestamp(),10),
|
||||||
|
`b1` varchar(64) GENERATED ALWAYS AS (lpad(`b0`,10)) STORED
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SHOW CREATE TABLE t2;
|
||||||
|
Table Create Table
|
||||||
|
t2 CREATE TABLE `t2` (
|
||||||
|
`a0` varchar(64) NOT NULL DEFAULT ltrim_oracle(current_timestamp()),
|
||||||
|
`a1` varchar(64) GENERATED ALWAYS AS (ltrim_oracle(`a0`)) STORED,
|
||||||
|
`b0` varchar(64) NOT NULL DEFAULT lpad_oracle(current_timestamp(),10),
|
||||||
|
`b1` varchar(64) GENERATED ALWAYS AS (lpad_oracle(`b0`,10)) STORED
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SHOW CREATE VIEW v1;
|
||||||
|
View Create View character_set_client collation_connection
|
||||||
|
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select ltrim(current_timestamp()) AS `a0`,lpad(current_timestamp(),10) AS `b0` latin1 latin1_swedish_ci
|
||||||
|
SHOW CREATE VIEW v2;
|
||||||
|
View Create View character_set_client collation_connection
|
||||||
|
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select oracle_schema.ltrim(current_timestamp()) AS `a0`,oracle_schema.lpad(current_timestamp(),10) AS `b0` latin1 latin1_swedish_ci
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
DROP VIEW v1, v2;
|
||||||
|
#
|
||||||
|
# End of 10.4 tests
|
||||||
|
#
|
@ -178,9 +178,9 @@ EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING 10;
|
|||||||
# Testing erroneous and diallowed prepare source
|
# Testing erroneous and diallowed prepare source
|
||||||
#
|
#
|
||||||
EXECUTE IMMEDIATE _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL';
|
EXECUTE IMMEDIATE _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL';
|
||||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_operator_oracle'
|
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
|
||||||
PREPARE stmt FROM _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL';
|
PREPARE stmt FROM _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL';
|
||||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_operator_oracle'
|
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
|
||||||
EXECUTE IMMEDIATE (SELECT 'SELECT 1');
|
EXECUTE IMMEDIATE (SELECT 'SELECT 1');
|
||||||
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
|
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
|
||||||
PREPARE stmt FROM (SELECT 'SELECT 1');
|
PREPARE stmt FROM (SELECT 'SELECT 1');
|
||||||
|
@ -758,7 +758,7 @@ END;
|
|||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
CALL p1();
|
CALL p1();
|
||||||
ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat_operator_oracle'
|
ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat'
|
||||||
DROP PROCEDURE p1;
|
DROP PROCEDURE p1;
|
||||||
#
|
#
|
||||||
# Non-existing field
|
# Non-existing field
|
||||||
|
54
mysql-test/suite/compat/oracle/r/vcol_innodb.result
Normal file
54
mysql-test/suite/compat/oracle/r/vcol_innodb.result
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#
|
||||||
|
# MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
|
||||||
|
#
|
||||||
|
FLUSH TABLES;
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE TABLE t (d INT,b VARCHAR(1),c CHAR(1),g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b),KEY g(g)) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t VALUES (0);
|
||||||
|
ERROR 21S01: Column count doesn't match value count at row 1
|
||||||
|
SET sql_mode='ORACLE';
|
||||||
|
INSERT INTO t SET c=REPEAT (1,0);
|
||||||
|
Warnings:
|
||||||
|
Warning 1364 Field 'b' doesn't have a default value
|
||||||
|
ALTER TABLE t CHANGE COLUMN a b INT;
|
||||||
|
ERROR 42S22: Unknown column 'a' in 't'
|
||||||
|
DELETE FROM t;
|
||||||
|
SET sql_mode='';
|
||||||
|
FLUSH TABLES;
|
||||||
|
INSERT INTO t SET c='0';
|
||||||
|
Warnings:
|
||||||
|
Warning 1364 Field 'b' doesn't have a default value
|
||||||
|
DROP TABLE t;
|
||||||
|
FLUSH TABLES;
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE TABLE t (a INT(1),d INT(1),b VARCHAR(1),c CHAR(1),vadc INT(1) GENERATED ALWAYS AS ( (a + length (d))) STORED,vbc CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,vbidxc CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b (1),a,d),KEY d (d),KEY a (a),KEY c_renamed (c (1),b (1)),KEY b (b (1),c (1),a),KEY vbidxc (vbidxc),KEY a_2 (a,vbidxc),KEY vbidxc_2 (vbidxc,d)) DEFAULT CHARSET=latin1 ENGINE=InnoDB;
|
||||||
|
INSERT INTO t VALUES (0,0,1,0,1,0,1,0,0);
|
||||||
|
ERROR 21S01: Column count doesn't match value count at row 1
|
||||||
|
SET SESSION sql_mode='ORACLE';
|
||||||
|
INSERT INTO t SET c=REPEAT (1,0);
|
||||||
|
Warnings:
|
||||||
|
Warning 1364 Field 'a' doesn't have a default value
|
||||||
|
Warning 1364 Field 'd' doesn't have a default value
|
||||||
|
Warning 1364 Field 'b' doesn't have a default value
|
||||||
|
ALTER TABLE t CHANGE COLUMN a b CHAR(1);
|
||||||
|
ERROR 42S21: Duplicate column name 'b'
|
||||||
|
DELETE FROM t;
|
||||||
|
SET SESSION sql_mode=DEFAULT;
|
||||||
|
DROP TABLE t;
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE TABLE t1 (d INT,b VARCHAR(1),c CHAR(1),g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b),KEY g(g)) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (0);
|
||||||
|
ERROR 21S01: Column count doesn't match value count at row 1
|
||||||
|
SET sql_mode='ORACLE';
|
||||||
|
INSERT INTO t1 SET c=REPEAT (1,0);
|
||||||
|
Warnings:
|
||||||
|
Warning 1364 Field 'b' doesn't have a default value
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN a b INT;
|
||||||
|
ERROR 42S22: Unknown column 'a' in 't1'
|
||||||
|
DELETE FROM t1;
|
||||||
|
SET sql_mode='';
|
||||||
|
FLUSH TABLES;
|
||||||
|
INSERT INTO t1 SET c='0';
|
||||||
|
Warnings:
|
||||||
|
Warning 1364 Field 'b' doesn't have a default value
|
||||||
|
DROP TABLE t1;
|
247
mysql-test/suite/compat/oracle/t/func_qualified.test
Normal file
247
mysql-test/suite/compat/oracle/t/func_qualified.test
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
--let $MYSQLD_DATADIR= `select @@datadir`
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
#
|
||||||
|
# Testing that the error message for DECODE preserves
|
||||||
|
# the exact letter case as typed by the user
|
||||||
|
#
|
||||||
|
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT decode_oracle(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT DECODE_ORACLE(1);
|
||||||
|
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT decode_oracle(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT DECODE_ORACLE(1);
|
||||||
|
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT decode(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT DECODE(1);
|
||||||
|
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT decode(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT DECODE(1);
|
||||||
|
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT mariadb_schema.decode(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT mariadb_schema.DECODE(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT mariadb_schema.decode_oracle(1);
|
||||||
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
||||||
|
SELECT mariadb_schema.DECODE_ORACLE(1);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Testing that REPLACE, SUBSTR, TRIM print the exact name
|
||||||
|
# as typed by the user in "Function .. is not defined"
|
||||||
|
#
|
||||||
|
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.TRIM(1);
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.trim(1);
|
||||||
|
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.TRIM();
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.TRIM('a','b');
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.TRIM('a','b','c','d');
|
||||||
|
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.SUBSTR('a',1,2);
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.substr('a',1,2);
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.SUBSTRING('a',1,2);
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.substring('a',1,2);
|
||||||
|
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.REPLACE('a','b','c');
|
||||||
|
--error ER_FUNC_INEXISTENT_NAME_COLLISION
|
||||||
|
SELECT unknown.replace('a','b','c');
|
||||||
|
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.REPLACE();
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.REPLACE('a');
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.REPLACE('a','b');
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.REPLACE('a','b','c','d');
|
||||||
|
|
||||||
|
#
|
||||||
|
# Testing EXPLAIN EXTENDED SELECT
|
||||||
|
#
|
||||||
|
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
DELIMITER $$;
|
||||||
|
CREATE PROCEDURE p1(sqlmode TEXT, qualifier TEXT, expr TEXT)
|
||||||
|
BEGIN
|
||||||
|
DECLARE query TEXT DEFAULT 'SELECT $(QUALIFIER)$(EXPR)';
|
||||||
|
DECLARE errmsg TEXT DEFAULT NULL;
|
||||||
|
DECLARE CONTINUE HANDLER FOR 1064, 1128, 1305, 1582, 1630
|
||||||
|
BEGIN
|
||||||
|
GET DIAGNOSTICS CONDITION 1 errmsg = MESSAGE_TEXT;
|
||||||
|
END;
|
||||||
|
|
||||||
|
SET sql_mode=sqlmode;
|
||||||
|
SET query=REPLACE(query, '$(QUALIFIER)', qualifier);
|
||||||
|
SET query=REPLACE(query, '$(EXPR)', expr);
|
||||||
|
SET query= CONCAT('EXPLAIN EXTENDED ', query);
|
||||||
|
SELECT CONCAT('sql_mode=''',sqlmode,'''', ' ',
|
||||||
|
'qualifier=''',qualifier,'''') AS `----------`;
|
||||||
|
SELECT query;
|
||||||
|
EXECUTE IMMEDIATE query;
|
||||||
|
IF errmsg IS NOT NULL THEN
|
||||||
|
SELECT CONCAT('ERROR: ', errmsg) AS errmsg;
|
||||||
|
ELSE
|
||||||
|
SHOW WARNINGS;
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
CREATE PROCEDURE p2(sqlmode TEXT, expr TEXT)
|
||||||
|
BEGIN
|
||||||
|
CALL p1(sqlmode, '', expr);
|
||||||
|
CALL p1(sqlmode, 'unknown_schema.', expr);
|
||||||
|
CALL p1(sqlmode, 'mariadb_schema.', expr);
|
||||||
|
CALL p1(sqlmode, 'maxdb_schema.', expr);
|
||||||
|
CALL p1(sqlmode, 'oracle_schema.', expr);
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
CREATE PROCEDURE p3(expr TEXT)
|
||||||
|
BEGIN
|
||||||
|
CALL p2('', expr);
|
||||||
|
CALL p2('ORACLE', expr);
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
DELIMITER ;$$
|
||||||
|
|
||||||
|
CALL p3('CONCAT(''a'')');
|
||||||
|
|
||||||
|
# MariaDB style
|
||||||
|
CALL p3('DECODE(''1'',''2'')');
|
||||||
|
# Oracle style
|
||||||
|
CALL p3('DECODE(1,1,10)');
|
||||||
|
|
||||||
|
CALL p3('LTRIM(''a'')');
|
||||||
|
CALL p3('RTRIM(''a'')');
|
||||||
|
|
||||||
|
CALL p3('LPAD(''a'',3)');
|
||||||
|
CALL p3('LPAD(''a'',3, '' '')');
|
||||||
|
|
||||||
|
CALL p3('RPAD(''a'',3)');
|
||||||
|
CALL p3('RPAD(''a'',3, '' '')');
|
||||||
|
|
||||||
|
CALL p3('REPLACE()');
|
||||||
|
CALL p3('REPLACE(''a'',''b'')');
|
||||||
|
CALL p3('REPLACE(''a'',''b'',''c'',''d'')');
|
||||||
|
CALL p3('REPLACE(''a'',''b'',''c'')');
|
||||||
|
|
||||||
|
CALL p3('SUBSTR()');
|
||||||
|
CALL p3('SUBSTR(''a'',1,2,3)');
|
||||||
|
CALL p3('SUBSTR(''a'',1,2)');
|
||||||
|
CALL p3('SUBSTR(''a'' FROM 1)');
|
||||||
|
|
||||||
|
CALL p3('SUBSTRING(''a'',1,2)');
|
||||||
|
CALL p3('SUBSTRING(''a'' FROM 1)');
|
||||||
|
|
||||||
|
CALL p3('TRIM()');
|
||||||
|
CALL p3('TRIM(1,2)');
|
||||||
|
CALL p3('TRIM(''a'')');
|
||||||
|
CALL p3('TRIM(BOTH '' '' FROM ''a'')');
|
||||||
|
|
||||||
|
|
||||||
|
# Deprecated compatibility XXX_ORACLE functions.
|
||||||
|
# These functions are implemented as simple native functions
|
||||||
|
# and have no special grammar rules in sql_yacc.yy.
|
||||||
|
# So they support the qualified syntax automatically,
|
||||||
|
# which is not absolutely required, but is not harmful.
|
||||||
|
|
||||||
|
CALL p3('CONCAT_OPERATOR_ORACLE(''a'')');
|
||||||
|
CALL p3('DECODE_ORACLE(1,1,10)');
|
||||||
|
CALL p3('LTRIM_ORACLE(''a'')');
|
||||||
|
CALL p3('RTRIM_ORACLE(''a'')');
|
||||||
|
CALL p3('LPAD_ORACLE(''a'',3)');
|
||||||
|
CALL p3('RPAD_ORACLE(''a'',3)');
|
||||||
|
CALL p3('REPLACE_ORACLE(''a'',''b'',''c'')');
|
||||||
|
CALL p3('SUBSTR_ORACLE(''a'',1,2)');
|
||||||
|
|
||||||
|
|
||||||
|
# Deprecated compatibility XXX_ORACLE variants for functions
|
||||||
|
# with a special syntax in sql_yacc.yy.
|
||||||
|
# These compatibility functions do not support qualified syntax.
|
||||||
|
# One should use a qualified variant without the _ORACLE suffix instead.
|
||||||
|
|
||||||
|
--error ER_PARSE_ERROR
|
||||||
|
SELECT oracle_schema.SUBSTR_ORACLE('a' FROM 1 FOR 2);
|
||||||
|
# Use this instead:
|
||||||
|
SELECT oracle_schema.SUBSTR('a' FROM 1 FOR 2);
|
||||||
|
|
||||||
|
--error ER_PARSE_ERROR
|
||||||
|
SELECT oracle_schema.TRIM_ORACLE(LEADING ' ' FROM 'a');
|
||||||
|
# Use this instead:
|
||||||
|
SELECT oracle_schema.TRIM(LEADING ' ' FROM 'a');
|
||||||
|
|
||||||
|
--error ER_FUNCTION_NOT_DEFINED
|
||||||
|
SELECT oracle_schema.TRIM_ORACLE('a');
|
||||||
|
# Use this instead:
|
||||||
|
SELECT oracle_schema.TRIM('a');
|
||||||
|
|
||||||
|
|
||||||
|
DROP PROCEDURE p1;
|
||||||
|
DROP PROCEDURE p2;
|
||||||
|
DROP PROCEDURE p3;
|
||||||
|
|
||||||
|
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE VIEW v1 AS SELECT
|
||||||
|
concat('a','b'),
|
||||||
|
decode('1','2'),
|
||||||
|
ltrim('1'),
|
||||||
|
rtrim('1'),
|
||||||
|
lpad('1','2', 3),
|
||||||
|
rpad('1','2', 3),
|
||||||
|
replace('1','2','3'),
|
||||||
|
substr('a',1,2),
|
||||||
|
trim(both 'a' FROM 'b');
|
||||||
|
CREATE TABLE kv (v BLOB);
|
||||||
|
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||||
|
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v1.frm' REPLACE INTO TABLE kv;
|
||||||
|
SELECT v FROM kv WHERE v RLIKE '^(query|view_body_utf8)=' ORDER BY v;
|
||||||
|
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME='v1' AND TABLE_SCHEMA='test';
|
||||||
|
DROP TABLE kv;
|
||||||
|
DROP VIEW v1;
|
||||||
|
|
||||||
|
SET sql_mode='ORACLE';
|
||||||
|
CREATE VIEW v1 AS SELECT
|
||||||
|
concat('a','b'),
|
||||||
|
decode('1',2,3),
|
||||||
|
ltrim('1'),
|
||||||
|
rtrim('1'),
|
||||||
|
lpad('1','2', 3),
|
||||||
|
rpad('1','2', 3),
|
||||||
|
replace('1','2','3'),
|
||||||
|
substr('a',1,2),
|
||||||
|
trim(both 'a' FROM 'b');
|
||||||
|
CREATE TABLE kv (v BLOB);
|
||||||
|
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||||
|
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v1.frm' REPLACE INTO TABLE kv;
|
||||||
|
SELECT v FROM kv WHERE v RLIKE '^(query|view_body_utf8)=' ORDER BY v;
|
||||||
|
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME='v1' AND TABLE_SCHEMA='test';
|
||||||
|
DROP TABLE kv;
|
||||||
|
DROP VIEW v1;
|
@ -0,0 +1,50 @@
|
|||||||
|
# See comments in mysql-test/main/mysqldump_restore.test
|
||||||
|
--source include/not_embedded.inc
|
||||||
|
|
||||||
|
let $mysqldumpfile = $MYSQLTEST_VARDIR/tmp/mysqldump_func_qualified.sql;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Start of 10.4 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a0 VARCHAR(64) NOT NULL DEFAULT LTRIM(now()),
|
||||||
|
a1 VARCHAR(64) AS (LTRIM(a0)) PERSISTENT,
|
||||||
|
b0 VARCHAR(64) NOT NULL DEFAULT LPAD(now(),10),
|
||||||
|
b1 VARCHAR(64) AS (LPAD(b0,10)) PERSISTENT
|
||||||
|
);
|
||||||
|
CREATE VIEW v1 AS SELECT
|
||||||
|
LTRIM(now()) AS a0,
|
||||||
|
LPAD(now(),10) AS b0;
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
a0 VARCHAR(64) NOT NULL DEFAULT LTRIM(now()),
|
||||||
|
a1 VARCHAR(64) AS (LTRIM(a0)) PERSISTENT,
|
||||||
|
b0 VARCHAR(64) NOT NULL DEFAULT LPAD(now(),10),
|
||||||
|
b1 VARCHAR(64) AS (LPAD(b0,10)) PERSISTENT
|
||||||
|
);
|
||||||
|
CREATE VIEW v2 AS SELECT
|
||||||
|
LTRIM(now()) AS a0,
|
||||||
|
LPAD(now(),10) AS b0;
|
||||||
|
--exec $MYSQL_DUMP --skip-extended-insert test --skip-comments --compact t1 t2 v1 v2
|
||||||
|
--exec $MYSQL_DUMP --skip-extended-insert test --skip-comments t1 t2 v1 v2 > $mysqldumpfile
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
DROP VIEW v1,v2;
|
||||||
|
--exec $MYSQL test < $mysqldumpfile
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SHOW CREATE TABLE t2;
|
||||||
|
SHOW CREATE VIEW v1;
|
||||||
|
SHOW CREATE VIEW v2;
|
||||||
|
--remove_file $mysqldumpfile
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
DROP VIEW v1, v2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 10.4 tests
|
||||||
|
--echo #
|
47
mysql-test/suite/compat/oracle/t/vcol_innodb.test
Normal file
47
mysql-test/suite/compat/oracle/t/vcol_innodb.test
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
FLUSH TABLES;
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE TABLE t (d INT,b VARCHAR(1),c CHAR(1),g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b),KEY g(g)) ENGINE=InnoDB;
|
||||||
|
--error ER_WRONG_VALUE_COUNT_ON_ROW
|
||||||
|
INSERT INTO t VALUES (0);
|
||||||
|
SET sql_mode='ORACLE';
|
||||||
|
INSERT INTO t SET c=REPEAT (1,0);
|
||||||
|
--error ER_BAD_FIELD_ERROR
|
||||||
|
ALTER TABLE t CHANGE COLUMN a b INT;
|
||||||
|
DELETE FROM t;
|
||||||
|
SET sql_mode='';
|
||||||
|
FLUSH TABLES;
|
||||||
|
INSERT INTO t SET c='0';
|
||||||
|
DROP TABLE t;
|
||||||
|
FLUSH TABLES;
|
||||||
|
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE TABLE t (a INT(1),d INT(1),b VARCHAR(1),c CHAR(1),vadc INT(1) GENERATED ALWAYS AS ( (a + length (d))) STORED,vbc CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,vbidxc CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b (1),a,d),KEY d (d),KEY a (a),KEY c_renamed (c (1),b (1)),KEY b (b (1),c (1),a),KEY vbidxc (vbidxc),KEY a_2 (a,vbidxc),KEY vbidxc_2 (vbidxc,d)) DEFAULT CHARSET=latin1 ENGINE=InnoDB;
|
||||||
|
--error ER_WRONG_VALUE_COUNT_ON_ROW
|
||||||
|
INSERT INTO t VALUES (0,0,1,0,1,0,1,0,0);
|
||||||
|
SET SESSION sql_mode='ORACLE';
|
||||||
|
INSERT INTO t SET c=REPEAT (1,0);
|
||||||
|
--error ER_DUP_FIELDNAME
|
||||||
|
ALTER TABLE t CHANGE COLUMN a b CHAR(1);
|
||||||
|
DELETE FROM t;
|
||||||
|
SET SESSION sql_mode=DEFAULT;
|
||||||
|
DROP TABLE t;
|
||||||
|
|
||||||
|
SET sql_mode='';
|
||||||
|
CREATE TABLE t1 (d INT,b VARCHAR(1),c CHAR(1),g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b),KEY g(g)) ENGINE=InnoDB;
|
||||||
|
--error ER_WRONG_VALUE_COUNT_ON_ROW
|
||||||
|
INSERT INTO t1 VALUES (0);
|
||||||
|
SET sql_mode='ORACLE';
|
||||||
|
INSERT INTO t1 SET c=REPEAT (1,0);
|
||||||
|
--error ER_BAD_FIELD_ERROR
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN a b INT;
|
||||||
|
DELETE FROM t1;
|
||||||
|
SET sql_mode='';
|
||||||
|
FLUSH TABLES;
|
||||||
|
INSERT INTO t1 SET c='0';
|
||||||
|
DROP TABLE t1;
|
@ -14,6 +14,5 @@ galera_as_slave_ctas : MDEV-28378 timeout
|
|||||||
galera_pc_recovery : MDEV-25199 cluster fails to start up
|
galera_pc_recovery : MDEV-25199 cluster fails to start up
|
||||||
galera_sst_encrypted : MDEV-29876 Galera test failure on galera_sst_encrypted
|
galera_sst_encrypted : MDEV-29876 Galera test failure on galera_sst_encrypted
|
||||||
galera_var_node_address : MDEV-20485 Galera test failure
|
galera_var_node_address : MDEV-20485 Galera test failure
|
||||||
MDEV-26575 : MDEV-29878 Galera test failure on MDEV-26575
|
galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATING -> COMMITTED
|
||||||
galera_bf_abort_group_commit : MDEV-30855 PR to remove the test exists
|
galera_shutdown_nonprim : MDEV-32635 galera_shutdown_nonprim: mysql_shutdown failed
|
||||||
galera.galera_sequences : MDEV-32024
|
|
||||||
|
@ -10,5 +10,5 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
galera_2_cluster : MDEV-29877 Galera test failure on galera_2_cluster
|
galera_2_cluster : MDEV-32631 galera_2_cluster: before_rollback(): Assertion `0' failed
|
||||||
galera_gtid_2_cluster : MDEV-29877 Galera test failure on galera_2_cluster
|
galera_gtid_2_cluster : MDEV-32633 galera_gtid_2_cluster: Assertion `thd->wsrep_next_trx_id() != (0x7fffffffffffffffLL * 2ULL + 1)'
|
||||||
|
@ -10,4 +10,4 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
galera_sr_kill_slave_after_apply_rollback2 : MDEV-29892 Galera test failure on galera_sr_kill_slave_after_apply_rollback2
|
galera_sr_kill_slave_after_apply_rollback2 : MDEV-29892 Galera test failure on galera_sr_kill_slave_after_apply_rollback2
|
||||||
|
@ -10,5 +10,4 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
galera_sr_cc_master : MDEV-29882 Galera test failure on galera_sr_cc_master
|
GCF-1060 : MDEV-32160 GCF-1060 test failure due to wsrep MDL conflict
|
||||||
|
|
||||||
|
@ -13,3 +13,32 @@ key(f1,f2(1))
|
|||||||
)ENGINE=INNODB;
|
)ENGINE=INNODB;
|
||||||
REPLACE INTO t1(f3) VALUES (1),(1);
|
REPLACE INTO t1(f3) VALUES (1),(1);
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#Create and alter table examples for full column index followed by prefix index.
|
||||||
|
CREATE TABLE t1(
|
||||||
|
f1 VARCHAR(100),
|
||||||
|
f2 char(2),
|
||||||
|
KEY(f1,f2),
|
||||||
|
KEY(f1(5)))ENGINE=INNODB;
|
||||||
|
REPLACE INTO t1(f2) VALUES (1),(1);
|
||||||
|
ALTER TABLE t1 ADD INDEX(f2,f1);
|
||||||
|
DROP TABLE t1;
|
||||||
|
#Create and alter table examples for small prefix index followed by large
|
||||||
|
#prefix index.
|
||||||
|
CREATE TABLE t1(
|
||||||
|
f1 VARCHAR(100),
|
||||||
|
f2 char(2),
|
||||||
|
KEY(f1(5),f2),
|
||||||
|
KEY(f1(10)))ENGINE=INNODB;
|
||||||
|
REPLACE INTO t1(f2) VALUES (1),(1);
|
||||||
|
ALTER TABLE t1 ADD INDEX(f2,f1);
|
||||||
|
DROP TABLE t1;
|
||||||
|
#Create and alter table examples for prefix index followed by full column
|
||||||
|
#index.
|
||||||
|
CREATE TABLE t1(
|
||||||
|
f1 VARCHAR(100),
|
||||||
|
f2 char(2),
|
||||||
|
KEY(f1(5),f2),
|
||||||
|
KEY(f1))ENGINE=INNODB;
|
||||||
|
REPLACE INTO t1(f2) VALUES (1),(1);
|
||||||
|
ALTER TABLE t1 ADD INDEX(f2,f1);
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -20,3 +20,46 @@ REPLACE INTO t1(f3) VALUES (1),(1);
|
|||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #Create and alter table examples for full column index followed by prefix index.
|
||||||
|
|
||||||
|
CREATE TABLE t1(
|
||||||
|
f1 VARCHAR(100),
|
||||||
|
f2 char(2),
|
||||||
|
KEY(f1,f2),
|
||||||
|
KEY(f1(5)))ENGINE=INNODB;
|
||||||
|
|
||||||
|
REPLACE INTO t1(f2) VALUES (1),(1);
|
||||||
|
|
||||||
|
ALTER TABLE t1 ADD INDEX(f2,f1);
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #Create and alter table examples for small prefix index followed by large
|
||||||
|
--echo #prefix index.
|
||||||
|
|
||||||
|
CREATE TABLE t1(
|
||||||
|
f1 VARCHAR(100),
|
||||||
|
f2 char(2),
|
||||||
|
KEY(f1(5),f2),
|
||||||
|
KEY(f1(10)))ENGINE=INNODB;
|
||||||
|
|
||||||
|
REPLACE INTO t1(f2) VALUES (1),(1);
|
||||||
|
|
||||||
|
ALTER TABLE t1 ADD INDEX(f2,f1);
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #Create and alter table examples for prefix index followed by full column
|
||||||
|
--echo #index.
|
||||||
|
|
||||||
|
CREATE TABLE t1(
|
||||||
|
f1 VARCHAR(100),
|
||||||
|
f2 char(2),
|
||||||
|
KEY(f1(5),f2),
|
||||||
|
KEY(f1))ENGINE=INNODB;
|
||||||
|
|
||||||
|
REPLACE INTO t1(f2) VALUES (1),(1);
|
||||||
|
|
||||||
|
ALTER TABLE t1 ADD INDEX(f2,f1);
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -31,3 +31,26 @@ sub mycrc32 {
|
|||||||
|
|
||||||
return $crc;
|
return $crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Fix the checksum of an InnoDB tablespace page.
|
||||||
|
# Inputs:
|
||||||
|
# $page A bytestring with the page data.
|
||||||
|
# $full_crc32 Checksum type, see get_full_crc32() in innodb-util.pl
|
||||||
|
# Returns: the modified page as a bytestring.
|
||||||
|
sub fix_page_crc {
|
||||||
|
my ($page, $full_crc32)= @_;
|
||||||
|
my $ps= length($page);
|
||||||
|
my $polynomial = 0x82f63b78; # CRC-32C
|
||||||
|
if ($full_crc32) {
|
||||||
|
my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial);
|
||||||
|
substr($page, $ps - 4, 4) = pack("N", $ck);
|
||||||
|
} else {
|
||||||
|
my $ck= pack("N",
|
||||||
|
mycrc32(substr($page, 4, 22), 0, $polynomial) ^
|
||||||
|
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
|
||||||
|
substr($page, 0, 4)= $ck;
|
||||||
|
substr($page, $ps-8, 4)= $ck;
|
||||||
|
}
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
@ -124,3 +124,22 @@ sub ib_restore_ibd_files {
|
|||||||
ib_restore_ibd_file($tmpd, $datadir, $db, $table);
|
ib_restore_ibd_file($tmpd, $datadir, $db, $table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Read the flag whether a tablespace is using full_crc32.
|
||||||
|
# Input: filehandle opened on the tablespace.
|
||||||
|
sub get_full_crc32 {
|
||||||
|
my ($TBLSPC)= @_;
|
||||||
|
my $old_pos= sysseek($TBLSPC, 0, 1);
|
||||||
|
die "tell() failed on tablespace filehandle: $!\n"
|
||||||
|
unless defined($old_pos);
|
||||||
|
sysseek($TBLSPC, 0, 0)
|
||||||
|
or die "sysseek() failed on tablespace filehandle: $!\n";
|
||||||
|
my $tblspc_hdr;
|
||||||
|
sysread($TBLSPC, $tblspc_hdr, 58)
|
||||||
|
or die "Cannot read tablespace header: $!\n";
|
||||||
|
sysseek($TBLSPC, $old_pos, 0)
|
||||||
|
or die "sysseek() failed on tablespace filehandle: $!\n";
|
||||||
|
my $full_crc32=
|
||||||
|
unpack("N", substr($tblspc_hdr, 54, 4)) & 0x10; # FIL_SPACE_FLAGS
|
||||||
|
return $full_crc32;
|
||||||
|
}
|
||||||
|
31
mysql-test/suite/innodb/r/add_foreign_key.result
Normal file
31
mysql-test/suite/innodb/r/add_foreign_key.result
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#
|
||||||
|
# Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE ADD
|
||||||
|
# FOREIGN KEY
|
||||||
|
#
|
||||||
|
CREATE TABLE `parent` (`parent_id` INT, PRIMARY KEY (`parent_id`));
|
||||||
|
CREATE TABLE `child1` (`id` INT ,`child1_fk1` INT, `child1_fk2` INT,
|
||||||
|
PRIMARY KEY (`id`));
|
||||||
|
CREATE TABLE `child2` (`id` INT, `child2_fk1` INT, `child2_fk2` INT,
|
||||||
|
PRIMARY KEY (`id`));
|
||||||
|
CREATE TABLE `child3` (`id` INT , `child3_fk1` INT, PRIMARY KEY (`id`));
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
drop table child3, child2, child1, parent;
|
76
mysql-test/suite/innodb/r/cascade_lock_wait.result
Normal file
76
mysql-test/suite/innodb/r/cascade_lock_wait.result
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
create table t1 (f1 int primary key) engine=innodb;
|
||||||
|
create table t2 (f1 int primary key,
|
||||||
|
constraint c1 foreign key (f1) references t1(f1)
|
||||||
|
on update cascade
|
||||||
|
on delete cascade) engine=innodb;
|
||||||
|
create table t3 (f1 int primary key,
|
||||||
|
constraint c2 foreign key (f1) references t1(f1)
|
||||||
|
on update cascade
|
||||||
|
on delete cascade) engine=innodb;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`f1` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`f1`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
show create table t2;
|
||||||
|
Table Create Table
|
||||||
|
t2 CREATE TABLE `t2` (
|
||||||
|
`f1` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`f1`),
|
||||||
|
CONSTRAINT `c1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
show create table t3;
|
||||||
|
Table Create Table
|
||||||
|
t3 CREATE TABLE `t3` (
|
||||||
|
`f1` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`f1`),
|
||||||
|
CONSTRAINT `c2` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
insert into t1 values (1);
|
||||||
|
insert into t1 values (2);
|
||||||
|
insert into t1 values (3);
|
||||||
|
insert into t2 values (1);
|
||||||
|
insert into t2 values (2);
|
||||||
|
insert into t2 values (3);
|
||||||
|
insert into t3 values (1);
|
||||||
|
insert into t3 values (2);
|
||||||
|
insert into t3 values (3);
|
||||||
|
select f1 from t1;
|
||||||
|
f1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
select f1 from t2;
|
||||||
|
f1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
select f1 from t3;
|
||||||
|
f1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
set @save_dbug = @@debug_dbug;
|
||||||
|
set debug_dbug = '+d,dml_cascade_only_once';
|
||||||
|
set debug_dbug = '+d,row_upd_cascade_lock_wait_err';
|
||||||
|
update t1 set f1 = 100 where f1 = 2;
|
||||||
|
select f1 from t1;
|
||||||
|
f1
|
||||||
|
1
|
||||||
|
3
|
||||||
|
100
|
||||||
|
select f1 from t2;
|
||||||
|
f1
|
||||||
|
1
|
||||||
|
3
|
||||||
|
100
|
||||||
|
select f1 from t3;
|
||||||
|
f1
|
||||||
|
1
|
||||||
|
3
|
||||||
|
100
|
||||||
|
set debug_dbug = @save_dbug;
|
||||||
|
drop table t2;
|
||||||
|
drop table t3;
|
||||||
|
drop table t1;
|
@ -118,4 +118,17 @@ ALTER TABLE t2 DROP INDEX idx;
|
|||||||
ALTER TABLE t2 MODIFY f2 VARCHAR(1023);
|
ALTER TABLE t2 MODIFY f2 VARCHAR(1023);
|
||||||
SET SESSION FOREIGN_KEY_CHECKS = ON;
|
SET SESSION FOREIGN_KEY_CHECKS = ON;
|
||||||
DROP TABLE t2, t1;
|
DROP TABLE t2, t1;
|
||||||
|
#
|
||||||
|
# MDEV-32638 MariaDB crashes with foreign_key_checks=0
|
||||||
|
# when changing a column and adding a foreign
|
||||||
|
# key at the same time
|
||||||
|
#
|
||||||
|
CREATE TABLE t1(f1 VARCHAR(2) NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB;
|
||||||
|
CREATE TABLE t2(f1 INT NOT NULL PRIMARY KEY,
|
||||||
|
f2 VARCHAR(10) NOT NULL DEFAULT '')ENGINE=InnoDB;
|
||||||
|
SET SESSION FOREIGN_KEY_CHECKS = OFF;
|
||||||
|
ALTER TABLE t2 CHANGE COLUMN f2 f3 VARCHAR(20) NOT NULL,
|
||||||
|
ADD CONSTRAINT t2_fk FOREIGN KEY(f3) REFERENCES t1(f1);
|
||||||
|
DROP TABLE t2, t1;
|
||||||
|
SET SESSION FOREIGN_KEY_CHECKS = ON;
|
||||||
# End of 10.4 tests
|
# End of 10.4 tests
|
||||||
|
72
mysql-test/suite/innodb/r/import_update_stats.result
Normal file
72
mysql-test/suite/innodb/r/import_update_stats.result
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
SET @old_innodb_file_per_table = @@innodb_file_per_table;
|
||||||
|
SET GLOBAL innodb_file_per_table = 1;
|
||||||
|
SELECT @@innodb_file_per_table;
|
||||||
|
@@innodb_file_per_table
|
||||||
|
1
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
col_1 CHAR (255),
|
||||||
|
col_2 VARCHAR (255)
|
||||||
|
) ENGINE = InnoDB;
|
||||||
|
CREATE INDEX idx1 ON t1(col_1);
|
||||||
|
CREATE INDEX idx2 ON t1(col_2);
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE
|
||||||
|
INSERT INTO t1 VALUES ("col1_00001", "col2_00001"), ("col1_00002", "col2_00002");
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
|
||||||
|
ANALYZE TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status Engine-independent statistics collected
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
|
||||||
|
FLUSH TABLES t1 FOR EXPORT;
|
||||||
|
backup: t1
|
||||||
|
UNLOCK TABLES;
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
col_1 CHAR (255),
|
||||||
|
col_2 VARCHAR (255)
|
||||||
|
) ENGINE = InnoDB STATS_PERSISTENT=1;
|
||||||
|
CREATE INDEX idx1 ON t1(col_1);
|
||||||
|
CREATE INDEX idx2 ON t1(col_2);
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE
|
||||||
|
INSERT INTO t1 VALUES ("col1_00001", "col2_00001");
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE
|
||||||
|
ALTER TABLE t1 DISCARD TABLESPACE;
|
||||||
|
restore: t1 .ibd and .cfg files
|
||||||
|
ALTER TABLE t1 IMPORT TABLESPACE;
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SHOW INDEXES FROM t1;
|
||||||
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||||
|
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
|
||||||
|
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
|
23
mysql-test/suite/innodb/r/index_length.result
Normal file
23
mysql-test/suite/innodb/r/index_length.result
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
connect stop_purge,localhost,root;
|
||||||
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||||
|
connection default;
|
||||||
|
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(1024))
|
||||||
|
ENGINE=InnoDB STATS_PERSISTENT=1;
|
||||||
|
INSERT INTO t1 VALUES (1,REPEAT('b',1024));
|
||||||
|
SELECT index_length FROM information_schema.tables
|
||||||
|
WHERE table_schema = 'test' AND table_name = 't1';
|
||||||
|
index_length
|
||||||
|
0
|
||||||
|
ALTER TABLE t1 ADD INDEX b (b(800));
|
||||||
|
SELECT FLOOR(index_length/@@innodb_page_size) FROM information_schema.tables
|
||||||
|
WHERE table_schema = 'test' AND table_name = 't1';
|
||||||
|
FLOOR(index_length/@@innodb_page_size)
|
||||||
|
1
|
||||||
|
ALTER TABLE t1 ADD INDEX ba (b(800),a);
|
||||||
|
SELECT FLOOR(index_length/@@innodb_page_size) FROM information_schema.tables
|
||||||
|
WHERE table_schema = 'test' AND table_name = 't1';
|
||||||
|
FLOOR(index_length/@@innodb_page_size)
|
||||||
|
2
|
||||||
|
disconnect stop_purge;
|
||||||
|
DROP TABLE t1;
|
||||||
|
# End of 10.4 tests
|
@ -1,4 +1,24 @@
|
|||||||
call mtr.add_suppression("Innodb: Cannot add field.*row size is");
|
call mtr.add_suppression("Innodb: Cannot add field.*row size is");
|
||||||
|
SET SESSION innodb_strict_mode=ON;
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
|
||||||
|
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
|
||||||
|
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
|
||||||
|
SET SESSION innodb_strict_mode=OFF;
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
|
||||||
|
Warnings:
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
SHOW WARNINGS;
|
||||||
|
Level Code Message
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
|
||||||
|
Warnings:
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
SHOW WARNINGS;
|
||||||
|
Level Code Message
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
DROP TABLE t1;
|
||||||
# Test 1) Show the page size from Information Schema
|
# Test 1) Show the page size from Information Schema
|
||||||
SELECT variable_value FROM information_schema.global_status
|
SELECT variable_value FROM information_schema.global_status
|
||||||
WHERE LOWER(variable_name) = 'innodb_page_size';
|
WHERE LOWER(variable_name) = 'innodb_page_size';
|
||||||
|
@ -1,4 +1,24 @@
|
|||||||
call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is');
|
call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is');
|
||||||
|
SET SESSION innodb_strict_mode=ON;
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
|
||||||
|
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
|
||||||
|
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
|
||||||
|
SET SESSION innodb_strict_mode=OFF;
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
|
||||||
|
Warnings:
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
SHOW WARNINGS;
|
||||||
|
Level Code Message
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
|
||||||
|
Warnings:
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
SHOW WARNINGS;
|
||||||
|
Level Code Message
|
||||||
|
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
|
||||||
|
DROP TABLE t1;
|
||||||
# Test 1) Show the page size from Information Schema
|
# Test 1) Show the page size from Information Schema
|
||||||
SELECT variable_value FROM information_schema.global_status
|
SELECT variable_value FROM information_schema.global_status
|
||||||
WHERE LOWER(variable_name) = 'innodb_page_size';
|
WHERE LOWER(variable_name) = 'innodb_page_size';
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
CREATE TABLE t1 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
|
||||||
|
INSERT INTO t1 VALUES(0, "0");
|
||||||
|
INSERT INTO t1 VALUES(1, "1");
|
||||||
|
INSERT INTO t1 VALUES(2, "2");
|
||||||
|
INSERT INTO t1 VALUES(3, "3");
|
||||||
|
connect con1,localhost,root,,;
|
||||||
|
connect con2,localhost,root,,;
|
||||||
|
connect con3,localhost,root,,;
|
||||||
|
connect con4,localhost,root,,;
|
||||||
|
connect con5,localhost,root,,;
|
||||||
|
connect con6,localhost,root,,;
|
||||||
|
connection default;
|
||||||
|
SET AUTOCOMMIT=0;
|
||||||
|
BEGIN;
|
||||||
|
SELECT * FROM t1 FOR UPDATE;
|
||||||
|
c1 c2
|
||||||
|
0 0
|
||||||
|
1 1
|
||||||
|
2 2
|
||||||
|
3 3
|
||||||
|
SELECT * FROM t1 WHERE c1 <= 3;
|
||||||
|
c1 c2
|
||||||
|
0 0
|
||||||
|
1 1
|
||||||
|
2 2
|
||||||
|
3 3
|
||||||
|
connection default;
|
||||||
|
SET DEBUG_SYNC='now WAIT_FOR waiting4';
|
||||||
|
SET DEBUG_SYNC= 'RESET';
|
||||||
|
SELECT trx_state, trx_query, trx_autocommit_non_locking
|
||||||
|
FROM INFORMATION_SCHEMA.INNODB_TRX
|
||||||
|
WHERE trx_state = 'LOCK WAIT'
|
||||||
|
ORDER BY trx_query;
|
||||||
|
trx_state trx_query trx_autocommit_non_locking
|
||||||
|
LOCK WAIT SELECT COUNT(*) FROM t1 LOCK IN SHARE MODE 0
|
||||||
|
LOCK WAIT SELECT COUNT(*) FROM t1 WHERE c1 >= 0 0
|
||||||
|
INSERT INTO t1 VALUES(4, '4');
|
||||||
|
COMMIT;
|
||||||
|
connection con6;
|
||||||
|
SELECT * FROM t1 WHERE c1 <= 4;
|
||||||
|
c1 c2
|
||||||
|
0 0
|
||||||
|
1 1
|
||||||
|
2 2
|
||||||
|
3 3
|
||||||
|
XA END '1';
|
||||||
|
XA PREPARE '1';
|
||||||
|
XA ROLLBACK '1';
|
||||||
|
disconnect con6;
|
||||||
|
disconnect con2;
|
||||||
|
disconnect con3;
|
||||||
|
disconnect con5;
|
||||||
|
connection con1;
|
||||||
|
COUNT(*)
|
||||||
|
5
|
||||||
|
disconnect con1;
|
||||||
|
connection con4;
|
||||||
|
COUNT(*)
|
||||||
|
5
|
||||||
|
disconnect con4;
|
||||||
|
connection default;
|
||||||
|
DROP TABLE t1;
|
@ -1090,3 +1090,59 @@ ALTER TABLE t1 ADD COLUMN b DATETIME NOT NULL, LOCK=NONE;
|
|||||||
# Cleanup
|
# Cleanup
|
||||||
SET @@SQL_MODE= @OLD_SQL_MODE;
|
SET @@SQL_MODE= @OLD_SQL_MODE;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# Bug#20977779 CANNOT IMPORT TABLES CONTAINING PREFIX INDEXES
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32),
|
||||||
|
PRIMARY KEY (c1, c2, c3))
|
||||||
|
ENGINE=InnoDB;
|
||||||
|
ALTER TABLE t1 ADD INDEX ind1(c1(5), c2, c3);
|
||||||
|
ALTER TABLE t1 ADD INDEX ind2(c3, c1(10), c2);
|
||||||
|
ALTER TABLE t1 ADD INDEX ind3(c2, c3, c1(20));
|
||||||
|
INSERT INTO t1 VALUES ('Test Data -1', 'Test Data -2', 'Test Data -3');
|
||||||
|
# Test with 2ndary index having prefix
|
||||||
|
FLUSH TABLES test.t1 FOR EXPORT;
|
||||||
|
UNLOCK TABLES;
|
||||||
|
ALTER TABLE test.t1 DISCARD TABLESPACE;
|
||||||
|
ALTER TABLE test.t1 IMPORT TABLESPACE;
|
||||||
|
CHECK TABLE test.t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 check status OK
|
||||||
|
SHOW CREATE TABLE test.t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`c1` varchar(32) NOT NULL,
|
||||||
|
`c2` varchar(32) NOT NULL,
|
||||||
|
`c3` varchar(32) NOT NULL,
|
||||||
|
PRIMARY KEY (`c1`,`c2`,`c3`),
|
||||||
|
KEY `ind1` (`c1`(5),`c2`,`c3`),
|
||||||
|
KEY `ind2` (`c3`,`c1`(10),`c2`),
|
||||||
|
KEY `ind3` (`c2`,`c3`,`c1`(20))
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT * FROM test.t1;
|
||||||
|
c1 c2 c3
|
||||||
|
Test Data -1 Test Data -2 Test Data -3
|
||||||
|
# Test with PK & 2ndary index with prefix
|
||||||
|
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1(5), c2(10), c3(20));
|
||||||
|
FLUSH TABLES test.t1 FOR EXPORT;
|
||||||
|
UNLOCK TABLES;
|
||||||
|
ALTER TABLE test.t1 DISCARD TABLESPACE;
|
||||||
|
ALTER TABLE test.t1 IMPORT TABLESPACE;
|
||||||
|
CHECK TABLE test.t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 check status OK
|
||||||
|
SHOW CREATE TABLE test.t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`c1` varchar(32) NOT NULL,
|
||||||
|
`c2` varchar(32) NOT NULL,
|
||||||
|
`c3` varchar(32) NOT NULL,
|
||||||
|
PRIMARY KEY (`c1`(5),`c2`(10),`c3`(20)),
|
||||||
|
KEY `ind1` (`c1`(5),`c2`,`c3`),
|
||||||
|
KEY `ind2` (`c3`,`c1`(10),`c2`),
|
||||||
|
KEY `ind3` (`c2`,`c3`,`c1`(20))
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT * FROM test.t1;
|
||||||
|
c1 c2 c3
|
||||||
|
Test Data -1 Test Data -2 Test Data -3
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -618,3 +618,39 @@ test/e d a 0
|
|||||||
test/fw c a 0
|
test/fw c a 0
|
||||||
DROP TABLE t2;
|
DROP TABLE t2;
|
||||||
DROP TABLE t3;
|
DROP TABLE t3;
|
||||||
|
# Bug #17449901 TABLE DISAPPEARS WHEN ALTERING
|
||||||
|
# WITH FOREIGN KEY CHECKS OFF
|
||||||
|
create table t1(f1 int,primary key(f1))engine=innodb;
|
||||||
|
create table t2(f2 int,f3 int,key t(f2,f3),foreign key(f2) references t1(f1))engine=innodb;
|
||||||
|
SET foreign_key_checks=0;
|
||||||
|
drop index t on t2;
|
||||||
|
drop table t2;
|
||||||
|
drop table t1;
|
||||||
|
create table t1(f1 int ,primary key(f1))engine=innodb;
|
||||||
|
create table t2(f2 int,f3 int, key t(f2),foreign key(f2) references t1(f1))engine=innodb;
|
||||||
|
SET foreign_key_checks = 0;
|
||||||
|
alter table t2 drop key t,algorithm=inplace;
|
||||||
|
show create table t2;
|
||||||
|
Table Create Table
|
||||||
|
t2 CREATE TABLE `t2` (
|
||||||
|
`f2` int(11) DEFAULT NULL,
|
||||||
|
`f3` int(11) DEFAULT NULL,
|
||||||
|
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
drop table t2;
|
||||||
|
drop table t1;
|
||||||
|
create table t1(f1 int ,primary key(f1))engine=innodb;
|
||||||
|
create table t2(f2 int,f3 int, key t(f2),key t1(f2,f3),
|
||||||
|
foreign key(f2) references t1(f1))engine=innodb;
|
||||||
|
SET foreign_key_checks = 0;
|
||||||
|
alter table t2 drop key t,algorithm=inplace;
|
||||||
|
show create table t2;
|
||||||
|
Table Create Table
|
||||||
|
t2 CREATE TABLE `t2` (
|
||||||
|
`f2` int(11) DEFAULT NULL,
|
||||||
|
`f3` int(11) DEFAULT NULL,
|
||||||
|
KEY `t1` (`f2`,`f3`),
|
||||||
|
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
drop table t2;
|
||||||
|
drop table t1;
|
||||||
|
@ -0,0 +1,124 @@
|
|||||||
|
#
|
||||||
|
# Bug #21025880 DUPLICATE UK VALUES IN READ-COMMITTED(AGAIN)
|
||||||
|
#
|
||||||
|
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||||
|
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a INT NOT NULL,
|
||||||
|
b INT NOT NULL,
|
||||||
|
PRIMARY KEY(b),
|
||||||
|
UNIQUE KEY(a))
|
||||||
|
ENGINE=INNODB;
|
||||||
|
SET @old_innodb_stats_auto_recalc = @@innodb_stats_auto_recalc;
|
||||||
|
SET GLOBAL innodb_stats_auto_recalc = OFF;
|
||||||
|
connect purge_control,localhost,root;
|
||||||
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||||
|
connection default;
|
||||||
|
SET @old_tx_isolation = @@tx_isolation;
|
||||||
|
SET GLOBAL tx_isolation = 'READ-COMMITTED';
|
||||||
|
SET @old_innodb_lock_wait_timeout = @@innodb_lock_wait_timeout;
|
||||||
|
SET GLOBAL innodb_lock_wait_timeout = 1;
|
||||||
|
connect con1,localhost,root,,;
|
||||||
|
INSERT INTO t1 VALUES (1,1),(2,2);
|
||||||
|
DELETE FROM t1;
|
||||||
|
SET debug_sync = 'row_ins_sec_index_entry_dup_locks_created SIGNAL
|
||||||
|
con1_locks_done WAIT_FOR con1_go';
|
||||||
|
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock SIGNAL
|
||||||
|
con1_insert_done WAIT_FOR con1_finish';
|
||||||
|
REPLACE INTO t1 VALUES (1,2);
|
||||||
|
connect con2,localhost,root,,;
|
||||||
|
SET debug_sync = 'now WAIT_FOR con1_locks_done';
|
||||||
|
SET debug_sync = 'lock_wait_suspend_thread_enter SIGNAL con2_blocked
|
||||||
|
WAIT_FOR con2_go';
|
||||||
|
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock
|
||||||
|
WAIT_FOR con2_finish';
|
||||||
|
SET debug_sync = 'ib_after_row_insert SIGNAL con2_insert_done';
|
||||||
|
REPLACE INTO t1 VALUES (1,3);
|
||||||
|
connection default;
|
||||||
|
SET debug_sync = 'now WAIT_FOR con2_blocked';
|
||||||
|
connection purge_control;
|
||||||
|
COMMIT;
|
||||||
|
disconnect purge_control;
|
||||||
|
connection default;
|
||||||
|
InnoDB 0 transactions not purged
|
||||||
|
SET debug_sync = 'now SIGNAL con2_go WAIT_FOR con2_insert_done';
|
||||||
|
SET debug_sync = 'now SIGNAL con1_go WAIT_FOR con1_insert_done';
|
||||||
|
SET debug_sync = 'now SIGNAL con1_finish';
|
||||||
|
connection con1;
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
SET debug_sync = 'now SIGNAL con2_finish';
|
||||||
|
connection con2;
|
||||||
|
disconnect con2;
|
||||||
|
connection default;
|
||||||
|
SET DEBUG_SYNC= 'RESET';
|
||||||
|
SELECT * FROM t1;
|
||||||
|
a b
|
||||||
|
1 2
|
||||||
|
CHECK TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 check status OK
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET GLOBAL innodb_stats_auto_recalc = @old_innodb_stats_auto_recalc;
|
||||||
|
SET GLOBAL tx_isolation = @old_tx_isolation;
|
||||||
|
SET GLOBAL innodb_lock_wait_timeout = @old_innodb_lock_wait_timeout;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a INT NOT NULL,
|
||||||
|
b INT NOT NULL,
|
||||||
|
PRIMARY KEY(b),
|
||||||
|
UNIQUE KEY(a))
|
||||||
|
ENGINE=INNODB;
|
||||||
|
SET @old_innodb_stats_auto_recalc = @@innodb_stats_auto_recalc;
|
||||||
|
SET GLOBAL innodb_stats_auto_recalc = OFF;
|
||||||
|
connect purge_control,localhost,root;
|
||||||
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||||
|
connection default;
|
||||||
|
SET @old_tx_isolation = @@tx_isolation;
|
||||||
|
SET GLOBAL tx_isolation = 'READ-COMMITTED';
|
||||||
|
SET @old_innodb_lock_wait_timeout = @@innodb_lock_wait_timeout;
|
||||||
|
SET GLOBAL innodb_lock_wait_timeout = 1;
|
||||||
|
connect con1,localhost,root,,;
|
||||||
|
INSERT INTO t1 VALUES (1,1),(2,2);
|
||||||
|
DELETE FROM t1;
|
||||||
|
SET debug_sync = 'row_ins_sec_index_entry_dup_locks_created SIGNAL
|
||||||
|
con1_locks_done WAIT_FOR con1_go';
|
||||||
|
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock SIGNAL
|
||||||
|
con1_insert_done WAIT_FOR con1_finish';
|
||||||
|
INSERT INTO t1 values (1,2) ON DUPLICATE KEY UPDATE a=2;
|
||||||
|
connect con2,localhost,root,,;
|
||||||
|
SET debug_sync = 'now WAIT_FOR con1_locks_done';
|
||||||
|
SET debug_sync = 'lock_wait_suspend_thread_enter SIGNAL con2_blocked
|
||||||
|
WAIT_FOR con2_go';
|
||||||
|
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock
|
||||||
|
WAIT_FOR con2_finish';
|
||||||
|
SET debug_sync = 'ib_after_row_insert SIGNAL con2_insert_done';
|
||||||
|
REPLACE INTO t1 VALUES (1,3);
|
||||||
|
connection default;
|
||||||
|
SET debug_sync = 'now WAIT_FOR con2_blocked';
|
||||||
|
connection purge_control;
|
||||||
|
COMMIT;
|
||||||
|
disconnect purge_control;
|
||||||
|
connection default;
|
||||||
|
InnoDB 0 transactions not purged
|
||||||
|
SET debug_sync = 'now SIGNAL con2_go WAIT_FOR con2_insert_done';
|
||||||
|
SET debug_sync = 'now SIGNAL con1_go WAIT_FOR con1_insert_done';
|
||||||
|
SET debug_sync = 'now SIGNAL con1_finish';
|
||||||
|
connection con1;
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
SET debug_sync = 'now SIGNAL con2_finish';
|
||||||
|
connection con2;
|
||||||
|
disconnect con2;
|
||||||
|
connection default;
|
||||||
|
SET DEBUG_SYNC= 'RESET';
|
||||||
|
SELECT * FROM t1;
|
||||||
|
a b
|
||||||
|
1 2
|
||||||
|
CHECK TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 check status OK
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET GLOBAL innodb_stats_auto_recalc = @old_innodb_stats_auto_recalc;
|
||||||
|
SET GLOBAL tx_isolation = @old_tx_isolation;
|
||||||
|
SET GLOBAL innodb_lock_wait_timeout = @old_innodb_lock_wait_timeout;
|
||||||
|
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
|
@ -9,9 +9,6 @@ INSERT INTO t2 VALUES(1, "b");
|
|||||||
INSERT INTO t2 VALUES(2, "c");
|
INSERT INTO t2 VALUES(2, "c");
|
||||||
INSERT INTO t2 VALUES(3, "d");
|
INSERT INTO t2 VALUES(3, "d");
|
||||||
connect con1,localhost,root,,;
|
connect con1,localhost,root,,;
|
||||||
connect con2,localhost,root,,;
|
|
||||||
connection con1;
|
|
||||||
'T1'
|
|
||||||
SET AUTOCOMMIT=0;
|
SET AUTOCOMMIT=0;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT * FROM t2;
|
SELECT * FROM t2;
|
||||||
@ -21,7 +18,6 @@ c1 c2
|
|||||||
2 c
|
2 c
|
||||||
3 d
|
3 d
|
||||||
connection default;
|
connection default;
|
||||||
'T2'
|
|
||||||
SET AUTOCOMMIT=0;
|
SET AUTOCOMMIT=0;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@ -30,8 +26,7 @@ c1 c2
|
|||||||
1 1
|
1 1
|
||||||
2 2
|
2 2
|
||||||
3 3
|
3 3
|
||||||
connection con2;
|
connect con2,localhost,root,,;
|
||||||
'T3'
|
|
||||||
SET AUTOCOMMIT=0;
|
SET AUTOCOMMIT=0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
@ -48,7 +43,6 @@ c1 c2
|
|||||||
2 c
|
2 c
|
||||||
3 d
|
3 d
|
||||||
connection con1;
|
connection con1;
|
||||||
'T1'
|
|
||||||
UPDATE t2 SET c1 = c1 + 100;
|
UPDATE t2 SET c1 = c1 + 100;
|
||||||
SELECT * FROM t2;
|
SELECT * FROM t2;
|
||||||
c1 c2
|
c1 c2
|
||||||
@ -58,7 +52,6 @@ c1 c2
|
|||||||
103 d
|
103 d
|
||||||
COMMIT;
|
COMMIT;
|
||||||
connection default;
|
connection default;
|
||||||
'T2'
|
|
||||||
UPDATE t1 SET c1 = c1 + 100;
|
UPDATE t1 SET c1 = c1 + 100;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
c1 c2
|
c1 c2
|
||||||
@ -68,42 +61,29 @@ c1 c2
|
|||||||
103 3
|
103 3
|
||||||
COMMIT;
|
COMMIT;
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
||||||
SELECT * FROM t1;;
|
SELECT * FROM t1;;
|
||||||
connection default;
|
connection default;
|
||||||
'T2'
|
|
||||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||||
'Signalled T3'
|
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
c1 c2
|
c1 c2
|
||||||
0 0
|
0 0
|
||||||
1 1
|
1 1
|
||||||
2 2
|
2 2
|
||||||
3 3
|
3 3
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
||||||
SELECT * FROM t2;;
|
SELECT * FROM t2;;
|
||||||
connection default;
|
connection default;
|
||||||
'T2'
|
|
||||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||||
'Signalled T3'
|
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
c1 c2
|
c1 c2
|
||||||
0 a
|
0 a
|
||||||
1 b
|
1 b
|
||||||
2 c
|
2 c
|
||||||
3 d
|
3 d
|
||||||
connection default;
|
connection default;
|
||||||
disconnect con1;
|
|
||||||
disconnect con2;
|
|
||||||
connect con1,localhost,root,,;
|
|
||||||
connect con2,localhost,root,,;
|
|
||||||
connection con1;
|
connection con1;
|
||||||
'T1'
|
|
||||||
SET AUTOCOMMIT=0;
|
SET AUTOCOMMIT=0;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@ -113,7 +93,6 @@ c1 c2
|
|||||||
102 2
|
102 2
|
||||||
103 3
|
103 3
|
||||||
connection default;
|
connection default;
|
||||||
'T2'
|
|
||||||
SET AUTOCOMMIT=0;
|
SET AUTOCOMMIT=0;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT * FROM t2;
|
SELECT * FROM t2;
|
||||||
@ -131,7 +110,6 @@ c1 c2
|
|||||||
203 d
|
203 d
|
||||||
COMMIT;
|
COMMIT;
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
SET AUTOCOMMIT=0;
|
SET AUTOCOMMIT=0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
@ -148,7 +126,6 @@ c1 c2
|
|||||||
202 c
|
202 c
|
||||||
203 d
|
203 d
|
||||||
connection con1;
|
connection con1;
|
||||||
'T1'
|
|
||||||
UPDATE t1 SET c1 = c1 + 100;
|
UPDATE t1 SET c1 = c1 + 100;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
c1 c2
|
c1 c2
|
||||||
@ -158,44 +135,34 @@ c1 c2
|
|||||||
203 3
|
203 3
|
||||||
COMMIT;
|
COMMIT;
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
||||||
SELECT * FROM t1;;
|
SELECT * FROM t1;;
|
||||||
connection con1;
|
connection con1;
|
||||||
'T2'
|
|
||||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||||
'Signalled T3'
|
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
c1 c2
|
c1 c2
|
||||||
100 0
|
100 0
|
||||||
101 1
|
101 1
|
||||||
102 2
|
102 2
|
||||||
103 3
|
103 3
|
||||||
connection con2;
|
|
||||||
'T3'
|
|
||||||
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
||||||
SELECT * FROM t2;;
|
SELECT * FROM t2;;
|
||||||
connection default;
|
connection default;
|
||||||
'T2'
|
|
||||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||||
'Signalled T3'
|
|
||||||
connection con2;
|
connection con2;
|
||||||
'T3'
|
|
||||||
c1 c2
|
c1 c2
|
||||||
200 a
|
200 a
|
||||||
201 b
|
201 b
|
||||||
202 c
|
202 c
|
||||||
203 d
|
203 d
|
||||||
connection default;
|
|
||||||
disconnect con1;
|
|
||||||
disconnect con2;
|
disconnect con2;
|
||||||
|
connection default;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DROP TABLE t2;
|
DROP TABLE t2;
|
||||||
#
|
#
|
||||||
# Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
|
# Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
|
||||||
#
|
#
|
||||||
connect con1,localhost,root,,;
|
connection con1;
|
||||||
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
|
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
|
||||||
INSERT INTO t1 values (1, 0), (2, 0);
|
INSERT INTO t1 values (1, 0), (2, 0);
|
||||||
SELECT * FROM t1 ORDER BY col1;
|
SELECT * FROM t1 ORDER BY col1;
|
||||||
@ -218,5 +185,5 @@ SET DEBUG_SYNC = 'now SIGNAL s2';
|
|||||||
connection con1;
|
connection con1;
|
||||||
disconnect con1;
|
disconnect con1;
|
||||||
connection default;
|
connection default;
|
||||||
DROP TABLE t1;
|
|
||||||
SET DEBUG_SYNC= 'RESET';
|
SET DEBUG_SYNC= 'RESET';
|
||||||
|
DROP TABLE t1;
|
||||||
|
BIN
mysql-test/suite/innodb/r/innodb_i_s_innodb_locks.result
Normal file
BIN
mysql-test/suite/innodb/r/innodb_i_s_innodb_locks.result
Normal file
Binary file not shown.
90
mysql-test/suite/innodb/r/innodb_i_s_innodb_trx.result
Normal file
90
mysql-test/suite/innodb/r/innodb_i_s_innodb_trx.result
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
SET @save_timeout=@@GLOBAL.innodb_lock_wait_timeout;
|
||||||
|
SET GLOBAL innodb_lock_wait_timeout=100000000;
|
||||||
|
DESCRIBE INFORMATION_SCHEMA.INNODB_TRX;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
trx_id varchar(18) NO NULL
|
||||||
|
trx_state varchar(13) NO NULL
|
||||||
|
trx_started datetime NO NULL
|
||||||
|
trx_requested_lock_id varchar(81) YES NULL
|
||||||
|
trx_wait_started datetime YES NULL
|
||||||
|
trx_weight bigint(21) unsigned NO NULL
|
||||||
|
trx_mysql_thread_id bigint(21) unsigned NO NULL
|
||||||
|
trx_query varchar(1024) YES NULL
|
||||||
|
trx_operation_state varchar(64) YES NULL
|
||||||
|
trx_tables_in_use bigint(21) unsigned NO NULL
|
||||||
|
trx_tables_locked bigint(21) unsigned NO NULL
|
||||||
|
trx_lock_structs bigint(21) unsigned NO NULL
|
||||||
|
trx_lock_memory_bytes bigint(21) unsigned NO NULL
|
||||||
|
trx_rows_locked bigint(21) unsigned NO NULL
|
||||||
|
trx_rows_modified bigint(21) unsigned NO NULL
|
||||||
|
trx_concurrency_tickets bigint(21) unsigned NO NULL
|
||||||
|
trx_isolation_level varchar(16) NO NULL
|
||||||
|
trx_unique_checks int(1) NO NULL
|
||||||
|
trx_foreign_key_checks int(1) NO NULL
|
||||||
|
trx_last_foreign_key_error varchar(256) YES NULL
|
||||||
|
trx_is_read_only int(1) NO NULL
|
||||||
|
trx_autocommit_non_locking int(1) NO NULL
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
c01 INT,
|
||||||
|
c02 INT,
|
||||||
|
PRIMARY KEY (c01)
|
||||||
|
) ENGINE=INNODB STATS_AUTO_RECALC=0;
|
||||||
|
INSERT INTO t1 VALUES
|
||||||
|
(1,2),(2,4),(3,6),(4,8);
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
c01 INT,
|
||||||
|
c02 INT,
|
||||||
|
PRIMARY KEY (c01),
|
||||||
|
FOREIGN KEY fk1 (c02) REFERENCES t1 (c01)
|
||||||
|
) ENGINE=INNODB STATS_AUTO_RECALC=0;
|
||||||
|
INSERT INTO t2 VALUES
|
||||||
|
(1,1),(2,2),(3,3);
|
||||||
|
connect con_trx,localhost,root,,;
|
||||||
|
connect con_verify_innodb_trx,localhost,root,,;
|
||||||
|
connection con_trx;
|
||||||
|
SET autocommit=0;
|
||||||
|
INSERT INTO t1 VALUES (5,10);
|
||||||
|
SELECT * FROM t1 FOR UPDATE;
|
||||||
|
c01 c02
|
||||||
|
1 2
|
||||||
|
2 4
|
||||||
|
3 6
|
||||||
|
4 8
|
||||||
|
5 10
|
||||||
|
connection con_verify_innodb_trx;
|
||||||
|
SELECT trx_state, trx_weight, trx_tables_in_use, trx_tables_locked,
|
||||||
|
trx_rows_locked, trx_rows_modified, trx_concurrency_tickets,
|
||||||
|
trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
|
||||||
|
FROM INFORMATION_SCHEMA.INNODB_TRX;
|
||||||
|
trx_state trx_weight trx_tables_in_use trx_tables_locked trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks
|
||||||
|
RUNNING 3 0 1 6 1 0 REPEATABLE READ 1 1
|
||||||
|
connection con_trx;
|
||||||
|
ROLLBACK;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
SET UNIQUE_CHECKS = 0;
|
||||||
|
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO t1 VALUES (6,12);
|
||||||
|
connection con_verify_innodb_trx;
|
||||||
|
SELECT trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
|
||||||
|
FROM INFORMATION_SCHEMA.INNODB_TRX;
|
||||||
|
trx_isolation_level trx_unique_checks trx_foreign_key_checks
|
||||||
|
SERIALIZABLE 0 0
|
||||||
|
connection con_trx;
|
||||||
|
ROLLBACK;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
SET UNIQUE_CHECKS = 1;
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO t2 VALUES (4,10);
|
||||||
|
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`))
|
||||||
|
disconnect con_trx;
|
||||||
|
connection con_verify_innodb_trx;
|
||||||
|
SELECT trx_state, trx_isolation_level, trx_last_foreign_key_error
|
||||||
|
FROM INFORMATION_SCHEMA.INNODB_TRX;
|
||||||
|
trx_state trx_isolation_level trx_last_foreign_key_error
|
||||||
|
RUNNING REPEATABLE READ `test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`)
|
||||||
|
disconnect con_verify_innodb_trx;
|
||||||
|
connection default;
|
||||||
|
DROP TABLE t2;
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET GLOBAL innodb_lock_wait_timeout=@save_timeout;
|
@ -1,2 +1,3 @@
|
|||||||
|
FOUND 1 /\[Warning\] InnoDB: innodb_open_files 1000000 should not be greater than the open_files_limit [0-9]+/ in mysqld.1.err
|
||||||
CREATE TABLE t1 ENGINE=InnoDB AS SELECT * FROM mysql.help_topic;
|
CREATE TABLE t1 ENGINE=InnoDB AS SELECT * FROM mysql.help_topic;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
44
mysql-test/suite/innodb/r/innodb_stats_auto_recalc.result
Normal file
44
mysql-test/suite/innodb/r/innodb_stats_auto_recalc.result
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
CREATE TABLE autorecalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
|
||||||
|
SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc';
|
||||||
|
n_rows 0
|
||||||
|
clustered_index_size 1
|
||||||
|
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc';
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_diff_pfx01
|
||||||
|
stat_value 0
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_leaf_pages
|
||||||
|
stat_value 1
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name size
|
||||||
|
stat_value 1
|
||||||
|
INSERT INTO autorecalc VALUES (1);
|
||||||
|
INSERT INTO autorecalc VALUES (2);
|
||||||
|
SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc';
|
||||||
|
n_rows 2
|
||||||
|
clustered_index_size 1
|
||||||
|
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc';
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_diff_pfx01
|
||||||
|
stat_value 2
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_leaf_pages
|
||||||
|
stat_value 1
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name size
|
||||||
|
stat_value 1
|
||||||
|
DELETE FROM autorecalc;
|
||||||
|
SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc';
|
||||||
|
n_rows 0
|
||||||
|
clustered_index_size 1
|
||||||
|
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc';
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_diff_pfx01
|
||||||
|
stat_value 0
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_leaf_pages
|
||||||
|
stat_value 1
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name size
|
||||||
|
stat_value 1
|
||||||
|
DROP TABLE autorecalc;
|
@ -0,0 +1,34 @@
|
|||||||
|
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a)) ENGINE=INNODB;
|
||||||
|
INSERT INTO arddl VALUES (1, 10);
|
||||||
|
INSERT INTO arddl VALUES (2, 10);
|
||||||
|
ALTER TABLE arddl ADD INDEX (b);
|
||||||
|
SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'arddl' ORDER BY 1;
|
||||||
|
n_rows 2
|
||||||
|
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' ORDER BY 1, 2, 3;
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_diff_pfx01
|
||||||
|
stat_value 2
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_leaf_pages
|
||||||
|
stat_value 1
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name size
|
||||||
|
stat_value 1
|
||||||
|
DROP TABLE arddl;
|
||||||
|
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a), KEY (b)) ENGINE=INNODB;
|
||||||
|
INSERT INTO arddl VALUES (3, 10);
|
||||||
|
INSERT INTO arddl VALUES (4, 10);
|
||||||
|
ALTER TABLE arddl DROP INDEX b;
|
||||||
|
SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'arddl' ORDER BY 1;
|
||||||
|
n_rows 2
|
||||||
|
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' ORDER BY 1, 2, 3;
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_diff_pfx01
|
||||||
|
stat_value 2
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name n_leaf_pages
|
||||||
|
stat_value 1
|
||||||
|
index_name PRIMARY
|
||||||
|
stat_name size
|
||||||
|
stat_value 1
|
||||||
|
DROP TABLE arddl;
|
202
mysql-test/suite/innodb/r/innodb_stats_auto_recalc_lots.result
Normal file
202
mysql-test/suite/innodb/r/innodb_stats_auto_recalc_lots.result
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
SELECT table_name, n_rows FROM mysql.innodb_table_stats WHERE table_name LIKE 'ar_%' ORDER BY table_name;
|
||||||
|
table_name n_rows
|
||||||
|
ar_1001 0
|
||||||
|
ar_1002 0
|
||||||
|
ar_1003 0
|
||||||
|
ar_1004 0
|
||||||
|
ar_1005 0
|
||||||
|
ar_1006 0
|
||||||
|
ar_1007 0
|
||||||
|
ar_1008 0
|
||||||
|
ar_1009 0
|
||||||
|
ar_1010 0
|
||||||
|
ar_1011 0
|
||||||
|
ar_1012 0
|
||||||
|
ar_1013 0
|
||||||
|
ar_1014 0
|
||||||
|
ar_1015 0
|
||||||
|
ar_1016 0
|
||||||
|
ar_1017 0
|
||||||
|
ar_1018 0
|
||||||
|
ar_1019 0
|
||||||
|
ar_1020 0
|
||||||
|
ar_1021 0
|
||||||
|
ar_1022 0
|
||||||
|
ar_1023 0
|
||||||
|
ar_1024 0
|
||||||
|
ar_1025 0
|
||||||
|
ar_1026 0
|
||||||
|
ar_1027 0
|
||||||
|
ar_1028 0
|
||||||
|
ar_1029 0
|
||||||
|
ar_1030 0
|
||||||
|
ar_1031 0
|
||||||
|
ar_1032 0
|
||||||
|
ar_1033 0
|
||||||
|
ar_1034 0
|
||||||
|
ar_1035 0
|
||||||
|
ar_1036 0
|
||||||
|
ar_1037 0
|
||||||
|
ar_1038 0
|
||||||
|
ar_1039 0
|
||||||
|
ar_1040 0
|
||||||
|
ar_1041 0
|
||||||
|
ar_1042 0
|
||||||
|
ar_1043 0
|
||||||
|
ar_1044 0
|
||||||
|
ar_1045 0
|
||||||
|
ar_1046 0
|
||||||
|
ar_1047 0
|
||||||
|
ar_1048 0
|
||||||
|
ar_1049 0
|
||||||
|
ar_1050 0
|
||||||
|
ar_1051 0
|
||||||
|
ar_1052 0
|
||||||
|
ar_1053 0
|
||||||
|
ar_1054 0
|
||||||
|
ar_1055 0
|
||||||
|
ar_1056 0
|
||||||
|
ar_1057 0
|
||||||
|
ar_1058 0
|
||||||
|
ar_1059 0
|
||||||
|
ar_1060 0
|
||||||
|
ar_1061 0
|
||||||
|
ar_1062 0
|
||||||
|
ar_1063 0
|
||||||
|
ar_1064 0
|
||||||
|
ar_1065 0
|
||||||
|
ar_1066 0
|
||||||
|
ar_1067 0
|
||||||
|
ar_1068 0
|
||||||
|
ar_1069 0
|
||||||
|
ar_1070 0
|
||||||
|
ar_1071 0
|
||||||
|
ar_1072 0
|
||||||
|
ar_1073 0
|
||||||
|
ar_1074 0
|
||||||
|
ar_1075 0
|
||||||
|
ar_1076 0
|
||||||
|
ar_1077 0
|
||||||
|
ar_1078 0
|
||||||
|
ar_1079 0
|
||||||
|
ar_1080 0
|
||||||
|
ar_1081 0
|
||||||
|
ar_1082 0
|
||||||
|
ar_1083 0
|
||||||
|
ar_1084 0
|
||||||
|
ar_1085 0
|
||||||
|
ar_1086 0
|
||||||
|
ar_1087 0
|
||||||
|
ar_1088 0
|
||||||
|
ar_1089 0
|
||||||
|
ar_1090 0
|
||||||
|
ar_1091 0
|
||||||
|
ar_1092 0
|
||||||
|
ar_1093 0
|
||||||
|
ar_1094 0
|
||||||
|
ar_1095 0
|
||||||
|
ar_1096 0
|
||||||
|
ar_1097 0
|
||||||
|
ar_1098 0
|
||||||
|
ar_1099 0
|
||||||
|
ar_1100 0
|
||||||
|
ar_1101 0
|
||||||
|
ar_1102 0
|
||||||
|
ar_1103 0
|
||||||
|
ar_1104 0
|
||||||
|
ar_1105 0
|
||||||
|
ar_1106 0
|
||||||
|
ar_1107 0
|
||||||
|
ar_1108 0
|
||||||
|
ar_1109 0
|
||||||
|
ar_1110 0
|
||||||
|
ar_1111 0
|
||||||
|
ar_1112 0
|
||||||
|
ar_1113 0
|
||||||
|
ar_1114 0
|
||||||
|
ar_1115 0
|
||||||
|
ar_1116 0
|
||||||
|
ar_1117 0
|
||||||
|
ar_1118 0
|
||||||
|
ar_1119 0
|
||||||
|
ar_1120 0
|
||||||
|
ar_1121 0
|
||||||
|
ar_1122 0
|
||||||
|
ar_1123 0
|
||||||
|
ar_1124 0
|
||||||
|
ar_1125 0
|
||||||
|
ar_1126 0
|
||||||
|
ar_1127 0
|
||||||
|
ar_1128 0
|
||||||
|
ar_1129 0
|
||||||
|
ar_1130 0
|
||||||
|
ar_1131 0
|
||||||
|
ar_1132 0
|
||||||
|
ar_1133 0
|
||||||
|
ar_1134 0
|
||||||
|
ar_1135 0
|
||||||
|
ar_1136 0
|
||||||
|
ar_1137 0
|
||||||
|
ar_1138 0
|
||||||
|
ar_1139 0
|
||||||
|
ar_1140 0
|
||||||
|
ar_1141 0
|
||||||
|
ar_1142 0
|
||||||
|
ar_1143 0
|
||||||
|
ar_1144 0
|
||||||
|
ar_1145 0
|
||||||
|
ar_1146 0
|
||||||
|
ar_1147 0
|
||||||
|
ar_1148 0
|
||||||
|
ar_1149 0
|
||||||
|
ar_1150 0
|
||||||
|
ar_1151 0
|
||||||
|
ar_1152 0
|
||||||
|
ar_1153 0
|
||||||
|
ar_1154 0
|
||||||
|
ar_1155 0
|
||||||
|
ar_1156 0
|
||||||
|
ar_1157 0
|
||||||
|
ar_1158 0
|
||||||
|
ar_1159 0
|
||||||
|
ar_1160 0
|
||||||
|
ar_1161 0
|
||||||
|
ar_1162 0
|
||||||
|
ar_1163 0
|
||||||
|
ar_1164 0
|
||||||
|
ar_1165 0
|
||||||
|
ar_1166 0
|
||||||
|
ar_1167 0
|
||||||
|
ar_1168 0
|
||||||
|
ar_1169 0
|
||||||
|
ar_1170 0
|
||||||
|
ar_1171 0
|
||||||
|
ar_1172 0
|
||||||
|
ar_1173 0
|
||||||
|
ar_1174 0
|
||||||
|
ar_1175 0
|
||||||
|
ar_1176 0
|
||||||
|
ar_1177 0
|
||||||
|
ar_1178 0
|
||||||
|
ar_1179 0
|
||||||
|
ar_1180 0
|
||||||
|
ar_1181 0
|
||||||
|
ar_1182 0
|
||||||
|
ar_1183 0
|
||||||
|
ar_1184 0
|
||||||
|
ar_1185 0
|
||||||
|
ar_1186 0
|
||||||
|
ar_1187 0
|
||||||
|
ar_1188 0
|
||||||
|
ar_1189 0
|
||||||
|
ar_1190 0
|
||||||
|
ar_1191 0
|
||||||
|
ar_1192 0
|
||||||
|
ar_1193 0
|
||||||
|
ar_1194 0
|
||||||
|
ar_1195 0
|
||||||
|
ar_1196 0
|
||||||
|
ar_1197 0
|
||||||
|
ar_1198 0
|
||||||
|
ar_1199 0
|
||||||
|
ar_1200 0
|
@ -0,0 +1,57 @@
|
|||||||
|
Test with default setting
|
||||||
|
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 1
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 3
|
||||||
|
FLUSH TABLE t;
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT * FROM t;
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 1
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 3
|
||||||
|
DROP TABLE t;
|
||||||
|
Test with explicit enable
|
||||||
|
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=1;
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 1
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 3
|
||||||
|
FLUSH TABLE t;
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT * FROM t;
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 1
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 3
|
||||||
|
DROP TABLE t;
|
||||||
|
Test with explicit disable
|
||||||
|
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=0;
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 1
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 3
|
||||||
|
FLUSH TABLE t;
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT * FROM t;
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
|
||||||
|
COUNT(*) 0
|
||||||
|
DROP TABLE t;
|
10
mysql-test/suite/innodb/r/innodb_stats_external_pages.result
Normal file
10
mysql-test/suite/innodb/r/innodb_stats_external_pages.result
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE bug18384390 (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
txt VARCHAR(10000)
|
||||||
|
) ENGINE=INNODB STATS_PERSISTENT=1 STATS_AUTO_RECALC=0;
|
||||||
|
INSERT INTO bug18384390 (txt) SELECT REPEAT('0', 10000) FROM seq_1_to_1024;
|
||||||
|
set use_stat_tables=never;
|
||||||
|
ANALYZE TABLE bug18384390;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.bug18384390 analyze status OK
|
||||||
|
DROP TABLE bug18384390;
|
34
mysql-test/suite/innodb/r/innodb_stats_flag_global,off.rdiff
Normal file
34
mysql-test/suite/innodb/r/innodb_stats_flag_global,off.rdiff
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
@@ -18,7 +18,7 @@
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
-1
|
||||||
|
+0
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=default;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
@@ -37,7 +37,7 @@
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
-1
|
||||||
|
+0
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after creation with explicit PS=OFF
|
||||||
|
@@ -142,7 +142,7 @@
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
-1
|
||||||
|
+0
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after creation with explicit PS=ON,
|
||||||
|
@@ -203,5 +203,5 @@
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
-1
|
||||||
|
+0
|
||||||
|
DROP TABLE test_ps_flag;
|
207
mysql-test/suite/innodb/r/innodb_stats_flag_global.result
Normal file
207
mysql-test/suite/innodb/r/innodb_stats_flag_global.result
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after default creation
|
||||||
|
=====
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=default;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after creation with explicit PS=OFF
|
||||||
|
=====
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=0;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
0
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after creation with explicit PS=ON
|
||||||
|
=====
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=1;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=1
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after creation with explicit PS=OFF,
|
||||||
|
=== then ALTER to ON, then ALTER to OFF, then ALTER to default
|
||||||
|
=====
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=0;
|
||||||
|
ALTER TABLE test_ps_flag STATS_PERSISTENT=1;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=1
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
ALTER TABLE test_ps_flag STATS_PERSISTENT=0;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
0
|
||||||
|
ALTER TABLE test_ps_flag STATS_PERSISTENT=default;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
DROP TABLE test_ps_flag;
|
||||||
|
=====
|
||||||
|
=== Test ANALYZE behavior after creation with explicit PS=ON,
|
||||||
|
=== then ALTER to OFF, then ALTER to ON, then ALTER to default
|
||||||
|
=====
|
||||||
|
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=1;
|
||||||
|
ALTER TABLE test_ps_flag STATS_PERSISTENT=0;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
0
|
||||||
|
ALTER TABLE test_ps_flag STATS_PERSISTENT=1;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=1
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
ALTER TABLE test_ps_flag STATS_PERSISTENT=default;
|
||||||
|
SHOW CREATE TABLE test_ps_flag;
|
||||||
|
Table Create Table
|
||||||
|
test_ps_flag CREATE TABLE `test_ps_flag` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_before
|
||||||
|
0
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE test_ps_flag;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_flag analyze status OK
|
||||||
|
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
|
||||||
|
cnt_after
|
||||||
|
1
|
||||||
|
DROP TABLE test_ps_flag;
|
@ -10,9 +10,9 @@ CREATE TABLE t1 (id SERIAL, val INT UNSIGNED NOT NULL, KEY(val))
|
|||||||
ENGINE=INNODB STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
|
ENGINE=INNODB STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
|
||||||
CREATE TABLE t2 LIKE t1;
|
CREATE TABLE t2 LIKE t1;
|
||||||
INSERT INTO t1 (val) SELECT 4 FROM seq_1_to_16;
|
INSERT INTO t1 (val) SELECT 4 FROM seq_1_to_16;
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
ANALYZE TABLE t1;
|
ANALYZE TABLE t1;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 analyze status Engine-independent statistics collected
|
|
||||||
test.t1 analyze status OK
|
test.t1 analyze status OK
|
||||||
connect con1, localhost, root,,;
|
connect con1, localhost, root,,;
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
@ -91,7 +91,7 @@ COUNT(*)
|
|||||||
# ha_innobase::records_in_range() would count the delete-marked records.
|
# ha_innobase::records_in_range() would count the delete-marked records.
|
||||||
EXPLAIN SELECT * FROM t1;
|
EXPLAIN SELECT * FROM t1;
|
||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE t1 index NULL val 4 NULL 16 Using index
|
1 SIMPLE t1 index NULL val 4 NULL 1 Using index
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
EXPLAIN SELECT * FROM t1;
|
EXPLAIN SELECT * FROM t1;
|
||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
@ -106,3 +106,25 @@ SET GLOBAL innodb_stats_include_delete_marked = @saved_include_delete_marked;
|
|||||||
SET GLOBAL innodb_stats_traditional = @saved_traditional;
|
SET GLOBAL innodb_stats_traditional = @saved_traditional;
|
||||||
SET GLOBAL innodb_stats_modified_counter = @saved_modified_counter;
|
SET GLOBAL innodb_stats_modified_counter = @saved_modified_counter;
|
||||||
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
||||||
|
CREATE TABLE bug12429573 (i INTEGER PRIMARY KEY, j INTEGER, KEY(j))
|
||||||
|
ENGINE=INNODB STATS_PERSISTENT=1;
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE bug12429573;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.bug12429573 analyze status OK
|
||||||
|
SELECT last_update INTO @last FROM mysql.innodb_table_stats
|
||||||
|
WHERE table_name = 'bug12429573';
|
||||||
|
SELECT * FROM mysql.innodb_index_stats
|
||||||
|
WHERE table_name = 'bug12429573' AND last_update!=@last;
|
||||||
|
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
|
||||||
|
SET STATEMENT use_stat_tables=never FOR
|
||||||
|
ANALYZE TABLE bug12429573;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.bug12429573 analyze status OK
|
||||||
|
SELECT * FROM mysql.innodb_table_stats
|
||||||
|
WHERE table_name = 'bug12429573' AND last_update=@last;
|
||||||
|
database_name table_name last_update n_rows clustered_index_size sum_of_other_index_sizes
|
||||||
|
SELECT * FROM mysql.innodb_index_stats
|
||||||
|
WHERE table_name = 'bug12429573' AND last_update=@last;
|
||||||
|
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
|
||||||
|
DROP TABLE bug12429573;
|
||||||
|
29
mysql-test/suite/innodb/r/innodb_stats_sample_pages.result
Normal file
29
mysql-test/suite/innodb/r/innodb_stats_sample_pages.result
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
SET GLOBAL innodb_stats_persistent_sample_pages=17;
|
||||||
|
CREATE TABLE test_ps_sample_pages_used (
|
||||||
|
a VARCHAR(512), PRIMARY KEY (a)
|
||||||
|
) ENGINE=INNODB STATS_SAMPLE_PAGES=default;
|
||||||
|
BEGIN;
|
||||||
|
COMMIT;
|
||||||
|
ANALYZE TABLE test_ps_sample_pages_used;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_sample_pages_used analyze status Engine-independent statistics collected
|
||||||
|
test.test_ps_sample_pages_used analyze status OK
|
||||||
|
SELECT stat_name, stat_value FROM mysql.innodb_index_stats
|
||||||
|
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_leaf_pages';
|
||||||
|
stat_name stat_value
|
||||||
|
n_leaf_pages 37
|
||||||
|
SELECT sample_size FROM mysql.innodb_index_stats
|
||||||
|
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
|
||||||
|
sample_size
|
||||||
|
17
|
||||||
|
ALTER TABLE test_ps_sample_pages_used STATS_SAMPLE_PAGES=14;
|
||||||
|
ANALYZE TABLE test_ps_sample_pages_used;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.test_ps_sample_pages_used analyze status Engine-independent statistics collected
|
||||||
|
test.test_ps_sample_pages_used analyze status OK
|
||||||
|
SELECT sample_size FROM mysql.innodb_index_stats
|
||||||
|
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
|
||||||
|
sample_size
|
||||||
|
14
|
||||||
|
DROP TABLE test_ps_sample_pages_used;
|
||||||
|
SET GLOBAL innodb_stats_persistent_sample_pages=default;
|
@ -0,0 +1,82 @@
|
|||||||
|
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options
|
||||||
|
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=1;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=1
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options stats_auto_recalc=1
|
||||||
|
DROP TABLE test_ps_auto_recalc;
|
||||||
|
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_AUTO_RECALC=default;
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options
|
||||||
|
DROP TABLE test_ps_auto_recalc;
|
||||||
|
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_AUTO_RECALC=0;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=0
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options stats_auto_recalc=0
|
||||||
|
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=1;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=1
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options stats_auto_recalc=1
|
||||||
|
DROP TABLE test_ps_auto_recalc;
|
||||||
|
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_AUTO_RECALC=1;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=1
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options stats_auto_recalc=1
|
||||||
|
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=0;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_auto_recalc;
|
||||||
|
Table test_ps_auto_recalc
|
||||||
|
Create Table CREATE TABLE `test_ps_auto_recalc` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=0
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_auto_recalc';
|
||||||
|
create_options stats_auto_recalc=0
|
||||||
|
DROP TABLE test_ps_auto_recalc;
|
@ -0,0 +1,95 @@
|
|||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_sample_pages';
|
||||||
|
create_options
|
||||||
|
ALTER TABLE test_ps_sample_pages STATS_SAMPLE_PAGES=12345;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=12345
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_sample_pages';
|
||||||
|
create_options stats_sample_pages=12345
|
||||||
|
DROP TABLE test_ps_sample_pages;
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=default;
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_sample_pages';
|
||||||
|
create_options
|
||||||
|
DROP TABLE test_ps_sample_pages;
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=-5;
|
||||||
|
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 '-5' at line 2
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=0;
|
||||||
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0' at line 2
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=67000;
|
||||||
|
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 '67000' at line 2
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=670000;
|
||||||
|
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 '670000' at line 2
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=65536;
|
||||||
|
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 '65536' at line 2
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=65535;
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=65535
|
||||||
|
DROP TABLE test_ps_sample_pages;
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=1;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=1
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_sample_pages';
|
||||||
|
create_options stats_sample_pages=1
|
||||||
|
DROP TABLE test_ps_sample_pages;
|
||||||
|
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
|
||||||
|
STATS_SAMPLE_PAGES=5678;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=5678
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_sample_pages';
|
||||||
|
create_options stats_sample_pages=5678
|
||||||
|
ALTER TABLE test_ps_sample_pages STATS_SAMPLE_PAGES=default;
|
||||||
|
# restart
|
||||||
|
SHOW CREATE TABLE test_ps_sample_pages;
|
||||||
|
Table test_ps_sample_pages
|
||||||
|
Create Table CREATE TABLE `test_ps_sample_pages` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
SELECT create_options FROM information_schema.tables
|
||||||
|
WHERE table_name='test_ps_sample_pages';
|
||||||
|
create_options
|
||||||
|
DROP TABLE test_ps_sample_pages;
|
5
mysql-test/suite/innodb/r/innodb_ut_format_name.result
Normal file
5
mysql-test/suite/innodb/r/innodb_ut_format_name.result
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
CREATE TABLE t (c INT) ENGINE=INNODB;
|
||||||
|
SET @save_dbug = @@debug_dbug;
|
||||||
|
SET debug_dbug = '+d,test_ut_format_name';
|
||||||
|
DROP TABLE t;
|
||||||
|
SET debug_dbug = @save_dbug;
|
@ -5,3 +5,49 @@ ALTER TABLE t1 ROW_FORMAT=DYNAMIC;
|
|||||||
INSERT INTO t1 VALUES ('',2);
|
INSERT INTO t1 VALUES ('',2);
|
||||||
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
|
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-26743 InnoDB: CHAR+nopad does not work well
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Basic Latin letter vs equal accented letter
|
||||||
|
#
|
||||||
|
SET NAMES utf8mb3;
|
||||||
|
CREATE TABLE t1 (a CHAR(2), PRIMARY KEY(a)) COLLATE utf8_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
||||||
|
INSERT INTO t1 VALUES ('a'),('ä');
|
||||||
|
ERROR 23000: Duplicate entry 'ä' for key 'PRIMARY'
|
||||||
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# Two letters vs equal (but space padded) expansion
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a CHAR(2), PRIMARY KEY(a)) COLLATE utf8_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
||||||
|
INSERT INTO t1 VALUES ('ss'),('ß');
|
||||||
|
SET sql_mode=PAD_CHAR_TO_FULL_LENGTH;
|
||||||
|
SELECT HEX(a) FROM t1;
|
||||||
|
HEX(a)
|
||||||
|
7373
|
||||||
|
C39F20
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# Basic Latin letter (but followed by an ignorable character) vs equal accented letter
|
||||||
|
#
|
||||||
|
SET NAMES utf8mb3;
|
||||||
|
CREATE TABLE t1 (a CHAR(3), PRIMARY KEY(a)) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
||||||
|
INSERT INTO t1 VALUES (CONCAT('a',_utf8mb3 0x01)),('ä');
|
||||||
|
SET sql_mode=PAD_CHAR_TO_FULL_LENGTH;
|
||||||
|
SELECT HEX(a) FROM t1 ORDER BY HEX(a);
|
||||||
|
HEX(a)
|
||||||
|
610120
|
||||||
|
C3A42020
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET NAMES utf8mb3;
|
||||||
|
CREATE TABLE t1 (a CHAR(2), PRIMARY KEY(a)) COLLATE utf8_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
||||||
|
INSERT INTO t1 VALUES (CONCAT('a',_utf8mb3 0x01)),('ä');
|
||||||
|
SET sql_mode=PAD_CHAR_TO_FULL_LENGTH;
|
||||||
|
SELECT HEX(a) FROM t1 ORDER BY HEX(a);
|
||||||
|
HEX(a)
|
||||||
|
6101
|
||||||
|
C3A420
|
||||||
|
SET sql_mode=DEFAULT;
|
||||||
|
DROP TABLE t1;
|
||||||
|
8
mysql-test/suite/innodb/r/records_in_range,4k.rdiff
Normal file
8
mysql-test/suite/innodb/r/records_in_range,4k.rdiff
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@@ -39,7 +39,7 @@
|
||||||
|
WHERE
|
||||||
|
table_name='records_in_range_test' AND stat_name = 'size';
|
||||||
|
index_name stat_name stat_value
|
||||||
|
-PRIMARY size 1
|
||||||
|
+PRIMARY size 5
|
||||||
|
SET @save_dbug = @@debug_dbug;
|
||||||
|
SET DEBUG_DBUG='+d,print_btr_estimate_n_rows_in_range_return_value';
|
8
mysql-test/suite/innodb/r/records_in_range,8k.rdiff
Normal file
8
mysql-test/suite/innodb/r/records_in_range,8k.rdiff
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@@ -39,7 +39,7 @@
|
||||||
|
WHERE
|
||||||
|
table_name='records_in_range_test' AND stat_name = 'size';
|
||||||
|
index_name stat_name stat_value
|
||||||
|
-PRIMARY size 1
|
||||||
|
+PRIMARY size 3
|
||||||
|
SET @save_dbug = @@debug_dbug;
|
||||||
|
SET DEBUG_DBUG='+d,print_btr_estimate_n_rows_in_range_return_value';
|
1275
mysql-test/suite/innodb/r/records_in_range.result
Normal file
1275
mysql-test/suite/innodb/r/records_in_range.result
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,134 @@
|
|||||||
|
#
|
||||||
|
# Test the limits of a file-per-table tablespace name. MySQL combines
|
||||||
|
# the database name with the table name to make a unique table name.
|
||||||
|
#
|
||||||
|
SET default_storage_engine=InnoDB;
|
||||||
|
#
|
||||||
|
# MySQL limits each database and tablename identifier to 64 characters
|
||||||
|
# of up to 3 bytes per character, corresponding to 192 bytes.
|
||||||
|
#
|
||||||
|
CREATE DATABASE `this_sixty_five_byte_name_is_too_long____________________________`;
|
||||||
|
ERROR 42000: Incorrect database name 'this_sixty_five_byte_name_is_too_long____________________________'
|
||||||
|
CREATE DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
USE `this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
#
|
||||||
|
# A 64 character tablename can be created in a 64 character database name
|
||||||
|
#
|
||||||
|
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________` (a SERIAL);
|
||||||
|
#
|
||||||
|
# A 65 character tablename is too long.
|
||||||
|
#
|
||||||
|
CREATE TABLE `test`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
|
||||||
|
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
|
||||||
|
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
|
||||||
|
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
|
||||||
|
#
|
||||||
|
# Non-non-filename-safe characters like '#' are expanded to '@0023'.
|
||||||
|
# On many file systems, such as Linux extfs, you can create a database name
|
||||||
|
# that expands to up to 255 bytes long.
|
||||||
|
# `##################################################_long` is expanded to
|
||||||
|
# (50 * 5) + 5 = 255.
|
||||||
|
#
|
||||||
|
CREATE DATABASE `##################################################_long`;;
|
||||||
|
USE `##################################################_long`;
|
||||||
|
#
|
||||||
|
# This 256-byte name is only one byte longer but fails with an error code
|
||||||
|
# from the stat operation.
|
||||||
|
# `##################################################_long_` is expanded to
|
||||||
|
# (50 * 5) + 6 = 256.
|
||||||
|
#
|
||||||
|
CREATE DATABASE `##################################################_long_`;
|
||||||
|
ERROR HY000: Can't get stat of './##################################################_long_' (Errcode: ## "File name too long")
|
||||||
|
#
|
||||||
|
# This 300-byte name which is the longest name that gets an error code
|
||||||
|
# from the stat operation.
|
||||||
|
# `###########################################################_long` is expanded to
|
||||||
|
# (59 * 5) + 5 = 300.
|
||||||
|
#
|
||||||
|
CREATE DATABASE `###########################################################_long`;
|
||||||
|
ERROR HY000: Can't get stat of './###########################################################_long' (Errcode: ## "File name too long")
|
||||||
|
#
|
||||||
|
# This 301-byte name which is only one byte longer but fails with ER_TOO_LONG_IDENT.
|
||||||
|
# `###########################################################_long_` is expanded to
|
||||||
|
# (59 * 5) + 6 = 301.
|
||||||
|
#
|
||||||
|
CREATE DATABASE `###########################################################_long_`;
|
||||||
|
ERROR 42000: Incorrect database name '###########################################################_long_'
|
||||||
|
USE test;
|
||||||
|
#
|
||||||
|
# An expanded table name is limited to 251 bytes
|
||||||
|
#
|
||||||
|
CREATE TABLE `test`.`#################################################_long_` (a SERIAL);
|
||||||
|
#
|
||||||
|
# A 252-byte tablename is too long
|
||||||
|
#
|
||||||
|
CREATE TABLE `test`.`#################################################_long___` (a SERIAL);
|
||||||
|
ERROR HY000: Can't create table `test`.`#################################################_long___` (errno: ## "File name too long")
|
||||||
|
CREATE DATABASE twenty_byte_db_name_;
|
||||||
|
USE `twenty_byte_db_name_`;
|
||||||
|
#
|
||||||
|
# A 251 byte expanded table name will fit with a longer database name
|
||||||
|
#
|
||||||
|
CREATE TABLE `twenty_byte_db_name_`.`#################################################_long_` (a SERIAL);
|
||||||
|
#
|
||||||
|
# A 252 byte expanded table name is also too long in a longer database name
|
||||||
|
#
|
||||||
|
CREATE TABLE `twenty_byte_db_name_`.`#################################################_long___` (a SERIAL);
|
||||||
|
ERROR HY000: Can't create table `twenty_byte_db_name_`.`#################################################_long___` (errno: ## "File name too long")
|
||||||
|
#
|
||||||
|
# Another limitation is a 512 byte length to an expanded path that includes
|
||||||
|
# the datadir which is './' in this test, the expanded database name,
|
||||||
|
# the directory separator '/', the expanded table name, and the file extension.
|
||||||
|
# './long_db_name.long_250_byte_table_name.frm'
|
||||||
|
# 2+ 255 +1+ 250 +1+3 = 512
|
||||||
|
#
|
||||||
|
CREATE TABLE `##################################################_long`.`#################################################_long` (a SERIAL);
|
||||||
|
CREATE TABLE `##################################################_long`.`#################################################_long_` (a SERIAL);
|
||||||
|
ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023_long/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@
|
||||||
|
SHOW WARNINGS;
|
||||||
|
Level Code Message
|
||||||
|
Error 1860 Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023_long/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@
|
||||||
|
#
|
||||||
|
# Show the successfully created databases and tables
|
||||||
|
#
|
||||||
|
---- list_files MYSQLD_DATADIR/test
|
||||||
|
#################################################_long_.frm
|
||||||
|
#################################################_long_.ibd
|
||||||
|
db.opt
|
||||||
|
---- list_files MYSQLD_DATADIR/this_sixty_four_byte_name_is_not_too_long_______________________
|
||||||
|
db.opt
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________.frm
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________.ibd
|
||||||
|
---- list_files MYSQLD_DATADIR/##################################################_long
|
||||||
|
#################################################_long.frm
|
||||||
|
#################################################_long.ibd
|
||||||
|
db.opt
|
||||||
|
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%';
|
||||||
|
name
|
||||||
|
##################################################_long/#################################################_long
|
||||||
|
test/#################################################_long_
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
|
||||||
|
twenty_byte_db_name_/#################################################_long_
|
||||||
|
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%';
|
||||||
|
name
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
|
||||||
|
test/#################################################_long_
|
||||||
|
twenty_byte_db_name_/#################################################_long_
|
||||||
|
##################################################_long/#################################################_long
|
||||||
|
SELECT path FROM information_schema.innodb_sys_datafiles WHERE path LIKE '%long%';
|
||||||
|
path
|
||||||
|
./this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________.ibd
|
||||||
|
./test/#################################################_long_.ibd
|
||||||
|
./twenty_byte_db_name_/#################################################_long_.ibd
|
||||||
|
./##################################################_long/#################################################_long.ibd
|
||||||
|
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%';
|
||||||
|
#
|
||||||
|
# Cleanup
|
||||||
|
#
|
||||||
|
DROP TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
DROP TABLE `test`.`#################################################_long_`;
|
||||||
|
DROP TABLE `twenty_byte_db_name_`.`#################################################_long_`;
|
||||||
|
DROP TABLE `##################################################_long`.`#################################################_long`;
|
||||||
|
DROP DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
DROP DATABASE `##################################################_long`;
|
||||||
|
DROP DATABASE `twenty_byte_db_name_`;
|
@ -0,0 +1,51 @@
|
|||||||
|
#
|
||||||
|
# Test the limits of a file-per-table tablespace name. MySQL combines
|
||||||
|
# the database name with the table name to make a unique table name.
|
||||||
|
#
|
||||||
|
SET default_storage_engine=InnoDB;
|
||||||
|
#
|
||||||
|
# MySQL limits each database and tablename identifier to 64 characters
|
||||||
|
# of up to 3 bytes per character, corresponding to 192 bytes.
|
||||||
|
#
|
||||||
|
CREATE DATABASE `this_sixty_five_byte_name_is_too_long____________________________`;
|
||||||
|
ERROR 42000: Incorrect database name 'this_sixty_five_byte_name_is_too_long____________________________'
|
||||||
|
CREATE DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
USE `this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
#
|
||||||
|
# A 64 character tablename can be created in a 64 character database name
|
||||||
|
#
|
||||||
|
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________` (a SERIAL);
|
||||||
|
#
|
||||||
|
# A 65 character tablename is too long.
|
||||||
|
#
|
||||||
|
CREATE TABLE `test`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
|
||||||
|
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
|
||||||
|
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
|
||||||
|
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
|
||||||
|
#
|
||||||
|
# Show the successfully created database and table
|
||||||
|
#
|
||||||
|
SHOW CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________`;
|
||||||
|
Table Create Table
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________ CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________` (
|
||||||
|
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
UNIQUE KEY `a` (`a`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
---- list_files MYSQLD_DATADIR/this_sixty_four_byte_name_is_not_too_long_______________________
|
||||||
|
db.opt
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________.frm
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________.ibd
|
||||||
|
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%';
|
||||||
|
name
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
|
||||||
|
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%';
|
||||||
|
name
|
||||||
|
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
|
||||||
|
SELECT path FROM information_schema.innodb_sys_datafiles WHERE path LIKE '%long%';
|
||||||
|
path
|
||||||
|
.\this_sixty_four_byte_name_is_not_too_long_______________________\this_sixty_four_byte_name_is_not_too_long_______________________.ibd
|
||||||
|
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%';
|
||||||
|
#
|
||||||
|
# Cleanup
|
||||||
|
#
|
||||||
|
DROP DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
|
38
mysql-test/suite/innodb/t/add_foreign_key.test
Normal file
38
mysql-test/suite/innodb/t/add_foreign_key.test
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE ADD
|
||||||
|
--echo # FOREIGN KEY
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE `parent` (`parent_id` INT, PRIMARY KEY (`parent_id`));
|
||||||
|
CREATE TABLE `child1` (`id` INT ,`child1_fk1` INT, `child1_fk2` INT,
|
||||||
|
PRIMARY KEY (`id`));
|
||||||
|
CREATE TABLE `child2` (`id` INT, `child2_fk1` INT, `child2_fk2` INT,
|
||||||
|
PRIMARY KEY (`id`));
|
||||||
|
CREATE TABLE `child3` (`id` INT , `child3_fk1` INT, PRIMARY KEY (`id`));
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
|
||||||
|
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES `parent`
|
||||||
|
(`parent_id`);
|
||||||
|
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES
|
||||||
|
`parent` (`parent_id`);
|
||||||
|
|
||||||
|
drop table child3, child2, child1, parent;
|
45
mysql-test/suite/innodb/t/cascade_lock_wait.test
Normal file
45
mysql-test/suite/innodb/t/cascade_lock_wait.test
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
--source include/have_debug.inc
|
||||||
|
|
||||||
|
create table t1 (f1 int primary key) engine=innodb;
|
||||||
|
create table t2 (f1 int primary key,
|
||||||
|
constraint c1 foreign key (f1) references t1(f1)
|
||||||
|
on update cascade
|
||||||
|
on delete cascade) engine=innodb;
|
||||||
|
create table t3 (f1 int primary key,
|
||||||
|
constraint c2 foreign key (f1) references t1(f1)
|
||||||
|
on update cascade
|
||||||
|
on delete cascade) engine=innodb;
|
||||||
|
show create table t1;
|
||||||
|
show create table t2;
|
||||||
|
show create table t3;
|
||||||
|
|
||||||
|
insert into t1 values (1);
|
||||||
|
insert into t1 values (2);
|
||||||
|
insert into t1 values (3);
|
||||||
|
|
||||||
|
insert into t2 values (1);
|
||||||
|
insert into t2 values (2);
|
||||||
|
insert into t2 values (3);
|
||||||
|
|
||||||
|
insert into t3 values (1);
|
||||||
|
insert into t3 values (2);
|
||||||
|
insert into t3 values (3);
|
||||||
|
|
||||||
|
select f1 from t1;
|
||||||
|
select f1 from t2;
|
||||||
|
select f1 from t3;
|
||||||
|
|
||||||
|
set @save_dbug = @@debug_dbug;
|
||||||
|
set debug_dbug = '+d,dml_cascade_only_once';
|
||||||
|
set debug_dbug = '+d,row_upd_cascade_lock_wait_err';
|
||||||
|
update t1 set f1 = 100 where f1 = 2;
|
||||||
|
|
||||||
|
select f1 from t1;
|
||||||
|
select f1 from t2;
|
||||||
|
select f1 from t3;
|
||||||
|
|
||||||
|
set debug_dbug = @save_dbug;
|
||||||
|
drop table t2;
|
||||||
|
drop table t3;
|
||||||
|
drop table t1;
|
@ -153,4 +153,18 @@ ALTER TABLE t2 DROP INDEX idx;
|
|||||||
ALTER TABLE t2 MODIFY f2 VARCHAR(1023);
|
ALTER TABLE t2 MODIFY f2 VARCHAR(1023);
|
||||||
SET SESSION FOREIGN_KEY_CHECKS = ON;
|
SET SESSION FOREIGN_KEY_CHECKS = ON;
|
||||||
DROP TABLE t2, t1;
|
DROP TABLE t2, t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-32638 MariaDB crashes with foreign_key_checks=0
|
||||||
|
--echo # when changing a column and adding a foreign
|
||||||
|
--echo # key at the same time
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1(f1 VARCHAR(2) NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB;
|
||||||
|
CREATE TABLE t2(f1 INT NOT NULL PRIMARY KEY,
|
||||||
|
f2 VARCHAR(10) NOT NULL DEFAULT '')ENGINE=InnoDB;
|
||||||
|
SET SESSION FOREIGN_KEY_CHECKS = OFF;
|
||||||
|
ALTER TABLE t2 CHANGE COLUMN f2 f3 VARCHAR(20) NOT NULL,
|
||||||
|
ADD CONSTRAINT t2_fk FOREIGN KEY(f3) REFERENCES t1(f1);
|
||||||
|
DROP TABLE t2, t1;
|
||||||
|
SET SESSION FOREIGN_KEY_CHECKS = ON;
|
||||||
--echo # End of 10.4 tests
|
--echo # End of 10.4 tests
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user