80_bug32223b.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. Bug #32223 (weird behaviour of pg_last_notice using define)
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. _skip_lc_messages();
  7. @pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
  8. $res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
  9. begin
  10. RAISE NOTICE ''11111'';
  11. return ''f'';
  12. end;
  13. ' LANGUAGE plpgsql;");
  14. if (!$res) die('skip PLPGSQL not available');
  15. ?>
  16. --INI--
  17. pgsql.ignore_notice=0
  18. --FILE--
  19. <?php
  20. require_once('config.inc');
  21. require_once('lcmess.inc');
  22. define('dbh', pg_connect($conn_str));
  23. if (!dbh) {
  24. die ("Could not connect to the server");
  25. }
  26. _set_lc_messages();
  27. $res = pg_query(dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
  28. begin
  29. RAISE NOTICE ''11111'';
  30. return ''f'';
  31. end;
  32. ' LANGUAGE plpgsql;");
  33. $res = pg_query(dbh, 'SET client_min_messages TO NOTICE;');
  34. var_dump($res);
  35. function tester() {
  36. $res = pg_query(dbh, 'SELECT test_notice()');
  37. $row = pg_fetch_row($res, 0);
  38. var_dump($row);
  39. pg_free_result($res);
  40. if ($row[0] == 'f')
  41. {
  42. var_dump(pg_last_notice(dbh));
  43. }
  44. }
  45. tester();
  46. pg_close(dbh);
  47. ?>
  48. ===DONE===
  49. --EXPECTF--
  50. resource(%d) of type (pgsql result)
  51. array(1) {
  52. [0]=>
  53. string(1) "f"
  54. }
  55. string(14) "NOTICE: 11111"
  56. ===DONE===