List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:June 28 2006 12:10am
Subject:bk commit into 5.0 tree (jimw:1.2200) BUG#17766
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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.2200 06/06/27 17:10:21 jimw@stripped +5 -0
  Bug #17766: The server accepts to create MERGE tables which cannot work
  
   Changed the error reporting (and a crash) when inserting data into a
   MERGE table that has no underlying tables or no INSERT_METHOD specified
   by reporting that it is read-only.

  sql/handler.cc
    1.213 06/06/27 17:10:18 jimw@stripped +4 -0
    Handle new error message

  sql/ha_myisammrg.cc
    1.78 06/06/27 17:10:18 jimw@stripped +4 -0
    When trying to insert into a MERGE table with no underlying tables
    or no INSERT_METHOD, report that it is read-only.

  mysql-test/t/merge.test
    1.42 06/06/27 17:10:18 jimw@stripped +16 -1
    Add new regression test

  mysql-test/r/merge.result
    1.49 06/06/27 17:10:18 jimw@stripped +12 -0
    Update results

  include/my_base.h
    1.78 06/06/27 17:10:18 jimw@stripped +2 -1
    Add new handler error

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-17766

--- 1.77/include/my_base.h	2006-03-10 06:04:04 -08:00
+++ 1.78/include/my_base.h	2006-06-27 17:10:18 -07:00
@@ -347,8 +347,9 @@ enum ha_base_keytype {
 #define HA_ERR_NULL_IN_SPATIAL   158  /* NULLs are not supported in spatial index */
 #define HA_ERR_TABLE_DEF_CHANGED 159  /* The table changed in storage engine */
 #define HA_ERR_TABLE_NEEDS_UPGRADE 160  /* The table changed in storage engine */
+#define HA_ERR_NOT_WRITABLE      161  /* The table is not writable */
 
-#define HA_ERR_LAST              160  /*Copy last error nr.*/
+#define HA_ERR_LAST              161  /*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.77/sql/ha_myisammrg.cc	2006-05-09 13:31:42 -07:00
+++ 1.78/sql/ha_myisammrg.cc	2006-06-27 17:10:18 -07:00
@@ -132,6 +132,10 @@ int ha_myisammrg::close(void)
 int ha_myisammrg::write_row(byte * buf)
 {
   statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+
+  if (file->merge_insert_method == MERGE_INSERT_DISABLED || !file->tables)
+    return (HA_ERR_NOT_WRITABLE);
+
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
   if (table->next_number_field && buf == table->record[0])

--- 1.212/sql/handler.cc	2006-04-13 00:25:52 -07:00
+++ 1.213/sql/handler.cc	2006-06-27 17:10:18 -07:00
@@ -426,6 +426,7 @@ static int ha_init_errors(void)
   SETMSG(HA_ERR_NO_CONNECTION,          "Could not connect to storage engine");
   SETMSG(HA_ERR_TABLE_DEF_CHANGED,      ER(ER_TABLE_DEF_CHANGED));
   SETMSG(HA_ERR_TABLE_NEEDS_UPGRADE,    ER(ER_TABLE_NEEDS_UPGRADE));
+  SETMSG(HA_ERR_NOT_WRITABLE,           ER(ER_OPEN_AS_READONLY));
 
   /* Register the error messages for use with my_error(). */
   return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@@ -1798,6 +1799,9 @@ void handler::print_error(int error, myf
   }
   case HA_ERR_TABLE_NEEDS_UPGRADE:
     textno=ER_TABLE_NEEDS_UPGRADE;
+    break;
+  case HA_ERR_NOT_WRITABLE:
+    textno= ER_OPEN_AS_READONLY;
     break;
   default:
     {

--- 1.48/mysql-test/r/merge.result	2006-05-30 17:10:50 -07:00
+++ 1.49/mysql-test/r/merge.result	2006-06-27 17:10:18 -07:00
@@ -782,3 +782,15 @@ create table tm (b bit(1)) engine = merg
 select * from tm;
 b
 drop table tm, t1, t2;
+create table t1 (a int) insert_method = last engine = merge;
+insert into t1 values (1);
+ERROR HY000: Table 't1' is read only
+create table t2 (a int) engine = myisam;
+alter table t1 union (t2);
+insert into t1 values (1);
+alter table t1 insert_method = no;
+insert into t1 values (1);
+ERROR HY000: Table 't1' is read only
+drop table t2;
+drop table t1;
+End of 5.0 tests

--- 1.41/mysql-test/t/merge.test	2006-05-30 17:10:50 -07:00
+++ 1.42/mysql-test/t/merge.test	2006-06-27 17:10:18 -07:00
@@ -399,4 +399,19 @@ create table tm (b bit(1)) engine = merg
 select * from tm;
 drop table tm, t1, t2;
 
-# End of 5.0 tests
+#
+# Bug #17766: The server accepts to create MERGE tables which cannot work
+#
+create table t1 (a int) insert_method = last engine = merge;
+--error ER_OPEN_AS_READONLY
+insert into t1 values (1);
+create table t2 (a int) engine = myisam;
+alter table t1 union (t2);
+insert into t1 values (1);
+alter table t1 insert_method = no;
+--error ER_OPEN_AS_READONLY
+insert into t1 values (1);
+drop table t2;
+drop table t1;
+
+--echo End of 5.0 tests
Thread
bk commit into 5.0 tree (jimw:1.2200) BUG#17766Jim Winstead28 Jun