SET STORAGE_ENGINE = Falcon;
#
# Bug #22125: Falcon: Double precision searches fail if index exists
#
--echo *** Bug #22125 ***
--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 (1e308*2,'max',0,3);
INSERT INTO t1 VALUES (1e308*2,'min',0,4);

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

INSERT INTO t1 VALUES (1e308*2,'nan',0,5);
INSERT INTO t1 VALUES (1e308*2,'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);

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;

# Final cleanup.
DROP TABLE t1;
