Fix self-referential resultset update/delete on MySQL (aggravated by
31073ac7)
MySQL is unable to figure out it needs a temp-table when it is trying
to update a table with a condition it derived from that table. So what
we do here is give it a helpful nudge by rewriting any "offending"
subquery to a double subquery post-sql-generation.
Performance seems to be about the same for moderately large sets. If it
becomes a problem later we can always revisit and add the ability to
induce "row-by-row" update/deletion instead.
The implementation sucks, but is rather concise and most importantly
contained to the MySQL codepath only - it does not affect the rest of
the code flow in any way.