Bug #13618 mysqldump --xml ommit comment on table field
Submitted: 29 Sep 2005 18:29 Modified: 29 Jan 2011 23:04
Reporter: Frédéric Hardy Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:4.1.14, 5.0.56, 5.1.28, 5.1.52 OS:Any (freebsd)
Assigned to: Nirbhay Choubey CPU Architecture:Any

[29 Sep 2005 18:29] Frédéric Hardy
Description:
mysqldump --xml ommit comment on table field

How to repeat:
create a table with comment on field.
Execute mysqldump <database> -a -u <user> -p --no-data --xml 

Suggested fix:
Append commend in <field />
[29 Sep 2005 18:56] Dean Ellis
I am unable to repeat this.  Look for the options element, with the Comment attribute, near the end of the dump.
[21 Oct 2008 20:41] Ben Krug
It seems this report may have been misunderstood.  Table-level comments are outputted, but not column-level comments.  I have a report of this in 5.0.56 and I have verified the behavior in 5.1.28.

mysqldump outputs column comments, unless you add --xml, then it won't, even if you also use --comments.

How to reproduce:

eg, create a table like:

create table comment_test (a int comment 'column comment') comment='table comment';

use mysqldump to see the comments, then add --xml and see the column-level comment disappear.
[5 May 2009 17:47] Jim Winstead
Bug #36917 is a duplicate of this bug.
[27 Oct 2010 15:14] Valeriy Kravchuk
Still happens:

macbook-pro:5.1 openxs$ bin/mysqldump -uroot test2
-- MySQL dump 10.13  Distrib 5.1.52, for apple-darwin9.6.0 (i386)
--
-- Host: localhost    Database: test2
-- ------------------------------------------------------
-- Server version	5.1.52-debug

/*!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 `comment_test`
--

DROP TABLE IF EXISTS `comment_test`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comment_test` (
  `a` int(11) DEFAULT NULL COMMENT 'column comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='table comment';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `comment_test`
--

LOCK TABLES `comment_test` WRITE;
/*!40000 ALTER TABLE `comment_test` DISABLE KEYS */;
/*!40000 ALTER TABLE `comment_test` 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-10-27 18:12:53
macbook-pro:5.1 openxs$ bin/mysqldump --xml -uroot test2
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test2">
	<table_structure name="comment_test">
		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
		<options Name="comment_test" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="0" Avg_row_length="0" Data_length="0" Max_data_length="1970324836974591" Index_length="1024" Data_free="0" Create_time="2010-10-27 15:12:42" Update_time="2010-10-27 15:12:42" Collation="latin1_swedish_ci" Create_options="" Comment="table comment" />
	</table_structure>
	<table_data name="comment_test">
	</table_data>
</database>
</mysqldump>
[14 Nov 2010 14:01] Nirbhay Choubey
Initial investigation shows that mysqldump uses 
"SHOW FIELDS FROM tab" to get information about
the fields in table tab. 

However, the above statement does not display other
informations such as 'Comment' by default, for that
we need to use 'FULL' keyword.

SHOW FIELDS FROM `comment_test`;
------->
 <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
 

SHOW FULL FIELDS FROM `comment_test`;
------>
 <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Privileges="select,insert,update,references" Comment="column comment" />
[30 Dec 2010 13:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/127718

3535 Nirbhay Choubey	2010-12-30
      Bug#13618 : mysqldump --xml omits comment on table field
      
      When mysqldump tries to dump information in xml format,
      the result does not contain field level comments.
      
      In order to retrieve various informations for a field/column,
      mysqldump currently uses 'show fields from <tab>' statement.
      The attributes returned by the statement lacks the information
      regarding field comments.
      
      Fixed by changing the query to one that probes I_S to retrieve
      required field informations, including the field comment.
     @ client/mysqldump.c
        Bug#13618 : mysqldump --xml omits comment on table field
        
        Replaced the 'show fields' command by a statement that
        queries I_S, in order to retrieve information on all the
        attributes that 'show fields' returns along-with an additional
        column_comment information.
     @ mysql-test/r/client_xml.result
        Result modifications for bug#13618.
     @ mysql-test/r/mysqldump.result
        Result modifications for bug#13618.
     @ mysql-test/t/mysqldump.test
        Added a testcase for bug#13618.
[14 Jan 2011 14:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128780

3552 Nirbhay Choubey	2011-01-14
      Bug#13618 : mysqldump --xml omits comment on table field
      
      When mysqldump tries to dump information in xml format,
      the result does not contain field level comments.
      
      In order to retrieve various informations for a field/column,
      mysqldump currently uses 'show fields from <tab>' statement.
      The attributes returned by the statement lacks the information
      regarding field comments.
      
      Fixed by changing the query to one that probes I_S to retrieve
      required field informations, including the field comment.
     @ client/mysqldump.c
        Bug#13618 : mysqldump --xml omits comment on table field.
        
        Replaced the 'show fields' command by a statement that
        queries I_S, in order to retrieve information on all the
        attributes that 'show fields' returns along-with an additional
        column_comment information.
     @ mysql-test/r/client_xml.result
        Result modifications for bug#13618.
     @ mysql-test/r/mysqldump.result
        Result modifications for bug#13618.
     @ mysql-test/t/mysqldump.test
        Added a testcase for bug#13618.
[14 Jan 2011 14:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128794

3248 Nirbhay Choubey	2011-01-14 [merge]
      Merging fix of Bug#13618 from mysql-5.1.
[14 Jan 2011 14:50] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128795

3510 Nirbhay Choubey	2011-01-14 [merge]
      Merging fix for Bug#13618 from mysql-5.5.
[14 Jan 2011 14:52] Bugs System
Pushed into mysql-5.1 5.1.56 (revid:nirbhay.choubey@sun.com-20110114142034-6xi85qdu54cysf7q) (version source revid:nirbhay.choubey@sun.com-20110114142034-6xi85qdu54cysf7q) (merge vers: 5.1.56) (pib:24)
[14 Jan 2011 14:53] Bugs System
Pushed into mysql-5.5 5.5.10 (revid:nirbhay.choubey@sun.com-20110114144100-p1054vg2ise9hggu) (version source revid:nirbhay.choubey@sun.com-20110114144100-p1054vg2ise9hggu) (merge vers: 5.5.10) (pib:24)
[14 Jan 2011 14:54] Bugs System
Pushed into mysql-trunk 5.6.2 (revid:nirbhay.choubey@sun.com-20110114144916-evvenid3zst4gv18) (version source revid:nirbhay.choubey@sun.com-20110114144916-evvenid3zst4gv18) (merge vers: 5.6.2) (pib:24)
[19 Jan 2011 1:10] Paul DuBois
Noted in 5.1.56, 5.5.10, 5.6.2 changelogs.

mysqldump --xml now displays comments from column definitions.