Simplify the way DB permission verification works.

db::executeQuery now uses less code for this purpose.
Rewrite setup DB queries and fix a bug in db::isSetup.

The setup script was never modified to use the new DB querying API. That has been fixed, resulting in fewer lines of code in the setup module.

I also discovered a bug in the isSetup function that would invariably cause a null pointer exception every time the code was run.