xref: /PHP-8.0/ext/pgsql/tests/skipif.inc (revision f8d79582)
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
9include("config.inc");
10include("lcmess.inc");
11
12if (!extension_loaded("pgsql")) {
13    die("skip pgsql extension not loaded\n");
14}
15$conn = @pg_connect($conn_str);
16if (!is_resource($conn)) {
17    die("skip could not connect\n");
18}
19
20function skip_server_version($version, $op = '<')
21{
22    $pg = pg_parameter_status('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
29function skip_bytea_not_hex()
30{
31    $out = pg_escape_bytea("\xFF");
32    if (strpos($out, '377') !== false) {
33        die("skip libpq or backend < 9.0\n");
34    }
35}
36
37function skip_bytea_not_escape()
38{
39    $out = pg_escape_bytea("\xFF");
40    if (strpos($out, '377') === false) {
41        die("skip libpq or backend >= 9.0\n");
42    }
43}
44
45?>
46