Sql tests

WIP for #4163. Not ready to merge yet

New test structure for sql, and working through sql/test_sql with abstract syntax (aim is to not be sql-platform specific anywhere).