Adding access checks to client_std SQL function