From f7a4a852df7e9774ef56c2ba43e0d51c74bd080d Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 14 Sep 2005 15:34:42 +0000 Subject: [PATCH] Fix error detection for queries such as OPTIMIZE --- ext/pdo_mysql/mysql_driver.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 75c7fc2cac..d97e350298 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -234,8 +234,13 @@ static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM pdo_mysql_error(dbh); return -1; } else { - my_ulonglong c= mysql_affected_rows(H->server); - return c != (my_ulonglong)-1 ? c:(pdo_mysql_error(dbh),-1); + my_ulonglong c = mysql_affected_rows(H->server); + if (c != (my_ulonglong) -1) { + pdo_mysql_error(dbh); + return (H->einfo.errcode ? -1 : 0); + } else { + return c; + } } } -- 2.50.1