Description:
For `SELECT DISTINCT <cols> FROM ... GROUP BY <same cols> ORDER BY ...`, when one of the columns is a boolean `||` (logical OR — no `PIPES_AS_CONCAT`) expression over a column read through a **merged VIEW**, and the `FROM` involves a join, MySQL's post-`GROUP BY` `DISTINCT` step silently omits that expression from its own deduplication key. Please see the repro
How to repeat:
CREATE TABLE t (c_pk BIGINT NOT NULL, c_txt VARCHAR(255), c_chr VARCHAR(255));
INSERT INTO t VALUES (1, NULL, NULL);
INSERT INTO t VALUES (2, 'a', 'a');
INSERT INTO t VALUES (3, 'o''brien', '');
INSERT INTO t VALUES (4, NULL, 'Zed');
CREATE VIEW t0 AS SELECT * FROM t;
SELECT a.c_pk, (t0.c_txt||t0.c_chr) FROM t a, t0 GROUP BY a.c_pk, (t0.c_txt||t0.c_chr) ORDER BY a.c_pk;
-- => (1,NULL),(1,0),(2,NULL),(2,0),(3,NULL),(3,0),(4,NULL),(4,0)
-- expected result
SELECT DISTINCT a.c_pk, (t0.c_txt||t0.c_chr) FROM t a, t0 GROUP BY a.c_pk, (t0.c_txt||t0.c_chr) ORDER BY a.c_pk;
-- => (1,NULL),(2,NULL),(3,NULL),(4,NULL)
-- unexpected results after adding DISTINCT, which should be the same 8 rows as the above query