List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:July 13 2006 11:25pm
Subject:bk commit into 5.0 tree (tnurnberg:1.2234) BUG#21014
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of tnurnberg. When tnurnberg 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, 2006-07-14 01:25:13+02:00, tnurnberg@stripped +3 -0
  Bug#21014: Segmentation fault of mysqldump on view
  
  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.

  client/mysqldump.c@stripped, 2006-07-14 01:25:06+02:00, tnurnberg@stripped +9 -2
    Bug#21014: Segmentation fault of mysqldump on view
    
    failsafe: if "select ... from information_schema.views" returns an
    empty set, don't deref NULL; throw an error instead.
    
    fix: select the correct database not only before dumping tables, but
    before dumping views, as well.

  mysql-test/r/mysqldump.result@stripped, 2006-07-14 01:25:06+02:00, tnurnberg@stripped +61 -0
    Bug#21014: Segmentation fault of mysqldump on view
    
    show that mysqldump selects the correct database before trying to dump
    views from it.

  mysql-test/t/mysqldump.test@stripped, 2006-07-14 01:25:06+02:00, tnurnberg@stripped +18 -0
    Bug#21014: Segmentation fault of mysqldump on view
    
    show that mysqldump selects the correct database before trying to dump
    views from it.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tnurnberg
# Host:	salvation.intern.azundris.com
# Root:	/home/tnurnberg/work/mysql-5.0-21014

--- 1.232/client/mysqldump.c	2006-07-14 01:25:20 +02:00
+++ 1.233/client/mysqldump.c	2006-07-14 01:25:20 +02:00
@@ -2781,6 +2781,12 @@
   uint numrows;
   char table_buff[NAME_LEN*2+3];
 
+  if (mysql_select_db(sock, database))
+  {
+    DB_error(sock, "when selecting the database");
+    return 1;
+  }
+
   if (opt_xml)
     print_xml_tag1(md_result_file, "", "database name=", database, "\n");
   if (lock_tables)
@@ -3436,12 +3442,13 @@
     mysql_free_result(table_res);
 
     /* Get the result from "select ... information_schema" */
-    if (!(table_res= mysql_store_result(sock)))
+    if (!(table_res= mysql_store_result(sock)) ||
+        !(row= mysql_fetch_row(table_res)))
     {
       safe_exit(EX_MYSQLERR);
       DBUG_RETURN(1);
     }
-    row= mysql_fetch_row(table_res);
+
     lengths= mysql_fetch_lengths(table_res);
 
     /*

--- 1.100/mysql-test/r/mysqldump.result	2006-07-14 01:25:20 +02:00
+++ 1.101/mysql-test/r/mysqldump.result	2006-07-14 01:25:20 +02:00
@@ -2844,3 +2844,64 @@
 drop view v1;
 drop table t1;
 drop database mysqldump_test_db;
+create database mysqldump_tables;
+use mysqldump_tables;
+create table basetable ( id serial, tag varchar(64) );
+create database mysqldump_views;
+use mysqldump_views;
+create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
+
+/*!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 */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 */;
+
+USE `mysqldump_tables`;
+DROP TABLE IF EXISTS `basetable`;
+CREATE TABLE `basetable` (
+  `id` bigint(20) unsigned NOT NULL auto_increment,
+  `tag` varchar(64) default NULL,
+  UNIQUE KEY `id` (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+
+/*!40000 ALTER TABLE `basetable` DISABLE KEYS */;
+LOCK TABLES `basetable` WRITE;
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `basetable` ENABLE KEYS */;
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_views` /*!40100 DEFAULT CHARACTER SET latin1 */;
+
+USE `mysqldump_views`;
+DROP TABLE IF EXISTS `nasishnasifu`;
+/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
+/*!50001 CREATE TABLE `nasishnasifu` (
+  `id` bigint(20) unsigned
+) */;
+/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/;
+/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+drop view nasishnasifu;
+drop database mysqldump_views;
+drop table mysqldump_tables.basetable;
+drop database mysqldump_tables;

--- 1.95/mysql-test/t/mysqldump.test	2006-07-14 01:25:20 +02:00
+++ 1.96/mysql-test/t/mysqldump.test	2006-07-14 01:25:20 +02:00
@@ -1194,6 +1194,7 @@
 --exec $MYSQL_DUMP --force -N --compact --skip-comments test
 --echo } mysqldump
 drop view v1;
+
 # BUG#17201 Spurious 'DROP DATABASE' in output,
 # also confusion between tables and views.
 # Example code from Markus Popp
@@ -1210,3 +1211,20 @@
 drop view v1;
 drop table t1;
 drop database mysqldump_test_db;
+
+# Bug21014 Segmentation fault of mysqldump on view
+
+create database mysqldump_tables;
+use mysqldump_tables;
+create table basetable ( id serial, tag varchar(64) );
+
+create database mysqldump_views;
+use mysqldump_views;
+create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
+
+--exec $MYSQL_DUMP --skip-comments --databases mysqldump_tables mysqldump_views;
+
+drop view nasishnasifu;
+drop database mysqldump_views;
+drop table mysqldump_tables.basetable;
+drop database mysqldump_tables;
Thread
bk commit into 5.0 tree (tnurnberg:1.2234) BUG#21014Tatjana A Nuernberg14 Jul