Bug #44372 bug 22125 affects handler::index_next_same in 5.1
Submitted: 20 Apr 2009 20:17 Modified: 31 Jul 2009 8:19
Reporter: Zardosht Kasheff (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.30, 5.1 bzr OS:Any
Assigned to: CPU Architecture:Any

[20 Apr 2009 20:17] Zardosht Kasheff
Description:
running falcon_bug_22125 on a storage engine that does NOT implement ::index_next_same (and as a result uses handler::index_next_same), the error described in 22125 is reproduced.

How to repeat:
run falcon_bug_22125 on 5.1.30 using a storage engine that does NOT implement index_next_same on 5.1.30
[31 Jul 2009 8:19] Sveta Smirnova
Thank you for the report.

Verified as described.

To repeat apply patch following to 5.1 tree:

$bzr diff
=== modified file 'storage/myisam/ha_myisam.cc'
--- storage/myisam/ha_myisam.cc 2009-07-08 12:11:34 +0000
+++ storage/myisam/ha_myisam.cc 2009-07-31 08:07:33 +0000
@@ -1724,7 +1724,7 @@
   return error;
 }
 
-int ha_myisam::index_next_same(uchar *buf,
+int ha_myisam::index_next_same1(uchar *buf,
                               const uchar *key __attribute__((unused)),
                               uint length __attribute__((unused)))
 {

=== modified file 'storage/myisam/ha_myisam.h'
--- storage/myisam/ha_myisam.h  2009-07-08 12:11:34 +0000
+++ storage/myisam/ha_myisam.h  2009-07-31 08:07:20 +0000
@@ -75,7 +75,7 @@
   int index_prev(uchar * buf);
   int index_first(uchar * buf);
   int index_last(uchar * buf);
-  int index_next_same(uchar *buf, const uchar *key, uint keylen);
+  int index_next_same1(uchar *buf, const uchar *key, uint keylen);
   int ft_init()
   {
     if (!ft_handler)

Then modify test as following:

$cat t/falcon_bug_22125.test 
#
# Bug #22125: Falcon: Double precision searches fail if index exists
#
--echo *** Bug #22125 ***

# ----------------------------------------------------- #
# --- Initialisation                                --- #
# ----------------------------------------------------- #
#let $engine = 'Falcon';
let $engine = 'MyISAM';
eval SET @@storage_engine = $engine;

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1 (
  f1 double,
  f2 char(5),
  f3 double,
  f4 int
);

INSERT INTO t1 VALUES (0,'zero',0,1);
INSERT INTO t1 VALUES (1.7976931348623157E+308,'max',0,3);
INSERT INTO t1 VALUES (1.7976931348623157E+308,'min',0,4);

UPDATE t1 SET f1 = 1 / f1 WHERE f2 = 'min';

INSERT INTO t1 VALUES (1.7976931348623157E+308,'nan',0,5);
INSERT INTO t1 VALUES (1.7976931348623157E+308,'inf',0,6);
INSERT INTO t1 SELECT -f1,concat('-',f2),f3,-f4 FROM t1;

UPDATE t1 SET f3 = -f3 WHERE f2 = '-nan';

CREATE INDEX it1 on t1 (f1);

# ----------------------------------------------------- #
# --- Test                                          --- #
# ----------------------------------------------------- #
SELECT * FROM t1 ORDER BY f1,f2,f3,f4;
SELECT count(*) FROM t1 where f1 = 0;
SELECT count(*) FROM t1 where f1 < 1;

# Without index we get correct count.
DROP INDEX it1 ON t1;
SELECT count(*) FROM t1 where f1 = 0;
SELECT count(*) FROM t1 where f1 < 1;

# ----------------------------------------------------- #
# --- Check                                         --- #
# ----------------------------------------------------- #
SELECT count(*) FROM t1;

# ----------------------------------------------------- #
# --- Final cleanup                                 --- #
# ----------------------------------------------------- #
DROP TABLE t1;

Get -0 and wrong count in result