MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:antony Date:July 26 2006 9:05am
Subject:bk commit into 5.0 tree (acurtis:1.2218) BUG#20573
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of antony. When antony 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-07-26 02:05:35-07:00, acurtis@stripped +14 -0
  Bug#20573
    "strict mode: inserts autogenerated auto_increment value bigger than max"
    Row inserts need to fail if a fatal error occurred updating auto-increment
    value. Autoincrement code is currently called from storage engine classes
    and so test cases exist for multiple storage engines.
  
  draft patch for 1st review.

  include/my_base.h@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +3 -1
    new constant HA_ERR_DATA_OUT_OF_RANGE

  mysql-test/r/auto_increment-heap.result@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +28 -0
    New BitKeeper file ``mysql-test/r/auto_increment-heap.result''

  mysql-test/r/auto_increment-heap.result@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +0 -0

  mysql-test/r/auto_increment-innodb.result@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +28 -0
    New BitKeeper file ``mysql-test/r/auto_increment-innodb.result''

  mysql-test/r/auto_increment-innodb.result@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +0 -0

  mysql-test/r/auto_increment.result@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +25 -0
    test for bug#20573

  mysql-test/t/auto_increment-heap.test@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +33 -0
    New BitKeeper file ``mysql-test/t/auto_increment-heap.test''

  mysql-test/t/auto_increment-heap.test@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +0 -0

  mysql-test/t/auto_increment-innodb.test@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +35 -0
    New BitKeeper file ``mysql-test/t/auto_increment-innodb.test''

  mysql-test/t/auto_increment-innodb.test@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +0 -0

  mysql-test/t/auto_increment.test@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +25 -0
    test for bug#20573

  sql/ha_berkeley.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +3 -2
    fail insert if auto-increment failed

  sql/ha_heap.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +3 -2
    fail insert if auto-increment failed

  sql/ha_innodb.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +5 -1
    fail insert if auto-increment failed

  sql/ha_myisam.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +3 -2
    fail insert if auto-increment failed

  sql/ha_myisammrg.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +3 -2
    fail insert if auto-increment failed

  sql/ha_ndbcluster.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +2 -1
    fail insert if auto-increment failed

  sql/handler.cc@stripped, 2006-07-26 02:05:29-07:00, acurtis@stripped +3 -0
    fail insert if auto-increment failed

# 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:	acurtis
# Host:	ltantony.xiphis.org
# Root:	/home/antony/work2/p2-bug20573.1

--- 1.79/include/my_base.h	2006-07-26 02:05:44 -07:00
+++ 1.80/include/my_base.h	2006-07-26 02:05:44 -07:00
@@ -358,7 +358,9 @@
 #define HA_ERR_TABLE_NEEDS_UPGRADE 160  /* The table changed in storage engine */
 #define HA_ERR_TABLE_READONLY    161  /* The table is not writable */
 
-#define HA_ERR_LAST              161  /*Copy last error nr.*/
+#define HA_ERR_DATA_OUT_OF_RANGE 162  /* Autoincrement failed */
+
+#define HA_ERR_LAST              162  /*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.161/sql/ha_berkeley.cc	2006-07-26 02:05:44 -07:00
+++ 1.162/sql/ha_berkeley.cc	2006-07-26 02:05:44 -07:00
@@ -952,8 +952,9 @@
   statistic_increment(table->in_use->status_var.ha_write_count, &LOCK_status);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
-  if (table->next_number_field && record == table->record[0])
-    update_auto_increment();
+  if (table->next_number_field && record == table->record[0] &&
+      update_auto_increment())
+    DBUG_RETURN(HA_ERR_DATA_OUT_OF_RANGE);
   if ((error=pack_row(&row, record,1)))
     DBUG_RETURN(error); /* purecov: inspected */
 

--- 1.77/sql/ha_heap.cc	2006-07-26 02:05:44 -07:00
+++ 1.78/sql/ha_heap.cc	2006-07-26 02:05:44 -07:00
@@ -175,8 +175,9 @@
   statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
-  if (table->next_number_field && buf == table->record[0])
-    update_auto_increment();
+  if (table->next_number_field && buf == table->record[0] &&
+      update_auto_increment())
+    return HA_ERR_DATA_OUT_OF_RANGE;
   res= heap_write(file,buf);
   if (!res && (++records_changed*HEAP_STATS_UPDATE_THRESHOLD > 
                file->s->records))

--- 1.166/sql/ha_myisam.cc	2006-07-26 02:05:44 -07:00
+++ 1.167/sql/ha_myisam.cc	2006-07-26 02:05:44 -07:00
@@ -315,8 +315,9 @@
     If we have an auto_increment column and we are writing a changed row
     or a new row, then update the auto_increment value in the record.
   */
-  if (table->next_number_field && buf == table->record[0])
-    update_auto_increment();
+  if (table->next_number_field && buf == table->record[0] &&
+      update_auto_increment())
+    return HA_ERR_DATA_OUT_OF_RANGE;
   return mi_write(file,buf);
 }
 

--- 1.79/sql/ha_myisammrg.cc	2006-07-26 02:05:44 -07:00
+++ 1.80/sql/ha_myisammrg.cc	2006-07-26 02:05:44 -07:00
@@ -138,8 +138,9 @@
 
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
-  if (table->next_number_field && buf == table->record[0])
-      update_auto_increment();
+  if (table->next_number_field && buf == table->record[0] &&
+      update_auto_increment())
+    return HA_ERR_DATA_OUT_OF_RANGE;
   return myrg_write(file,buf);
 }
 

--- 1.216/sql/handler.cc	2006-07-26 02:05:44 -07:00
+++ 1.217/sql/handler.cc	2006-07-26 02:05:44 -07:00
@@ -429,6 +429,7 @@
   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_TABLE_READONLY,         ER(ER_OPEN_AS_READONLY));
+  SETMSG(HA_ERR_DATA_OUT_OF_RANGE,      ER(ER_WARN_DATA_OUT_OF_RANGE));
 
   /* Register the error messages for use with my_error(). */
   return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@@ -1635,6 +1636,8 @@
 
   if (likely(!table->next_number_field->store((longlong) nr, TRUE)))
     thd->insert_id((ulonglong) nr);
+  else if (thd->killed == THD::KILL_BAD_DATA)
+    result= 1;
   else
   {
     /*
--- New file ---
+++ mysql-test/r/auto_increment-heap.result	06/07/26 02:05:29
drop table if exists t1;
drop table if exists t2;
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
`a` tinyint(4) NOT NULL auto_increment,
PRIMARY KEY  (`a`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
set @old_sql_mode=@@sql_mode, sql_mode='strict_all_tables';
insert into t1 values(1000);
ERROR 22003: Out of range value adjusted for column 'a' at row 1
select count(*) from t1;
count(*)
0
set auto_increment_increment=1000;
set auto_increment_offset=700;
insert into t1 values(null);
ERROR 22003: Out of range value adjusted for column 'a' at row 1
select count(*) from t1;
count(*)
0
set @@sql_mode=@old_sql_mode;
insert into t1 values(null);
Warnings:
Warning	1264	Out of range value adjusted for column 'a' at row 1
select * from t1;
a
127
drop table t1;

--- New file ---
+++ mysql-test/r/auto_increment-innodb.result	06/07/26 02:05:29
drop table if exists t1;
drop table if exists t2;
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
`a` tinyint(4) NOT NULL auto_increment,
PRIMARY KEY  (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
set @old_sql_mode=@@sql_mode, sql_mode='strict_all_tables';
insert into t1 values(1000);
ERROR 22003: Out of range value adjusted for column 'a' at row 1
select count(*) from t1;
count(*)
0
set auto_increment_increment=1000;
set auto_increment_offset=700;
insert into t1 values(null);
ERROR 22003: Out of range value adjusted for column 'a' at row 1
select count(*) from t1;
count(*)
0
set @@sql_mode=@old_sql_mode;
insert into t1 values(null);
Warnings:
Warning	1264	Out of range value adjusted for column 'a' at row 1
select * from t1;
a
127
drop table t1;

--- New file ---
+++ mysql-test/t/auto_increment-heap.test	06/07/26 02:05:29
#
# Test of auto_increment for MEMORY
#
--disable_warnings
drop table if exists t1;
drop table if exists t2;
--enable_warnings
SET SQL_WARNINGS=1;

#
# Bug #20573: strict autoincrement should respect range
#
CREATE TABLE t1 (
  `a` tinyint(4) NOT NULL auto_increment,
  PRIMARY KEY  (`a`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;

set @old_sql_mode=@@sql_mode, sql_mode='strict_all_tables';
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t1 values(1000);
select count(*) from t1;

set auto_increment_increment=1000;
set auto_increment_offset=700;
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t1 values(null);
select count(*) from t1;

set @@sql_mode=@old_sql_mode;
insert into t1 values(null);
select * from t1;

drop table t1;

--- New file ---
+++ mysql-test/t/auto_increment-innodb.test	06/07/26 02:05:29
-- source include/have_innodb.inc

#
# Test of auto_increment for innodb
#
--disable_warnings
drop table if exists t1;
drop table if exists t2;
--enable_warnings
SET SQL_WARNINGS=1;

#
# Bug #20573: strict autoincrement should respect range
#
CREATE TABLE t1 (
  `a` tinyint(4) NOT NULL auto_increment,
  PRIMARY KEY  (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

set @old_sql_mode=@@sql_mode, sql_mode='strict_all_tables';
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t1 values(1000);
select count(*) from t1;

set auto_increment_increment=1000;
set auto_increment_offset=700;
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t1 values(null);
select count(*) from t1;

set @@sql_mode=@old_sql_mode;
insert into t1 values(null);
select * from t1;

drop table t1;


--- 1.273/sql/ha_ndbcluster.cc	2006-07-26 02:05:44 -07:00
+++ 1.274/sql/ha_ndbcluster.cc	2006-07-26 02:05:44 -07:00
@@ -2127,7 +2127,8 @@
       THD *thd= table->in_use;
       
       m_skip_auto_increment= FALSE;
-      update_auto_increment();
+      if (update_auto_increment())
+        DBUG_RETURN(HA_ERR_DATA_OUT_OF_RANGE);
       /* Ensure that handler is always called for auto_increment values */
       thd->next_insert_id= 0;
       m_skip_auto_increment= !auto_increment_column_changed;

--- 1.38/mysql-test/r/auto_increment.result	2006-07-26 02:05:44 -07:00
+++ 1.39/mysql-test/r/auto_increment.result	2006-07-26 02:05:44 -07:00
@@ -440,3 +440,28 @@
 2	1
 3	1
 drop table t1;
+CREATE TABLE t1 (
+`a` tinyint(4) NOT NULL auto_increment,
+PRIMARY KEY  (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+set @old_sql_mode=@@sql_mode, sql_mode='strict_all_tables';
+insert into t1 values(1000);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values(null);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set @@sql_mode=@old_sql_mode;
+insert into t1 values(null);
+Warnings:
+Warning	1264	Out of range value adjusted for column 'a' at row 1
+select * from t1;
+a
+127
+drop table t1;

--- 1.27/mysql-test/t/auto_increment.test	2006-07-26 02:05:44 -07:00
+++ 1.28/mysql-test/t/auto_increment.test	2006-07-26 02:05:44 -07:00
@@ -292,3 +292,28 @@
 insert into t1 (val) values (1);
 select * from t1;
 drop table t1;
+
+#
+# Bug #20573: strict autoincrement should respect range
+#
+CREATE TABLE t1 (
+  `a` tinyint(4) NOT NULL auto_increment,
+  PRIMARY KEY  (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+set @old_sql_mode=@@sql_mode, sql_mode='strict_all_tables';
+--error ER_WARN_DATA_OUT_OF_RANGE
+insert into t1 values(1000);
+select count(*) from t1;
+
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+--error ER_WARN_DATA_OUT_OF_RANGE
+insert into t1 values(null);
+select count(*) from t1;
+
+set @@sql_mode=@old_sql_mode;
+insert into t1 values(null);
+select * from t1;
+
+drop table t1;

--- 1.296/sql/ha_innodb.cc	2006-07-26 02:05:44 -07:00
+++ 1.297/sql/ha_innodb.cc	2006-07-26 02:05:44 -07:00
@@ -3254,7 +3254,11 @@
 		/* We must use the handler code to update the auto-increment
                 value to be sure that we increment it correctly. */
 
-    		update_auto_increment();
+    		if (update_auto_increment())
+                {
+                        error = HA_ERR_DATA_OUT_OF_RANGE;
+                        goto func_exit;
+                }
                 auto_inc_used = 1;
 
 	}
Thread
bk commit into 5.0 tree (acurtis:1.2218) BUG#20573antony26 Jul