Move the WITH-related semantic check bits to the WITH node

Signed-off-by: Jakub Wieczorek <jakub@jakub.cc>
Cleanup of rewriters

Ronja expects ORDER BY and WHERE to contain aliases and not the original expressions,
when possible. Our old legacy planner on the other hand, wants ORDER BY and WHERE to
contain the original expressions. To cater for this, this commit moves
reattachAliasedExpressions so it only runs on queries handled by the legacy planner.

reattachedAliasedExpressions was also refactored to follow the code style of other
rewriters.

Author: Pontus Melke <pontus.melke@neotechnology.com>
Merge pull request #2866 from systay/with-sem-check

Move the WITH-related semantic check bits to the WITH node