summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVesa Pentti <vesa.pentti@mariadb.com>2017-10-08 22:15:00 +0300
committerVesa Pentti <vesa.pentti@mariadb.com>2017-10-10 16:16:12 +0300
commit93aadda513d8b5c2b49001514e235c4fdd73e08a (patch)
tree7de265a46bab1d8c480f8fb444d40ae59b5f4100
parentc2509a1588ee1dc7351b67b2f9149003540015c4 (diff)
downloadmariadb-git-93aadda513d8b5c2b49001514e235c4fdd73e08a.tar.gz
MDEV-13149 -- show function status now works with PAD_CHAR_TO_FULL_LENGTH
-rw-r--r--mysql-test/r/show_function_with_pad_char_to_full_length.result24
-rw-r--r--mysql-test/t/show_function_with_pad_char_to_full_length.test23
-rw-r--r--sql/sql_show.cc5
3 files changed, 52 insertions, 0 deletions
diff --git a/mysql-test/r/show_function_with_pad_char_to_full_length.result b/mysql-test/r/show_function_with_pad_char_to_full_length.result
new file mode 100644
index 00000000000..785cab7b3e6
--- /dev/null
+++ b/mysql-test/r/show_function_with_pad_char_to_full_length.result
@@ -0,0 +1,24 @@
+create function f() returns int return 1;
+show function status;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+T f T T T T T T T T T
+set sql_mode = 'PAD_CHAR_TO_FULL_LENGTH';
+show function status;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+T f T T T T T T T T T
+drop function f;
+select @@sql_mode;
+@@sql_mode
+PAD_CHAR_TO_FULL_LENGTH
+create function f() returns int return 1;
+select ROUTINE_NAME from information_schema.ROUTINES where ROUTINE_NAME='f';
+ROUTINE_NAME
+f
+set sql_mode = 'PAD_CHAR_TO_FULL_LENGTH';
+select ROUTINE_NAME from information_schema.ROUTINES where ROUTINE_NAME='f';
+ROUTINE_NAME
+f
+drop function f;
+select @@sql_mode;
+@@sql_mode
+PAD_CHAR_TO_FULL_LENGTH
diff --git a/mysql-test/t/show_function_with_pad_char_to_full_length.test b/mysql-test/t/show_function_with_pad_char_to_full_length.test
new file mode 100644
index 00000000000..f47f36294d4
--- /dev/null
+++ b/mysql-test/t/show_function_with_pad_char_to_full_length.test
@@ -0,0 +1,23 @@
+#
+# Test that show function status succeeds with
+# sql_mode = 'PAD_CHAR_TO_FULL_LENGTH (MDEV-13149)
+
+# show function status
+
+create function f() returns int return 1;
+--replace_column 1 T 3 T 4 T 5 T 6 T 7 T 8 T 9 T 10 T 11 T
+show function status;
+set sql_mode = 'PAD_CHAR_TO_FULL_LENGTH';
+--replace_column 1 T 3 T 4 T 5 T 6 T 7 T 8 T 9 T 10 T 11 T
+show function status;
+drop function f;
+select @@sql_mode;
+
+# select ROUTINE_NAME from information_schema.ROUTINES
+
+create function f() returns int return 1;
+select ROUTINE_NAME from information_schema.ROUTINES where ROUTINE_NAME='f';
+set sql_mode = 'PAD_CHAR_TO_FULL_LENGTH';
+select ROUTINE_NAME from information_schema.ROUTINES where ROUTINE_NAME='f';
+drop function f;
+select @@sql_mode;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d8ea232caea..6e045648591 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -5716,6 +5716,10 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
DBUG_RETURN(1);
}
+ /* Disable padding temporarily so it doesn't break the query */
+ ulonglong sql_mode_was = thd->variables.sql_mode;
+ thd->variables.sql_mode &= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
if (proc_table->file->ha_index_init(0, 1))
{
res= 1;
@@ -5751,6 +5755,7 @@ err:
(void) proc_table->file->ha_index_end();
close_system_tables(thd, &open_tables_state_backup);
+ thd->variables.sql_mode = sql_mode_was;
DBUG_RETURN(res);
}