Delegate sorting/ordering operation to Datanode/s by  pushing down the ORDER BY
clause to Datanode/s while planning in standard_planner().

Leveraged the already existing merge sort mechanism for RemoteQuery but now
it is executed outside RemoteQuery using Sort plans.

For a Sort plan check if all the expressions on which the result needs to be
sorted are shippable and that the underlying tree allows to push ORDER BY to the
Datanodes. If so, include the ORDER BY clause in the query to be sent to the
Datanodes. If the number of Datanodes which participate in RemoteQuery is not 1,
add a covering Sort node to merge the results from the Datanodes, otherwise,
there is no need for covering Sort plan.

The merge sort mechanism treats every Datanode as a tape and prefetches the
results from the Datanode corresponding to a dwindling tape. This is enabled by
setting the node from where to pull the next row before calling ExecProcNode on
RemoteQueryState.

The same mechanism is being used for Sort plan node under Group or Agg nodes.

Added test xc_sort.sql for testing this functionality. Added GUC
enable_remotesort to enable/disable the optimization along-with the
documentation.

Removed the now useless members sort and tuplesortstate from RemoteQuery and
RemoteQueryState resp.
This commit fixes the bug 3598030, incorrect transaction handling
for direct connection to datanodes.

	modified:   src/backend/access/transam/gtm.c
	modified:   src/backend/access/transam/xact.c
	modified:   src/include/access/gtm.h
This commit fixes the problem that promoted gtm restarts as standby
unless gtm.conf file is modified.

Nikhil Sontakke kindly provided the patch.

Will backport to REL1_0_STABLE too.

	modified:   src/gtm/main/main.c
This commit fixes the bug 3598637 where gtm slave occasionally
crashes.

	modified:   src/gtm/main/gtm_standby.c
	modified:   src/gtm/main/gtm_txn.c
Fix for bug 3597414.
When both the sides of relations are distributed on one node each, they should
share the same node for the JOIN to be pushable.
This is the additional patch to fix the bug 3598637 for the master
branch.  This patch corrects the lock to release, as well as
restoring memory context at error.

	modified:   src/gtm/main/gtm_txn.c
This patch corrects CREATE NODE GROUP description that it works only
locally.

	modified:   doc-xc/src/sgml/ref/create_nodegroup.sgmlin
Merge pull request #2 from postgres-xc/master

pull request