MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:January 9 2007 2:14pm
Subject:bk commit into 5.1 tree (gluh:1.2382) BUG#25026
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of gluh. When gluh 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@stripped, 2007-01-09 18:14:04+04:00, gluh@stripped +3 -0
  Fix for bug#25026 `information_schema.KEY_COLUMN_USAGE`.`REFERENCED_TABLE_NAME` returns garbage
  Unencode internal db & table name

  mysql-test/r/information_schema_inno.result@stripped, 2007-01-09 18:14:02+04:00, gluh@stripped +22 -0
    test result

  mysql-test/t/information_schema_inno.test@stripped, 2007-01-09 18:14:02+04:00, gluh@stripped +24 -0
    test case

  storage/innobase/handler/ha_innodb.cc@stripped, 2007-01-09 18:14:02+04:00, gluh@stripped +17 -5
    Unencode internal db & table name

# 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:	gluh
# Host:	eagle.(none)
# Root:	/home/gluh/MySQL/Merge/5.1-opt

--- 1.9/mysql-test/r/information_schema_inno.result	2006-05-02 16:31:32 +05:00
+++ 1.10/mysql-test/r/information_schema_inno.result	2007-01-09 18:14:02 +04:00
@@ -56,3 +56,25 @@ test	t3	FOREIGN KEY	A2	test	t2	NONE	SET 
 test	t4	FOREIGN KEY	A3	test	t3	NONE	NO ACTION	SET NULL
 test	t5	FOREIGN KEY	A4	test	t4	NONE	RESTRICT	CASCADE
 drop tables t5, t4, t3, t2, t1;
+create database `db-1`;
+use `db-1`;
+create table `t-2` (
+id int(10) unsigned not null auto_increment,
+primary key (id)
+) engine=innodb;
+create table `t-1` (
+id int(10) unsigned not null auto_increment,
+idtype int(10) unsigned not null,
+primary key (id),
+key fk_t1_1 (idtype),
+constraint fk_t1_1 foreign key (idtype) references `t-2` (id)
+) engine=innodb;
+use test;
+select referenced_table_schema, referenced_table_name 
+from information_schema.key_column_usage
+where constraint_schema = 'db-1';
+referenced_table_schema	referenced_table_name
+NULL	NULL
+db-1	t-2
+NULL	NULL
+drop database `db-1`;

--- 1.6/mysql-test/t/information_schema_inno.test	2006-05-02 16:31:32 +05:00
+++ 1.7/mysql-test/t/information_schema_inno.test	2007-01-09 18:14:02 +04:00
@@ -1,3 +1,4 @@
+-- source include/testdb_only.inc
 -- source include/have_innodb.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3;
@@ -53,3 +54,26 @@ from information_schema.TABLE_CONSTRAINT
 where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and
 a.CONSTRAINT_NAME = b.CONSTRAINT_NAME;
 drop tables t5, t4, t3, t2, t1;
+
+#
+# Bug#25026  `information_schema.KEY_COLUMN_USAGE`.`REFERENCED_TABLE_NAME` returns garbage
+#
+create database `db-1`;
+use `db-1`;
+create table `t-2` (
+  id int(10) unsigned not null auto_increment,
+  primary key (id)
+) engine=innodb;
+
+create table `t-1` (
+  id int(10) unsigned not null auto_increment,
+  idtype int(10) unsigned not null,
+  primary key (id),
+  key fk_t1_1 (idtype),
+  constraint fk_t1_1 foreign key (idtype) references `t-2` (id)
+) engine=innodb;
+use test;
+select referenced_table_schema, referenced_table_name 
+from information_schema.key_column_usage
+where constraint_schema = 'db-1';
+drop database `db-1`;

--- 1.317/storage/innobase/handler/ha_innodb.cc	2006-12-23 23:19:59 +04:00
+++ 1.318/storage/innobase/handler/ha_innodb.cc	2007-01-09 18:14:02 +04:00
@@ -5933,6 +5933,9 @@ ha_innobase::get_foreign_key_list(THD *t
 	  uint i;
 	  FOREIGN_KEY_INFO f_key_info;
 	  LEX_STRING *name= 0;
+          uint ulen;
+          char uname[NAME_LEN*3+1];           /* Unencoded name */
+          char db_name[NAME_LEN*3+1];
 	  const char *tmp_buff;
 
 	  tmp_buff= foreign->id;
@@ -5943,14 +5946,23 @@ ha_innobase::get_foreign_key_list(THD *t
 	  f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff,
 		  (uint) strlen(tmp_buff), 1);
 	  tmp_buff= foreign->referenced_table_name;
+
+          /* Database name */
 	  i= 0;
 	  while (tmp_buff[i] != '/')
-		  i++;
-	  f_key_info.referenced_db= make_lex_string(thd, 0,
-		  tmp_buff, i, 1);
+          {
+            db_name[i]= tmp_buff[i];
+            i++;
+          }
+          db_name[i]= 0;
+          ulen= filename_to_tablename(db_name, uname, sizeof(uname));
+          f_key_info.referenced_db= make_lex_string(thd, 0, uname, ulen, 1);
+
+          /* Table name */
 	  tmp_buff+= i + 1;
-	  f_key_info.referenced_table= make_lex_string(thd, 0, tmp_buff,
-		  (uint) strlen(tmp_buff), 1);
+          ulen= filename_to_tablename(tmp_buff, uname, sizeof(uname));
+          f_key_info.referenced_table= make_lex_string(thd, 0, uname,
+                                                       ulen, 1);
 
 	  for (i= 0;;) {
 		  tmp_buff= foreign->foreign_col_names[i];
Thread
bk commit into 5.1 tree (gluh:1.2382) BUG#25026gluh9 Jan