Skip to content

Commit a8edab4

Browse files
committed
pgsqlSetNoticeCallback: clean call to libpq
Make the dirty casting work inside our callback, not while interacting with libpq's functions
1 parent c89544e commit a8edab4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
102102
}
103103
/* }}} */
104104

105-
static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */
105+
static void _pdo_pgsql_notice(void *context, const char *message) /* {{{ */
106106
{
107107
int ret;
108108
zval zarg;
109109
zval retval;
110110
pdo_pgsql_fci * fc;
111+
pdo_dbh_t * dbh = (pdo_dbh_t *)context;
111112
if ((fc = ((pdo_pgsql_db_handle *)dbh->driver_data)->notice_callback)) {
112113
ZVAL_STRINGL(&zarg, (char *) message, strlen(message));
113114
fc->fci.param_count = 1;
@@ -1415,7 +1416,7 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
14151416
goto cleanup;
14161417
}
14171418

1418-
PQsetNoticeProcessor(H->server, (void(*)(void*,const char*))_pdo_pgsql_notice, (void *)dbh);
1419+
PQsetNoticeProcessor(H->server, _pdo_pgsql_notice, (void *)dbh);
14191420

14201421
H->attached = 1;
14211422
H->pgoid = -1;

0 commit comments

Comments
 (0)