Refactoring of gram.y for distribution clauses

This refactoring allows the usage of clauses TO NODE, TO GROUP and
DISTRIBUTE BY in a more flexible way by decoupling empty extensions.
This is particularly useful to plug-in those clauses to other existing
SQL of Postgres.
A slight grammar modification is being introduced in this commit, which
is the addition of brackets when defining a node list. This has consequences
on the following queries:
- EXECUTE DIRECT
- CLEAN CONNECTION
- CREATE TABLE (subset of nodes)
- CREATE TABLE AS
- CREATE NODE GROUP
This simple modification allows the use of TO NODE/TO GROUP extensions
when they are listed in a list of commands separated by commas.
By the way, this modification really lowers the possibility of
shift-reduce conflicts in bison when implementing new features in XC
using existing clauses.
Correct whitespaces, format and message format in gtm_client.c

This had consequences on the data types of the values sent by
GTM which was not matching those GTM Standby was trying to read.

Patch by Andrei Martsinchyk
Remove duplicate block of code looking in gtm_serialize.c

It looks like it was accidentally copy/pasted. This has as consequence
to write the coordinator name twice when serializing, so the result
could not be deserialized properly.

Patch by Andrei Martsinchyk
Solve SEGENV for GTM-Standby

Wrong variable was referenced when writing terminating null at the
end of a string. It caused seg faults, because the referenced variable
was not initialized yet.

Patch by Andrei Martsinchyk.
Introduce new GTM thread status managing thread backup

In the case of a GTM standby crash during the initial backup, the
master GTM remained locked. The origin of this problem was during
GTM backup process, where GTM locks all its threads one by one,
performs a backup and then releases everything.
This commit adds an additional control layer able to detect the
thread status during backup. The new status GTM_THREAD_BACKUP is
introduced for this purpose. Once backup is performed, the thread
status is changed to GTM_THREAD_RUNNING.
Hence, if the handler (GTM) is invoked upon sudden disconnection for
backend (here GTM-Standby) disconnect of its connection and it sees
that the current thread has status GTM_THREAD_BACKUP it goes ahead
and releases the locks.

This commit also includes some fixes for whitespaces.

Patch by Andrei Martsinchyk
Release GTM thread lock before exit

This avoid to have another thread waiting for it, as it is possible
it waits for it.

Patch by Andrei Martsinchyk
Block GXID generation on standbys

If a node accidentally connects to the Standby and reconnects to the
Master afterwards, it will get an inconsistent GXID value since GTM
Master is not aware of GXIDs generated by GTM Standby.

Patch by Andrei Martsinchyk
Refactor functions for management and interpretation of distribution clauses

This commit externalizes all the features used for the interpretation
of SQL clauses TO NODE, TO GROUP and DISTRIBUTE BY. This reduces the footprint
of XC code in heap.c. It is important to note here that this code cannot be
completely removed from heap.c as there is a necessary dependency regarding
system columns that cannot be used as distribution columns for HASH and MODULO
tables.
Remove all the trailing whitespaces in GTM code
Remove all the trailing whitespaces in XC backend files

This includes locator, XC planner, pool, barrier and node manager.
This clean-up should have been done long ago...
Remove trailing whitespaces in contrib module pgxc_clean
Correct grammar of EXECUTE DIRECT in pgxc_clean

This is a consequence of commit 011b1d7.
Simplify reconnection protocol of GTM-Proxy to GTM

With this commit, reconnection of a GTM-Proxy to a GTM instance
is controlled only with the interval time between 2 reconnections.
While being in reconnection waiting process, it is possible to
specify new GTM connection information with gtm_ctl reconnect.

In consequence, 5 setting parameters of GTM-Proxy are removed here:
- err_wait_count
- err_wait_interval
- err_wait_idle
- gtm_connect_retry_count
- gtm_connect_retry_idle
Related information and documentation also is removed.
Refactor COPY command code exclusive to Postgres-XC

Some functionalities related to relation locator determination
depending on the COPY operation done and remote query generation
are removed from copy.c to remotecopy.c and added in an XC-only
specific file for two reasons:
1) Externalize the process of COPY to allow other modules to use it.
2) Reduce the footprint of XC code in postgres core code.

The information of CopyStateData is necessary to generate a complete
remote query but this data is private to copy.c, so an intermediate
structure is used here to complete the externalization of those
functionalities. If in a (distant?) future, CopyStateData is removed
outside copy.c, we should use the same data for remotecopy.c, however
this is still not the case in Postgres 9.2.
Merge branch 'master' into altertable2

Conflicts:
	src/backend/catalog/heap.c
	src/backend/commands/copy.c
	src/backend/pgxc/Makefile
	src/backend/pgxc/copy/Makefile
	src/backend/pgxc/copy/remotecopy.c
	src/include/pgxc/remotecopy.h