List:Commits« Previous MessageNext Message »
From:konstantin Date:January 30 2008 3:18pm
Subject:bk commit into 5.1 tree (kostja:1.2664) BUG#34166
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kostja.  When kostja 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, 2008-01-30 18:18:09+03:00, kostja@dipika.(none) +12 -0
  A fix and a test case for Bug#34166 Server crash in SHOW OPEN TABLES and
  pre-locking.
  
  The crash was caused by an implicit assumption in check_table_access() that
  table_list parameter is always a part of lex->query_tables.
  
  When iterating over the passed list of tables, check_table_access() used
  to stop only when lex->query_tables_last_not_own was reached. 
  In case of pre-locking, lex->query_tables_last_own is not NULL and points
  to some element of lex->query_tables. When the parameter
  of check_table_access() was not part of lex->query_tables, loop invariant
  could never be violated and a crash would happen when the current table
  pointer would point beyond the end of the provided list.
  
  The fix is to change the signature of check_table_access() to also accept
  a numeric limit of loop iterations, similarly to check_grant(), and 
  supply this limit in all places when we want to check access of tables
  that are outside lex->query_tables, or just want to check access to one table.

  mysql-test/r/information_schema.result@stripped, 2008-01-30 18:18:06+03:00, kostja@dipika.(none) +15 -0
    Update test results (Bug#34166).

  mysql-test/t/information_schema.test@stripped, 2008-01-30 18:18:06+03:00, kostja@dipika.(none) +22 -0
    Add a test case for Bug#34166.

  sql/mysql_priv.h@stripped, 2008-01-30 18:18:06+03:00, kostja@dipika.(none) +2 -2
    Change signature of check_table_access() to accept a numeric limit
    of tables to check.

  sql/sp_head.cc@stripped, 2008-01-30 18:18:06+03:00, kostja@dipika.(none) +2 -2
    Update to the new signature of check_table_access().

  sql/sql_base.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +1 -1
    Update to the new signature of check_table_access().

  sql/sql_cache.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +1 -1
    Update to the new signature of check_table_access().

  sql/sql_parse.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +40 -34
    Update to the new signature of check_table_access().
    Change check_table_access() to accept an optional numeric limit of tables
    to check. A crash would happen when check_table_access() was
    passed a list of tables that is not part of lex->query_tables and
    lex->query_tables_last_own was not NULL.

  sql/sql_plugin.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +1 -1
    Update to the new signature of check_table_access().

  sql/sql_prepare.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +3 -3
    Update to the new signature of check_table_access().

  sql/sql_show.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +2 -4
    Update to the new signature of check_table_access().
    Ensure that check_table_access() only checks access to the first
    table in the table list when called from list_open_tables().
    list_open_tables() supplies a table list that is created on stack,
    whereas check_table_access() used to assume that the supplied list is a part
    of thd->lex.

  sql/sql_trigger.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +1 -1
    Update to the new signature of check_table_access().

  sql/sql_view.cc@stripped, 2008-01-30 18:18:07+03:00, kostja@dipika.(none) +3 -3
    Update to the new signature of check_table_access().

diff -Nrup a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
--- a/mysql-test/r/information_schema.result	2007-12-04 11:48:09 +03:00
+++ b/mysql-test/r/information_schema.result	2008-01-30 18:18:06 +03:00
@@ -1619,4 +1619,19 @@ Db	Name	Definer	Time zone	Type	Execute a
 show events where Db= 'information_schema';
 Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
 use test;
+#
+# Bug#XXX: Server crash in SHOW OPEN TABLES and prelocking
+#
+drop table if exists t1;
+drop function if exists f1;
+create table t1 (a int);
+create function f1() returns int
+begin
+insert into t1 (a) values (1);
+return 0;
+end|
+show open tables where f1()=0;
+show open tables where f1()=0;
+drop table t1;
+drop function f1;
 End of 5.1 tests.
diff -Nrup a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
--- a/mysql-test/t/information_schema.test	2007-12-13 14:49:52 +03:00
+++ b/mysql-test/t/information_schema.test	2008-01-30 18:18:06 +03:00
@@ -1248,4 +1248,26 @@ show events from information_schema;
 show events where Db= 'information_schema';
 use test;
 
+--echo #
+--echo # Bug#XXX: Server crash in SHOW OPEN TABLES and prelocking
+--echo #
+--disable_warnings
+drop table if exists t1;
+drop function if exists f1;
+--enable_warnings
+create table t1 (a int);
+delimiter |;
+create function f1() returns int
+begin
+  insert into t1 (a) values (1);
+  return 0;
+end|
+delimiter ;|
+--disable_result_log
+show open tables where f1()=0;
+show open tables where f1()=0;
+--enable_result_log
+drop table t1;
+drop function f1;
+
 --echo End of 5.1 tests.
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h	2007-12-14 16:01:09 +03:00
+++ b/sql/mysql_priv.h	2008-01-30 18:18:06 +03:00
@@ -1015,7 +1015,7 @@ bool reload_acl_and_cache(THD *thd, ulon
 bool check_access(THD *thd, ulong access, const char *db, ulong *save_priv,
 		  bool no_grant, bool no_errors, bool schema_db);
 bool check_table_access(THD *thd, ulong want_access, TABLE_LIST *tables,
-			bool no_errors);
+			uint number, bool no_errors);
 bool check_global_access(THD *thd, ulong want_access);
 #else
 inline bool check_access(THD *thd, ulong access, const char *db,
@@ -1027,7 +1027,7 @@ inline bool check_access(THD *thd, ulong
   return false;
 }
 inline bool check_table_access(THD *thd, ulong want_access, TABLE_LIST *tables,
-			bool no_errors)
+			uint number, bool no_errors)
 { return false; }
 inline bool check_global_access(THD *thd, ulong want_access)
 { return false; }
diff -Nrup a/sql/sp_head.cc b/sql/sp_head.cc
--- a/sql/sp_head.cc	2008-01-24 01:36:39 +03:00
+++ b/sql/sp_head.cc	2008-01-30 18:18:06 +03:00
@@ -2265,7 +2265,7 @@ bool check_show_routine_access(THD *thd,
   bzero((char*) &tables,sizeof(tables));
   tables.db= (char*) "mysql";
   tables.table_name= tables.alias= (char*) "proc";
-  *full_access= (!check_table_access(thd, SELECT_ACL, &tables, 1) ||
+  *full_access= (!check_table_access(thd, SELECT_ACL, &tables, 1, TRUE) ||
                  (!strcmp(sp->m_definer_user.str,
                           thd->security_ctx->priv_user) &&
                   !strcmp(sp->m_definer_host.str,
@@ -2712,7 +2712,7 @@ int sp_instr::exec_open_and_lock_tables(
     Check whenever we have access to tables for this statement
     and open and lock them before executing instructions core function.
   */
-  if (check_table_access(thd, SELECT_ACL, tables, 0)
+  if (check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)
       || open_and_lock_tables(thd, tables))
     result= -1;
   else
diff -Nrup a/sql/sql_base.cc b/sql/sql_base.cc
--- a/sql/sql_base.cc	2008-01-19 22:32:43 +03:00
+++ b/sql/sql_base.cc	2008-01-30 18:18:07 +03:00
@@ -799,7 +799,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *t
     table_list.table_name= share->table_name.str;
     table_list.grant.privilege=0;
 
-    if (check_table_access(thd,SELECT_ACL | EXTRA_ACL,&table_list,1))
+    if (check_table_access(thd,SELECT_ACL | EXTRA_ACL,&table_list, 1, TRUE))
       continue;
     /* need to check if we haven't already listed it */
     for (table= open_list  ; table ; table=table->next)
diff -Nrup a/sql/sql_cache.cc b/sql/sql_cache.cc
--- a/sql/sql_cache.cc	2008-01-03 17:37:50 +03:00
+++ b/sql/sql_cache.cc	2008-01-30 18:18:07 +03:00
@@ -1378,7 +1378,7 @@ def_week_frmt: %lu",                    
     table_list.db = table->db();
     table_list.alias= table_list.table_name= table->table();
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
-    if (check_table_access(thd,SELECT_ACL,&table_list,1))
+    if (check_table_access(thd,SELECT_ACL,&table_list, 1, TRUE))
     {
       DBUG_PRINT("qcache",
 		 ("probably no SELECT access to %s.%s =>  return to normal processing",
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2007-12-17 16:28:05 +03:00
+++ b/sql/sql_parse.cc	2008-01-30 18:18:07 +03:00
@@ -495,7 +495,7 @@ static bool check_merge_table_access(THD
         tlist->db= db; /* purecov: inspected */
     }
     error= check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
-                              table_list,0);
+                              table_list, UINT_MAX, FALSE);
   }
   return error;
 }
@@ -1994,7 +1994,7 @@ mysql_execute_command(THD *thd)
       res= check_table_access(thd,
                               lex->exchange ? SELECT_ACL | FILE_ACL :
                               SELECT_ACL,
-                              all_tables, 0);
+                              all_tables, UINT_MAX, FALSE);
     }
     else
       res= check_access(thd,
@@ -2019,7 +2019,7 @@ mysql_execute_command(THD *thd)
     break;
   }
   case SQLCOM_DO:
-    if (check_table_access(thd, SELECT_ACL, all_tables, 0) ||
+    if (check_table_access(thd, SELECT_ACL, all_tables, UINT_MAX, FALSE) ||
         open_and_lock_tables(thd, all_tables))
       goto error;
 
@@ -2116,7 +2116,7 @@ mysql_execute_command(THD *thd)
   case SQLCOM_BACKUP_TABLE:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL, all_tables, 0) ||
+    if (check_table_access(thd, SELECT_ACL, all_tables, UINT_MAX, FALSE) ||
 	check_global_access(thd, FILE_ACL))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
@@ -2128,7 +2128,7 @@ mysql_execute_command(THD *thd)
   case SQLCOM_RESTORE_TABLE:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, INSERT_ACL, all_tables, 0) ||
+    if (check_table_access(thd, INSERT_ACL, all_tables, UINT_MAX, FALSE) ||
 	check_global_access(thd, FILE_ACL))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
@@ -2677,7 +2677,8 @@ end_with_restore_list:
   case SQLCOM_CHECKSUM:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL | EXTRA_ACL, all_tables, 0))
+    if (check_table_access(thd, SELECT_ACL | EXTRA_ACL, all_tables,
+                           UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     res = mysql_checksum_table(thd, first_table, &lex->check_opt);
     break;
@@ -2685,7 +2686,8 @@ end_with_restore_list:
   case SQLCOM_REPAIR:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
+    if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables,
+                           UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
     res= mysql_repair_table(thd, first_table, &lex->check_opt);
@@ -2704,7 +2706,8 @@ end_with_restore_list:
   case SQLCOM_CHECK:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL | EXTRA_ACL , all_tables, 0))
+    if (check_table_access(thd, SELECT_ACL | EXTRA_ACL , all_tables,
+                           UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
     res = mysql_check_table(thd, first_table, &lex->check_opt);
@@ -2715,7 +2718,8 @@ end_with_restore_list:
   case SQLCOM_ANALYZE:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
+    if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables,
+                           UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
     res= mysql_analyze_table(thd, first_table, &lex->check_opt);
@@ -2735,7 +2739,8 @@ end_with_restore_list:
   case SQLCOM_OPTIMIZE:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
+    if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables,
+                           UINT_MAX, FALSE))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
     res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
@@ -3064,7 +3069,7 @@ end_with_restore_list:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
     if (!lex->drop_temporary)
     {
-      if (check_table_access(thd, DROP_ACL, all_tables, 0))
+      if (check_table_access(thd, DROP_ACL, all_tables, UINT_MAX, FALSE))
 	goto error;				/* purecov: inspected */
       if (end_active_trans(thd))
         goto error;
@@ -3168,7 +3173,7 @@ end_with_restore_list:
     if (lex->autocommit && end_active_trans(thd))
       goto error;
 
-    if ((check_table_access(thd, SELECT_ACL, all_tables, 0) ||
+    if ((check_table_access(thd, SELECT_ACL, all_tables, UINT_MAX, FALSE) ||
 	 open_and_lock_tables(thd, all_tables)))
       goto error;
     if (lex->one_shot_set && not_all_support_one_shot(lex_var_list))
@@ -3210,7 +3215,8 @@ end_with_restore_list:
     /* we must end the trasaction first, regardless of anything */
     if (end_active_trans(thd))
       goto error;
-    if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, 0))
+    if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables,
+                           UINT_MAX, FALSE))
       goto error;
     thd->in_lock_tables=1;
     thd->options|= OPTION_TABLE_LOCK;
@@ -3704,7 +3710,7 @@ end_with_restore_list:
 #endif
   case SQLCOM_HA_OPEN:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL, all_tables, 0))
+    if (check_table_access(thd, SELECT_ACL, all_tables, UINT_MAX, FALSE))
       goto error;
     res= mysql_ha_open(thd, first_table, 0);
     break;
@@ -3952,7 +3958,7 @@ create_sp_error:
         This will cache all SP and SF and open and lock all tables
         required for execution.
       */
-      if (check_table_access(thd, SELECT_ACL, all_tables, 0) ||
+      if (check_table_access(thd, SELECT_ACL, all_tables, UINT_MAX, FALSE) ||
 	  open_and_lock_tables(thd, all_tables))
        goto error;
 
@@ -4299,7 +4305,7 @@ create_sp_error:
     }
   case SQLCOM_DROP_VIEW:
     {
-      if (check_table_access(thd, DROP_ACL, all_tables, 0) ||
+      if (check_table_access(thd, DROP_ACL, all_tables, UINT_MAX, FALSE) ||
           end_active_trans(thd))
         goto error;
       /* Conditionally writes to binlog. */
@@ -4778,7 +4784,7 @@ bool check_one_table_access(THD *thd, ul
       subselects_tables= subselects_tables->next_global;
     }
     if (subselects_tables &&
-        (check_table_access(thd, SELECT_ACL, subselects_tables, 0)))
+        (check_table_access(thd, SELECT_ACL, subselects_tables, UINT_MAX, FALSE)))
       return 1;
   }
   return 0;
@@ -5011,39 +5017,39 @@ static bool check_show_access(THD *thd, 
 /*
   Check the privilege for all used tables.
 
-  SYNOPSYS
-    check_table_access()
-      thd          Thread context
-      want_access  Privileges requested
-      tables       List of tables to be checked
-      no_errors    FALSE/TRUE - report/don't report error to
-                   the client (using my_error() call).
+  @param    thd          Thread context
+  @param    want_access  Privileges requested
+  @param    tables       List of tables to be checked
+  @param    number       Check at most this number of tables.
+  @param    no_errors    FALSE/TRUE - report/don't report error to
+                         the client (using my_error() call).
 
-  NOTES
+  @note
     Table privileges are cached in the table list for GRANT checking.
     This functions assumes that table list used and
     thd->lex->query_tables_own_last value correspond to each other
     (the latter should be either 0 or point to next_global member
     of one of elements of this table list).
 
-  RETURN VALUE
-    FALSE - OK
-    TRUE  - Access denied
+  @retval  FALSE   OK
+  @retval  TRUE    Access denied
 */
 
 bool
 check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
-		   bool no_errors)
+		   uint number, bool no_errors)
 {
   TABLE_LIST *org_tables= tables;
   TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
+  uint i= 0;
   Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
   /*
     The check that first_not_own_table is not reached is for the case when
     the given table list refers to the list for prelocking (contains tables
     of other queries). For simple queries first_not_own_table is 0.
   */
-  for (; tables != first_not_own_table; tables= tables->next_global)
+  for (; i < number && tables != first_not_own_table;
+       tables= tables->next_global, i++)
   {
     if (tables->security_ctx)
       sctx= tables->security_ctx;
@@ -5093,7 +5099,7 @@ check_table_access(THD *thd, ulong want_
   }
   thd->security_ctx= backup_ctx;
   return check_grant(thd,want_access & ~EXTRA_ACL,org_tables,
-		       test(want_access & EXTRA_ACL), UINT_MAX, no_errors);
+		       test(want_access & EXTRA_ACL), number, no_errors);
 deny:
   thd->security_ctx= backup_ctx;
   return TRUE;
@@ -6855,7 +6861,7 @@ bool multi_delete_precheck(THD *thd, TAB
 
   /* sql_yacc guarantees that tables and aux_tables are not zero */
   DBUG_ASSERT(aux_tables != 0);
-  if (check_table_access(thd, SELECT_ACL, tables, 0))
+  if (check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE))
     DBUG_RETURN(TRUE);
 
   /*
@@ -6864,7 +6870,7 @@ bool multi_delete_precheck(THD *thd, TAB
     call check_table_access() safely.
   */
   thd->lex->query_tables_own_last= 0;
-  if (check_table_access(thd, DELETE_ACL, aux_tables, 0))
+  if (check_table_access(thd, DELETE_ACL, aux_tables, UINT_MAX, FALSE))
   {
     thd->lex->query_tables_own_last= save_query_tables_own_last;
     DBUG_RETURN(TRUE);
@@ -7108,7 +7114,7 @@ bool create_table_precheck(THD *thd, TAB
       }
     }
 #endif
-    if (tables && check_table_access(thd, SELECT_ACL, tables,0))
+    if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE))
       goto err;
   }
   else if (lex->create_info.options & HA_LEX_CREATE_TABLE_LIKE)
diff -Nrup a/sql/sql_plugin.cc b/sql/sql_plugin.cc
--- a/sql/sql_plugin.cc	2007-12-13 14:49:55 +03:00
+++ b/sql/sql_plugin.cc	2008-01-30 18:18:07 +03:00
@@ -1619,7 +1619,7 @@ bool mysql_install_plugin(THD *thd, cons
   bzero(&tables, sizeof(tables));
   tables.db= (char *)"mysql";
   tables.table_name= tables.alias= (char *)"plugin";
-  if (check_table_access(thd, INSERT_ACL, &tables, 0))
+  if (check_table_access(thd, INSERT_ACL, &tables, 1, FALSE))
     DBUG_RETURN(TRUE);
 
   /* need to open before acquiring LOCK_plugin or it will deadlock */
diff -Nrup a/sql/sql_prepare.cc b/sql/sql_prepare.cc
--- a/sql/sql_prepare.cc	2007-12-12 18:20:56 +03:00
+++ b/sql/sql_prepare.cc	2008-01-30 18:18:07 +03:00
@@ -1272,7 +1272,7 @@ static int mysql_test_select(Prepared_st
   ulong privilege= lex->exchange ? SELECT_ACL | FILE_ACL : SELECT_ACL;
   if (tables)
   {
-    if (check_table_access(thd, privilege, tables,0))
+    if (check_table_access(thd, privilege, tables, UINT_MAX, FALSE))
       goto error;
   }
   else if (check_access(thd, privilege, any_db,0,0,0,0))
@@ -1342,7 +1342,7 @@ static bool mysql_test_do_fields(Prepare
   THD *thd= stmt->thd;
 
   DBUG_ENTER("mysql_test_do_fields");
-  if (tables && check_table_access(thd, SELECT_ACL, tables, 0))
+  if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE))
     DBUG_RETURN(TRUE);
 
   if (open_normal_and_derived_tables(thd, tables, 0))
@@ -1374,7 +1374,7 @@ static bool mysql_test_set_fields(Prepar
   THD *thd= stmt->thd;
   set_var_base *var;
 
-  if (tables && check_table_access(thd, SELECT_ACL, tables, 0) ||
+  if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) ||
       open_normal_and_derived_tables(thd, tables, 0))
     goto error;
 
diff -Nrup a/sql/sql_show.cc b/sql/sql_show.cc
--- a/sql/sql_show.cc	2008-01-19 22:32:44 +03:00
+++ b/sql/sql_show.cc	2008-01-30 18:18:07 +03:00
@@ -4059,7 +4059,7 @@ int fill_schema_proc(THD *thd, TABLE_LIS
   proc_tables.table_name= proc_tables.alias= (char*) "proc";
   proc_tables.table_name_length= 4;
   proc_tables.lock_type= TL_READ;
-  full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, 1);
+  full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, 1, TRUE);
   if (!(proc_table= open_proc_table_for_read(thd, &open_tables_state_backup)))
   {
     DBUG_RETURN(1);
@@ -4447,10 +4447,8 @@ static int get_schema_triggers_record(TH
     Table_triggers_list *triggers= tables->table->triggers;
     int event, timing;
 
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-    if (check_table_access(thd, TRIGGER_ACL, tables, 1))
+    if (check_table_access(thd, TRIGGER_ACL, tables, 1, TRUE))
       goto ret;
-#endif
 
     for (event= 0; event < (int)TRG_EVENT_MAX; event++)
     {
diff -Nrup a/sql/sql_trigger.cc b/sql/sql_trigger.cc
--- a/sql/sql_trigger.cc	2007-11-29 14:42:24 +03:00
+++ b/sql/sql_trigger.cc	2008-01-30 18:18:07 +03:00
@@ -418,7 +418,7 @@ bool mysql_create_or_drop_trigger(THD *t
     TABLE_LIST **save_query_tables_own_last= thd->lex->query_tables_own_last;
     thd->lex->query_tables_own_last= 0;
 
-    err_status= check_table_access(thd, TRIGGER_ACL, tables, 0);
+    err_status= check_table_access(thd, TRIGGER_ACL, tables, 1, FALSE);
 
     thd->lex->query_tables_own_last= save_query_tables_own_last;
 
diff -Nrup a/sql/sql_view.cc b/sql/sql_view.cc
--- a/sql/sql_view.cc	2007-10-30 20:08:13 +03:00
+++ b/sql/sql_view.cc	2008-01-30 18:18:07 +03:00
@@ -1123,8 +1123,8 @@ bool mysql_make_view(THD *thd, File_pars
     if (!table->prelocking_placeholder &&
         (old_lex->sql_command == SQLCOM_SELECT && old_lex->describe))
     {
-      if (check_table_access(thd, SELECT_ACL, view_tables, 1) &&
-          check_table_access(thd, SHOW_VIEW_ACL, table, 1))
+      if (check_table_access(thd, SELECT_ACL, view_tables, UINT_MAX, TRUE) &&
+          check_table_access(thd, SHOW_VIEW_ACL, table, UINT_MAX, TRUE))
       {
         my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0));
         goto err;
@@ -1134,7 +1134,7 @@ bool mysql_make_view(THD *thd, File_pars
              (old_lex->sql_command == SQLCOM_SHOW_CREATE) &&
              !table->belong_to_view)
     {
-      if (check_table_access(thd, SHOW_VIEW_ACL, table, 0))
+      if (check_table_access(thd, SHOW_VIEW_ACL, table, UINT_MAX, FALSE))
         goto err;
     }
 
Thread
bk commit into 5.1 tree (kostja:1.2664) BUG#34166konstantin30 Jan