From 1e1a06079023ec9c818980787c5d78614d693276 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Mon, 14 Oct 2019 01:00:57 +0200 Subject: [PATCH 01/14] pgsqlSetNoticeCallback Allows a callback to be triggered on every notice sent by PostgreSQL. Such notices can be sent with a RAISE NOTICE in PL/pgSQL; in a long running stored procedure, they prove useful as realtime checkpoint indicators. --- ext/pdo_pgsql/pgsql_driver.c | 66 ++++++++++++++++++++++++++++++- ext/pdo_pgsql/php_pdo_pgsql_int.h | 6 +++ 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 63eb38c7590f3..b4f63a96751fc 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -103,7 +103,19 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char * static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ { -/* pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */ + int ret; + zval zarg; + zval retval; + pdo_pgsql_fci * fc; + if ((fc = ((pdo_pgsql_db_handle *)dbh->driver_data)->notice_callback)) { + ZVAL_STRINGL(&zarg, (char *) message, strlen(message)); + fc->fci.param_count = 1; + fc->fci.params = &zarg; + fc->fci.retval = &retval; + if ((ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC)) == FAILURE) { + pdo_raise_impl_error(dbh, NULL, "HY000", "could not call user-supplied function" TSRMLS_CC); + } + } } /* }}} */ @@ -1128,6 +1140,55 @@ static PHP_METHOD(PDO, pgsqlGetPid) } /* }}} */ +/* {{{ proto bool PDO::pgsqlSetNoticeCallback(mixed callback) + Sets a callback to receive DB notices (after client_min_messages has been set) */ +static PHP_METHOD(PDO, pgsqlSetNoticeCallback) +{ + zval *callback; + zend_string *cbname; + pdo_dbh_t *dbh; + pdo_pgsql_db_handle *H; + int ret; + pdo_pgsql_fci *fc; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callback)) { + RETURN_FALSE; + } + + dbh = Z_PDO_DBH_P(getThis()); + PDO_CONSTRUCT_CHECK; + + H = (pdo_pgsql_db_handle *)dbh->driver_data; + + if (Z_TYPE_P(callback) == IS_NULL) { + if (H->notice_callback) { + efree(H->notice_callback); + H->notice_callback = NULL; + } + RETURN_TRUE; + } else { + if (!(fc = H->notice_callback)) { + fc = (pdo_pgsql_fci*)ecalloc(1, sizeof(pdo_pgsql_fci)); + } else { + memcpy(&fc->fcc, &empty_fcall_info_cache, sizeof(fc->fcc)); + } + + if (FAILURE == zend_fcall_info_init(callback, 0, &fc->fci, &fc->fcc, &cbname, NULL TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); + zend_string_release_ex(cbname, 0); + efree(fc); + H->notice_callback = NULL; + RETURN_FALSE; + } + zend_string_release_ex(cbname, 0); + + H->notice_callback = fc; + + RETURN_TRUE; + } +} +/* }}} */ + static const zend_function_entry dbh_methods[] = { PHP_ME(PDO, pgsqlLOBCreate, NULL, ZEND_ACC_PUBLIC) @@ -1139,6 +1200,7 @@ static const zend_function_entry dbh_methods[] = { PHP_ME(PDO, pgsqlCopyToFile, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, pgsqlGetNotify, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, pgsqlGetPid, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PDO, pgsqlSetNoticeCallback, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -1245,7 +1307,7 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ goto cleanup; } - PQsetNoticeProcessor(H->server, (void(*)(void*,const char*))_pdo_pgsql_notice, (void *)&dbh); + PQsetNoticeProcessor(H->server, (void(*)(void*,const char*))_pdo_pgsql_notice, (void *)dbh); H->attached = 1; H->pgoid = -1; diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h index 5d80e3220568e..ec4c012dbffc9 100644 --- a/ext/pdo_pgsql/php_pdo_pgsql_int.h +++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h @@ -32,6 +32,11 @@ typedef struct { char *errmsg; } pdo_pgsql_error_info; +typedef struct { + zend_fcall_info fci; + zend_fcall_info_cache fcc; +} pdo_pgsql_fci; + /* stuff we use in a pgsql database handle */ typedef struct { PGconn *server; @@ -45,6 +50,7 @@ typedef struct { zend_bool emulate_prepares; zend_bool disable_native_prepares; /* deprecated since 5.6 */ zend_bool disable_prepares; + pdo_pgsql_fci * notice_callback; } pdo_pgsql_db_handle; typedef struct { From d859e134ac23595ef852d70dae4794e68ff66654 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 14:27:50 +0100 Subject: [PATCH 02/14] pgsqlSetNoticeCallback: test case Add a test for a standard pgsqlSetNoticeCallback use. --- ext/pdo_pgsql/tests/issue78621.inc | 15 +++++++++++++++ ext/pdo_pgsql/tests/issue78621.phpt | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 ext/pdo_pgsql/tests/issue78621.inc create mode 100644 ext/pdo_pgsql/tests/issue78621.phpt diff --git a/ext/pdo_pgsql/tests/issue78621.inc b/ext/pdo_pgsql/tests/issue78621.inc new file mode 100644 index 0000000000000..b1cdc990fd1ec --- /dev/null +++ b/ext/pdo_pgsql/tests/issue78621.inc @@ -0,0 +1,15 @@ +beginTransaction(); +$db->exec("create temporary table t (a varchar(3))"); +$db->exec("create function hey() returns trigger as \$\$ begin new.a := 'oh'; raise notice 'I tampered your data, did you know?'; return new; end; \$\$ language plpgsql"); +$db->exec("create trigger hop before insert on t for each row execute procedure hey()"); +$db->exec("insert into t values ('ah')"); +var_dump($db->query("select * from t")->fetchAll(PDO::FETCH_ASSOC)); +echo "Done\n"; +?> diff --git a/ext/pdo_pgsql/tests/issue78621.phpt b/ext/pdo_pgsql/tests/issue78621.phpt new file mode 100644 index 0000000000000..89213dd38472a --- /dev/null +++ b/ext/pdo_pgsql/tests/issue78621.phpt @@ -0,0 +1,28 @@ +--TEST-- +pgsqlSetNoticeCallback catches Postgres "raise notice". +--SKIPIF-- + +--FILE-- +pgsqlSetNoticeCallback('disp'); +} +require dirname(__FILE__) . '/issue78621.inc'; +?> +--EXPECT-- +NOTICE: I tampered your data, did you know? +array(1) { + [0]=> + array(1) { + ["a"]=> + string(2) "oh" + } +} +Done From fb326d15814c4396b166f76376dae9a534f12e06 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 14:44:13 +0100 Subject: [PATCH 03/14] pgsqlSetNoticeCallback: test case for closure callback https://github.com/php/php-src/pull/4823#discussion_r360669537 Closure cannot be used as a callback if not persisted. --- ext/pdo_pgsql/tests/issue78621_closure.phpt | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ext/pdo_pgsql/tests/issue78621_closure.phpt diff --git a/ext/pdo_pgsql/tests/issue78621_closure.phpt b/ext/pdo_pgsql/tests/issue78621_closure.phpt new file mode 100644 index 0000000000000..c116cde305d95 --- /dev/null +++ b/ext/pdo_pgsql/tests/issue78621_closure.phpt @@ -0,0 +1,30 @@ +--TEST-- +pgsqlSetNoticeCallback catches Postgres "raise notice". +--SKIPIF-- + +--FILE-- +pgsqlSetNoticeCallback(function($message) { echo trim($message)."\n"; }); + // https://github.com/php/php-src/pull/4823#pullrequestreview-335623806 + $eraseCallbackMemoryHere = (object)[1]; +} +require dirname(__FILE__) . '/issue78621.inc'; +?> +--EXPECT-- +NOTICE: I tampered your data, did you know? +array(1) { + [0]=> + array(1) { + ["a"]=> + string(2) "oh" + } +} +Done From 59178903303053526b1fc8327de7ea2d98a7d08c Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 17:23:43 +0100 Subject: [PATCH 04/14] pgsqlSetNoticeCallback: code cleanup Move callback cleanup to a separate function. --- ext/pdo_pgsql/pgsql_driver.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index b4f63a96751fc..fef3cdd598d04 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -133,6 +133,15 @@ static int pdo_pgsql_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *in } /* }}} */ +static void pdo_pgsql_cleanup_notice_callback(pdo_pgsql_db_handle *H) /* {{{ */ +{ + if (H->notice_callback) { + efree(H->notice_callback); + H->notice_callback = NULL; + } +} +/* }}} */ + /* {{{ pdo_pgsql_create_lob_stream */ static ssize_t pgsql_lob_write(php_stream *stream, const char *buf, size_t count) { @@ -1161,10 +1170,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) H = (pdo_pgsql_db_handle *)dbh->driver_data; if (Z_TYPE_P(callback) == IS_NULL) { - if (H->notice_callback) { - efree(H->notice_callback); - H->notice_callback = NULL; - } + pdo_pgsql_cleanup_notice_callback(H); RETURN_TRUE; } else { if (!(fc = H->notice_callback)) { From 6bdac76a32dc63b7211aba7ff85b6581896b9446 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 17:36:21 +0100 Subject: [PATCH 05/14] pgsqlSetNoticeCallback: tests: ensure where are "multiple calls"-proof --- ext/pdo_pgsql/tests/issue78621.inc | 6 ++++++ ext/pdo_pgsql/tests/issue78621.phpt | 6 ++++-- ext/pdo_pgsql/tests/issue78621_closure.phpt | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/pdo_pgsql/tests/issue78621.inc b/ext/pdo_pgsql/tests/issue78621.inc index b1cdc990fd1ec..42236d803163d 100644 --- a/ext/pdo_pgsql/tests/issue78621.inc +++ b/ext/pdo_pgsql/tests/issue78621.inc @@ -10,6 +10,12 @@ $db->exec("create temporary table t (a varchar(3))"); $db->exec("create function hey() returns trigger as \$\$ begin new.a := 'oh'; raise notice 'I tampered your data, did you know?'; return new; end; \$\$ language plpgsql"); $db->exec("create trigger hop before insert on t for each row execute procedure hey()"); $db->exec("insert into t values ('ah')"); +attach($db, 'Re'); +$db->exec("delete from t"); +$db->exec("insert into t values ('ah')"); +$db->pgsqlSetNoticeCallback(null); +$db->exec("delete from t"); +$db->exec("insert into t values ('ah')"); var_dump($db->query("select * from t")->fetchAll(PDO::FETCH_ASSOC)); echo "Done\n"; ?> diff --git a/ext/pdo_pgsql/tests/issue78621.phpt b/ext/pdo_pgsql/tests/issue78621.phpt index 89213dd38472a..ee474a116cbdb 100644 --- a/ext/pdo_pgsql/tests/issue78621.phpt +++ b/ext/pdo_pgsql/tests/issue78621.phpt @@ -10,14 +10,16 @@ PDOTest::skip(); --FILE-- pgsqlSetNoticeCallback('disp'); + $db->pgsqlSetNoticeCallback('disp'.$prefix); } require dirname(__FILE__) . '/issue78621.inc'; ?> --EXPECT-- NOTICE: I tampered your data, did you know? +ReNOTICE: I tampered your data, did you know? array(1) { [0]=> array(1) { diff --git a/ext/pdo_pgsql/tests/issue78621_closure.phpt b/ext/pdo_pgsql/tests/issue78621_closure.phpt index c116cde305d95..f041f85f8e066 100644 --- a/ext/pdo_pgsql/tests/issue78621_closure.phpt +++ b/ext/pdo_pgsql/tests/issue78621_closure.phpt @@ -10,9 +10,9 @@ PDOTest::skip(); --FILE-- pgsqlSetNoticeCallback(function($message) { echo trim($message)."\n"; }); + $db->pgsqlSetNoticeCallback(function($message) use($prefix) { echo $prefix.trim($message)."\n"; }); // https://github.com/php/php-src/pull/4823#pullrequestreview-335623806 $eraseCallbackMemoryHere = (object)[1]; } @@ -20,6 +20,7 @@ require dirname(__FILE__) . '/issue78621.inc'; ?> --EXPECT-- NOTICE: I tampered your data, did you know? +ReNOTICE: I tampered your data, did you know? array(1) { [0]=> array(1) { From 6414d181148e9ad31620b348d104ea3c855d0534 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 17:39:25 +0100 Subject: [PATCH 06/14] pgsqlSetNoticeCallback: accept closure callbacks Fix to what @ranvis noted in https://github.com/php/php-src/pull/4823#discussion_r360669537 --- ext/pdo_pgsql/pgsql_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index fef3cdd598d04..4ee8fe99948e8 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -136,6 +136,7 @@ static int pdo_pgsql_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *in static void pdo_pgsql_cleanup_notice_callback(pdo_pgsql_db_handle *H) /* {{{ */ { if (H->notice_callback) { + zval_ptr_dtor(&H->notice_callback->fci.function_name); efree(H->notice_callback); H->notice_callback = NULL; } @@ -1176,6 +1177,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) if (!(fc = H->notice_callback)) { fc = (pdo_pgsql_fci*)ecalloc(1, sizeof(pdo_pgsql_fci)); } else { + zval_ptr_dtor(&fc->fci.function_name); memcpy(&fc->fcc, &empty_fcall_info_cache, sizeof(fc->fcc)); } @@ -1186,6 +1188,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) H->notice_callback = NULL; RETURN_FALSE; } + Z_ADDREF_P(&fc->fci.function_name); zend_string_release_ex(cbname, 0); H->notice_callback = fc; From 33a3ac167eef0ce8000cb47fac198548fb5a2bcb Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 17:47:54 +0100 Subject: [PATCH 07/14] pgsqlSetNoticeCallback: cleanup on pgsql_handle_closer Fix to what @ranvis noticed in https://github.com/php/php-src/pull/4823#discussion_r360669567 --- ext/pdo_pgsql/pgsql_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 4ee8fe99948e8..4da8538877872 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -225,6 +225,7 @@ static int pgsql_handle_closer(pdo_dbh_t *dbh) /* {{{ */ { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; if (H) { + pdo_pgsql_cleanup_notice_callback(H); if (H->server) { PQfinish(H->server); H->server = NULL; From 994ac071b4fe2277233a1cbf9ace7d3481d4ddd3 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 3 Jan 2020 21:09:25 +0100 Subject: [PATCH 08/14] pgsqlSetNoticeCallback: test case for method callback --- ext/pdo_pgsql/tests/issue78621_method.phpt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ext/pdo_pgsql/tests/issue78621_method.phpt diff --git a/ext/pdo_pgsql/tests/issue78621_method.phpt b/ext/pdo_pgsql/tests/issue78621_method.phpt new file mode 100644 index 0000000000000..749788b667bfd --- /dev/null +++ b/ext/pdo_pgsql/tests/issue78621_method.phpt @@ -0,0 +1,35 @@ +--TEST-- +pgsqlSetNoticeCallback catches Postgres "raise notice". +--SKIPIF-- + +--FILE-- +pgsqlSetNoticeCallback(array($logger, 'disp'.$prefix)); +} +require dirname(__FILE__) . '/issue78621.inc'; +?> +--EXPECT-- +NOTICE: I tampered your data, did you know? +ReNOTICE: I tampered your data, did you know? +array(1) { + [0]=> + array(1) { + ["a"]=> + string(2) "oh" + } +} +Done From f8a7e5d93204b32752f624076e25d9acb6b5a0c4 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Thu, 9 Jan 2020 07:20:36 +0100 Subject: [PATCH 09/14] pgsqlSetNoticeCallback: tests: set client_min_messages --- ext/pdo_pgsql/tests/issue78621.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/pdo_pgsql/tests/issue78621.inc b/ext/pdo_pgsql/tests/issue78621.inc index 42236d803163d..76acd201c1794 100644 --- a/ext/pdo_pgsql/tests/issue78621.inc +++ b/ext/pdo_pgsql/tests/issue78621.inc @@ -6,6 +6,7 @@ $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); attach($db); $db->beginTransaction(); +$db->exec("set client_min_messages to notice"); $db->exec("create temporary table t (a varchar(3))"); $db->exec("create function hey() returns trigger as \$\$ begin new.a := 'oh'; raise notice 'I tampered your data, did you know?'; return new; end; \$\$ language plpgsql"); $db->exec("create trigger hop before insert on t for each row execute procedure hey()"); From 7492232385329c1754a15617e2de62e5fed37f4f Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Thu, 9 Jan 2020 08:09:25 +0100 Subject: [PATCH 10/14] fix: pgsqlSetNoticeCallback: memory leak The PostgreSQL-provided message was zvaled and not freed. --- ext/pdo_pgsql/pgsql_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 4da8538877872..d612f3d6f71ed 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -112,7 +112,9 @@ static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ fc->fci.param_count = 1; fc->fci.params = &zarg; fc->fci.retval = &retval; - if ((ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC)) == FAILURE) { + ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC); + zval_ptr_dtor(&zarg); + if (ret == FAILURE) { pdo_raise_impl_error(dbh, NULL, "HY000", "could not call user-supplied function" TSRMLS_CC); } } From 44f5d819093829c1c4d2f93016fbd709f8af7985 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Thu, 9 Jan 2020 19:53:46 +0100 Subject: [PATCH 11/14] fix: pgsqlSetNoticeCallback: potential memory leak Discard non-null result of callback. --- ext/pdo_pgsql/pgsql_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index d612f3d6f71ed..c65fec2348447 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -112,7 +112,9 @@ static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ fc->fci.param_count = 1; fc->fci.params = &zarg; fc->fci.retval = &retval; - ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC); + if ((ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC)) != FAILURE) { + zval_ptr_dtor(&retval); + } zval_ptr_dtor(&zarg); if (ret == FAILURE) { pdo_raise_impl_error(dbh, NULL, "HY000", "could not call user-supplied function" TSRMLS_CC); From 12fc06020898d5c865e1711f983c3a053717cd5b Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Thu, 9 Jan 2020 19:56:29 +0100 Subject: [PATCH 12/14] fix: pgsqlSetNoticeCallback: ADDREF on non ref counted Core dumped when using a string callable. --- ext/pdo_pgsql/pgsql_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index c65fec2348447..3eca068ab9244 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -1193,7 +1193,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) H->notice_callback = NULL; RETURN_FALSE; } - Z_ADDREF_P(&fc->fci.function_name); + Z_TRY_ADDREF_P(&fc->fci.function_name); zend_string_release_ex(cbname, 0); H->notice_callback = fc; From dd97c3c6778e66a670a34b6208e87f08daf3e0c7 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 10 Jan 2020 05:24:02 +0100 Subject: [PATCH 13/14] pgsqlSetNoticeCallback: get rid of TSRMLS --- ext/pdo_pgsql/pgsql_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 3eca068ab9244..7cf9efce9642f 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -112,12 +112,12 @@ static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ fc->fci.param_count = 1; fc->fci.params = &zarg; fc->fci.retval = &retval; - if ((ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC)) != FAILURE) { + if ((ret = zend_call_function(&fc->fci, &fc->fcc)) != FAILURE) { zval_ptr_dtor(&retval); } zval_ptr_dtor(&zarg); if (ret == FAILURE) { - pdo_raise_impl_error(dbh, NULL, "HY000", "could not call user-supplied function" TSRMLS_CC); + pdo_raise_impl_error(dbh, NULL, "HY000", "could not call user-supplied function"); } } } @@ -1166,7 +1166,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) int ret; pdo_pgsql_fci *fc; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callback)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback)) { RETURN_FALSE; } @@ -1186,8 +1186,8 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) memcpy(&fc->fcc, &empty_fcall_info_cache, sizeof(fc->fcc)); } - if (FAILURE == zend_fcall_info_init(callback, 0, &fc->fci, &fc->fcc, &cbname, NULL TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); + if (FAILURE == zend_fcall_info_init(callback, 0, &fc->fci, &fc->fcc, &cbname, NULL)) { + php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release_ex(cbname, 0); efree(fc); H->notice_callback = NULL; From b3d6dd54a07d3004b16af200a8a00b53997a40c5 Mon Sep 17 00:00:00 2001 From: Guillaume Outters Date: Fri, 10 Jan 2020 05:33:01 +0100 Subject: [PATCH 14/14] pgsqlSetNoticeCallback: unused variable --- ext/pdo_pgsql/pgsql_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 7cf9efce9642f..f69dcdf11cfc4 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -1163,7 +1163,6 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback) zend_string *cbname; pdo_dbh_t *dbh; pdo_pgsql_db_handle *H; - int ret; pdo_pgsql_fci *fc; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback)) {