Replace plpgsql with sql for the overloaded functions