Skip to content

Commit 78e15ac

Browse files
committed
debugging
1 parent 0522ae6 commit 78e15ac

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,23 +1989,33 @@ PHP_FUNCTION(mysqli_thread_id)
19891989
MYSQL_ROW row;
19901990
zval *mysql_link;
19911991
zend_long processid;
1992+
int r;
19921993

19931994
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
19941995
RETURN_THROWS();
19951996
}
19961997
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
19971998

19981999
static const char *query = "SELECT CONNECTION_ID()";
2000+
size_t query_len = strlen(query);
19992001

2000-
if (mysql_real_query(mysql->mysql, query, strlen(query))) {
2001-
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
2002-
RETURN_LONG(-1);
2002+
if ((r = mysql_real_query(mysql->mysql, query, query_len))) {
2003+
if (r == CR_COMMANDS_OUT_OF_SYNC) {
2004+
if (mysql_ping(mysql->mysql) == 0) {
2005+
if (mysql_real_query(mysql->mysql, query, query_len)) {
2006+
goto fail;
2007+
}
2008+
goto process;
2009+
}
2010+
}
2011+
goto fail;
20032012
}
20042013

2014+
process:
20052015
result = mysql_store_result(mysql->mysql);
20062016
if (!result) {
20072017
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
2008-
RETURN_LONG(-1);
2018+
RETURN_THROWS();
20092019
}
20102020

20112021
row = mysql_fetch_row(result);
@@ -2015,6 +2025,10 @@ PHP_FUNCTION(mysqli_thread_id)
20152025
mysql_free_result(result);
20162026

20172027
RETURN_LONG(processid);
2028+
2029+
fail:
2030+
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
2031+
RETURN_THROWS();
20182032
}
20192033
/* }}} */
20202034

0 commit comments

Comments
 (0)