Postgres backend: implement scan_keys(), infrastructure stuff.

In PsycoPG >= 2.5, you can use a connection object in a 'with' statement
to get a transaction, and you can create named cursor objects that do
reasonable things as iterators (in particular batch fetches).

Build queries piecewise, especially for scans, and split out the code
that converts back from a row response to a (key,value) (or just key)
return value.