bug fixes for batch upgrade on postgresql