From 5bc3eb2e1183dc5f73b007d48a509793cceb19f1 Mon Sep 17 00:00:00 2001
From: unknown <svoj@mysql.com/june.mysql.com>
Date: Thu, 14 Jun 2007 16:18:01 +0500
Subject: [PATCH] BUG#26976 - Missing table in merge not noted in related error
 msg +             SHOW CREATE TABLE fails Addition to the fix: report db name
 + table name instead of table path. This solves embedded merge test failure.

mysql-test/r/merge.result:
  BUG#26976 - Missing table in merge not noted in related error msg +
              SHOW CREATE TABLE fails
  Addition to the fix: report db name + table name instead of table path.
sql/ha_myisammrg.cc:
  BUG#26976 - Missing table in merge not noted in related error msg +
              SHOW CREATE TABLE fails
  Addition to the fix: report db name + table name instead of table path.
---
 mysql-test/r/merge.result |  8 ++++----
 sql/ha_myisammrg.cc       | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 9f7d5f54d0e..42669eeb66f 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -849,8 +849,8 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table './test/t1' is differently defined or of non-MyISAM type or doesn't exist
-test.tm1	check	Error	Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t1(a INT);
@@ -858,7 +858,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t2(a BLOB);
@@ -866,7 +866,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 ALTER TABLE t2 MODIFY a INT;
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index e7baa6705ee..60aa4bd6adc 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -72,11 +72,22 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
                             uint t1_keys, uint t1_recs,
                             MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
                             uint t2_keys, uint t2_recs, bool strict);
+static void split_file_name(const char *file_name,
+			    LEX_STRING *db, LEX_STRING *name);
+
+
 extern "C" void myrg_print_wrong_table(const char *table_name)
 {
+  LEX_STRING db, name;
+  char buf[FN_REFLEN];
+  split_file_name(table_name, &db, &name);
+  memcpy(buf, db.str, db.length);
+  buf[db.length]= '.';
+  memcpy(buf + db.length + 1, name.str, name.length);
+  buf[db.length + name.length + 1]= 0;
   push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
                       ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
-                      table_name);
+                      buf);
 }