Commit d933cb16 authored by Satya B's avatar Satya B

Fix for BUG#45816 - assertion failure with index containing double

                    column on partitioned table
      
      
An assertion 'ASSERT_COULUMN_MARKED_FOR_READ' is failed if the query 
is executed with index containing double column on partitioned table.
The problem is that assertion expects all the fields which are read,
to be in the read_set.
      
In this query only the field 'a' is in the readset as the tables in
the query are joined by the field 'a' and so the assertion fails 
expecting other field 'b'.
      
Since the function cmp() is just comparison of two parameters passed, 
the assertion is not required.
      
Fixed by removing the assertion in the double fields comparision
function and also fixed the index initialization to do ordered
index scan with RW LOCK which ensures all the fields from a key are in
the read_set.
 

Note: this bug is not reproducible with other datatypes because the
      assertion doesn't exist in comparision function for other 
      datatypes.

mysql-test/r/partition.result:
  Testcase for BUG#45816
mysql-test/t/partition.test:
  Testcase for BUG#45816
sql/field.cc:
  Removed the assertion ASSERT_COLUMN_MARED_FOR_READ in Field_double::cmp()
  function
sql/ha_partition.cc:
  Fixed index_int() method to make it initialize the read_set properly if
  ordered index scan with RW lock is requested.
parent 70cd9772
...@@ -1985,4 +1985,23 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM ...@@ -1985,4 +1985,23 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
PARTITION BY HASH(id) PARTITIONS 2; PARTITION BY HASH(id) PARTITIONS 2;
DROP TABLE t1; DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT; SET SESSION SQL_MODE=DEFAULT;
#
# BUG#45816 - assertion failure with index containing double
# column on partitioned table
#
CREATE TABLE t1 (
a INT DEFAULT NULL,
b DOUBLE DEFAULT NULL,
c INT DEFAULT NULL,
KEY idx2(b,a)
) PARTITION BY HASH(c) PARTITIONS 3;
INSERT INTO t1 VALUES (6,8,9);
INSERT INTO t1 VALUES (6,8,10);
SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
1
1
1
1
1
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
...@@ -1979,4 +1979,23 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM ...@@ -1979,4 +1979,23 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
DROP TABLE t1; DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT; SET SESSION SQL_MODE=DEFAULT;
--echo #
--echo # BUG#45816 - assertion failure with index containing double
--echo # column on partitioned table
--echo #
CREATE TABLE t1 (
a INT DEFAULT NULL,
b DOUBLE DEFAULT NULL,
c INT DEFAULT NULL,
KEY idx2(b,a)
) PARTITION BY HASH(c) PARTITIONS 3;
INSERT INTO t1 VALUES (6,8,9);
INSERT INTO t1 VALUES (6,8,10);
SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -4598,7 +4598,6 @@ bool Field_double::send_binary(Protocol *protocol) ...@@ -4598,7 +4598,6 @@ bool Field_double::send_binary(Protocol *protocol)
int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr) int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr)
{ {
ASSERT_COLUMN_MARKED_FOR_READ;
double a,b; double a,b;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first) if (table->s->db_low_byte_first)
......
...@@ -3730,7 +3730,7 @@ int ha_partition::index_init(uint inx, bool sorted) ...@@ -3730,7 +3730,7 @@ int ha_partition::index_init(uint inx, bool sorted)
*/ */
if (m_lock_type == F_WRLCK) if (m_lock_type == F_WRLCK)
bitmap_union(table->read_set, &m_part_info->full_part_field_set); bitmap_union(table->read_set, &m_part_info->full_part_field_set);
else if (sorted) if (sorted)
{ {
/* /*
An ordered scan is requested. We must make sure all fields of the An ordered scan is requested. We must make sure all fields of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment