/** * @param $sql string * @return true|false|resource * * For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error. * For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error. */ protected function doQuery($sql) { $this->installErrorHandler(); if ($this->bufferResults()) { $ret = mysql_query($sql, $this->mConn); } else { $ret = mysql_unbuffered_query($sql, $this->mConn); } $phpError = $this->restoreErrorHandler(); if ($ret === false) { global $wgDBname; $error = $this->lastError(); if (!$error) { $error = $phpError; } $err_num = $this->lastErrno(); error_log(sprintf("SQL (%s): %d: %s", $wgDBname, $err_num, $error)); error_log("SQL: invalid query: {$sql}"); # Wikia change - begin switch ($err_num) { case 1213: /* deadlock*/ error_log("MOLI: deadlock: {$error} "); Wikia::debugBacktrace("MOLI: Deadlock:"); break; case 2006: /* server has gone away */ error_log("MOLI: gone away: {$error} "); Wikia::debugBacktrace("MOLI: gone away:"); break; } # Wikia change - end } return $ret; }
/** * @param $sql string * @return resource */ protected function doQuery($sql) { $this->installErrorHandler(); if ($this->bufferResults()) { $ret = mysql_query($sql, $this->mConn); } else { $ret = mysql_unbuffered_query($sql, $this->mConn); } $phpError = $this->restoreErrorHandler(); if ($ret === false) { global $wgDBname; $error = $this->lastError(); if (!$error) { $error = $phpError; } $err_num = $this->lastErrno(); error_log(sprintf("SQL (%s): %d: %s", $wgDBname, $err_num, $error)); error_log("SQL: invalid query: {$sql}"); if ($err_num == 1213) { /* deadlock*/ error_log("MOLI: deadlock: {$error} "); Wikia::debugBacktrace("MOLI: Deadlock:"); } } return $ret; }