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