Bug #80653 [Opn->Fbk]: MySQL BIGINT UNSIGNED value in prepared statement treated incorrectly

From: Date: Thu, 21 Jan 2021 19:16:03 +0000
Subject: Bug #80653 [Opn->Fbk]: MySQL BIGINT UNSIGNED value in prepared statement treated incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231683@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80653&edit=1 ID: 80653 Updated by: dharman@php.net Reported by: gman dot n at xrbr dot com Summary: MySQL BIGINT UNSIGNED value in prepared statement treated incorrectly -Status: Open +Status: Feedback Type: Bug Package: MySQLi related Operating System: Ubuntu 20.04.1 LTS PHP Version: 7.4.14 Block user comment: N Private report: N New Comment: I can't reproduce it. I tried with PHP 7.3, 7.4.14 and 8.0. I tried on Windows and Linux. I tried it with MySQL and MariaDB. I even tried it online, but I always get the same output: https://phpize.online/?phpses=ff46fef22cb57979f1280d43f0ad2729&sqlses=null&php_version=php7&sql_version=mysql57 1111 11 11 Are you sure there isn't something else in your environment that causes the wrong output? Previous Comments: ------------------------------------------------------------------------ [2021-01-21 18:47:06] gman dot n at xrbr dot com 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 this bug report at https://bugs.php.net/bug.php?id=80653&edit=1

« previous php.bugs (#231683) next »