Bug #119160 Found different values set for sql_buffer_result and materialization lead to different query results.

Submitted: 15 Oct 2025 9:32 Modified: 13 Jan 11:27
Reporter: david silva Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.41 OS:Any
Assigned to: CPU Architecture:Any
Tags: SQL_BUFFER_RESULT

[15 Oct 2025 9:32] david silva
Description:
the results of the two queries below are inconsistent.

mysql> SET SESSION sql_buffer_result = ON;
Query OK, 0 rows affected (0.00 sec)

mysql> SET optimizer_switch = 'materialization=off';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT t0.c5 FROM t0, t2 WHERE (((t0.c5) IN (select c5 from tmp_t0)) IN ((48085430) IN (t0.c1))) IN (((t0.c9) IN (t2.c2)));
+------+
| c5   |
+------+
| r    |
+------+
1 row in set (0.00 sec)

mysql> SET SESSION sql_buffer_result = Off;
Query OK, 0 rows affected (0.00 sec)

mysql> SET optimizer_switch = 'materialization=on';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT t0.c5 FROM t0, t2 WHERE (((t0.c5) IN (select c5 from tmp_t0)) IN ((48085430) IN (t0.c1))) IN (((t0.c9) IN (t2.c2)));
Empty set (0.01 sec)

How to repeat:
CREATE TABLE `t0` (
  `c1` float  DEFAULT NULL,
  `c5` varchar(500)  DEFAULT NULL,
  `c9` decimal(10,0) unsigned zerofill  DEFAULT NULL
);

INSERT INTO `t0` VALUES(0.286385,'r',0);
CREATE TABLE `t2` (
  `c2` float
);
INSERT INTO `t2` VALUES (0.615793);

create table tmp_t0(c5 varchar(500));
insert into tmp_t0 values(NULL), ('0.1002505534510798');

SET SESSION sql_buffer_result = ON;
SET optimizer_switch = 'materialization=off';
SELECT t0.c5 FROM t0, t2 WHERE (((t0.c5) IN (select c5 from tmp_t0)) IN ((48085430) IN (t0.c1))) IN (((t0.c9) IN (t2.c2)));

SET SESSION sql_buffer_result = Off;
SET optimizer_switch = 'materialization=on';
SELECT t0.c5 FROM t0, t2 WHERE (((t0.c5) IN (select c5 from tmp_t0)) IN ((48085430) IN (t0.c1))) IN (((t0.c9) IN (t2.c2)));
[13 Jan 11:27] Øystein Grøvlen
Thank you for the bug report.
Verified as described.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.