List:Commits« Previous MessageNext Message »
From:Martin Hansson Date:October 16 2009 11:12am
Subject:bzr commit into mysql-5.1-bugteam branch (martin.hansson:3177) Bug#46019
View as plain text  
#At file:///data0/martin/bzr/bug46019/5.1bt/ based on revid:joerg@stripped

 3177 Martin Hansson	2009-10-16
      Bug#46019: ERROR 1356 When selecting from within another
                  view that has Group By
            
      When SELECT'ing from a view that mentions another,
      materialized, view, access was being denied. The issue was
      resolved by lifting a special case which avoided such access
      checking in check_single_table_access. In the past, this was
      necessary since if such a check were performed, the error
      message would be downgraded to a warning in the case of SHOW
      CREATE VIEW. The downgrading of errors was meant to handle
      only that scenario, but could not distinguish the two as it
      read only the error messages.
            
      The special case was needed in the fix of bug no 36086.
      Before that, views were confused with derived tables.
            
      After bug no 35996 was fixed, the manipulation of errors
      during SHOW CREATE VIEW execution is not dependent on the
      actual error messages in the queue, it rather looks at the
      actual cause of the error and takes appropriate
      action. Hence the aforementioned special case is now
      superfluous and the bug is fixed.
     @ mysql-test/r/view_grant.result
        Bug#46019: Test result.
     @ mysql-test/t/view_grant.test
        Bug#46019: Test case.
     @ sql/sql_parse.cc
        Bug#46019: fix.

    modified:
      mysql-test/r/view_grant.result
      mysql-test/t/view_grant.test
      sql/sql_parse.cc
=== modified file 'mysql-test/r/view_grant.result'
--- a/mysql-test/r/view_grant.result	2009-09-28 11:25:47 +0000
+++ b/mysql-test/r/view_grant.result	2009-10-16 11:12:21 +0000
@@ -1218,3 +1218,22 @@ Warnings:
 Note	1449	The user specified as a definer ('no_such_user'@'no_such_host') does not exist
 DROP TABLE t1;
 DROP VIEW v1;
+#
+# Bug #46019: ERROR 1356 When selecting from within another 
+#  view that has Group By
+#
+CREATE DATABASE mysqltest1;
+USE mysqltest1;
+CREATE TABLE t1 (a INT);
+CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT a FROM t1 GROUP BY a;
+CREATE SQL SECURITY INVOKER VIEW v2 AS SELECT a FROM v1;
+CREATE USER mysqluser1;
+GRANT SELECT ON TABLE t1 TO mysqluser1;
+GRANT SELECT, SHOW VIEW ON TABLE v1 TO mysqluser1;
+GRANT SELECT, SHOW VIEW ON TABLE v2 TO mysqluser1;
+SELECT a FROM v1;
+a
+SELECT a FROM v2;
+a
+DROP USER mysqluser1;
+DROP DATABASE mysqltest1;

=== modified file 'mysql-test/t/view_grant.test'
--- a/mysql-test/t/view_grant.test	2009-09-28 11:25:47 +0000
+++ b/mysql-test/t/view_grant.test	2009-10-16 11:12:21 +0000
@@ -1506,3 +1506,29 @@ DROP VIEW v1;
 # Wait till we reached the initial number of concurrent sessions
 --source include/wait_until_count_sessions.inc
 
+--echo #
+--echo # Bug #46019: ERROR 1356 When selecting from within another 
+--echo #  view that has Group By
+--echo #
+CREATE DATABASE mysqltest1;
+USE mysqltest1;
+
+CREATE TABLE t1 (a INT);
+
+CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT a FROM t1 GROUP BY a;
+CREATE SQL SECURITY INVOKER VIEW v2 AS SELECT a FROM v1;
+
+CREATE USER mysqluser1;
+
+GRANT SELECT ON TABLE t1 TO mysqluser1;
+GRANT SELECT, SHOW VIEW ON TABLE v1 TO mysqluser1;
+GRANT SELECT, SHOW VIEW ON TABLE v2 TO mysqluser1;
+
+--connect (mysqluser1, localhost, mysqluser1,,mysqltest1)
+SELECT a FROM v1;
+SELECT a FROM v2;
+
+--connection default
+--disconnect mysqluser1
+DROP USER mysqluser1;
+DROP DATABASE mysqltest1;

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2009-10-07 15:03:42 +0000
+++ b/sql/sql_parse.cc	2009-10-16 11:12:21 +0000
@@ -5089,8 +5089,6 @@ bool check_single_table_access(THD *thd,
   /* Show only 1 table for check_grant */
   if (!(all_tables->belong_to_view &&
         (thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
-      !(all_tables->view &&
-        all_tables->effective_algorithm == VIEW_ALGORITHM_TMPTABLE) &&
       check_grant(thd, privilege, all_tables, 0, 1, no_errors))
     goto deny;
 


Attachment: [text/bzr-bundle] bzr/martin.hansson@sun.com-20091016111221-18gayknl6eoobl2r.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (martin.hansson:3177) Bug#46019Martin Hansson16 Oct