Add a more generic ref_types API
Add POSTGIS_DETOAST_DATUM macro