1--TEST-- 2mysqli_change_user() - LAST_INSERT_ID() - http://bugs.mysql.com/bug.php?id=45184? 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7require_once('connect.inc'); 8 9if (!$IS_MYSQLND) { 10 die("skip Might hit known and open bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184"); 11} 12?> 13--FILE-- 14<?php 15 require_once('connect.inc'); 16 17 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 18 printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 19 20 if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) 21 printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 22 23 if (!mysqli_query($link, 'CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, label CHAR(10))')) 24 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 25 26 if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')")) 27 printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 28 29 if (($insert_id = mysqli_insert_id($link)) !== 100) 30 printf("[005] Expecting 100, got %d, [%d] %s\n", 31 $insert_id, 32 mysqli_errno($link), mysqli_error($link)); 33 34 // LAST_INSERT_ID should be reset 35 mysqli_change_user($link, $user, $passwd, $db); 36 37 if (($insert_id = mysqli_insert_id($link)) !== 0) 38 printf("[006] Expecting 0, got %d, [%d] %s\n", 39 $insert_id, 40 mysqli_errno($link), mysqli_error($link)); 41 42 if (!$res = mysqli_query($link, 'SELECT LAST_INSERT_ID() as _insert_id')) 43 printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 44 45 if (!$row = mysqli_fetch_assoc($res)) 46 printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 47 mysqli_free_result($res); 48 49 if ($row['_insert_id'] != $insert_id) 50 printf("LAST_INSERT_ID() [%d] and mysqli_insert_id [%d] differ!\n", 51 $row['_insert_id'], $insert_id); 52 53 if ($row['_insert_id'] != 0) 54 printf("Expecting 0 got %d\n", $row['_insert_id']); 55 56 mysqli_close($link); 57 print "done!"; 58?> 59--CLEAN-- 60<?php 61 require_once("clean_table.inc"); 62?> 63--EXPECT-- 64done! 65