Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-12-25 16:36:44+04:00, gluh@stripped +5 -0
Bug#22763 Disrepancy between SHOW CREATE VIEW and I_S.VIEWS
if user does not have privileges on underlying tables then we hide view body
if user has priviliges on underlying tables and user is definer or has 'SHOW_VIEW_ACL' privilege
then we show body
mysql-test/r/information_schema.result@stripped, 2006-12-25 16:36:42+04:00, gluh@stripped +11 -0
test result
mysql-test/t/information_schema.test@stripped, 2006-12-25 16:36:42+04:00, gluh@stripped +16 -3
test case
sql/sql_acl.cc@stripped, 2006-12-25 16:36:42+04:00, gluh@stripped +9 -4
checked that user has privileges on underlying table and
set no_privs_on_underlying_tables for top view
sql/sql_show.cc@stripped, 2006-12-25 16:36:42+04:00, gluh@stripped +15 -3
if user does not have privileges on underlying tables then we hide view body
if user has priviliges on underlying tables and user is definer or has 'SHOW_VIEW_ACL' privilege
then we show body
sql/table.h@stripped, 2006-12-25 16:36:42+04:00, gluh@stripped +1 -1
'allowed_show' is renamed to 'no_privs_on_underlying_tables'
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gluh
# Host: eagle.(none)
# Root: /home/gluh/MySQL/Bugs/5.0.22763
--- 1.214/sql/sql_acl.cc 2006-11-30 20:24:57 +04:00
+++ 1.215/sql/sql_acl.cc 2006-12-25 16:36:42 +04:00
@@ -3812,10 +3812,10 @@ bool check_column_grant_in_table_ref(THD
view_privs= get_column_grant(thd, grant, db_name, table_name, name);
if (view_privs & VIEW_ANY_ACL)
{
- table_ref->belong_to_view->allowed_show= TRUE;
+ table_ref->belong_to_view->no_privs_on_underlying_tables= FALSE;
return FALSE;
}
- table_ref->belong_to_view->allowed_show= FALSE;
+ table_ref->belong_to_view->no_privs_on_underlying_tables= TRUE;
my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0));
return TRUE;
}
@@ -3830,8 +3830,13 @@ bool check_column_grant_in_table_ref(THD
}
if (grant->want_privilege)
- return check_grant_column(thd, grant, db_name, table_name, name,
- length, sctx);
+ {
+ bool res= check_grant_column(thd, grant, db_name, table_name, name,
+ length, sctx);
+ if (table_ref->belong_to_view)
+ table_ref->belong_to_view->no_privs_on_underlying_tables= res;
+ return res;
+ }
else
return FALSE;
--- 1.333/sql/sql_show.cc 2006-11-30 20:25:01 +04:00
+++ 1.334/sql/sql_show.cc 2006-12-25 16:36:42 +04:00
@@ -3137,19 +3137,31 @@ static int get_schema_views_record(THD *
if (tables->view)
{
+ bool show_body= 0;
Security_context *sctx= thd->security_ctx;
- if (!tables->allowed_show)
+
+ if (!tables->no_privs_on_underlying_tables)
{
if (!my_strcasecmp(system_charset_info, tables->definer.user.str,
sctx->priv_user) &&
!my_strcasecmp(system_charset_info, tables->definer.host.str,
sctx->priv_host))
- tables->allowed_show= TRUE;
+ show_body= 1;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ else
+ {
+ fill_effective_table_privileges(thd, &tables->grant,
+ tables->view_db.str,
+ tables->view_name.str);
+ show_body= (bool) (tables->grant.privilege & SHOW_VIEW_ACL);
+ }
+#endif
}
+
restore_record(table, s->default_values);
table->field[1]->store(tables->view_db.str, tables->view_db.length, cs);
table->field[2]->store(tables->view_name.str, tables->view_name.length, cs);
- if (tables->allowed_show)
+ if (show_body)
{
char buff[2048];
String qwe_str(buff, sizeof(buff), cs);
--- 1.135/sql/table.h 2006-11-01 05:31:49 +04:00
+++ 1.136/sql/table.h 2006-12-25 16:36:42 +04:00
@@ -577,7 +577,7 @@ typedef struct st_table_list
tables. Unlike 'next_local', this in this list views are *not*
leaves. Created in setup_tables() -> make_leaves_list().
*/
- bool allowed_show;
+ bool no_privs_on_underlying_tables;
st_table_list *next_leaf;
Item *where; /* VIEW WHERE clause condition */
Item *check_option; /* WITH CHECK OPTION condition */
--- 1.117/mysql-test/r/information_schema.result 2006-12-01 20:56:55 +04:00
+++ 1.118/mysql-test/r/information_schema.result 2006-12-25 16:36:42 +04:00
@@ -1269,3 +1269,14 @@ id select_type table type possible_keys
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
2 DERIVED tables ALL NULL NULL NULL NULL 2
drop view v1;
+create database mysqltest;
+create table mysqltest.t1 (a int);
+create view mysqltest.v1 as select * from mysqltest.t1;
+grant show view on mysqltest.* to mysqltest22763@localhost;
+grant select on mysqltest.* to mysqltest22763@localhost;
+select table_schema, table_name, view_definition from information_schema.views
+where table_name = 'v1';
+table_schema table_name view_definition
+mysqltest v1 /* ALGORITHM=UNDEFINED */ select `mysqltest`.`t1`.`a` AS `a` from `mysqltest`.`t1`
+drop database mysqltest;
+drop user mysqltest22763@localhost;
--- 1.88/mysql-test/t/information_schema.test 2006-12-01 20:56:55 +04:00
+++ 1.89/mysql-test/t/information_schema.test 2006-12-25 16:36:42 +04:00
@@ -971,9 +971,6 @@ SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT),
DROP TABLE bug23037;
DROP FUNCTION get_value;
-
-
-
#
# Bug#22413: EXPLAIN SELECT FROM view with ORDER BY yield server crash
#
@@ -986,5 +983,21 @@ order by object_schema;
explain select * from v1;
explain select * from (select table_name from information_schema.tables) as a;
drop view v1;
+
+#
+# Bug#22763 Disrepancy between SHOW CREATE VIEW and I_S.VIEWS
+#
+create database mysqltest;
+create table mysqltest.t1 (a int);
+create view mysqltest.v1 as select * from mysqltest.t1;
+grant show view on mysqltest.* to mysqltest22763@localhost;
+grant select on mysqltest.* to mysqltest22763@localhost;
+connect (user22763, localhost,mysqltest22763,,test);
+connection user22763;
+select table_schema, table_name, view_definition from information_schema.views
+where table_name = 'v1';
+connection default;
+drop database mysqltest;
+drop user mysqltest22763@localhost;
# End of 5.0 tests.
| Thread |
|---|
| • bk commit into 5.0 tree (gluh:1.2350) BUG#22763 | gluh | 25 Dec |