Bug #27293 mysqldump crashes when dumping procedure defined by different user
Submitted: 20 Mar 2007 14:53 Modified: 4 May 2007 18:10
Reporter: Giuseppe Maxia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S2 (Serious)
Version:5.0.37, 5.1.17 OS:Linux (Linux, Mac OS X)
Assigned to: Tatiana Azundris Nuernberg CPU Architecture:Any
Tags: Backup, FUNCTION, grant, mysqldump, privileges, PROCEDURE, routine

[20 Mar 2007 14:53] Giuseppe Maxia
Description:
When a user dumps a database containing a routine created by a different user, mysqldump crashes.

Let's assume two users, with the same privileges on a database.
For example, user1 creates a procedure

CREATE PROCEDURE p1() SELECT 'HELLO';

Then, user2 dumps the database

$ mysqldump -u user2 --routines db_name
Segmentation Fault

This bug may be related to Bug#26817.

How to repeat:
# see also the complete test and result file attached
# 
# mysqldump crashes when dumping routines
# defined by a different user
#

# Embedded server doesn't support external clients
--source include/not_embedded.inc

--disable_warnings
drop schema if exists my_dump_test;
--enable_warnings

--echo # creating a test database
create schema my_dump_test;

--echo # creating two users with the same privileges
grant all privileges on my_dump_test.*  to user1 ;
grant all privileges on my_dump_test.*  to user2 ;

--echo # user1 creates a routine
connect (user1,127.0.0.1,user1,,my_dump_test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user1;

create procedure my_dump_test.p1() select 'hello';

--echo # user2 dumps the routine
--exec $MYSQL_DUMP  --user=user2 --password=  -h 127.0.0.1 -P $MASTER_MYPORT --routines my_dump_test | grep p1

--echo # cleaning up
connection default;
drop user user1;
drop user user2;
drop schema my_dump_test;
[20 Mar 2007 14:54] Giuseppe Maxia
test case for Bug#27293

Attachment: mysqldump_routines.tar.gz (application/x-tar, text), 700 bytes.

[26 Apr 2007 12:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25508

ChangeSet@1.2468, 2007-04-26 14:26:54+02:00, tnurnberg@mysql.com +3 -0
  Bug#27293: mysqldump crashes when dumping procedure defined by different user
  
  mysqldump didn't properly handle getting no data on
  SHOW CREATE PROCEDURE.  If S/C/P fails (due to dumping
  user's insufficient privileges on mysql.proc, say),
  mysqldump will print a comment to that effect to the
  output and return an error-code.  If the -f (force) option
  is used, the dump will continue, otherwise, it will abort
  right there and then.
  
  Also fixes Bug#22761, "mysqldump reports no errors when using
  --routines without mysql.proc privileges"
[30 Apr 2007 7:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25728

ChangeSet@1.2468, 2007-04-30 09:26:46+02:00, tnurnberg@mysql.com +3 -0
  Bug#27293: mysqldump crashes when dumping procedure defined by different user
  
  mysqldump didn't properly handle getting no data on
  SHOW CREATE PROCEDURE.  If S/C/P fails (due to dumping
  user's insufficient privileges on mysql.proc, say),
  mysqldump will print a comment to that effect to the
  output and return an error-code.  If the -f (force) option
  is used, the dump will continue, otherwise, it will abort
  right there and then.
  
  Also fixes Bug#22761, "mysqldump reports no errors when using
  --routines without mysql.proc privileges"
[30 Apr 2007 7:47] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25733

ChangeSet@1.2458, 2007-04-30 09:47:39+02:00, tnurnberg@mysql.com +3 -0
  Bug#27293: mysqldump crashes when dumping procedure defined by different user
  
  mysqldump didn't properly handle getting no data on
  SHOW CREATE PROCEDURE.  If S/C/P fails (due to dumping
  user's insufficient privileges on mysql.proc, say),
  mysqldump will print a comment to that effect to the
  output and return an error-code.  If the -f (force) option
  is used, the dump will continue, otherwise, it will abort
  right there and then.
  
  Also fixes Bug#22761, "mysqldump reports no errors when using
  --routines without mysql.proc privileges"
  ---
  Merge mysql.com:/home/tnurnberg/27293/50-27293
  into  mysql.com:/home/tnurnberg/27293/51-27293
[30 Apr 2007 9:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25739

ChangeSet@1.2466, 2007-04-30 11:30:07+02:00, tnurnberg@mysql.com +3 -0
  Bug#27293: mysqldump crashes when dumping procedure defined by different user
  
  mysqldump didn't properly handle getting no data on
  SHOW CREATE PROCEDURE.  If S/C/P fails (due to dumping
  user's insufficient privileges on mysql.proc, say),
  mysqldump will print a comment to that effect to the
  output and return an error-code.  If the -f (force) option
  is used, the dump will continue, otherwise, it will abort
  right there and then.
  
  Also fixes Bug#22761, "mysqldump reports no errors when using
  --routines without mysql.proc privileges"
  ---
  Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.0-maint
  into  mysql.com:/home/tnurnberg/27293/50-27293
[30 Apr 2007 10:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25746

ChangeSet@1.2493, 2007-04-30 12:12:44+02:00, tnurnberg@mysql.com +3 -0
  Bug#27293: mysqldump crashes when dumping procedure defined by different user
  
  mysqldump didn't properly handle getting no data on
  SHOW CREATE PROCEDURE.  If S/C/P fails (due to dumping
  user's insufficient privileges on mysql.proc, say),
  mysqldump will print a comment to that effect to the
  output and return an error-code.  If the -f (force) option
  is used, the dump will continue, otherwise, it will abort
  right there and then.
  
  Also fixes Bug#22761, "mysqldump reports no errors when using
  --routines without mysql.proc privileges"
  ---
  Merge mysql.com:/home/tnurnberg/27293/50-27293
  into  mysql.com:/home/tnurnberg/27293/51-27293
  ---
  Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-maint
  into  mysql.com:/home/tnurnberg/27293/51-27293
[30 Apr 2007 10:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25747

ChangeSet@1.2493, 2007-04-30 12:32:57+02:00, tnurnberg@mysql.com +3 -0
  Bug#27293: mysqldump crashes when dumping procedure defined by different user
  
  mysqldump didn't properly handle getting no data on
  SHOW CREATE PROCEDURE.  If S/C/P fails (due to dumping
  user's insufficient privileges on mysql.proc, say),
  mysqldump will print a comment to that effect to the
  output and return an error-code.  If the -f (force) option
  is used, the dump will continue, otherwise, it will abort
  right there and then.
  
  Also fixes Bug#22761, "mysqldump reports no errors when using
  --routines without mysql.proc privileges"
  ---
  Merge mysql.com:/home/tnurnberg/27293/50-27293
  into  mysql.com:/home/tnurnberg/27293/51-27293
  ---
  Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-maint
  into  mysql.com:/home/tnurnberg/27293/51-27293
[1 May 2007 20:58] Bugs System
Pushed into 5.1.18-beta
[1 May 2007 20:59] Bugs System
Pushed into 5.0.42
[4 May 2007 18:10] Paul Dubois
Noted in 5.0.42, 5.1.18 changelogs.

mysqldump crashed if it got no data from SHOW CREATE PROCEDURE (for
example, when trying to dump a routine defined by a different user
and for which the current user had no privileges). Now it prints a
comment to indicate the problem. It also returns an error, or
continues if the --force option is given.