[MDEV-25808] PREPARE/EXECUTE makes signed integer out of unsigned Created: 2021-05-28  Updated: 2021-07-24  Resolved: 2021-07-24

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements, Storage Engine - Spider
Affects Version/s: 10.4.13, 10.3.29, 10.5.10, 10.6.1
Fix Version/s: 10.3.31, 10.4.21, 10.5.12, 10.6.4

Type: Bug Priority: Major
Reporter: Yongxin Xu Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: bug, spider
Environment:

ALL



 Description   

how to repeat:

On Spider:

CREATE TABLE t1 (
  `c1` bigint(20) UNSIGNED DEFAULT NULL
)ENGINE=SPIDER PARTITION BY LIST (`c1` MOD 4)
(PARTITION `pt0` VALUES IN (0)....);
 
insert into t1(c1) values (6800281190650363904), (17864960750176564435);
 
mysql> PREPARE p1 FROM 'select * FROM t1 WHERE c1 = ?';
Query OK, 0 rows affected (0.05 sec)
Statement prepared
 
mysql> EXECUTE p1 USING 17864960750176564435; # BUG HERE
Empty set (0.11 sec)
 
mysql> SELECT * FROM t1 WHERE c1 = 17864960750176564435; # CORRECT HERE
+----------------------+
| c1                   |
+----------------------+
| 17864960750176564435 |
+----------------------+
1 row in set (0.01 sec)



 Comments   
Comment by Sergei Golubchik [ 2021-07-24 ]

The reason here is that Item_param doesn't take the unsigned-ness of the value into account in a string context. Here's a simpler test case:

prepare p1 from 'select concat(?)';
execute p1 using 17864960750176564435;

Same bug in the real context:

prepare p1 from 'select SQRT(?)';
execute p1 using 17864960750176564435;

Generated at Thu Feb 08 09:40:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.