Skip to content

Commit f31d253

Browse files
committed
ext/pgsql adding PGSQL_ERRORS_SQLSTATE constant support.
Close phpGH-11181
1 parent 3af5f47 commit f31d253

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

Diff for: NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ PHP NEWS
126126
. pg_cancel use thread safe PQcancel api instead. (David Carlier)
127127
. pg_trace new PGSQL_TRACE_SUPPRESS_TIMESTAMPS/PGSQL_TRACE_REGRESS_MODE
128128
contants support. (David Carlier)
129+
. pg_set_error_verbosity adding PGSQL_ERRORS_STATE constant. (David Carlier)
129130

130131
- Phar:
131132
. Fix memory leak in phar_rename_archive(). (stkeke)

Diff for: UPGRADING

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ PHP 8.3 UPGRADE NOTES
220220
- PGSQL:
221221
. PGSQL_TRACE_SUPPRESS_TIMESTAMPS.
222222
. PGSQL_TRACE_REGRESS_MODE.
223+
. PGSQL_ERRORS_SQLSTATE.
223224

224225
- Posix:
225226
. POSIX_SC_ARG_MAX.

Diff for: ext/pgsql/pgsql.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ char pgsql_libpq_version[16];
112112
#define PQfreemem free
113113
#endif
114114

115+
#if PG_VERSION_NUM < 120000
116+
#define PQERRORS_SQLSTATE 0
117+
#endif
118+
115119
ZEND_DECLARE_MODULE_GLOBALS(pgsql)
116120
static PHP_GINIT_FUNCTION(pgsql);
117121

@@ -2821,7 +2825,7 @@ PHP_FUNCTION(pg_set_error_verbosity)
28212825

28222826
pgsql = link->conn;
28232827

2824-
if (verbosity & (PQERRORS_TERSE|PQERRORS_DEFAULT|PQERRORS_VERBOSE)) {
2828+
if (verbosity & (PQERRORS_TERSE|PQERRORS_DEFAULT|PQERRORS_VERBOSE|PQERRORS_SQLSTATE)) {
28252829
RETURN_LONG(PQsetErrorVerbosity(pgsql, verbosity));
28262830
} else {
28272831
RETURN_FALSE;

Diff for: ext/pgsql/pgsql.stub.php

+13
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@
183183
* @cvalue PQERRORS_VERBOSE
184184
*/
185185
const PGSQL_ERRORS_VERBOSE = UNKNOWN;
186+
#if PGVERSION_NUM > 110000
187+
/**
188+
* @var int
189+
* @cvalue PQERRORS_SQLSTATE
190+
*/
191+
const PGSQL_ERRORS_SQLSTATE = UNKNOWN;
192+
#else
193+
/**
194+
* @var int
195+
* @cvalue PQERRORS_TERSE
196+
*/
197+
const PGSQL_ERRORS_SQLSTATE = UNKNOWN;
198+
#endif
186199

187200
/* For lo_seek() */
188201

Diff for: ext/pgsql/pgsql_arginfo.h

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ext/pgsql/tests/07optional.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if (function_exists('pg_set_error_verbosity')) {
1919
pg_set_error_verbosity($db, PGSQL_ERRORS_TERSE);
2020
pg_set_error_verbosity($db, PGSQL_ERRORS_DEFAULT);
2121
pg_set_error_verbosity($db, PGSQL_ERRORS_VERBOSE);
22+
pg_set_error_verbosity($db, PGSQL_ERRORS_SQLSTATE);
2223
}
2324
echo "OK";
2425
?>

0 commit comments

Comments
 (0)