I have just committed changes that alter the representation of
SortClause nodes (making them like GroupClause, instead of the
crufty way they were done before). This breaks stored rules!
You will need to initdb next time you pull current sources...
The good news is that the optimizer is finally reasonably smart
about avoiding a top-level Sort operation.
regards, tom lane