HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/server/php/83/src/ext/pdo_pgsql/tests/bug68371.phpt
--TEST--
PDO PgSQL Bug #38671 (PDO#getAttribute() cannot be called with platform-specific attribute names)
--EXTENSIONS--
pdo
pdo_pgsql
--SKIPIF--
<?php
require __DIR__ . '/config.inc';
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php

require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

$attrs = array(
    // Extensive test: default value and set+get values
    PDO::ATTR_EMULATE_PREPARES			=> array(null, true, false),
    PDO::PGSQL_ATTR_DISABLE_PREPARES	=> array(null, true, false),

    // Just test the default
    PDO::ATTR_AUTOCOMMIT			=> array(null),
    PDO::ATTR_PREFETCH				=> array(null),
    PDO::ATTR_TIMEOUT				=> array(null),
    PDO::ATTR_ERRMODE				=> array(null),
    PDO::ATTR_SERVER_VERSION		=> array(null),
    PDO::ATTR_CLIENT_VERSION		=> array(null),
    PDO::ATTR_SERVER_INFO			=> array(null),
    PDO::ATTR_CONNECTION_STATUS		=> array(null),
    PDO::ATTR_CASE					=> array(null),
    PDO::ATTR_CURSOR_NAME			=> array(null),
    PDO::ATTR_CURSOR				=> array(null),
    PDO::ATTR_ORACLE_NULLS			=> array(null),
    PDO::ATTR_PERSISTENT			=> array(null),
    PDO::ATTR_STATEMENT_CLASS		=> array(null),
    PDO::ATTR_FETCH_TABLE_NAMES		=> array(null),
    PDO::ATTR_FETCH_CATALOG_NAMES	=> array(null),
    PDO::ATTR_DRIVER_NAME			=> array(null),
    PDO::ATTR_STRINGIFY_FETCHES		=> array(null),
    PDO::ATTR_MAX_COLUMN_LEN		=> array(null),
    PDO::ATTR_DEFAULT_FETCH_MODE	=> array(null),
);

foreach ($attrs as $a => $vals) {
    foreach ($vals as $v) {
        try {
            if (!isset($v)) {
                var_dump($pdo->getAttribute($a));
            } else {
                $pdo->setAttribute($a, $v);
                if ($pdo->getAttribute($a) === $v) {
                    echo "OK\n";
                } else {
                    throw new \Exception('KO');
                }
            }
        } catch (\Exception $e) {
            if ($e->getCode() == 'IM001') {
                echo "ERR\n";
            } else {
                echo "ERR {$e->getMessage()}\n";
            }
        }
    }
}

?>
--EXPECTF--
bool(false)
OK
OK
bool(false)
OK
OK
ERR
ERR
ERR
int(2)
string(%d) "%s"
string(%d) "%s"
string(%d) "%s"
string(31) "%s"
int(2)
ERR
ERR
int(0)
bool(false)
array(1) {
  [0]=>
  string(12) "PDOStatement"
}
ERR
ERR
string(5) "pgsql"
ERR
ERR
int(4)