Commit 8204f690 authored by unknown's avatar unknown
Browse files

Bug #13323

Select count(*) returned 2 on empty table where handler
used exact count


mysql-test/r/partition.result:
  New test case for Bug #13323
mysql-test/t/partition.test:
  New test case for Bug #13323
sql/ha_partition.cc:
  Fix for Bug #13323
parent a5b52c45
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ b int not null,
c int not null,
primary key(a,b))
partition by key (a);
select count(*) from t1;
count(*)
0
drop table t1;
CREATE TABLE t1 (
a int not null,
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ c int not null,
primary key(a,b))
partition by key (a);

#
# Bug 13323: Select count(*) on empty table returns 2
#
select count(*) from t1;

drop table t1;
#
# Partition by key no partition, list of fields
+9 −2
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ static handlerton partition_hton = {
  NULL, /* recover */
  NULL, /* commit_by_xid */
  NULL, /* rollback_by_xid */
  NULL,
  NULL,
  NULL,
  HTON_NO_FLAGS
};

@@ -2305,9 +2308,13 @@ void ha_partition::info(uint flag)
      if (file->check_time > check_time)
	check_time= file->check_time;
    } while (*(++file_array));
    if (records < 2)
    if (records < 2 &&
        m_table_flags & HA_NOT_EXACT_COUNT)
      records= 2;
    if (records > 0)
      mean_rec_length= (ulong) (data_file_length / records);
    else
      mean_rec_length= 1; //? What should we set here 
  }
  if (flag & HA_STATUS_CONST)
  {