summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <gkodinov@mysql.com>2006-06-12 18:15:08 +0300
committerunknown <gkodinov@mysql.com>2006-06-12 18:15:08 +0300
commite7daa497613cdd1845ec6b05d7cf3f9efaa2662c (patch)
tree7998638bb2a54c4bb0c47162d82a0400a026acd6 /sql/sql_parse.cc
parent2dd1dc62462a9b7348d1c815acacddedb5a62d88 (diff)
downloadmariadb-git-e7daa497613cdd1845ec6b05d7cf3f9efaa2662c.tar.gz
Bug #20363: Create view on just created view is now denied
There was a wrong determination of the DB name (witch is not always the one in TABLE_LIST because derived tables may be calculated using temp tables that have their db name set to ""). The fix determines the database name according to the type of table reference, and calls the function check_access() with the correct db name so the correct set of grants is found. mysql-test/r/view_grant.result: testsuite for the bug mysql-test/t/view_grant.test: testsuite for the bug sql/sql_parse.cc: correct determination of the db name.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 213a7730824..ba5c2ebf484 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5004,7 +5004,14 @@ bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
if (all_tables->security_ctx)
thd->security_ctx= all_tables->security_ctx;
- if (check_access(thd, privilege, all_tables->db,
+ const char *db_name;
+ if ((all_tables->view || all_tables->field_translation) &&
+ !all_tables->schema_table)
+ db_name= all_tables->view_db.str;
+ else
+ db_name= all_tables->db;
+
+ if (check_access(thd, privilege, db_name,
&all_tables->grant.privilege, 0, 0,
test(all_tables->schema_table)))
goto deny;