MERGE engine".
Backport the patch from 6.0 by Ingo Struewing:
revid:ingo.struewing@sun.com-20091028183659-6kmv1k3gdq6cpg4d
Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
In former MySQL versions, up to 5.1.23/6.0.4 it was possible to create
temporary MERGE tables with non-temporary MyISAM tables.
This has been changed in the mentioned version due to Bug 19627
(temporary merge table locking). MERGE children were locked through
the parent table. If the parent was temporary, it was not locked and
so the children were not locked either. Parallel use of the MyISAM
tables corrupted them.
Since 6.0.6 (WL 4144 - Lock MERGE engine children), the children are
locked independently from the parent. Now it is possible to allow
non-temporary children with a temporary parent. Even though the
temporary MERGE table itself is not locked, each non-temporary
MyISAM table is locked anyway.
NOTE: Behavior change: In 5.1.23/6.0.4 we prohibited non-temporary
children with a temporary MERGE table. Now we re-allow it.
An important side-effect is that temporary tables, which overlay
non-temporary MERGE children, overlay the children in the MERGE table.
mysql-test/r/merge.result:
Update results (Bug#36171).
mysql-test/r/merge_mmap.result:
Update results (Bug#36171).
mysql-test/t/merge.test:
Add tests for Bug#36171
mysql-test/t/merge_mmap.test:
Add tests for Bug#36171.
storage/myisammrg/ha_myisammrg.cc:
Changed constraint for temporary state of tables.
and a backport of relevant changes from the 6.0
version of the fix done by Ingo Struewing.
The bug itself was fixed by the patch for Bug#54811.
MyISAMMRG engine would try to use MMAP on its children
even on platforms that don't support it and even if
myisam_use_mmap option was off.
This lead to an infinite hang in INSERT ... SELECT into
a MyISAMMRG table when the destination MyISAM table
was also selected from.
A bug in duplicate detection fixed by 54811 was essential to
the hang - when a duplicate is detected, the optimizer
disables the use of memory mapped files, and it wasn't the case.
The patch below is also to not turn on MMAP on children tables
if myisam_use_mmap is off.
A test case is added to cover MyISAMMRG and myisam_use_mmap
option.
mysql-test/r/merge_mmap.result:
Result file - Bug#50788.
mysql-test/t/merge_mmap-master.opt:
An option file for the test for Bug#50788 -- use mmap.
mysql-test/t/merge_mmap.test:
Try INSERT ... SELECT into a merge table when myisam_use_mmap is on (Bug#50788).
storage/myisam/mi_statrec.c:
Fixed misinterpretation of the return value of my_b_read().
storage/myisammrg/ha_myisammrg.cc:
Skip HA_EXTRA_MMAP if MyISAM memory mapping is disabled.