1--TEST-- 2Bug #80908: pdo_mysql lastInsertId() return wrong, when table id bigger than the maximum value of int64 3--EXTENSIONS-- 4pdo 5pdo_mysql 6--SKIPIF-- 7<?php 8require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 9MySQLPDOTest::skip(); 10?> 11--FILE-- 12<?php 13require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 14 15function createDB(): PDO { 16 $db = MySQLPDOTest::factory(); 17 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 18 $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 19 return $db; 20} 21 22$db = createDB(); 23$db->exec('DROP TABLE IF EXISTS test'); 24$db->exec('CREATE TABLE test (`id` bigint(20) unsigned AUTO_INCREMENT, `name` varchar(5), primary key (`id`)) ENGINE = InnoDB AUTO_INCREMENT=10376293541461622799'); 25 26function testLastInsertId(PDO $db) { 27 echo "Running test lastInsertId\n"; 28 $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); 29 try { 30 $db->exec("insert into test (`name`) values ('bar')"); 31 $id = $db->lastInsertId(); 32 echo "Last insert id is " . $id . "\n"; 33 } catch (PDOException $e) { 34 echo $e->getMessage()."\n"; 35 } 36} 37 38testLastInsertId($db); 39unset($db); 40echo "\n"; 41 42?> 43--CLEAN-- 44<?php 45require __DIR__ . '/mysql_pdo_test.inc'; 46MySQLPDOTest::dropTestTable(); 47?> 48--EXPECT-- 49Running test lastInsertId 50Last insert id is 10376293541461622799 51