summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-06-17 23:33:04 +0200
committerSergei Golubchik <serg@mariadb.org>2019-06-17 23:41:43 +0200
commitb8e655ce029a1f182602c9f12c3cc5931226eec2 (patch)
tree1eb8d50ce8535fbdfa72251db06809651b681489
parente85e4814eeca9123b23c23b40dd776416bfba2ca (diff)
downloadmariadb-git-b8e655ce029a1f182602c9f12c3cc5931226eec2.tar.gz
bugfix: crash on the empty db namemariadb-10.4.6
followup for 0a43df4fbc7
-rw-r--r--mysql-test/main/grant5.result3
-rw-r--r--mysql-test/main/grant5.test7
-rw-r--r--sql/sql_acl.cc2
3 files changed, 11 insertions, 1 deletions
diff --git a/mysql-test/main/grant5.result b/mysql-test/main/grant5.result
index 086ae7011e4..2f16c5d630a 100644
--- a/mysql-test/main/grant5.result
+++ b/mysql-test/main/grant5.result
@@ -127,3 +127,6 @@ disconnect conn1;
connection default;
drop database mysqltest_1;
drop user twg@'%';
+insert mysql.tables_priv (host,db,user,table_name,grantor,table_priv) values ('localhost','','otto','t1','root@localhost','select');
+flush privileges;
+delete from mysql.tables_priv where db='';
diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test
index 4db262c25c1..43f5b9c180f 100644
--- a/mysql-test/main/grant5.test
+++ b/mysql-test/main/grant5.test
@@ -124,3 +124,10 @@ connection default;
drop database mysqltest_1;
drop user twg@'%';
+
+#
+# test the empty db case
+#
+insert mysql.tables_priv (host,db,user,table_name,grantor,table_priv) values ('localhost','','otto','t1','root@localhost','select');
+flush privileges;
+delete from mysql.tables_priv where db='';
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 17ae6dc036a..076b2e2994d 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -5084,7 +5084,6 @@ GRANT_NAME::GRANT_NAME(TABLE *form, bool is_routine)
update_hostname(&host, hostname);
db= get_field(&grant_memroot,form->field[1]);
- sort= get_magic_sort("hdu", host.hostname, db, user);
tname= get_field(&grant_memroot,form->field[3]);
if (!db || !tname)
{
@@ -5092,6 +5091,7 @@ GRANT_NAME::GRANT_NAME(TABLE *form, bool is_routine)
privs= 0;
return; /* purecov: inspected */
}
+ sort= get_magic_sort("hdu", host.hostname, db, user);
if (lower_case_table_names)
{
my_casedn_str(files_charset_info, db);