Bug #33908 code duplication in sql_acl.cc (my_bool acl_reload(THD *thd))
Submitted: 17 Jan 2008 20:50 Modified: 1 Jul 2011 6:32
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:5.1.23bk OS:Any
Assigned to: CPU Architecture:Any

[17 Jan 2008 20:50] Roland Bouman
Description:
In sql/sql_acl.cc, this fragment appears at lines 675-680

  if (thd->locked_tables)
  {					// Can't have locked tables here
    thd->lock=thd->locked_tables;
    thd->locked_tables=0;
    close_thread_tables(thd);
  }

The same code fragment appears isolated in sql_parse.cc, lines 89-97

static void unlock_locked_tables(THD *thd)
{
  if (thd->locked_tables)
  {
    thd->lock=thd->locked_tables;
    thd->locked_tables=0;			// Will be automatically closed
    close_thread_tables(thd);			// Free tables
  }
}

How to repeat:
see Description

Suggested fix:
Replace the fragment in sql/sql_acl.cc with a call to 

unlock_locked_tables(THD *thd)
[17 Jan 2008 20:53] Roland Bouman
In sql/sql_servers.cc, lines 224-229, there is another occurrence of this fragment that could  be replaced by the call to the function
[18 Jan 2008 5:42] Valeriy Kravchuk
Thank you for a problem report. Verified by code review.
[22 Jan 2008 23:06] Jim Winstead
Reassigning to the correct category/lead.
[1 Jul 2011 6:32] Dmitry Lenev
Hello!

Code duplication issue has been addressed during re-factoring which was made
as part of work on new metadata/transactional locking subsystem in 5.5
versions of server (in version 5.5.3 to be exact).

Since there is nothing to document I am simply closing this bug.

For the record links to relevant patches:

http://lists.mysql.com/commits/92942
http://lists.mysql.com/commits/92491
http://lists.mysql.com/commits/92123