80_bug32223b.phpt 1.3 KB

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