mysqli_debug.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. mysqli_debug()
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. if (!function_exists('mysqli_debug'))
  9. die("skip: mysqli_debug() not available");
  10. if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
  11. die("skip: can't say for sure if mysqli_debug works");
  12. if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
  13. die("skip: debug functionality not enabled");
  14. ?>
  15. --FILE--
  16. <?php
  17. require_once('connect.inc');
  18. // NOTE: documentation is not clear on this: function always return NULL or TRUE
  19. if (true !== ($tmp = mysqli_debug(sprintf('d:t:O,%s/mysqli_debug_phpt.trace', sys_get_temp_dir()))))
  20. printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  21. if ($IS_MYSQLND) {
  22. // let's make this mysqlnd only - for libmysql we need debug installation
  23. // table.inc will create a database connection and run some SQL queries, therefore
  24. // the debug file should have entries
  25. require_once('table.inc');
  26. clearstatcache();
  27. $trace_file = sprintf('%s/mysqli_debug_phpt.trace', sys_get_temp_dir());
  28. if (!file_exists($trace_file))
  29. printf("[003] Trace file '%s' has not been created\n", $trace_file);
  30. if (filesize($trace_file) < 50)
  31. printf("[004] Trace file '%s' is very small. filesize() reports only %d bytes. Please check.\n",
  32. $trace_file,
  33. filesize($trace_file));
  34. // will mysqli_debug() mind if the trace file gets removed?
  35. unlink($trace_file);
  36. clearstatcache();
  37. if (!$res = mysqli_query($link, 'SELECT * FROM test'))
  38. printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  39. else
  40. mysqli_free_result($res);
  41. mysqli_close($link);
  42. clearstatcache();
  43. if (!file_exists($trace_file))
  44. printf("[006] Trace file '%s' does not exist\n", $trace_file);
  45. unlink($trace_file);
  46. }
  47. print "done!";
  48. ?>
  49. --CLEAN--
  50. <?php
  51. require_once("clean_table.inc");
  52. ?>
  53. --EXPECTF--
  54. done%s