Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

In Drupal 8, executed update queries always return the number of rows matched by the query, including rows that didn't have to be updated because their values wouldn't have changed.

In Drupal 7, this used to be inconsistent, depending on database engine and version:

  • MySQL / InnoDB: changed rows only
    (except on unsupported MySQL versions 5.1.0 - 5.1.24: all rows matched by the query)
  • MySQL / MyISAM: changed rows only
  • PostgreSQL: all rows matched by the query
  • SQLite: changed rows only

Note that this relates to all update queries whether executed from a Database::getConnection()->update() object or its procedural wrapper db_update().
However, in most cases where you want to know the number of affected rows, a merge query might be the even better solution, see Database::getConnection()->merge() or its procedural wrapper db_merge().

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Coder upgrade done
Other: 
Not done
Details: 

Coder upgrade module might possibly want to check for return values of update queries being assigned to a variable and add a comment.
More documentation probably isn't needed.