Bug #80653 [NEW]: MySQL BIGINT UNSIGNED value in prepared statement treated incorrectly

From: Date: Thu, 21 Jan 2021 18:47:06 +0000
Subject: Bug #80653 [NEW]: MySQL BIGINT UNSIGNED value in prepared statement treated incorrectly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231682@lists.php.net to get a copy of this message
From: gman dot n at xrbr dot com Operating system: Ubuntu 20.04.1 LTS PHP version: 7.4.14 Package: MySQLi related Bug Type: Bug Bug description:MySQL BIGINT UNSIGNED value in prepared statement treated incorrectly Description: ------------ When using MySQLi prepared statement, everything works as expected when using only a single BIGINT UNSIGNED column by itself: Using one column only: "... WHERE val_hash=?" test value A: 8969302881072144 => result: works. test value B: 13326067295508650029 => result: works. The query returns the expected result in both cases. However, when adding a second column, which in my scenario is a TINYINT column, the SELECT query will work for test value A, but not yield any results for test value B. This occurs probabaly because the test value B ist a BIGINT UNSIGNED value is higher than PHP_INT_MAX. Using two columns: "... WHERE val_type=? AND val_hash=?" test value A: 8969302881072144 => result: works. test value B: 13326067295508650029 => result: DOES NOT WORK. Therefore, there must be a bug that messes up the BIGINT UNSIGNED value when higher than PHP_INT_MAX. Test script: --------------- Full script: https://pastebin.com/g4ZCG3sB Shorted version: <?php $connection = new \mysqli(...); $statement1 = $connection->prepare('SELECT val_id, val_type FROM copy_pw_values WHERE val_type=? AND val_hash=?'); $type3 = 3; $hash3 = '13326067295508650029'; $statement1->bind_param('is', $type3, $hash3); $statement1->execute(); echo $statement1->get_result()->num_rows; // Returns 0, should return 1. $type4 = '3'; $hash4 = '13326067295508650029'; $statement1->bind_param('ss', $type4, $hash4); $statement1->execute(); echo $statement1->get_result()->num_rows; // Returns 0, should return 1. Expected result: ---------------- 1111 11 11 Actual result: -------------- 1100 11 11 -- Edit bug report at https://bugs.php.net/bug.php?id=80653&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80653&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80653&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80653&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80653&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80653&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80653&r=support Expected behavior: https://bugs.php.net/fix.php?id=80653&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80653&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80653&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80653&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80653&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80653&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80653&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80653&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80653&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80653&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80653&r=mysqlcfg

« previous php.bugs (#231682) next »