skipif.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // This script prints "skip" unless:
  3. // * the pgsql extension is built-in or loadable, AND
  4. // * there is a database called "test" accessible
  5. // with no username/password, AND
  6. // * we have create/drop privileges on the entire "test"
  7. // database
  8. include("config.inc");
  9. include("lcmess.inc");
  10. if (getenv("SKIP_REPEAT")) {
  11. // pgsql tests are order-dependent.
  12. // We should probably change that, but in the meantime do not allow repetition.
  13. die("skip Cannot repeat pgsql tests");
  14. }
  15. $conn = @pg_connect($conn_str);
  16. if (!$conn) {
  17. die("skip could not connect\n");
  18. }
  19. function skip_server_version($version, $op = '<')
  20. {
  21. global $conn;
  22. $pg = pg_parameter_status($conn,'server_version');
  23. if (version_compare($pg, $version, $op)) {
  24. die("skip Server version {$pg} is {$op} {$version}\n");
  25. }
  26. return $pg;
  27. }
  28. function skip_bytea_not_hex()
  29. {
  30. global $conn;
  31. $out = pg_escape_bytea($conn, "\xFF");
  32. if (strpos($out, '377') !== false) {
  33. die("skip libpq or backend < 9.0\n");
  34. }
  35. }
  36. function skip_bytea_not_escape()
  37. {
  38. global $conn;
  39. $out = pg_escape_bytea($conn, "\xFF");
  40. if (strpos($out, '377') === false) {
  41. die("skip libpq or backend >= 9.0\n");
  42. }
  43. }
  44. ?>