rdbms: improve query logging logic in Database
* Merge the two debug() calls in attemptQuery() into one single
call which checks DBO_DEBUG. This avoids pointless SPI logger
overhead.
* Avoid calling generalizeSQL() unless actually necessary. This
works via a lazy-loading object.
* Make lastQuery() a bit more consistent in terms of when it
gets updated.
* Add DBQueryDisconnectedError class for dropped connections.
* Clean up visbility and names of last query/error fields.
Change-Id: Ie8df3434d23b18f7a0f4c056d71388192cc52c6b