better return-type detection for PG functions