From 7b3d8cc93f3eaede9fc93e2cc8a2b2327b82584d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Dec 2003 17:33:29 +0400 Subject: [PATCH 1/2] Fix for the bugs: #2005 Long decimal comparion bug. #2055 mysqldump should replace "-inf" numeric field values with "NULL" --- client/mysqldump.c | 34 +++++++++++++++++++++++++++++----- mysql-test/t/mysqldump.test | 19 +++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 40f88021c89..7092503fa25 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1067,10 +1067,22 @@ static void dumpTable(uint numFields, char *table) } else { - /* change any strings ("inf","nan",..) into NULL */ + /* change any strings ("inf", "-inf", "nan") into NULL */ char *ptr = row[i]; - dynstr_append(&extended_row, - (!isalpha(*ptr)) ? ptr : "NULL"); + if (isalpha(*ptr) || (*ptr == '-' && *(ptr+1) == 'i')) + dynstr_append(&extended_row, "NULL"); + else + { + if (field->type == FIELD_TYPE_DECIMAL) + { + /* add " signs around */ + dynstr_append(&extended_row, "\""); + dynstr_append(&extended_row, ptr); + dynstr_append(&extended_row, "\""); + } + else + dynstr_append(&extended_row, ptr); + } } } else @@ -1098,13 +1110,25 @@ static void dumpTable(uint numFields, char *table) } else { - /* change any strings ("inf","nan",..) into NULL */ + /* change any strings ("inf", "-inf", "nan") into NULL */ char *ptr = row[i]; if (opt_xml) fprintf(md_result_file, "\t\t%s\n", field->name,!isalpha(*ptr) ?ptr: "NULL"); + else if (isalpha(*ptr) || (*ptr == '-' && *(ptr+1) == 'i')) + fputs("NULL", md_result_file); else - fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file); + { + if (field->type == FIELD_TYPE_DECIMAL) + { + /* add " signs around */ + fputs("\"", md_result_file); + fputs(ptr, md_result_file); + fputs("\"", md_result_file); + } + else + fputs(ptr, md_result_file); + } } } else diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index c98fd4050f2..87363855db0 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -8,3 +8,22 @@ CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); --exec $MYSQL_DUMP -X test t1 DROP TABLE t1; + +# +# Bug #2005 +# + +CREATE TABLE t1 (a decimal(240, 20)); +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), +("0987654321098765432109876543210987654321"); +--exec $MYSQL_DUMP test t1 +DROP TABLE t1; + +# +# Bug #2055 +# + +CREATE TABLE t1 (a double); +INSERT INTO t1 VALUES (-9e999999); +--exec $MYSQL_DUMP test t1 +DROP TABLE t1; From 568d3a5d231cd9e3816d91bd40ae70845e7e8e64 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Dec 2003 18:41:13 +0400 Subject: [PATCH 2/2] proper musqldump test result (in addition to CS 1.1623 03/12/09) --- mysql-test/r/mysqldump.result | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 085cf2788f9..01edd10b896 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -15,3 +15,51 @@ INSERT INTO t1 VALUES (1), (2); DROP TABLE t1; +CREATE TABLE t1 (a decimal(240, 20)); +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), +("0987654321098765432109876543210987654321"); +-- MySQL dump 9.09 +-- +-- Host: localhost Database: test +-- ------------------------------------------------------ +-- Server version 4.0.17-debug-log + +-- +-- Table structure for table `t1` +-- + +CREATE TABLE t1 ( + a decimal(240,20) default NULL +) TYPE=MyISAM; + +-- +-- Dumping data for table `t1` +-- + +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890.00000000000000000000"); +INSERT INTO t1 VALUES ("0987654321098765432109876543210987654321.00000000000000000000"); + +DROP TABLE t1; +CREATE TABLE t1 (a double); +INSERT INTO t1 VALUES (-9e999999); +-- MySQL dump 9.09 +-- +-- Host: localhost Database: test +-- ------------------------------------------------------ +-- Server version 4.0.17-debug-log + +-- +-- Table structure for table `t1` +-- + +CREATE TABLE t1 ( + a double default NULL +) TYPE=MyISAM; + +-- +-- Dumping data for table `t1` +-- + +INSERT INTO t1 VALUES (NULL); + +DROP TABLE t1;