MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:antony Date:August 30 2006 7:12pm
Subject:bk commit into 5.0 tree (acurtis:1.2252) 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-08-30 12:12:03-07:00, acurtis@stripped +21 -0
  Bug#20573
    "strict mode: inserts autogenerated auto_increment value bigger than max"
    Strict mode should fail if autoincrement value is out of range

  include/my_base.h@stripped, 2006-08-30 12:11:58-07:00, acurtis@stripped +3 -1
    Add new handler error codes

  mysql-test/include/strict_autoinc.inc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +28 -0
    New BitKeeper file ``mysql-test/include/strict_autoinc.inc''

  mysql-test/include/strict_autoinc.inc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/r/strict_autoinc_1myisam.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +27 -0
    New BitKeeper file ``mysql-test/r/strict_autoinc_1myisam.result''

  mysql-test/r/strict_autoinc_1myisam.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/r/strict_autoinc_2innodb.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +27 -0
    New BitKeeper file ``mysql-test/r/strict_autoinc_2innodb.result''

  mysql-test/r/strict_autoinc_2innodb.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/r/strict_autoinc_3heap.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +27 -0
    New BitKeeper file ``mysql-test/r/strict_autoinc_3heap.result''

  mysql-test/r/strict_autoinc_3heap.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/r/strict_autoinc_4bdb.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +27 -0
    New BitKeeper file ``mysql-test/r/strict_autoinc_4bdb.result''

  mysql-test/r/strict_autoinc_4bdb.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/r/strict_autoinc_5ndb.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +27 -0
    New BitKeeper file ``mysql-test/r/strict_autoinc_5ndb.result''

  mysql-test/r/strict_autoinc_5ndb.result@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/t/strict_autoinc_1myisam.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +8 -0
    New BitKeeper file ``mysql-test/t/strict_autoinc_1myisam.test''

  mysql-test/t/strict_autoinc_1myisam.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/t/strict_autoinc_2innodb.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +10 -0
    New BitKeeper file ``mysql-test/t/strict_autoinc_2innodb.test''

  mysql-test/t/strict_autoinc_2innodb.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/t/strict_autoinc_3heap.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +8 -0
    New BitKeeper file ``mysql-test/t/strict_autoinc_3heap.test''

  mysql-test/t/strict_autoinc_3heap.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/t/strict_autoinc_4bdb.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +10 -0
    New BitKeeper file ``mysql-test/t/strict_autoinc_4bdb.test''

  mysql-test/t/strict_autoinc_4bdb.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  mysql-test/t/strict_autoinc_5ndb.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +10 -0
    New BitKeeper file ``mysql-test/t/strict_autoinc_5ndb.test''

  mysql-test/t/strict_autoinc_5ndb.test@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +0 -0

  sql/ha_berkeley.cc@stripped, 2006-08-30 12:11:58-07:00, acurtis@stripped +4 -1
    handle error in update_auto_increment()

  sql/ha_heap.cc@stripped, 2006-08-30 12:11:58-07:00, acurtis@stripped +4 -1
    handle error in update_auto_increment()

  sql/ha_innodb.cc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +2 -1
    handle error in update_auto_increment()

  sql/ha_myisam.cc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +5 -1
    handle error in update_auto_increment()

  sql/ha_myisammrg.cc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +5 -1
    handle error in update_auto_increment()

  sql/ha_ndbcluster.cc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +3 -1
    handle error in update_auto_increment()

  sql/handler.cc@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +18 -5
    return error from handler::update_auto_increment()

  sql/handler.h@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +1 -1
    change return type of handler::update_auto_increment() to int

  sql/share/errmsg.txt@stripped, 2006-08-30 12:11:59-07:00, acurtis@stripped +2 -0
    new error message for auto-increment

# 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.79/include/my_base.h	2006-08-30 12:12:13 -07:00
+++ 1.80/include/my_base.h	2006-08-30 12:12:13 -07:00
@@ -357,8 +357,10 @@
 #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_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_LAST              161  /*Copy last error nr.*/
+#define HA_ERR_LAST              163  /*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-08-30 12:12:13 -07:00
+++ 1.162/sql/ha_berkeley.cc	2006-08-30 12:12:13 -07:00
@@ -953,7 +953,10 @@
   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 ((error= update_auto_increment()))
+      DBUG_RETURN(error);
+  }
   if ((error=pack_row(&row, record,1)))
     DBUG_RETURN(error); /* purecov: inspected */
 

--- 1.77/sql/ha_heap.cc	2006-08-30 12:12:13 -07:00
+++ 1.78/sql/ha_heap.cc	2006-08-30 12:12:13 -07:00
@@ -176,7 +176,10 @@
   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 ((res= update_auto_increment()))
+      return res;
+  }
   res= heap_write(file,buf);
   if (!res && (++records_changed*HEAP_STATS_UPDATE_THRESHOLD > 
                file->s->records))

--- 1.166/sql/ha_myisam.cc	2006-08-30 12:12:13 -07:00
+++ 1.167/sql/ha_myisam.cc	2006-08-30 12:12:13 -07:00
@@ -316,7 +316,11 @@
     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();
+  {
+    int error;
+    if ((error= update_auto_increment()))
+      return error;
+  }
   return mi_write(file,buf);
 }
 

--- 1.79/sql/ha_myisammrg.cc	2006-08-30 12:12:13 -07:00
+++ 1.80/sql/ha_myisammrg.cc	2006-08-30 12:12:13 -07:00
@@ -139,7 +139,11 @@
   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();
+  {
+    int error;
+    if ((error= update_auto_increment()))
+      return error;
+  }
   return myrg_write(file,buf);
 }
 

--- 1.217/sql/handler.cc	2006-08-30 12:12:13 -07:00
+++ 1.218/sql/handler.cc	2006-08-30 12:12:13 -07:00
@@ -429,6 +429,8 @@
   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_AUTOINC_READ_FAILED,    ER(ER_AUTOINC_READ_FAILED));
+  SETMSG(HA_ERR_AUTOINC_ERANGE,         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);
@@ -1542,7 +1544,10 @@
 
   RETURN
     0	ok
-    1 	get_auto_increment() was called and returned ~(ulonglong) 0
+    HA_ERR_AUTOINC_READ_FAILED
+     	get_auto_increment() was called and returned ~(ulonglong) 0
+    HA_ERR_AUTOINC_ERANGE
+        storing value in field caused strict mode failure.
 
 
   IMPLEMENTATION
@@ -1586,13 +1591,12 @@
     thd->next_insert_id is cleared after it's been used for a statement.
 */
 
-bool handler::update_auto_increment()
+int handler::update_auto_increment()
 {
   ulonglong nr;
   THD *thd= table->in_use;
   struct system_variables *variables= &thd->variables;
   bool auto_increment_field_not_null;
-  bool result= 0;
   DBUG_ENTER("handler::update_auto_increment");
 
   /*
@@ -1616,7 +1620,7 @@
   if (!(nr= thd->next_insert_id))
   {
     if ((nr= get_auto_increment()) == ~(ulonglong) 0)
-      result= 1;                                // Mark failure
+      DBUG_RETURN(HA_ERR_AUTOINC_READ_FAILED);  // Mark failure
 
     if (variables->auto_increment_increment != 1)
       nr= next_insert_id(nr-1, variables);
@@ -1636,6 +1640,7 @@
   if (likely(!table->next_number_field->store((longlong) nr, TRUE)))
     thd->insert_id((ulonglong) nr);
   else
+  if (thd->killed != THD::KILL_BAD_DATA) /* did we fail strict mode? */
   {
     /*
       overflow of the field; we'll use the max value, however we try to
@@ -1646,6 +1651,8 @@
     if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
       thd->insert_id(nr= table->next_number_field->val_int());
   }
+  else
+    DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
 
   /*
     We can't set next_insert_id if the auto-increment key is not the
@@ -1666,7 +1673,7 @@
 
   /* Mark that we generated a new value */
   auto_increment_column_changed=1;
-  DBUG_RETURN(result);
+  DBUG_RETURN(0);
 }
 
 /*
@@ -1863,6 +1870,12 @@
     break;
   case HA_ERR_TABLE_READONLY:
     textno= ER_OPEN_AS_READONLY;
+    break;
+  case HA_ERR_AUTOINC_READ_FAILED:
+    textno= ER_AUTOINC_READ_FAILED;
+    break;
+  case HA_ERR_AUTOINC_ERANGE:
+    textno= ER_WARN_DATA_OUT_OF_RANGE;
     break;
   default:
     {

--- 1.177/sql/handler.h	2006-08-30 12:12:13 -07:00
+++ 1.178/sql/handler.h	2006-08-30 12:12:13 -07:00
@@ -565,7 +565,7 @@
   virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
   int ha_open(const char *name, int mode, int test_if_locked);
   void adjust_next_insert_id_after_explicit_value(ulonglong nr);
-  bool update_auto_increment();
+  int update_auto_increment();
   virtual void print_error(int error, myf errflag);
   virtual bool get_error_message(int error, String *buf);
   uint get_dup_key(int error);
--- New file ---
+++ mysql-test/include/strict_autoinc.inc	06/08/30 12:11:59
#
# Test for strict-mode autoincrement
#

set @org_mode=@@sql_mode;
eval create table t1
(
  `a` tinyint(4) NOT NULL auto_increment,
  primary key (`a`)
) engine = $type ;
set @@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=@org_mode;
insert into t1 values(null);
select * from t1;

drop table t1;

# End of test

--- New file ---
+++ mysql-test/r/strict_autoinc_1myisam.result	06/08/30 12:11:59
set @org_mode=@@sql_mode;
create table t1
(
`a` tinyint(4) NOT NULL auto_increment,
primary key (`a`)
) engine = 'MYISAM'  ;
set @@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=@org_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/strict_autoinc_2innodb.result	06/08/30 12:11:59
set @org_mode=@@sql_mode;
create table t1
(
`a` tinyint(4) NOT NULL auto_increment,
primary key (`a`)
) engine = 'InnoDB'  ;
set @@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=@org_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/strict_autoinc_3heap.result	06/08/30 12:11:59
set @org_mode=@@sql_mode;
create table t1
(
`a` tinyint(4) NOT NULL auto_increment,
primary key (`a`)
) engine = 'MEMORY'  ;
set @@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=@org_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/strict_autoinc_4bdb.result	06/08/30 12:11:59
set @org_mode=@@sql_mode;
create table t1
(
`a` tinyint(4) NOT NULL auto_increment,
primary key (`a`)
) engine = 'BDB'  ;
set @@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=@org_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/strict_autoinc_5ndb.result	06/08/30 12:11:59
set @org_mode=@@sql_mode;
create table t1
(
`a` tinyint(4) NOT NULL auto_increment,
primary key (`a`)
) engine = 'NDB'  ;
set @@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=@org_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/strict_autoinc_1myisam.test	06/08/30 12:11:59
#
# Bug#20573 Strict mode auto-increment
#

let $type= 'MYISAM' ;
--source include/strict_autoinc.inc

# end of test

--- New file ---
+++ mysql-test/t/strict_autoinc_2innodb.test	06/08/30 12:11:59
-- source include/have_innodb.inc

#
# Bug#20573 Strict mode auto-increment
#

let $type= 'InnoDB' ;
--source include/strict_autoinc.inc

# end of test

--- New file ---
+++ mysql-test/t/strict_autoinc_3heap.test	06/08/30 12:11:59
#
# Bug#20573 Strict mode auto-increment
#

let $type= 'MEMORY' ;
--source include/strict_autoinc.inc

# end of test

--- New file ---
+++ mysql-test/t/strict_autoinc_4bdb.test	06/08/30 12:11:59
-- source include/have_bdb.inc

#
# Bug#20573 Strict mode auto-increment
#

let $type= 'BDB' ;
--source include/strict_autoinc.inc

# end of test

--- New file ---
+++ mysql-test/t/strict_autoinc_5ndb.test	06/08/30 12:11:59
-- source include/have_ndb.inc

#
# Bug#20573 Strict mode auto-increment
#

let $type= 'NDB' ;
--source include/strict_autoinc.inc

# end of test


--- 1.68/sql/share/errmsg.txt	2006-08-30 12:12:13 -07:00
+++ 1.69/sql/share/errmsg.txt	2006-08-30 12:12:13 -07:00
@@ -5623,3 +5623,5 @@
 	eng "Triggers can not be created on system tables"
 ER_REMOVED_SPACES
         eng "Leading spaces are removed from name '%s'"
+ER_AUTOINC_READ_FAILED
+        eng "Failed to read auto-increment value from storage engine"

--- 1.275/sql/ha_ndbcluster.cc	2006-08-30 12:12:13 -07:00
+++ 1.276/sql/ha_ndbcluster.cc	2006-08-30 12:12:13 -07:00
@@ -2130,9 +2130,11 @@
     if (has_auto_increment) 
     {
       THD *thd= table->in_use;
+      int error;
       
       m_skip_auto_increment= FALSE;
-      update_auto_increment();
+      if ((error= update_auto_increment()))
+        DBUG_RETURN(error);
       /* Ensure that handler is always called for auto_increment values */
       thd->next_insert_id= 0;
       m_skip_auto_increment= !auto_increment_column_changed;

--- 1.298/sql/ha_innodb.cc	2006-08-30 12:12:13 -07:00
+++ 1.299/sql/ha_innodb.cc	2006-08-30 12:12:13 -07:00
@@ -3252,7 +3252,8 @@
 		/* We must use the handler code to update the auto-increment
                 value to be sure that we increment it correctly. */
 
-    		update_auto_increment();
+    		if ((error= update_auto_increment()))
+			goto func_exit;
                 auto_inc_used = 1;
 
 	}
Thread
bk commit into 5.0 tree (acurtis:1.2252) BUG#20573antony30 Aug