Bug #55824 Option or compatibility mode for mysqldump to NOT quote decimal values
Submitted: 8 Aug 2010 16:40 Modified: 16 Dec 2010 8:34
Reporter: Valeriy Kravchuk Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:5.1+ OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any
Tags: mysqldump, regression

[8 Aug 2010 16:40] Valeriy Kravchuk
Description:
mysqldump (in any existing compatibility mode) dumps values of DECIMAL column quoted, like this:

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqldump --skip-extended-insert -ur
oot -proot -P3310 test tdec
-- MySQL dump 10.13  Distrib 5.1.48, for Win32 (ia32)
--
-- Host: localhost    Database: test
-- ------------------------------------------------------
-- Server version       5.1.48-community

/*!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 */;

--
-- Table structure for table `tdec`
--

DROP TABLE IF EXISTS `tdec`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tdec` (
  `c1` int(11) DEFAULT NULL,
  `c2` decimal(6,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `tdec`
--

LOCK TABLES `tdec` WRITE;
/*!40000 ALTER TABLE `tdec` DISABLE KEYS */;
INSERT INTO `tdec` VALUES (1,'6000.25');
INSERT INTO `tdec` VALUES (2,'123.45');
/*!40000 ALTER TABLE `tdec` ENABLE KEYS */;
UNLOCK TABLES;
/*!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 */;

-- Dump completed on 2010-08-08 18:44:00

This may lead to problems when execution SQL generated on other systems, like Sybase.

Note also that quotes are NOT used for DOUBLE values (see bug #44995 also).

By the way, similar bug #3361 had a patch, and is claimed to be fixed since long time ago. This is NOT the case though.

How to repeat:
Try to get INSERTs generated with DECIMAL data NOT quoted.

Suggested fix:
Add option to control quoting for DECIMAL (and DOUBLE) values. Or, maybe, add some compatibility mode (like SYBASE) that will control this.
[15 Dec 2010 19:30] Peter Gulutzan
In an earlier private comment I said this doesn't
happen in 5.5. That's technically true, but the
relevant code in mysqldump is:
  if (field->type == MYSQL_TYPE_DECIMAL)
  {
    /* add " signs around */
    dynstr_append_checked(&extended_row, "'");
    dynstr_append_checked(&extended_row, ptr);
    dynstr_append_checked(&extended_row, "'");
    }
  else
    dynstr_append_checked(&extended_row, ptr);
and in this recently-created table
field->type is not MYSQL_TYPE_DECIMAL,
it is MYSQL_TYPE_NEWDECIMAL.

Two possibly related bugs.mysql.com items are:
Bug#2005 Long decimal comparison bug
 (this might be the reason for the ''s).
Bug#58878 UPDATE fails when DECIMAL column value is quoted
 (this might be due to qt3 adding quotes as mysqldump does).
[16 Dec 2010 8:34] Georgi Kodinov
FIxed by the fix for bug #42980