2967 lars-erik.bjork@stripped 2009-01-21
This is a fix for Bug#42196
Issue with key look up for bit field in Falcon table after insert + stored func
This bug was already partly fixed by the patch for #40607 and #41582,
but some additional cleaning and testing is necessary. The problem was
that the old implementation of StorageDatabase::getSegmentValue would
choose code paths depending on 'segment->isUnsigned' when extracting
the value from keys of type HA_KEYTYPE_BINARY. 'segment->isUnsigned'
was set in StorageInterface::getKeyDesc in the following way, when
creating the index:
segment->isUnsigned = (part->field->flags & ENUM_FLAG) ?
true : ((Field_num*) part->field)->unsigned_flag;
The BIT type (class Field_bit_as_char) is not a subclass of Field_num,
which this is casted to, and has no 'unsigned_flag'. For BITs,
segment->isUnsigned would therefore contain more or less random
data. In the cases where this random data was '0', the bug would
occur.
The previously mentioned patch removed the need to check on
segment->isUnsiged. This patch removes the flag from the
StorageSegment altogether, as well as adding a test for the bug.
Modified file 'storage/falcon/StorageTableShare.h'
--------------------------------------------------
Removed 'isUnsigned' from the StorageSegment
Modified file 'storage/falcon/ha_falcon.cpp'
--------------------------------------------------
Removed the usage of 'segment->isUnsigned'
Added file 'mysql-test/suite/falcon/t/falcon_bug_42196.test'
--------------------------------------------------------------
Added a test for the bug, based on the report
Added file 'mysql-test/suite/falcon/r/falcon_bug_42196.result'
--------------------------------------------------------------
The expected output of the test
added:
mysql-test/suite/falcon/r/falcon_bug_42196.result
mysql-test/suite/falcon/t/falcon_bug_42196.test
modified:
storage/falcon/StorageTableShare.h
storage/falcon/ha_falcon.cpp
2966 lars-erik.bjork@stripped 2009-01-21 [merge]
Merging ...
modified:
mysql-test/suite/falcon/r/falcon_online_index.result
mysql-test/suite/falcon/t/falcon_online_index.test
storage/falcon/Record.h
storage/falcon/SRLUpdateRecords.cpp
storage/falcon/SRLUpdateRecords.h
storage/falcon/Table.cpp
storage/falcon/Table.h
=== added file 'mysql-test/suite/falcon/r/falcon_bug_42196.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_42196.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_42196.result 2009-01-21 16:48:25 +0000
@@ -0,0 +1,18 @@
+*** Bug #42196 ***
+SET @@storage_engine = 'Falcon';
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+CREATE TABLE t1 (s1 bit(3), key(s1));
+CREATE FUNCTION f1() RETURNS int RETURN 1;
+INSERT INTO t1 VALUES (2*f1());
+SELECT s1+0 FROM t1 WHERE s1 = 2;
+s1+0
+2
+SELECT s1+0 from t1;
+s1+0
+2
+SELECT count(*) FROM t1;
+count(*)
+1
+DROP TABLE t1;
+DROP FUNCTION f1;
=== added file 'mysql-test/suite/falcon/t/falcon_bug_42196.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_42196.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_42196.test 2009-01-21 16:48:25 +0000
@@ -0,0 +1,42 @@
+--source include/have_falcon.inc
+
+#
+# Bug #42196: Issue with key look up for bit field in Falcon table after insert + stored func
+#
+--echo *** Bug #42196 ***
+
+# ----------------------------------------------------- #
+# --- Initialisation --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+# ----------------------------------------------------- #
+# --- Test --- #
+# ----------------------------------------------------- #
+
+CREATE TABLE t1 (s1 bit(3), key(s1));
+CREATE FUNCTION f1() RETURNS int RETURN 1;
+INSERT INTO t1 VALUES (2*f1());
+
+# Following tatement failed to return any rows
+SELECT s1+0 FROM t1 WHERE s1 = 2;
+
+# Following statement returns row with value '2'
+SELECT s1+0 from t1;
+
+# ----------------------------------------------------- #
+# --- Check --- #
+# ----------------------------------------------------- #
+SELECT count(*) FROM t1;
+
+# ----------------------------------------------------- #
+# --- Final cleanup --- #
+# ----------------------------------------------------- #
+DROP TABLE t1;
+DROP FUNCTION f1;
=== modified file 'storage/falcon/StorageTableShare.h'
--- a/storage/falcon/StorageTableShare.h 2009-01-20 08:09:02 +0000
+++ b/storage/falcon/StorageTableShare.h 2009-01-21 16:48:25 +0000
@@ -67,7 +67,6 @@ struct StorageSegment {
int offset;
int length;
unsigned char nullBit;
- char isUnsigned;
void *mysql_charset;
};
=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp 2009-01-20 08:09:02 +0000
+++ b/storage/falcon/ha_falcon.cpp 2009-01-21 16:48:25 +0000
@@ -1586,9 +1586,6 @@ void StorageInterface::getKeyDesc(TABLE
segment->length = part->length;
segment->type = part->field->key_type();
segment->nullBit = part->null_bit;
- segment->isUnsigned = (part->field->flags & ENUM_FLAG) ?
- true : ((Field_num*) part->field)->unsigned_flag;
-
segment->mysql_charset = NULL;
// Separate correctly between types that may map to
| Thread |
|---|
| • bzr push into mysql-6.0-falcon-team branch (lars-erik.bjork:2966 to 2967)Bug#42196 | lars-erik.bjork | 21 Jan |