Bug #21014 Segmentation fault of mysqldump on view
Submitted: 12 Jul 2006 19:46 Modified: 4 Aug 2006 19:34
Reporter: Beat Vontobel (Silver Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S1 (Critical)
Version:5.0.25-BK, 5.0.23,5.1 OS:Linux (Linux)
Assigned to: Tatiana Azundris Nuernberg CPU Architecture:Any

[12 Jul 2006 19:46] Beat Vontobel
Description:
While trying to dump a test case for bug bug #20989 I hit a segmentation fault in mysqldump introduced in version 5.0.23. Use setup.sql from bug #20989 (also attached to this bug) to set up the databases/tables and try to dump it again with mysqldump from 5.0.23, it will crash.

How to repeat:
mysql1:~ # mysql < setup.sql
mysql1:~ # mysqldump --databases s ms
-- MySQL dump 10.10
--
[...snip...]
--
-- Final view structure for view `stationen`
--

/*!50001 DROP TABLE IF EXISTS `stationen`*/;
/*!50001 DROP VIEW IF EXISTS `stationen`*/;
Segmentation fault

Suggested fix:
Double check the bugfixes introduced in 5.0.23 regarding the dump of views...
[12 Jul 2006 20:01] Valeriy Kravchuk
Thank you for a bug report. Verified just as described, with your test case uploaded, with 5.0.25-BK on Linux:

openxs@suse:~/dbs/5.0> bin/mysql -uroot < /tmp/setup.sql
openxs@suse:~/dbs/5.0> bin/mysqldump -uroot --databases s ms
-- MySQL dump 10.10
--
-- Host: localhost    Database: s
-- ------------------------------------------------------
-- Server version       5.0.25

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
...

--
-- Final view structure for view `stationen`
--

/*!50001 DROP TABLE IF EXISTS `stationen`*/;
/*!50001 DROP VIEW IF EXISTS `stationen`*/;
Segmentation fault
openxs@suse:~/dbs/5.0>
[13 Jul 2006 23:25] 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/9153
[13 Jul 2006 23:35] Timothy Smith
Patch looks good.  Thanks for being proactive about the seg fault.
[14 Jul 2006 1:54] Tatiana Azundris Nuernberg
fixed in 5.0.25.

mysqldump did not select the correct database before trying to dump views from it. this resulted in an empty result set, which in turn startled mysql-dump into a core-dump. this only happened for views, not for tables, and was only visible with multiple databases that weren't by sheer luck in the order mysqldump required, anyway. this fixes by selecting the correct database before dumping views; it also catches the empty set-condition if it should occur for other reasons.
[14 Jul 2006 13:11] Tatiana Azundris Nuernberg
also pushed to 5.0-release (5.0.24)
[4 Aug 2006 19:34] Paul DuBois
Noted in 5.1.12 changelog.