diff --git a/client/mysqldump.c b/client/mysqldump.c index 4aec31c8ff2..42b094d2902 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1116,9 +1116,9 @@ static void dumpTable(uint numFields, char *table) if (field->type == FIELD_TYPE_DECIMAL) { /* add " signs around */ - dynstr_append(&extended_row, "\""); + dynstr_append(&extended_row, "\'"); dynstr_append(&extended_row, ptr); - dynstr_append(&extended_row, "\""); + dynstr_append(&extended_row, "\'"); } else dynstr_append(&extended_row, ptr); @@ -1162,9 +1162,9 @@ static void dumpTable(uint numFields, char *table) if (field->type == FIELD_TYPE_DECIMAL) { /* add " signs around */ - fputs("\"", md_result_file); + fputs("\'", md_result_file); fputs(ptr, md_result_file); - fputs("\"", md_result_file); + fputs("\'", md_result_file); } else fputs(ptr, md_result_file); diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 837a3627647..714cb42af5e 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -22,8 +22,8 @@ CREATE TABLE t1 ( a decimal(240,20) default NULL ) TYPE=MyISAM; -INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890.00000000000000000000"); -INSERT INTO t1 VALUES ("0987654321098765432109876543210987654321.00000000000000000000"); +INSERT INTO t1 VALUES ('1234567890123456789012345678901234567890.00000000000000000000'); +INSERT INTO t1 VALUES ('0987654321098765432109876543210987654321.00000000000000000000'); DROP TABLE t1; CREATE TABLE t1 (a double); @@ -35,3 +35,17 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (RES); DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT); +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +CREATE TABLE t1 ( + a decimal(10,5) default NULL, + b float default NULL +) TYPE=MyISAM; + +INSERT INTO t1 VALUES ('1.23450',2.3456); +INSERT INTO t1 VALUES ('1.23450',2.3456); +INSERT INTO t1 VALUES ('1.23450',2.3456); + +DROP TABLE t1; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index bc63dc37d96..d1394e40a49 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -30,3 +30,31 @@ INSERT INTO t1 VALUES (-9e999999); --replace_result (-1.79769313486232e+308) (RES) (NULL) (RES) --exec $MYSQL_DUMP --skip-comments test t1 DROP TABLE t1; + +# +# Bug #3361 mysqldum quotes DECIMAL values +# + +CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT); + +# check at first how mysql work with quoted decimal + +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); + +# The code below should be uncommented in mysql-4.1 to fix +# behaviour of quoting DECIMAL fields with different +# values of sql_mode +######## +#SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES'; +#INSERT INTO t1 VALUES (1.2345, 2.3456); +#INSERT INTO t1 VALUES ('1.2345', 2.3456); +#--error 1054 +#INSERT INTO t1 VALUES ("1.2345", 2.3456); +#SET SQL_MODE=@OLD_SQL_MODE; +######## + +# check how mysqldump make quoting +--exec $MYSQL_DUMP --skip-comments test t1 +DROP TABLE t1;