update pg function and test