Fix self-referential resultset update/delete on MySQL (aggravated by 31073ac7)
authorPeter Rabbitson <ribasushi@cpan.org>
Wed, 21 Nov 2012 11:38:43 +0000 (12:38 +0100)
committerPeter Rabbitson <ribasushi@cpan.org>
Mon, 21 Jan 2013 13:33:34 +0000 (14:33 +0100)
commit45150bc4f3b983d64477728e2bd8e722c10c7a31
tree6373758f85c65faac76caeae2517fdd02206b2d9
parent31073ac79e22ae0f977c7e0fc4e9857d250143c4
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.
Changes
Makefile.PL
lib/DBIx/Class/SQLMaker/MySQL.pm
lib/DBIx/Class/Storage/DBI/mysql.pm
t/71mysql.t
t/sqlmaker/mysql.t [new file with mode: 0644]