Commit 93f4daf1 authored by unknown's avatar unknown
Browse files

BUG#18198: Partition function handling

Fixes of after review fixes


mysql-test/r/partition_hash.result:
  Fixed test cases
mysql-test/r/partition_range.result:
  Fixed test cases
mysql-test/t/partition_range.test:
  Fixed test cases
sql/ha_ndbcluster.cc:
  Fixed error printout to avoid complex character set code in print_error
sql/ha_partition.cc:
  Fixed error printout to avoid complex character set code in print_error
sql/partition_info.cc:
  Fixed error printout to avoid complex character set code in print_error
sql/partition_info.h:
  Fixed error printout to avoid complex character set code in print_error
sql/sql_partition.cc:
  indendentation fix
parent d8e3aebe
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
drop table if exists t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin)
partition by hash(length(a))
partitions 10;
insert into t1 values (''),(' '),('a'),('a '),('a  ');
explain partitions select * from t1 where a='a ';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
explain partitions select * from t1 where a='a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
explain partitions select * from t1 where a='a ' OR a='a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
drop table t1;
create table t1 (a int unsigned)
partition by hash(a div 2)
partitions 4;
+6 −6
Original line number Diff line number Diff line
drop table if exists t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (b* length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(b) * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(a) * length(b))
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (length(a) * c)
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  ', 2),('a','b', 3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (c * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  ', 2),('a','b', 3);
drop table t1;
create table t1 (a int unsigned)
+6 −6
Original line number Diff line number Diff line
@@ -14,41 +14,41 @@ drop table if exists t1;
#
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;

create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (b* length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;

create table t1 (a varchar(10) charset latin1 collate latin1_bin,
                 b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(b) * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  '),('a','b');
drop table t1;

create table t1 (a varchar(10) charset latin1 collate latin1_bin,
                 b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(a) * length(b))
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  '),('a','b');
drop table t1;

create table t1 (a varchar(10) charset latin1 collate latin1_bin,
                 b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (length(a) * c)
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  ', 2),('a','b', 3);
drop table t1;

create table t1 (a varchar(10) charset latin1 collate latin1_bin,
                 b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (c * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b  ', 2),('a','b', 3);
drop table t1;

+7 −0
Original line number Diff line number Diff line
@@ -1899,7 +1899,10 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record)
      error= m_part_info->get_partition_id(m_part_info, &part_id, &func_value);
      dbug_tmp_restore_column_map(table->read_set, old_map);
      if (error)
      {
        m_part_info->err_value= func_value;
        DBUG_RETURN(error);
      }
      op->setPartitionId(part_id);
    }
  }
@@ -2534,7 +2537,10 @@ int ha_ndbcluster::write_row(byte *record)
    error= m_part_info->get_partition_id(m_part_info, &part_id, &func_value);
    dbug_tmp_restore_column_map(table->read_set, old_map);
    if (error)
    {
      m_part_info->err_value= func_value;
      DBUG_RETURN(error);
    }
    op->setPartitionId(part_id);
  }

@@ -2726,6 +2732,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
                                   m_part_info, &old_part_id, &new_part_id,
                                   &func_value)))
  {
    m_part_info->err_value= func_value;
    DBUG_RETURN(error);
  }

+4 −0
Original line number Diff line number Diff line
@@ -2670,7 +2670,10 @@ int ha_partition::write_row(byte * buf)
#endif
  dbug_tmp_restore_column_map(table->read_set, old_map);
  if (unlikely(error))
  {
    m_part_info->err_value= func_value;
    DBUG_RETURN(error);
  }
  m_last_part= part_id;
  DBUG_PRINT("info", ("Insert in partition %d", part_id));
  DBUG_RETURN(m_file[part_id]->write_row(buf));
@@ -2719,6 +2722,7 @@ int ha_partition::update_row(const byte *old_data, byte *new_data)
                                   m_part_info, &old_part_id, &new_part_id,
                                   &func_value)))
  {
    m_part_info->err_value= func_value;
    DBUG_RETURN(error);
  }

Loading