1--TEST-- 2mysqli_change_user() - ROLLBACK 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7require_once('connect.inc'); 8if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 9 die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); 10 11if (!have_innodb($link)) 12 die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error)); 13?> 14--FILE-- 15<?php 16 require_once('connect.inc'); 17 require_once('table.inc'); 18 19 if (!mysqli_query($link, 'ALTER TABLE test ENGINE=InnoDB')) 20 printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 21 22 mysqli_autocommit($link, false); 23 24 if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) 25 printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 26 27 if (!$row = mysqli_fetch_assoc($res)) 28 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 29 mysqli_free_result($res); 30 31 $num = $row['_num']; 32 assert($num > 0); 33 34 if (!$res = mysqli_query($link, 'DELETE FROM test')) 35 printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 36 37 if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) 38 printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 39 40 if (!$row = mysqli_fetch_assoc($res)) 41 printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 42 mysqli_free_result($res); 43 44 if (0 != $row['_num']) 45 printf("[007] Rows should have been deleted in this transaction\n"); 46 47 // DELETE should be rolled back 48 mysqli_change_user($link, $user, $passwd, $db); 49 50 if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) 51 printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 52 53 if (!$row = mysqli_fetch_assoc($res)) 54 printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 55 56 if ($row['_num'] != $num) 57 printf("[010] Expecting %d rows in the table test, found %d rows\n", 58 $num, $row['_num']); 59 60 mysqli_free_result($res); 61 mysqli_close($link); 62 print "done!"; 63?> 64--CLEAN-- 65<?php 66 require_once("clean_table.inc"); 67?> 68--EXPECT-- 69done! 70