mysqli_pconn_disabled.phpt 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --TEST--
  2. mysqli_pconnect() - mysqli.allow_persistent = 0
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. die("skip TODO - we need to add a user level way to check if CHANGE_USER gets called by pconnect");
  9. ?>
  10. --INI--
  11. mysqli.allow_persistent=0
  12. mysqli.max_persistent=2
  13. mysqli.max_links=2
  14. --FILE--
  15. <?php
  16. require_once("connect.inc");
  17. $host = 'p:' . $host;
  18. if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
  19. // automatic downgrade to normal connections has failed
  20. printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
  21. $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
  22. }
  23. if (!mysqli_query($link1, "SET @pcondisabled = 'Connection 1'"))
  24. printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
  25. mysqli_errno($link1), mysqli_error($link1));
  26. if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
  27. // automatic downgrade to normal connections has failed
  28. printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
  29. $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
  30. }
  31. if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test'))
  32. printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
  33. $row = mysqli_fetch_assoc($res);
  34. printf("Connecction 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
  35. mysqli_free_result($res);
  36. if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
  37. printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
  38. $row = mysqli_fetch_assoc($res);
  39. printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
  40. mysqli_free_result($res);
  41. if ($link1 === $link2)
  42. printf("[006] Links should not be identical\n");
  43. mysqli_close($link1);
  44. mysqli_close($link2);
  45. print "done!";
  46. ?>
  47. --EXPECTF--
  48. Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
  49. Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
  50. Connecction 1 - SELECT @pcondisabled -> 'Connection 1'
  51. Connecction 2 - SELECT @pcondisabled -> ''
  52. done!