Move pgsql specific code to postgis