php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76400 PDO cannot caught mysql error 1690:bigint unsigned value is out of range
Submitted: 2018-06-01 06:50 UTC Modified: 2020-01-27 12:32 UTC
Votes:3
Avg. Score:3.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: kadovat at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: PDO MySQL
PHP Version: 5.6.36 OS: Linux
Private report: No CVE-ID: None
 [2018-06-01 06:50 UTC] kadovat at gmail dot com
Description:
------------
PDO doesn't throw an exception when occurs mysql error 1690:bigint unsigned value is out of rangeļ¼Œjust return an empty array 

Test script:
---------------
# CREATE TABLE  `test` (`id` int(10) unsigned DEFAULT NULL, `pv` int(10) unsigned DEFAULT NULL,`yesterday_pv` int(10) unsigned DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8

#insert into test set id=1,pv=1,yesterday_pv=2;
<?php
$dbh = new PDO("mysql:host=localhost;port=3306;dbname=testdb","root");
$sth = $dbh->prepare('select id,pv-yesterday_pv from test');
$sth->execute();
$result = $sth->fetchAll();
var_dump($result);

Expected result:
----------------
throw a PDOException

Actual result:
--------------
array(0) {
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-01 06:56 UTC] kadovat at gmail dot com
MySQL cli show error like this:

mysql> select id,pv-yesterday_pv from test;
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(`DB_ad_fengye`.`test`.`pv` - `DB_ad_fengye`.`test`.`yesterday_pv`)'
 [2020-01-27 12:32 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-01-27 12:32 UTC] cmb@php.net
If you want PDO to throw exceptions, you have to tell it to:

    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC