(maint) Add pretty SQL formatting

This patch converts all SQL code from the query engine into a pretty format
so it is easier to read from the debug output.

Signed-off-by: Ken Barber <ken@bob.sh>