1--TEST--
2PDO_Firebird: persistent connect test
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--XLEAK--
8A bug in firebird causes a memory leak when calling `isc_attach_database()`.
9See https://github.com/FirebirdSQL/firebird/issues/7849
10--FILE--
11<?php
12
13/**
14 * Omit the case where the connection is broken when it checks liveness and
15 * it has to reconnect, as it is very difficult to reproduce the situation.
16 */
17
18require("testdb.inc");
19unset($dbh);
20
21$connIds = [];
22
23foreach (['First', 'Second'] as $times) {
24    $dbh = new PDO(
25        PDO_FIREBIRD_TEST_DSN,
26        PDO_FIREBIRD_TEST_USER,
27        PDO_FIREBIRD_TEST_PASS,
28        [
29            PDO::ATTR_PERSISTENT => true,
30        ],
31    );
32    $stmt = $dbh->query('SELECT CURRENT_CONNECTION FROM RDB$DATABASE');
33    $connId = $stmt->fetchColumn();
34    $connIds[] = $connId;
35    echo "{$times} connection ID: {$connId}\n";
36
37    unset($dbh);
38    unset($stmt);
39    unset($connID);
40}
41
42echo $connIds[0] === $connIds[1] ? "Same ID.\n" : "Different ID\n";
43?>
44--EXPECTF--
45First connection ID: %d
46Second connection ID: %d
47Same ID.
48