List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:February 16 2006 8:19pm
Subject:bk commit into 5.1 tree (jimw:1.2122) BUG#14526
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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.2122 06/02/16 12:19:00 jimw@stripped +3 -0
  Bug #14526: Partitions: indexed searches fail. When inserting a row into
  a partitioned table, the value of auto_increment fields was not calculated
  until after deciding what partition to add the row into, which led to rows
  being written to the wrong partitions (or spurious errors).

  sql/ha_partition.cc
    1.31 06/02/16 12:18:56 jimw@stripped +13 -11
    Fix notes about, and handling of, auto_increment in ha_partition::write_row().
    We have to decide on an auto_increment value before we can figure out which
    partition the rows should be inserted into.

  mysql-test/t/partition.test
    1.16 06/02/16 12:18:56 jimw@stripped +12 -0
    Add new regression test

  mysql-test/r/partition.result
    1.15 06/02/16 12:18:56 jimw@stripped +18 -0
    Add new results

# 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.1-14526

--- 1.14/mysql-test/r/partition.result	2006-02-15 17:01:27 -08:00
+++ 1.15/mysql-test/r/partition.result	2006-02-16 12:18:56 -08:00
@@ -312,4 +312,22 @@
 insert into t1 values (1,1),(2,2);
 replace into t1 values (1,1),(2,2);
 drop table t1;
+create table t2 (s1 int not null auto_increment, primary key (s1)) partition by list (s1) (partition p1 values in (1),partition p2 values in (2),partition p3 values in (3),partition p4 values in (4));
+insert into t2 values (null),(null),(null);
+select * from t2;
+s1
+1
+2
+3
+select * from t2 where s1 < 2;
+s1
+1
+update t2 set s1 = s1 + 1 order by s1 desc;
+select * from t2 where s1 < 3;
+s1
+2
+select * from t2 where s1 = 2;
+s1
+2
+drop table t2;
 End of 5.1 tests

--- 1.15/mysql-test/t/partition.test	2006-02-15 17:01:27 -08:00
+++ 1.16/mysql-test/t/partition.test	2006-02-16 12:18:56 -08:00
@@ -401,4 +401,16 @@
 replace into t1 values (1,1),(2,2);
 drop table t1;
 
+#
+# Bug #14526: Partitions: indexed searches fail
+#
+create table t2 (s1 int not null auto_increment, primary key (s1)) partition by list (s1) (partition p1 values in (1),partition p2 values in (2),partition p3 values in (3),partition p4 values in (4));
+insert into t2 values (null),(null),(null);
+select * from t2;
+select * from t2 where s1 < 2;
+update t2 set s1 = s1 + 1 order by s1 desc;
+select * from t2 where s1 < 3;
+select * from t2 where s1 = 2;
+drop table t2;
+
 --echo End of 5.1 tests

--- 1.30/sql/ha_partition.cc	2006-02-15 11:37:45 -08:00
+++ 1.31/sql/ha_partition.cc	2006-02-16 12:18:56 -08:00
@@ -2600,22 +2600,13 @@
     ha_berkeley.cc has a variant of how to store it intact by "packing" it
     for ha_berkeley's own native storage type.
 
-    See the note for update_row() on auto_increments and timestamps. This
-    case also applied to write_row().
-
     Called from item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc,
     sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc.
 
     ADDITIONAL INFO:
 
-    Most handlers set timestamp when calling write row if any such fields
-    underlying handler will assume this responsibility.
-
-    Underlying handlers will also call update_auto_increment to calculate
-    the new auto increment value. We will catch the call to
-    get_auto_increment and ensure this increment value is maintained by
-    only one of the underlying handlers.
+    We have to set timestamp fields and auto_increment fields, because those
+    may be used in determining which partition the row should be written to.
 */
 
 int ha_partition::write_row(byte * buf)
@@ -2628,6 +2619,17 @@
 #endif
   DBUG_ENTER("ha_partition::write_row");
   DBUG_ASSERT(buf == m_rec0);
+
+  /* If we have a timestamp column, update it to the current time */
+  if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
+    table->timestamp_field->set_time();
+
+  /*
+    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();
 
 #ifdef NOT_NEEDED
   if (likely(buf == rec0))
Thread
bk commit into 5.1 tree (jimw:1.2122) BUG#14526Jim Winstead16 Feb