ALM-167 changes SQL queries for retrieval_statuses and retrieval_histories