The execution part of the patch seems to be working correctly, but I think there's an improvement - we don't need to execute the outer plan to completion before emitting the first row. For example, let's say the outer plan produces 10000 rows in total and we're supposed to return the first 1% of those rows. We can emit the first row after fetching the first 100 rows, we don't have to wait for fetching all 10k rows.
my other concern is in this case we are going to determine limit and safe row to return on the fly
which have additional computation and i fair that it will not perform better on most of the case