Commit 44a2ccc1 authored by unknown's avatar unknown
Browse files

Bug #16782: Partitions: crash, REPLACE .. on table with PK, DUPLICATE

KEY event. Partitioning wrongly claimed to be able to handle HA_DUPP_POS
when it was supported by the underlying storage engine, which resulted
in a crash when handling REPLACE statements.


mysql-test/r/partition.result:
  Add new results
mysql-test/t/partition.test:
  Add regression test
sql/ha_partition.cc:
  Fix list of table flags that are not passed through for partitioned
  tables, and add HA_DUPP_POS to that list. Also, handle HA_EXTRA_FLUSH_CACHE
  in ha_partition::extra().
parent fe98fef9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -278,3 +278,9 @@ partition p1 values in (14)
insert into t1 values (10,1);
ERROR HY000: Table has no partition for value 11
drop table t1;
create table t1 (f_int1 integer, f_int2 integer, primary key (f_int1))
partition by hash(f_int1) partitions 2;
insert into t1 values (1,1),(2,2);
replace into t1 values (1,1),(2,2);
drop table t1;
End of 5.1 tests
+10 −0
Original line number Diff line number Diff line
@@ -353,3 +353,13 @@ insert into t1 values (10,1);

drop table t1;

#
# Bug #16782: Crash using REPLACE on table with primary key
#
create table t1 (f_int1 integer, f_int2 integer, primary key (f_int1))
  partition by hash(f_int1) partitions 2;
insert into t1 values (1,1),(2,2);
replace into t1 values (1,1),(2,2);
drop table t1;

--echo End of 5.1 tests
+4 −3
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ int ha_partition::ha_initialise()
    other parameters are calculated on demand.
    HA_FILE_BASED is always set for partition handler since we use a
    special file for handling names of partitions, engine types.
    HA_CAN_GEOMETRY, HA_CAN_FULLTEXT, HA_CAN_SQL_HANDLER,
    HA_CAN_GEOMETRY, HA_CAN_FULLTEXT, HA_CAN_SQL_HANDLER, HA_DUPP_POS,
    HA_CAN_INSERT_DELAYED is disabled until further investigated.
  */
  m_table_flags= m_file[0]->table_flags();
@@ -382,8 +382,8 @@ int ha_partition::ha_initialise()
      m_pkey_is_clustered= FALSE;
    m_table_flags&= file->table_flags();
  } while (*(++file_array));
  m_table_flags&= ~(HA_CAN_GEOMETRY & HA_CAN_FULLTEXT &
                    HA_CAN_SQL_HANDLER & HA_CAN_INSERT_DELAYED);
  m_table_flags&= ~(HA_CAN_GEOMETRY | HA_CAN_FULLTEXT | HA_DUPP_POS |
                    HA_CAN_SQL_HANDLER | HA_CAN_INSERT_DELAYED);
  m_table_flags|= HA_FILE_BASED | HA_REC_NOT_IN_SEQ;
  DBUG_RETURN(0);
}
@@ -4688,6 +4688,7 @@ int ha_partition::extra(enum ha_extra_function operation)
  case HA_EXTRA_PREPARE_FOR_UPDATE:
  case HA_EXTRA_PREPARE_FOR_DELETE:
  case HA_EXTRA_FORCE_REOPEN:
  case HA_EXTRA_FLUSH_CACHE:
  {
    if (m_myisam)
      DBUG_RETURN(loop_extra(operation));