| Bug #119606 | Assertion failure in item_func.cc:3937: !unsigned_flag || !arg_val.is_negative() during JOIN optimization | ||
|---|---|---|---|
| Submitted: | 29 Dec 2025 14:23 | Modified: | 16 Jan 12:43 |
| Reporter: | gelin zhang | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | 8.0.42 | OS: | Linux (Linux (x86_64)) |
| Assigned to: | CPU Architecture: | Any | |
[30 Dec 2025 5:29]
Chaithra Marsur Gopala Reddy
Hi gelin zhang, Thank you for the test case. Verified as described.
[16 Jan 12:43]
Knut Anders Hatlen
Posted by developer: Closing as duplicate of Bug#37083848 (virtual longlong Item_func_min_max::int_op(): Assertion `!unsigned_flag || !arg_val.is_negative()' failed) which was fixed in MySQL 9.2.0.
[21 Jan 20:35]
Jean-François Gagné
From what I see, this bug is fixed in 9.6.0, but not in 8.4.8 nor in 8.0.45 (see test results below). Can we hope for a back-port of the fix in 8.4 and 8.0 ? For reference, this looks like a simple fix, see related commit below. Unclear why this was only fixed in 9.2, but I would think that if this was worth fixing in 9.2, it is probably worth fixing in 8.4 and 8.0 (I did not dive into the impacts of skipping this assert in a release build). https://github.com/mysql/mysql-server/commit/8631ce99fa8ee4f008161c5460a134057489fc42 sql=" DROP TABLE IF EXISTS t1; CREATE TABLE t1 (id INT UNSIGNED NOT NULL); INSERT INTO t1 VALUES(1); SELECT id FROM t1 WHERE LEAST(id, id) AND -1 = id;" for d in msb_mysql_9_6_0 msb_mysql_8_4_8 msb_mysql_8_0_45; do echo ./$d/use -N <<< "select version()" ./$d/use test <<< "$sql" && echo ok done 9.6.0-debug ok 8.4.8-debug ERROR 2013 (HY000) at line 5: Lost connection to MySQL server during query 8.0.45-debug ERROR 2013 (HY000) at line 5: Lost connection to MySQL server during query
[21 Jan 20:58]
Jean-François Gagné
Adding for completeness, Bug#119639 was closed as a duplicate of this bug.

Description: In MySQL 8.0.42, a specific complex query involving CASE, BETWEEN, and EXISTS clauses causes the server to crash with an assertion failure in sql/item_func.cc. Error Message: mysqld: /home/tzx/mysql-server-mysql-8.0.42/sql/item_func.cc:3937: virtual longlong Item_func_min_max::int_op(): Assertion '!unsigned_flag || !arg_val.is_negative()' failed. How to repeat: SELECT t0.c0 AS ref0 FROM t0 WHERE ((('Sazdp') LIKE (273751740)) BETWEEN ((CASE -749309257 WHEN t0.c0 THEN 0.14684209982357677 WHEN t0.c0 THEN NULL WHEN '374833474' THEN NULL ELSE t0.c0 END)) AND ( EXISTS (SELECT 1 wHERE FALSE))) && ((LEAST(t0.c0, t0.c0)) AND ((-2009705112) IN (t0.c0))) UNION ALL SELECT ALL t0.c0 AS ref0 FROM t0 WHERE (NOT (((('Sazdp') LIKE (273751740)) BETWEEN ((CASE -749309257 WHEN t0.c0 THEN 0.14684209982357677 WHEN t0.c0 THEN NULL WHEN '374833474' THEN NULL ELSE t0.c0 END)) AND ( EXISTS (SELECT 1 wHERE FALSE))) && ((LEAST(t0.c0, t0.c0)) AND ((-2009705112) IN (t0.c0))))) UNION ALL SELECT t0.c0 AS ref0 FROM t0 WHERE (((('Sazdp') LIKE (273751740)) BETWEEN ((CASE -749309257 WHEN t0.c0 THEN 0.14684209982357677 WHEN t0.c0 THEN NULL WHEN '374833474' THEN NULL ELSE t0.c0 END)) AND ( EXISTS (SELECT 1 wHERE FALSE))) && ((LEAST(t0.c0, t0.c0)) AND ((-2009705112) IN (t0.c0)))) IS NULL;