#At file:///Users/malff/BZR_TREE/mysql-next-mr-bugfixing-52586/ based on revid:alik@stripped
3144 Marc Alff 2010-04-07
Bug#52586 Misleading error message on attempt to access a P_S table using a wrong name
Before this fix,
select * from performance_schema.no_such_table
would fail with ER_TABLEACCESS_DENIED_ERROR,
because the performance schema code automatically
denied SELECT_ACL on performance_schema.*.
With this fix, SELECT_ACL on performance_schema.*
is not premptively rejected,
so that:
select * from performance_schema.no_such_table
now fails later in the code execution with ER_NO_SUCH_TABLE.
The statement still fails, as expected,
but returning a more detailed error
(that now discloses the information that the table really does not exist)
is better for ease of use.
modified:
mysql-test/suite/perfschema/r/misc.result
mysql-test/suite/perfschema/t/misc.test
storage/perfschema/pfs_engine_table.cc
=== modified file 'mysql-test/suite/perfschema/r/misc.result'
--- a/mysql-test/suite/perfschema/r/misc.result 2010-02-26 17:39:57 +0000
+++ b/mysql-test/suite/perfschema/r/misc.result 2010-04-07 08:53:19 +0000
@@ -25,3 +25,5 @@ drop table test.ghost;
select * from performance_schema.FILE_INSTANCES
where file_name like "%ghost%";
FILE_NAME EVENT_NAME OPEN_COUNT
+select * from performance_schema.no_such_table;
+ERROR 42S02: Table 'performance_schema.no_such_table' doesn't exist
=== modified file 'mysql-test/suite/perfschema/t/misc.test'
--- a/mysql-test/suite/perfschema/t/misc.test 2010-03-22 09:08:28 +0000
+++ b/mysql-test/suite/perfschema/t/misc.test 2010-04-07 08:53:19 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -11,7 +11,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Tests for PERFORMANCE_SCHEMA
# Miscelaneous
@@ -76,3 +76,10 @@ drop table test.ghost;
select * from performance_schema.FILE_INSTANCES
where file_name like "%ghost%";
+#
+# Bug#52586 Misleading error message on attempt to access
+# a P_S table using a wrong name
+
+--error ER_NO_SUCH_TABLE
+select * from performance_schema.no_such_table;
+
=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc 2010-02-24 17:04:00 +0000
+++ b/storage/perfschema/pfs_engine_table.cc 2010-04-07 08:53:19 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,7 +11,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
/**
@file storage/perfschema/pfs_engine_table.cc
@@ -463,7 +464,22 @@ PFS_unknown_acl pfs_unknown_acl;
ACL_internal_access_result
PFS_unknown_acl::check(ulong want_access, ulong *save_priv) const
{
- return ACL_INTERNAL_ACCESS_DENIED;
+ const ulong always_forbidden= INSERT_ACL | UPDATE_ACL | DELETE_ACL
+ | CREATE_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL
+ | CREATE_VIEW_ACL | TRIGGER_ACL | LOCK_TABLES_ACL;
+
+ if (unlikely(want_access & always_forbidden))
+ return ACL_INTERNAL_ACCESS_DENIED;
+
+ /*
+ There is no point in hidding (by enforcing ACCESS_DENIED for SELECT_ACL
+ on performance_schema.*) tables that do not exist anyway.
+ When SELECT_ACL is granted on performance_schema.* or *.*,
+ SELECT * from performance_schema.wrong_table
+ will fail with a more understandable ER_NO_SUCH_TABLE error,
+ instead of ER_TABLEACCESS_DENIED_ERROR.
+ */
+ return ACL_INTERNAL_ACCESS_CHECK_GRANT;
}
/**
Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100407085319-6jbe2zt152u73wyn.bundle