Add cursor mode to DB and paginator (no conflict).

New PR to master branch instead of 4.1 since it's been decided to push this as a feature for 4.2.

Continuation of #3649.