Continue work on pg support
Continue pg support
Fix date_sub
Move date, table name, some other functions to db-specific classes