Further work on fixing mysql's DISTINCT/OFFSET bug