Check for boolean false result from database query in SqlBagOStuff

Database::select() can return false, so we should check for it before
attempting to iterate on the result or to call methods on it.

Change-Id: I0862493305e5b2784422e0e94b3e62e734267795
Merge "Check for boolean false result from database query in SqlBagOStuff"