09notice.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. PostgreSQL notice function
  3. --EXTENSIONS--
  4. pgsql
  5. --SKIPIF--
  6. <?php
  7. include("skipif.inc");
  8. _skip_lc_messages($conn);
  9. ?>
  10. --FILE--
  11. <?php
  12. include 'config.inc';
  13. include 'lcmess.inc';
  14. ini_set('pgsql.log_notice', TRUE);
  15. ini_set('pgsql.ignore_notice', FALSE);
  16. $db = pg_connect($conn_str);
  17. _set_lc_messages($db);
  18. $res = pg_query($db, 'SET client_min_messages TO NOTICE;');
  19. var_dump($res);
  20. // Get empty notice
  21. var_dump(pg_last_notice($db));
  22. var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
  23. pg_query($db, "BEGIN;");
  24. pg_query($db, "BEGIN;");
  25. pg_query($db, "BEGIN;");
  26. pg_query($db, "BEGIN;");
  27. // Get notices
  28. var_dump(pg_last_notice($db));
  29. var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
  30. // Clear and get notices
  31. var_dump(pg_last_notice($db, PGSQL_NOTICE_CLEAR));
  32. var_dump(pg_last_notice($db, PGSQL_NOTICE_LAST));
  33. var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
  34. // Invalid option
  35. try {
  36. var_dump(pg_last_notice($db, 99));
  37. } catch (\ValueError $e) {
  38. echo $e->getMessage() . \PHP_EOL;
  39. }
  40. ?>
  41. --EXPECTF--
  42. object(PgSql\Result)#%d (0) {
  43. }
  44. string(0) ""
  45. array(0) {
  46. }
  47. Notice: pg_query(): %s already a transaction in progress in %s on line %d
  48. Notice: pg_query(): %s already a transaction in progress in %s on line %d
  49. Notice: pg_query(): %s already a transaction in progress in %s on line %d
  50. string(52) "WARNING: there is already a transaction in progress"
  51. array(3) {
  52. [0]=>
  53. string(52) "WARNING: there is already a transaction in progress"
  54. [1]=>
  55. string(52) "WARNING: there is already a transaction in progress"
  56. [2]=>
  57. string(52) "WARNING: there is already a transaction in progress"
  58. }
  59. bool(true)
  60. string(0) ""
  61. array(0) {
  62. }
  63. pg_last_notice(): Argument #2 ($mode) must be one of PGSQL_NOTICE_LAST, PGSQL_NOTICE_ALL, or PGSQL_NOTICE_CLEAR