summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqldump.c452
-rw-r--r--include/my_sys.h12
-rw-r--r--mysql-test/include/ddl_i18n.check_events.inc48
-rw-r--r--mysql-test/include/ddl_i18n.check_sp.inc83
-rw-r--r--mysql-test/include/ddl_i18n.check_triggers.inc106
-rw-r--r--mysql-test/include/ddl_i18n.check_views.inc32
-rw-r--r--mysql-test/include/have_cp1251.inc7
-rw-r--r--mysql-test/include/have_cp866.inc7
-rw-r--r--mysql-test/include/have_koi8r.inc7
-rw-r--r--mysql-test/include/have_utf8.inc7
-rw-r--r--mysql-test/lib/mtr_report.pl7
-rw-r--r--mysql-test/r/create.result4
-rw-r--r--mysql-test/r/ctype_cp932_binlog_stm.result6
-rw-r--r--mysql-test/r/ddl_i18n_koi8r.result2783
-rw-r--r--mysql-test/r/ddl_i18n_utf8.result2783
-rw-r--r--mysql-test/r/events.result139
-rw-r--r--mysql-test/r/events_bugs.result76
-rw-r--r--mysql-test/r/events_grant.result24
-rw-r--r--mysql-test/r/func_in.result4
-rw-r--r--mysql-test/r/gis.result4
-rw-r--r--mysql-test/r/grant.result24
-rw-r--r--mysql-test/r/have_cp1251.require2
-rw-r--r--mysql-test/r/have_cp866.require2
-rw-r--r--mysql-test/r/have_koi8r.require2
-rw-r--r--mysql-test/r/have_utf8.require2
-rw-r--r--mysql-test/r/information_schema.result100
-rw-r--r--mysql-test/r/information_schema_db.result26
-rw-r--r--mysql-test/r/lowercase_view.result12
-rw-r--r--mysql-test/r/mysqldump.result423
-rw-r--r--mysql-test/r/ndb_sp.result4
-rw-r--r--mysql-test/r/ps.result84
-rw-r--r--mysql-test/r/rpl_replicate_do.result14
-rw-r--r--mysql-test/r/rpl_sp.result72
-rw-r--r--mysql-test/r/rpl_trigger.result6
-rw-r--r--mysql-test/r/rpl_view.result4
-rw-r--r--mysql-test/r/show_check.result112
-rw-r--r--mysql-test/r/skip_grants.result12
-rw-r--r--mysql-test/r/sp-destruct.result19
-rw-r--r--mysql-test/r/sp-error.result12
-rw-r--r--mysql-test/r/sp-security.result36
-rw-r--r--mysql-test/r/sp.result154
-rw-r--r--mysql-test/r/sql_mode.result24
-rw-r--r--mysql-test/r/system_mysql_db.result8
-rw-r--r--mysql-test/r/temp_table.result4
-rw-r--r--mysql-test/r/trigger-compat.result6
-rw-r--r--mysql-test/r/trigger-grant.result18
-rw-r--r--mysql-test/r/trigger.result10
-rw-r--r--mysql-test/r/view.result163
-rw-r--r--mysql-test/r/view_grant.result76
-rw-r--r--mysql-test/t/ddl_i18n_koi8r.test1112
-rw-r--r--mysql-test/t/ddl_i18n_utf8.test1112
-rw-r--r--mysql-test/t/events.test25
-rw-r--r--mysql-test/t/information_schema.test2
-rw-r--r--mysql-test/t/show_check.test51
-rw-r--r--mysql-test/t/sp-destruct.test15
-rw-r--r--mysql-test/t/sp.test2
-rw-r--r--mysql-test/t/view.test10
-rw-r--r--mysys/charset.c14
-rw-r--r--scripts/mysql_system_tables.sql5
-rw-r--r--scripts/mysql_system_tables_fix.sql46
-rw-r--r--sql/event_data_objects.cc145
-rw-r--r--sql/event_data_objects.h7
-rw-r--r--sql/event_db_repository.cc48
-rw-r--r--sql/event_db_repository.h5
-rw-r--r--sql/events.cc21
-rw-r--r--sql/mysql_priv.h96
-rw-r--r--sql/share/errmsg.txt21
-rw-r--r--sql/sp.cc254
-rw-r--r--sql/sp_head.cc103
-rw-r--r--sql/sp_head.h78
-rw-r--r--sql/sql_lex.cc205
-rw-r--r--sql/sql_lex.h65
-rw-r--r--sql/sql_parse.cc46
-rw-r--r--sql/sql_partition.cc2
-rw-r--r--sql/sql_prepare.cc3
-rw-r--r--sql/sql_show.cc439
-rw-r--r--sql/sql_trigger.cc417
-rw-r--r--sql/sql_trigger.h27
-rw-r--r--sql/sql_view.cc80
-rw-r--r--sql/sql_yacc.yy100
-rw-r--r--sql/table.cc124
-rw-r--r--sql/table.h51
82 files changed, 11822 insertions, 931 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 7fae3c023b1..a01912ee7a1 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1002,6 +1002,192 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
return 0;
}
+
+static int fetch_db_collation(const char *db_name,
+ char *db_cl_name,
+ int db_cl_size)
+{
+ bool err_status= FALSE;
+ char query[QUERY_LENGTH];
+ MYSQL_RES *db_cl_res;
+ MYSQL_ROW db_cl_row;
+
+ my_snprintf(query, sizeof (query), "use %s", db_name);
+
+ if (mysql_query_with_error_report(mysql, NULL, query))
+ return 1;
+
+ if (mysql_query_with_error_report(mysql, &db_cl_res,
+ "select @@collation_database"))
+ return 1;
+
+ do
+ {
+ if (mysql_num_rows(db_cl_res) != 1)
+ {
+ err_status= TRUE;
+ break;
+ }
+
+ if (!(db_cl_row= mysql_fetch_row(db_cl_res)))
+ {
+ err_status= TRUE;
+ break;
+ }
+
+ strncpy(db_cl_name, db_cl_row[0], db_cl_size);
+ db_cl_name[db_cl_size - 1]= 0; /* just in case. */
+
+ } while (FALSE);
+
+ mysql_free_result(db_cl_res);
+
+ return err_status ? 1 : 0;
+}
+
+
+static char *my_case_str(const char *str,
+ uint str_len,
+ const char *token,
+ uint token_len)
+{
+ my_match_t match;
+
+ uint status= my_charset_latin1.coll->instr(&my_charset_latin1,
+ str, str_len,
+ token, token_len,
+ &match, 1);
+
+ return status ? (char *) str + match.end : NULL;
+}
+
+
+static int switch_db_collation(FILE *sql_file,
+ const char *db_name,
+ const char *delimiter,
+ const char *current_db_cl_name,
+ const char *required_db_cl_name)
+{
+ if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
+ {
+ CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
+
+ fprintf(sql_file,
+ "ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
+ (const char *) db_name,
+ (const char *) db_cl->csname,
+ (const char *) db_cl->name,
+ (const char *) delimiter);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+
+static void restore_db_collation(FILE *sql_file,
+ const char *db_name,
+ const char *delimiter,
+ const char *db_cl_name)
+{
+ CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
+
+ fprintf(sql_file,
+ "ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
+ (const char *) db_name,
+ (const char *) db_cl->csname,
+ (const char *) db_cl->name,
+ (const char *) delimiter);
+}
+
+
+static void switch_cs_variables(FILE *sql_file,
+ const char *delimiter,
+ const char *character_set_client,
+ const char *character_set_results,
+ const char *collation_connection)
+{
+ fprintf(sql_file,
+ "/*!50003 SET @saved_cs_client = @@character_set_client */ %s\n"
+ "/*!50003 SET @saved_cs_results = @@character_set_results */ %s\n"
+ "/*!50003 SET @saved_col_connection = @@collation_connection */ %s\n"
+ "/*!50003 SET character_set_client = %s */ %s\n"
+ "/*!50003 SET character_set_results = %s */ %s\n"
+ "/*!50003 SET collation_connection = %s */ %s\n",
+ (const char *) delimiter,
+ (const char *) delimiter,
+ (const char *) delimiter,
+
+ (const char *) character_set_client,
+ (const char *) delimiter,
+
+ (const char *) character_set_results,
+ (const char *) delimiter,
+
+ (const char *) collation_connection,
+ (const char *) delimiter);
+}
+
+
+static void restore_cs_variables(FILE *sql_file,
+ const char *delimiter)
+{
+ fprintf(sql_file,
+ "/*!50003 SET character_set_client = @saved_cs_client */ %s\n"
+ "/*!50003 SET character_set_results = @saved_cs_results */ %s\n"
+ "/*!50003 SET collation_connection = @saved_col_connection */ %s\n",
+ (const char *) delimiter,
+ (const char *) delimiter,
+ (const char *) delimiter);
+}
+
+
+static void switch_sql_mode(FILE *sql_file,
+ const char *delimiter,
+ const char *sql_mode)
+{
+ fprintf(sql_file,
+ "/*!50003 SET @saved_sql_mode = @@sql_mode */ %s\n"
+ "/*!50003 SET sql_mode = '%s' */ %s\n",
+ (const char *) delimiter,
+
+ (const char *) sql_mode,
+ (const char *) delimiter);
+}
+
+
+static void restore_sql_mode(FILE *sql_file,
+ const char *delimiter)
+{
+ fprintf(sql_file,
+ "/*!50003 SET sql_mode = @saved_sql_mode */ %s\n",
+ (const char *) delimiter);
+}
+
+
+static void switch_time_zone(FILE *sql_file,
+ const char *delimiter,
+ const char *time_zone)
+{
+ fprintf(sql_file,
+ "/*!50003 SET @saved_time_zone = @@time_zone */ %s\n"
+ "/*!50003 SET time_zone = '%s' */ %s\n",
+ (const char *) delimiter,
+
+ (const char *) time_zone,
+ (const char *) delimiter);
+}
+
+
+static void restore_time_zone(FILE *sql_file,
+ const char *delimiter)
+{
+ fprintf(sql_file,
+ "/*!50003 SET time_zone = @saved_time_zone */ %s\n",
+ (const char *) delimiter);
+}
+
/*
Open a new .sql file to dump the table or view into
@@ -1470,10 +1656,14 @@ static uint dump_events_for_db(char *db)
char query_buff[QUERY_LENGTH];
char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3];
char *event_name;
- char delimiter[QUERY_LENGTH], *delimit_test;
+ char delimiter[QUERY_LENGTH];
FILE *sql_file= md_result_file;
MYSQL_RES *event_res, *event_list_res;
MYSQL_ROW row, event_list_row;
+
+ char db_cl_name[MY_CS_NAME_SIZE];
+ int db_cl_altered;
+
DBUG_ENTER("dump_events_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
@@ -1498,6 +1688,11 @@ static uint dump_events_for_db(char *db)
{
fprintf(sql_file, "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;\n");
+ /* Get database collation. */
+
+ if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name)))
+ DBUG_RETURN(1);
+
while ((event_list_row= mysql_fetch_row(event_list_res)) != NULL)
{
event_name= quote_name(event_list_row[1], name_buff, 0);
@@ -1520,17 +1715,41 @@ static uint dump_events_for_db(char *db)
fprintf(sql_file, "/*!50106 DROP EVENT IF EXISTS %s */%s\n",
event_name, delimiter);
- delimit_test= create_delimiter(row[3], delimiter, sizeof(delimiter));
- if (delimit_test == NULL) {
- fprintf(stderr, "%s: Warning: Can't dump event '%s'\n",
- event_name, my_progname);
+ if (create_delimiter(row[3], delimiter, sizeof(delimiter)) == NULL)
+ {
+ fprintf(stderr, "%s: Warning: Can't create delimiter for event '%s'\n",
+ event_name, my_progname);
DBUG_RETURN(1);
}
fprintf(sql_file, "DELIMITER %s\n", delimiter);
- fprintf(sql_file, "/*!50106 SET TIME_ZONE= '%s' */ %s\n",
- row[2], delimiter);
- fprintf(sql_file, "/*!50106 %s */ %s\n", row[3], delimiter);
+
+ db_cl_altered= switch_db_collation(sql_file,
+ db_name_buff,
+ delimiter,
+ db_cl_name,
+ row[6]);
+
+ switch_cs_variables(sql_file, delimiter,
+ row[4], /* character_set_client */
+ row[4], /* character_set_results */
+ row[5]); /* collation_connection */
+
+ switch_sql_mode(sql_file, delimiter, row[1]);
+
+ switch_time_zone(sql_file, delimiter, row[2]);
+
+ fprintf(sql_file,
+ "/*!50106 %s */ %s\n",
+ (const char *) row[3],
+ (const char *) delimiter);
+
+ restore_time_zone(sql_file, delimiter);
+ restore_sql_mode(sql_file, delimiter);
+ restore_cs_variables(sql_file, delimiter);
+
+ if (db_cl_altered)
+ restore_db_collation(sql_file, db_name_buff, delimiter, db_cl_name);
}
} /* end of event printing */
mysql_free_result(event_res);
@@ -1592,6 +1811,10 @@ static uint dump_routines_for_db(char *db)
FILE *sql_file= md_result_file;
MYSQL_RES *routine_res, *routine_list_res;
MYSQL_ROW row, routine_list_row;
+
+ char db_cl_name[MY_CS_NAME_SIZE];
+ int db_cl_altered;
+
DBUG_ENTER("dump_routines_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
@@ -1608,10 +1831,10 @@ static uint dump_routines_for_db(char *db)
if (lock_tables)
mysql_query(mysql, "LOCK TABLES mysql.proc READ");
- if (opt_compact)
- fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
+ /* Get database collation. */
- fprintf(sql_file, "DELIMITER ;;\n");
+ if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name)))
+ DBUG_RETURN(1);
/* 0, retrieve and dump functions, 1, procedures */
for (i= 0; i <= 1; i++)
@@ -1658,26 +1881,34 @@ static uint dump_routines_for_db(char *db)
char *definer_begin;
if (opt_drop)
- fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;;\n",
+ fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n",
routine_type[i], routine_name);
/*
Cover DEFINER-clause in version-specific comments.
TODO: this is definitely a BAD IDEA to parse SHOW CREATE output.
- We should user INFORMATION_SCHEMA instead. The only problem is
- that now INFORMATION_SCHEMA does not provide information about
- routine parameters.
+ However, we can not use INFORMATION_SCHEMA instead:
+ 1. INFORMATION_SCHEMA provides data in UTF8, but here we
+ need data in the original character set;
+ 2. INFORMATION_SCHEMA does not provide information about
+ routine parameters now.
*/
- definer_begin= strstr(row[2], " DEFINER");
+ definer_begin= my_case_str(row[2], strlen(row[2]),
+ C_STRING_WITH_LEN(" DEFINER"));
if (definer_begin)
{
- char *definer_end= strstr(definer_begin, " PROCEDURE");
+ char *definer_end= my_case_str(definer_begin,
+ strlen(definer_begin),
+ C_STRING_WITH_LEN(" PROCEDURE"));
if (!definer_end)
- definer_end= strstr(definer_begin, " FUNCTION");
+ {
+ definer_end= my_case_str(definer_begin, strlen(definer_begin),
+ C_STRING_WITH_LEN(" FUNCTION"));
+ }
if (definer_end)
{
@@ -1703,13 +1934,28 @@ static uint dump_routines_for_db(char *db)
we need to change sql_mode only for the CREATE
PROCEDURE/FUNCTION otherwise we may need to re-quote routine_name
*/
- fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/;;\n",
- row[1] /* sql_mode */);
- fprintf(sql_file, "/*!50003 %s */;;\n",
- (query_str != NULL ? query_str : row[2]));
+
+ db_cl_altered= switch_db_collation(sql_file, db_name_buff, ";",
+ db_cl_name, row[5]);
+
+ switch_cs_variables(sql_file, ";",
+ row[3], /* character_set_client */
+ row[3], /* character_set_results */
+ row[4]); /* collation_connection */
+
+ switch_sql_mode(sql_file, ";", row[1]);
+
fprintf(sql_file,
- "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/"
- ";;\n");
+ "DELIMITER ;;\n"
+ "/*!50003 %s */;;\n"
+ "DELIMITER ;\n",
+ (const char *) (query_str != NULL ? query_str : row[2]));
+
+ restore_sql_mode(sql_file, ";");
+ restore_cs_variables(sql_file, ";");
+
+ if (db_cl_altered)
+ restore_db_collation(sql_file, db_name_buff, ";", db_cl_name);
my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
}
@@ -1720,8 +1966,6 @@ static uint dump_routines_for_db(char *db)
}
mysql_free_result(routine_list_res);
} /* end of for i (0 .. 1) */
- /* set the delimiter back to ';' */
- fprintf(sql_file, "DELIMITER ;\n");
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
@@ -2239,8 +2483,7 @@ continue_xml:
*/
-static void dump_triggers_for_table(char *table,
- char *db __attribute__((unused)))
+static void dump_triggers_for_table(char *table, char *db_name)
{
char *result_table;
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
@@ -2249,8 +2492,12 @@ static void dump_triggers_for_table(char *table,
FILE *sql_file= md_result_file;
MYSQL_RES *result;
MYSQL_ROW row;
+
+ char db_cl_name[MY_CS_NAME_SIZE];
+ int db_cl_altered;
+
DBUG_ENTER("dump_triggers_for_table");
- DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
+ DBUG_PRINT("enter", ("db: %s, table: %s", db_name, table));
/* Do not use ANSI_QUOTES on triggers in dump */
opt_compatible_mode&= ~MASK_ANSI_QUOTES;
@@ -2266,62 +2513,109 @@ static void dump_triggers_for_table(char *table,
my_fclose(sql_file, MYF(MY_WME));
DBUG_VOID_RETURN;
}
- if (mysql_num_rows(result))
- {
- if (opt_compact)
- fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
- fprintf(sql_file, "\nDELIMITER ;;\n");
- }
+
+ /* Get database collation. */
+
+ if (fetch_db_collation(db_name, db_cl_name, sizeof (db_cl_name)))
+ DBUG_VOID_RETURN;
+
+ /* Dump triggers. */
+
while ((row= mysql_fetch_row(result)))
{
- fprintf(sql_file,
- "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n"
- "/*!50003 CREATE */ ",
- row[6] /* sql_mode */);
+ MYSQL_RES *res2;
+
+ my_snprintf(query_buff, sizeof (query_buff),
+ "SHOW CREATE TRIGGER %s",
+ quote_name(row[0], name_buff, TRUE));
- if (mysql_num_fields(result) > 7)
+ if (mysql_query_with_error_report(mysql, &res2, query_buff))
{
+ if (path)
+ my_fclose(sql_file, MYF(MY_WME));
+ maybe_exit(EX_MYSQLERR);
+ DBUG_VOID_RETURN;
+ }
+
+ while ((row= mysql_fetch_row(res2)))
+ {
+ char *query_str= NULL;
+ char *definer_begin;
+
/*
- mysqldump can be run against the server, that does not support definer
- in triggers (there is no DEFINER column in SHOW TRIGGERS output). So,
- we should check if we have this column before accessing it.
+ Cover DEFINER-clause in version-specific comments.
+
+ TODO: this is definitely a BAD IDEA to parse SHOW CREATE output.
+ However, we can not use INFORMATION_SCHEMA instead:
+ 1. INFORMATION_SCHEMA provides data in UTF8, but here we
+ need data in the original character set;
+ 2. INFORMATION_SCHEMA does not provide information about
+ routine parameters now.
*/
- size_t user_name_len;
- char user_name_str[USERNAME_LENGTH + 1];
- char quoted_user_name_str[USERNAME_LENGTH * 2 + 3];
- size_t host_name_len;
- char host_name_str[HOSTNAME_LENGTH + 1];
- char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
+ definer_begin= my_case_str(row[2], strlen(row[2]),
+ C_STRING_WITH_LEN(" DEFINER"));
- parse_user(row[7], strlen(row[7]), user_name_str, &user_name_len,
- host_name_str, &host_name_len);
+ if (definer_begin)
+ {
+ char *definer_end= my_case_str(definer_begin, strlen(definer_begin),
+ C_STRING_WITH_LEN(" TRIGGER"));
+
+ if (definer_end)
+ {
+ char *query_str_tail;
+
+ /*
+ Allocate memory for new query string: original string
+ from SHOW statement and version-specific comments.
+ */
+ query_str= alloc_query_str(strlen(row[2]) + 23);
+
+ query_str_tail= strnmov(query_str, row[2],
+ definer_begin - row[2]);
+ query_str_tail= strmov(query_str_tail, "*/ /*!50017");
+ query_str_tail= strnmov(query_str_tail, definer_begin,
+ definer_end - definer_begin);
+ query_str_tail= strxmov(query_str_tail, "*/ /*!50003",
+ definer_end, NullS);
+ }
+ }
+
+ db_cl_altered= switch_db_collation(sql_file, db_name, ";",
+ db_cl_name, row[5]);
+
+ switch_cs_variables(sql_file, ";",
+ row[3], /* character_set_client */
+ row[3], /* character_set_results */
+ row[4]); /* collation_connection */
+
+ switch_sql_mode(sql_file, ";", row[1]);
fprintf(sql_file,
- "/*!50017 DEFINER=%s@%s */ ",
- quote_name(user_name_str, quoted_user_name_str, FALSE),
- quote_name(host_name_str, quoted_host_name_str, FALSE));
- }
+ "DELIMITER ;;\n"
+ "/*!50003 %s */;;\n"
+ "DELIMITER ;\n",
+ (const char *) (query_str != NULL ? query_str : row[2]));
- fprintf(sql_file,
- "/*!50003 TRIGGER %s %s %s ON %s FOR EACH ROW%s%s */;;\n\n",
- quote_name(row[0], name_buff, 0), /* Trigger */
- row[4], /* Timing */
- row[1], /* Event */
- result_table,
- (strchr(" \t\n\r", *(row[3]))) ? "" : " ",
- row[3] /* Statement */);
+ restore_sql_mode(sql_file, ";");
+ restore_cs_variables(sql_file, ";");
+
+ if (db_cl_altered)
+ restore_db_collation(sql_file, db_name, ";", db_cl_name);
+
+ my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
+ }
+ mysql_free_result(res2);
}
- if (mysql_num_rows(result))
- fprintf(sql_file,
- "DELIMITER ;\n"
- "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n");
+
mysql_free_result(result);
+
/*
make sure to set back opt_compatible mode to
original value
*/
opt_compatible_mode=old_opt_compatible_mode;
+
DBUG_VOID_RETURN;
}
@@ -4107,9 +4401,11 @@ static my_bool get_view_structure(char *table, char* db)
my_snprintf(query, sizeof(query),
- "SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE " \
- "FROM information_schema.views " \
+ "SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE, "
+ " CHARACTER_SET_CLIENT, COLLATION_CONNECTION "
+ "FROM information_schema.views "
"WHERE table_name=\"%s\" AND table_schema=\"%s\"", table, db);
+
if (mysql_query(mysql, query))
{
/*
@@ -4195,7 +4491,23 @@ static my_bool get_view_structure(char *table, char* db)
}
/* Dump view structure to file */
- fprintf(sql_file, "/*!50001 %s */;\n", ds_view.str);
+
+ fprintf(sql_file,
+ "/*!50001 SET @saved_cs_client = @@character_set_client */;\n"
+ "/*!50001 SET @saved_cs_results = @@character_set_results */;\n"
+ "/*!50001 SET @saved_col_connection = @@collation_connection */;\n"
+ "/*!50001 SET character_set_client = %s */;\n"
+ "/*!50001 SET character_set_results = %s */;\n"
+ "/*!50001 SET collation_connection = %s */;\n"
+ "/*!50001 %s */;\n"
+ "/*!50001 SET character_set_client = @saved_cs_client */;\n"
+ "/*!50001 SET character_set_results = @saved_cs_results */;\n"
+ "/*!50001 SET collation_connection = @saved_col_connection */;\n",
+ (const char *) row[3],
+ (const char *) row[3],
+ (const char *) row[4],
+ (const char *) ds_view.str);
+
check_io(sql_file);
mysql_free_result(table_res);
dynstr_free(&ds_view);
diff --git a/include/my_sys.h b/include/my_sys.h
index d1a253e4a7f..fb949842e48 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -905,12 +905,12 @@ extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
uint cs_flags, myf my_flags);
-extern bool resolve_charset(CHARSET_INFO **cs,
- const char *cs_name,
- CHARSET_INFO *default_cs);
-extern bool resolve_collation(CHARSET_INFO **cl,
- const char *cl_name,
- CHARSET_INFO *default_cl);
+extern bool resolve_charset(const char *cs_name,
+ CHARSET_INFO *default_cs,
+ CHARSET_INFO **cs);
+extern bool resolve_collation(const char *cl_name,
+ CHARSET_INFO *default_cl,
+ CHARSET_INFO **cl);
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf);
diff --git a/mysql-test/include/ddl_i18n.check_events.inc b/mysql-test/include/ddl_i18n.check_events.inc
new file mode 100644
index 00000000000..8b0d70e3c0e
--- /dev/null
+++ b/mysql-test/include/ddl_i18n.check_events.inc
@@ -0,0 +1,48 @@
+# - Check SHOW CREATE statement;
+
+--echo
+--echo
+
+SHOW CREATE EVENT ev1|
+--echo
+SHOW CREATE EVENT ev2|
+--echo
+SHOW CREATE EVENT mysqltest2.ev3|
+--echo
+SHOW CREATE EVENT mysqltest2.ev3|
+
+# - Check SHOW statement;
+
+--echo
+--echo
+
+SHOW EVENTS LIKE 'ev1'|
+
+--echo
+SHOW EVENTS LIKE 'ev2'|
+
+--echo
+SHOW EVENTS LIKE 'ev3'|
+
+--echo
+SHOW EVENTS LIKE 'ev4'|
+
+# - Check INFORMATION_SCHEMA;
+
+--echo
+--echo
+
+--replace_column 17 CREATED 18 LAST_ALTERED
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+
+--echo
+--replace_column 17 CREATED 18 LAST_ALTERED
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+
+--echo
+--replace_column 17 CREATED 18 LAST_ALTERED
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+
+--echo
+--replace_column 17 CREATED 18 LAST_ALTERED
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
diff --git a/mysql-test/include/ddl_i18n.check_sp.inc b/mysql-test/include/ddl_i18n.check_sp.inc
new file mode 100644
index 00000000000..bb1657d7072
--- /dev/null
+++ b/mysql-test/include/ddl_i18n.check_sp.inc
@@ -0,0 +1,83 @@
+# - Check SHOW CREATE statement;
+
+--echo
+--echo
+
+SHOW CREATE PROCEDURE p1|
+--echo
+SHOW CREATE PROCEDURE p2|
+--echo
+SHOW CREATE PROCEDURE mysqltest2.p3|
+--echo
+SHOW CREATE PROCEDURE mysqltest2.p4|
+
+# - Check SHOW statement;
+
+--echo
+--echo
+
+--replace_column 5 MODIFIED 6 CREATED
+SHOW PROCEDURE STATUS LIKE 'p1'|
+
+--echo
+--replace_column 5 MODIFIED 6 CREATED
+SHOW PROCEDURE STATUS LIKE 'p2'|
+
+--echo
+--replace_column 5 MODIFIED 6 CREATED
+SHOW PROCEDURE STATUS LIKE 'p3'|
+
+--echo
+--replace_column 5 MODIFIED 6 CREATED
+SHOW PROCEDURE STATUS LIKE 'p4'|
+
+# - Check INFORMATION_SCHEMA;
+
+--echo
+--echo
+
+--replace_column 16 CREATED 17 ALTERED
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+
+--echo
+--replace_column 16 CREATED 17 ALTERED
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+
+--echo
+--replace_column 16 CREATED 17 ALTERED
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+
+--echo
+--replace_column 16 CREATED 17 ALTERED
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+
+# - Initialize the used variables (actual values don't matter);
+
+--echo
+--echo
+
+SET @a = '1'|
+SET @b = '2'|
+
+# - Execute the routines;
+
+--echo
+--echo
+
+CALL p1(@a, @b)|
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+
+--echo
+
+CALL p2(@a, @b)|
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+
+--echo
+
+CALL mysqltest2.p3(@a, @b)|
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+
+--echo
+
+CALL mysqltest2.p4(@a, @b)|
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
diff --git a/mysql-test/include/ddl_i18n.check_triggers.inc b/mysql-test/include/ddl_i18n.check_triggers.inc
new file mode 100644
index 00000000000..dbfbc3cda5e
--- /dev/null
+++ b/mysql-test/include/ddl_i18n.check_triggers.inc
@@ -0,0 +1,106 @@
+# - Check SHOW CREATE statement;
+
+--echo
+--echo
+
+SHOW CREATE TRIGGER trg1|
+--echo
+SHOW CREATE TRIGGER trg2|
+--echo
+SHOW CREATE TRIGGER mysqltest2.trg3|
+--echo
+SHOW CREATE TRIGGER mysqltest2.trg4|
+
+# - Check SHOW statement;
+
+--echo
+--echo
+
+SHOW TRIGGERS|
+
+--echo
+
+use mysqltest2|
+
+--echo
+
+SHOW TRIGGERS|
+
+use mysqltest1|
+
+# - Check INFORMATION_SCHEMA;
+
+--echo
+--echo
+
+--replace_column 17 CREATED
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+
+--echo
+--replace_column 17 CREATED
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+
+--echo
+--replace_column 17 CREATED
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+
+--echo
+--replace_column 17 CREATED
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+
+# - Initialize the used variables (actual values don't matter);
+
+--echo
+--echo
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+# - Execute the triggers;
+
+--echo
+--echo
+
+INSERT INTO t1 VALUES(1)|
+
+--echo
+--echo ---> Log:
+SELECT msg FROM log|
+
+--echo
+SELECT
+ COLLATION(@a1) AS ca1,
+ COLLATION(@a2) AS ca2,
+ COLLATION(@a3) AS ca3,
+ COLLATION(@b1) AS cb1,
+ COLLATION(@b2) AS cb2,
+ COLLATION(@b3) AS cb3|
+
+--echo
+DELETE FROM log|
+
+--echo
+--echo
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+--echo
+--echo ---> Log:
+SELECT msg FROM mysqltest2.log|
+
+--echo
+SELECT
+ COLLATION(@a1) AS ca1,
+ COLLATION(@a2) AS ca2,
+ COLLATION(@a3) AS ca3,
+ COLLATION(@b1) AS cb1,
+ COLLATION(@b2) AS cb2,
+ COLLATION(@b3) AS cb3|
+
+--echo
+DELETE FROM mysqltest2.log|
diff --git a/mysql-test/include/ddl_i18n.check_views.inc b/mysql-test/include/ddl_i18n.check_views.inc
new file mode 100644
index 00000000000..727f3506e4a
--- /dev/null
+++ b/mysql-test/include/ddl_i18n.check_views.inc
@@ -0,0 +1,32 @@
+# - Check SHOW CREATE statement;
+
+--echo
+--echo
+
+SHOW CREATE VIEW v1|
+
+--echo
+
+SHOW CREATE VIEW v2|
+
+# - Check INFORMATION_SCHEMA;
+
+--echo
+--echo
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+
+--echo
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+
+# - Execute the views;
+
+--echo
+--echo
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+
+--echo
+
+SELECT COLLATION(c1) FROM v2|
diff --git a/mysql-test/include/have_cp1251.inc b/mysql-test/include/have_cp1251.inc
new file mode 100644
index 00000000000..2d5f1b3b529
--- /dev/null
+++ b/mysql-test/include/have_cp1251.inc
@@ -0,0 +1,7 @@
+--require r/have_cp1251.require
+
+--disable_query_log
+
+SHOW COLLATION LIKE 'cp1251_general_ci';
+
+--enable_query_log
diff --git a/mysql-test/include/have_cp866.inc b/mysql-test/include/have_cp866.inc
new file mode 100644
index 00000000000..27390d87d51
--- /dev/null
+++ b/mysql-test/include/have_cp866.inc
@@ -0,0 +1,7 @@
+--require r/have_cp866.require
+
+--disable_query_log
+
+SHOW COLLATION LIKE 'cp866_general_ci';
+
+--enable_query_log
diff --git a/mysql-test/include/have_koi8r.inc b/mysql-test/include/have_koi8r.inc
new file mode 100644
index 00000000000..1fe163565ba
--- /dev/null
+++ b/mysql-test/include/have_koi8r.inc
@@ -0,0 +1,7 @@
+--require r/have_koi8r.require
+
+--disable_query_log
+
+SHOW COLLATION LIKE 'koi8r_general_ci';
+
+--enable_query_log
diff --git a/mysql-test/include/have_utf8.inc b/mysql-test/include/have_utf8.inc
new file mode 100644
index 00000000000..58b74f4072f
--- /dev/null
+++ b/mysql-test/include/have_utf8.inc
@@ -0,0 +1,7 @@
+--require r/have_utf8.require
+
+--disable_query_log
+
+SHOW COLLATION LIKE 'utf8_general_ci';
+
+--enable_query_log
diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl
index d82ed200a4b..a9d6d17d870 100644
--- a/mysql-test/lib/mtr_report.pl
+++ b/mysql-test/lib/mtr_report.pl
@@ -364,7 +364,12 @@ sub mtr_report_stats ($) {
# Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
# server coredump
/\QError in Log_event::read_log_event(): 'Sanity check failed', data_len: 258, event_type: 49\E/ or
- /Statement is not safe to log in statement format/
+ /Statement is not safe to log in statement format/ or
+
+ # Test case for Bug#14233 produces the following warnings:
+ /Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc/ or
+ /Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc/ or
+ /Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc/
)
{
next; # Skip these lines
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index e73b74ccac3..f85478d7f9e 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -980,8 +980,8 @@ Table Create Table
KEY `имÑ_индекÑа_в_кодировке_утф8_длиной_больше_чем_48` (`имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create view имÑ_вью_кодировке_утф8_длиной_больше_чем_42;
-View Create View
-имÑ_вью_кодировке_утф8_длиной_больше_чем_42 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `имÑ_вью_кодировке_утф8_длиной_больше_чем_42` AS select `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48`.`имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` AS `имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` from `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48`
+View Create View character_set_client collation_connection
+имÑ_вью_кодировке_утф8_длиной_больше_чем_42 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `имÑ_вью_кодировке_утф8_длиной_больше_чем_42` AS select `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48`.`имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` AS `имÑ_полÑ_в_кодировке_утф8_длиной_больше_чем_45` from `имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48` utf8 utf8_general_ci
create event имÑ_ÑобытиÑ_в_кодировке_утф8_длиной_больше_чем_48 on schedule every 2 year do select 1;
select EVENT_NAME from information_schema.events
where event_schema='test';
diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result
index b9a39b88ae5..c6ca7a3f008 100644
--- a/mysql-test/r/ctype_cp932_binlog_stm.result
+++ b/mysql-test/r/ctype_cp932_binlog_stm.result
@@ -40,9 +40,9 @@ IN ind DECIMAL(10,2))
BEGIN
INSERT INTO t4 VALUES (ins1, ins2, ind);
END
-master-bin.000001 783 Query 1 1002 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
-master-bin.000001 1002 Query 1 1091 use `test`; DROP PROCEDURE bug18293
-master-bin.000001 1091 Query 1 1170 use `test`; DROP TABLE t4
+master-bin.000001 783 Query 1 999 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
+master-bin.000001 999 Query 1 1085 use `test`; DROP PROCEDURE bug18293
+master-bin.000001 1085 Query 1 1161 use `test`; DROP TABLE t4
End of 5.0 tests
SHOW BINLOG EVENTS FROM 364;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result
new file mode 100644
index 00000000000..9e5931330e2
--- /dev/null
+++ b/mysql-test/r/ddl_i18n_koi8r.result
@@ -0,0 +1,2783 @@
+set names koi8r;
+
+-------------------------------------------------------------------
+Views
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+CREATE TABLE t1(ËÏÌ INT)|
+INSERT INTO t1 VALUES(1)|
+
+CREATE VIEW v1 AS
+SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2
+FROM t1|
+
+CREATE VIEW v2 AS SELECT _utf8'теÑÑ‚' as c1|
+
+
+
+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 _koi8r'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_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 _utf8'теÑÑ‚' AS `c1` koi8r koi8r_general_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NONE YES root@localhost DEFINER koi8r koi8r_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v2 SELECT 'ÔÅÓÔ' as c1 NONE NO root@localhost DEFINER koi8r koi8r_general_ci
+
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+COLLATION(c1) COLLATION(c2)
+koi8r_general_ci binary
+
+SELECT COLLATION(c1) FROM v2|
+COLLATION(c1)
+utf8_general_ci
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+use mysqltest1|
+set names koi8r|
+
+
+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 _koi8r'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_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 _utf8'теÑÑ‚' AS `c1` koi8r koi8r_general_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NONE YES root@localhost DEFINER koi8r koi8r_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v2 SELECT 'ÔÅÓÔ' as c1 NONE NO root@localhost DEFINER koi8r koi8r_general_ci
+
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+COLLATION(c1) COLLATION(c2)
+koi8r_general_ci binary
+
+SELECT COLLATION(c1) FROM v2|
+COLLATION(c1)
+utf8_general_ci
+
+---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
+
+
+DROP DATABASE mysqltest1|
+
+
+---> Restoring mysqltest1...
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+use mysqltest1|
+set names koi8r|
+
+
+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 _koi8r'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` koi8r koi8r_general_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 _utf8'теÑÑ‚' AS `c1` koi8r koi8r_general_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v1 select 'ÔÅÓÔ' AS `c1`,`t1`.`ËÏÌ` AS `c2` from `t1` NONE YES root@localhost DEFINER koi8r koi8r_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v2 select 'ÔÅÓÔ' AS `c1` NONE NO root@localhost DEFINER koi8r koi8r_general_ci
+
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+COLLATION(c1) COLLATION(c2)
+koi8r_general_ci binary
+
+SELECT COLLATION(c1) FROM v2|
+COLLATION(c1)
+utf8_general_ci
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+
+-------------------------------------------------------------------
+Stored procedures/functions
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+
+CREATE PROCEDURE p1(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END|
+
+CREATE PROCEDURE p2(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END|
+
+CREATE PROCEDURE mysqltest2.p3(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END|
+
+CREATE PROCEDURE mysqltest2.p4(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END|
+
+
+SHOW CREATE PROCEDURE p1|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE p2|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p2 CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p3|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p3 CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p4|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p4 CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW PROCEDURE STATUS LIKE 'p1'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p1 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p2'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p2 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p3'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p3 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p4'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p4 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p1 NULL mysqltest1 p1 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p2 NULL mysqltest1 p2 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p3 NULL mysqltest2 p3 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p4 NULL mysqltest2 p4 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SET @a = '1'|
+SET @b = '2'|
+
+
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+set names koi8r|
+
+
+SHOW CREATE PROCEDURE p1|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE p2|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p2 CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p3|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p3 CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p4|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p4 CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW PROCEDURE STATUS LIKE 'p1'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p1 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p2'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p2 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p3'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p3 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p4'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p4 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p1 NULL mysqltest1 p1 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p2 NULL mysqltest1 p2 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p3 NULL mysqltest2 p3 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p4 NULL mysqltest2 p4 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SET @a = '1'|
+SET @b = '2'|
+
+
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+---> Dump of mysqltest1
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest1`;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p1`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p2`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
+
+---> Dump of mysqltest2
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest2`;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p3`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p4`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
+
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+---> Restoring mysqltest1...
+---> Restoring mysqltest2...
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+set names koi8r|
+
+
+SHOW CREATE PROCEDURE p1|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE p2|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p2 CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p3|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p3 CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`(
+INOUT ÐÁÒÁÍ1 CHAR(10),
+OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p4|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p4 CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`(
+INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+COLLATION(_utf8 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW PROCEDURE STATUS LIKE 'p1'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p1 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p2'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p2 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p3'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p3 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p4'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p4 PROCEDURE root@localhost MODIFIED CREATED DEFINER koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p1 NULL mysqltest1 p1 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p2 NULL mysqltest1 p2 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p3 NULL mysqltest2 p3 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p4 NULL mysqltest2 p4 PROCEDURE NULL SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION(ÐÁÒÁÍ1) AS c2,
+COLLATION(ÐÁÒÁÍ2) AS c3;
+SELECT
+COLLATION('ÔÅËÓÔ') AS c4,
+COLLATION( 'ÔÅËÓÔ') AS c5,
+COLLATION( 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET ÐÁÒÁÍ1 = 'a';
+SET ÐÁÒÁÍ2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SET @a = '1'|
+SET @b = '2'|
+
+
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+-------------------------------------------------------------------
+Triggers
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+CREATE TABLE t1(c INT)|
+CREATE TABLE mysqltest2.t1(c INT)|
+CREATE TABLE log(msg VARCHAR(255))|
+CREATE TABLE mysqltest2.log(msg VARCHAR(255))|
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END|
+
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END|
+
+CREATE TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END|
+
+CREATE TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END|
+
+
+
+SHOW CREATE TRIGGER trg1|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg1 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER trg2|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg2 CREATE DEFINER=`root`@`localhost` TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg3|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg3 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg4|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg4 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END BEFORE NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+trg2 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END AFTER NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+use mysqltest2|
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg3 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END BEFORE NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+trg4 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END AFTER NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+use mysqltest1|
+
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg1 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg2 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg3 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg4 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+
+INSERT INTO t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM log|
+msg
+utf8_unicode_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+utf8_general_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM log|
+
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM mysqltest2.log|
+msg
+utf8_unicode_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+utf8_general_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM mysqltest2.log|
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+ALTER TABLE t1 ADD COLUMN fake INT|
+ALTER TABLE t1 DROP COLUMN fake|
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+set names koi8r|
+use mysqltest1|
+
+
+SHOW CREATE TRIGGER trg1|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg1 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER trg2|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg2 CREATE DEFINER=`root`@`localhost` TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg3|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg3 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg4|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg4 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END BEFORE NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+trg2 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END AFTER NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+use mysqltest2|
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg3 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END BEFORE NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+trg4 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END AFTER NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+use mysqltest1|
+
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg1 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg2 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg3 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg4 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+
+INSERT INTO t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM log|
+msg
+utf8_unicode_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+utf8_general_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM log|
+
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM mysqltest2.log|
+msg
+utf8_unicode_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+utf8_general_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM mysqltest2.log|
+
+---> Dump of mysqltest1
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest1`;
+CREATE TABLE `log` (
+ `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TABLE `t1` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+INSERT INTO `t1` VALUES (1),(0),(1);
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
+
+---> Dump of mysqltest2
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest2`;
+CREATE TABLE `log` (
+ `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TABLE `t1` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+INSERT INTO `t1` VALUES (1),(0),(1);
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = koi8r */ ;
+/*!50003 SET character_set_results = koi8r */ ;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
+
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+---> Restoring mysqltest1...
+---> Restoring mysqltest2...
+ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest1.t1 DROP COLUMN fake|
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+set names koi8r|
+use mysqltest1|
+
+
+SHOW CREATE TRIGGER trg1|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg1 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER trg2|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg2 CREATE DEFINER=`root`@`localhost` TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg3|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg3 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = _koi8r 'ÔÅËÓÔ';
+SET @a2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg4|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg4 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = _koi8r 'ÔÅËÓÔ';
+SET @b2 = _utf8 'текÑÑ‚';
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END BEFORE NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+trg2 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END AFTER NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+use mysqltest2|
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg3 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END BEFORE NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+trg4 INSERT t1 BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END AFTER NULL root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+use mysqltest1|
+
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg1 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg2 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg3 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'ÔÅËÓÔ';
+SET @a1 = 'ÔÅËÓÔ';
+SET @a2 = 'ÔÅËÓÔ';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg4 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(COLLATION( 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'ÔÅËÓÔ';
+SET @b1 = 'ÔÅËÓÔ';
+SET @b2 = 'ÔÅËÓÔ';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+
+INSERT INTO t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM log|
+msg
+utf8_unicode_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+utf8_general_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM log|
+
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM mysqltest2.log|
+msg
+utf8_unicode_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+utf8_general_ci
+koi8r_general_ci
+koi8r_general_ci
+utf8_general_ci
+koi8r_general_ci
+koi8r
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM mysqltest2.log|
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+-------------------------------------------------------------------
+Events
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+
+CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+CREATE EVENT ev2 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+CREATE EVENT mysqltest2.ev3 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+CREATE EVENT mysqltest2.ev4 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+
+
+SHOW CREATE EVENT ev1|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT ev2|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev2 SYSTEM CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW EVENTS LIKE 'ev1'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev2'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev2 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev3'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+SHOW EVENTS LIKE 'ev4'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev1 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev2 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev3 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev4 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+set names koi8r|
+
+
+SHOW CREATE EVENT ev1|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT ev2|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev2 SYSTEM CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW EVENTS LIKE 'ev1'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev2'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev2 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev3'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+SHOW EVENTS LIKE 'ev4'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev1 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev2 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev3 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev4 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+---> Dump of mysqltest1
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest1`;
+/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
+DELIMITER ;;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = koi8r */ ;;
+/*!50003 SET character_set_results = koi8r */ ;;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = koi8r */ ;;
+/*!50003 SET character_set_results = koi8r */ ;;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;
+/*!50106 SET TIME_ZONE= @save_time_zone */ ;
+
+---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
+
+---> Dump of mysqltest2
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest2`;
+/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
+DELIMITER ;;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = koi8r */ ;;
+/*!50003 SET character_set_results = koi8r */ ;;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = koi8r */ ;;
+/*!50003 SET character_set_results = koi8r */ ;;
+/*!50003 SET collation_connection = koi8r_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev4` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;
+/*!50106 SET TIME_ZONE= @save_time_zone */ ;
+
+---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql
+
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+---> Restoring mysqltest1...
+---> Restoring mysqltest2...
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+set names koi8r|
+
+
+SHOW CREATE EVENT ev1|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT ev2|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev2 SYSTEM CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+COLLATION(_utf8 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END koi8r koi8r_general_ci utf8_unicode_ci
+
+
+SHOW EVENTS LIKE 'ev1'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev2'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev2 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev3'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+SHOW EVENTS LIKE 'ev4'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev1 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10);
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev2 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev3 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev4 root@localhost SYSTEM SQL BEGIN
+DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(ÐÅÒÅÍ1) AS c1,
+COLLATION('ÔÅËÓÔ') AS c2,
+COLLATION( 'ÔÅËÓÔ') AS c3,
+COLLATION( 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci
+
+-------------------------------------------------------------------
+DDL statements within stored routine.
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+
+CREATE PROCEDURE p1()
+BEGIN
+CREATE TABLE t1(col1 VARCHAR(10));
+SHOW CREATE TABLE t1;
+END|
+
+CREATE PROCEDURE mysqltest2.p2()
+BEGIN
+CREATE TABLE t2(col1 VARCHAR(10));
+SHOW CREATE TABLE t2;
+END|
+
+CALL p1()|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+SHOW CREATE TABLE t1|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+
+CALL mysqltest2.p2()|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+SHOW CREATE TABLE mysqltest2.t2|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+ALTER DATABASE mysqltest1 COLLATE cp1251_general_cs|
+ALTER DATABASE mysqltest2 COLLATE cp1251_general_cs|
+DROP TABLE t1|
+DROP TABLE mysqltest2.t2|
+
+CALL p1()|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+SHOW CREATE TABLE t1|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+
+CALL mysqltest2.p2()|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+SHOW CREATE TABLE mysqltest2.t2|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result
new file mode 100644
index 00000000000..d74d014d755
--- /dev/null
+++ b/mysql-test/r/ddl_i18n_utf8.result
@@ -0,0 +1,2783 @@
+set names utf8;
+
+-------------------------------------------------------------------
+Views
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+CREATE TABLE t1(кол INT)|
+INSERT INTO t1 VALUES(1)|
+
+CREATE VIEW v1 AS
+SELECT 'теÑÑ‚' AS c1, кол AS c2
+FROM t1|
+
+CREATE VIEW v2 AS SELECT _koi8r'ÔÅÓÔ' as c1|
+
+
+
+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 _utf8'теÑÑ‚' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_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 _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 NONE YES root@localhost DEFINER utf8 utf8_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v2 SELECT 'теÑÑ‚' as c1 NONE NO root@localhost DEFINER utf8 utf8_general_ci
+
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+COLLATION(c1) COLLATION(c2)
+utf8_general_ci binary
+
+SELECT COLLATION(c1) FROM v2|
+COLLATION(c1)
+koi8r_general_ci
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+use mysqltest1|
+set names utf8|
+
+
+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 _utf8'теÑÑ‚' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_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 _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 NONE YES root@localhost DEFINER utf8 utf8_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v2 SELECT 'теÑÑ‚' as c1 NONE NO root@localhost DEFINER utf8 utf8_general_ci
+
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+COLLATION(c1) COLLATION(c2)
+utf8_general_ci binary
+
+SELECT COLLATION(c1) FROM v2|
+COLLATION(c1)
+koi8r_general_ci
+
+---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
+
+
+DROP DATABASE mysqltest1|
+
+
+---> Restoring mysqltest1...
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+use mysqltest1|
+set names utf8|
+
+
+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 _utf8'теÑÑ‚' AS `c1`,`t1`.`кол` AS `c2` from `t1` utf8 utf8_general_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 _koi8r'ÔÅÓÔ' AS `c1` utf8 utf8_general_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v1 select 'теÑÑ‚' AS `c1`,`t1`.`кол` AS `c2` from `t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v2 select 'теÑÑ‚' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
+
+
+SELECT COLLATION(c1), COLLATION(c2) FROM v1|
+COLLATION(c1) COLLATION(c2)
+utf8_general_ci binary
+
+SELECT COLLATION(c1) FROM v2|
+COLLATION(c1)
+koi8r_general_ci
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+
+-------------------------------------------------------------------
+Stored procedures/functions
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+
+CREATE PROCEDURE p1(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END|
+
+CREATE PROCEDURE p2(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END|
+
+CREATE PROCEDURE mysqltest2.p3(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END|
+
+CREATE PROCEDURE mysqltest2.p4(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END|
+
+
+SHOW CREATE PROCEDURE p1|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE p2|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p2 CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p3|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p3 CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p4|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p4 CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW PROCEDURE STATUS LIKE 'p1'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p1 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p2'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p2 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p3'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p3 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p4'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p4 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p1 NULL mysqltest1 p1 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p2 NULL mysqltest1 p2 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p3 NULL mysqltest2 p3 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p4 NULL mysqltest2 p4 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+
+SET @a = '1'|
+SET @b = '2'|
+
+
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+set names utf8|
+
+
+SHOW CREATE PROCEDURE p1|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE p2|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p2 CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p3|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p3 CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p4|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p4 CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW PROCEDURE STATUS LIKE 'p1'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p1 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p2'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p2 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p3'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p3 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p4'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p4 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p1 NULL mysqltest1 p1 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p2 NULL mysqltest1 p2 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p3 NULL mysqltest2 p3 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p4 NULL mysqltest2 p4 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+
+SET @a = '1'|
+SET @b = '2'|
+
+
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+---> Dump of mysqltest1
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest1`;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p1`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p2`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
+
+---> Dump of mysqltest2
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest2`;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p3`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `p4`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
+
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+---> Restoring mysqltest1...
+---> Restoring mysqltest2...
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+set names utf8|
+
+
+SHOW CREATE PROCEDURE p1|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE p2|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p2 CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p3|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p3 CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`(
+INOUT парам1 CHAR(10),
+OUT парам2 CHAR(10))
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE PROCEDURE mysqltest2.p4|
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p4 CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`(
+INOUT парам1 CHAR(10) CHARACTER SET utf8,
+OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION(_utf8 'текÑÑ‚') AS c5,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW PROCEDURE STATUS LIKE 'p1'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p1 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p2'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest1 p2 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p3'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p3 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW PROCEDURE STATUS LIKE 'p4'|
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p4 PROCEDURE root@localhost MODIFIED CREATED DEFINER utf8 utf8_general_ci utf8_unicode_ci
+
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p1 NULL mysqltest1 p1 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p2 NULL mysqltest1 p2 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p3 NULL mysqltest2 p3 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'|
+SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+p4 NULL mysqltest2 p4 PROCEDURE NULL SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION(парам1) AS c2,
+COLLATION(парам2) AS c3;
+SELECT
+COLLATION('текÑÑ‚') AS c4,
+COLLATION( 'текÑÑ‚') AS c5,
+COLLATION( 'текÑÑ‚') AS c6,
+@@collation_connection AS c7,
+@@character_set_client AS c8;
+SET парам1 = 'a';
+SET парам2 = 'b';
+END NULL NULL SQL NO CONTAINS SQL NULL DEFINER CREATED ALTERED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+
+SET @a = '1'|
+SET @b = '2'|
+
+
+CALL p1(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL p2(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+CALL mysqltest2.p3(@a, @b)|
+c1 c2 c3
+utf8_unicode_ci utf8_unicode_ci utf8_unicode_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_unicode_ci utf8_unicode_ci
+
+CALL mysqltest2.p4(@a, @b)|
+c1 c2 c3
+utf8_general_ci utf8_general_ci utf8_general_ci
+c4 c5 c6 c7 c8
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
+SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
+ca cb
+utf8_general_ci utf8_general_ci
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+-------------------------------------------------------------------
+Triggers
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+CREATE TABLE t1(c INT)|
+CREATE TABLE mysqltest2.t1(c INT)|
+CREATE TABLE log(msg VARCHAR(255))|
+CREATE TABLE mysqltest2.log(msg VARCHAR(255))|
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+CREATE TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+CREATE TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+
+
+SHOW CREATE TRIGGER trg1|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg1 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER trg2|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg2 CREATE DEFINER=`root`@`localhost` TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg3|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg3 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg4|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg4 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END BEFORE NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+trg2 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END AFTER NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+use mysqltest2|
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg3 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END BEFORE NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+trg4 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END AFTER NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+use mysqltest1|
+
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg1 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg2 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg3 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg4 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+
+INSERT INTO t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM log|
+msg
+utf8_unicode_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+utf8_general_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM log|
+
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM mysqltest2.log|
+msg
+utf8_unicode_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+utf8_general_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM mysqltest2.log|
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+ALTER TABLE t1 ADD COLUMN fake INT|
+ALTER TABLE t1 DROP COLUMN fake|
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+set names utf8|
+use mysqltest1|
+
+
+SHOW CREATE TRIGGER trg1|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg1 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER trg2|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg2 CREATE DEFINER=`root`@`localhost` TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg3|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg3 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg4|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg4 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END BEFORE NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+trg2 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END AFTER NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+use mysqltest2|
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg3 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END BEFORE NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+trg4 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END AFTER NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+use mysqltest1|
+
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg1 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg2 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg3 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg4 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+
+INSERT INTO t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM log|
+msg
+utf8_unicode_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+utf8_general_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM log|
+
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM mysqltest2.log|
+msg
+utf8_unicode_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+utf8_general_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM mysqltest2.log|
+
+---> Dump of mysqltest1
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest1`;
+CREATE TABLE `log` (
+ `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TABLE `t1` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+INSERT INTO `t1` VALUES (1),(0),(1);
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
+
+---> Dump of mysqltest2
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest2`;
+CREATE TABLE `log` (
+ `msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TABLE `t1` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+INSERT INTO `t1` VALUES (1),(0),(1);
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+
+---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
+
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+---> Restoring mysqltest1...
+---> Restoring mysqltest2...
+ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest1.t1 DROP COLUMN fake|
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+set names utf8|
+use mysqltest1|
+
+
+SHOW CREATE TRIGGER trg1|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg1 CREATE DEFINER=`root`@`localhost` TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER trg2|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg2 CREATE DEFINER=`root`@`localhost` TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg3|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg3 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = _utf8 'текÑÑ‚';
+SET @a3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE TRIGGER mysqltest2.trg4|
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+trg4 CREATE DEFINER=`root`@`localhost` TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = _utf8 'текÑÑ‚';
+SET @b3 = _koi8r 'ÔÅËÓÔ';
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END BEFORE NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+trg2 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END AFTER NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+use mysqltest2|
+
+SHOW TRIGGERS|
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg3 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END BEFORE NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+trg4 INSERT t1 BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END AFTER NULL root@localhost utf8 utf8_general_ci utf8_unicode_ci
+use mysqltest1|
+
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg1'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg1 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg2'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 trg2 INSERT NULL mysqltest1 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg3'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg3 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10);
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @a1 = 'текÑÑ‚';
+SET @a2 = 'текÑÑ‚';
+SET @a3 = 'текÑÑ‚';
+END ROW BEFORE NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trg4'|
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 trg4 INSERT NULL mysqltest2 t1 0 NULL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+INSERT INTO log VALUES(COLLATION(перем1));
+INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(COLLATION( 'текÑÑ‚'));
+INSERT INTO log VALUES(@@collation_connection);
+INSERT INTO log VALUES(@@character_set_client);
+SET @b1 = 'текÑÑ‚';
+SET @b2 = 'текÑÑ‚';
+SET @b3 = 'текÑÑ‚';
+END ROW AFTER NULL NULL OLD NEW CREATED root@localhost utf8 utf8_general_ci utf8_unicode_ci
+
+
+SET @a1 = '1'|
+SET @a2 = '1'|
+SET @a3 = '1'|
+SET @b1 = '2'|
+SET @b2 = '2'|
+SET @b3 = '2'|
+
+
+INSERT INTO t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM log|
+msg
+utf8_unicode_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+utf8_general_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM log|
+
+
+INSERT INTO mysqltest2.t1 VALUES(1)|
+
+---> Log:
+SELECT msg FROM mysqltest2.log|
+msg
+utf8_unicode_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+utf8_general_ci
+utf8_general_ci
+utf8_general_ci
+koi8r_general_ci
+utf8_general_ci
+utf8
+
+SELECT
+COLLATION(@a1) AS ca1,
+COLLATION(@a2) AS ca2,
+COLLATION(@a3) AS ca3,
+COLLATION(@b1) AS cb1,
+COLLATION(@b2) AS cb2,
+COLLATION(@b3) AS cb3|
+ca1 ca2 ca3 cb1 cb2 cb3
+utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
+
+DELETE FROM mysqltest2.log|
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+-------------------------------------------------------------------
+Events
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+
+CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+CREATE EVENT ev2 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+CREATE EVENT mysqltest2.ev3 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+CREATE EVENT mysqltest2.ev4 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END|
+
+
+
+SHOW CREATE EVENT ev1|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT ev2|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev2 SYSTEM CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW EVENTS LIKE 'ev1'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev2'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev2 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev3'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+SHOW EVENTS LIKE 'ev4'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev1 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev2 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev3 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev4 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+---> connection: con2
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+set names utf8|
+
+
+SHOW CREATE EVENT ev1|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT ev2|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev2 SYSTEM CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW EVENTS LIKE 'ev1'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev2'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev2 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev3'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+SHOW EVENTS LIKE 'ev4'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev1 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev2 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev3 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev4 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+---> Dump of mysqltest1
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest1`;
+/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
+DELIMITER ;;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = utf8 */ ;;
+/*!50003 SET character_set_results = utf8 */ ;;
+/*!50003 SET collation_connection = utf8_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;;
+ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = utf8 */ ;;
+/*!50003 SET character_set_results = utf8 */ ;;
+/*!50003 SET collation_connection = utf8_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;
+/*!50106 SET TIME_ZONE= @save_time_zone */ ;
+
+---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
+
+---> Dump of mysqltest2
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
+
+USE `mysqltest2`;
+/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
+DELIMITER ;;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = utf8 */ ;;
+/*!50003 SET character_set_results = utf8 */ ;;
+/*!50003 SET collation_connection = utf8_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;;
+ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
+/*!50003 SET character_set_client = utf8 */ ;;
+/*!50003 SET character_set_results = utf8 */ ;;
+/*!50003 SET collation_connection = utf8_general_ci */ ;;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
+/*!50003 SET sql_mode = '' */ ;;
+/*!50003 SET @saved_time_zone = @@time_zone */ ;;
+/*!50003 SET time_zone = 'SYSTEM' */ ;;
+/*!50106 CREATE EVENT `ev4` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END */ ;;
+/*!50003 SET time_zone = @saved_time_zone */ ;;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;;
+/*!50003 SET character_set_client = @saved_cs_client */ ;;
+/*!50003 SET character_set_results = @saved_cs_results */ ;;
+/*!50003 SET collation_connection = @saved_col_connection */ ;;
+ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+DELIMITER ;
+/*!50106 SET TIME_ZONE= @save_time_zone */ ;
+
+---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql
+
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+---> Restoring mysqltest1...
+---> Restoring mysqltest2...
+
+---> connection: con3
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+set names utf8|
+
+
+SHOW CREATE EVENT ev1|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT ev2|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev2 SYSTEM CREATE EVENT `ev2` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW CREATE EVENT mysqltest2.ev3|
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ev3 SYSTEM CREATE EVENT `ev3` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION(_utf8 'текÑÑ‚') AS c3,
+COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END utf8 utf8_general_ci utf8_unicode_ci
+
+
+SHOW EVENTS LIKE 'ev1'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev2'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+mysqltest1 ev2 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SHOW EVENTS LIKE 'ev3'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+SHOW EVENTS LIKE 'ev4'|
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev1'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev1 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10);
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev2'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest1 ev2 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev3'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev3 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE event_name = 'ev4'|
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest2 ev4 root@localhost SYSTEM SQL BEGIN
+DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+SELECT
+COLLATION(перем1) AS c1,
+COLLATION('текÑÑ‚') AS c2,
+COLLATION( 'текÑÑ‚') AS c3,
+COLLATION( 'текÑÑ‚') AS c4,
+@@collation_connection AS c5,
+@@character_set_client AS c6;
+END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci
+
+-------------------------------------------------------------------
+DDL statements within stored routine.
+-------------------------------------------------------------------
+
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+use mysqltest1|
+
+CREATE PROCEDURE p1()
+BEGIN
+CREATE TABLE t1(col1 VARCHAR(10));
+SHOW CREATE TABLE t1;
+END|
+
+CREATE PROCEDURE mysqltest2.p2()
+BEGIN
+CREATE TABLE t2(col1 VARCHAR(10));
+SHOW CREATE TABLE t2;
+END|
+
+CALL p1()|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+SHOW CREATE TABLE t1|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+
+CALL mysqltest2.p2()|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+SHOW CREATE TABLE mysqltest2.t2|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+
+ALTER DATABASE mysqltest1 COLLATE cp1251_general_cs|
+ALTER DATABASE mysqltest2 COLLATE cp1251_general_cs|
+DROP TABLE t1|
+DROP TABLE mysqltest2.t2|
+
+CALL p1()|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+SHOW CREATE TABLE t1|
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+
+CALL mysqltest2.p2()|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+SHOW CREATE TABLE mysqltest2.t2|
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
+
+---> connection: default
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
diff --git a/mysql-test/r/events.result b/mysql-test/r/events.result
index 0b1cd67f559..579f5907882 100644
--- a/mysql-test/r/events.result
+++ b/mysql-test/r/events.result
@@ -122,82 +122,105 @@ drop table t_event3;
set names utf8;
CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1;
SHOW CREATE EVENT root6;
-Event sql_mode time_zone Create Event
-root6 SYSTEM CREATE EVENT `root6` ON SCHEDULE EVERY '10:20' MINUTE_SECOND STARTS '#' ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root6 SYSTEM CREATE EVENT `root6` ON SCHEDULE EVERY '10:20' MINUTE_SECOND STARTS '#' ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root7 on schedule every 2 year do select 1;
SHOW CREATE EVENT root7;
-Event sql_mode time_zone Create Event
-root7 SYSTEM CREATE EVENT `root7` ON SCHEDULE EVERY 2 YEAR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root7 SYSTEM CREATE EVENT `root7` ON SCHEDULE EVERY 2 YEAR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root8 on schedule every '2:5' year_month do select 1;
SHOW CREATE EVENT root8;
-Event sql_mode time_zone Create Event
-root8 SYSTEM CREATE EVENT `root8` ON SCHEDULE EVERY '2-5' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root8 SYSTEM CREATE EVENT `root8` ON SCHEDULE EVERY '2-5' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root8_1 on schedule every '2:15' year_month do select 1;
SHOW CREATE EVENT root8_1;
-Event sql_mode time_zone Create Event
-root8_1 SYSTEM CREATE EVENT `root8_1` ON SCHEDULE EVERY '3-3' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root8_1 SYSTEM CREATE EVENT `root8_1` ON SCHEDULE EVERY '3-3' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1;
SHOW CREATE EVENT root9;
-Event sql_mode time_zone Create Event
-root9 SYSTEM CREATE EVENT `root9` ON SCHEDULE EVERY 2 WEEK STARTS '#' ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root9 SYSTEM CREATE EVENT `root9` ON SCHEDULE EVERY 2 WEEK STARTS '#' ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root10 on schedule every '20:5' day_hour do select 1;
SHOW CREATE EVENT root10;
-Event sql_mode time_zone Create Event
-root10 SYSTEM CREATE EVENT `root10` ON SCHEDULE EVERY '20 5' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root10 SYSTEM CREATE EVENT `root10` ON SCHEDULE EVERY '20 5' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root11 on schedule every '20:25' day_hour do select 1;
SHOW CREATE EVENT root11;
-Event sql_mode time_zone Create Event
-root11 SYSTEM CREATE EVENT `root11` ON SCHEDULE EVERY '21 1' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root11 SYSTEM CREATE EVENT `root11` ON SCHEDULE EVERY '21 1' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root12 on schedule every '20:25' hour_minute do select 1;
SHOW CREATE EVENT root12;
-Event sql_mode time_zone Create Event
-root12 SYSTEM CREATE EVENT `root12` ON SCHEDULE EVERY '20:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root12 SYSTEM CREATE EVENT `root12` ON SCHEDULE EVERY '20:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root13 on schedule every '25:25' hour_minute do select 1;
SHOW CREATE EVENT root13;
-Event sql_mode time_zone Create Event
-root13 SYSTEM CREATE EVENT `root13` ON SCHEDULE EVERY '25:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root13 SYSTEM CREATE EVENT `root13` ON SCHEDULE EVERY '25:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root13_1 on schedule every '11:65' hour_minute do select 1;
SHOW CREATE EVENT root13_1;
-Event sql_mode time_zone Create Event
-root13_1 SYSTEM CREATE EVENT `root13_1` ON SCHEDULE EVERY '12:5' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root13_1 SYSTEM CREATE EVENT `root13_1` ON SCHEDULE EVERY '12:5' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root14 on schedule every '35:35' minute_second do select 1;
SHOW CREATE EVENT root14;
-Event sql_mode time_zone Create Event
-root14 SYSTEM CREATE EVENT `root14` ON SCHEDULE EVERY '35:35' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root14 SYSTEM CREATE EVENT `root14` ON SCHEDULE EVERY '35:35' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root15 on schedule every '35:66' minute_second do select 1;
SHOW CREATE EVENT root15;
-Event sql_mode time_zone Create Event
-root15 SYSTEM CREATE EVENT `root15` ON SCHEDULE EVERY '36:6' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root15 SYSTEM CREATE EVENT `root15` ON SCHEDULE EVERY '36:6' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root16 on schedule every '35:56' day_minute do select 1;
SHOW CREATE EVENT root16;
-Event sql_mode time_zone Create Event
-root16 SYSTEM CREATE EVENT `root16` ON SCHEDULE EVERY '1 11:56' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root16 SYSTEM CREATE EVENT `root16` ON SCHEDULE EVERY '1 11:56' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root17 on schedule every '35:12:45' day_minute do select 1;
SHOW CREATE EVENT root17;
-Event sql_mode time_zone Create Event
-root17 SYSTEM CREATE EVENT `root17` ON SCHEDULE EVERY '35 12:45' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root17 SYSTEM CREATE EVENT `root17` ON SCHEDULE EVERY '35 12:45' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root17_1 on schedule every '35:25:65' day_minute do select 1;
SHOW CREATE EVENT root17_1;
-Event sql_mode time_zone Create Event
-root17_1 SYSTEM CREATE EVENT `root17_1` ON SCHEDULE EVERY '36 2:5' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root17_1 SYSTEM CREATE EVENT `root17_1` ON SCHEDULE EVERY '36 2:5' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root18 on schedule every '35:12:45' hour_second do select 1;
SHOW CREATE EVENT root18;
-Event sql_mode time_zone Create Event
-root18 SYSTEM CREATE EVENT `root18` ON SCHEDULE EVERY '35:12:45' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root18 SYSTEM CREATE EVENT `root18` ON SCHEDULE EVERY '35:12:45' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root19 on schedule every '15:59:85' hour_second do select 1;
SHOW CREATE EVENT root19;
-Event sql_mode time_zone Create Event
-root19 SYSTEM CREATE EVENT `root19` ON SCHEDULE EVERY '16:0:25' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root19 SYSTEM CREATE EVENT `root19` ON SCHEDULE EVERY '16:0:25' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
create event root20 on schedule every '50:20:12:45' day_second do select 1;
SHOW CREATE EVENT root20;
-Event sql_mode time_zone Create Event
-root20 SYSTEM CREATE EVENT `root20` ON SCHEDULE EVERY '50 20:12:45' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+root20 SYSTEM CREATE EVENT `root20` ON SCHEDULE EVERY '50 20:12:45' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
set names cp1251;
create event ðóóò21 on schedule every '50:23:59:95' day_second COMMENT 'òîâà å 1251 êîìåíòàð' do select 1;
SHOW CREATE EVENT ðóóò21;
-Event sql_mode time_zone Create Event
-ðóóò21 SYSTEM CREATE EVENT `ðóóò21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'òîâà å 1251 êîìåíòàð' DO select 1
-insert into mysql.event (db, name, body, definer, interval_value, interval_field, originator) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND", 1);
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ðóóò21 SYSTEM CREATE EVENT `руут21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'това е 1251 коментар' DO select 1 cp1251 cp1251_general_ci latin1_swedish_ci
+insert into mysql.event (
+db,
+name,
+body,
+definer,
+interval_value,
+interval_field,
+originator,
+character_set_client,
+collation_connection,
+db_collation,
+body_utf8)
+values (
+database(),
+"root22",
+"select 1",
+user(),
+100,
+"SECOND_MICROSECOND",
+1,
+'utf8',
+'utf8_general_ci',
+'utf8_general_ci',
+'select 1');
show create event root22;
ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
SHOW EVENTS;
@@ -231,8 +254,8 @@ Create a test event. Only event metadata is relevant,
the actual schedule and body are not.
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
Try to alter mysql.event: the server should fail to load
event information after mysql.event was tampered with.
@@ -241,14 +264,14 @@ works as before
ALTER TABLE mysql.event ADD dummy INT;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT event_name FROM INFORMATION_SCHEMA.events;
event_name
intact_check
SHOW CREATE EVENT intact_check;
-Event sql_mode time_zone Create Event
-intact_check SYSTEM CREATE EVENT `intact_check` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO SELECT "nothing"
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+intact_check SYSTEM CREATE EVENT `intact_check` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO SELECT "nothing" latin1 latin1_swedish_ci latin1_swedish_ci
DROP EVENT no_such_event;
ERROR HY000: Unknown event 'no_such_event'
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
@@ -330,7 +353,7 @@ ERROR HY000: Cannot load from mysql.event. The table is probably corrupted
DROP EVENT no_such_event;
ERROR HY000: Unknown event 'no_such_event'
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
-ERROR HY000: Column count of mysql.event is wrong. Expected 18, found 16. The table is probably corrupted
+ERROR HY000: Column count of mysql.event is wrong. Expected 22, found 20. The table is probably corrupted
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
ERROR HY000: Unknown event 'intact_check_1'
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
@@ -400,7 +423,7 @@ Restore the original table.
CREATE TABLE mysql.event like event_like;
DROP TABLE event_like;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5;
select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event;
db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion
@@ -512,7 +535,7 @@ ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SHOW EVENTS FROM ``;
ERROR 42000: Incorrect database name ''
SHOW EVENTS FROM `events\\test`;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
LOCK TABLES mode.
@@ -520,8 +543,8 @@ create table t1 (a int);
create event e1 on schedule every 10 hour do select 1;
lock table t1 read;
show create event e1;
-Event sql_mode time_zone Create Event
-e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
select event_name from information_schema.events;
event_name
e1
@@ -538,8 +561,8 @@ ERROR HY000: Table 'event' was not locked with LOCK TABLES
unlock tables;
lock table t1 write;
show create event e1;
-Event sql_mode time_zone Create Event
-e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
select event_name from information_schema.events;
event_name
e1
@@ -556,8 +579,8 @@ ERROR HY000: Table 'event' was not locked with LOCK TABLES
unlock tables;
lock table t1 read, mysql.event read;
show create event e1;
-Event sql_mode time_zone Create Event
-e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
select event_name from information_schema.events;
event_name
e1
@@ -574,8 +597,8 @@ ERROR HY000: Table 'event' was locked with a READ lock and can't be updated
unlock tables;
lock table t1 write, mysql.event read;
show create event e1;
-Event sql_mode time_zone Create Event
-e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
select event_name from information_schema.events;
event_name
e1
@@ -596,8 +619,8 @@ lock table t1 write, mysql.event write;
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
lock table mysql.event write;
show create event e1;
-Event sql_mode time_zone Create Event
-e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e1 SYSTEM CREATE EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8 utf8_general_ci latin1_swedish_ci
select event_name from information_schema.events;
event_name
e1
diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result
index fae530f556b..fb66b96d816 100644
--- a/mysql-test/r/events_bugs.result
+++ b/mysql-test/r/events_bugs.result
@@ -33,7 +33,7 @@ create event e_55 on schedule at 20000101000000 do drop table t;
Warnings:
Note 1584 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
show events;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'starts 10000101000000 do drop table t' at line 1
create event e_55 on schedule at 20200101000000 ends 10000101000000 do drop table t;
@@ -389,30 +389,30 @@ SET TIME_ZONE= '+00:00';
SET TIMESTAMP= UNIX_TIMESTAMP('2005-12-31 23:58:59');
CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost +00:00 RECURRING NULL 1 DAY 2005-12-31 23:58:59 NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost +00:00 RECURRING NULL 1 DAY 2005-12-31 23:58:59 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SET TIME_ZONE= '-01:00';
ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:00';
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost -01:00 RECURRING NULL 1 DAY 2000-01-01 00:00:00 NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost -01:00 RECURRING NULL 1 DAY 2000-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SET TIME_ZONE= '+02:00';
ALTER EVENT e1 ON SCHEDULE AT '2000-01-02 00:00:00'
ON COMPLETION PRESERVE DISABLE;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost +02:00 ONE TIME 2000-01-02 00:00:00 NULL NULL NULL NULL DISABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost +02:00 ONE TIME 2000-01-02 00:00:00 NULL NULL NULL NULL DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SET TIME_ZONE= '-03:00';
ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY ENDS '2030-01-03 00:00:00'
ON COMPLETION PRESERVE DISABLE;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost -03:00 RECURRING NULL 1 DAY 2005-12-31 20:58:59 2030-01-03 00:00:00 DISABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost -03:00 RECURRING NULL 1 DAY 2005-12-31 20:58:59 2030-01-03 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SET TIME_ZONE= '+04:00';
ALTER EVENT e1 DO SELECT 2;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost -03:00 RECURRING NULL 1 DAY 2005-12-31 20:58:59 2030-01-03 00:00:00 ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost -03:00 RECURRING NULL 1 DAY 2005-12-31 20:58:59 2030-01-03 00:00:00 ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
DROP EVENT e1;
SET TIME_ZONE='+05:00';
CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO
@@ -426,24 +426,24 @@ SET TIME_ZONE='+00:00';
CREATE EVENT e3 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO
SELECT 1;
SELECT * FROM INFORMATION_SCHEMA.EVENTS ORDER BY event_name;
-EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR
-NULL events_test e1 root@localhost +05:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:58:59 2005-12-31 23:58:59 NULL 1
-NULL events_test e2 root@localhost -05:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:59:00 2005-12-31 23:59:00 NULL 1
-NULL events_test e3 root@localhost +00:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:59:01 2005-12-31 23:59:01 NULL 1
+EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL events_test e1 root@localhost +05:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:58:59 2005-12-31 23:58:59 NULL 1 latin1 latin1_swedish_ci latin1_swedish_ci
+NULL events_test e2 root@localhost -05:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:59:00 2005-12-31 23:59:00 NULL 1 latin1 latin1_swedish_ci latin1_swedish_ci
+NULL events_test e3 root@localhost +00:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:59:01 2005-12-31 23:59:01 NULL 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1
-events_test e2 root@localhost -05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1
-events_test e3 root@localhost +00:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e2 root@localhost -05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e3 root@localhost +00:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE EVENT e1;
-Event sql_mode time_zone Create Event
-e1 +05:00 CREATE EVENT `e1` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e1 +05:00 CREATE EVENT `e1` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE EVENT e2;
-Event sql_mode time_zone Create Event
-e2 -05:00 CREATE EVENT `e2` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e2 -05:00 CREATE EVENT `e2` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE EVENT e3;
-Event sql_mode time_zone Create Event
-e3 +00:00 CREATE EVENT `e3` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+e3 +00:00 CREATE EVENT `e3` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
The following should fail, and nothing should be altered.
ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
ENDS '1999-01-02 00:00:00';
@@ -474,10 +474,10 @@ SELECT 1;
Warnings:
Note 1584 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1
-events_test e2 root@localhost -05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1
-events_test e3 root@localhost +00:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e2 root@localhost -05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e3 root@localhost +00:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
The following should succeed giving a warning.
ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE;
@@ -510,15 +510,15 @@ CREATE EVENT e8 ON SCHEDULE AT '1999-01-01 00:00:00'
DO
SELECT 1;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test e1 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1
-events_test e2 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 NULL ENABLED 1
-events_test e3 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1
-events_test e4 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1
-events_test e5 root@localhost +00:00 ONE TIME 1999-01-01 00:00:00 NULL NULL NULL NULL DISABLED 1
-events_test e6 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 NULL ENABLED 1
-events_test e7 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1
-events_test e8 root@localhost +00:00 ONE TIME 1999-01-01 00:00:00 NULL NULL NULL NULL DISABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test e1 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e2 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e3 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e4 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e5 root@localhost +00:00 ONE TIME 1999-01-01 00:00:00 NULL NULL NULL NULL DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e6 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e7 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test e8 root@localhost +00:00 ONE TIME 1999-01-01 00:00:00 NULL NULL NULL NULL DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
DROP EVENT e8;
DROP EVENT e7;
DROP EVENT e6;
diff --git a/mysql-test/r/events_grant.result b/mysql-test/r/events_grant.result
index 278cc5956f5..1aadf7e11f4 100644
--- a/mysql-test/r/events_grant.result
+++ b/mysql-test/r/events_grant.result
@@ -2,8 +2,8 @@ CREATE DATABASE IF NOT EXISTS events_test;
use events_test;
CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
@@ -29,8 +29,8 @@ ERROR 42000: Access denied for user 'ev_test'@'localhost' to database 'events_te
USE events_test;
"We should see one event";
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT CONCAT("Let's create some new events from the name of ", USER());
CONCAT("Let's create some new events from the name of ", USER())
Let's create some new events from the name of ev_test@localhost
@@ -40,18 +40,18 @@ CREATE EVENT two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE CO
CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123;
"Now we should see 3 events:";
SHOW EVENTS;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1
-events_test three_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1
-events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test three_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
"This should show us only 2 events:";
SHOW EVENTS LIKE 't%event';
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-events_test three_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1
-events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+events_test three_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
"This should show us no events:";
SHOW EVENTS FROM test LIKE '%';
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
GRANT EVENT ON events_test2.* TO ev_test@localhost;
USE events_test2;
CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result
index 54b29353fb8..4f64d39ccc0 100644
--- a/mysql-test/r/func_in.result
+++ b/mysql-test/r/func_in.result
@@ -225,8 +225,8 @@ a
46
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45);
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci
SELECT * FROM v1;
a
44
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 4896210c19d..1529fe77ac4 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -745,10 +745,10 @@ drop table t1;
drop procedure if exists fn3;
create function fn3 () returns point deterministic return GeomFromText("point(1 1)");
show create function fn3;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
fn3 CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS point
DETERMINISTIC
-return GeomFromText("point(1 1)")
+return GeomFromText("point(1 1)") latin1 latin1_swedish_ci latin1_swedish_ci
select astext(fn3());
astext(fn3())
POINT(1 1)
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index a68cee5e52e..0d4dad39882 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -907,11 +907,11 @@ ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for tabl
SHOW CREATE TABLE mysqltest2.v_yn;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn'
SHOW CREATE TABLE mysqltest2.v_ny;
-View Create View
-v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn`
+View Create View character_set_client collation_connection
+v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` latin1 latin1_swedish_ci
SHOW CREATE VIEW mysqltest2.v_ny;
-View Create View
-v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn`
+View Create View character_set_client collation_connection
+v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` latin1 latin1_swedish_ci
SHOW CREATE TABLE mysqltest3.t_nn;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn'
SHOW CREATE VIEW mysqltest3.t_nn;
@@ -928,17 +928,17 @@ t_nn CREATE TABLE `t_nn` (
SHOW CREATE VIEW mysqltest2.t_nn;
ERROR HY000: 'mysqltest2.t_nn' is not VIEW
SHOW CREATE VIEW mysqltest2.v_yy;
-View Create View
-v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55)
+View Create View character_set_client collation_connection
+v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55) latin1 latin1_swedish_ci
SHOW CREATE TABLE mysqltest2.v_yy;
-View Create View
-v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55)
+View Create View character_set_client collation_connection
+v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55) latin1 latin1_swedish_ci
SHOW CREATE TABLE mysqltest2.v_nn;
-View Create View
-v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn`
+View Create View character_set_client collation_connection
+v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn` latin1 latin1_swedish_ci
SHOW CREATE VIEW mysqltest2.v_nn;
-View Create View
-v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn`
+View Create View character_set_client collation_connection
+v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn` latin1 latin1_swedish_ci
SHOW CREATE TABLE mysqltest2.t_nn;
Table Create Table
t_nn CREATE TABLE `t_nn` (
diff --git a/mysql-test/r/have_cp1251.require b/mysql-test/r/have_cp1251.require
new file mode 100644
index 00000000000..465e8338084
--- /dev/null
+++ b/mysql-test/r/have_cp1251.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+cp1251_general_ci cp1251 51 Yes 0
diff --git a/mysql-test/r/have_cp866.require b/mysql-test/r/have_cp866.require
new file mode 100644
index 00000000000..da2a3e2f05e
--- /dev/null
+++ b/mysql-test/r/have_cp866.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+cp866_general_ci cp866 36 Yes 0
diff --git a/mysql-test/r/have_koi8r.require b/mysql-test/r/have_koi8r.require
new file mode 100644
index 00000000000..b109b9ae520
--- /dev/null
+++ b/mysql-test/r/have_koi8r.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+koi8r_general_ci koi8r 7 Yes 0
diff --git a/mysql-test/r/have_utf8.require b/mysql-test/r/have_utf8.require
new file mode 100644
index 00000000000..71f8ccfff47
--- /dev/null
+++ b/mysql-test/r/have_utf8.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+utf8_general_ci utf8 33 Yes Yes 1
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index fc111430a4e..e290457d4ee 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -274,11 +274,11 @@ parameter_style sql_data_access dtd_identifier
SQL CONTAINS SQL NULL
SQL CONTAINS SQL int(11)
show procedure status;
-Db Name Type Definer Modified Created Security_type Comment
-test sel2 PROCEDURE root@localhost # # DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test sel2 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
show function status;
-Db Name Type Definer Modified Created Security_type Comment
-test sub1 FUNCTION root@localhost # # DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test sub1 FUNCTION root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
@@ -327,26 +327,26 @@ sel2 NULL
sub1 NULL
sub2 return i+1
show create procedure sel2;
-Procedure sql_mode Create Procedure
-sel2 NULL
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+sel2 NULL latin1 latin1_swedish_ci latin1_swedish_ci
show create function sub1;
-Function sql_mode Create Function
-sub1 NULL
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+sub1 NULL latin1 latin1_swedish_ci latin1_swedish_ci
show create function sub2;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
sub2 CREATE DEFINER=`mysqltest_1`@`localhost` FUNCTION `sub2`(i int) RETURNS int(11)
-return i+1
+return i+1 latin1 latin1_swedish_ci latin1_swedish_ci
show function status like "sub2";
-Db Name Type Definer Modified Created Security_type Comment
-test sub2 FUNCTION mysqltest_1@localhost # # DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test sub2 FUNCTION mysqltest_1@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
drop function sub2;
show create procedure sel2;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
sel2 CREATE DEFINER=`root`@`localhost` PROCEDURE `sel2`()
begin
select * from t1;
select * from t2;
-end
+end latin1 latin1_swedish_ci latin1_swedish_ci
create view v0 (c) as select schema_name from information_schema.schemata;
select * from v0;
c
@@ -386,12 +386,12 @@ latin1_spanish_ci
show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.views where TABLE_NAME like "v%";
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
-NULL test v0 /* ALGORITHM=UNDEFINED */ select `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER
-NULL test v1 /* ALGORITHM=UNDEFINED */ select `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO root@localhost DEFINER
-NULL test v2 /* ALGORITHM=UNDEFINED */ select `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO root@localhost DEFINER
-NULL test v3 /* ALGORITHM=UNDEFINED */ select `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
-NULL test v4 /* ALGORITHM=UNDEFINED */ select `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL test v0 select schema_name from information_schema.schemata NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v1 select table_name from information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v2 select column_name from information_schema.columns NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v4 select COLLATION_NAME from information_schema.collations NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
drop view v0, v1, v2, v3, v4;
create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost;
@@ -483,10 +483,10 @@ create view v1 (c) as select a from t1 with check option;
create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
-NULL test v1 /* ALGORITHM=UNDEFINED */ select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
-NULL test v2 /* ALGORITHM=UNDEFINED */ select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER
-NULL test v3 /* ALGORITHM=UNDEFINED */ select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL test v1 select a from t1 with check option CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v2 select a from t1 WITH LOCAL CHECK OPTION LOCAL YES root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v3 select a from t1 WITH CASCADED CHECK OPTION CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
@@ -586,6 +586,10 @@ proc created timestamp
proc modified timestamp
proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE')
proc comment char(64)
+proc character_set_client char(32)
+proc collation_connection char(32)
+proc db_collation char(32)
+proc body_utf8 longblob
drop table t115;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;//
@@ -700,13 +704,13 @@ select constraint_name from information_schema.table_constraints
where table_schema='test';
constraint_name
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `test`.`t1`.`f1` AS `c` from `t1`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `test`.`t1`.`f1` AS `c` from `t1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
show create table v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `sub1`(1) AS `c`
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `sub1`(1) AS `c` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
drop view v2;
@@ -872,39 +876,39 @@ set @fired:= "Yes";
end if;
end|
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trg1 INSERT t1 begin
if new.j > 10 then
set new.j := 10;
end if;
-end BEFORE NULL root@localhost
+end BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg2 UPDATE t1 begin
if old.i % 2 = 0 then
set new.j := -1;
end if;
-end BEFORE NULL root@localhost
+end BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg3 UPDATE t1 begin
if new.j = -1 then
set @fired:= "Yes";
end if;
-end AFTER NULL root@localhost
+end AFTER NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
select * from information_schema.triggers;
-TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
NULL test trg1 INSERT NULL test t1 0 NULL begin
if new.j > 10 then
set new.j := 10;
end if;
-end ROW BEFORE NULL NULL OLD NEW NULL root@localhost
+end ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
NULL test trg2 UPDATE NULL test t1 0 NULL begin
if old.i % 2 = 0 then
set new.j := -1;
end if;
-end ROW BEFORE NULL NULL OLD NEW NULL root@localhost
+end ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
NULL test trg3 UPDATE NULL test t1 0 NULL begin
if new.j = -1 then
set @fired:= "Yes";
end if;
-end ROW AFTER NULL NULL OLD NEW NULL root@localhost
+end ROW AFTER NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
drop trigger trg1;
drop trigger trg2;
drop trigger trg3;
@@ -1156,7 +1160,7 @@ drop table t1;
use mysql;
INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL',
'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03',
-'2006-03-02 18:40:03','','');
+'2006-03-02 18:40:03','','','utf8','utf8_general_ci','utf8_general_ci','n/a');
select routine_name from information_schema.routines;
routine_name
@@ -1169,9 +1173,9 @@ create definer = mysqltest_1@localhost
sql security definer view v2 as select 1;
select * from information_schema.views
where table_name='v1' or table_name='v2';
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
-NULL test v1 NONE YES root@localhost DEFINER
-NULL test v2 /* ALGORITHM=UNDEFINED */ select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v2 select 1 NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
@@ -1196,23 +1200,23 @@ ROUTINE_NAME ROUTINE_DEFINITION
f1 RETURN @a + 1
p1 SET @a= 1
SHOW CREATE PROCEDURE p1;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
-SET @a= 1
+SET @a= 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f1;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
-RETURN @a + 1
+RETURN @a + 1 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
f1 NULL
p1 NULL
SHOW CREATE PROCEDURE p1;
-Procedure sql_mode Create Procedure
-p1 NULL
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
+p1 NULL latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f1;
-Function sql_mode Create Function
-f1 NULL
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+f1 NULL latin1 latin1_swedish_ci latin1_swedish_ci
CALL p1();
SELECT f1();
f1()
diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
index 94ebc213122..a0fd33ac068 100644
--- a/mysql-test/r/information_schema_db.result
+++ b/mysql-test/r/information_schema_db.result
@@ -132,11 +132,11 @@ show fields from testdb_1.v6;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view testdb_1.v6;
-View Create View
-v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1`
+View Create View character_set_client collation_connection
+v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
show create view testdb_1.v7;
-View Create View
-v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
+View Create View character_set_client collation_connection
+v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
show fields from testdb_1.v7;
@@ -153,22 +153,22 @@ show fields from testdb_1.v5;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view testdb_1.v5;
-View Create View
-v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
+View Create View character_set_client collation_connection
+v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` latin1 latin1_swedish_ci
show fields from testdb_1.v6;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view testdb_1.v6;
-View Create View
-v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
+View Create View character_set_client collation_connection
+v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` latin1 latin1_swedish_ci
show fields from testdb_1.v7;
Field Type Null Key Default Extra
f1 null YES NULL
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
show create view testdb_1.v7;
-View Create View
-v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
+View Create View character_set_client collation_connection
+v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
revoke insert(f1) on v3 from testdb_2@localhost;
@@ -200,8 +200,8 @@ show fields from testdb_1.v1;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1` latin1 latin1_swedish_ci
show create view testdb_1.v1;
ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1'
select table_name from information_schema.columns a
@@ -211,7 +211,7 @@ v2
select view_definition from information_schema.views a
where a.table_name = 'v2';
view_definition
-/* ALGORITHM=UNDEFINED */ select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
+select f1 from testdb_1.v1
select view_definition from information_schema.views a
where a.table_name = 'testdb_1.v1';
view_definition
diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result
index f09725dafcb..3653461c6b8 100644
--- a/mysql-test/r/lowercase_view.result
+++ b/mysql-test/r/lowercase_view.result
@@ -6,8 +6,8 @@ use MySQLTest;
create table TaB (Field int);
create view ViE as select * from TAb;
show create table VIe;
-View Create View
-vie CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vie` AS select `tab`.`Field` AS `Field` from `tab`
+View Create View character_set_client collation_connection
+vie CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vie` AS select `tab`.`Field` AS `Field` from `tab` latin1 latin1_swedish_ci
drop database MySQLTest;
use test;
create table t1Aa (col1 int);
@@ -118,8 +118,8 @@ drop table t1Aa,t2Aa;
create table t1Aa (col1 int);
create view v1Aa as select col1 from t1Aa as AaA;
show create view v1AA;
-View Create View
-v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA`
+View Create View character_set_client collation_connection
+v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA` latin1 latin1_swedish_ci
drop view v1AA;
select Aaa.col1 from t1Aa as AaA;
col1
@@ -127,7 +127,7 @@ create view v1Aa as select Aaa.col1 from t1Aa as AaA;
drop view v1AA;
create view v1Aa as select AaA.col1 from t1Aa as AaA;
show create view v1AA;
-View Create View
-v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA`
+View Create View character_set_client collation_connection
+v1aa CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1aa` AS select `aaa`.`col1` AS `col1` from `t1aa` `AaA` latin1 latin1_swedish_ci
drop view v1AA;
drop table t1Aa;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index b6a0e506eda..007ed57f651 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1892,10 +1892,19 @@ DROP TABLE IF EXISTS `v2`;
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!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 `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
/*!50002 WITH CASCADED CHECK OPTION */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1974,9 +1983,18 @@ DROP TABLE IF EXISTS `v1`;
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!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 `t1`.`a` AS `a` from `t1` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2033,10 +2051,19 @@ DROP TABLE IF EXISTS `v2`;
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!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 `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
/*!50002 WITH CASCADED CHECK OPTION */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2143,19 +2170,46 @@ DROP TABLE IF EXISTS `v3`;
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!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 `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `v3` where (`v3`.`b` in (1,2,3,4,5,6,7)) */;
+/*!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 TABLE IF EXISTS `v2`*/;
/*!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 `v3`.`a` AS `a` from (`v3` join `v1`) where ((`v1`.`a` = `v3`.`a`) and (`v3`.`b` = 3)) limit 1 */;
+/*!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 TABLE IF EXISTS `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
+/*!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 `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2198,21 +2252,21 @@ end if;
end|
set sql_mode=default|
show triggers like "t1";
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trg1 INSERT t1 begin
if new.a > 10 then
set new.a := 10;
set new.a := 11;
end if;
-end BEFORE 0000-00-00 00:00:00 root@localhost
+end BEFORE 0000-00-00 00:00:00 root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg2 UPDATE t1 begin
if old.a % 2 = 0 then set new.b := 12; end if;
-end BEFORE 0000-00-00 00:00:00 root@localhost
+end BEFORE 0000-00-00 00:00:00 root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg3 UPDATE t1 begin
if new.a = -1 then
set @fired:= "Yes";
end if;
-end AFTER 0000-00-00 00:00:00 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost
+end AFTER 0000-00-00 00:00:00 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
update t1 set a = 4 where a=3;
@@ -2241,30 +2295,64 @@ LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
-
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
DELIMITER ;;
-/*!50003 SET SESSION SQL_MODE="" */;;
-/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW begin
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 trigger trg1 before insert on t1 for each row
+begin
if new.a > 10 then
set new.a := 10;
set new.a := 11;
end if;
end */;;
-
-/*!50003 SET SESSION SQL_MODE="" */;;
-/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 trigger trg2 before update on t1 for each row begin
if old.a % 2 = 0 then set new.b := 12; end if;
end */;;
-
-/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;;
-/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW begin
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 trigger trg3 after update on t1 for each row
+begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end */;;
-
DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
@@ -2274,17 +2362,26 @@ LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
UNLOCK TABLES;
-
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER' */ ;
DELIMITER ;;
-/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;;
-/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW begin
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 trigger trg4 before insert on t2 for each row
+begin
if new.a > 10 then
set @fired:= "No";
end if;
end */;;
-
DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2346,26 +2443,26 @@ Tables_in_test
t1
t2
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trg1 INSERT t1 begin
if new.a > 10 then
set new.a := 10;
set new.a := 11;
end if;
-end BEFORE # root@localhost
+end BEFORE # root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg2 UPDATE t1 begin
if old.a % 2 = 0 then set new.b := 12; end if;
-end BEFORE # root@localhost
+end BEFORE # root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg3 UPDATE t1 begin
if new.a = -1 then
set @fired:= "Yes";
end if;
-end AFTER # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost
+end AFTER # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
trg4 INSERT t2 begin
if new.a > 10 then
set @fired:= "No";
end if;
-end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost
+end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
DROP TABLE t1, t2;
#
# Bugs #9136, #12917: problems with --defaults-extra-file option
@@ -2394,9 +2491,9 @@ SELECT * FROM `test2`;
a2
1
SHOW TRIGGERS;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
testref INSERT test1 BEGIN
-INSERT INTO test2 SET a2 = NEW.a1; END BEFORE NULL root@localhost
+INSERT INTO test2 SET a2 = NEW.a1; END BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
SELECT * FROM `test1`;
a1
1
@@ -2457,38 +2554,96 @@ LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1),(2),(3),(4),(5);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
+/*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
DELIMITER ;;
-/*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;;
-/*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b */;;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
-/*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;;
-/*!50003 SET SESSION SQL_MODE=""*/;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1) CHARSET latin1
begin
set f1= concat( 'hello', f1 );
return f1;
end */;;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
-/*!50003 DROP PROCEDURE IF EXISTS `a'b` */;;
-/*!50003 SET SESSION SQL_MODE="REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI"*/;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `a'b` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50020 DEFINER="root"@"localhost"*/ /*!50003 PROCEDURE "a'b"()
select 1 */;;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
-/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */;;
-/*!50003 SET SESSION SQL_MODE=""*/;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end */;;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
-/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */;;
-/*!50003 SET SESSION SQL_MODE=""*/;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc2`(OUT a INT)
BEGIN
select sum(id) from t1 into a;
END */;;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2631,14 +2786,22 @@ LOCK TABLES "t1 test" WRITE;
INSERT INTO "t1 test" VALUES (1),(2),(3);
/*!40000 ALTER TABLE "t1 test" ENABLE KEYS */;
UNLOCK TABLES;
-
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
DELIMITER ;;
-/*!50003 SET SESSION SQL_MODE="" */;;
-/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
INSERT INTO `t2 test` SET a2 = NEW.a1; END */;;
-
DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
DROP TABLE IF EXISTS "t2 test";
CREATE TABLE "t2 test" (
"a2" int(11) DEFAULT NULL
@@ -2727,19 +2890,46 @@ DROP TABLE IF EXISTS `v2`;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
+/*!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 `v0` AS select `v1`.`a` AS `a`,`v1`.`b` AS `b`,`v1`.`c` AS `c` from `v1` */;
+/*!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 TABLE IF EXISTS `v1`*/;
/*!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 `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1` */;
+/*!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 TABLE IF EXISTS `v2`*/;
/*!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 `v0`.`a` AS `a`,`v0`.`b` AS `b`,`v0`.`c` AS `c` from `v0` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2791,15 +2981,25 @@ LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
-
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE' */ ;
DELIMITER ;;
-/*!50003 SET SESSION SQL_MODE="IGNORE_SPACE" */;;
-/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER tr1 BEFORE INSERT ON t1
+FOR EACH ROW
+BEGIN
SET new.a = 0;
END */;;
-
DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2927,12 +3127,12 @@ drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
tr1 INSERT t1 set
-new.created=now() BEFORE # root@localhost
+new.created=now() BEFORE # root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
tr2 INSERT t1 begin
insert into t2 set b=new.a and created=new.created;
-end AFTER # root@localhost
+end AFTER # root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
@@ -2945,14 +3145,32 @@ insert into t values(5, 51);
create view v1 as select qty, price, qty*price as value from t;
create view v2 as select qty from v1;
mysqldump {
+/*!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 `t`.`qty` AS `qty`,`t`.`price` AS `price`,(`t`.`qty` * `t`.`price`) AS `value` from `t` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
} mysqldump {
+/*!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 `v1`.`qty` AS `qty` from `v1` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
} mysqldump
drop view v1;
@@ -2967,13 +3185,13 @@ return 42 */|
/*!50003 CREATE PROCEDURE `p`()
select 42 */|
show create function f;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
f CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS bigint(20)
-return 42
+return 42 latin1 latin1_swedish_ci latin1_swedish_ci
show create procedure p;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
drop function f;
drop procedure p;
#
@@ -3035,9 +3253,18 @@ DROP TABLE IF EXISTS `v1`;
USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!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 `t1`.`id` AS `id` from `t1` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -3080,9 +3307,18 @@ USE `mysqldump_views`;
USE `mysqldump_tables`;
USE `mysqldump_views`;
+/*!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 `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
@@ -3269,11 +3505,11 @@ create function f2() returns int return f1();
create view v3 as select bug23491_original.f1();
use bug23491_restore;
show create view bug23491_restore.v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `f1`() AS `f1()`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `f1`() AS `f1()` latin1 latin1_swedish_ci
show create view bug23491_restore.v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `bug23491_original`.`f1`() AS `bug23491_original.f1()`
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `bug23491_original`.`f1`() AS `bug23491_original.f1()` latin1 latin1_swedish_ci
drop database bug23491_original;
drop database bug23491_restore;
use test;
@@ -3289,21 +3525,25 @@ grant all privileges on mysqldump_test_db.* to user1;
grant all privileges on mysqldump_test_db.* to user2;
create procedure mysqldump_test_db.sp1() select 'hello';
-/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
-DELIMITER ;;
-
-- insufficient privileges to SHOW CREATE PROCEDURE `sp1`
-- does user2 have permissions on mysql.proc?
-DELIMITER ;
-
-/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
DELIMITER ;;
-/*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`user1`@`%`*/ /*!50003 PROCEDURE `sp1`()
select 'hello' */;;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
drop procedure sp1;
drop user user1;
drop user user2;
@@ -3543,35 +3783,35 @@ use first;
set time_zone = 'UTC';
create event ee1 on schedule at '2035-12-31 20:01:23' do set @a=5;
show events;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-first ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+first ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
show create event ee1;
-Event sql_mode time_zone Create Event
-ee1 UTC CREATE EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ee1 UTC CREATE EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci
drop database first;
create database second;
use second;
show events;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
show create event ee1;
-Event sql_mode time_zone Create Event
-ee1 NO_AUTO_VALUE_ON_ZERO UTC CREATE EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5
+Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
+ee1 UTC CREATE EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci
create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5;
create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5;
show events;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1
-second ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1
-second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+second ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
drop database second;
create database third;
use third;
show events;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1
-third ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1
-third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+third ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
drop database third;
set time_zone = 'SYSTEM';
use test;
@@ -3624,9 +3864,18 @@ DROP TABLE IF EXISTS `v1`;
USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!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 `t1`.`id` AS `id` from `t1` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
diff --git a/mysql-test/r/ndb_sp.result b/mysql-test/r/ndb_sp.result
index 32e6d2eddd7..3a59d09bb4a 100644
--- a/mysql-test/r/ndb_sp.result
+++ b/mysql-test/r/ndb_sp.result
@@ -31,12 +31,12 @@ select @test_var;
10
alter procedure test_proc1 comment 'new comment';
show create procedure test_proc1;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure Client_cs Connection_cl Database_cl
test_proc1 CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc1`(in var_in int)
COMMENT 'new comment'
begin
select * from t1 where a = var_in;
-end
+end latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure test_proc1;
drop procedure test_proc2;
drop procedure test_proc3;
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 84fcb8634d6..9214d470b37 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -2118,11 +2118,11 @@ prepare abc from "show master logs";
deallocate prepare abc;
create procedure proc_1() show events;
call proc_1();
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
call proc_1();
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
call proc_1();
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
drop procedure proc_1;
create function func_1() returns int begin show events; return 1; end|
ERROR 0A000: Not allowed to return a result set from a function
@@ -2132,27 +2132,27 @@ drop function func_1;
ERROR 42000: FUNCTION test.func_1 does not exist
prepare abc from "show events";
execute abc;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
execute abc;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
execute abc;
-Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
deallocate prepare abc;
drop procedure if exists a;
create procedure a() select 42;
create procedure proc_1(a char(2)) show create procedure a;
call proc_1("bb");
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
call proc_1("bb");
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
call proc_1("bb");
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure proc_1;
create function func_1() returns int begin show create procedure a; return 1; end|
ERROR 0A000: Not allowed to return a result set from a function
@@ -2162,34 +2162,34 @@ drop function func_1;
ERROR 42000: FUNCTION test.func_1 does not exist
prepare abc from "show create procedure a";
execute abc;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
execute abc;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
execute abc;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
-select 42
+select 42 latin1 latin1_swedish_ci latin1_swedish_ci
deallocate prepare abc;
drop procedure a;
drop function if exists a;
create function a() returns int return 42+13;
create procedure proc_1(a char(2)) show create function a;
call proc_1("bb");
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
-return 42+13
+return 42+13 latin1 latin1_swedish_ci latin1_swedish_ci
call proc_1("bb");
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
-return 42+13
+return 42+13 latin1 latin1_swedish_ci latin1_swedish_ci
call proc_1("bb");
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
-return 42+13
+return 42+13 latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure proc_1;
create function func_1() returns int begin show create function a; return 1; end|
ERROR 0A000: Not allowed to return a result set from a function
@@ -2199,17 +2199,17 @@ drop function func_1;
ERROR 42000: FUNCTION test.func_1 does not exist
prepare abc from "show create function a";
execute abc;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
-return 42+13
+return 42+13 latin1 latin1_swedish_ci latin1_swedish_ci
execute abc;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
-return 42+13
+return 42+13 latin1 latin1_swedish_ci latin1_swedish_ci
execute abc;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
-return 42+13
+return 42+13 latin1 latin1_swedish_ci latin1_swedish_ci
deallocate prepare abc;
drop function a;
drop table if exists tab1;
@@ -2277,14 +2277,14 @@ union all
(select b, count(*) from t1 group by b);
create procedure proc_1() show create view v1;
call proc_1();
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) latin1 latin1_swedish_ci
call proc_1();
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) latin1 latin1_swedish_ci
call proc_1();
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) latin1 latin1_swedish_ci
drop procedure proc_1;
create function func_1() returns int begin show create view v1; return 1; end|
ERROR 0A000: Not allowed to return a result set from a function
@@ -2294,14 +2294,14 @@ drop function func_1;
ERROR 42000: FUNCTION test.func_1 does not exist
prepare abc from "show create view v1";
execute abc;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) latin1 latin1_swedish_ci
execute abc;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) latin1 latin1_swedish_ci
execute abc;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all (select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`) latin1 latin1_swedish_ci
deallocate prepare abc;
drop view v1;
drop table t1;
diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result
index 2a1dc4b44af..d854a2d0f8d 100644
--- a/mysql-test/r/rpl_replicate_do.result
+++ b/mysql-test/r/rpl_replicate_do.result
@@ -87,27 +87,27 @@ Tables_in_test
t1
t2
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
-trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
-trg2 INSERT t2 set new.b=2 BEFORE NULL root@localhost
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
+trg2 INSERT t2 set new.b=2 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
*** slave ***
show tables;
Tables_in_test
t1
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
-trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
*** master ***
drop trigger trg1;
drop trigger trg2;
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
*** slave ***
show tables;
Tables_in_test
t1
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
*** master ***
drop table t1;
drop table t2;
diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result
index 208c46c5fab..0b89b6d29c7 100644
--- a/mysql-test/r/rpl_sp.result
+++ b/mysql-test/r/rpl_sp.result
@@ -17,21 +17,31 @@ insert into t1 values (b);
insert into t1 values (unix_timestamp());
end|
select * from mysql.proc where name='foo' and db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
mysqltest1 foo PROCEDURE foo SQL CONTAINS_SQL NO DEFINER begin
declare b int;
set b = 8;
insert into t1 values (b);
insert into t1 values (unix_timestamp());
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+declare b int;
+set b = 8;
+insert into t1 values (b);
+insert into t1 values (unix_timestamp());
+end
select * from mysql.proc where name='foo' and db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
mysqltest1 foo PROCEDURE foo SQL CONTAINS_SQL NO DEFINER begin
declare b int;
set b = 8;
insert into t1 values (b);
insert into t1 values (unix_timestamp());
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+declare b int;
+set b = 8;
+insert into t1 values (b);
+insert into t1 values (unix_timestamp());
+end
set timestamp=1000000000;
call foo();
select * from t1;
@@ -115,15 +125,17 @@ select * from t2;
a
20
select * from mysql.proc where name="foo4" and db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
mysqltest1 foo4 PROCEDURE foo4 SQL CONTAINS_SQL YES DEFINER begin
insert into t2 values(20),(20);
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+insert into t2 values(20),(20);
+end
drop procedure foo4;
select * from mysql.proc where name="foo4" and db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
select * from mysql.proc where name="foo4" and db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
drop procedure foo;
drop procedure foo2;
drop procedure foo3;
@@ -202,16 +214,22 @@ select fn3();
fn3()
0
select * from mysql.proc where db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
mysqltest1 fn1 FUNCTION fn1 SQL NO_SQL NO DEFINER int(11) begin
return unix_timestamp();
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+return unix_timestamp();
+end
mysqltest1 fn2 FUNCTION fn2 SQL NO_SQL NO DEFINER int(11) begin
return unix_timestamp();
-end zedjzlcsjhd@localhost # #
+end zedjzlcsjhd@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+return unix_timestamp();
+end
mysqltest1 fn3 FUNCTION fn3 SQL READS_SQL_DATA NO DEFINER int(11) begin
return 0;
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+return 0;
+end
select * from t1;
a
1000000000
@@ -220,16 +238,22 @@ select * from t1;
a
1000000000
select * from mysql.proc where db='mysqltest1';
-db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment
+db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
mysqltest1 fn1 FUNCTION fn1 SQL NO_SQL NO DEFINER int(11) begin
return unix_timestamp();
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+return unix_timestamp();
+end
mysqltest1 fn2 FUNCTION fn2 SQL NO_SQL NO DEFINER int(11) begin
return unix_timestamp();
-end zedjzlcsjhd@localhost # #
+end zedjzlcsjhd@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+return unix_timestamp();
+end
mysqltest1 fn3 FUNCTION fn3 SQL READS_SQL_DATA NO DEFINER int(11) begin
return 0;
-end root@localhost # #
+end root@localhost # # latin1 latin1_swedish_ci latin1_swedish_ci begin
+return 0;
+end
delete from t2;
alter table t2 add unique (a);
drop function fn1;
@@ -337,26 +361,26 @@ DROP FUNCTION IF EXISTS f1;
---> Checking on master...
SHOW CREATE PROCEDURE p1;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
-SET @a = 1
+SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f1;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
-RETURN 0
+RETURN 0 latin1 latin1_swedish_ci latin1_swedish_ci
---> Synchronizing slave with master...
---> connection: master
---> Checking on slave...
SHOW CREATE PROCEDURE p1;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
-SET @a = 1
+SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f1;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
-RETURN 0
+RETURN 0 latin1 latin1_swedish_ci latin1_swedish_ci
---> connection: master
diff --git a/mysql-test/r/rpl_trigger.result b/mysql-test/r/rpl_trigger.result
index 815a87eede5..b4ce3ee1d36 100644
--- a/mysql-test/r/rpl_trigger.result
+++ b/mysql-test/r/rpl_trigger.result
@@ -868,8 +868,8 @@ Tables_in_test (t_)
t1
t2
SHOW TRIGGERS;
-Trigger Event Table Statement Timing Created sql_mode Definer
-trg1 INSERT t1 INSERT INTO t2 VALUES(CURRENT_USER()) AFTER NULL
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 INSERT INTO t2 VALUES(CURRENT_USER()) AFTER NULL latin1 latin1_swedish_ci latin1_swedish_ci
SELECT * FROM t1;
c
1
@@ -895,7 +895,7 @@ RESET SLAVE;
SHOW TABLES LIKE 't_';
Tables_in_test (t_)
SHOW TRIGGERS;
-Trigger Event Table Statement Timing Created sql_mode Definer
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
RESET MASTER;
START SLAVE;
diff --git a/mysql-test/r/rpl_view.result b/mysql-test/r/rpl_view.result
index 0d862a2a912..12b7b46ffed 100644
--- a/mysql-test/r/rpl_view.result
+++ b/mysql-test/r/rpl_view.result
@@ -88,8 +88,8 @@ Field Type Null Key Default Extra
a int(11) YES NULL
b decimal(32,0) YES NULL
show create table v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,sum(`t1`.`b`) AS `b` from `t1` group by `t1`.`a`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,sum(`t1`.`b`) AS `b` from `t1` group by `t1`.`a` latin1 latin1_swedish_ci
select * from v1;
a b
1 6
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 66cd929ee05..180968b3f96 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -617,48 +617,48 @@ DROP VIEW IF EXISTS v1;
DROP PROCEDURE IF EXISTS p1;
CREATE VIEW v1 AS SELECT 1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_CACHE 1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache 1 AS `1` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_NO_CACHE 1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache 1 AS `1` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT NOW();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select now() AS `NOW()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_CACHE NOW();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache now() AS `NOW()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_NO_CACHE NOW();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE NOW();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_NO_CACHE SQL_CACHE NOW();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE SQL_CACHE NOW();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE PROCEDURE p1()
BEGIN
@@ -669,8 +669,8 @@ DROP PREPARE stmt;
END |
CALL p1();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache 1 AS `1` binary binary
DROP PROCEDURE p1;
DROP VIEW v1;
SHOW TABLES FROM no_such_database;
@@ -754,4 +754,76 @@ drop table `été`;
set names latin1;
show columns from `#mysql50#????????`;
Got one of the listed errors
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1(c1 INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
+SHOW CREATE TRIGGER t1_bi;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CREATE PROCEDURE p1() SHOW CREATE TRIGGER t1_bi;
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+CALL p1();
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+PREPARE stmt1 FROM 'SHOW CREATE TRIGGER t1_bi';
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+EXECUTE stmt1;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1 latin1 latin1_swedish_ci latin1_swedish_ci
+DROP TABLE t1;
+DROP PROCEDURE p1;
+DEALLOCATE PREPARE stmt1;
End of 5.1 tests
diff --git a/mysql-test/r/skip_grants.result b/mysql-test/r/skip_grants.result
index 0961ffd734c..6bb8cbea2f1 100644
--- a/mysql-test/r/skip_grants.result
+++ b/mysql-test/r/skip_grants.result
@@ -35,16 +35,16 @@ SELECT 3;
CREATE DEFINER=a@'' FUNCTION f3() RETURNS INT
RETURN 3;
SHOW CREATE VIEW v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`a`@`` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`c` AS `c` from `t1`
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`a`@`` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`c` AS `c` from `t1` latin1 latin1_swedish_ci
SHOW CREATE PROCEDURE p3;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p3 CREATE DEFINER=`a`@`` PROCEDURE `p3`()
-SELECT 3
+SELECT 3 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f3;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
f3 CREATE DEFINER=`a`@`` FUNCTION `f3`() RETURNS int(11)
-RETURN 3
+RETURN 3 latin1 latin1_swedish_ci latin1_swedish_ci
DROP TRIGGER t1_bi;
DROP TRIGGER ti_ai;
DROP TRIGGER ti_bu;
diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result
index 4df8086c84e..ae294f05b25 100644
--- a/mysql-test/r/sp-destruct.result
+++ b/mysql-test/r/sp-destruct.result
@@ -37,26 +37,33 @@ insert into mysql.proc
(
db, name, type, specific_name, language, sql_data_access, is_deterministic,
security_type, param_list, returns, body, definer, created, modified,
-sql_mode, comment
+sql_mode, comment, character_set_client, collation_connection, db_collation,
+body_utf8
)
values
(
'test', 'bug14233_1', 'FUNCTION', 'bug14233_1', 'SQL', 'READS_SQL_DATA', 'NO',
'DEFINER', '', 'int(10)',
'select count(*) from mysql.user',
-'root@localhost', NOW() , '0000-00-00 00:00:00', '', ''
+'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
+'', '', '',
+'select count(*) from mysql.user'
),
(
'test', 'bug14233_2', 'FUNCTION', 'bug14233_2', 'SQL', 'READS_SQL_DATA', 'NO',
'DEFINER', '', 'int(10)',
'begin declare x int; select count(*) into x from mysql.user; end',
-'root@localhost', NOW() , '0000-00-00 00:00:00', '', ''
+'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
+'', '', '',
+'begin declare x int; select count(*) into x from mysql.user; end'
),
(
'test', 'bug14233_3', 'PROCEDURE', 'bug14233_3', 'SQL', 'READS_SQL_DATA','NO',
'DEFINER', '', '',
'alksj wpsj sa ^#!@ ',
-'root@localhost', NOW() , '0000-00-00 00:00:00', '', ''
+'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
+'', '', '',
+'alksj wpsj sa ^#!@ '
);
select bug14233_1();
ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
@@ -78,6 +85,6 @@ drop function bug14233_1;
drop function bug14233_2;
drop procedure bug14233_3;
show procedure status;
-Db Name Type Definer Modified Created Security_type Comment
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
show function status;
-Db Name Type Definer Modified Created Security_type Comment
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 0f043a73f85..675a59f1fb7 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -682,8 +682,8 @@ create procedure bug17015_012345678901234567890123456789012345678901234567890123
begin
end|
show procedure status like 'bug17015%'|
-Db Name Type Definer Modified Created Security_type Comment
-test bug17015_0123456789012345678901234567890123456789012345678901234 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test bug17015_0123456789012345678901234567890123456789012345678901234 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure bug17015_0123456789012345678901234567890123456789012345678901234|
drop procedure if exists bug10969|
create procedure bug10969()
@@ -1087,8 +1087,8 @@ create procedure p2() select version();
ERROR 3D000: No database selected
use mysqltest2;
show procedure status;
-Db Name Type Definer Modified Created Security_type Comment
-mysqltest2 p1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+mysqltest2 p1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
drop database mysqltest2;
use test;
DROP FUNCTION IF EXISTS bug13012|
@@ -1177,8 +1177,8 @@ call ` bug15658`();
1
1
show procedure status;
-Db Name Type Definer Modified Created Security_type Comment
-test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure ` bug15658`;
drop function if exists bug14270;
drop table if exists t1;
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 7315ef40083..1a1645ca971 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -12,8 +12,8 @@ insert into t1 values('test', 0);
create procedure stamp(i int)
insert into db1_secret.t1 values (user(), i);
show procedure status like 'stamp';
-Db Name Type Definer Modified Created Security_type Comment
-db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
create function db() returns varchar(64)
begin
declare v varchar(64);
@@ -21,8 +21,8 @@ select u into v from t1 limit 1;
return v;
end|
show function status like 'db';
-Db Name Type Definer Modified Created Security_type Comment
-db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
call stamp(1);
select * from t1;
u i
@@ -71,12 +71,12 @@ user1@localhost 2
anon@localhost 3
alter procedure stamp sql security invoker;
show procedure status like 'stamp';
-Db Name Type Definer Modified Created Security_type Comment
-db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER latin1 latin1_swedish_ci latin1_swedish_ci
alter function db sql security invoker;
show function status like 'db';
-Db Name Type Definer Modified Created Security_type Comment
-db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER latin1 latin1_swedish_ci latin1_swedish_ci
call stamp(4);
select * from t1;
u i
@@ -365,21 +365,21 @@ Note 1449 There is no 'a @ b @ c'@'localhost' registered
---> connection: con1root
use mysqltest;
SHOW CREATE PROCEDURE wl2897_p1;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
wl2897_p1 CREATE DEFINER=`mysqltest_2`@`localhost` PROCEDURE `wl2897_p1`()
-SELECT 1
+SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE PROCEDURE wl2897_p3;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
wl2897_p3 CREATE DEFINER=`a @ b @ c`@`localhost` PROCEDURE `wl2897_p3`()
-SELECT 3
+SELECT 3 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION wl2897_f1;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
wl2897_f1 CREATE DEFINER=`mysqltest_2`@`localhost` FUNCTION `wl2897_f1`() RETURNS int(11)
-RETURN 1
+RETURN 1 latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION wl2897_f3;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
wl2897_f3 CREATE DEFINER=`a @ b @ c`@`localhost` FUNCTION `wl2897_f3`() RETURNS int(11)
-RETURN 3
+RETURN 3 latin1 latin1_swedish_ci latin1_swedish_ci
DROP USER mysqltest_1@localhost;
DROP USER mysqltest_2@localhost;
DROP DATABASE mysqltest;
@@ -443,14 +443,14 @@ SET a=1;
SELECT a;
END //
SHOW CREATE PROCEDURE test.sp19857;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
sp19857 CREATE DEFINER=`user19857`@`localhost` PROCEDURE `sp19857`()
DETERMINISTIC
BEGIN
DECLARE a INT;
SET a=1;
SELECT a;
-END
+END latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS test.sp19857;
---> connection: root
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 98d73f7536c..b060bfb081a 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -787,11 +787,11 @@ sql security definer
comment 'Characteristics procedure test'
insert into t1 values ("chistics", 1)|
show create procedure chistics|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
chistics CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`()
MODIFIES SQL DATA
COMMENT 'Characteristics procedure test'
-insert into t1 values ("chistics", 1)
+insert into t1 values ("chistics", 1) latin1 latin1_swedish_ci latin1_swedish_ci
call chistics()|
select * from t1|
id data
@@ -799,12 +799,12 @@ chistics 1
delete from t1|
alter procedure chistics sql security invoker|
show create procedure chistics|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
chistics CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`()
MODIFIES SQL DATA
SQL SECURITY INVOKER
COMMENT 'Characteristics procedure test'
-insert into t1 values ("chistics", 1)
+insert into t1 values ("chistics", 1) latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure chistics|
drop function if exists chistics|
create function chistics() returns int
@@ -814,12 +814,12 @@ sql security invoker
comment 'Characteristics procedure test'
return 42|
show create function chistics|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
chistics CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int(11)
DETERMINISTIC
SQL SECURITY INVOKER
COMMENT 'Characteristics procedure test'
-return 42
+return 42 latin1 latin1_swedish_ci latin1_swedish_ci
select chistics()|
chistics()
42
@@ -827,13 +827,13 @@ alter function chistics
no sql
comment 'Characteristics function test'|
show create function chistics|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
chistics CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int(11)
NO SQL
DETERMINISTIC
SQL SECURITY INVOKER
COMMENT 'Characteristics function test'
-return 42
+return 42 latin1 latin1_swedish_ci latin1_swedish_ci
drop function chistics|
insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
set @@sql_mode = 'ANSI'|
@@ -1223,12 +1223,12 @@ n f
20 2432902008176640000
drop table t3|
show function status like '%f%'|
-Db Name Type Definer Modified Created Security_type Comment
-test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure ifac|
drop function fac|
show function status like '%f%'|
-Db Name Type Definer Modified Created Security_type Comment
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
drop table if exists t3|
create table t3 (
i int unsigned not null primary key,
@@ -1290,7 +1290,7 @@ end;
end while;
end|
show create procedure opp|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
opp CREATE DEFINER=`root`@`localhost` PROCEDURE `opp`(n bigint unsigned, out pp bool)
begin
declare r double;
@@ -1316,11 +1316,11 @@ set s = s+1;
end;
end if;
end loop;
-end
+end latin1 latin1_swedish_ci latin1_swedish_ci
show procedure status like '%p%'|
-Db Name Type Definer Modified Created Security_type Comment
-test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
+test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
call ip(200)|
select * from t3 where i=45 or i=100 or i=199|
i p
@@ -1331,7 +1331,7 @@ drop table t3|
drop procedure opp|
drop procedure ip|
show procedure status like '%p%'|
-Db Name Type Definer Modified Created Security_type Comment
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
drop table if exists t3|
create table t3 ( f bigint unsigned not null )|
drop procedure if exists fib|
@@ -1383,19 +1383,19 @@ create procedure bar(x char(16), y int)
comment "111111111111" sql security invoker
insert into test.t1 values (x, y)|
show procedure status like 'bar'|
-Db Name Type Definer Modified Created Security_type Comment
-test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111 latin1 latin1_swedish_ci latin1_swedish_ci
alter procedure bar comment "2222222222" sql security definer|
alter procedure bar comment "3333333333"|
alter procedure bar|
show create procedure bar|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
bar CREATE DEFINER=`root`@`localhost` PROCEDURE `bar`(x char(16), y int)
COMMENT '3333333333'
-insert into test.t1 values (x, y)
+insert into test.t1 values (x, y) latin1 latin1_swedish_ci latin1_swedish_ci
show procedure status like 'bar'|
-Db Name Type Definer Modified Created Security_type Comment
-test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333 latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure bar|
drop procedure if exists p1|
create procedure p1 ()
@@ -1960,24 +1960,24 @@ show create function bug2267_4;
end|
create function bug2267_4() returns int return 100|
call bug2267_1()|
-Db Name Type Definer Modified Created Security_type Comment
-test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
+test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
+test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
+test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
call bug2267_2()|
-Db Name Type Definer Modified Created Security_type Comment
-test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
call bug2267_3()|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
bug2267_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2267_1`()
begin
show procedure status;
-end
+end latin1 latin1_swedish_ci latin1_swedish_ci
call bug2267_4()|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug2267_4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2267_4`() RETURNS int(11)
-return 100
+return 100 latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure bug2267_1|
drop procedure bug2267_2|
drop procedure bug2267_3|
@@ -2308,22 +2308,22 @@ create function bug2564_4(x int, y int) returns int
return x || y$
set @@sql_mode = ''|
show create procedure bug2564_1|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
bug2564_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2564_1`()
COMMENT 'Joe''s procedure'
-insert into `t1` values ("foo", 1)
+insert into `t1` values ("foo", 1) latin1 latin1_swedish_ci latin1_swedish_ci
show create procedure bug2564_2|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
bug2564_2 ANSI_QUOTES CREATE DEFINER="root"@"localhost" PROCEDURE "bug2564_2"()
-insert into "t1" values ('foo', 1)
+insert into "t1" values ('foo', 1) latin1 latin1_swedish_ci latin1_swedish_ci
show create function bug2564_3|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug2564_3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2564_3`(x int, y int) RETURNS int(11)
-return x || y
+return x || y latin1 latin1_swedish_ci latin1_swedish_ci
show create function bug2564_4|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE DEFINER="root"@"localhost" FUNCTION "bug2564_4"(x int, y int) RETURNS int(11)
-return x || y
+return x || y latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure bug2564_1|
drop procedure bug2564_2|
drop function bug2564_3|
@@ -3999,11 +3999,11 @@ main_loop: begin
return 42;
end */;;
show create function bug14723;;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug14723 CREATE DEFINER=`root`@`localhost` FUNCTION `bug14723`() RETURNS bigint(20)
main_loop: begin
return 42;
-end
+end latin1 latin1_swedish_ci latin1_swedish_ci
select bug14723();;
bug14723()
42
@@ -4012,11 +4012,11 @@ main_loop: begin
select 42;
end */;;
show create procedure bug14723;;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
bug14723 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug14723`()
main_loop: begin
select 42;
-end
+end latin1 latin1_swedish_ci latin1_swedish_ci
call bug14723();;
42
42
@@ -5071,21 +5071,21 @@ RETURN ""|
CREATE FUNCTION mysqltest2.bug16211_f4() RETURNS CHAR(10) CHARSET koi8r
RETURN ""|
SHOW CREATE FUNCTION bug16211_f1|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SHOW CREATE FUNCTION bug16211_f2|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SELECT dtd_identifier
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
@@ -5121,21 +5121,21 @@ koi8r
ALTER DATABASE mysqltest1 CHARACTER SET cp1251|
ALTER DATABASE mysqltest2 CHARACTER SET cp1251|
SHOW CREATE FUNCTION bug16211_f1|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SHOW CREATE FUNCTION bug16211_f2|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r
-RETURN ""
+RETURN "" latin1 latin1_swedish_ci utf8_general_ci
SELECT dtd_identifier
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
@@ -5380,9 +5380,9 @@ ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghi
drop procedure if exists bug21416|
create procedure bug21416() show create procedure bug21416|
call bug21416()|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
-show create procedure bug21416
+show create procedure bug21416 latin1 latin1_swedish_ci latin1_swedish_ci
drop procedure bug21416|
DROP PROCEDURE IF EXISTS bug21414|
CREATE PROCEDURE bug21414() SELECT 1|
@@ -5395,7 +5395,7 @@ DROP PROCEDURE bug21414|
set names utf8|
drop database if exists това_е_дълго_име_за_база_данни_нали|
create database това_е_дълго_име_за_база_данни_нали|
-INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','')|
+INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','', 'utf8', 'utf8_general_ci', 'utf8_general_ci', 'n/a')|
call това_е_дълго_име_за_база_данни_нали.това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго()|
ERROR HY000: Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
drop database това_е_дълго_име_за_база_данни_нали|
@@ -6240,9 +6240,9 @@ DROP FUNCTION bug5274_f2|
drop procedure if exists proc_21513|
create procedure proc_21513()`my_label`:BEGIN END|
show create procedure proc_21513|
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
proc_21513 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_21513`()
-`my_label`:BEGIN END
+`my_label`:BEGIN END utf8 utf8_general_ci latin1_swedish_ci
drop procedure proc_21513|
End of 5.0 tests.
drop table t1,t2;
@@ -6276,8 +6276,8 @@ INSERT INTO t1 VALUES (1),(2);
CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1` utf8 utf8_general_ci
DROP VIEW v1;
DROP FUNCTION metered;
DROP TABLE t1;
@@ -6314,7 +6314,7 @@ select 1 /*!,2*/ /*!00000,3*/ /*!99999,4*/ ;
end
$$
show create procedure proc_25411_a;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
proc_25411_a CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_a`()
begin
/* real comment */
@@ -6323,7 +6323,7 @@ select 1;
select 3;
select 4;
-end
+end utf8 utf8_general_ci latin1_swedish_ci
call proc_25411_a();
1
1
@@ -6334,7 +6334,7 @@ call proc_25411_a();
4
4
show create procedure proc_25411_b;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
proc_25411_b CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_b`(
/* real comment */
p1 int,
@@ -6343,7 +6343,7 @@ proc_25411_b CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_b`(
)
begin
select p1, p2;
-end
+end utf8 utf8_general_ci latin1_swedish_ci
select name, param_list, body from mysql.proc where name like "%25411%";
name param_list body
proc_25411_a begin
@@ -6373,7 +6373,7 @@ call proc_25411_b(10, 20);
p1 p2
10 20
show create procedure proc_25411_c;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
proc_25411_c CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_c`()
begin
select 1,2,3;
@@ -6381,7 +6381,7 @@ select 1 ,2 ,3;
select 1,2 ,3 ;
select 1 ,2 ,3 ;
select 1 ,2 ,3 ;
-end
+end utf8 utf8_general_ci latin1_swedish_ci
call proc_25411_c();
1 2 3
1 2 3
@@ -6400,9 +6400,9 @@ drop procedure if exists proc_26302;
create procedure proc_26302()
select 1 /* testing */;
show create procedure proc_26302;
-Procedure sql_mode Create Procedure
+Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
proc_26302 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_26302`()
-select 1 /* testing */
+select 1 /* testing */ utf8 utf8_general_ci latin1_swedish_ci
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES
where ROUTINE_NAME = "proc_26302";
ROUTINE_NAME ROUTINE_DEFINITION
diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result
index 9998a51fdc8..2b34ff8c021 100644
--- a/mysql-test/r/sql_mode.result
+++ b/mysql-test/r/sql_mode.result
@@ -426,37 +426,37 @@ a\b a\'b a"\b a"\'b
SET @@SQL_MODE='';
create function `foo` () returns int return 5;
show create function `foo`;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
foo CREATE DEFINER=`root`@`localhost` FUNCTION `foo`() RETURNS int(11)
-return 5
+return 5 latin1 latin1_swedish_ci latin1_swedish_ci
SET @@SQL_MODE='ANSI_QUOTES';
show create function `foo`;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
foo CREATE DEFINER=`root`@`localhost` FUNCTION `foo`() RETURNS int(11)
-return 5
+return 5 latin1 latin1_swedish_ci latin1_swedish_ci
drop function `foo`;
create function `foo` () returns int return 5;
show create function `foo`;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
foo ANSI_QUOTES CREATE DEFINER="root"@"localhost" FUNCTION "foo"() RETURNS int(11)
-return 5
+return 5 latin1 latin1_swedish_ci latin1_swedish_ci
SET @@SQL_MODE='';
show create function `foo`;
-Function sql_mode Create Function
+Function sql_mode Create Function character_set_client collation_connection Database Collation
foo ANSI_QUOTES CREATE DEFINER="root"@"localhost" FUNCTION "foo"() RETURNS int(11)
-return 5
+return 5 latin1 latin1_swedish_ci latin1_swedish_ci
drop function `foo`;
SET @@SQL_MODE='';
create table t1 (a int);
create table t2 (a int);
create view v1 as select a from t1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
SET @@SQL_MODE='ANSI_QUOTES';
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER="root"@"localhost" SQL SECURITY DEFINER VIEW "v1" AS select "t1"."a" AS "a" from "t1"
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER="root"@"localhost" SQL SECURITY DEFINER VIEW "v1" AS select "t1"."a" AS "a" from "t1" latin1 latin1_swedish_ci
create view v2 as select a from t2 where a in (select a from v1);
drop view v2, v1;
drop table t1, t2;
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index 5acbace480a..7696afdf06d 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -203,6 +203,10 @@ proc CREATE TABLE `proc` (
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') NOT NULL DEFAULT '',
`comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
+ `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `body_utf8` longblob,
PRIMARY KEY (`db`,`name`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
show create table event;
@@ -226,6 +230,10 @@ event CREATE TABLE `event` (
`comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`originator` int(10) NOT NULL,
`time_zone` char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM',
+ `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `body_utf8` longblob,
PRIMARY KEY (`db`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
show create table general_log;
diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result
index 9cb4a6b2427..46724de4281 100644
--- a/mysql-test/r/temp_table.result
+++ b/mysql-test/r/temp_table.result
@@ -111,8 +111,8 @@ v1 CREATE TEMPORARY TABLE `v1` (
`A` varchar(19) NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'This is view' AS `A`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'This is view' AS `A` latin1 latin1_swedish_ci
drop view v1;
select * from v1;
A
diff --git a/mysql-test/r/trigger-compat.result b/mysql-test/r/trigger-compat.result
index 068bf6c6968..1609707fb09 100644
--- a/mysql-test/r/trigger-compat.result
+++ b/mysql-test/r/trigger-compat.result
@@ -32,9 +32,9 @@ Warnings:
Warning 1454 No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
-TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER
-NULL mysqltest_db1 wl2818_trg1 INSERT NULL mysqltest_db1 t1 0 NULL INSERT INTO t2 VALUES(CURRENT_USER()) ROW BEFORE NULL NULL OLD NEW NULL
-NULL mysqltest_db1 wl2818_trg2 INSERT NULL mysqltest_db1 t1 0 NULL INSERT INTO t2 VALUES(CURRENT_USER()) ROW AFTER NULL NULL OLD NEW NULL mysqltest_dfn@localhost
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest_db1 wl2818_trg1 INSERT NULL mysqltest_db1 t1 0 NULL INSERT INTO t2 VALUES(CURRENT_USER()) ROW BEFORE NULL NULL OLD NEW NULL latin1 latin1_swedish_ci latin1_swedish_ci
+NULL mysqltest_db1 wl2818_trg2 INSERT NULL mysqltest_db1 t1 0 NULL INSERT INTO t2 VALUES(CURRENT_USER()) ROW AFTER NULL NULL OLD NEW NULL mysqltest_dfn@localhost latin1 latin1_swedish_ci latin1_swedish_ci
DROP TRIGGER wl2818_trg1;
Warnings:
Warning 1454 No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
diff --git a/mysql-test/r/trigger-grant.result b/mysql-test/r/trigger-grant.result
index 49c36513fbc..14b8c98f2fa 100644
--- a/mysql-test/r/trigger-grant.result
+++ b/mysql-test/r/trigger-grant.result
@@ -137,9 +137,9 @@ Note 1449 There is no 'mysqltest_nonexs'@'localhost' registered
INSERT INTO t1 VALUES(6);
ERROR HY000: There is no 'mysqltest_nonexs'@'localhost' registered
SHOW TRIGGERS;
-Trigger Event Table Statement Timing Created sql_mode Definer
-trg1 INSERT t1 SET @new_sum = 0 BEFORE NULL mysqltest_inv@localhost
-trg2 INSERT t1 SET @new_sum = 0 AFTER NULL mysqltest_nonexs@localhost
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 SET @new_sum = 0 BEFORE NULL mysqltest_inv@localhost latin1 latin1_swedish_ci latin1_swedish_ci
+trg2 INSERT t1 SET @new_sum = 0 AFTER NULL mysqltest_nonexs@localhost latin1 latin1_swedish_ci latin1_swedish_ci
DROP TRIGGER trg1;
DROP TRIGGER trg2;
CREATE TRIGGER trg1 BEFORE INSERT ON t1
@@ -169,12 +169,12 @@ Warnings:
Warning 1454 No definer attribute for trigger 'mysqltest_db1'.'trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
-TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER
-NULL mysqltest_db1 trg1 INSERT NULL mysqltest_db1 t1 0 NULL SET @a = 1 ROW BEFORE NULL NULL OLD NEW NULL
-NULL mysqltest_db1 trg2 INSERT NULL mysqltest_db1 t1 0 NULL SET @a = 2 ROW AFTER NULL NULL OLD NEW NULL @
-NULL mysqltest_db1 trg3 UPDATE NULL mysqltest_db1 t1 0 NULL SET @a = 3 ROW BEFORE NULL NULL OLD NEW NULL @abc@def@@
-NULL mysqltest_db1 trg4 UPDATE NULL mysqltest_db1 t1 0 NULL SET @a = 4 ROW AFTER NULL NULL OLD NEW NULL @hostname
-NULL mysqltest_db1 trg5 DELETE NULL mysqltest_db1 t1 0 NULL SET @a = 5 ROW BEFORE NULL NULL OLD NEW NULL @abcdef@@@hostname
+TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
+NULL mysqltest_db1 trg1 INSERT NULL mysqltest_db1 t1 0 NULL SET @a = 1 ROW BEFORE NULL NULL OLD NEW NULL latin1 latin1_swedish_ci latin1_swedish_ci
+NULL mysqltest_db1 trg2 INSERT NULL mysqltest_db1 t1 0 NULL SET @a = 2 ROW AFTER NULL NULL OLD NEW NULL @ latin1 latin1_swedish_ci latin1_swedish_ci
+NULL mysqltest_db1 trg3 UPDATE NULL mysqltest_db1 t1 0 NULL SET @a = 3 ROW BEFORE NULL NULL OLD NEW NULL @abc@def@@ latin1 latin1_swedish_ci latin1_swedish_ci
+NULL mysqltest_db1 trg4 UPDATE NULL mysqltest_db1 t1 0 NULL SET @a = 4 ROW AFTER NULL NULL OLD NEW NULL @hostname latin1 latin1_swedish_ci latin1_swedish_ci
+NULL mysqltest_db1 trg5 DELETE NULL mysqltest_db1 t1 0 NULL SET @a = 5 ROW BEFORE NULL NULL OLD NEW NULL @abcdef@@@hostname latin1 latin1_swedish_ci latin1_swedish_ci
---> connection: default
DROP USER mysqltest_dfn@localhost;
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index ecaef458e92..f901fd783e8 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -600,9 +600,9 @@ select @a;
@a
10
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
-t1_bi INSERT t1 set new."t1 column" = 5 BEFORE # REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI root@localhost
-t1_af INSERT t1 set @a=10 AFTER # root@localhost
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+t1_bi INSERT t1 set new."t1 column" = 5 BEFORE # REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
+t1_af INSERT t1 set @a=10 AFTER # root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
drop table t1;
set sql_mode="traditional";
create table t1 (a date);
@@ -622,8 +622,8 @@ t1 CREATE TABLE `t1` (
`a` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show triggers;
-Trigger Event Table Statement Timing Created sql_mode Definer
-t1_bi INSERT t1 set new.a = '2004-01-00' BEFORE # root@localhost
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+t1_bi INSERT t1 set new.a = '2004-01-00' BEFORE # root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
drop table t1;
create table t1 (id int);
create trigger t1_ai after insert on t1 for each row reset query cache;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 88e12e26c4a..cfad70a9bb5 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -37,11 +37,11 @@ c
6
11
show create table v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci
show create view t1;
ERROR HY000: 'test.t1' is not VIEW
drop table t1;
@@ -60,8 +60,8 @@ Warnings:
Note 1003 select (`test`.`t1`.`b` + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v2 (c) as select b+1 from t1;
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t1`.`b` + 1) AS `c` from `t1`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t1`.`b` + 1) AS `c` from `t1` latin1 latin1_swedish_ci
select c from v2;
c
3
@@ -576,8 +576,8 @@ set sql_mode='ansi';
create table t1 ("a*b" int);
create view v1 as select "a*b" from t1;
show create view v1;
-View Create View
-v1 CREATE VIEW "v1" AS select "t1"."a*b" AS "a*b" from "t1"
+View Create View character_set_client collation_connection
+v1 CREATE VIEW "v1" AS select "t1"."a*b" AS "a*b" from "t1" latin1 latin1_swedish_ci
drop view v1;
drop table t1;
set sql_mode=default;
@@ -682,8 +682,8 @@ drop view v1;
drop table t1;
CREATE VIEW v1 (f1,f2,f3,f4) AS SELECT connection_id(), pi(), current_user(), version();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select connection_id() AS `f1`,pi() AS `f2`,current_user() AS `f3`,version() AS `f4`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select connection_id() AS `f1`,pi() AS `f2`,current_user() AS `f3`,version() AS `f4` latin1 latin1_swedish_ci
drop view v1;
create table t1 (s1 int);
create table t2 (s2 int);
@@ -716,14 +716,14 @@ create table t2 (a int);
create view v1 as select a from t1;
create view v2 as select a from t2 where a in (select a from v1);
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` AS `a` from `v1`)
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` AS `a` from `v1`) latin1 latin1_swedish_ci
drop view v2, v1;
drop table t1, t2;
CREATE VIEW `v 1` AS select 5 AS `5`;
show create view `v 1`;
-View Create View
-v 1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v 1` AS select 5 AS `5`
+View Create View character_set_client collation_connection
+v 1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v 1` AS select 5 AS `5` latin1 latin1_swedish_ci
drop view `v 1`;
create database mysqltest;
create table mysqltest.t1 (a int, b int);
@@ -790,15 +790,15 @@ select * from v3;
a b
1 1
show create view v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from (`v1` join `v2`) where (`v1`.`col1` = `v2`.`col1`)
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from (`v1` join `v2`) where (`v1`.`col1` = `v2`.`col1`) latin1 latin1_swedish_ci
drop view v3, v2, v1;
drop table t2, t1;
create function `f``1` () returns int return 5;
create view v1 as select test.`f``1` ();
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`f``1`() AS `test.``f````1`` ()`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`f``1`() AS `test.``f````1`` ()` latin1 latin1_swedish_ci
select * from v1;
test.`f``1` ()
5
@@ -814,11 +814,11 @@ drop function a;
create table t2 (col1 char collate latin1_german2_ci);
create view v2 as select col1 collate latin1_german1_ci from t2;
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2` latin1 latin1_swedish_ci
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2` latin1 latin1_swedish_ci
drop view v2;
drop table t2;
create table t1 (a int);
@@ -844,9 +844,12 @@ drop view v1;
drop table t1;
create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1` latin1 latin1_swedish_ci
drop view v1;
+SET @old_cs_client = @@character_set_client;
+SET @old_cs_results = @@character_set_results;
+SET @old_cs_connection = @@character_set_connection;
set names utf8;
create table tü (cü char);
create view vü as select cü from tü;
@@ -856,7 +859,9 @@ cü
ü
drop view vü;
drop table tü;
-set names latin1;
+SET character_set_client = @old_cs_client;
+SET character_set_results = @old_cs_results;
+SET character_set_connection = @old_cs_connection;
create table t1 (a int, b int);
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
create view v1(c) as select a+1 from t1 where b >= 4;
@@ -867,8 +872,8 @@ drop view v1;
drop table t1;
create view v1 as select cast(1 as char(3));
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1 as char(3) charset latin1) AS `cast(1 as char(3))`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1 as char(3) charset latin1) AS `cast(1 as char(3))` latin1 latin1_swedish_ci
select * from v1;
cast(1 as char(3))
1
@@ -1199,20 +1204,20 @@ drop table t1;
create table t1 (a int);
create view v1 as select * from t1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
alter algorithm=undefined view v1 as select * from t1 with check option;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION latin1 latin1_swedish_ci
alter algorithm=merge view v1 as select * from t1 with cascaded check option;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION latin1 latin1_swedish_ci
alter algorithm=temptable view v1 as select * from t1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
drop table t1;
create table t1 (s1 int);
@@ -1885,25 +1890,25 @@ create table t1 (a timestamp default now());
create table t2 (b timestamp default now());
create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,(`t1`.`a` < now()) AS `t1.a < now()` from (`t1` join `t2`) where (`t1`.`a` < now())
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,(`t1`.`a` < now()) AS `t1.a < now()` from (`t1` join `t2`) where (`t1`.`a` < now()) latin1 latin1_swedish_ci
drop view v1;
drop table t1, t2;
CREATE TABLE t1 ( a varchar(50) );
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = current_user())
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = current_user()) latin1 latin1_swedish_ci
DROP VIEW v1;
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = VERSION();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = version())
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = version()) latin1 latin1_swedish_ci
DROP VIEW v1;
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = DATABASE();
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = database())
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = database()) latin1 latin1_swedish_ci
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (col1 time);
@@ -2005,8 +2010,8 @@ drop table t1;
create table t1 (s1 int);
create view v1 as select var_samp(s1) from t1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select var_samp(`t1`.`s1`) AS `var_samp(s1)` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select var_samp(`t1`.`s1`) AS `var_samp(s1)` from `t1` latin1 latin1_swedish_ci
drop view v1;
drop table t1;
set sql_mode='strict_all_tables';
@@ -2251,16 +2256,16 @@ CREATE TABLE t1 (date DATE NOT NULL);
INSERT INTO t1 VALUES ('2005-09-06');
CREATE VIEW v1 AS SELECT DAYNAME(date) FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select dayname(`t1`.`date`) AS `DAYNAME(date)` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select dayname(`t1`.`date`) AS `DAYNAME(date)` from `t1` latin1 latin1_swedish_ci
CREATE VIEW v2 AS SELECT DAYOFWEEK(date) FROM t1;
SHOW CREATE VIEW v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select dayofweek(`t1`.`date`) AS `DAYOFWEEK(date)` from `t1`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select dayofweek(`t1`.`date`) AS `DAYOFWEEK(date)` from `t1` latin1 latin1_swedish_ci
CREATE VIEW v3 AS SELECT WEEKDAY(date) FROM t1;
SHOW CREATE VIEW v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select weekday(`t1`.`date`) AS `WEEKDAY(date)` from `t1`
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select weekday(`t1`.`date`) AS `WEEKDAY(date)` from `t1` latin1 latin1_swedish_ci
SELECT DAYNAME('2005-09-06');
DAYNAME('2005-09-06')
Tuesday
@@ -2419,13 +2424,13 @@ test.v1 repair error Corrupt
DROP VIEW v1;
create definer = current_user() sql security invoker view v1 as select 1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
drop view v1;
create definer = current_user sql security invoker view v1 as select 1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
drop view v1;
create table t1 (id INT, primary key(id));
insert into t1 values (1),(2);
@@ -2454,8 +2459,8 @@ end;
//
call p1();
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
drop view v1;
drop procedure p1;
CREATE VIEW v1 AS SELECT 42 AS Meaning;
@@ -2560,8 +2565,8 @@ drop table t1;
show create view v1;
drop view v1;
//
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`id` AS `id` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`id` AS `id` from `t1` latin1 latin1_swedish_ci
create table t1(f1 int, f2 int);
create view v1 as select ta.f1 as a, tb.f1 as b from t1 ta, t1 tb where ta.f1=tb
.f1 and ta.f2=tb.f2;
@@ -2677,8 +2682,8 @@ CREATE VIEW v1 AS
SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*)
FROM t1 GROUP BY id, t;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) AS `t`,count(0) AS `COUNT(*)` from `t1` group by `t1`.`id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) AS `t`,count(0) AS `COUNT(*)` from `t1` group by `t1`.`id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) latin1 latin1_swedish_ci
SELECT * FROM v1;
id t COUNT(*)
DROP VIEW v1;
@@ -2705,8 +2710,8 @@ CREATE VIEW v1 AS
SELECT (year(now())-year(DOB)) AS Age
FROM t1 HAVING Age < 75;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75)
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) latin1 latin1_swedish_ci
set timestamp=1136066400;
SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75;
Age
@@ -2835,12 +2840,12 @@ DROP TABLE t1;
CREATE TABLE t1 (x INT, y INT);
CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x` from `t1` latin1 latin1_swedish_ci
ALTER VIEW v1 AS SELECT x, y FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x`,`t1`.`y` AS `y` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x`,`t1`.`y` AS `y` from `t1` latin1 latin1_swedish_ci
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (s1 char);
@@ -2900,8 +2905,8 @@ USE test;
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute))
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute)) latin1 latin1_swedish_ci
drop view v1;
drop table t1;
DROP TABLE IF EXISTS t1;
@@ -2977,8 +2982,8 @@ t2.ver = (SELECT MAX(t.ver) FROM t2 t WHERE t.org = t2.org);
SHOW WARNINGS;
Level Code Message
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) AS `MAX(t.ver)` from `t2` `t` where (`t`.`org` = `t2`.`org`))))))
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) AS `MAX(t.ver)` from `t2` `t` where (`t`.`org` = `t2`.`org`)))))) latin1 latin1_swedish_ci
DROP VIEW v1;
DROP TABLE t1, t2;
DROP FUNCTION IF EXISTS f1;
@@ -3041,8 +3046,8 @@ DROP VIEW v1, v2;
DROP TABLE t1;
CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
SHOW CREATE VIEW v;
-View Create View
-v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((not(0)) * 5) AS `x`
+View Create View character_set_client collation_connection
+v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((not(0)) * 5) AS `x` latin1 latin1_swedish_ci
SELECT !0 * 5 AS x FROM DUAL;
x
5
@@ -3056,8 +3061,8 @@ SELECT * FROM v1;
TheEnd
TheEnd
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd` latin1 latin1_swedish_ci
DROP VIEW v1;
CREATE TABLE t1 (mydate DATETIME);
INSERT INTO t1 VALUES
@@ -3278,8 +3283,8 @@ old_isfalse int(1) NO 0
a IS NOT FALSE int(1) NO 0
old_isnotfalse int(1) NO 0
show create view view_24532_b;
-View Create View
-view_24532_b CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_24532_b` AS select (`table_24532`.`a` is true) AS `a IS TRUE`,if(ifnull(`table_24532`.`a`,0),1,0) AS `old_istrue`,(`table_24532`.`a` is not true) AS `a IS NOT TRUE`,if(ifnull(`table_24532`.`a`,0),0,1) AS `old_isnottrue`,(`table_24532`.`a` is false) AS `a IS FALSE`,if(ifnull(`table_24532`.`a`,1),0,1) AS `old_isfalse`,(`table_24532`.`a` is not false) AS `a IS NOT FALSE`,if(ifnull(`table_24532`.`a`,1),1,0) AS `old_isnotfalse` from `table_24532`
+View Create View character_set_client collation_connection
+view_24532_b CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_24532_b` AS select (`table_24532`.`a` is true) AS `a IS TRUE`,if(ifnull(`table_24532`.`a`,0),1,0) AS `old_istrue`,(`table_24532`.`a` is not true) AS `a IS NOT TRUE`,if(ifnull(`table_24532`.`a`,0),0,1) AS `old_isnottrue`,(`table_24532`.`a` is false) AS `a IS FALSE`,if(ifnull(`table_24532`.`a`,1),0,1) AS `old_isfalse`,(`table_24532`.`a` is not false) AS `a IS NOT FALSE`,if(ifnull(`table_24532`.`a`,1),1,0) AS `old_isnotfalse` from `table_24532` latin1 latin1_swedish_ci
insert into table_24532 values (0, 0, 0, 0);
select * from view_24532_b;
a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse
@@ -3377,8 +3382,8 @@ col decimal(7,5) NO 0.00000
DROP VIEW v1;
CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col` latin1 latin1_swedish_ci
DROP VIEW v1;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT, c INT DEFAULT 0);
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 0a32b3b3fcd..49c98d8e03f 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -27,8 +27,8 @@ ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for ta
create view v2 as select * from mysqltest.t2;
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2'
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
grant create view,drop,select on test.* to mysqltest_1@localhost;
use test;
alter view v1 as select * from mysqltest.t1;
@@ -127,28 +127,28 @@ explain select c from mysqltest.v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci
explain select c from mysqltest.v2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
show create view mysqltest.v2;
-View Create View
-v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci
explain select c from mysqltest.v3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2`
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci
explain select c from mysqltest.v4;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
show create view mysqltest.v4;
-View Create View
-v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2`
+View Create View character_set_client collation_connection
+v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
drop database mysqltest;
@@ -308,8 +308,8 @@ grant select on mysqltest.t1 to mysqltest_1@localhost;
grant create view,select on test.* to mysqltest_1@localhost;
create view v1 as select * from mysqltest.t1;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
revoke select on mysqltest.t1 from mysqltest_1@localhost;
select * from v1;
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
@@ -476,15 +476,15 @@ grant all on test.* to 'test14256'@'%';
use test;
create view v1 as select 42;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` latin1 latin1_swedish_ci
select definer into @v1def1 from information_schema.views
where table_schema = 'test' and table_name='v1';
drop view v1;
create definer=`test14256`@`%` view v1 as select 42;
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` latin1 latin1_swedish_ci
select definer into @v1def2 from information_schema.views
where table_schema = 'test' and table_name='v1';
drop view v1;
@@ -500,8 +500,8 @@ use mysqltest;
CREATE TABLE t1 (i INT);
CREATE VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost;
use mysqltest;
LOCK TABLES v1 READ;
@@ -519,11 +519,11 @@ create definer=some_user@localhost sql security invoker view v2 as select 1;
Warnings:
Note 1449 There is no 'some_user'@'localhost' registered
show create view v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
show create view v2;
-View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select 1 AS `1`
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select 1 AS `1` latin1 latin1_swedish_ci
drop view v1;
drop view v2;
CREATE DATABASE mysqltest1;
@@ -602,8 +602,8 @@ CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1;
Warnings:
Note 1449 There is no 'no-such-user'@'localhost' registered
SHOW CREATE VIEW v;
-View Create View
-v CREATE ALGORITHM=UNDEFINED DEFINER=`no-such-user`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `test`.`t1`.`a` AS `a` from `t1`
+View Create View character_set_client collation_connection
+v CREATE ALGORITHM=UNDEFINED DEFINER=`no-such-user`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `test`.`t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SELECT * FROM v;
@@ -619,14 +619,14 @@ CREATE TABLE t1 (f1 INTEGER);
CREATE VIEW view1 AS
SELECT * FROM t1;
SHOW CREATE VIEW view1;
-View Create View
-view1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view1` AS select `t1`.`f1` AS `f1` from `t1`
+View Create View character_set_client collation_connection
+view1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view1` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
CREATE VIEW view2 AS
SELECT * FROM view1;
# Here comes a suspicious warning
SHOW CREATE VIEW view2;
-View Create View
-view2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view2` AS select `view1`.`f1` AS `f1` from `view1`
+View Create View character_set_client collation_connection
+view2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view2` AS select `view1`.`f1` AS `f1` from `view1` latin1 latin1_swedish_ci
# But the view view2 is usable
SELECT * FROM view2;
f1
@@ -783,8 +783,8 @@ ALTER VIEW v2 AS SELECT f2 FROM t1;
ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2'
ALTER VIEW v3 AS SELECT f2 FROM t1;
SHOW CREATE VIEW v3;
-View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1`
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci
DROP USER u26813@localhost;
DROP DATABASE db26813;
DROP DATABASE IF EXISTS mysqltest1;
@@ -882,28 +882,28 @@ CREATE TABLE t1 (i INT);
CREATE VIEW v1 AS SELECT * FROM t1;
ALTER VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_2' registered
SHOW CREATE VIEW v1;
-View Create View
-v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1`
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
DROP VIEW v1;
diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test
new file mode 100644
index 00000000000..c3475c98428
--- /dev/null
+++ b/mysql-test/t/ddl_i18n_koi8r.test
@@ -0,0 +1,1112 @@
+# Objects to test:
+# - stored procedures/functions;
+# - triggers;
+# - events;
+# - views;
+#
+# For stored routines:
+# - create a database with collation utf8_unicode_ci;
+# - create an object, which
+# - contains SP-var with explicit CHARSET-clause;
+# - contains SP-var without CHARSET-clause;
+# - contains text constant;
+# - has localized routine/parameter names;
+# - check:
+# - execute;
+# - SHOW CREATE output;
+# - SHOW output;
+# - SELECT FROM INFORMATION_SCHEMA output;
+# - alter database character set;
+# - change connection collation;
+# - check again;
+# - dump definition using mysqldump;
+# - drop object;
+# - restore object;
+#
+
+###########################################################################
+#
+# NOTE: this file contains text in UTF8 and KOI8-R encodings.
+#
+###########################################################################
+
+--source include/have_utf8.inc
+--source include/have_cp866.inc
+--source include/have_cp1251.inc
+--source include/have_koi8r.inc
+
+###########################################################################
+
+set names koi8r;
+delimiter |;
+
+###########################################################################
+#
+# * Views.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Views
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+CREATE TABLE t1(ËÏÌ INT)|
+INSERT INTO t1 VALUES(1)|
+
+# - Create views;
+
+--echo
+
+CREATE VIEW v1 AS
+ SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2
+ FROM t1|
+
+--echo
+
+CREATE VIEW v2 AS SELECT _utf8'теÑÑ‚' as c1|
+
+--echo
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_views.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Change connection to flush cache;
+
+--connect (con2,localhost,root,,)
+--echo
+--echo ---> connection: con2
+
+# - Switch environment variables and trigger loading views;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+--enable_result_log
+
+use mysqltest1|
+
+# - Restore environment;
+
+set names koi8r|
+
+# - Check!
+
+--source include/ddl_i18n.check_views.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1;
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
+
+--exec $MYSQL_DUMP --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
+
+# - Clean mysqltest1;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
+
+#
+# Third-round checks.
+#
+
+# - Change connection to flush cache;
+
+--connect (con3,localhost,root,,)
+--echo
+--echo ---> connection: con3
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+--enable_result_log
+
+use mysqltest1|
+
+# - Restore environment;
+
+set names koi8r|
+
+# - Check!
+
+--source include/ddl_i18n.check_views.inc
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+
+###########################################################################
+#
+# * Stored procedures/functions.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Stored procedures/functions
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create two stored routines -- with and without explicit
+# CHARSET-clause for SP-variable;
+#
+
+--echo
+
+# - Procedure p1
+
+CREATE PROCEDURE p1(
+ INOUT ÐÁÒÁÍ1 CHAR(10),
+ OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10);
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION(ÐÁÒÁÍ1) AS c2,
+ COLLATION(ÐÁÒÁÍ2) AS c3;
+
+ SELECT
+ COLLATION('ÔÅËÓÔ') AS c4,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+ COLLATION(_utf8 'текÑÑ‚') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET ÐÁÒÁÍ1 = 'a';
+ SET ÐÁÒÁÍ2 = 'b';
+END|
+
+--echo
+
+# - Procedure p2
+
+CREATE PROCEDURE p2(
+ INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+ OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION(ÐÁÒÁÍ1) AS c2,
+ COLLATION(ÐÁÒÁÍ2) AS c3;
+
+ SELECT
+ COLLATION('ÔÅËÓÔ') AS c4,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+ COLLATION(_utf8 'текÑÑ‚') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET ÐÁÒÁÍ1 = 'a';
+ SET ÐÁÒÁÍ2 = 'b';
+END|
+
+--echo
+
+# - Procedure p3
+
+CREATE PROCEDURE mysqltest2.p3(
+ INOUT ÐÁÒÁÍ1 CHAR(10),
+ OUT ÐÁÒÁÍ2 CHAR(10))
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10);
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION(ÐÁÒÁÍ1) AS c2,
+ COLLATION(ÐÁÒÁÍ2) AS c3;
+
+ SELECT
+ COLLATION('ÔÅËÓÔ') AS c4,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+ COLLATION(_utf8 'текÑÑ‚') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET ÐÁÒÁÍ1 = 'a';
+ SET ÐÁÒÁÍ2 = 'b';
+END|
+
+--echo
+
+# - Procedure p4
+
+CREATE PROCEDURE mysqltest2.p4(
+ INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8,
+ OUT ÐÁÒÁÍ2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION(ÐÁÒÁÍ1) AS c2,
+ COLLATION(ÐÁÒÁÍ2) AS c3;
+
+ SELECT
+ COLLATION('ÔÅËÓÔ') AS c4,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c5,
+ COLLATION(_utf8 'текÑÑ‚') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET ÐÁÒÁÍ1 = 'a';
+ SET ÐÁÒÁÍ2 = 'b';
+END|
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_sp.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Change connection to flush SP-cache;
+
+--connect (con2,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con2
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+CALL p1(@a, @b)|
+CALL p2(@a, @b)|
+CALL mysqltest2.p3(@a, @b)|
+CALL mysqltest2.p4(@a, @b)|
+
+# - Restore environment;
+
+set names koi8r|
+
+# - Check!
+
+--source include/ddl_i18n.check_sp.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1, mysqltest2;
+
+--echo
+--echo ---> Dump of mysqltest1
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest1
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
+
+--echo
+--echo ---> Dump of mysqltest2
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest2
+
+--echo
+--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
+
+# - Clean mysqltest1, mysqltest2;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
+
+--echo ---> Restoring mysqltest2...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
+
+#
+# Third-round checks.
+#
+
+# - Change connection to flush SP-cache;
+
+--connect (con3,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con3
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+CALL p1(@a, @b)|
+CALL p2(@a, @b)|
+CALL mysqltest2.p3(@a, @b)|
+CALL mysqltest2.p4(@a, @b)|
+
+# - Restore environment;
+
+set names koi8r|
+
+# - Check!
+
+--source include/ddl_i18n.check_sp.inc
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+###########################################################################
+#
+# * Triggers.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Triggers
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set;
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create tables for triggers;
+
+CREATE TABLE t1(c INT)|
+CREATE TABLE mysqltest2.t1(c INT)|
+
+# - Create log tables;
+
+CREATE TABLE log(msg VARCHAR(255))|
+CREATE TABLE mysqltest2.log(msg VARCHAR(255))|
+
+
+# - Create triggers -- with and without explicit CHARSET-clause for
+# SP-variable;
+#
+
+--echo
+
+# - Trigger trg1
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10);
+
+ INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+ INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @a1 = 'ÔÅËÓÔ';
+ SET @a1 = _koi8r 'ÔÅËÓÔ';
+ SET @a2 = _utf8 'текÑÑ‚';
+END|
+
+--echo
+
+# - Trigger trg2
+
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+ INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @b1 = 'ÔÅËÓÔ';
+ SET @b1 = _koi8r 'ÔÅËÓÔ';
+ SET @b2 = _utf8 'текÑÑ‚';
+END|
+
+--echo
+
+# - Trigger trg3
+
+CREATE TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10);
+
+ INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+ INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @a1 = 'ÔÅËÓÔ';
+ SET @a1 = _koi8r 'ÔÅËÓÔ';
+ SET @a2 = _utf8 'текÑÑ‚';
+END|
+
+--echo
+
+# - Trigger trg4
+
+CREATE TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ INSERT INTO log VALUES(COLLATION(ÐÅÒÅÍ1));
+ INSERT INTO log VALUES(COLLATION('ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @b1 = 'ÔÅËÓÔ';
+ SET @b1 = _koi8r 'ÔÅËÓÔ';
+ SET @b2 = _utf8 'текÑÑ‚';
+END|
+
+--echo
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_triggers.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Flush table cache;
+
+ALTER TABLE t1 ADD COLUMN fake INT|
+ALTER TABLE t1 DROP COLUMN fake|
+
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+# - Switch environment variables and initiate loading of triggers
+# (connect using NULL database);
+
+--connect (con2,localhost,root,,)
+--echo
+--echo ---> connection: con2
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+
+# - Restore environment;
+
+set names koi8r|
+
+use mysqltest1|
+
+# - Check!
+
+--source include/ddl_i18n.check_triggers.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1, mysqltest2;
+
+--echo
+--echo ---> Dump of mysqltest1
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
+
+--echo
+--echo ---> Dump of mysqltest2
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2
+
+--echo
+--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
+
+# - Clean mysqltest1, mysqltest2;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
+
+--echo ---> Restoring mysqltest2...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
+
+#
+# Third-round checks.
+#
+
+# - Flush table cache;
+
+ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest1.t1 DROP COLUMN fake|
+
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+# - Switch environment variables and initiate loading of triggers
+# (connect using NULL database);
+
+--connect (con3,localhost,root,,)
+--echo
+--echo ---> connection: con3
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+
+# - Restore environment;
+
+set names koi8r|
+
+use mysqltest1|
+
+# - Check!
+
+--source include/ddl_i18n.check_triggers.inc
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+###########################################################################
+#
+# * Events
+#
+# We don't have EXECUTE EVENT so far, so this test is limited. It checks that
+# event with non-latin1 symbols can be created, dumped, restored and SHOW
+# statements work properly.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Events
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create two stored routines -- with and without explicit
+# CHARSET-clause for SP-variable;
+#
+
+--echo
+
+# - Event ev1
+
+CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10);
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION('ÔÅËÓÔ') AS c2,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+ COLLATION(_utf8 'текÑÑ‚') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+# - Event ev2
+
+CREATE EVENT ev2 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION('ÔÅËÓÔ') AS c2,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+ COLLATION(_utf8 'текÑÑ‚') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+# - Event ev3
+
+CREATE EVENT mysqltest2.ev3 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION('ÔÅËÓÔ') AS c2,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+ COLLATION(_utf8 'текÑÑ‚') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+# - Event ev4
+
+CREATE EVENT mysqltest2.ev4 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE ÐÅÒÅÍ1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(ÐÅÒÅÍ1) AS c1,
+ COLLATION('ÔÅËÓÔ') AS c2,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c3,
+ COLLATION(_utf8 'текÑÑ‚') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_events.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Change connection to flush cache;
+
+--connect (con2,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con2
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+--enable_result_log
+
+# - Restore environment;
+
+set names koi8r|
+
+# - Check!
+
+--source include/ddl_i18n.check_events.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1, mysqltest2;
+
+--echo
+--echo ---> Dump of mysqltest1
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest1
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
+
+--echo
+--echo ---> Dump of mysqltest2
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest2
+
+--echo
+--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
+
+# - Clean mysqltest1, mysqltest2;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
+
+--echo ---> Restoring mysqltest2...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
+
+#
+# Third-round checks.
+#
+
+# - Change connection to flush cache;
+
+--connect (con3,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con3
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+--enable_result_log
+
+# - Restore environment;
+
+set names koi8r|
+
+# - Check!
+
+--source include/ddl_i18n.check_events.inc
+
+###########################################################################
+#
+# * DDL statements inside stored routine.
+#
+# Here we check that DDL statements use actual database collation even if they
+# are called from stored routine.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo DDL statements within stored routine.
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create procedures;
+
+--echo
+
+CREATE PROCEDURE p1()
+BEGIN
+ CREATE TABLE t1(col1 VARCHAR(10));
+ SHOW CREATE TABLE t1;
+END|
+
+--echo
+
+CREATE PROCEDURE mysqltest2.p2()
+BEGIN
+ CREATE TABLE t2(col1 VARCHAR(10));
+ SHOW CREATE TABLE t2;
+END|
+
+--echo
+
+#
+# First-round checks.
+#
+
+CALL p1()|
+
+--echo
+
+SHOW CREATE TABLE t1|
+
+--echo
+--echo
+
+CALL mysqltest2.p2()|
+
+--echo
+
+SHOW CREATE TABLE mysqltest2.t2|
+
+#
+# Alter database.
+#
+
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp1251_general_cs|
+ALTER DATABASE mysqltest2 COLLATE cp1251_general_cs|
+
+DROP TABLE t1|
+DROP TABLE mysqltest2.t2|
+
+--echo
+
+#
+# Second-round checks.
+#
+
+CALL p1()|
+
+--echo
+
+SHOW CREATE TABLE t1|
+
+--echo
+--echo
+
+CALL mysqltest2.p2()|
+
+--echo
+
+SHOW CREATE TABLE mysqltest2.t2|
+
+###########################################################################
+#
+# That's it.
+#
+###########################################################################
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test
new file mode 100644
index 00000000000..8fbf819a1b0
--- /dev/null
+++ b/mysql-test/t/ddl_i18n_utf8.test
@@ -0,0 +1,1112 @@
+# Objects to test:
+# - stored procedures/functions;
+# - triggers;
+# - events;
+# - views;
+#
+# For stored routines:
+# - create a database with collation utf8_unicode_ci;
+# - create an object, which
+# - contains SP-var with explicit CHARSET-clause;
+# - contains SP-var without CHARSET-clause;
+# - contains text constant;
+# - has localized routine/parameter names;
+# - check:
+# - execute;
+# - SHOW CREATE output;
+# - SHOW output;
+# - SELECT FROM INFORMATION_SCHEMA output;
+# - alter database character set;
+# - change connection collation;
+# - check again;
+# - dump definition using mysqldump;
+# - drop object;
+# - restore object;
+#
+
+###########################################################################
+#
+# NOTE: this file contains text in UTF8 and KOI8-R encodings.
+#
+###########################################################################
+
+--source include/have_utf8.inc
+--source include/have_cp866.inc
+--source include/have_cp1251.inc
+--source include/have_koi8r.inc
+
+###########################################################################
+
+set names utf8;
+delimiter |;
+
+###########################################################################
+#
+# * Views.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Views
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+CREATE TABLE t1(кол INT)|
+INSERT INTO t1 VALUES(1)|
+
+# - Create views;
+
+--echo
+
+CREATE VIEW v1 AS
+ SELECT 'теÑÑ‚' AS c1, кол AS c2
+ FROM t1|
+
+--echo
+
+CREATE VIEW v2 AS SELECT _koi8r'ÔÅÓÔ' as c1|
+
+--echo
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_views.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Change connection to flush cache;
+
+--connect (con2,localhost,root,,)
+--echo
+--echo ---> connection: con2
+
+# - Switch environment variables and trigger loading views;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+--enable_result_log
+
+use mysqltest1|
+
+# - Restore environment;
+
+set names utf8|
+
+# - Check!
+
+--source include/ddl_i18n.check_views.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1;
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
+
+--exec $MYSQL_DUMP --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
+
+# - Clean mysqltest1;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
+
+#
+# Third-round checks.
+#
+
+# - Change connection to flush cache;
+
+--connect (con3,localhost,root,,)
+--echo
+--echo ---> connection: con3
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SELECT * FROM mysqltest1.v1|
+SELECT * FROM mysqltest1.v2|
+--enable_result_log
+
+use mysqltest1|
+
+# - Restore environment;
+
+set names utf8|
+
+# - Check!
+
+--source include/ddl_i18n.check_views.inc
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+
+###########################################################################
+#
+# * Stored procedures/functions.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Stored procedures/functions
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create two stored routines -- with and without explicit
+# CHARSET-clause for SP-variable;
+#
+
+--echo
+
+# - Procedure p1
+
+CREATE PROCEDURE p1(
+ INOUT парам1 CHAR(10),
+ OUT парам2 CHAR(10))
+BEGIN
+ DECLARE перем1 CHAR(10);
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION(парам1) AS c2,
+ COLLATION(парам2) AS c3;
+
+ SELECT
+ COLLATION('текÑÑ‚') AS c4,
+ COLLATION(_utf8 'текÑÑ‚') AS c5,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET парам1 = 'a';
+ SET парам2 = 'b';
+END|
+
+--echo
+
+# - Procedure p2
+
+CREATE PROCEDURE p2(
+ INOUT парам1 CHAR(10) CHARACTER SET utf8,
+ OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION(парам1) AS c2,
+ COLLATION(парам2) AS c3;
+
+ SELECT
+ COLLATION('текÑÑ‚') AS c4,
+ COLLATION(_utf8 'текÑÑ‚') AS c5,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET парам1 = 'a';
+ SET парам2 = 'b';
+END|
+
+--echo
+
+# - Procedure p3
+
+CREATE PROCEDURE mysqltest2.p3(
+ INOUT парам1 CHAR(10),
+ OUT парам2 CHAR(10))
+BEGIN
+ DECLARE перем1 CHAR(10);
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION(парам1) AS c2,
+ COLLATION(парам2) AS c3;
+
+ SELECT
+ COLLATION('текÑÑ‚') AS c4,
+ COLLATION(_utf8 'текÑÑ‚') AS c5,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET парам1 = 'a';
+ SET парам2 = 'b';
+END|
+
+--echo
+
+# - Procedure p4
+
+CREATE PROCEDURE mysqltest2.p4(
+ INOUT парам1 CHAR(10) CHARACTER SET utf8,
+ OUT парам2 CHAR(10) CHARACTER SET utf8)
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION(парам1) AS c2,
+ COLLATION(парам2) AS c3;
+
+ SELECT
+ COLLATION('текÑÑ‚') AS c4,
+ COLLATION(_utf8 'текÑÑ‚') AS c5,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c6,
+ @@collation_connection AS c7,
+ @@character_set_client AS c8;
+
+ SET парам1 = 'a';
+ SET парам2 = 'b';
+END|
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_sp.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Change connection to flush SP-cache;
+
+--connect (con2,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con2
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+CALL p1(@a, @b)|
+CALL p2(@a, @b)|
+CALL mysqltest2.p3(@a, @b)|
+CALL mysqltest2.p4(@a, @b)|
+
+# - Restore environment;
+
+set names utf8|
+
+# - Check!
+
+--source include/ddl_i18n.check_sp.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1, mysqltest2;
+
+--echo
+--echo ---> Dump of mysqltest1
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest1
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
+
+--echo
+--echo ---> Dump of mysqltest2
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest2
+
+--echo
+--echo ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
+
+--exec $MYSQL_DUMP --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
+
+# - Clean mysqltest1, mysqltest2;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
+
+--echo ---> Restoring mysqltest2...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
+
+#
+# Third-round checks.
+#
+
+# - Change connection to flush SP-cache;
+
+--connect (con3,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con3
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+CALL p1(@a, @b)|
+CALL p2(@a, @b)|
+CALL mysqltest2.p3(@a, @b)|
+CALL mysqltest2.p4(@a, @b)|
+
+# - Restore environment;
+
+set names utf8|
+
+# - Check!
+
+--source include/ddl_i18n.check_sp.inc
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+###########################################################################
+#
+# * Triggers.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Triggers
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set;
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create tables for triggers;
+
+CREATE TABLE t1(c INT)|
+CREATE TABLE mysqltest2.t1(c INT)|
+
+# - Create log tables;
+
+CREATE TABLE log(msg VARCHAR(255))|
+CREATE TABLE mysqltest2.log(msg VARCHAR(255))|
+
+
+# - Create triggers -- with and without explicit CHARSET-clause for
+# SP-variable;
+#
+
+--echo
+
+# - Trigger trg1
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE перем1 CHAR(10);
+
+ INSERT INTO log VALUES(COLLATION(перем1));
+ INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @a1 = 'текÑÑ‚';
+ SET @a2 = _utf8 'текÑÑ‚';
+ SET @a3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+--echo
+
+# - Trigger trg2
+
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ INSERT INTO log VALUES(COLLATION(перем1));
+ INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @b1 = 'текÑÑ‚';
+ SET @b2 = _utf8 'текÑÑ‚';
+ SET @b3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+--echo
+
+# - Trigger trg3
+
+CREATE TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+ DECLARE перем1 CHAR(10);
+
+ INSERT INTO log VALUES(COLLATION(перем1));
+ INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @a1 = 'текÑÑ‚';
+ SET @a2 = _utf8 'текÑÑ‚';
+ SET @a3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+--echo
+
+# - Trigger trg4
+
+CREATE TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ INSERT INTO log VALUES(COLLATION(перем1));
+ INSERT INTO log VALUES(COLLATION('текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_utf8 'текÑÑ‚'));
+ INSERT INTO log VALUES(COLLATION(_koi8r 'ÔÅËÓÔ'));
+ INSERT INTO log VALUES(@@collation_connection);
+ INSERT INTO log VALUES(@@character_set_client);
+
+ SET @b1 = 'текÑÑ‚';
+ SET @b2 = _utf8 'текÑÑ‚';
+ SET @b3 = _koi8r 'ÔÅËÓÔ';
+END|
+
+--echo
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_triggers.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Flush table cache;
+
+ALTER TABLE t1 ADD COLUMN fake INT|
+ALTER TABLE t1 DROP COLUMN fake|
+
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+# - Switch environment variables and initiate loading of triggers
+# (connect using NULL database);
+
+--connect (con2,localhost,root,,)
+--echo
+--echo ---> connection: con2
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+
+# - Restore environment;
+
+set names utf8|
+
+use mysqltest1|
+
+# - Check!
+
+--source include/ddl_i18n.check_triggers.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1, mysqltest2;
+
+--echo
+--echo ---> Dump of mysqltest1
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
+
+--echo
+--echo ---> Dump of mysqltest2
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2
+
+--echo
+--echo ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
+
+--exec $MYSQL_DUMP --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
+
+# - Clean mysqltest1, mysqltest2;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
+
+--echo ---> Restoring mysqltest2...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
+
+#
+# Third-round checks.
+#
+
+# - Flush table cache;
+
+ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest1.t1 DROP COLUMN fake|
+
+ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
+ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
+
+# - Switch environment variables and initiate loading of triggers
+# (connect using NULL database);
+
+--connect (con3,localhost,root,,)
+--echo
+--echo ---> connection: con3
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+INSERT INTO mysqltest1.t1 VALUES(0)|
+INSERT INTO mysqltest2.t1 VALUES(0)|
+
+DELETE FROM mysqltest1.log|
+DELETE FROM mysqltest2.log|
+
+# - Restore environment;
+
+set names utf8|
+
+use mysqltest1|
+
+# - Check!
+
+--source include/ddl_i18n.check_triggers.inc
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+###########################################################################
+#
+# * Events
+#
+# We don't have EXECUTE EVENT so far, so this test is limited. It checks that
+# event with non-latin1 symbols can be created, dumped, restored and SHOW
+# statements work properly.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo Events
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create two stored routines -- with and without explicit
+# CHARSET-clause for SP-variable;
+#
+
+--echo
+
+# - Event ev1
+
+CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE перем1 CHAR(10);
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION('текÑÑ‚') AS c2,
+ COLLATION(_utf8 'текÑÑ‚') AS c3,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+# - Event ev2
+
+CREATE EVENT ev2 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION('текÑÑ‚') AS c2,
+ COLLATION(_utf8 'текÑÑ‚') AS c3,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+# - Event ev3
+
+CREATE EVENT mysqltest2.ev3 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION('текÑÑ‚') AS c2,
+ COLLATION(_utf8 'текÑÑ‚') AS c3,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+# - Event ev4
+
+CREATE EVENT mysqltest2.ev4 ON SCHEDULE AT '2030-01-01 00:00:00' DO
+BEGIN
+ DECLARE перем1 CHAR(10) CHARACTER SET utf8;
+
+ SELECT
+ COLLATION(перем1) AS c1,
+ COLLATION('текÑÑ‚') AS c2,
+ COLLATION(_utf8 'текÑÑ‚') AS c3,
+ COLLATION(_koi8r 'ÔÅËÓÔ') AS c4,
+ @@collation_connection AS c5,
+ @@character_set_client AS c6;
+END|
+
+--echo
+
+
+#
+# First-round checks.
+#
+
+--source include/ddl_i18n.check_events.inc
+
+#
+# Change running environment (alter database character set, change session
+# variables).
+#
+
+--echo
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
+ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
+
+#
+# Second-round checks:
+#
+
+# - Change connection to flush cache;
+
+--connect (con2,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con2
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+--enable_result_log
+
+# - Restore environment;
+
+set names utf8|
+
+# - Check!
+
+--source include/ddl_i18n.check_events.inc
+
+#
+# Check mysqldump.
+#
+
+# - Dump mysqltest1, mysqltest2;
+
+--echo
+--echo ---> Dump of mysqltest1
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest1
+
+--echo
+--echo ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
+
+--echo
+--echo ---> Dump of mysqltest2
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest2
+
+--echo
+--echo ---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql
+
+--exec $MYSQL_DUMP --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
+
+# - Clean mysqltest1, mysqltest2;
+
+--echo
+--echo
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+# - Restore mysqltest1;
+
+--echo
+--echo
+
+--echo ---> Restoring mysqltest1...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
+
+--echo ---> Restoring mysqltest2...
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
+
+#
+# Third-round checks.
+#
+
+# - Change connection to flush cache;
+
+--connect (con3,localhost,root,,mysqltest1)
+--echo
+--echo ---> connection: con3
+
+# - Switch environment variables and trigger loading stored procedures;
+
+SET @@character_set_client= cp1251|
+SET @@character_set_results= cp1251|
+SET @@collation_connection= cp1251_general_ci|
+
+--disable_result_log
+SHOW CREATE EVENT ev1|
+SHOW CREATE EVENT ev2|
+SHOW CREATE EVENT mysqltest2.ev3|
+SHOW CREATE EVENT mysqltest2.ev4|
+--enable_result_log
+
+# - Restore environment;
+
+set names utf8|
+
+# - Check!
+
+--source include/ddl_i18n.check_events.inc
+
+###########################################################################
+#
+# * DDL statements inside stored routine.
+#
+# Here we check that DDL statements use actual database collation even if they
+# are called from stored routine.
+#
+###########################################################################
+
+--echo
+--echo -------------------------------------------------------------------
+--echo DDL statements within stored routine.
+--echo -------------------------------------------------------------------
+--echo
+
+#
+# Preparation:
+#
+
+# - Create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci|
+
+use mysqltest1|
+
+# - Create procedures;
+
+--echo
+
+CREATE PROCEDURE p1()
+BEGIN
+ CREATE TABLE t1(col1 VARCHAR(10));
+ SHOW CREATE TABLE t1;
+END|
+
+--echo
+
+CREATE PROCEDURE mysqltest2.p2()
+BEGIN
+ CREATE TABLE t2(col1 VARCHAR(10));
+ SHOW CREATE TABLE t2;
+END|
+
+--echo
+
+#
+# First-round checks.
+#
+
+CALL p1()|
+
+--echo
+
+SHOW CREATE TABLE t1|
+
+--echo
+--echo
+
+CALL mysqltest2.p2()|
+
+--echo
+
+SHOW CREATE TABLE mysqltest2.t2|
+
+#
+# Alter database.
+#
+
+--echo
+
+ALTER DATABASE mysqltest1 COLLATE cp1251_general_cs|
+ALTER DATABASE mysqltest2 COLLATE cp1251_general_cs|
+
+DROP TABLE t1|
+DROP TABLE mysqltest2.t2|
+
+--echo
+
+#
+# Second-round checks.
+#
+
+CALL p1()|
+
+--echo
+
+SHOW CREATE TABLE t1|
+
+--echo
+--echo
+
+CALL mysqltest2.p2()|
+
+--echo
+
+SHOW CREATE TABLE mysqltest2.t2|
+
+###########################################################################
+#
+# That's it.
+#
+###########################################################################
+
+#
+# Cleanup.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect con2
+--disconnect con3
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test
index dcb591352a8..d7232705b81 100644
--- a/mysql-test/t/events.test
+++ b/mysql-test/t/events.test
@@ -185,7 +185,30 @@ set names cp1251;
create event ðóóò21 on schedule every '50:23:59:95' day_second COMMENT 'òîâà å 1251 êîìåíòàð' do select 1;
--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT ðóóò21;
-insert into mysql.event (db, name, body, definer, interval_value, interval_field, originator) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND", 1);
+insert into mysql.event (
+ db,
+ name,
+ body,
+ definer,
+ interval_value,
+ interval_field,
+ originator,
+ character_set_client,
+ collation_connection,
+ db_collation,
+ body_utf8)
+values (
+ database(),
+ "root22",
+ "select 1",
+ user(),
+ 100,
+ "SECOND_MICROSECOND",
+ 1,
+ 'utf8',
+ 'utf8_general_ci',
+ 'utf8_general_ci',
+ 'select 1');
--error ER_NOT_SUPPORTED_YET
show create event root22;
--error ER_NOT_SUPPORTED_YET
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 755419cbf52..9babeddbae2 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -825,7 +825,7 @@ drop table t1;
use mysql;
INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL',
'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03',
-'2006-03-02 18:40:03','','');
+'2006-03-02 18:40:03','','','utf8','utf8_general_ci','utf8_general_ci','n/a');
select routine_name from information_schema.routines;
delete from proc where name='';
use test;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index af2c044ee10..bca2ce7101a 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -599,4 +599,55 @@ set names latin1;
--error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND
show columns from `#mysql50#????????`;
+#
+# SHOW CREATE TRIGGER test.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1(c1 INT);
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
+
+# Test.
+
+SHOW CREATE TRIGGER t1_bi;
+
+CREATE PROCEDURE p1() SHOW CREATE TRIGGER t1_bi;
+
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+
+PREPARE stmt1 FROM 'SHOW CREATE TRIGGER t1_bi';
+
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+EXECUTE stmt1;
+
+# Cleanup.
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
+DEALLOCATE PREPARE stmt1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test
index df07091d2de..04a581ab45f 100644
--- a/mysql-test/t/sp-destruct.test
+++ b/mysql-test/t/sp-destruct.test
@@ -94,26 +94,33 @@ insert into mysql.proc
(
db, name, type, specific_name, language, sql_data_access, is_deterministic,
security_type, param_list, returns, body, definer, created, modified,
- sql_mode, comment
+ sql_mode, comment, character_set_client, collation_connection, db_collation,
+ body_utf8
)
values
(
'test', 'bug14233_1', 'FUNCTION', 'bug14233_1', 'SQL', 'READS_SQL_DATA', 'NO',
'DEFINER', '', 'int(10)',
'select count(*) from mysql.user',
- 'root@localhost', NOW() , '0000-00-00 00:00:00', '', ''
+ 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
+ '', '', '',
+ 'select count(*) from mysql.user'
),
(
'test', 'bug14233_2', 'FUNCTION', 'bug14233_2', 'SQL', 'READS_SQL_DATA', 'NO',
'DEFINER', '', 'int(10)',
'begin declare x int; select count(*) into x from mysql.user; end',
- 'root@localhost', NOW() , '0000-00-00 00:00:00', '', ''
+ 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
+ '', '', '',
+ 'begin declare x int; select count(*) into x from mysql.user; end'
),
(
'test', 'bug14233_3', 'PROCEDURE', 'bug14233_3', 'SQL', 'READS_SQL_DATA','NO',
'DEFINER', '', '',
'alksj wpsj sa ^#!@ ',
- 'root@localhost', NOW() , '0000-00-00 00:00:00', '', ''
+ 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
+ '', '', '',
+ 'alksj wpsj sa ^#!@ '
);
--error ER_SP_PROC_TABLE_CORRUPT
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 29e759d7881..f5bad05a40a 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -6331,7 +6331,7 @@ set names utf8|
drop database if exists това_е_дълго_име_за_база_данни_нали|
--enable_warnings
create database това_е_дълго_име_за_база_данни_нали|
-INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','')|
+INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','', 'utf8', 'utf8_general_ci', 'utf8_general_ci', 'n/a')|
--error ER_SP_PROC_TABLE_CORRUPT
call това_е_дълго_име_за_база_данни_нали.това_е_процедура_Ñ_доÑта_дълго_име_нали_и_още_по_дълго()|
drop database това_е_дълго_име_за_база_данни_нали|
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index c441c7b5efc..ee807a1ae25 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -752,6 +752,11 @@ drop view v1;
#
# VIEWs with national characters
#
+
+SET @old_cs_client = @@character_set_client;
+SET @old_cs_results = @@character_set_results;
+SET @old_cs_connection = @@character_set_connection;
+
set names utf8;
create table tü (cü char);
create view vü as select cü from tü;
@@ -759,7 +764,10 @@ insert into vü values ('ü');
select * from vü;
drop view vü;
drop table tü;
-set names latin1;
+
+SET character_set_client = @old_cs_client;
+SET character_set_results = @old_cs_results;
+SET character_set_connection = @old_cs_connection;
#
# problem with used_tables() of outer reference resolved in VIEW
diff --git a/mysys/charset.c b/mysys/charset.c
index f6bcf3f5a4f..1c81e480404 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -595,17 +595,17 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
parameter and FALSE is returned. If there is no such character set,
"default_cs" is assigned to the "cs" and TRUE is returned.
- @param[out] cs Variable to store character set.
@param[in] cs_name Character set name.
@param[in] default_cs Default character set.
+ @param[out] cs Variable to store character set.
@return FALSE if character set was resolved successfully; TRUE if there
is no character set with given name.
*/
-bool resolve_charset(CHARSET_INFO **cs,
- const char *cs_name,
- CHARSET_INFO *default_cs)
+bool resolve_charset(const char *cs_name,
+ CHARSET_INFO *default_cs,
+ CHARSET_INFO **cs)
{
*cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0));
@@ -635,9 +635,9 @@ bool resolve_charset(CHARSET_INFO **cs,
collation with given name.
*/
-bool resolve_collation(CHARSET_INFO **cl,
- const char *cl_name,
- CHARSET_INFO *default_cl)
+bool resolve_collation(const char *cl_name,
+ CHARSET_INFO *default_cl,
+ CHARSET_INFO **cl)
{
*cl= get_charset_by_name(cl_name, MYF(0));
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index c779d174d12..f46c7c7027a 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -59,8 +59,7 @@ CREATE TABLE IF NOT EXISTS time_zone_transition_type ( Time_zone_id int unsign
CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones';
-CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-
+CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
@@ -75,7 +74,7 @@ CALL create_slow_log_table();;
DROP PROCEDURE create_slow_log_table;;
delimiter ;
-CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
+CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 8ee28cbf1cb..78e6a0ceb57 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -388,6 +388,29 @@ ALTER TABLE proc MODIFY db
MODIFY comment
char(64) collate utf8_bin DEFAULT '' NOT NULL;
+ALTER TABLE proc ADD character_set_client
+ char(32) collate utf8_bin DEFAULT NULL
+ AFTER comment;
+ALTER TABLE proc MODIFY character_set_client
+ char(32) collate utf8_bin DEFAULT NULL;
+
+ALTER TABLE proc ADD collation_connection
+ char(32) collate utf8_bin DEFAULT NULL
+ AFTER character_set_client;
+ALTER TABLE proc MODIFY collation_connection
+ char(32) collate utf8_bin DEFAULT NULL;
+
+ALTER TABLE proc ADD db_collation
+ char(32) collate utf8_bin DEFAULT NULL
+ AFTER collation_connection;
+ALTER TABLE proc MODIFY db_collation
+ char(32) collate utf8_bin DEFAULT NULL;
+
+ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
+ AFTER db_collation;
+ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL;
+
+
#
# EVENT privilege
#
@@ -446,6 +469,29 @@ ALTER TABLE event MODIFY COLUMN status ENUM('ENABLED','DISABLED','SLAVESIDE_DISA
ALTER TABLE event ADD COLUMN time_zone char(64) CHARACTER SET latin1
NOT NULL DEFAULT 'SYSTEM' AFTER originator;
+ALTER TABLE event ADD character_set_client
+ char(32) collate utf8_bin DEFAULT NULL
+ AFTER time_zone;
+ALTER TABLE event MODIFY character_set_client
+ char(32) collate utf8_bin DEFAULT NULL;
+
+ALTER TABLE event ADD collation_connection
+ char(32) collate utf8_bin DEFAULT NULL
+ AFTER character_set_client;
+ALTER TABLE event MODIFY collation_connection
+ char(32) collate utf8_bin DEFAULT NULL;
+
+ALTER TABLE event ADD db_collation
+ char(32) collate utf8_bin DEFAULT NULL
+ AFTER collation_connection;
+ALTER TABLE event MODIFY db_collation
+ char(32) collate utf8_bin DEFAULT NULL;
+
+ALTER TABLE event ADD body_utf8 longblob DEFAULT NULL
+ AFTER db_collation;
+ALTER TABLE event MODIFY body_utf8 longblob DEFAULT NULL;
+
+
#
# TRIGGER privilege
#
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 77dc33e6265..786a31497a9 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -23,6 +23,126 @@
#define EVEX_MAX_INTERVAL_VALUE 1000000000L
+/*************************************************************************/
+
+/**
+ Event_creation_ctx -- creation context of events.
+*/
+
+class Event_creation_ctx :public Stored_program_creation_ctx,
+ public Sql_alloc
+{
+public:
+ static bool load_from_db(THD *thd,
+ MEM_ROOT *event_mem_root,
+ const char *db_name,
+ const char *event_name,
+ TABLE *event_tbl,
+ Stored_program_creation_ctx **ctx);
+
+public:
+ virtual Stored_program_creation_ctx *clone(MEM_ROOT *mem_root)
+ {
+ return new (mem_root)
+ Event_creation_ctx(m_client_cs, m_connection_cl, m_db_cl);
+ }
+
+protected:
+ virtual Object_creation_ctx *create_backup_ctx(THD *thd) const
+ {
+ /*
+ We can avoid usual backup/restore employed in stored programs since we
+ know that this is a top level statement and the worker thread is
+ allocated exclusively to execute this event.
+ */
+
+ return NULL;
+ }
+
+private:
+ Event_creation_ctx(CHARSET_INFO *client_cs,
+ CHARSET_INFO *connection_cl,
+ CHARSET_INFO *db_cl)
+ : Stored_program_creation_ctx(client_cs, connection_cl, db_cl)
+ { }
+};
+
+/**************************************************************************
+ Event_creation_ctx implementation.
+**************************************************************************/
+
+bool
+Event_creation_ctx::load_from_db(THD *thd,
+ MEM_ROOT *event_mem_root,
+ const char *db_name,
+ const char *event_name,
+ TABLE *event_tbl,
+ Stored_program_creation_ctx **ctx)
+{
+ /* Load character set/collation attributes. */
+
+ CHARSET_INFO *client_cs;
+ CHARSET_INFO *connection_cl;
+ CHARSET_INFO *db_cl;
+
+ bool invalid_creation_ctx= FALSE;
+
+ if (load_charset(event_mem_root,
+ event_tbl->field[ET_FIELD_CHARACTER_SET_CLIENT],
+ thd->variables.character_set_client,
+ &client_cs))
+ {
+ sql_print_warning("Event '%s'.'%s': invalid value "
+ "in column mysql.event.character_set_client.",
+ (const char *) db_name,
+ (const char *) event_name);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (load_collation(event_mem_root,
+ event_tbl->field[ET_FIELD_COLLATION_CONNECTION],
+ thd->variables.collation_connection,
+ &connection_cl))
+ {
+ sql_print_warning("Event '%s'.'%s': invalid value "
+ "in column mysql.event.collation_connection.",
+ (const char *) db_name,
+ (const char *) event_name);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (load_collation(event_mem_root,
+ event_tbl->field[ET_FIELD_DB_COLLATION],
+ NULL,
+ &db_cl))
+ {
+ sql_print_warning("Event '%s'.'%s': invalid value "
+ "in column mysql.event.db_collation.",
+ (const char *) db_name,
+ (const char *) event_name);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ /*
+ If we failed to resolve the database collation, load the default one
+ from the disk.
+ */
+
+ if (!db_cl)
+ db_cl= get_default_db_collation(thd, db_name);
+
+ /* Create the context. */
+
+ *ctx= new Event_creation_ctx(client_cs, connection_cl, db_cl);
+
+ return invalid_creation_ctx;
+}
+
+/*************************************************************************/
+
/*
Initiliazes dbname and name of an Event_queue_element_for_exec
object
@@ -761,6 +881,7 @@ Event_timed::init()
/**
Load an event's body from a row from mysql.event.
+
@details This method is silent on errors and should behave like that.
Callers should handle throwing of error messages. The reason is that the
class should not know about how to deal with communication.
@@ -797,6 +918,9 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
if (load_time_zone(thd, tz_name))
DBUG_RETURN(TRUE);
+ Event_creation_ctx::load_from_db(thd, &mem_root, dbname.str, name.str, table,
+ &creation_ctx);
+
ptr= strchr(definer.str, '@');
if (! ptr)
@@ -979,9 +1103,20 @@ Event_timed::load_from_row(THD *thd, TABLE *table)
if (load_string_fields(table->field,
ET_FIELD_BODY, &body,
+ ET_FIELD_BODY_UTF8, &body_utf8,
ET_FIELD_COUNT))
DBUG_RETURN(TRUE);
+ if (Event_creation_ctx::load_from_db(thd, &mem_root, dbname.str, name.str,
+ table, &creation_ctx))
+ {
+ push_warning_printf(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_EVENT_INVALID_CREATION_CTX,
+ ER(ER_EVENT_INVALID_CREATION_CTX),
+ (const char *) dbname.str,
+ (const char *) name.str);
+ }
ptr= strchr(definer.str, '@');
@@ -1743,7 +1878,6 @@ Event_job_data::execute(THD *thd, bool drop)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context event_sctx, *save_sctx= NULL;
#endif
- CHARSET_INFO *charset_connection;
List<Item> empty_item_list;
bool ret= TRUE;
@@ -1808,12 +1942,6 @@ Event_job_data::execute(THD *thd, bool drop)
this is a top level statement and the worker thread is
allocated exclusively to execute this event.
*/
- charset_connection= get_charset_by_csname("utf8",
- MY_CS_PRIMARY, MYF(MY_WME));
- thd->variables.character_set_client= charset_connection;
- thd->variables.character_set_results= charset_connection;
- thd->variables.collation_connection= charset_connection;
- thd->update_charset();
thd->variables.sql_mode= sql_mode;
thd->variables.time_zone= time_zone;
@@ -1830,7 +1958,7 @@ Event_job_data::execute(THD *thd, bool drop)
Lex_input_stream lip(thd, thd->query, thd->query_length);
lex_start(thd);
- if (parse_sql(thd, &lip))
+ if (parse_sql(thd, &lip, creation_ctx))
{
sql_print_error("Event Scheduler: "
"%serror during compilation of %s.%s",
@@ -1850,6 +1978,7 @@ Event_job_data::execute(THD *thd, bool drop)
sphead->m_flags|= sp_head::LOG_GENERAL_LOG;
sphead->set_info(0, 0, &thd->lex->sp_chistics, sql_mode);
+ sphead->set_creation_ctx(creation_ctx);
sphead->optimize();
ret= sphead->execute_procedure(thd, &empty_item_list);
diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h
index d79732780ff..a8e7d1720ca 100644
--- a/sql/event_data_objects.h
+++ b/sql/event_data_objects.h
@@ -20,8 +20,6 @@
#define EVEX_BAD_PARAMS -5
#define EVEX_MICROSECOND_UNSUP -6
-class sp_head;
-class Sql_alloc;
class Event_queue_element_for_exec
{
@@ -151,6 +149,9 @@ public:
ulong sql_mode;
+ class Stored_program_creation_ctx *creation_ctx;
+ LEX_STRING body_utf8;
+
Event_timed();
virtual ~Event_timed();
@@ -174,6 +175,8 @@ public:
ulong sql_mode;
+ class Stored_program_creation_ctx *creation_ctx;
+
Event_job_data();
virtual bool
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index 703c4160216..a16a04739e2 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -123,6 +123,26 @@ const TABLE_FIELD_W_TYPE event_table_fields[ET_FIELD_COUNT] =
{ C_STRING_WITH_LEN("time_zone") },
{ C_STRING_WITH_LEN("char(64)") },
{ C_STRING_WITH_LEN("latin1") }
+ },
+ {
+ { C_STRING_WITH_LEN("character_set_client") },
+ { C_STRING_WITH_LEN("char(32)") },
+ { C_STRING_WITH_LEN("utf8") }
+ },
+ {
+ { C_STRING_WITH_LEN("collation_connection") },
+ { C_STRING_WITH_LEN("char(32)") },
+ { C_STRING_WITH_LEN("utf8") }
+ },
+ {
+ { C_STRING_WITH_LEN("db_collation") },
+ { C_STRING_WITH_LEN("char(32)") },
+ { C_STRING_WITH_LEN("utf8") }
+ },
+ {
+ { C_STRING_WITH_LEN("body_utf8") },
+ { C_STRING_WITH_LEN("longblob") },
+ { NULL, 0 }
}
};
@@ -135,6 +155,7 @@ const TABLE_FIELD_W_TYPE event_table_fields[ET_FIELD_COUNT] =
@param thd THD
@param table The row to fill out
@param et Event's data
+ @param sp Event stored routine
@param is_update CREATE EVENT or ALTER EVENT
@retval FALSE success
@@ -281,6 +302,33 @@ mysql_event_fill_row(THD *thd,
goto err_truncate;
}
+ fields[ET_FIELD_CHARACTER_SET_CLIENT]->set_notnull();
+ fields[ET_FIELD_CHARACTER_SET_CLIENT]->store(
+ thd->variables.character_set_client->csname,
+ strlen(thd->variables.character_set_client->csname),
+ system_charset_info);
+
+ fields[ET_FIELD_COLLATION_CONNECTION]->set_notnull();
+ fields[ET_FIELD_COLLATION_CONNECTION]->store(
+ thd->variables.collation_connection->name,
+ strlen(thd->variables.collation_connection->name),
+ system_charset_info);
+
+ {
+ CHARSET_INFO *db_cl= get_default_db_collation(thd, et->dbname.str);
+
+ fields[ET_FIELD_DB_COLLATION]->set_notnull();
+ fields[ET_FIELD_DB_COLLATION]->store(
+ db_cl->name, strlen(db_cl->name), system_charset_info);
+ }
+
+ if (et->body_changed)
+ {
+ fields[ET_FIELD_BODY_UTF8]->set_notnull();
+ fields[ET_FIELD_BODY_UTF8]->store(
+ sp->m_body_utf8.str, sp->m_body_utf8.length, system_charset_info);
+ }
+
DBUG_RETURN(FALSE);
err_truncate:
diff --git a/sql/event_db_repository.h b/sql/event_db_repository.h
index 64e19854933..b60d2ea7afc 100644
--- a/sql/event_db_repository.h
+++ b/sql/event_db_repository.h
@@ -42,6 +42,10 @@ enum enum_events_table_field
ET_FIELD_COMMENT,
ET_FIELD_ORIGINATOR,
ET_FIELD_TIME_ZONE,
+ ET_FIELD_CHARACTER_SET_CLIENT,
+ ET_FIELD_COLLATION_CONNECTION,
+ ET_FIELD_DB_COLLATION,
+ ET_FIELD_BODY_UTF8,
ET_FIELD_COUNT /* a cool trick to count the number of fields :) */
};
@@ -53,6 +57,7 @@ events_table_index_read_for_db(THD *thd, TABLE *schema_table,
int
events_table_scan_all(THD *thd, TABLE *schema_table, TABLE *event_table);
+
class Event_basic;
class Event_parse_data;
diff --git a/sql/events.cc b/sql/events.cc
index 2d1b3c59a4c..e48daeca63d 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -19,6 +19,7 @@
#include "event_db_repository.h"
#include "event_queue.h"
#include "event_scheduler.h"
+#include "sp_head.h" // for Stored_program_creation_ctx
/*
TODO list :
@@ -698,6 +699,15 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
field_list.push_back(new Item_empty_string("Create Event",
show_str.length()));
+ field_list.push_back(
+ new Item_empty_string("character_set_client", MY_CS_NAME_SIZE));
+
+ field_list.push_back(
+ new Item_empty_string("collation_connection", MY_CS_NAME_SIZE));
+
+ field_list.push_back(
+ new Item_empty_string("Database Collation", MY_CS_NAME_SIZE));
+
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
@@ -707,7 +717,16 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
protocol->store(et->name.str, et->name.length, system_charset_info);
protocol->store(sql_mode.str, sql_mode.length, system_charset_info);
protocol->store(tz_name->ptr(), tz_name->length(), system_charset_info);
- protocol->store(show_str.c_ptr(), show_str.length(), system_charset_info);
+ protocol->store(show_str.c_ptr(), show_str.length(), &my_charset_bin);
+ protocol->store(et->creation_ctx->get_client_cs()->csname,
+ strlen(et->creation_ctx->get_client_cs()->csname),
+ system_charset_info);
+ protocol->store(et->creation_ctx->get_connection_cl()->name,
+ strlen(et->creation_ctx->get_connection_cl()->name),
+ system_charset_info);
+ protocol->store(et->creation_ctx->get_db_cl()->name,
+ strlen(et->creation_ctx->get_db_cl()->name),
+ system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 5a50b03282f..ae7c4ca5f3f 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -150,6 +150,86 @@ extern MY_LOCALE *my_default_lc_time_names;
MY_LOCALE *my_locale_by_name(const char *name);
MY_LOCALE *my_locale_by_number(uint number);
+/*************************************************************************/
+
+/**
+ Object_creation_ctx -- interface for creation context of database objects
+ (views, stored routines, events, triggers). Creation context -- is a set
+ of attributes, that should be fixed at the creation time and then be used
+ each time the object is parsed or executed.
+*/
+
+class Object_creation_ctx
+{
+public:
+ Object_creation_ctx *set_n_backup(THD *thd);
+
+ void restore_env(THD *thd, Object_creation_ctx *backup_ctx);
+
+protected:
+ virtual Object_creation_ctx *create_backup_ctx(THD *thd) = 0;
+
+ virtual void change_env(THD *thd) const = 0;
+
+public:
+ virtual ~Object_creation_ctx()
+ { }
+};
+
+/*************************************************************************/
+
+/**
+ Default_object_creation_ctx -- default implementation of
+ Object_creation_ctx.
+*/
+
+class Default_object_creation_ctx : public Object_creation_ctx
+{
+public:
+ CHARSET_INFO *get_client_cs()
+ {
+ return m_client_cs;
+ }
+
+ CHARSET_INFO *get_connection_cl()
+ {
+ return m_connection_cl;
+ }
+
+protected:
+ Default_object_creation_ctx(THD *thd);
+
+ Default_object_creation_ctx(CHARSET_INFO *client_cs,
+ CHARSET_INFO *connection_cl);
+
+protected:
+ virtual Object_creation_ctx *create_backup_ctx(THD *thd);
+
+ virtual void change_env(THD *thd) const;
+
+protected:
+ /**
+ client_cs stores the value of character_set_client session variable.
+ The only character set attribute is used.
+
+ Client character set is included into query context, because we save
+ query in the original character set, which is client character set. So,
+ in order to parse the query properly we have to switch client character
+ set on parsing.
+ */
+ CHARSET_INFO *m_client_cs;
+
+ /**
+ connection_cl stores the value of collation_connection session
+ variable. Both character set and collation attributes are used.
+
+ Connection collation is included into query context, becase it defines
+ the character set and collation of text literals in internal
+ representation of query (item-objects).
+ */
+ CHARSET_INFO *m_connection_cl;
+};
+
/***************************************************************************
Configuration parameters
****************************************************************************/
@@ -618,7 +698,9 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
uint max_char_length, CHARSET_INFO *cs,
bool no_error);
-bool parse_sql(THD *thd, class Lex_input_stream *lip);
+bool parse_sql(THD *thd,
+ class Lex_input_stream *lip,
+ class Object_creation_ctx *creation_ctx);
enum enum_mysql_completiontype {
ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7,
@@ -2156,12 +2238,24 @@ bool schema_table_store_record(THD *thd, TABLE *table);
int item_create_init();
void item_create_cleanup();
+bool show_create_trigger(THD *thd, const sp_name *trg_name);
+
inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
{
lex_str->str= (char *) c_str;
lex_str->length= strlen(c_str);
}
+bool load_charset(MEM_ROOT *mem_root,
+ Field *field,
+ CHARSET_INFO *dflt_cs,
+ CHARSET_INFO **cs);
+
+bool load_collation(MEM_ROOT *mem_root,
+ Field *field,
+ CHARSET_INFO *dflt_cl,
+ CHARSET_INFO **cl);
+
#endif /* MYSQL_SERVER */
#endif /* MYSQL_CLIENT */
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 1dde977800b..0e3544415d1 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -6076,3 +6076,24 @@ ER_SLAVE_MASTER_COM_FAILURE
eng "Master command %s failed: %s"
ER_BINLOG_LOGGING_IMPOSSIBLE
eng "Binary logging not possible. Message: %s"
+
+ER_VIEW_NO_CREATION_CTX
+ eng "View `%-.64s`.`%-.64s` has no creation context"
+ER_VIEW_INVALID_CREATION_CTX
+ eng "Creation context of view `%-.64s`.`%-.64s' is invalid"
+
+ER_SR_INVALID_CREATION_CTX
+ eng "Creation context of stored routine `%-.64s`.`%-.64s` is invalid"
+
+ER_TRG_CORRUPTED_FILE
+ eng "Corrupted TRG file for table `%-.64s`.`%-.64s`"
+ER_TRG_NO_CREATION_CTX
+ eng "Triggers for table `%-.64s`.`%-.64s` have no creation context"
+ER_TRG_INVALID_CREATION_CTX
+ eng "Trigger creation context of table `%-.64s`.`%-.64s` is invalid"
+
+ER_EVENT_INVALID_CREATION_CTX
+ eng "Creation context of event `%-.64s`.`%-.64s` is invalid"
+
+ER_TRG_CANT_OPEN_TABLE
+ eng "Cannot open table for trigger `%-.64s`.`%-.64s`"
diff --git a/sql/sp.cc b/sql/sp.cc
index 6e890f638d0..aa2cf87bcee 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -35,7 +35,8 @@ static int
db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
ulong sql_mode, const char *params, const char *returns,
const char *body, st_sp_chistics &chistics,
- const char *definer, longlong created, longlong modified);
+ const char *definer, longlong created, longlong modified,
+ Stored_program_creation_ctx *creation_ctx);
/*
*
@@ -61,12 +62,191 @@ enum
MYSQL_PROC_FIELD_MODIFIED,
MYSQL_PROC_FIELD_SQL_MODE,
MYSQL_PROC_FIELD_COMMENT,
+ MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT,
+ MYSQL_PROC_FIELD_COLLATION_CONNECTION,
+ MYSQL_PROC_FIELD_DB_COLLATION,
+ MYSQL_PROC_FIELD_BODY_UTF8,
MYSQL_PROC_FIELD_COUNT
};
/* Tells what SP_DEFAULT_ACCESS should be mapped to */
#define SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL
+/*************************************************************************/
+
+/**
+ Stored_routine_creation_ctx -- creation context of stored routines
+ (stored procedures and functions).
+*/
+
+class Stored_routine_creation_ctx : public Stored_program_creation_ctx,
+ public Sql_alloc
+{
+public:
+ static Stored_routine_creation_ctx *
+ load_from_db(THD *thd, const class sp_name *name, TABLE *proc_tbl);
+
+public:
+ virtual Stored_program_creation_ctx *clone(MEM_ROOT *mem_root)
+ {
+ return new (mem_root) Stored_routine_creation_ctx(m_client_cs,
+ m_connection_cl,
+ m_db_cl);
+ }
+
+protected:
+ virtual Object_creation_ctx *create_backup_ctx(THD *thd) const
+ {
+ return new Stored_routine_creation_ctx(thd);
+ }
+
+private:
+ Stored_routine_creation_ctx(THD *thd)
+ : Stored_program_creation_ctx(thd)
+ { }
+
+ Stored_routine_creation_ctx(CHARSET_INFO *client_cs,
+ CHARSET_INFO *connection_cl,
+ CHARSET_INFO *db_cl)
+ : Stored_program_creation_ctx(client_cs, connection_cl, db_cl)
+ { }
+};
+
+/**************************************************************************
+ Stored_routine_creation_ctx implementation.
+**************************************************************************/
+
+bool load_charset(MEM_ROOT *mem_root,
+ Field *field,
+ CHARSET_INFO *dflt_cs,
+ CHARSET_INFO **cs)
+{
+ String cs_name;
+
+ if (get_field(mem_root, field, &cs_name))
+ {
+ *cs= dflt_cs;
+ return TRUE;
+ }
+
+ *cs= get_charset_by_csname(cs_name.c_ptr(), MY_CS_PRIMARY, MYF(0));
+
+ if (*cs == NULL)
+ {
+ *cs= dflt_cs;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*************************************************************************/
+
+bool load_collation(MEM_ROOT *mem_root,
+ Field *field,
+ CHARSET_INFO *dflt_cl,
+ CHARSET_INFO **cl)
+{
+ String cl_name;
+
+ if (get_field(mem_root, field, &cl_name))
+ {
+ *cl= dflt_cl;
+ return TRUE;
+ }
+
+ *cl= get_charset_by_name(cl_name.c_ptr(), MYF(0));
+
+ if (*cl == NULL)
+ {
+ *cl= dflt_cl;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*************************************************************************/
+
+Stored_routine_creation_ctx *
+Stored_routine_creation_ctx::load_from_db(THD *thd,
+ const sp_name *name,
+ TABLE *proc_tbl)
+{
+ /* Load character set/collation attributes. */
+
+ CHARSET_INFO *client_cs;
+ CHARSET_INFO *connection_cl;
+ CHARSET_INFO *db_cl;
+
+ const char *db_name= thd->strmake(name->m_db.str, name->m_db.length);
+ const char *sr_name= thd->strmake(name->m_name.str, name->m_name.length);
+
+ bool invalid_creation_ctx= FALSE;
+
+ if (load_charset(thd->mem_root,
+ proc_tbl->field[MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT],
+ thd->variables.character_set_client,
+ &client_cs))
+ {
+ sql_print_warning("Stored routine '%s'.'%s': invalid value "
+ "in column mysql.proc.character_set_client.",
+ (const char *) db_name,
+ (const char *) sr_name);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (load_collation(thd->mem_root,
+ proc_tbl->field[MYSQL_PROC_FIELD_COLLATION_CONNECTION],
+ thd->variables.collation_connection,
+ &connection_cl))
+ {
+ sql_print_warning("Stored routine '%s'.'%s': invalid value "
+ "in column mysql.proc.collation_connection.",
+ (const char *) db_name,
+ (const char *) sr_name);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (load_collation(thd->mem_root,
+ proc_tbl->field[MYSQL_PROC_FIELD_DB_COLLATION],
+ NULL,
+ &db_cl))
+ {
+ sql_print_warning("Stored routine '%s'.'%s': invalid value "
+ "in column mysql.proc.db_collation.",
+ (const char *) db_name,
+ (const char *) sr_name);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (invalid_creation_ctx)
+ {
+ push_warning_printf(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_SR_INVALID_CREATION_CTX,
+ ER(ER_SR_INVALID_CREATION_CTX),
+ (const char *) db_name,
+ (const char *) sr_name);
+ }
+
+ /*
+ If we failed to retrieve the database collation, load the default one
+ from the disk.
+ */
+
+ if (!db_cl)
+ db_cl= get_default_db_collation(thd, name->m_db.str);
+
+ /* Create the context. */
+
+ return new Stored_routine_creation_ctx(client_cs, connection_cl, db_cl);
+}
+
+/*************************************************************************/
/*
Open the mysql.proc table for read.
@@ -213,6 +393,8 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
String str(buff, sizeof(buff), &my_charset_bin);
ulong sql_mode;
Open_tables_state open_tables_state_backup;
+ Stored_program_creation_ctx *creation_ctx;
+
DBUG_ENTER("db_find_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",
type, (int) name->m_name.length, name->m_name.str));
@@ -313,13 +495,14 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
chistics.comment.str= ptr;
chistics.comment.length= length;
+ creation_ctx= Stored_routine_creation_ctx::load_from_db(thd, name, table);
+
close_system_tables(thd, &open_tables_state_backup);
table= 0;
ret= db_load_routine(thd, type, name, sphp,
sql_mode, params, returns, body, chistics,
- definer, created, modified);
-
+ definer, created, modified, creation_ctx);
done:
if (table)
close_system_tables(thd, &open_tables_state_backup);
@@ -331,7 +514,8 @@ static int
db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
ulong sql_mode, const char *params, const char *returns,
const char *body, st_sp_chistics &chistics,
- const char *definer, longlong created, longlong modified)
+ const char *definer, longlong created, longlong modified,
+ Stored_program_creation_ctx *creation_ctx)
{
LEX *old_lex= thd->lex, newlex;
String defstr;
@@ -361,7 +545,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
definer_user_name.str, &definer_user_name.length,
definer_host_name.str, &definer_host_name.length);
- defstr.set_charset(system_charset_info);
+ defstr.set_charset(creation_ctx->get_client_cs());
/*
We have to add DEFINER clause and provide proper routine characterstics in
@@ -381,6 +565,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
goto end;
}
+ /*
+ Change current database if needed.
+
+ collation_database will be updated here. However, it can be wrong,
+ because it will contain the current value of the database collation.
+ We need collation_database to be fixed at the creation time -- so
+ we'll update it later in switch_query_ctx().
+ */
+
if ((ret= sp_use_new_db(thd, name->m_db, &old_db, 1, &dbchanged)))
goto end;
@@ -388,9 +581,10 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
{
Lex_input_stream lip(thd, defstr.c_ptr(), defstr.length());
+
lex_start(thd);
- if (parse_sql(thd, &lip) || newlex.sphead == NULL)
+ if (parse_sql(thd, &lip, creation_ctx) || newlex.sphead == NULL)
{
sp_head *sp= newlex.sphead;
@@ -406,6 +600,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
*sphp= newlex.sphead;
(*sphp)->set_definer(&definer_user_name, &definer_host_name);
(*sphp)->set_info(created, modified, &chistics, sql_mode);
+ (*sphp)->set_creation_ctx(creation_ctx);
(*sphp)->optimize();
}
}
@@ -465,6 +660,8 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
TABLE *table;
char definer[USER_HOST_BUFF_SIZE];
+ CHARSET_INFO *db_cs= get_default_db_collation(thd, sp->m_db.str);
+
DBUG_ENTER("sp_create_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",type, (int) sp->m_name.length,
sp->m_name.str));
@@ -576,6 +773,26 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
}
}
+ table->field[MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT]->set_notnull();
+ table->field[MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT]->store(
+ thd->charset()->csname,
+ strlen(thd->charset()->csname),
+ system_charset_info);
+
+ table->field[MYSQL_PROC_FIELD_COLLATION_CONNECTION]->set_notnull();
+ table->field[MYSQL_PROC_FIELD_COLLATION_CONNECTION]->store(
+ thd->variables.collation_connection->name,
+ strlen(thd->variables.collation_connection->name),
+ system_charset_info);
+
+ table->field[MYSQL_PROC_FIELD_DB_COLLATION]->set_notnull();
+ table->field[MYSQL_PROC_FIELD_DB_COLLATION]->store(
+ db_cs->name, strlen(db_cs->name), system_charset_info);
+
+ table->field[MYSQL_PROC_FIELD_BODY_UTF8]->set_notnull();
+ table->field[MYSQL_PROC_FIELD_BODY_UTF8]->store(
+ sp->m_body_utf8.str, sp->m_body_utf8.length, system_charset_info);
+
ret= SP_OK;
if (table->file->ha_write_row(table->record[0]))
ret= SP_WRITE_ROW_FAILED;
@@ -740,15 +957,18 @@ struct st_used_field
static struct st_used_field init_fields[]=
{
- { "Db", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0},
- { "Name", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0},
- { "Type", 9, MYSQL_TYPE_STRING, 0},
- { "Definer", 77, MYSQL_TYPE_STRING, 0},
- { "Modified", 0, MYSQL_TYPE_TIMESTAMP, 0},
- { "Created", 0, MYSQL_TYPE_TIMESTAMP, 0},
- { "Security_type", 1, MYSQL_TYPE_STRING, 0},
- { "Comment", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0},
- { 0, 0, MYSQL_TYPE_STRING, 0}
+ { "Db", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0},
+ { "Name", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0},
+ { "Type", 9, MYSQL_TYPE_STRING, 0},
+ { "Definer", USER_HOST_BUFF_SIZE, MYSQL_TYPE_STRING, 0},
+ { "Modified", 0, MYSQL_TYPE_TIMESTAMP, 0},
+ { "Created", 0, MYSQL_TYPE_TIMESTAMP, 0},
+ { "Security_type", 1, MYSQL_TYPE_STRING, 0},
+ { "Comment", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0},
+ { "character_set_client", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0},
+ { "collation_connection", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0},
+ { "Database Collation", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0},
+ { 0, 0, MYSQL_TYPE_STRING, 0}
};
@@ -1124,7 +1344,8 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
if (db_load_routine(thd, type, name, &new_sp,
sp->m_sql_mode, sp->m_params.str, returns,
sp->m_body.str, *sp->m_chistics, definer,
- sp->m_created, sp->m_modified) == SP_OK)
+ sp->m_created, sp->m_modified,
+ sp->get_creation_ctx()) == SP_OK)
{
sp->m_last_cached_sp->m_next_cached_sp= new_sp;
new_sp->m_recursion_level= level;
@@ -1853,4 +2074,3 @@ sp_use_new_db(THD *thd, LEX_STRING new_db, LEX_STRING *old_db,
*dbchangedp= ret == 0;
DBUG_RETURN(ret);
}
-
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 821d19dca79..3e1f50b91bb 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -180,6 +180,7 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_SHOW_CREATE_FUNC:
case SQLCOM_SHOW_CREATE_PROC:
case SQLCOM_SHOW_CREATE_EVENT:
+ case SQLCOM_SHOW_CREATE_TRIGGER:
case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_ERRORS:
case SQLCOM_SHOW_FIELDS:
@@ -280,7 +281,6 @@ sp_get_flags_for_command(LEX *lex)
return flags;
}
-
/*
Prepare an Item for evaluation (call of fix_fields).
@@ -426,8 +426,6 @@ check_routine_name(LEX_STRING *ident)
return FALSE;
}
-/* ------------------------------------------------------------------ */
-
/*
*
@@ -493,6 +491,10 @@ sp_head::sp_head()
m_lex.empty();
hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0);
hash_init(&m_sroutines, system_charset_info, 0, 0, 0, sp_sroutine_key, 0, 0);
+
+ m_body_utf8.str= NULL;
+ m_body_utf8.length= 0;
+
DBUG_VOID_RETURN;
}
@@ -550,32 +552,53 @@ sp_head::init_sp_name(THD *thd, sp_name *spname)
void
-sp_head::init_strings(THD *thd, LEX *lex)
+sp_head::set_body_start(THD *thd, const char *begin_ptr)
+{
+ m_body_begin= begin_ptr;
+ thd->m_lip->body_utf8_start(thd, begin_ptr);
+}
+
+
+void
+sp_head::set_stmt_end(THD *thd)
{
- DBUG_ENTER("sp_head::init_strings");
- const char *endp; /* Used to trim the end */
- /* During parsing, we must use thd->mem_root */
- MEM_ROOT *root= thd->mem_root;
- Lex_input_stream *lip=thd->m_lip;
+ Lex_input_stream *lip= thd->m_lip; /* shortcut */
+ const char *end_ptr= lip->get_cpp_ptr(); /* shortcut */
+
+ /* Make the string of parameters. */
if (m_param_begin && m_param_end)
{
m_params.length= m_param_end - m_param_begin;
- m_params.str= strmake_root(root, m_param_begin, m_params.length);
+ m_params.str= thd->strmake(m_param_begin, m_params.length);
}
- endp= lip->get_cpp_ptr();
- lex->stmt_definition_end= endp;
+ /* Remember end pointer for further dumping of whole statement. */
+
+ thd->lex->stmt_definition_end= end_ptr;
+
+ /* Make the string of body (in the original character set). */
- m_body.length= endp - m_body_begin;
- m_body.str= strmake_root(root, m_body_begin, m_body.length);
+ m_body.length= end_ptr - m_body_begin;
+ m_body.str= thd->strmake(m_body_begin, m_body.length);
trim_whitespace(thd->charset(), & m_body);
- m_defstr.length= endp - lip->get_cpp_buf();
- m_defstr.str= strmake_root(root, lip->get_cpp_buf(), m_defstr.length);
- trim_whitespace(thd->charset(), & m_defstr);
+ /* Make the string of UTF-body. */
- DBUG_VOID_RETURN;
+ lip->body_utf8_append(end_ptr);
+
+ m_body_utf8.length= lip->get_body_utf8_length();
+ m_body_utf8.str= thd->strmake(lip->get_body_utf8_str(), m_body_utf8.length);
+ trim_whitespace(thd->charset(), & m_body_utf8);
+
+ /*
+ Make the string of whole stored-program-definition query (in the
+ original character set).
+ */
+
+ m_defstr.length= end_ptr - lip->get_cpp_buf();
+ m_defstr.str= thd->strmake(lip->get_cpp_buf(), m_defstr.length);
+ trim_whitespace(thd->charset(), & m_defstr);
}
@@ -968,6 +991,8 @@ sp_head::execute(THD *thd)
Item_change_list old_change_list;
String old_packet;
+ Object_creation_ctx *saved_creation_ctx;
+
/* Use some extra margin for possible SP recursion and functions */
if (check_stack_overrun(thd, 8 * STACK_MIN_SIZE, (uchar*)&old_packet))
DBUG_RETURN(TRUE);
@@ -1057,6 +1082,10 @@ sp_head::execute(THD *thd)
*/
thd->spcont->callers_arena= &backup_arena;
+ /* Switch query context. */
+
+ saved_creation_ctx= m_creation_ctx->set_n_backup(thd);
+
do
{
sp_instr *i;
@@ -1143,6 +1172,12 @@ sp_head::execute(THD *thd)
}
} while (!err_status && !thd->killed);
+ /* Restore query context. */
+
+ m_creation_ctx->restore_env(thd, saved_creation_ctx);
+
+ /* Restore arena. */
+
thd->restore_active_arena(&execute_arena, &backup_arena);
thd->spcont->pop_all_cursors(); // To avoid memory leaks after an error
@@ -1971,18 +2006,15 @@ sp_head::fill_field_definition(THD *thd, LEX *lex,
enum enum_field_types field_type,
Create_field *field_def)
{
- HA_CREATE_INFO sp_db_info;
LEX_STRING cmt = { 0, 0 };
uint unused1= 0;
int unused2= 0;
- load_db_opt_by_name(thd, m_db.str, &sp_db_info);
-
if (field_def->init(thd, (char*) "", field_type, lex->length, lex->dec,
lex->type, (Item*) 0, (Item*) 0, &cmt, 0,
&lex->interval_list,
- (lex->charset ? lex->charset :
- sp_db_info.default_table_charset),
+ lex->charset ? lex->charset :
+ thd->variables.collation_database,
lex->uint_geom_type))
return TRUE;
@@ -2054,13 +2086,6 @@ sp_head::set_info(longlong created, longlong modified,
void
-sp_head::set_body_begin_ptr(Lex_input_stream *lip, const char *begin_ptr)
-{
- m_body_begin= begin_ptr;
-}
-
-
-void
sp_head::set_definer(const char *definer, uint definerlen)
{
char user_name_holder[USERNAME_LENGTH + 1];
@@ -2212,6 +2237,15 @@ sp_head::show_create_routine(THD *thd, int type)
fields.push_back(stmt_fld);
}
+ fields.push_back(new Item_empty_string("character_set_client",
+ MY_CS_NAME_SIZE));
+
+ fields.push_back(new Item_empty_string("collation_connection",
+ MY_CS_NAME_SIZE));
+
+ fields.push_back(new Item_empty_string("Database Collation",
+ MY_CS_NAME_SIZE));
+
if (protocol->send_fields(&fields,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
{
@@ -2230,6 +2264,11 @@ sp_head::show_create_routine(THD *thd, int type)
else
protocol->store_null();
+
+ protocol->store(m_creation_ctx->get_client_cs()->csname, system_charset_info);
+ protocol->store(m_creation_ctx->get_connection_cl()->name, system_charset_info);
+ protocol->store(m_creation_ctx->get_db_cl()->name, system_charset_info);
+
err_status= protocol->write();
if (!err_status)
@@ -2424,7 +2463,9 @@ sp_head::show_routine_code(THD *thd)
if ((res= protocol->write()))
break;
}
- send_eof(thd);
+
+ if (!res)
+ send_eof(thd);
DBUG_RETURN(res);
}
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 50f6017ca0d..490fda67bfe 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -45,6 +45,58 @@ class sp_instr_jump_if_not;
struct sp_cond_type;
struct sp_variable;
+/*************************************************************************/
+
+/**
+ Stored_program_creation_ctx -- base class for creation context of stored
+ programs (stored routines, triggers, events).
+*/
+
+class Stored_program_creation_ctx :public Default_object_creation_ctx
+{
+public:
+ CHARSET_INFO *get_db_cl()
+ {
+ return m_db_cl;
+ }
+
+public:
+ virtual Stored_program_creation_ctx *clone(MEM_ROOT *mem_root) = 0;
+
+protected:
+ Stored_program_creation_ctx(THD *thd)
+ : Default_object_creation_ctx(thd),
+ m_db_cl(thd->variables.collation_database)
+ { }
+
+ Stored_program_creation_ctx(CHARSET_INFO *client_cs,
+ CHARSET_INFO *connection_cl,
+ CHARSET_INFO *db_cl)
+ : Default_object_creation_ctx(client_cs, connection_cl),
+ m_db_cl(db_cl)
+ { }
+
+protected:
+ virtual void change_env(THD *thd) const
+ {
+ thd->variables.collation_database= m_db_cl;
+
+ Default_object_creation_ctx::change_env(thd);
+ }
+
+protected:
+ /**
+ db_cl stores the value of the database collation. Both character set
+ and collation attributes are used.
+
+ Database collation is included into the context because it defines the
+ default collation for stored-program variables.
+ */
+ CHARSET_INFO *m_db_cl;
+};
+
+/*************************************************************************/
+
class sp_name : public Sql_alloc
{
public:
@@ -136,9 +188,25 @@ public:
LEX_STRING m_name;
LEX_STRING m_params;
LEX_STRING m_body;
+ LEX_STRING m_body_utf8;
LEX_STRING m_defstr;
LEX_STRING m_definer_user;
LEX_STRING m_definer_host;
+
+private:
+ Stored_program_creation_ctx *m_creation_ctx;
+
+public:
+ inline Stored_program_creation_ctx *get_creation_ctx()
+ {
+ return m_creation_ctx;
+ }
+
+ inline void set_creation_ctx(Stored_program_creation_ctx *creation_ctx)
+ {
+ m_creation_ctx= creation_ctx->clone(mem_root);
+ }
+
longlong m_created;
longlong m_modified;
/* Recursion level of the current SP instance. The levels are numbered from 0 */
@@ -205,9 +273,13 @@ public:
void
init_sp_name(THD *thd, sp_name *spname);
- // Initialize strings after parsing header
+ /** Set the body-definition start position. */
+ void
+ set_body_start(THD *thd, const char *begin_ptr);
+
+ /** Set the statement-definition (body-definition) end position. */
void
- init_strings(THD *thd, LEX *lex);
+ set_stmt_end(THD *thd);
int
create(THD *thd);
@@ -300,8 +372,6 @@ public:
void set_info(longlong created, longlong modified,
st_sp_chistics *chistics, ulong sql_mode);
- void set_body_begin_ptr(Lex_input_stream *lip, const char *begin_ptr);
-
void set_definer(const char *definer, uint definerlen);
void set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 304feea5f5c..8f2231dedf1 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -123,15 +123,19 @@ Lex_input_stream::Lex_input_stream(THD *thd,
m_end_of_query(buffer + length),
m_tok_start_prev(NULL),
m_buf(buffer),
+ m_buf_length(length),
m_echo(true),
m_cpp_tok_start(NULL),
m_cpp_tok_start_prev(NULL),
m_cpp_tok_end(NULL),
+ m_body_utf8(NULL),
+ m_cpp_utf8_processed_ptr(NULL),
next_state(MY_LEX_START),
found_semicolon(NULL),
ignore_space(test(thd->variables.sql_mode & MODE_IGNORE_SPACE)),
stmt_prepare_mode(FALSE),
- in_comment(NO_COMMENT)
+ in_comment(NO_COMMENT),
+ m_underscore_cs(NULL)
{
m_cpp_buf= (char*) thd->alloc(length + 1);
m_cpp_ptr= m_cpp_buf;
@@ -140,6 +144,133 @@ Lex_input_stream::Lex_input_stream(THD *thd,
Lex_input_stream::~Lex_input_stream()
{}
+/**
+ The operation is called from the parser in order to
+ 1) designate the intention to have utf8 body;
+ 1) Indicate to the lexer that we will need a utf8 representation of this
+ statement;
+ 2) Determine the beginning of the body.
+
+ @param thd Thread context.
+ @param begin_ptr Pointer to the start of the body in the pre-processed
+ buffer.
+*/
+
+void Lex_input_stream::body_utf8_start(THD *thd, const char *begin_ptr)
+{
+ DBUG_ASSERT(begin_ptr);
+ DBUG_ASSERT(m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length);
+
+ uint body_utf8_length=
+ (m_buf_length / thd->variables.character_set_client->mbminlen) *
+ my_charset_utf8_bin.mbmaxlen;
+
+ m_body_utf8= (char *) thd->alloc(body_utf8_length + 1);
+ m_body_utf8_ptr= m_body_utf8;
+ *m_body_utf8_ptr= 0;
+
+ m_cpp_utf8_processed_ptr= begin_ptr;
+}
+
+/**
+ The operation appends unprocessed part of pre-processed buffer till
+ the given pointer (ptr) and sets m_cpp_utf8_processed_ptr to end_ptr.
+
+ The idea is that some tokens in the pre-processed buffer (like character
+ set introducers) should be skipped.
+
+ Example:
+ CPP buffer: SELECT 'str1', _latin1 'str2';
+ m_cpp_utf8_processed_ptr -- points at the "SELECT ...";
+ In order to skip "_latin1", the following call should be made:
+ body_utf8_append(<pointer to "_latin1 ...">, <pointer to " 'str2'...">)
+
+ @param ptr Pointer in the pre-processed buffer, which specifies the
+ end of the chunk, which should be appended to the utf8
+ body.
+ @param end_ptr Pointer in the pre-processed buffer, to which
+ m_cpp_utf8_processed_ptr will be set in the end of the
+ operation.
+*/
+
+void Lex_input_stream::body_utf8_append(const char *ptr,
+ const char *end_ptr)
+{
+ DBUG_ASSERT(m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length);
+ DBUG_ASSERT(m_cpp_buf <= end_ptr && end_ptr <= m_cpp_buf + m_buf_length);
+
+ if (!m_body_utf8)
+ return;
+
+ if (m_cpp_utf8_processed_ptr >= ptr)
+ return;
+
+ int bytes_to_copy= ptr - m_cpp_utf8_processed_ptr;
+
+ memcpy(m_body_utf8_ptr, m_cpp_utf8_processed_ptr, bytes_to_copy);
+ m_body_utf8_ptr += bytes_to_copy;
+ *m_body_utf8_ptr= 0;
+
+ m_cpp_utf8_processed_ptr= end_ptr;
+}
+
+/**
+ The operation appends unprocessed part of the pre-processed buffer till
+ the given pointer (ptr) and sets m_cpp_utf8_processed_ptr to ptr.
+
+ @param ptr Pointer in the pre-processed buffer, which specifies the end
+ of the chunk, which should be appended to the utf8 body.
+*/
+
+void Lex_input_stream::body_utf8_append(const char *ptr)
+{
+ body_utf8_append(ptr, ptr);
+}
+
+/**
+ The operation converts the specified text literal to the utf8 and appends
+ the result to the utf8-body.
+
+ @param thd Thread context.
+ @param txt Text literal.
+ @param txt_cs Character set of the text literal.
+ @param end_ptr Pointer in the pre-processed buffer, to which
+ m_cpp_utf8_processed_ptr will be set in the end of the
+ operation.
+*/
+
+void Lex_input_stream::body_utf8_append_literal(THD *thd,
+ const LEX_STRING *txt,
+ CHARSET_INFO *txt_cs,
+ const char *end_ptr)
+{
+ if (!m_cpp_utf8_processed_ptr)
+ return;
+
+ LEX_STRING utf_txt;
+
+ if (txt_cs->number != my_charset_utf8_general_ci.number)
+ {
+ thd->convert_string(&utf_txt,
+ &my_charset_utf8_general_ci,
+ txt->str, txt->length,
+ txt_cs);
+ }
+ else
+ {
+ utf_txt.str= txt->str;
+ utf_txt.length= txt->length;
+ }
+
+ /* NOTE: utf_txt.length is in bytes, not in symbols. */
+
+ memcpy(m_body_utf8_ptr, utf_txt.str, utf_txt.length);
+ m_body_utf8_ptr += utf_txt.length;
+ *m_body_utf8_ptr= 0;
+
+ m_cpp_utf8_processed_ptr= end_ptr;
+}
+
/*
This is called before every query that is to be parsed.
@@ -231,6 +362,7 @@ void lex_start(THD *thd)
lex->server_options.socket= 0;
lex->server_options.owner= 0;
lex->server_options.port= -1;
+
DBUG_VOID_RETURN;
}
@@ -311,6 +443,10 @@ static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
lip->yyUnget(); // ptr points now after last token char
tmp.length=lip->yytoklen=length;
tmp.str= lip->m_thd->strmake(lip->get_tok_start() + skip, tmp.length);
+
+ lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
+ lip->m_cpp_text_end= lip->m_cpp_text_start + tmp.length;
+
return tmp;
}
@@ -334,10 +470,17 @@ static LEX_STRING get_quoted_token(Lex_input_stream *lip,
from= lip->get_tok_start() + skip;
to= tmp.str;
end= to+length;
+
+ lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
+ lip->m_cpp_text_end= lip->m_cpp_text_start + length;
+
for ( ; to != end; )
{
if ((*to++= *from++) == quote)
+ {
from++; // Skip double quotes
+ lip->m_cpp_text_start++;
+ }
}
*to= 0; // End null for safety
return tmp;
@@ -402,6 +545,10 @@ static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip)
if (!(start= (char*) lip->m_thd->alloc((uint) (end-str)+1)))
return (char*) ""; // Sql_alloc has set error flag
+
+ lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip;
+ lip->m_cpp_text_end= lip->get_cpp_ptr() - post_skip;
+
if (!found_escape)
{
lip->yytoklen=(uint) (end-str);
@@ -743,18 +890,33 @@ int MYSQLlex(void *arg, void *yythd)
}
yylval->lex_str=get_token(lip, 0, length);
- /*
+ /*
Note: "SELECT _bla AS 'alias'"
_bla should be considered as a IDENT if charset haven't been found.
- So we don't use MYF(MY_WME) with get_charset_by_csname to avoid
+ So we don't use MYF(MY_WME) with get_charset_by_csname to avoid
producing an error.
*/
- if ((yylval->lex_str.str[0]=='_') &&
- (lex->underscore_charset=
- get_charset_by_csname(yylval->lex_str.str + 1,
- MY_CS_PRIMARY,MYF(0))))
- return(UNDERSCORE_CHARSET);
+ if (yylval->lex_str.str[0] == '_')
+ {
+ CHARSET_INFO *cs= get_charset_by_csname(yylval->lex_str.str + 1,
+ MY_CS_PRIMARY, MYF(0));
+ if (cs)
+ {
+ yylval->charset= cs;
+ lip->m_underscore_cs= cs;
+
+ lip->body_utf8_append(lip->m_cpp_text_start,
+ lip->get_cpp_tok_start() + length);
+ return(UNDERSCORE_CHARSET);
+ }
+ }
+
+ lip->body_utf8_append(lip->m_cpp_text_start);
+
+ lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
+ lip->m_cpp_text_end);
+
return(result_state); // IDENT or IDENT_QUOTED
case MY_LEX_IDENT_SEP: // Found ident and now '.'
@@ -852,6 +1014,12 @@ int MYSQLlex(void *arg, void *yythd)
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
yylval->lex_str= get_token(lip, 0, lip->yyLength());
+
+ lip->body_utf8_append(lip->m_cpp_text_start);
+
+ lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
+ lip->m_cpp_text_end);
+
return(result_state);
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char
@@ -887,6 +1055,12 @@ int MYSQLlex(void *arg, void *yythd)
if (c == quote_char)
lip->yySkip(); // Skip end `
lip->next_state= MY_LEX_START;
+
+ lip->body_utf8_append(lip->m_cpp_text_start);
+
+ lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
+ lip->m_cpp_text_end);
+
return(IDENT_QUOTED);
}
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
@@ -995,6 +1169,15 @@ int MYSQLlex(void *arg, void *yythd)
break;
}
yylval->lex_str.length=lip->yytoklen;
+
+ lip->body_utf8_append(lip->m_cpp_text_start);
+
+ lip->body_utf8_append_literal(thd, &yylval->lex_str,
+ lip->m_underscore_cs ? lip->m_underscore_cs : cs,
+ lip->m_cpp_text_end);
+
+ lip->m_underscore_cs= NULL;
+
return(TEXT_STRING);
case MY_LEX_COMMENT: // Comment
@@ -1201,6 +1384,12 @@ int MYSQLlex(void *arg, void *yythd)
return(tokval); // Was keyword
}
yylval->lex_str=get_token(lip, 0, length);
+
+ lip->body_utf8_append(lip->m_cpp_text_start);
+
+ lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
+ lip->m_cpp_text_end);
+
return(result_state);
}
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 7a47c57a722..254403fe736 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -112,7 +112,8 @@ enum enum_sql_command {
SQLCOM_SHOW_CONTRIBUTORS,
SQLCOM_CREATE_SERVER, SQLCOM_DROP_SERVER, SQLCOM_ALTER_SERVER,
SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT,
- SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
+ SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
+ SQLCOM_SHOW_CREATE_TRIGGER,
/* This should be the last !!! */
@@ -1330,6 +1331,26 @@ public:
return (uint) ((m_ptr - m_tok_start) - 1);
}
+ /** Get the utf8-body string. */
+ const char *get_body_utf8_str()
+ {
+ return m_body_utf8;
+ }
+
+ /** Get the utf8-body length. */
+ uint get_body_utf8_length()
+ {
+ return m_body_utf8_ptr - m_body_utf8;
+ }
+
+ void body_utf8_start(THD *thd, const char *begin_ptr);
+ void body_utf8_append(const char *ptr);
+ void body_utf8_append(const char *ptr, const char *end_ptr);
+ void body_utf8_append_literal(THD *thd,
+ const LEX_STRING *txt,
+ CHARSET_INFO *txt_cs,
+ const char *end_ptr);
+
/** Current thread. */
THD *m_thd;
@@ -1361,6 +1382,9 @@ private:
/** Begining of the query text in the input stream, in the raw buffer. */
const char* m_buf;
+ /** Length of the raw buffer. */
+ uint m_buf_length;
+
/** Echo the parsed stream to the pre-processed buffer. */
bool m_echo;
@@ -1388,6 +1412,18 @@ private:
*/
const char* m_cpp_tok_end;
+ /** UTF8-body buffer created during parsing. */
+ char *m_body_utf8;
+
+ /** Pointer to the current position in the UTF8-body buffer. */
+ char *m_body_utf8_ptr;
+
+ /**
+ Position in the pre-processed buffer. The query from m_cpp_buf to
+ m_cpp_utf_processed_ptr is converted to UTF8-body.
+ */
+ const char *m_cpp_utf8_processed_ptr;
+
public:
/** Current state of the lexical analyser. */
@@ -1410,6 +1446,29 @@ public:
/** State of the lexical analyser for comments. */
enum_comment_state in_comment;
+
+ /**
+ Starting position of the TEXT_STRING or IDENT in the pre-processed
+ buffer.
+
+ NOTE: this member must be used within MYSQLlex() function only.
+ */
+ const char *m_cpp_text_start;
+
+ /**
+ Ending position of the TEXT_STRING or IDENT in the pre-processed
+ buffer.
+
+ NOTE: this member must be used within MYSQLlex() function only.
+ */
+ const char *m_cpp_text_end;
+
+ /**
+ Character set specified by the character-set-introducer.
+
+ NOTE: this member must be used within MYSQLlex() function only.
+ */
+ CHARSET_INFO *m_underscore_cs;
};
@@ -1444,7 +1503,7 @@ typedef struct st_lex : public Query_tables_list
DYNAMIC_ARRAY plugins;
plugin_ref plugins_static_buffer[INITIAL_LEX_PLUGIN_LIST_SIZE];
- CHARSET_INFO *charset, *underscore_charset;
+ CHARSET_INFO *charset;
/* store original leaf_tables for INSERT SELECT and PS/SP */
TABLE_LIST *leaf_tables_insert;
@@ -1635,6 +1694,8 @@ typedef struct st_lex : public Query_tables_list
const char *fname_start;
const char *fname_end;
+ LEX_STRING view_body_utf8;
+
/*
Reference to a struct that contains information in various commands
to add/create/drop/change table spaces.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 99c749aa441..5de00071f33 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4074,6 +4074,19 @@ create_sp_error:
break;
}
#endif // ifndef DBUG_OFF
+ case SQLCOM_SHOW_CREATE_TRIGGER:
+ {
+ if (lex->spname->m_name.length > NAME_LEN)
+ {
+ my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
+ goto error;
+ }
+
+ if (show_create_trigger(thd, lex->spname))
+ goto error; /* Error has been already logged. */
+
+ break;
+ }
case SQLCOM_CREATE_VIEW:
{
/*
@@ -5340,7 +5353,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
Lex_input_stream lip(thd, inBuf, length);
- bool err= parse_sql(thd, &lip);
+ bool err= parse_sql(thd, &lip, NULL);
*found_semicolon= lip.found_semicolon;
if (!err)
@@ -5424,7 +5437,7 @@ bool mysql_test_parse_for_slave(THD *thd, char *inBuf, uint length)
lex_start(thd);
mysql_reset_thd_for_next_command(thd);
- if (!parse_sql(thd, &lip) &&
+ if (!parse_sql(thd, &lip, NULL) &&
all_tables_not_ok(thd,(TABLE_LIST*) lex->select_lex.table_list.first))
error= 1; /* Ignore question */
thd->end_statement();
@@ -7127,23 +7140,44 @@ extern int MYSQLparse(void *thd); // from sql_yacc.cc
@param thd Thread context.
@param lip Lexer context.
+ @param creation_ctx Object creation context.
@return Error status.
@retval FALSE on success.
@retval TRUE on parsing error.
*/
-bool parse_sql(THD *thd, Lex_input_stream *lip)
+bool parse_sql(THD *thd,
+ Lex_input_stream *lip,
+ Object_creation_ctx *creation_ctx)
{
- bool err_status;
-
DBUG_ASSERT(thd->m_lip == NULL);
+ /* Backup creation context. */
+
+ Object_creation_ctx *backup_ctx= NULL;
+
+ if (creation_ctx)
+ backup_ctx= creation_ctx->set_n_backup(thd);
+
+ /* Set Lex_input_stream. */
+
thd->m_lip= lip;
- err_status= MYSQLparse(thd) != 0 || thd->is_fatal_error;
+ /* Parse the query. */
+
+ bool err_status= MYSQLparse(thd) != 0 || thd->is_fatal_error;
+
+ /* Reset Lex_input_stream. */
thd->m_lip= NULL;
+ /* Restore creation context. */
+
+ if (creation_ctx)
+ creation_ctx->restore_env(thd, backup_ctx);
+
+ /* That's it. */
+
return err_status;
}
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index ad3cf2d3e7a..f3253e5b086 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -3728,7 +3728,7 @@ bool mysql_unpack_partition(THD *thd,
lex.part_info->part_state= part_state;
lex.part_info->part_state_len= part_state_len;
DBUG_PRINT("info", ("Parse: %s", part_buf));
- if (parse_sql(thd, &lip))
+ if (parse_sql(thd, &lip, NULL))
{
thd->free_items();
goto end;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 6994ff99422..406e242cada 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1769,6 +1769,7 @@ static bool check_prepared_statement(Prepared_statement *stmt,
case SQLCOM_SHOW_CREATE_PROC:
case SQLCOM_SHOW_CREATE_FUNC:
case SQLCOM_SHOW_CREATE_EVENT:
+ case SQLCOM_SHOW_CREATE_TRIGGER:
case SQLCOM_SHOW_CREATE:
case SQLCOM_SHOW_PROC_CODE:
case SQLCOM_SHOW_FUNC_CODE:
@@ -2876,7 +2877,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
lip.stmt_prepare_mode= TRUE;
lex_start(thd);
- error= parse_sql(thd, &lip) ||
+ error= parse_sql(thd, &lip, NULL) ||
thd->net.report_error ||
init_param_array(this);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 903c8ab74f1..f66897df671 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -54,10 +54,12 @@ enum enum_i_s_events_fields
ISE_LAST_ALTERED,
ISE_LAST_EXECUTED,
ISE_EVENT_COMMENT,
- ISE_ORIGINATOR
+ ISE_ORIGINATOR,
+ ISE_CLIENT_CS,
+ ISE_CONNECTION_CL,
+ ISE_DB_CL
};
-
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static const char *grant_names[]={
"select","insert","update","delete","create","drop","reload","shutdown",
@@ -592,6 +594,10 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
}
buffer.length(0);
+
+ if (table_list->view)
+ buffer.set_charset(table_list->view_creation_ctx->get_client_cs());
+
if ((table_list->view ?
view_store_create_info(thd, table_list, &buffer) :
store_create_info(thd, table_list, &buffer, NULL)))
@@ -603,6 +609,10 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
field_list.push_back(new Item_empty_string("Create View",
max(buffer.length(),1024)));
+ field_list.push_back(new Item_empty_string("character_set_client",
+ MY_CS_NAME_SIZE));
+ field_list.push_back(new Item_empty_string("collation_connection",
+ MY_CS_NAME_SIZE));
}
else
{
@@ -626,10 +636,23 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
else
protocol->store(table_list->table->alias, system_charset_info);
}
- protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
+
+ if (table_list->view)
+ {
+ protocol->store(buffer.ptr(), buffer.length(), &my_charset_bin);
+
+ protocol->store(table_list->view_creation_ctx->get_client_cs()->csname,
+ system_charset_info);
+
+ protocol->store(table_list->view_creation_ctx->get_connection_cl()->name,
+ system_charset_info);
+ }
+ else
+ protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
DBUG_RETURN(TRUE);
+
send_eof(thd);
DBUG_RETURN(FALSE);
}
@@ -842,7 +865,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
if (q == EOF)
{
- packet->append(name, length, system_charset_info);
+ packet->append(name, length, packet->charset());
return;
}
@@ -860,7 +883,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
uchar chr= (uchar) *name;
length= my_mbcharlen(system_charset_info, chr);
/*
- my_mbcharlen can retur 0 on a wrong multibyte
+ my_mbcharlen can return 0 on a wrong multibyte
sequence. It is possible when upgrading from 4.0,
and identifier contains some accented characters.
The manual says it does not work. So we'll just
@@ -870,7 +893,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
length= 1;
if (length == 1 && chr == (uchar) quote_char)
packet->append(&quote_char, 1, system_charset_info);
- packet->append(name, length, packet->charset());
+ packet->append(name, length, system_charset_info);
}
packet->append(&quote_char, 1, system_charset_info);
}
@@ -2374,6 +2397,7 @@ int make_db_list(THD *thd, List<char> *files,
LEX *lex= thd->lex;
*with_i_schema= 0;
get_index_field_values(lex, idx_field_vals);
+
if (is_wild_value)
{
/*
@@ -3421,7 +3445,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
}
if (full_access)
{
- get_field(thd->mem_root, proc_table->field[10], &tmp_string);
+ get_field(thd->mem_root, proc_table->field[19], &tmp_string);
table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[7]->set_notnull();
}
@@ -3444,6 +3468,16 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
get_field(thd->mem_root, proc_table->field[15], &tmp_string);
table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[19]->store(definer.ptr(), definer.length(), cs);
+
+ get_field(thd->mem_root, proc_table->field[16], &tmp_string);
+ table->field[20]->store(tmp_string.ptr(), tmp_string.length(), cs);
+
+ get_field(thd->mem_root, proc_table->field[17], &tmp_string);
+ table->field[21]->store(tmp_string.ptr(), tmp_string.length(), cs);
+
+ get_field(thd->mem_root, proc_table->field[18], &tmp_string);
+ table->field[22]->store(tmp_string.ptr(), tmp_string.length(), cs);
+
return schema_table_store_record(thd, table);
}
}
@@ -3621,14 +3655,9 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
table->field[2]->store(tables->view_name.str, tables->view_name.length, cs);
if (tables->allowed_show)
{
- char buff[2048];
- String qwe_str(buff, sizeof(buff), cs);
- qwe_str.length(0);
- qwe_str.append(STRING_WITH_LEN("/* "));
- append_algorithm(tables, &qwe_str);
- qwe_str.append(STRING_WITH_LEN("*/ "));
- qwe_str.append(tables->query.str, tables->query.length);
- table->field[3]->store(qwe_str.ptr(), qwe_str.length(), cs);
+ table->field[3]->store(tables->view_body_utf8.str,
+ tables->view_body_utf8.length,
+ cs);
}
if (tables->with_check != VIEW_CHECK_NONE)
@@ -3679,6 +3708,17 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs);
else
table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs);
+
+ table->field[8]->store(
+ tables->view_creation_ctx->get_client_cs()->csname,
+ strlen(tables->view_creation_ctx->get_client_cs()->csname),
+ cs);
+
+ table->field[9]->store(
+ tables->view_creation_ctx->get_connection_cl()->name,
+ strlen(tables->view_creation_ctx->get_connection_cl()->name),
+ cs);
+
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
if (res)
@@ -3772,7 +3812,10 @@ static bool store_trigger(THD *thd, TABLE *table, const char *db,
enum trg_action_time_type timing,
LEX_STRING *trigger_stmt,
ulong sql_mode,
- LEX_STRING *definer_buffer)
+ LEX_STRING *definer_buffer,
+ LEX_STRING *client_cs_name,
+ LEX_STRING *connection_cl_name,
+ LEX_STRING *db_cl_name)
{
CHARSET_INFO *cs= system_charset_info;
LEX_STRING sql_mode_rep;
@@ -3794,7 +3837,12 @@ static bool store_trigger(THD *thd, TABLE *table, const char *db,
sys_var_thd_sql_mode::symbolic_mode_representation(thd, sql_mode,
&sql_mode_rep);
table->field[17]->store(sql_mode_rep.str, sql_mode_rep.length, cs);
- table->field[18]->store((const char *)definer_buffer->str, definer_buffer->length, cs);
+ table->field[18]->store(definer_buffer->str, definer_buffer->length, cs);
+ table->field[19]->store(client_cs_name->str, client_cs_name->length, cs);
+ table->field[20]->store(connection_cl_name->str,
+ connection_cl_name->length, cs);
+ table->field[21]->store(db_cl_name->str, db_cl_name->length, cs);
+
return schema_table_store_record(thd, table);
}
@@ -3830,19 +3878,29 @@ static int get_schema_triggers_record(THD *thd, struct st_table_list *tables,
ulong sql_mode;
char definer_holder[USER_HOST_BUFF_SIZE];
LEX_STRING definer_buffer;
+ LEX_STRING client_cs_name;
+ LEX_STRING connection_cl_name;
+ LEX_STRING db_cl_name;
+
definer_buffer.str= definer_holder;
if (triggers->get_trigger_info(thd, (enum trg_event_type) event,
(enum trg_action_time_type)timing,
&trigger_name, &trigger_stmt,
&sql_mode,
- &definer_buffer))
+ &definer_buffer,
+ &client_cs_name,
+ &connection_cl_name,
+ &db_cl_name))
continue;
if (store_trigger(thd, table, base_name, file_name, &trigger_name,
(enum trg_event_type) event,
(enum trg_action_time_type) timing, &trigger_stmt,
sql_mode,
- &definer_buffer))
+ &definer_buffer,
+ &client_cs_name,
+ &connection_cl_name,
+ &db_cl_name))
DBUG_RETURN(1);
}
}
@@ -4320,7 +4378,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
MYSQL_TIME time;
- Event_timed et;
+ Event_timed et;
DBUG_ENTER("copy_event_to_schema_table");
restore_record(sch_table, s->default_values);
@@ -4357,8 +4415,8 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
store(tz_name->ptr(), tz_name->length(), scs);
sch_table->field[ISE_EVENT_BODY]->
store(STRING_WITH_LEN("SQL"), scs);
- sch_table->field[ISE_EVENT_DEFINITION]->
- store(et.body.str, et.body.length, scs);
+ sch_table->field[ISE_EVENT_DEFINITION]->store(
+ et.body_utf8.str, et.body_utf8.length, scs);
/* SQL_MODE */
{
@@ -4461,6 +4519,24 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
sch_table->field[ISE_EVENT_COMMENT]->
store(et.comment.str, et.comment.length, scs);
+ sch_table->field[ISE_CLIENT_CS]->set_notnull();
+ sch_table->field[ISE_CLIENT_CS]->store(
+ et.creation_ctx->get_client_cs()->csname,
+ strlen(et.creation_ctx->get_client_cs()->csname),
+ scs);
+
+ sch_table->field[ISE_CONNECTION_CL]->set_notnull();
+ sch_table->field[ISE_CONNECTION_CL]->store(
+ et.creation_ctx->get_connection_cl()->name,
+ strlen(et.creation_ctx->get_connection_cl()->name),
+ scs);
+
+ sch_table->field[ISE_DB_CL]->set_notnull();
+ sch_table->field[ISE_DB_CL]->store(
+ et.creation_ctx->get_db_cl()->name,
+ strlen(et.creation_ctx->get_db_cl()->name),
+ scs);
+
if (schema_table_store_record(thd, sch_table))
DBUG_RETURN(1);
@@ -4987,7 +5063,7 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
- int fields_arr[]= {2, 3, 4, 19, 16, 15, 14, 18, -1};
+ int fields_arr[]= {2, 3, 4, 19, 16, 15, 14, 18, 20, 21, 22, -1};
int *field_num= fields_arr;
ST_FIELD_INFO *field_info;
Name_resolution_context *context= &thd->lex->select_lex.context;
@@ -5370,14 +5446,20 @@ ST_FIELD_INFO events_fields_info[]=
{"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"STARTS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Starts"},
{"ENDS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Ends"},
- {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status"},
+ {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status"},
{"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0},
{"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0},
{"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0},
{"LAST_EXECUTED", 0, MYSQL_TYPE_DATETIME, 0, 1, 0},
{"EVENT_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
- {"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0, "Originator"},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+ {"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0, "Originator"},
+ {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "character_set_client"},
+ {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "collation_connection"},
+ {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "Database Collation"},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
@@ -5412,6 +5494,12 @@ ST_FIELD_INFO proc_fields_info[]=
{"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"ROUTINE_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"},
+ {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "character_set_client"},
+ {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "collation_connection"},
+ {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "Database Collation"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
@@ -5448,6 +5536,8 @@ ST_FIELD_INFO view_fields_info[]=
{"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0},
{"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
@@ -5569,6 +5659,12 @@ ST_FIELD_INFO triggers_fields_info[]=
{"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 1, "Created"},
{"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, "sql_mode"},
{"DEFINER", 65535, MYSQL_TYPE_STRING, 0, 0, "Definer"},
+ {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "character_set_client"},
+ {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "collation_connection"},
+ {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
+ "Database Collation"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
@@ -5856,3 +5952,294 @@ int finalize_schema_table(st_plugin_int *plugin)
}
DBUG_RETURN(0);
}
+
+
+/**
+ Output trigger information (SHOW CREATE TRIGGER) to the client.
+
+ @param thd Thread context.
+ @param triggers List of triggers for the table.
+ @param trigger_idx Index of the trigger to dump.
+
+ @return Operation status
+ @retval TRUE Error.
+ @retval FALSE Success.
+*/
+
+static bool show_create_trigger_impl(THD *thd,
+ Table_triggers_list *triggers,
+ int trigger_idx)
+{
+ int ret_code;
+
+ Protocol *p= thd->protocol;
+ List<Item> fields;
+
+ LEX_STRING trg_name;
+ ulonglong trg_sql_mode;
+ LEX_STRING trg_sql_mode_str;
+ LEX_STRING trg_sql_original_stmt;
+ LEX_STRING trg_client_cs_name;
+ LEX_STRING trg_connection_cl_name;
+ LEX_STRING trg_db_cl_name;
+
+ /*
+ TODO: Check privileges here. This functionality will be added by
+ implementation of the following WL items:
+ - WL#2227: New privileges for new objects
+ - WL#3482: Protect SHOW CREATE PROCEDURE | FUNCTION | VIEW | TRIGGER
+ properly
+
+ SHOW TRIGGERS and I_S.TRIGGERS will be affected too.
+ */
+
+ /* Prepare trigger "object". */
+
+ triggers->get_trigger_info(thd,
+ trigger_idx,
+ &trg_name,
+ &trg_sql_mode,
+ &trg_sql_original_stmt,
+ &trg_client_cs_name,
+ &trg_connection_cl_name,
+ &trg_db_cl_name);
+
+ sys_var_thd_sql_mode::symbolic_mode_representation(thd,
+ trg_sql_mode,
+ &trg_sql_mode_str);
+
+ /* Send header. */
+
+ fields.push_back(new Item_empty_string("Trigger", NAME_LEN));
+ fields.push_back(new Item_empty_string("sql_mode", trg_sql_mode_str.length));
+
+ {
+ /*
+ NOTE: SQL statement field must be not less than 1024 in order not to
+ confuse old clients.
+ */
+
+ Item_empty_string *stmt_fld=
+ new Item_empty_string("SQL Original Statement",
+ max(trg_sql_original_stmt.length, 1024));
+
+ stmt_fld->maybe_null= TRUE;
+
+ fields.push_back(stmt_fld);
+ }
+
+ fields.push_back(new Item_empty_string("character_set_client",
+ MY_CS_NAME_SIZE));
+
+ fields.push_back(new Item_empty_string("collation_connection",
+ MY_CS_NAME_SIZE));
+
+ fields.push_back(new Item_empty_string("Database Collation",
+ MY_CS_NAME_SIZE));
+
+ if (p->send_fields(&fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
+ return TRUE;
+
+ /* Send data. */
+
+ p->prepare_for_resend();
+
+ p->store(trg_name.str,
+ trg_name.length,
+ system_charset_info);
+
+ p->store(trg_sql_mode_str.str,
+ trg_sql_mode_str.length,
+ system_charset_info);
+
+ p->store(trg_sql_original_stmt.str,
+ trg_sql_original_stmt.length,
+ &my_charset_bin);
+
+ p->store(trg_client_cs_name.str,
+ trg_client_cs_name.length,
+ system_charset_info);
+
+ p->store(trg_connection_cl_name.str,
+ trg_connection_cl_name.length,
+ system_charset_info);
+
+ p->store(trg_db_cl_name.str,
+ trg_db_cl_name.length,
+ system_charset_info);
+
+ ret_code= p->write();
+
+ if (!ret_code)
+ send_eof(thd);
+
+ return ret_code != 0;
+}
+
+
+/**
+ Read TRN and TRG files to obtain base table name for the specified
+ trigger name and construct TABE_LIST object for the base table.
+
+ @param thd Thread context.
+ @param trg_name Trigger name.
+
+ @return TABLE_LIST object corresponding to the base table.
+
+ TODO: This function is a copy&paste from add_table_to_list() and
+ sp_add_to_query_tables(). The problem is that in order to be compatible
+ with Stored Programs (Prepared Statements), we should not touch thd->lex.
+ The "source" functions also add created TABLE_LIST object to the
+ thd->lex->query_tables.
+
+ The plan to eliminate this copy&paste is to:
+
+ - get rid of sp_add_to_query_tables() and use Lex::add_table_to_list().
+ Only add_table_to_list() must be used to add tables from the parser
+ into Lex::query_tables list.
+
+ - do not update Lex::query_tables in add_table_to_list().
+*/
+
+static TABLE_LIST *get_trigger_table_impl(
+ THD *thd,
+ const sp_name *trg_name)
+{
+ char trn_path_buff[FN_REFLEN];
+
+ LEX_STRING trn_path= { trn_path_buff, 0 };
+ LEX_STRING tbl_name;
+
+ build_trn_path(thd, trg_name, &trn_path);
+
+ if (check_trn_exists(&trn_path))
+ {
+ my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
+ return NULL;
+ }
+
+ if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name))
+ return NULL;
+
+ /* We need to reset statement table list to be PS/SP friendly. */
+
+ TABLE_LIST *table;
+
+ if (!(table= (TABLE_LIST *)thd->calloc(sizeof(TABLE_LIST))))
+ {
+ my_error(ER_OUTOFMEMORY, MYF(0), sizeof(TABLE_LIST));
+ return NULL;
+ }
+
+ table->db_length= trg_name->m_db.length;
+ table->db= thd->strmake(trg_name->m_db.str, trg_name->m_db.length);
+
+ table->table_name_length= tbl_name.length;
+ table->table_name= thd->strmake(tbl_name.str, tbl_name.length);
+
+ table->alias= thd->strmake(tbl_name.str, tbl_name.length);
+
+ table->lock_type= TL_IGNORE;
+ table->cacheable_table= 0;
+
+ return table;
+}
+
+/**
+ Read TRN and TRG files to obtain base table name for the specified
+ trigger name and construct TABE_LIST object for the base table. Acquire
+ LOCK_open when doing this.
+
+ @param thd Thread context.
+ @param trg_name Trigger name.
+
+ @return TABLE_LIST object corresponding to the base table.
+*/
+
+static TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
+{
+ /* Acquire LOCK_open (stop the server). */
+
+ pthread_mutex_lock(&LOCK_open);
+
+ /*
+ Load base table name from the TRN-file and create TABLE_LIST object.
+ */
+
+ TABLE_LIST *lst= get_trigger_table_impl(thd, trg_name);
+
+ /* Release LOCK_open (continue the server). */
+
+ pthread_mutex_unlock(&LOCK_open);
+
+ /* That's it. */
+
+ return lst;
+}
+
+
+/**
+ SHOW CREATE TRIGGER high-level implementation.
+
+ @param thd Thread context.
+ @param trg_name Trigger name.
+
+ @return Operation status
+ @retval TRUE Error.
+ @retval FALSE Success.
+*/
+
+bool show_create_trigger(THD *thd, const sp_name *trg_name)
+{
+ TABLE_LIST *lst= get_trigger_table(thd, trg_name);
+
+ /*
+ Open the table by name in order to load Table_triggers_list object.
+
+ NOTE: there is race condition here -- the table can be dropped after
+ LOCK_open is released. It will be fixed later by introducing
+ acquire-shared-table-name-lock functionality.
+ */
+
+ uint num_tables; /* NOTE: unused, only to pass to open_tables(). */
+
+ if (open_tables(thd, &lst, &num_tables, 0))
+ {
+ my_error(ER_TRG_CANT_OPEN_TABLE, MYF(0),
+ (const char *) trg_name->m_db.str,
+ (const char *) lst->table_name);
+
+ return TRUE;
+
+ /* Perform closing actions and return error status. */
+ }
+
+ DBUG_ASSERT(num_tables == 1);
+
+ Table_triggers_list *triggers= lst->table->triggers;
+
+ if (!triggers)
+ {
+ my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
+ return TRUE;
+ }
+
+ int trigger_idx= triggers->find_trigger_by_name(&trg_name->m_name);
+
+ if (trigger_idx < 0)
+ {
+ my_error(ER_TRG_CORRUPTED_FILE, MYF(0),
+ (const char *) trg_name->m_db.str,
+ (const char *) lst->table_name);
+
+ return TRUE;
+ }
+
+ return show_create_trigger_impl(thd, triggers, trigger_idx);
+
+ /*
+ NOTE: if show_create_trigger_impl() failed, that means we could not
+ send data to the client. In this case we simply raise the error
+ status and client connection will be closed.
+ */
+}
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 7c28dff850a..06dd0dded43 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -20,6 +20,149 @@
#include "sql_trigger.h"
#include "parse_file.h"
+/*************************************************************************/
+
+template <class T>
+inline T *alloc_type(MEM_ROOT *m)
+{
+ return (T *) alloc_root(m, sizeof (T));
+}
+
+/*
+ NOTE: Since alloc_type() is declared as inline, alloc_root() calls should
+ be inlined by the compiler. So, implementation of alloc_root() is not
+ needed. However, let's put the implementation in object file just in case
+ of stupid MS or other old compilers.
+*/
+
+template LEX_STRING *alloc_type<LEX_STRING>(MEM_ROOT *m);
+template ulonglong *alloc_type<ulonglong>(MEM_ROOT *m);
+
+inline LEX_STRING *alloc_lex_string(MEM_ROOT *m)
+{
+ return alloc_type<LEX_STRING>(m);
+}
+
+/*************************************************************************/
+/**
+ Trigger_creation_ctx -- creation context of triggers.
+*/
+
+class Trigger_creation_ctx : public Stored_program_creation_ctx,
+ public Sql_alloc
+{
+public:
+ static Trigger_creation_ctx *create(THD *thd,
+ const char *db_name,
+ const char *table_name,
+ const LEX_STRING *client_cs_name,
+ const LEX_STRING *connection_cl_name,
+ const LEX_STRING *db_cl_name);
+
+public:
+ virtual Stored_program_creation_ctx *clone(MEM_ROOT *mem_root)
+ {
+ return new (mem_root) Trigger_creation_ctx(m_client_cs,
+ m_connection_cl,
+ m_db_cl);
+ }
+
+protected:
+ virtual Object_creation_ctx *create_backup_ctx(THD *thd) const
+ {
+ return new Trigger_creation_ctx(thd);
+ }
+
+private:
+ Trigger_creation_ctx(THD *thd)
+ :Stored_program_creation_ctx(thd)
+ { }
+
+ Trigger_creation_ctx(CHARSET_INFO *client_cs,
+ CHARSET_INFO *connection_cl,
+ CHARSET_INFO *db_cl)
+ :Stored_program_creation_ctx(client_cs, connection_cl, db_cl)
+ { }
+};
+
+/**************************************************************************
+ Trigger_creation_ctx implementation.
+**************************************************************************/
+
+Trigger_creation_ctx *
+Trigger_creation_ctx::create(THD *thd,
+ const char *db_name,
+ const char *table_name,
+ const LEX_STRING *client_cs_name,
+ const LEX_STRING *connection_cl_name,
+ const LEX_STRING *db_cl_name)
+{
+ CHARSET_INFO *client_cs;
+ CHARSET_INFO *connection_cl;
+ CHARSET_INFO *db_cl;
+
+ bool invalid_creation_ctx= FALSE;
+
+ if (resolve_charset(client_cs_name->str,
+ thd->variables.character_set_client,
+ &client_cs))
+ {
+ sql_print_warning("Trigger for table '%s'.'%s': "
+ "invalid character_set_client value (%s).",
+ (const char *) db_name,
+ (const char *) table_name,
+ (const char *) client_cs_name->str);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (resolve_collation(connection_cl_name->str,
+ thd->variables.collation_connection,
+ &connection_cl))
+ {
+ sql_print_warning("Trigger for table '%s'.'%s': "
+ "invalid collation_connection value (%s).",
+ (const char *) db_name,
+ (const char *) table_name,
+ (const char *) connection_cl_name->str);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (resolve_collation(db_cl_name->str, NULL, &db_cl))
+ {
+ sql_print_warning("Trigger for table '%s'.'%s': "
+ "invalid database_collation value (%s).",
+ (const char *) db_name,
+ (const char *) table_name,
+ (const char *) db_cl_name->str);
+
+ invalid_creation_ctx= TRUE;
+ }
+
+ if (invalid_creation_ctx)
+ {
+ push_warning_printf(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRG_INVALID_CREATION_CTX,
+ ER(ER_TRG_INVALID_CREATION_CTX),
+ (const char *) db_name,
+ (const char *) table_name);
+ }
+
+ /*
+ If we failed to resolve the database collation, load the default one
+ from the disk.
+ */
+
+ if (!db_cl)
+ db_cl= get_default_db_collation(thd, db_name);
+
+ return new Trigger_creation_ctx(client_cs, connection_cl, db_cl);
+}
+
+/*************************************************************************/
+
static const LEX_STRING triggers_file_type=
{ C_STRING_WITH_LEN("TRIGGERS") };
@@ -48,6 +191,21 @@ static File_option triggers_file_parameters[]=
my_offsetof(class Table_triggers_list, definers_list),
FILE_OPTIONS_STRLIST
},
+ {
+ { C_STRING_WITH_LEN("client_cs_names") },
+ my_offsetof(class Table_triggers_list, client_cs_names),
+ FILE_OPTIONS_STRLIST
+ },
+ {
+ { C_STRING_WITH_LEN("connection_cl_names") },
+ my_offsetof(class Table_triggers_list, connection_cl_names),
+ FILE_OPTIONS_STRLIST
+ },
+ {
+ { C_STRING_WITH_LEN("db_cl_names") },
+ my_offsetof(class Table_triggers_list, db_cl_names),
+ FILE_OPTIONS_STRLIST
+ },
{ { 0, 0 }, 0, FILE_OPTIONS_STRING }
};
@@ -64,7 +222,7 @@ File_option sql_modes_parameters=
.trg file.
*/
-static const int TRG_NUM_REQUIRED_PARAMETERS= 4;
+static const int TRG_NUM_REQUIRED_PARAMETERS= 6;
/*
Structure representing contents of .TRN file which are used to support
@@ -118,6 +276,7 @@ public:
MEM_ROOT *mem_root, char *end);
};
+
class Handle_old_incorrect_trigger_table_hook: public Unknown_key_hook
{
public:
@@ -359,6 +518,9 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
LEX_STRING *trg_definer;
Item_trigger_field *trg_field;
struct st_trigname trigname;
+ LEX_STRING *trg_client_cs_name;
+ LEX_STRING *trg_connection_cl_name;
+ LEX_STRING *trg_db_cl_name;
/* Trigger must be in the same schema as target table. */
@@ -489,16 +651,26 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
QQ: Hmm... probably we should not care about setting up active thread
mem_root too.
*/
- if (!(trg_def= (LEX_STRING *)alloc_root(&table->mem_root,
- sizeof(LEX_STRING))) ||
+ if (!(trg_def= alloc_lex_string(&table->mem_root)) ||
definitions_list.push_back(trg_def, &table->mem_root) ||
- !(trg_sql_mode= (ulonglong*)alloc_root(&table->mem_root,
- sizeof(ulonglong))) ||
+
+ !(trg_sql_mode= alloc_type<ulonglong>(&table->mem_root)) ||
definition_modes_list.push_back(trg_sql_mode, &table->mem_root) ||
- !(trg_definer= (LEX_STRING*) alloc_root(&table->mem_root,
- sizeof(LEX_STRING))) ||
- definers_list.push_back(trg_definer, &table->mem_root))
+
+ !(trg_definer= alloc_lex_string(&table->mem_root)) ||
+ definers_list.push_back(trg_definer, &table->mem_root) ||
+
+ !(trg_client_cs_name= alloc_lex_string(&table->mem_root)) ||
+ client_cs_names.push_back(trg_client_cs_name, &table->mem_root) ||
+
+ !(trg_connection_cl_name= alloc_lex_string(&table->mem_root)) ||
+ connection_cl_names.push_back(trg_connection_cl_name, &table->mem_root) ||
+
+ !(trg_db_cl_name= alloc_lex_string(&table->mem_root)) ||
+ db_cl_names.push_back(trg_db_cl_name, &table->mem_root))
+ {
goto err_with_cleanup;
+ }
*trg_sql_mode= thd->variables.sql_mode;
@@ -541,6 +713,21 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
}
/*
+ Fill character set information:
+ - client character set contains charset info only;
+ - connection collation contains pair {character set, collation};
+ - database collation contains pair {character set, collation};
+ */
+
+ lex_string_set(trg_client_cs_name, thd->charset()->csname);
+
+ lex_string_set(trg_connection_cl_name,
+ thd->variables.collation_connection->name);
+
+ lex_string_set(trg_db_cl_name,
+ get_default_db_collation(thd, tables->db)->name);
+
+ /*
Create well-formed trigger definition query. Original query is not
appropriated, because definer-clause can be not truncated.
*/
@@ -674,14 +861,20 @@ static bool save_trigger_file(Table_triggers_list *triggers, const char *db,
bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
String *stmt_query)
{
- LEX *lex= thd->lex;
+ const char *sp_name= thd->lex->spname->m_name.str; // alias
+
LEX_STRING *name;
- List_iterator_fast<LEX_STRING> it_name(names_list);
- List_iterator<LEX_STRING> it_def(definitions_list);
- List_iterator<ulonglong> it_mod(definition_modes_list);
- List_iterator<LEX_STRING> it_definer(definers_list);
char path[FN_REFLEN];
+ List_iterator_fast<LEX_STRING> it_name(names_list);
+
+ List_iterator<ulonglong> it_mod(definition_modes_list);
+ List_iterator<LEX_STRING> it_def(definitions_list);
+ List_iterator<LEX_STRING> it_definer(definers_list);
+ List_iterator<LEX_STRING> it_client_cs_name(client_cs_names);
+ List_iterator<LEX_STRING> it_connection_cl_name(connection_cl_names);
+ List_iterator<LEX_STRING> it_db_cl_name(db_cl_names);
+
stmt_query->append(thd->query, thd->query_length);
while ((name= it_name++))
@@ -689,9 +882,11 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
it_def++;
it_mod++;
it_definer++;
+ it_client_cs_name++;
+ it_connection_cl_name++;
+ it_db_cl_name++;
- if (my_strcasecmp(table_alias_charset, lex->spname->m_name.str,
- name->str) == 0)
+ if (my_strcasecmp(table_alias_charset, sp_name, name->str) == 0)
{
/*
Again we don't care much about other things required for
@@ -700,6 +895,9 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
it_def.remove();
it_mod.remove();
it_definer.remove();
+ it_client_cs_name.remove();
+ it_connection_cl_name.remove();
+ it_db_cl_name.remove();
if (definitions_list.is_empty())
{
@@ -718,7 +916,7 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
return 1;
}
- if (rm_trigname_file(path, tables->db, lex->spname->m_name.str))
+ if (rm_trigname_file(path, tables->db, sp_name))
return 1;
return 0;
}
@@ -857,9 +1055,13 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
we should initialize the list for safety:
- sql_modes;
- definers;
+ - character sets (client, connection, database);
*/
triggers->definition_modes_list.empty();
triggers->definers_list.empty();
+ triggers->client_cs_names.empty();
+ triggers->connection_cl_names.empty();
+ triggers->db_cl_names.empty();
if (parser->parse((uchar*)triggers, &table->mem_root,
triggers_file_parameters,
@@ -880,8 +1082,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
We use one mode (current) for all triggers, because we have not
information about mode in old format.
*/
- if (!(trg_sql_mode= (ulonglong*)alloc_root(&table->mem_root,
- sizeof(ulonglong))))
+ if (!(trg_sql_mode= alloc_type<ulonglong>(&table->mem_root)))
{
DBUG_RETURN(1); // EOM
}
@@ -910,8 +1111,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
LEX_STRING *trg_definer;
- if (! (trg_definer= (LEX_STRING*)alloc_root(&table->mem_root,
- sizeof(LEX_STRING))))
+ if (!(trg_definer= alloc_lex_string(&table->mem_root)))
DBUG_RETURN(1); // EOM
trg_definer->str= (char*) "";
@@ -929,10 +1129,85 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
it.rewind();
}
+ if (!triggers->definitions_list.is_empty() &&
+ (triggers->client_cs_names.is_empty() ||
+ triggers->connection_cl_names.is_empty() ||
+ triggers->db_cl_names.is_empty()))
+ {
+ /*
+ It is old file format => we should fill lists of character sets.
+ */
+
+ LEX_STRING *trg_client_cs_name;
+ LEX_STRING *trg_connection_cl_name;
+ LEX_STRING *trg_db_cl_name;
+
+ if (!triggers->client_cs_names.is_empty() ||
+ !triggers->connection_cl_names.is_empty() ||
+ !triggers->db_cl_names.is_empty())
+ {
+ my_error(ER_TRG_CORRUPTED_FILE, MYF(0),
+ (const char *) db,
+ (const char *) table_name);
+
+ DBUG_RETURN(1); // EOM
+ }
+
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRG_NO_CREATION_CTX,
+ ER(ER_TRG_NO_CREATION_CTX),
+ (const char*) db,
+ (const char*) table_name);
+
+ if (!(trg_client_cs_name= alloc_lex_string(&table->mem_root)) ||
+ !(trg_connection_cl_name= alloc_lex_string(&table->mem_root)) ||
+ !(trg_db_cl_name= alloc_lex_string(&table->mem_root)))
+ {
+ DBUG_RETURN(1); // EOM
+ }
+
+ /*
+ Backward compatibility: assume that the query is in the current
+ character set.
+ */
+
+ lex_string_set(trg_client_cs_name,
+ thd->variables.character_set_client->csname);
+
+ lex_string_set(trg_connection_cl_name,
+ thd->variables.collation_connection->name);
+
+ lex_string_set(trg_db_cl_name,
+ thd->variables.collation_database->name);
+
+ while (it++)
+ {
+ if (triggers->client_cs_names.push_back(trg_client_cs_name,
+ &table->mem_root) ||
+
+ triggers->connection_cl_names.push_back(trg_connection_cl_name,
+ &table->mem_root) ||
+
+ triggers->db_cl_names.push_back(trg_db_cl_name,
+ &table->mem_root))
+ {
+ DBUG_RETURN(1); // EOM
+ }
+ }
+
+ it.rewind();
+ }
+
DBUG_ASSERT(triggers->definition_modes_list.elements ==
triggers->definitions_list.elements);
DBUG_ASSERT(triggers->definers_list.elements ==
triggers->definitions_list.elements);
+ DBUG_ASSERT(triggers->client_cs_names.elements ==
+ triggers->definitions_list.elements);
+ DBUG_ASSERT(triggers->connection_cl_names.elements ==
+ triggers->definitions_list.elements);
+ DBUG_ASSERT(triggers->db_cl_names.elements ==
+ triggers->definitions_list.elements);
table->triggers= triggers;
@@ -956,6 +1231,9 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
List_iterator_fast<ulonglong> itm(triggers->definition_modes_list);
List_iterator_fast<LEX_STRING> it_definer(triggers->definers_list);
+ List_iterator_fast<LEX_STRING> it_client_cs_name(triggers->client_cs_names);
+ List_iterator_fast<LEX_STRING> it_connection_cl_name(triggers->connection_cl_names);
+ List_iterator_fast<LEX_STRING> it_db_cl_name(triggers->db_cl_names);
LEX *old_lex= thd->lex, lex;
sp_rcontext *save_spcont= thd->spcont;
ulong save_sql_mode= thd->variables.sql_mode;
@@ -974,10 +1252,19 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
thd->variables.sql_mode= (ulong)*trg_sql_mode;
Lex_input_stream lip(thd, trg_create_str->str, trg_create_str->length);
+
+ Trigger_creation_ctx *creation_ctx=
+ Trigger_creation_ctx::create(thd,
+ db,
+ table_name,
+ it_client_cs_name++,
+ it_connection_cl_name++,
+ it_db_cl_name++);
+
lex_start(thd);
- thd->spcont= 0;
+ thd->spcont= NULL;
- if (parse_sql(thd, &lip))
+ if (parse_sql(thd, &lip, creation_ctx))
{
/* Currently sphead is always deleted in case of a parse error */
DBUG_ASSERT(lex.sphead == 0);
@@ -986,8 +1273,11 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
lex.sphead->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
- triggers->bodies[lex.trg_chistics.event]
- [lex.trg_chistics.action_time]= lex.sphead;
+ int event= lex.trg_chistics.event;
+ int action_time= lex.trg_chistics.action_time;
+
+ lex.sphead->set_creation_ctx(creation_ctx);
+ triggers->bodies[event][action_time]= lex.sphead;
if (!trg_definer->length)
{
@@ -1023,8 +1313,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
&table->mem_root))
goto err_with_lex_cleanup;
- if (!(on_table_name= (LEX_STRING*) alloc_root(&table->mem_root,
- sizeof(LEX_STRING))))
+ if (!(on_table_name= alloc_lex_string(&table->mem_root)))
goto err_with_lex_cleanup;
on_table_name->str= (char*) lex.raw_trg_on_table_name_begin;
@@ -1070,7 +1359,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
trg_field;
trg_field= trg_field->next_trg_field)
{
- trg_field->setup_field(thd, table,
+ trg_field->setup_field(thd, table,
&triggers->subject_table_grants[lex.trg_chistics.event]
[lex.trg_chistics.action_time]);
}
@@ -1132,14 +1421,20 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event,
LEX_STRING *trigger_name,
LEX_STRING *trigger_stmt,
ulong *sql_mode,
- LEX_STRING *definer)
+ LEX_STRING *definer,
+ LEX_STRING *client_cs_name,
+ LEX_STRING *connection_cl_name,
+ LEX_STRING *db_cl_name)
{
sp_head *body;
DBUG_ENTER("get_trigger_info");
if ((body= bodies[event][time_type]))
{
+ Stored_program_creation_ctx *creation_ctx=
+ bodies[event][time_type]->get_creation_ctx();
+
*trigger_name= body->m_name;
- *trigger_stmt= body->m_body;
+ *trigger_stmt= body->m_body_utf8;
*sql_mode= body->m_sql_mode;
if (body->m_chistics->suid == SP_IS_NOT_SUID)
@@ -1153,12 +1448,74 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event,
body->m_definer_host.str, NullS) - definer->str;
}
+ lex_string_set(client_cs_name,
+ creation_ctx->get_client_cs()->csname);
+
+ lex_string_set(connection_cl_name,
+ creation_ctx->get_connection_cl()->name);
+
+ lex_string_set(db_cl_name,
+ creation_ctx->get_db_cl()->name);
+
DBUG_RETURN(0);
}
DBUG_RETURN(1);
}
+void Table_triggers_list::get_trigger_info(THD *thd,
+ int trigger_idx,
+ LEX_STRING *trigger_name,
+ ulonglong *sql_mode,
+ LEX_STRING *sql_original_stmt,
+ LEX_STRING *client_cs_name,
+ LEX_STRING *connection_cl_name,
+ LEX_STRING *db_cl_name)
+{
+ List_iterator_fast<LEX_STRING> it_trigger_name(names_list);
+ List_iterator_fast<ulonglong> it_sql_mode(definition_modes_list);
+ List_iterator_fast<LEX_STRING> it_sql_orig_stmt(definitions_list);
+ List_iterator_fast<LEX_STRING> it_client_cs_name(client_cs_names);
+ List_iterator_fast<LEX_STRING> it_connection_cl_name(connection_cl_names);
+ List_iterator_fast<LEX_STRING> it_db_cl_name(db_cl_names);
+
+ for (int i = 0; i < trigger_idx; ++i)
+ {
+ it_trigger_name.next_fast();
+ it_sql_mode.next_fast();
+ it_sql_orig_stmt.next_fast();
+
+ it_client_cs_name.next_fast();
+ it_connection_cl_name.next_fast();
+ it_db_cl_name.next_fast();
+ }
+
+ *trigger_name= *(it_trigger_name++);
+ *sql_mode= *(it_sql_mode++);
+ *sql_original_stmt= *(it_sql_orig_stmt++);
+
+ *client_cs_name= *(it_client_cs_name++);
+ *connection_cl_name= *(it_connection_cl_name++);
+ *db_cl_name= *(it_db_cl_name++);
+}
+
+
+int Table_triggers_list::find_trigger_by_name(const LEX_STRING *trg_name)
+{
+ List_iterator_fast<LEX_STRING> it(names_list);
+
+ for (int i = 0; ; ++i)
+ {
+ LEX_STRING *cur_name= it++;
+
+ if (!cur_name)
+ return -1;
+
+ if (strcmp(cur_name->str, trg_name->str) == 0)
+ return i;
+ }
+}
+
/**
Find trigger's table from trigger identifier and add it to
the statement table list.
@@ -1177,7 +1534,7 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event,
*/
bool add_table_for_trigger(THD *thd,
- sp_name *trg_name,
+ const sp_name *trg_name,
bool if_exists,
TABLE_LIST **table)
{
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h
index c305efb5029..bfdbae12bdc 100644
--- a/sql/sql_trigger.h
+++ b/sql/sql_trigger.h
@@ -83,6 +83,14 @@ public:
List<LEX_STRING> definers_list;
+ /* Character set context, used for parsing and executing triggers. */
+
+ List<LEX_STRING> client_cs_names;
+ List<LEX_STRING> connection_cl_names;
+ List<LEX_STRING> db_cl_names;
+
+ /* End of character ser context. */
+
Table_triggers_list(TABLE *table_arg):
record1_field(0), trigger_table(table_arg)
{
@@ -97,11 +105,26 @@ public:
bool process_triggers(THD *thd, trg_event_type event,
trg_action_time_type time_type,
bool old_row_is_record1);
+
bool get_trigger_info(THD *thd, trg_event_type event,
trg_action_time_type time_type,
LEX_STRING *trigger_name, LEX_STRING *trigger_stmt,
ulong *sql_mode,
- LEX_STRING *definer);
+ LEX_STRING *definer,
+ LEX_STRING *client_cs_name,
+ LEX_STRING *connection_cl_name,
+ LEX_STRING *db_cl_name);
+
+ void get_trigger_info(THD *thd,
+ int trigger_idx,
+ LEX_STRING *trigger_name,
+ ulonglong *sql_mode,
+ LEX_STRING *sql_original_stmt,
+ LEX_STRING *client_cs_name,
+ LEX_STRING *connection_cl_name,
+ LEX_STRING *db_cl_name);
+
+ int find_trigger_by_name(const LEX_STRING *trigger_name);
static bool check_n_load(THD *thd, const char *db, const char *table_name,
TABLE *table, bool names_only);
@@ -144,7 +167,7 @@ extern const LEX_STRING trg_action_time_type_names[];
extern const LEX_STRING trg_event_type_names[];
bool add_table_for_trigger(THD *thd,
- sp_name *trg_name,
+ const sp_name *trg_name,
bool continue_if_not_exist,
TABLE_LIST **table);
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 7021a8cba3b..ce311f5d4a2 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -610,8 +610,8 @@ err:
/* index of revision number in following table */
static const int revision_number_position= 8;
-/* index of last required parameter for making view */
-static const int required_view_parameters= 10;
+/* number of required parameters for making view */
+static const int required_view_parameters= 16;
/* number of backups */
static const int num_view_backups= 3;
@@ -623,7 +623,7 @@ static const int num_view_backups= 3;
*/
static File_option view_parameters[]=
{{{ C_STRING_WITH_LEN("query")},
- my_offsetof(TABLE_LIST, query),
+ my_offsetof(TABLE_LIST, select_stmt),
FILE_OPTIONS_ESTRING},
{{ C_STRING_WITH_LEN("md5")},
my_offsetof(TABLE_LIST, md5),
@@ -658,6 +658,15 @@ static File_option view_parameters[]=
{{ C_STRING_WITH_LEN("source")},
my_offsetof(TABLE_LIST, source),
FILE_OPTIONS_ESTRING},
+ {{(char*) STRING_WITH_LEN("client_cs_name")},
+ my_offsetof(TABLE_LIST, view_client_cs_name),
+ FILE_OPTIONS_STRING},
+ {{(char*) STRING_WITH_LEN("connection_cl_name")},
+ my_offsetof(TABLE_LIST, view_connection_cl_name),
+ FILE_OPTIONS_STRING},
+ {{(char*) STRING_WITH_LEN("view_body_utf8")},
+ my_offsetof(TABLE_LIST, view_body_utf8),
+ FILE_OPTIONS_STRING},
{{NullS, 0}, 0,
FILE_OPTIONS_STRING}
};
@@ -685,7 +694,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
{
LEX *lex= thd->lex;
char buff[4096];
- String str(buff,(uint32) sizeof(buff), system_charset_info);
+ String view_query(buff, sizeof (buff), thd->charset());
char md5[MD5_BUFF_LENGTH];
bool can_be_merged;
char dir_buff[FN_REFLEN], path_buff[FN_REFLEN];
@@ -694,18 +703,18 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
DBUG_ENTER("mysql_register_view");
/* print query */
- str.length(0);
+ view_query.length(0);
{
ulong sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
thd->variables.sql_mode&= ~MODE_ANSI_QUOTES;
- lex->unit.print(&str);
+ lex->unit.print(&view_query);
thd->variables.sql_mode|= sql_mode;
}
- DBUG_PRINT("info", ("View: %s", str.ptr()));
+ DBUG_PRINT("info", ("View: %s", view_query.ptr()));
/* fill structure */
- view->query.str= str.c_ptr_safe();
- view->query.length= str.length();
+ view->select_stmt.str= view_query.c_ptr_safe();
+ view->select_stmt.length= view_query.length();
view->source.str= (char*) thd->lex->create_view_select_start;
view->source.length= (thd->lex->create_view_select_end
@@ -826,6 +835,23 @@ loop_out:
}
}
+ /* Initialize view creation context from the environment. */
+
+ view->view_creation_ctx= View_creation_ctx::create(thd);
+
+ /*
+ Set LEX_STRING attributes in view-structure for parser to create
+ frm-file.
+ */
+
+ lex_string_set(&view->view_client_cs_name,
+ view->view_creation_ctx->get_client_cs()->csname);
+
+ lex_string_set(&view->view_connection_cl_name,
+ view->view_creation_ctx->get_connection_cl()->name);
+
+ view->view_body_utf8= lex->view_body_utf8;
+
/*
Check that table of main select do not used in subqueries.
@@ -862,8 +888,8 @@ loop_out:
}
DBUG_RETURN(0);
err:
- view->query.str= NULL;
- view->query.length= 0;
+ view->select_stmt.str= NULL;
+ view->select_stmt.length= 0;
view->md5.str= NULL;
view->md5.length= 0;
DBUG_RETURN(error);
@@ -892,9 +918,10 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
LEX *old_lex, *lex;
Query_arena *arena, backup;
TABLE_LIST *top_view= table->top_table();
- bool res;
+ bool parse_status;
bool result, view_is_mergeable;
TABLE_LIST *view_main_select_tables;
+
DBUG_ENTER("mysql_make_view");
DBUG_PRINT("info", ("table: 0x%lx (%s)", (ulong) table, table->table_name));
@@ -995,6 +1022,14 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
/*TODO: md5 test here and warning if it is differ */
/*
+ Initialize view definition context by character set names loaded from
+ the view definition file. Use UTF8 character set if view definition
+ file is of old version and does not contain the character set names.
+ */
+
+ table->view_creation_ctx= View_creation_ctx::create(thd, table);
+
+ /*
TODO: TABLE mem root should be used here when VIEW will be stored in
TABLE cache
@@ -1003,12 +1038,15 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local;
{
- Lex_input_stream lip(thd, table->query.str, table->query.length);
+ Lex_input_stream lip(thd,
+ table->select_stmt.str,
+ table->select_stmt.length);
+
lex_start(thd);
view_select= &lex->select_lex;
view_select->select_number= ++thd->select_number;
- ulong save_mode= thd->variables.sql_mode;
+ ulong saved_mode= thd->variables.sql_mode;
/* switch off modes which can prevent normal parsing of VIEW
- MODE_REAL_AS_FLOAT affect only CREATE TABLE parsing
+ MODE_PIPES_AS_CONCAT affect expression parsing
@@ -1035,18 +1073,20 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
*/
thd->variables.sql_mode&= ~(MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
MODE_IGNORE_SPACE | MODE_NO_BACKSLASH_ESCAPES);
- CHARSET_INFO *save_cs= thd->variables.character_set_client;
- thd->variables.character_set_client= system_charset_info;
- res= parse_sql(thd, &lip);
+
+ /* Parse the query. */
+
+ parse_status= parse_sql(thd, &lip, table->view_creation_ctx);
+
+ /* Restore environment. */
if ((old_lex->sql_command == SQLCOM_SHOW_FIELDS) ||
(old_lex->sql_command == SQLCOM_SHOW_CREATE))
lex->sql_command= old_lex->sql_command;
- thd->variables.character_set_client= save_cs;
- thd->variables.sql_mode= save_mode;
+ thd->variables.sql_mode= saved_mode;
}
- if (!res)
+ if (!parse_status)
{
TABLE_LIST *view_tables= lex->query_tables;
TABLE_LIST *view_tables_tail= 0;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 97e35d8c6ae..81dd8aebf65 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1089,7 +1089,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <lex_str>
IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM
LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text
- UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
+ IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
NCHAR_STRING opt_component key_cache_name
sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
@@ -1205,6 +1205,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
collation_name
collation_name_or_default
opt_load_data_charset
+ UNDERSCORE_CHARSET
%type <variable> internal_variable_name
@@ -1716,21 +1717,24 @@ event_tail:
YYTHD->client_capabilities is set back to original value
*/
{
- Lex->create_info.options= $2;
+ THD *thd= YYTHD;
+ LEX *lex=Lex;
- if (!(Lex->event_parse_data= Event_parse_data::new_instance(YYTHD)))
+ lex->create_info.options= $2;
+
+ if (!(lex->event_parse_data= Event_parse_data::new_instance(thd)))
MYSQL_YYABORT;
- Lex->event_parse_data->identifier= $3;
+ lex->event_parse_data->identifier= $3;
/*
We have to turn of CLIENT_MULTI_QUERIES while parsing a
stored procedure, otherwise yylex will chop it into pieces
at each ';'.
*/
- $<ulong_num>$= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES;
- YYTHD->client_capabilities &= (~CLIENT_MULTI_QUERIES);
+ $<ulong_num>$= thd->client_capabilities & CLIENT_MULTI_QUERIES;
+ thd->client_capabilities &= (~CLIENT_MULTI_QUERIES);
- Lex->sql_command= SQLCOM_CREATE_EVENT;
+ lex->sql_command= SQLCOM_CREATE_EVENT;
/* We need that for disallowing subqueries */
}
ON SCHEDULE_SYM ev_schedule_time
@@ -1863,16 +1867,16 @@ ev_sql_stmt:
if (!(lex->sphead= new sp_head()))
MYSQL_YYABORT;
- lex->sphead->reset_thd_mem_root(YYTHD);
+ lex->sphead->reset_thd_mem_root(thd);
lex->sphead->init(lex);
- lex->sphead->init_sp_name(YYTHD, Lex->event_parse_data->identifier);
+ lex->sphead->init_sp_name(thd, lex->event_parse_data->identifier);
lex->sphead->m_type= TYPE_ENUM_PROCEDURE;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
lex->sphead->m_chistics= &lex->sp_chistics;
- lex->sphead->set_body_begin_ptr(lip, lip->get_cpp_ptr());
+ lex->sphead->set_body_start(thd, lip->get_cpp_ptr());
}
ev_sql_stmt_inner
{
@@ -1880,7 +1884,7 @@ ev_sql_stmt:
LEX *lex= thd->lex;
/* return back to the original memory root ASAP */
- lex->sphead->init_strings(thd, lex);
+ lex->sphead->set_stmt_end(thd);
lex->sphead->restore_thd_mem_root(thd);
lex->sp_chistics.suid= SP_IS_SUID; //always the definer!
@@ -1946,7 +1950,7 @@ sp_name:
MYSQL_YYABORT;
$$= new sp_name(db, $1, false);
if ($$)
- $$->init_qname(YYTHD);
+ $$->init_qname(thd);
}
;
@@ -2066,7 +2070,7 @@ create_function_tail:
Lex_input_stream *lip= thd->m_lip;
lex->sphead->m_chistics= &lex->sp_chistics;
- lex->sphead->set_body_begin_ptr(lip, lip->get_cpp_tok_start());
+ lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
}
sp_proc_stmt
{
@@ -2078,7 +2082,7 @@ create_function_tail:
MYSQL_YYABORT;
lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
- sp->init_strings(thd, lex);
+ sp->set_stmt_end(thd);
if (!(sp->m_flags & sp_head::HAS_RETURN))
{
my_error(ER_SP_NORETURN, MYF(0), sp->m_qname.str);
@@ -3604,14 +3608,20 @@ create2:
create3 {}
| LIKE table_ident
{
- Lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
- if (!Lex->select_lex.add_table_to_list(YYTHD, $2, NULL, 0, TL_READ))
+ THD *thd= YYTHD;
+ LEX *lex= thd->lex;
+
+ lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
+ if (!lex->select_lex.add_table_to_list(thd, $2, NULL, 0, TL_READ))
MYSQL_YYABORT;
}
| '(' LIKE table_ident ')'
{
- Lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
- if (!Lex->select_lex.add_table_to_list(YYTHD, $3, NULL, 0, TL_READ))
+ THD *thd= YYTHD;
+ LEX *lex= thd->lex;
+
+ lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
+ if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0, TL_READ))
MYSQL_YYABORT;
}
;
@@ -8669,7 +8679,7 @@ show_param:
{ Lex->create_info.db_type= NULL; }
| opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
{
- LEX *lex= Lex;
+ LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_FIELDS;
if ($5)
$4->change_db($5);
@@ -8867,6 +8877,12 @@ show_param:
lex->sql_command = SQLCOM_SHOW_CREATE_FUNC;
lex->spname= $3;
}
+ | CREATE TRIGGER_SYM sp_name
+ {
+ LEX *lex= Lex;
+ lex->sql_command= SQLCOM_SHOW_CREATE_TRIGGER;
+ lex->spname= $3;
+ }
| PROCEDURE STATUS_SYM wild_and_where
{
LEX *lex= Lex;
@@ -9307,7 +9323,9 @@ text_literal:
| NCHAR_STRING
{ $$= new Item_string($1.str,$1.length,national_charset_info); }
| UNDERSCORE_CHARSET TEXT_STRING
- { $$ = new Item_string($2.str,$2.length,Lex->underscore_charset); }
+ {
+ $$ = new Item_string($2.str, $2.length, $1);
+ }
| text_literal TEXT_STRING_literal
{ ((Item_string*) $1)->append($2.str,$2.length); }
;
@@ -9394,7 +9412,7 @@ literal:
(String*) 0;
$$= new Item_string(str ? str->ptr() : "",
str ? str->length() : 0,
- Lex->underscore_charset);
+ $1);
}
| UNDERSCORE_CHARSET BIN_NUM
{
@@ -9669,6 +9687,7 @@ IDENT_sys:
| IDENT_QUOTED
{
THD *thd= YYTHD;
+
if (thd->charset_is_system_charset)
{
CHARSET_INFO *cs= system_charset_info;
@@ -9694,6 +9713,7 @@ TEXT_STRING_sys:
TEXT_STRING
{
THD *thd= YYTHD;
+
if (thd->charset_is_system_charset)
$$= $1;
else
@@ -9706,6 +9726,7 @@ TEXT_STRING_literal:
TEXT_STRING
{
THD *thd= YYTHD;
+
if (thd->charset_is_collation_connection)
$$= $1;
else
@@ -9719,6 +9740,7 @@ TEXT_STRING_filesystem:
TEXT_STRING
{
THD *thd= YYTHD;
+
if (thd->charset_is_character_set_filesystem)
$$= $1;
else
@@ -10408,7 +10430,8 @@ option_value:
internal_variable_name:
ident
{
- LEX *lex= Lex;
+ THD *thd= YYTHD;
+ LEX *lex= thd->lex;
sp_pcontext *spc= lex->spcont;
sp_variable_t *spv;
@@ -10416,7 +10439,7 @@ internal_variable_name:
if (!spc || !(spv = spc->find_variable(&$1)))
{
/* Not an SP local variable */
- sys_var *tmp=find_sys_var(YYTHD, $1.str, $1.length);
+ sys_var *tmp=find_sys_var(thd, $1.str, $1.length);
if (!tmp)
MYSQL_YYABORT;
$$.var= tmp;
@@ -11376,8 +11399,27 @@ view_tail:
if (!lex->select_lex.add_table_to_list(thd, $3, NULL, TL_OPTION_UPDATING))
MYSQL_YYABORT;
}
- view_list_opt AS view_select
- {}
+ view_list_opt AS
+ {
+ THD *thd= YYTHD;
+ Lex_input_stream *lip= thd->m_lip;
+
+ lip->body_utf8_start(thd, lip->get_cpp_ptr());
+ }
+ view_select
+ {
+ THD *thd= YYTHD;
+ LEX *lex= thd->lex;
+ Lex_input_stream *lip= thd->m_lip;
+
+ lip->body_utf8_append(lip->get_cpp_ptr());
+
+ lex->view_body_utf8.str= thd->strmake(lip->get_body_utf8_str(),
+ lip->get_body_utf8_length());
+ lex->view_body_utf8.length= lip->get_body_utf8_length();
+
+ trim_whitespace(&my_charset_utf8_general_ci, &lex->view_body_utf8);
+ }
;
view_list_opt:
@@ -11504,7 +11546,7 @@ trigger_tail:
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
lex->sphead->m_chistics= &lex->sp_chistics;
- lex->sphead->set_body_begin_ptr(lip, lip->get_cpp_ptr());
+ lex->sphead->set_body_start(thd, lip->get_cpp_ptr());
}
sp_proc_stmt /* $16 */
{ /* $17 */
@@ -11512,7 +11554,7 @@ trigger_tail:
sp_head *sp= lex->sphead;
lex->sql_command= SQLCOM_CREATE_TRIGGER;
- sp->init_strings(YYTHD, lex);
+ sp->set_stmt_end(YYTHD);
/* Restore flag if it was cleared above */
YYTHD->client_capabilities |= $<ulong_num>15;
@@ -11607,14 +11649,14 @@ sp_tail:
Lex_input_stream *lip= thd->m_lip;
lex->sphead->m_chistics= &lex->sp_chistics;
- lex->sphead->set_body_begin_ptr(lip, lip->get_cpp_tok_start());
+ lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
}
sp_proc_stmt
{
LEX *lex= Lex;
sp_head *sp= lex->sphead;
- sp->init_strings(YYTHD, lex);
+ sp->set_stmt_end(YYTHD);
lex->sql_command= SQLCOM_CREATE_PROCEDURE;
/*
Restore flag if it was cleared above
diff --git a/sql/table.cc b/sql/table.cc
index 45ca17afce4..254f0d5503c 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -32,6 +32,127 @@ static void fix_type_pointers(const char ***array, TYPELIB *point_to_type,
static uint find_field(Field **fields, uchar *record, uint start, uint length);
+/**************************************************************************
+ Object_creation_ctx implementation.
+**************************************************************************/
+
+Object_creation_ctx *Object_creation_ctx::set_n_backup(THD *thd)
+{
+ Object_creation_ctx *backup_ctx= create_backup_ctx(thd);
+
+ change_env(thd);
+
+ return backup_ctx;
+}
+
+void Object_creation_ctx::restore_env(THD *thd, Object_creation_ctx *backup_ctx)
+{
+ if (!backup_ctx)
+ return;
+
+ backup_ctx->change_env(thd);
+
+ delete backup_ctx;
+}
+
+/**************************************************************************
+ Default_object_creation_ctx implementation.
+**************************************************************************/
+
+Default_object_creation_ctx::Default_object_creation_ctx(THD *thd)
+ : m_client_cs(thd->variables.character_set_client),
+ m_connection_cl(thd->variables.collation_connection)
+{ }
+
+Default_object_creation_ctx::Default_object_creation_ctx(
+ CHARSET_INFO *client_cs, CHARSET_INFO *connection_cl)
+ : m_client_cs(client_cs),
+ m_connection_cl(connection_cl)
+{ }
+
+Object_creation_ctx *
+Default_object_creation_ctx::create_backup_ctx(THD *thd)
+{
+ return new Default_object_creation_ctx(thd);
+}
+
+void Default_object_creation_ctx::change_env(THD *thd) const
+{
+ thd->variables.character_set_client= m_client_cs;
+ thd->variables.collation_connection= m_connection_cl;
+
+ thd->update_charset();
+}
+
+/**************************************************************************
+ View_creation_ctx implementation.
+**************************************************************************/
+
+View_creation_ctx *View_creation_ctx::create(THD *thd)
+{
+ View_creation_ctx *ctx= new (thd->mem_root) View_creation_ctx(thd);
+
+ return ctx;
+}
+
+/*************************************************************************/
+
+View_creation_ctx * View_creation_ctx::create(THD *thd,
+ st_table_list *view)
+{
+ View_creation_ctx *ctx= new (thd->mem_root) View_creation_ctx(thd);
+
+ /* Throw a warning if there is NULL cs name. */
+
+ if (!view->view_client_cs_name.str ||
+ !view->view_connection_cl_name.str)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_VIEW_NO_CREATION_CTX,
+ ER(ER_VIEW_NO_CREATION_CTX),
+ (const char *) view->db,
+ (const char *) view->table_name);
+
+ ctx->m_client_cs= system_charset_info;
+ ctx->m_connection_cl= system_charset_info;
+
+ return ctx;
+ }
+
+ /* Resolve cs names. Throw a warning if there is unknown cs name. */
+
+ bool invalid_creation_ctx;
+
+ invalid_creation_ctx= resolve_charset(view->view_client_cs_name.str,
+ system_charset_info,
+ &ctx->m_client_cs);
+
+ invalid_creation_ctx= resolve_collation(view->view_connection_cl_name.str,
+ system_charset_info,
+ &ctx->m_connection_cl) ||
+ invalid_creation_ctx;
+
+ if (invalid_creation_ctx)
+ {
+ sql_print_warning("View '%s'.'%s': there is unknown charset/collation "
+ "names (client: '%s'; connection: '%s').",
+ (const char *) view->db,
+ (const char *) view->table_name,
+ (const char *) view->view_client_cs_name.str,
+ (const char *) view->view_connection_cl_name.str);
+
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_VIEW_INVALID_CREATION_CTX,
+ ER(ER_VIEW_INVALID_CREATION_CTX),
+ (const char *) view->db,
+ (const char *) view->table_name);
+ }
+
+ return ctx;
+}
+
+/*************************************************************************/
+
/* Get column name from column hash */
static uchar *get_field_name(Field **buff, size_t *length,
@@ -42,7 +163,6 @@ static uchar *get_field_name(Field **buff, size_t *length,
}
-
/*
Returns pointer to '.frm' extension of the file name.
@@ -2730,7 +2850,7 @@ void st_table_list::calc_md5(char *buffer)
my_MD5_CTX context;
uchar digest[16];
my_MD5Init(&context);
- my_MD5Update(&context,(uchar *) query.str, query.length);
+ my_MD5Update(&context,(uchar *) select_stmt.str, select_stmt.length);
my_MD5Final(digest, &context);
sprintf((char *) buffer,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
diff --git a/sql/table.h b/sql/table.h
index 90c07979512..4c98f5146ab 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -25,6 +25,29 @@ class partition_info;
class COND_EQUAL;
class Security_context;
+/*************************************************************************/
+
+/**
+ View_creation_ctx -- creation context of view objects.
+*/
+
+class View_creation_ctx : public Default_object_creation_ctx,
+ public Sql_alloc
+{
+public:
+ static View_creation_ctx *create(THD *thd);
+
+ static View_creation_ctx *create(THD *thd,
+ struct st_table_list *view);
+
+private:
+ View_creation_ctx(THD *thd)
+ : Default_object_creation_ctx(thd)
+ { }
+};
+
+/*************************************************************************/
+
/* Order clause list element */
typedef struct st_order {
@@ -863,7 +886,7 @@ typedef struct st_table_list
st_table_list *next_leaf;
Item *where; /* VIEW WHERE clause condition */
Item *check_option; /* WITH CHECK OPTION condition */
- LEX_STRING query; /* text of (CRETE/SELECT) statement */
+ LEX_STRING select_stmt; /* text of (CREATE/SELECT) statement */
LEX_STRING md5; /* md5 of query text */
LEX_STRING source; /* source of CREATE VIEW */
LEX_STRING view_db; /* saved view database */
@@ -930,6 +953,32 @@ typedef struct st_table_list
*/
bool create;
+
+ /* View creation context. */
+
+ View_creation_ctx *view_creation_ctx;
+
+ /*
+ Attributes to save/load view creation context in/from frm-file.
+
+ Ther are required only to be able to use existing parser to load
+ view-definition file. As soon as the parser parsed the file, view
+ creation context is initialized and the attributes become redundant.
+
+ These attributes MUST NOT be used for any purposes but the parsing.
+ */
+
+ LEX_STRING view_client_cs_name;
+ LEX_STRING view_connection_cl_name;
+
+ /*
+ View definition (SELECT-statement) in the UTF-form.
+ */
+
+ LEX_STRING view_body_utf8;
+
+ /* End of view definition context. */
+
enum enum_schema_table_state schema_table_state;
void calc_md5(char *buffer);
void set_underlying_merge();