php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66525 Mysqli::thread_id limited in 32bit int.
Submitted: 2014-01-21 03:08 UTC Modified: 2014-02-25 12:25 UTC
From: aleiphoenix at gmail dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.5.8 OS: Linux x86_64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aleiphoenix at gmail dot com
New email:
PHP Version: OS:

 

 [2014-01-21 03:08 UTC] aleiphoenix at gmail dot com
Description:
------------
When MySQL connection_id goes larger then 2**31, Mysqli::thread_id just return the wrong value.


tested version

PHP 5.5.7 on Gentoo Linux x86_64
PHP 5.2.14 on RHEL 5.5 x86_64

Test script:
---------------
<?php

$mysql = new Mysqli('127.0.0.1', 'batchjob', 'aN2jU3ke', 'anjuke_db');

$_id = $mysql->thread_id;

var_dump($_id);

$sql = 'select connection_id()';

$res = $mysql->query($sql);

var_dump($res->fetch_row()[0]);

sleep(30);

$mysql->close();


Expected result:
----------------
result of Mysqli::thread_id is the same as result of `select connection_id()` statement.

Actual result:
--------------
Mysqli::thread_id: 2804557258
select connection_id(): 11394491850


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-25 12:25 UTC] uw@php.net
-Status: Open +Status: Not a bug
 [2014-02-25 12:25 UTC] uw@php.net
mysql::thread_id is taken from the C/S protocol. The C/S protocol is using 32bit. Hence, any consumer, such as PHP, is limited to 32bit. If you consider this an error, report it at MySQL.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC