Payday rewrite, part 5

Step 6 of #2508. Follow-on from #2541.
Also, might the `DROP TABLE IF EXISTS` here mask a bug at some point? Under what circumstances would these temporary tables still exist when we're running payday? Presumably after a payday crash?