MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:August 30 2006 2:41pm
Subject:bk commit into 4.1 tree (svoj:1.2545) BUG#457
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 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, 2006-08-30 19:41:25+05:00, svoj@stripped +8 -0
  BUG#457 - No error message on MERGE definition type mismatch
  a. Fixed confusing error message from the storage engine when
     it fails to open underlying table. The error message is issued
     when a table is _opened_ (not when it is created).
  b. Fixed a crash when selecting from a merge table that has underlying
     tables with defferent index definition.
  c. (internal) Replaced annoying ifndef DBUG_OFF with DBUG_ASSERT in
     queue_insert() and queue_remove() functions.

  myisammrg/myrg_open.c@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +3 -0
    Set my_errno to HA_ERR_WRONG_MRG_TABLE_DEF if attempt to open
    underlying table failed.

  mysql-test/r/merge.result@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +15 -2
    A test case for bug#457.

  mysql-test/r/repair.result@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +1 -1
    Fixed a test case according to patch for bug#457.

  mysql-test/t/merge.test@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +23 -2
    A test case for bug#457.

  mysys/queues.c@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +19 -29
    Replaced annoying ifndef DBUG_OFF with DBUG_ASSERT, fixed coding style.
    The problem was that having queue overrun in debug build was hidden
    with this ifdef.

  sql/ha_myisammrg.cc@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +8 -0
    Fixed a crash when selecting from a merge table that has underlying
    tables with different index definition. This is done by comparing
    number of keys and fields for each underlying table with
    number of keys and fields in merge table definition.

  sql/share/english/errmsg.txt@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +1 -1
    Better error message if we fail to open underlying table.

  sql/table.cc@stripped, 2006-08-30 19:41:22+05:00, svoj@stripped +8 -1
    Report error from handler with print_error instead of frm_error. This
    fixes confusing error message from the handler. Actually this is
    backported from 5.0.

# 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:	may.pils.ru
# Root:	/home/svoj/devel/mysql/BUG497/mysql-4.1-engines

--- 1.30/myisammrg/myrg_open.c	2006-08-30 19:41:32 +05:00
+++ 1.31/myisammrg/myrg_open.c	2006-08-30 19:41:32 +05:00
@@ -89,7 +89,10 @@
     else
       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 (!m_info)                                /* First file */
     {
       key_parts=isam->s->base.key_parts;

--- 1.15/mysys/queues.c	2006-08-30 19:41:32 +05:00
+++ 1.16/mysys/queues.c	2006-08-30 19:41:32 +05:00
@@ -164,28 +164,22 @@
 
 void queue_insert(register QUEUE *queue, byte *element)
 {
-  reg2 uint idx,next;
+  reg2 uint idx, next;
   int cmp;
-
-#ifndef DBUG_OFF
-  if (queue->elements < queue->max_elements)
-#endif
+  DBUG_ASSERT(queue->elements < queue->max_elements);
+  queue->root[0]= element;
+  idx= ++queue->elements;
+  /* max_at_top swaps the comparison if we want to order by desc */
+  while ((cmp= queue->compare(queue->first_cmp_arg,
+                              element + queue->offset_to_key,
+                              queue->root[(next= idx >> 1)] +
+                              queue->offset_to_key)) &&
+         (cmp ^ queue->max_at_top) < 0)
   {
-    queue->root[0]=element;
-    idx= ++queue->elements;
-
-    /* max_at_top swaps the comparison if we want to order by desc */
-    while ((cmp=queue->compare(queue->first_cmp_arg,
-			       element+queue->offset_to_key,
-			       queue->root[(next=idx >> 1)] +
-			       queue->offset_to_key)) &&
-	   (cmp ^ queue->max_at_top) < 0)
-    {
-      queue->root[idx]=queue->root[next];
-      idx=next;
-    }
-    queue->root[idx]=element;
+    queue->root[idx]= queue->root[next];
+    idx= next;
   }
+  queue->root[idx]= element;
 }
 
 	/* Remove item from queue */
@@ -193,16 +187,12 @@
 
 byte *queue_remove(register QUEUE *queue, uint idx)
 {
-#ifndef DBUG_OFF
-  if (idx >= queue->max_elements)
-    return 0;
-#endif
-  {
-    byte *element=queue->root[++idx];	/* Intern index starts from 1 */
-    queue->root[idx]=queue->root[queue->elements--];
-    _downheap(queue,idx);
-    return element;
-  }
+  byte *element;
+  DBUG_ASSERT(idx < queue->max_elements);
+  element= queue->root[++idx];  /* Intern index starts from 1 */
+  queue->root[idx]= queue->root[queue->elements--];
+  _downheap(queue, idx);
+  return element;
 }
 
 	/* Fix when element on top has been replaced */

--- 1.62/sql/ha_myisammrg.cc	2006-08-30 19:41:32 +05:00
+++ 1.63/sql/ha_myisammrg.cc	2006-08-30 19:41:32 +05:00
@@ -50,6 +50,7 @@
 int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
 {
   char name_buff[FN_REFLEN];
+  MYRG_TABLE *u_table;
 
   DBUG_PRINT("info", ("ha_myisammrg::open"));
   if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode,
@@ -72,6 +73,13 @@
     DBUG_PRINT("error",("reclength: %d  mean_rec_length: %d",
 			table->reclength, mean_rec_length));
     goto err;
+  }
+  for (u_table= file->open_tables; u_table < file->end_table; u_table++)
+  {
+    if (u_table->table->s->base.keys < table->keys)
+      goto err;
+    if (u_table->table->s->base.fields < table->fields)
+      goto err;
   }
 #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4
   /* Merge table has more than 2G rows */

--- 1.151/sql/share/english/errmsg.txt	2006-08-30 19:41:32 +05:00
+++ 1.152/sql/share/english/errmsg.txt	2006-08-30 19:41:32 +05:00
@@ -184,7 +184,7 @@
 "INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES",
 "Incorrect column name '%-.100s'",
 "The used storage engine can't index column '%-.64s'",
-"All tables in the MERGE table are not identically defined",
+"Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists",
 "Can't write, because of unique constraint, to table '%-.64s'",
 "BLOB/TEXT column '%-.64s' used in key specification without a key length",
 "All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead",

--- 1.136/sql/table.cc	2006-08-30 19:41:32 +05:00
+++ 1.137/sql/table.cc	2006-08-30 19:41:32 +05:00
@@ -77,6 +77,7 @@
   my_string record;
   const char **int_array;
   bool	 use_hash, null_field_first;
+  bool   error_reported= FALSE;
   File	 file;
   Field  **field_ptr,*reg_field;
   KEY	 *keyinfo;
@@ -791,6 +792,11 @@
 	error= 1;
 	my_errno= ENOENT;
       }
+      else
+      {
+        outparam->file->print_error(err, MYF(0));
+        error_reported= TRUE;
+      }
       goto err_not_open; /* purecov: inspected */
     }
   }
@@ -812,7 +818,8 @@
  err_end:					/* Here when no file */
   delete crypted;
   *root_ptr= old_root;
-  frm_error(error, outparam, name, ME_ERROR + ME_WAITTANG, errarg);
+  if (!error_reported)
+    frm_error(error, outparam, name, ME_ERROR + ME_WAITTANG, errarg);
   delete outparam->file;
   outparam->file=0;				// For easyer errorchecking
   outparam->db_stat=0;

--- 1.40/mysql-test/r/merge.result	2006-08-30 19:41:32 +05:00
+++ 1.41/mysql-test/r/merge.result	2006-08-30 19:41:32 +05:00
@@ -178,9 +178,9 @@
 ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
 create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
 select * from t4;
-ERROR HY000: Can't open file: 't4.MRG' (errno: 143)
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
 alter table t4 add column c int;
-ERROR HY000: Can't open file: 't4.MRG' (errno: 143)
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
 create database mysqltest;
 create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
 create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6);
@@ -766,3 +766,16 @@
 test.t1	check	status	OK
 test.t2	check	status	OK
 drop table t1, t2, t3;
+CREATE TABLE t3(a TINYINT, KEY(a)) ENGINE=MERGE UNION=(t1,t2);
+SELECT * FROM t3;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
+CREATE TABLE t1(a TINYINT, KEY(a));
+CREATE TABLE t2(a TINYINT, KEY(a)) ENGINE=MEMORY;
+SELECT * FROM t3;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
+DROP TABLE t2;
+CREATE TABLE t2(a TINYINT);
+INSERT INTO t1 VALUES(2),(1);
+SELECT * FROM t3 WHERE a=2;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
+DROP TABLE t1, t2, t3;

--- 1.38/mysql-test/t/merge.test	2006-08-30 19:41:32 +05:00
+++ 1.39/mysql-test/t/merge.test	2006-08-30 19:41:32 +05:00
@@ -47,9 +47,9 @@
 
 # The following should give errors
 create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
---error 1016
+--error 1168
 select * from t4;
---error 1016
+--error 1168
 alter table t4 add column c int;
 
 #
@@ -375,5 +375,26 @@
 select * from t3;
 check table t1, t2;
 drop table t1, t2, t3;
+
+#
+# BUG#457 - No error message on MERGE definition type mismatch
+#
+
+# Underlying table doesn't exists.
+CREATE TABLE t3(a TINYINT, KEY(a)) ENGINE=MERGE UNION=(t1,t2);
+--error 1168
+SELECT * FROM t3;
+# Underlying table is of non-myisam type.
+CREATE TABLE t1(a TINYINT, KEY(a));
+CREATE TABLE t2(a TINYINT, KEY(a)) ENGINE=MEMORY;
+--error 1168
+SELECT * FROM t3;
+DROP TABLE t2;
+# Different key definition
+CREATE TABLE t2(a TINYINT);
+INSERT INTO t1 VALUES(2),(1);
+--error 1168
+SELECT * FROM t3 WHERE a=2;
+DROP TABLE t1, t2, t3;
 
 # End of 4.1 tests

--- 1.17/mysql-test/r/repair.result	2006-08-30 19:41:32 +05:00
+++ 1.18/mysql-test/r/repair.result	2006-08-30 19:41:32 +05:00
@@ -31,7 +31,7 @@
 flush tables;
 repair table t1;
 Table	Op	Msg_type	Msg_text
-test.t1	repair	error	Can't open file: 't1.MYI' (errno: 130)
+test.t1	repair	error	Got error 130 from storage engine
 repair table t1 use_frm;
 Table	Op	Msg_type	Msg_text
 test.t1	repair	warning	Number of rows changed from 0 to 1
Thread
bk commit into 4.1 tree (svoj:1.2545) BUG#457Sergey Vojtovich30 Aug