DERBY-6688 NPE (or sane: ASSERT failure) with ROW_NUMBER in some subqueries

Backported from trunk with a manual merge as:

svn merge -c 1616332 https://svn.apache.org/repos/asf/db/derby/code/trunk

In FromSubquery (used in the OK subquery) the phasing is different
than in SubqueryNode (used in the failing query): the order by list is
pushed down too late in the SubqueryNode (after the
SelectNode#preprocess), so that the fact that the order by carries an
implicit window definition isn't recorded, causing the "windows" field
to be null, leading to missing rewriting in the getProjectRestrict
phase, hence the error.

In FromSubquery, the order by list is pushed down into the child
select node just before calling its preprocess method, i.e. the order
by list is present what that happens.

The patch (derby-6688-b) moves the pushing down of the order by list
in SubqueryNode#preprocess to the resultSet (the SelectNode) to just
before the call to preprocess of the resultSet, so the rest of the
windows rewriting machinery kicks in.



git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/branches/10.11@1616515 13f79535-47bb-0310-9956-ffa450edef68