diff options
author | Ole John Aske <ole.john.aske@oracle.com> | 2011-02-01 13:20:16 +0100 |
---|---|---|
committer | Ole John Aske <ole.john.aske@oracle.com> | 2011-02-01 13:20:16 +0100 |
commit | 59269b1da1552ae21e935c04588844c573e9c0c3 (patch) | |
tree | 34f43dd47d12582d52644c40d2282a6f2d8854dd /mysql-test/include | |
parent | 2d2f80e07e858f157a0823c5e886c3589cd1a435 (diff) | |
download | mariadb-git-59269b1da1552ae21e935c04588844c573e9c0c3.tar.gz |
Fix for bug#57030: ('BETWEEN' evaluation is incorrect')
Root cause for this bug is that the optimizer try to detect&
optimize the special case:
'<field> BETWEEN c1 AND c1' and handle this as the condition '<field> = c1'
This was implemented inside add_key_field(.. *field, *value[]...)
which assumed field to refer key Field, and value[] to refer a [low...high]
constant pair. value[0] and value[1] was then compared for equality.
In a 'normal' BETWEEN condition of the form '<field> BETWEEN val1 and val2' the
BETWEEN operation is represented with an argementlist containing the
values [<field>, val1, val2] - add_key_field() is then called with
parameters field=<field>, *value=val1.
However, if the BETWEEN predicate specified:
1) '<const1> BETWEEN<const2> AND<field>
the 'field' and 'value' arguments to add_key_field() had to be swapped.
This was implemented by trying to cheat add_key_field() to handle it like:
2) '<const1> GE<const2> AND<const1> LE<field>'
As we didn't really replace the BETWEEN operation with 'ge' and 'le',
add_key_field() still handled it as a 'BETWEEN' and compared the (swapped)
arguments<const1> and<const2> for equality. If they was equal, the
condition 1) was incorrectly 'optimized' to:
3) '<field> EQ <const1>'
This fix moves this optimization of '<field> BETWEEN c1 AND c1' into
add_key_fields() which then calls add_key_equal_fields() to collect
key equality / comparison for the key fields in the BETWEEN condition.
Diffstat (limited to 'mysql-test/include')
0 files changed, 0 insertions, 0 deletions