80_bug32223.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Bug #32223 (weird behaviour of pg_last_notice)
  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. $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. $res = pg_query($dbh, 'SELECT test_notice()');
  36. var_dump($res);
  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. pg_close($dbh);
  45. ?>
  46. ===DONE===
  47. --EXPECTF--
  48. resource(%d) of type (pgsql result)
  49. resource(%d) of type (pgsql result)
  50. array(1) {
  51. [0]=>
  52. string(1) "f"
  53. }
  54. string(14) "NOTICE: 11111"
  55. ===DONE===