MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:holyfoot Date:June 2 2006 1:05pm
Subject:bk commit into 5.1 tree (holyfoot:1.2178) BUG#16614
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2178 06/06/02 18:04:50 holyfoot@deer.(none) +5 -0
  bug #16614 SHOW CREATE TABLE doesn't show constraints for innodb.
  
  In fact constraints aren't created properly as innodb fails altering
  tables with spaces in their names. Fixed adding tablename conversion to
  innodb code

  storage/innobase/dict/dict0dict.c
    1.82 06/06/02 18:02:51 holyfoot@stripped +6 -1
    we get not encoded table name here from the query
    so have to code it properly with tablename_to_filename

  sql/sql_table.cc
    1.336 06/06/02 18:02:51 holyfoot@stripped +2 -0
    tablename_to_filename is to be exported in plain C code

  sql/mysql_priv.h
    1.406 06/06/02 18:02:51 holyfoot@stripped +2 -0
    tablename_to_filename is to be exported in plain C code

  mysql-test/t/innodb.test
    1.147 06/06/02 18:02:51 holyfoot@stripped +9 -1
    test case added

  mysql-test/r/innodb.result
    1.178 06/06/02 18:02:51 holyfoot@stripped +12 -1
    test result

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.1.16614

--- 1.405/sql/mysql_priv.h	Sat May 27 10:05:13 2006
+++ 1.406/sql/mysql_priv.h	Fri Jun  2 18:02:51 2006
@@ -1797,7 +1797,9 @@
 uint strconvert(CHARSET_INFO *from_cs, const char *from,
                 CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
 uint filename_to_tablename(const char *from, char *to, uint to_length);
+C_MODE_START
 uint tablename_to_filename(const char *from, char *to, uint to_length);
+C_MODE_END
 uint build_table_filename(char *buff, size_t bufflen, const char *db,
                           const char *table, const char *ext);
 /* from hostname.cc */

--- 1.335/sql/sql_table.cc	Thu May 18 20:23:30 2006
+++ 1.336/sql/sql_table.cc	Fri Jun  2 18:02:51 2006
@@ -70,6 +70,7 @@
 }
 
 
+C_MODE_START
 uint tablename_to_filename(const char *from, char *to, uint to_length)
 {
   uint errors, length;
@@ -86,6 +87,7 @@
   }
   return length;
 }
+C_MODE_END
 
 
 /*

--- 1.81/storage/innobase/dict/dict0dict.c	Wed Apr 26 09:30:31 2006
+++ 1.82/storage/innobase/dict/dict0dict.c	Fri Jun  2 18:02:51 2006
@@ -2561,6 +2561,8 @@
 #endif /* UNIV_HOTBACKUP */
 }
 
+uint tablename_to_filename(const char *from, char *to, uint to_length);
+
 /*************************************************************************
 Scans a table name from an SQL string. */
 static
@@ -2583,6 +2585,7 @@
 	ulint		table_name_len;
 	const char*	scan_name;
 	char*		ref;
+        char *          normalized_name[FN_REFLEN];
 
 	*success = FALSE;
 	*table = NULL;
@@ -2637,7 +2640,9 @@
 		database_name_len = dict_get_db_name_len(name);
 	}
 
-	table_name_len = strlen(table_name);
+	table_name_len = tablename_to_filename(table_name, normalized_name,
+                                               sizeof(normalized_name));
+        table_name= normalized_name;
 
 	/* Copy database_name, '/', table_name, '\0' */
 	ref = mem_heap_alloc(heap, database_name_len + table_name_len + 2);

--- 1.177/mysql-test/r/innodb.result	Wed May 10 12:54:03 2006
+++ 1.178/mysql-test/r/innodb.result	Fri Jun  2 18:02:51 2006
@@ -1,4 +1,4 @@
-drop table if exists t1,t2,t3,t4;
+drop table if exists t1,t2,t3,t4,`app tab`;
 drop database if exists mysqltest;
 create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
 insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
@@ -3464,3 +3464,14 @@
 Table	Op	Msg_type	Msg_text
 test.t1	optimize	status	OK
 DROP TABLE t1;
+create table `app tab` ( C1 int(11) NULL, INDEX NEWINX (C1), INDEX NEWINX2 (C1)) ENGINE = InnoDB;
+ALTER TABLE `app tab` ADD CONSTRAINT APPFK FOREIGN KEY (C1) REFERENCES `app tab` (C1);
+show create table `app tab`;
+Table	Create Table
+app tab	CREATE TABLE `app tab` (
+  `C1` int(11) DEFAULT NULL,
+  KEY `NEWINX` (`C1`),
+  KEY `NEWINX2` (`C1`),
+  CONSTRAINT `APPFK` FOREIGN KEY (`C1`) REFERENCES `app@0020tab` (`C1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table `app tab`;

--- 1.146/mysql-test/t/innodb.test	Wed May 10 12:54:03 2006
+++ 1.147/mysql-test/t/innodb.test	Fri Jun  2 18:02:51 2006
@@ -18,7 +18,7 @@
 #
 
 --disable_warnings
-drop table if exists t1,t2,t3,t4;
+drop table if exists t1,t2,t3,t4,`app tab`;
 drop database if exists mysqltest;
 --enable_warnings
 
@@ -2510,3 +2510,11 @@
 INSERT INTO t1 VALUES (1);
 OPTIMIZE TABLE t1;
 DROP TABLE t1;
+
+#
+# Bug #16614: SHOW CREATE TABLE does not show constraints for InnoDB tables
+#   the table name should contain an space to check the bug
+create table `app tab` ( C1 int(11) NULL, INDEX NEWINX (C1), INDEX NEWINX2 (C1)) ENGINE = InnoDB;
+ALTER TABLE `app tab` ADD CONSTRAINT APPFK FOREIGN KEY (C1) REFERENCES `app tab` (C1);
+show create table `app tab`;
+drop table `app tab`;
Thread
bk commit into 5.1 tree (holyfoot:1.2178) BUG#16614holyfoot2 Jun