List:Commits« Previous MessageNext Message »
From:Nirbhay Choubey Date:December 30 2010 1:47pm
Subject:bzr commit into mysql-5.1-bugteam branch (nirbhay.choubey:3535)
Bug#13618
View as plain text  
#At file:///home/nirbhay/Project/mysql/repo/bugs/mysql-5.1-bugteam.13618/ based on revid:sergey.glukhov@stripped

 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.

    modified:
      client/mysqldump.c
      mysql-test/r/client_xml.result
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-06-10 20:16:43 +0000
+++ b/client/mysqldump.c	2010-12-30 13:47:51 +0000
@@ -2247,6 +2247,15 @@ static uint get_table_structure(char *ta
   const char *insert_option;
   char	     name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
   char       table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
+  const char *show_fields_stmt = "SELECT `COLUMN_NAME` AS `Field`, "
+                                 "`COLUMN_TYPE` AS `Type`, "
+                                 "`IS_NULLABLE` AS `Null`, "
+                                 "`COLUMN_KEY` AS `Key`, "
+                                 "`COLUMN_DEFAULT` AS `Default`, "
+                                 "`EXTRA` AS `Extra`, "
+                                 "`COLUMN_COMMENT` AS `Comment` "
+                                 "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE "
+                                 "TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
   FILE       *sql_file= md_result_file;
   int        len;
   MYSQL_RES  *result;
@@ -2514,8 +2523,7 @@ static uint get_table_structure(char *ta
     verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
                 my_progname, mysql_error(mysql));
 
-    my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
-                result_table);
+    my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
     if (mysql_query_with_error_report(mysql, &result, query_buff))
       DBUG_RETURN(0);
 

=== modified file 'mysql-test/r/client_xml.result'
--- a/mysql-test/r/client_xml.result	2008-07-18 12:00:45 +0000
+++ b/mysql-test/r/client_xml.result	2010-12-30 13:47:51 +0000
@@ -21,9 +21,9 @@ insert into t1 values (1, 2, 'a&b a<b a>
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" />
-		<field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" />
-		<field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" />
+		<field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2010-05-06 20:41:37 +0000
+++ b/mysql-test/r/mysqldump.result	2010-12-30 13:47:51 +0000
@@ -14,7 +14,7 @@ INSERT INTO t1 VALUES (1), (2);
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="MUL" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="MUL" Extra="" Comment="" />
 		<key Table="t1" Non_unique="1" Key_name="a" Seq_in_index="1" Column_name="a" Collation="A" Null="YES" Index_type="BTREE" Comment="" />
 	</table_structure>
 	<table_data name="t1">
@@ -150,9 +150,9 @@ INSERT INTO t1 VALUES (1, "test", "tes")
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
-		<field Field="b" Type="text" Null="YES" Key="" Extra="" />
-		<field Field="c" Type="varchar(3)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="b" Type="text" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="c" Type="varchar(3)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>
@@ -178,7 +178,7 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" />
+		<field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>
@@ -1612,10 +1612,10 @@ CREATE TABLE `t2` (
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="mysqldump_test_db">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_structure name="t2">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 </database>
 </mysqldump>
@@ -1623,10 +1623,10 @@ CREATE TABLE `t2` (
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="mysqldump_test_db">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_structure name="t2">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 </database>
 </mysqldump>
@@ -3644,8 +3644,8 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" />
-		<field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" />
+		<field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>
@@ -4576,5 +4576,20 @@ LENGTH(a)
 800
 DROP TABLE t1, t2;
 #
+# Bug #13618 : mysqldump --xml ommit comment on table field
+#
+CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="test">
+	<table_structure name="comment_table">
+		<field Field="i" Type="int(11)" Null="YES" Key="" Extra="" Comment="FIELD COMMENT" />
+	</table_structure>
+	<table_data name="comment_table">
+	</table_data>
+</database>
+</mysqldump>
+DROP TABLE `comment_table`;
+#
 # End of 5.1 tests
 #

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2010-05-20 15:38:01 +0000
+++ b/mysql-test/t/mysqldump.test	2010-12-30 13:47:51 +0000
@@ -2164,6 +2164,15 @@ SELECT LENGTH(a) FROM t2;
 DROP TABLE t1, t2;
 
 ###########################################################################
+
+--echo #
+--echo # Bug #13618 : mysqldump --xml ommit comment on table field
+--echo #
+
+CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
+--exec $MYSQL_DUMP --compact --skip-create --xml test
+DROP TABLE `comment_table`;
+
 --echo #
 --echo # End of 5.1 tests
 --echo #


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-bugteam branch (nirbhay.choubey:3535)Bug#13618Nirbhay Choubey30 Dec