Added DatabaseBase::selectRowCount() method

* Useful for doing COUNT(*) with a LIMIT for performance
* Made MergeHistory use it

Change-Id: If1cfc52ea22fd09d34915c29b45d0b487d28d15a
Merge "Added DatabaseBase::selectRowCount() method"