Description:
Two tables containing identical data produce different query results depending on whether a `UNIQUE` constraint is defined.
When the column `c0` has a `UNIQUE` constraint, the query returns one row. However, when the constraint is removed (while keeping the table data identical), the same query returns an empty set.
The issue appears to be related to how the optimizer evaluates the `SUBTIME(1, c1)` expression in the `HAVING` clause, where `c1` is an alias for `SYSDATE()`.
Since the table contents are identical in both cases, the query result should be consistent regardless of index constraints.
How to repeat:
Case 1: Table with `UNIQUE` constraint
```sql
DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
USE test;
CREATE TABLE t0(
c0 DOUBLE UNIQUE,
c1 VARCHAR(500)
);
INSERT INTO t0(c0) VALUES(1);
SELECT SYSDATE() AS c1
FROM t0 AS tom0
GROUP BY tom0.c0
HAVING SUBTIME(1, c1);
```
Result:
```
+---------------------+
| c1 |
+---------------------+
| 2026-03-11 13:29:24 |
+---------------------+
1 row in set
```
Case 2: Table without `UNIQUE` constraint (same data)
```sql
DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
USE test;
CREATE TABLE t0(
c0 DOUBLE,
c1 VARCHAR(500)
);
INSERT INTO t0(c0) VALUES(1);
SELECT SYSDATE() AS c1
FROM t0 AS tom0
GROUP BY tom0.c0
HAVING SUBTIME(1, c1);
```
Result:
```
Empty set
```
The two tables contain identical data, so the query result should be the same.