Another fix to sql fetch semanttics
Optimize handle-setting.