Looking at EXPLAIN outputs, I see that
- The query with "Correct result" settings does not use Materialization (even though optimizer_switch value instructs it to do it)
- The query with "Wrong result" settings does use Materialization.
It seems, the problem is that SJ-Materialization attempts to handle this case, while it should refuse it, like regular materialization did.
Looking at EXPLAIN outputs, I see that
- The query with "Correct result" settings does not use Materialization (even though optimizer_switch value instructs it to do it)
- The query with "Wrong result" settings does use Materialization.
It seems, the problem is that SJ-Materialization attempts to handle this case, while it should refuse it, like regular materialization did.