MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:August 17 2006 9:09pm
Subject:bk commit into 4.1 tree (jimw:1.2538) BUG#21288
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jimw. When jimw 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-08-17 14:09:24-07:00, jimw@rama.(none) +3 -0
  Bug #21288: mysqldump segmentation fault when using --where
  
    The problem was that the error handling was using a too-small buffer to
    print the error message generated. We fix this by not using a buffer at
    all, but by using fprintf() directly. There were also some problems with
    the error handling in table dumping that was exposed by this fix that were
    also corrected.

  client/mysqldump.c@stripped, 2006-08-17 14:09:23-07:00, jimw@rama.(none) +11 -5
    Use fprintf() instead of my_printf_error() to avoid buffer overflow issues.
    Since ME_BELL wasn't specified, calling my_printf_error() offered no advantage
    except for adding my_progname, which we just go ahead and do manually. Also,
    fix the error handling in dumpTable() when queries to get data fail and --force
    was specified.

  mysql-test/r/mysqldump.result@stripped, 2006-08-17 14:09:23-07:00, jimw@rama.(none) +27 -0
    Add new results

  mysql-test/t/mysqldump.test@stripped, 2006-08-17 14:09:23-07:00, jimw@rama.(none) +8 -0
    Add new regression test

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-4.1-21288

--- 1.201/client/mysqldump.c	2006-08-17 14:09:28 -07:00
+++ 1.202/client/mysqldump.c	2006-08-17 14:09:28 -07:00
@@ -783,8 +783,8 @@ static int get_options(int *argc, char *
 static void DBerror(MYSQL *mysql, const char *when)
 {
   DBUG_ENTER("DBerror");
-  my_printf_error(0,"Got error: %d: %s %s", MYF(0),
-		  mysql_errno(mysql), mysql_error(mysql), when);
+  fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname,
+          mysql_errno(mysql), mysql_error(mysql), when);
   safe_exit(EX_MYSQLERR);
   DBUG_VOID_RETURN;
 } /* DBerror */
@@ -811,9 +811,9 @@ static int mysql_query_with_error_report
   if (mysql_query(mysql_con, query) ||
       (res && !((*res)= mysql_store_result(mysql_con))))
   {
-    my_printf_error(0, "%s: Couldn't execute '%s': %s (%d)",
-                    MYF(0), my_progname, query,
-                    mysql_error(mysql_con), mysql_errno(mysql_con));
+    fprintf(stderr, "%s: Couldn't execute '%s': %s (%d)\n",
+            my_progname, query,
+            mysql_error(mysql_con), mysql_errno(mysql_con));
     return 1;
   }
   return 0;
@@ -1705,13 +1705,19 @@ static void dumpTable(uint numFields, ch
       check_io(md_result_file);
     }
     if (mysql_query_with_error_report(sock, 0, query))
+    {
       DBerror(sock, "when retrieving data from server");
+      goto err;
+    }
     if (quick)
       res=mysql_use_result(sock);
     else
       res=mysql_store_result(sock);
     if (!res)
+    {
       DBerror(sock, "when retrieving data from server");
+      goto err;
+    }
     if (verbose)
       fprintf(stderr, "-- Retrieving rows...\n");
     if (mysql_num_fields(res) != numFields)

--- 1.54/mysql-test/r/mysqldump.result	2006-08-17 14:09:28 -07:00
+++ 1.55/mysql-test/r/mysqldump.result	2006-08-17 14:09:28 -07:00
@@ -1557,4 +1557,31 @@ CREATE TABLE `t2` (
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
 drop table t1, t2, t3;
+create table t1 (a int);
+mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064)
+mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server
+
+/*!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 */;
+/*!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 */;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+  `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+
+/*!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 table t1;
 End of 4.1 tests

--- 1.45/mysql-test/t/mysqldump.test	2006-08-17 14:09:28 -07:00
+++ 1.46/mysql-test/t/mysqldump.test	2006-08-17 14:09:28 -07:00
@@ -694,4 +694,12 @@ create table t3(a int);
 --exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
 drop table t1, t2, t3;
 
+#
+# Bug #21288: mysqldump segmentation fault when using --where
+#
+create table t1 (a int);
+--error 2
+--exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1
+drop table t1;
+
 --echo End of 4.1 tests
Thread
bk commit into 4.1 tree (jimw:1.2538) BUG#21288Jim Winstead17 Aug