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-09 09:19:15 +0300
commit39e4bb8f46275007f586a01439b67fa1c276ad45 (patch)
treeb136954b13bc877f6db1ed36d2afd9e87a6cab99
parent3557de68d14eb3d5f8808933a4f52b6ca8f9a005 (diff)
downloadmariadb-git-work-in-progress-pentve.tar.gz
MDEV-13149 -- show function status now works with PAD_CHAR_TO_FULL_LENGTHwork-in-progress-pentve
-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.cc4
3 files changed, 51 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 97fa231a13a..873af0d3dc3 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -6058,6 +6058,10 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
get_schema_table_idx(tables->schema_table);
DBUG_ENTER("fill_schema_proc");
+ /* Disable padding temporarily so it doesn't break the query */
+ Sql_mode_save restore_sql_mode(thd);
+ thd->variables.sql_mode &= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
strxmov(definer, thd->security_ctx->priv_user, "@",
thd->security_ctx->priv_host, NullS);
/* We use this TABLE_LIST instance only for checking of privileges. */