Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 22125)
+++ wp-includes/wp-db.php	(working copy)
@@ -1195,11 +1195,13 @@
 		$this->result = @mysql_query( $query, $this->dbh );
 		$this->num_queries++;
 
+		$this->last_error = mysql_error( $this->dbh );
+
 		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
-			$this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() );
+			$this->queries[] = array( $query, $this->timer_stop(), $this->get_caller(), $this->last_error );
 
 		// If there is an error then take note of it..
-		if ( $this->last_error = mysql_error( $this->dbh ) ) {
+		if ( $this->last_error ) {
 			$this->print_error();
 			return false;
 		}
