summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorserg@sergbook.mysql.com <>2007-03-23 17:56:58 +0200
committerserg@sergbook.mysql.com <>2007-03-23 17:56:58 +0200
commit2810a5a2667f93904ff38b09c46b92b0af435768 (patch)
treef346113a96a2cb894237c1d05bbd86496a6cc497 /sql/sql_view.cc
parent3e9d98b0391a559fc97ee4832c4ca40711343e79 (diff)
parent37e7a07465a4a255f843e1d24779cf84af7f04d0 (diff)
downloadmariadb-git-2810a5a2667f93904ff38b09c46b92b0af435768.tar.gz
Merge sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.0-build
into sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.0
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 83beec3d1be..533e847682d 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -496,35 +496,46 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
/*
Compare/check grants on view with grants of underlying tables
*/
+
+ fill_effective_table_privileges(thd, &view->grant, view->db,
+ view->table_name);
+
+ {
+ Item *report_item= NULL;
+ uint final_priv= VIEW_ANY_ACL;
+
for (sl= select_lex; sl; sl= sl->next_select())
{
DBUG_ASSERT(view->db); /* Must be set in the parser */
List_iterator_fast<Item> it(sl->item_list);
Item *item;
- fill_effective_table_privileges(thd, &view->grant, view->db,
- view->table_name);
while ((item= it++))
{
- Item_field *fld;
+ Item_field *fld= item->filed_for_view_update();
uint priv= (get_column_grant(thd, &view->grant, view->db,
view->table_name, item->name) &
VIEW_ANY_ACL);
- if ((fld= item->filed_for_view_update()))
+
+ if (fld && !fld->field->table->s->tmp_table)
{
- /*
- Do we have more privileges on view field then underlying table field?
- */
- if (!fld->field->table->s->tmp_table && (~fld->have_privileges & priv))
+ final_priv&= fld->have_privileges;
+
+ if (~fld->have_privileges & priv)
+ report_item= item;
+ }
+ }
+ }
+
+ if (!final_priv)
{
- /* VIEW column has more privileges */
+ DBUG_ASSERT(report_item);
+
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
"create view", thd->security_ctx->priv_user,
- thd->security_ctx->priv_host, item->name,
+ thd->security_ctx->priv_host, report_item->name,
view->table_name);
res= TRUE;
goto err;
- }
- }
}
}
#endif