FoundationDB/sql-layer — pull request #1424 by tjoneslo (2014-08-28 02:31:02+00:00)
Title: Fix assert insersect ordered

This addresses the assert message in the `Intersect_Ordered` operator when used with look ahead enabled.

The specific cause was the specific query using two look ahead enabled index scans as the left/right inputs to the Intersect Ordered operator. Because of the way the lookahead interacts with the query bindings the IndexScan operator bindings would get ahead of the Intersect_Ordered understanding of where the bindings really were. So have the `Intersect_Ordered#nextBindings()` walk the current binding forward until it catches up with the two input bindings. With multiple checks to ensure it doesn't go too far, and still is correct.

This uncovered two other problems, both dealing with the interaction of the multiple bindings which can change the state of the associated cursors. In Map_NestedLoops, double check that the input cursors are open before trying to call next() on them.

Finally in the `Intersect_ordered#cancelBindings()`, mark the intersect cursor as closed to request the parent operator either skip or re-open the cursor. This is a hack, but required because canceling the bindings will, in some cases also close downstream cursors in a way that requires reopening to reset them.

It also updates some of the debug messages to make it clearer in the future where things are occurring.

Add the two queries from the YAML test that were causing problems to the PostgresPipelineSelectIT test, which runs with lookahead enabled.