Commit c234aaa0 authored by unknown's avatar unknown
Browse files

Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt

into  sunlight.local:/local_work/21261-bug-5.0-mysql


sql/sql_select.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
mysql-test/r/view.result:
  SCCS merged
mysql-test/t/view.test:
  SCCS merged
parents 03a5e2e7 a23d1792
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -2850,6 +2850,25 @@ Tables_in_test
t1
DROP TABLE t1;
DROP VIEW IF EXISTS v1;
CREATE DATABASE bug21261DB;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
UPDATE v1,t2 SET x=1 WHERE x=y;
SELECT * FROM t1;
x
1
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
+30 −0
Original line number Diff line number Diff line
@@ -2719,6 +2719,36 @@ DROP TABLE t1;
DROP VIEW IF EXISTS v1;
--enable_warnings

#
# Bug #21261: Wrong access rights was required for an insert to a view
#
CREATE DATABASE bug21261DB;
CONNECT (root,localhost,root,,bug21261DB);
CONNECTION root;

CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';

CONNECT (user21261, localhost, user21261,, bug21261DB);
CONNECTION user21261;
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
CONNECTION root;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
CONNECTION user21261;
UPDATE v1,t2 SET x=1 WHERE x=y;
CONNECTION root;
SELECT * FROM t1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;

#
# Bug #15950: NOW() optimized away in VIEWs
#
+1 −0
Original line number Diff line number Diff line
@@ -974,6 +974,7 @@ bool setup_tables_and_check_access (THD *thd,
                                    TABLE_LIST *tables, Item **conds, 
                                    TABLE_LIST **leaves, 
                                    bool select_insert,
                                    ulong want_access_first,
                                    ulong want_access);
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
	       List<Item> *sum_func_list, uint wild_num);
+7 −2
Original line number Diff line number Diff line
@@ -4563,9 +4563,11 @@ bool setup_tables_and_check_access(THD *thd,
                                   TABLE_LIST *tables,
                                   Item **conds, TABLE_LIST **leaves,
                                   bool select_insert,
                                   ulong want_access_first,
                                   ulong want_access)
{
  TABLE_LIST *leaves_tmp = NULL;
  bool first_table= true;

  if (setup_tables (thd, context, from_clause, tables, conds, 
                    &leaves_tmp, select_insert))
@@ -4575,13 +4577,16 @@ bool setup_tables_and_check_access(THD *thd,
    *leaves = leaves_tmp;

  for (; leaves_tmp; leaves_tmp= leaves_tmp->next_leaf)
  {
    if (leaves_tmp->belong_to_view && 
        check_single_table_access(thd, want_access,  leaves_tmp))
        check_single_table_access(thd, first_table ? want_access_first :
                                  want_access,  leaves_tmp))
    {
      tables->hide_view_error(thd);
      return TRUE;
    }

    first_table= false;
  }
  return FALSE;
}

+2 −2
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
                                    &thd->lex->select_lex.top_join_list,
                                    table_list, conds, 
                                    &select_lex->leaf_tables, FALSE, 
                                    DELETE_ACL) ||
                                    DELETE_ACL, SELECT_ACL) ||
      setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
      setup_ftfuncs(select_lex))
    DBUG_RETURN(TRUE);
@@ -413,7 +413,7 @@ bool mysql_multi_delete_prepare(THD *thd)
                                    &thd->lex->select_lex.top_join_list,
                                    lex->query_tables, &lex->select_lex.where,
                                    &lex->select_lex.leaf_tables, FALSE, 
                                    DELETE_ACL))
                                    DELETE_ACL, SELECT_ACL))
    DBUG_RETURN(TRUE);


Loading