You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hex literals return wrong results in numeric context and text comparisons #575
SELECT 0x1 +0, 5 & 0x1, CAST(0x711 AS UNSIGNED);
CREATETABLEt (id INTPRIMARY KEY, title TEXT, n INT);
INSERT INTO t VALUES (1, 'AB', 1);
SELECTCOUNT(*) FROM t WHERE title = 0x4142;
INSERT INTO t VALUES (2, NULL, 0x711);
MySQL
Driver
0x1 + 0
1
0
5 & 0x1
1
0
CAST(0x711 AS UNSIGNED)
1809
0
WHERE title = 0x4142
1 row
0 rows
Insert 0x711 into an INT column
Stores 1809
Error 19: cannot store BLOB value in INTEGER column t.n
MySQL results are from MySQL 8.4. Driver results are from #573 at cd4384bc, with PHP 8.5.12 and SQLite 3.54.1. Even-length literals, such as 0x01 + 0, behave the same way on trunk.
This is uncommon in WordPress. Hex literals there mostly come from SQL dumps of binary columns, such as mysqldump --hex-blob, and those already work. Only the INSERT fails with an error. The other cases return wrong results silently.
Related
#538 is a similar binary-versus-text comparison problem with UNHEX().
Activity