[MDEV-14476] Integer overflow when using 9223372036854775808 as a LIMIT parameter Created: 2017-11-23  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Data types, Prepared Statements, Stored routines
Affects Version/s: 10.2, 10.3
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-14467 Item_param: replace {INT|DECIMAL|REAL... Closed
relates to MDEV-14498 PS: Wrong value for CAST(? AS DOUBLE)... Open

 Description   

DELIMITER $$
BEGIN NOT ATOMIC
  DECLARE a DECIMAL(30,0) DEFAULT 9223372036854775808;
  EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT 1 LIMIT ?' USING a;
END;
$$
DELIMITER ;
SHOW WARNINGS;

+---------+------+----------------------------------------------------------------------------+
| Level   | Code | Message                                                                    |
+---------+------+----------------------------------------------------------------------------+
| Warning | 1916 | Got overflow when converting '9223372036854775808' to INT. Value truncated |
| Note    | 1003 | select 1 AS `1` limit 9223372036854775807                                  |
+---------+------+----------------------------------------------------------------------------+

Notice, the value was truncated to the maximum signed integer. This looks wrong.
It should treat 9223372036854775808 as an unsigned value and preserve it in the LIMIT clause.


Generated at Thu Feb 08 08:13:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.