Remove duplication of functions get_xc_node_name and is_prepared_on_node

Those functions were created in regression tests xc_for_update and
xc_prepared_xacts. Now their creation is done in xc_create_function.
Merge branch 'master' into remotecopy
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.
Merge branch 'master' into remotecopy
Fix due to comments from Ashutosh