Refine paranoid SQL handling

Add a RawSql class that can be used to pass through SQL. As a bonus, it
accepts closures which take the DB as a parameter, so you can pass a
closure that uses the passed DB object to escape whatever needs escaping.

Change-Id: Ic88739b665d20fadbf3cc80185770661bef18658
Merge "Refine paranoid SQL handling"