Bug #119140 DISTINCT works inconsistently in normal SELECT and prepared statement for 0 and -0
Submitted: 13 Oct 8:01
Reporter: chi zhang Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:9.4.0 OS:Any
Assigned to: CPU Architecture:Any

[13 Oct 8:01] chi zhang
Description:
Hi,

In the following test case, there are two equivalent queries, one is a normal SELECT, and the other is a prepared statement. But they have different results.

```
CREATE TABLE t2(c0 DOUBLE) ;
INSERT INTO t2(c0) VALUES(0), ("-0.0");
SELECT DISTINCT IF((NULL) NOT IN (t2.c0), "1", NULL) AS ref0, t2.c0 AS ref1 FROM t2;
-- NULL    0

SET @a = NULL;
SET @b = NULL;
PREPARE prepare_query FROM 'SELECT DISTINCT IF((?) NOT IN (t2.c0), "1", ?) AS ref0, t2.c0 AS ref1  FROM t2';
EXECUTE prepare_query USING @a,@b;
-- NULL    0
-- NULL    -0
```

How to repeat:
```
CREATE TABLE t2(c0 DOUBLE) ;
INSERT INTO t2(c0) VALUES(0), ("-0.0");
SELECT DISTINCT IF((NULL) NOT IN (t2.c0), "1", NULL) AS ref0, t2.c0 AS ref1 FROM t2;
-- NULL    0

SET @a = NULL;
SET @b = NULL;
PREPARE prepare_query FROM 'SELECT DISTINCT IF((?) NOT IN (t2.c0), "1", ?) AS ref0, t2.c0 AS ref1  FROM t2';
EXECUTE prepare_query USING @a,@b;
-- NULL    0
-- NULL    -0
```