List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:May 28 2007 12:25pm
Subject:bk commit into 5.0 tree (svoj:1.2500) BUG#26976
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of svoj. When svoj 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-05-28 17:25:17+05:00, svoj@stripped +10 -0
  BUG#26976 - Missing table in merge not noted in related error msg +
              SHOW CREATE TABLE fails
  
  Underlying table names, that merge engine fails to open were not
  reported.
  
  With this fix CHECK TABLE issued against merge table reports all
  underlying table names that it fails to open. Other statements
  are unaffected.
  
  This fix doesn't solve SHOW CREATE TABLE issue.

  include/my_base.h@stripped, 2007-05-28 17:25:15+05:00, svoj@stripped +2 -1
    Added HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF errno. It is used instead
    of HA_ERR_WRONG_MRG_TABLE_DEF in case HA_OPEN_FOR_REPAIR is
    passed to merge engine handler open function.

  myisammrg/myrg_def.h@stripped, 2007-05-28 17:25:15+05:00, svoj@stripped +4 -1
    Added myrg_print_wrong_table declaration.

  myisammrg/myrg_open.c@stripped, 2007-05-28 17:25:15+05:00, svoj@stripped +24 -5
    If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
    report names of tables that we fail to open.

  mysql-test/r/merge.result@stripped, 2007-05-28 17:25:15+05:00, svoj@stripped +32 -0
    A test case for BUG#26976.

  mysql-test/t/merge.test@stripped, 2007-05-28 17:25:15+05:00, svoj@stripped +21 -0
    A test case for BUG#26976.

  sql/ha_myisammrg.cc@stripped, 2007-05-28 17:25:15+05:00, svoj@stripped +34 -4
    If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
    report names of tables that we fail to open.
    
    Added dummy ha_myisammrg::check to not confuse users with
    "not implemented" error in case all underlying tables are
    fine.

  sql/ha_myisammrg.h@stripped, 2007-05-28 17:25:16+05:00, svoj@stripped +1 -0
    Added ha_myisammrg::check declaration.

  sql/handler.cc@stripped, 2007-05-28 17:25:16+05:00, svoj@stripped +4 -0
    Added handling of HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF.

  sql/share/errmsg.txt@stripped, 2007-05-28 17:25:16+05:00, svoj@stripped +2 -1
    Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead
    of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is
    passed to merge engine handler open function.

  sql/sql_table.cc@stripped, 2007-05-28 17:25:16+05:00, svoj@stripped +1 -1
    Reorder mysql_admin_table arguments to meet it's definition.

# 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:	svoj
# Host:	june.mysql.com
# Root:	/home/svoj/devel/mysql/BUG26976/mysql-5.0-engines

--- 1.83/include/my_base.h	2007-04-05 11:29:08 +05:00
+++ 1.84/include/my_base.h	2007-05-28 17:25:15 +05:00
@@ -371,8 +371,9 @@ enum ha_base_keytype {
 #define HA_ERR_TABLE_READONLY    161  /* The table is not writable */
 #define HA_ERR_AUTOINC_READ_FAILED 162/* Failed to get the next autoinc value */
 #define HA_ERR_AUTOINC_ERANGE    163  /* Failed to set the row autoinc value */
+#define HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF 164 /* errno 143 for CHECK TABLE */
 
-#define HA_ERR_LAST              163  /*Copy last error nr.*/
+#define HA_ERR_LAST              164  /*Copy last error nr.*/
 /* Add error numbers before HA_ERR_LAST and change it accordingly. */
 #define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)
 

--- 1.13/myisammrg/myrg_def.h	2006-12-31 00:02:05 +04:00
+++ 1.14/myisammrg/myrg_def.h	2007-05-28 17:25:15 +05:00
@@ -29,4 +29,7 @@ extern pthread_mutex_t THR_LOCK_open;
 
 int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag);
 int _myrg_mi_read_record(MI_INFO *info, byte *buf);
-
+#ifdef __cplusplus
+extern "C" 
+#endif
+void myrg_print_wrong_table(const char *table_name);

--- 1.35/myisammrg/myrg_open.c	2006-12-31 00:02:05 +04:00
+++ 1.36/myisammrg/myrg_open.c	2007-05-28 17:25:15 +05:00
@@ -89,8 +89,17 @@ MYRG_INFO *myrg_open(const char *name, i
       fn_format(buff, buff, "", "", 0);
     if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0))))
     {
-      my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
-      goto err;
+      if (handle_locking & HA_OPEN_FOR_REPAIR)
+      {
+        my_errno= HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF;
+        myrg_print_wrong_table(buff);
+        continue;
+      }
+      else
+      {
+        my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
+        goto err;
+      }
     }
     if (!m_info)                                /* First file */
     {
@@ -117,8 +126,17 @@ MYRG_INFO *myrg_open(const char *name, i
     files++;
     if (m_info->reclength != isam->s->base.reclength)
     {
-      my_errno=HA_ERR_WRONG_MRG_TABLE_DEF;
-      goto err;
+      if (handle_locking & HA_OPEN_FOR_REPAIR)
+      {
+        my_errno= HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF;
+        myrg_print_wrong_table(buff);
+        continue;
+      }
+      else
+      {
+        my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
+        goto err;
+      }
     }
     m_info->options|= isam->s->options;
     m_info->records+= isam->state->records;
@@ -130,7 +148,8 @@ MYRG_INFO *myrg_open(const char *name, i
       m_info->rec_per_key_part[i]+= (isam->s->state.rec_per_key_part[i] /
                                      m_info->tables);
   }
-
+  if (my_errno == HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF)
+    goto err;
   if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
                                                   MYF(MY_WME | MY_ZEROFILL))))
     goto err;

--- 1.89/sql/ha_myisammrg.cc	2007-02-21 15:04:59 +04:00
+++ 1.90/sql/ha_myisammrg.cc	2007-05-28 17:25:15 +05:00
@@ -72,6 +72,14 @@ extern int check_definition(MI_KEYDEF *t
                             uint t1_keys, uint t1_recs,
                             MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
                             uint t2_keys, uint t2_recs, bool strict);
+extern "C" void myrg_print_wrong_table(const char *table_name)
+{
+  sql_print_error(ER(ER_ADMIN_WRONG_MRG_TABLE), table_name);
+  push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                      ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
+                      table_name);
+}
+
 
 const char **ha_myisammrg::bas_ext() const
 {
@@ -121,7 +129,13 @@ int ha_myisammrg::open(const char *name,
   {
     DBUG_PRINT("error",("reclength: %lu  mean_rec_length: %lu",
 			table->s->reclength, mean_rec_length));
-    error= HA_ERR_WRONG_MRG_TABLE_DEF;
+    if (test_if_locked & HA_OPEN_FOR_REPAIR)
+    {
+      error= HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF;
+      myrg_print_wrong_table(file->open_tables->table->filename);
+    }
+    else
+      error= HA_ERR_WRONG_MRG_TABLE_DEF;
     goto err;
   }
   if ((error= table2myisam(table, &keyinfo, &recinfo, &recs)))
@@ -139,12 +153,22 @@ int ha_myisammrg::open(const char *name,
                          u_table->table->s->base.keys,
                          u_table->table->s->base.fields, false))
     {
-      my_free((gptr) recinfo, MYF(0));
-      error= HA_ERR_WRONG_MRG_TABLE_DEF;
-      goto err;
+      if (test_if_locked & HA_OPEN_FOR_REPAIR)
+      {
+        error= HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF;
+        myrg_print_wrong_table(u_table->table->filename);
+      }
+      else
+      {
+        my_free((gptr) recinfo, MYF(0));
+        error= HA_ERR_WRONG_MRG_TABLE_DEF;
+        goto err;
+      }
     }
   }
   my_free((gptr) recinfo, MYF(0));
+  if (error == HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF)
+    goto err;
 #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4
   /* Merge table has more than 2G rows */
   if (table->s->crashed)
@@ -596,4 +620,10 @@ void ha_myisammrg::append_create_info(St
     append_identifier(thd, packet, name.str, name.length);
   }
   packet->append(')');
+}
+
+
+int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt)
+{
+  return HA_ADMIN_OK;
 }

--- 1.45/sql/ha_myisammrg.h	2007-03-06 13:34:12 +04:00
+++ 1.46/sql/ha_myisammrg.h	2007-05-28 17:25:16 +05:00
@@ -81,4 +81,5 @@ class ha_myisammrg: public handler
   void update_create_info(HA_CREATE_INFO *create_info);
   void append_create_info(String *packet);
   MYRG_INFO *myrg_info() { return file; }
+  int check(THD* thd, HA_CHECK_OPT* check_opt);
 };

--- 1.233/sql/handler.cc	2007-05-08 00:12:13 +05:00
+++ 1.234/sql/handler.cc	2007-05-28 17:25:16 +05:00
@@ -425,6 +425,7 @@ static int ha_init_errors(void)
   SETMSG(HA_ERR_TABLE_READONLY,         ER(ER_OPEN_AS_READONLY));
   SETMSG(HA_ERR_AUTOINC_READ_FAILED,    ER(ER_AUTOINC_READ_FAILED));
   SETMSG(HA_ERR_AUTOINC_ERANGE,         ER(ER_WARN_DATA_OUT_OF_RANGE));
+  SETMSG(HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF, ER(ER_ADMIN_WRONG_MRG_TABLE));
 
   /* Register the error messages for use with my_error(). */
   return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@@ -1762,6 +1763,9 @@ void handler::print_error(int error, myf
   case HA_ERR_WRONG_MRG_TABLE_DEF:
     textno=ER_WRONG_MRG_TABLE;
     break;
+  case HA_ERR_ADMIN_WRONG_MRG_TABLE_DEF:
+    /* Error is reported by the handler. */
+    DBUG_VOID_RETURN;
   case HA_ERR_FOUND_DUPP_KEY:
   {
     uint key_nr=get_dup_key(error);

--- 1.343/sql/sql_table.cc	2007-05-11 21:33:11 +05:00
+++ 1.344/sql/sql_table.cc	2007-05-28 17:25:16 +05:00
@@ -2924,7 +2924,7 @@ bool mysql_check_table(THD* thd, TABLE_L
   DBUG_ENTER("mysql_check_table");
   DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
 				"check", lock_type,
-				0, HA_OPEN_FOR_REPAIR, 0, 0,
+				0, true, HA_OPEN_FOR_REPAIR, 0,
 				&handler::ha_check, &view_checksum));
 }
 

--- 1.78/sql/share/errmsg.txt	2007-02-23 20:36:00 +04:00
+++ 1.79/sql/share/errmsg.txt	2007-05-28 17:25:16 +05:00
@@ -5633,4 +5633,5 @@ ER_WRONG_STRING_LENGTH
 	eng "String '%-.70s' is too long for %s (should be no longer than %d)"
 ER_NON_INSERTABLE_TABLE  
 	eng "The target table %-.100s of the %s is not insertable-into"
-
+ER_ADMIN_WRONG_MRG_TABLE
+	eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"

--- 1.60/mysql-test/r/merge.result	2007-04-18 16:22:21 +05:00
+++ 1.61/mysql-test/r/merge.result	2007-05-28 17:25:15 +05:00
@@ -844,4 +844,36 @@ insert into t1 values (1);
 ERROR HY000: Table 't1' is read only
 drop table t2;
 drop table t1;
+CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2);
+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	
+Warnings:
+Error	1472	Table './test/t1' is differently defined or of non-MyISAM type or doesn't exist
+Error	1472	Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
+CREATE TABLE t1(a INT);
+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	
+Warnings:
+Error	1472	Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
+CREATE TABLE t2(a BLOB);
+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	
+Warnings:
+Error	1472	Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
+ALTER TABLE t2 MODIFY a INT;
+SELECT * FROM tm1;
+a
+CHECK TABLE tm1;
+Table	Op	Msg_type	Msg_text
+test.tm1	check	status	OK
+DROP TABLE tm1, t1, t2;
 End of 5.0 tests

--- 1.50/mysql-test/t/merge.test	2007-04-18 16:20:04 +05:00
+++ 1.51/mysql-test/t/merge.test	2007-05-28 17:25:15 +05:00
@@ -486,4 +486,25 @@ insert into t1 values (1);
 drop table t2;
 drop table t1;
 
+#
+# BUG#26976 - Missing table in merge not noted in related error msg + SHOW
+#             CREATE TABLE fails
+#
+CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2);
+--error 1168
+SELECT * FROM tm1;
+CHECK TABLE tm1;
+CREATE TABLE t1(a INT);
+--error 1168
+SELECT * FROM tm1;
+CHECK TABLE tm1;
+CREATE TABLE t2(a BLOB);
+--error 1168
+SELECT * FROM tm1;
+CHECK TABLE tm1;
+ALTER TABLE t2 MODIFY a INT;
+SELECT * FROM tm1;
+CHECK TABLE tm1;
+DROP TABLE tm1, t1, t2;
+
 --echo End of 5.0 tests
Thread
bk commit into 5.0 tree (svoj:1.2500) BUG#26976Sergey Vojtovich28 May