Skip to content

Commit 926dee1

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix error message allocation of PDO PgSQL
2 parents f19250a + 778513f commit 926dee1

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ PHP NEWS
2727
- Reflection:
2828
. Fixed bug #81681 (ReflectionEnum throwing exceptions). (cmb)
2929

30+
- PDO_PGSQL:
31+
. Fixed error message allocation of PDO PgSQL. (SATO Kentaro)
32+
3033
- Spl:
3134
. Fixed bug #75917 (SplFileObject::seek broken with CSV flags). (Aliaksandr
3235
Bystry)

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
8787
}
8888

8989
if (msg) {
90-
einfo->errmsg = estrdup(msg);
90+
einfo->errmsg = pestrdup(msg, dbh->is_persistent);
9191
}
9292
else if (errmsg) {
9393
einfo->errmsg = _pdo_pgsql_trim_message(errmsg, dbh->is_persistent);

ext/pdo_pgsql/tests/gh7723.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
GitHub #7723 (Fix error message allocation of PDO PgSQL)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
7+
require __DIR__ . '/config.inc';
8+
PDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
13+
require __DIR__ . '/config.inc';
14+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
15+
$db->setAttribute(PDO::ATTR_PERSISTENT, true);
16+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
17+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
18+
19+
$st = $db->prepare('select 1');
20+
for ($i = 0; ++$i <= 2;) {
21+
try {
22+
$st->bindValue(':invalid', $i);
23+
} catch (PDOException $e) {
24+
echo $e->getMessage() . "\n";
25+
}
26+
}
27+
?>
28+
--EXPECT--
29+
SQLSTATE[HY093]: Invalid parameter number: :invalid
30+
SQLSTATE[HY093]: Invalid parameter number: :invalid

0 commit comments

Comments
 (0)