Fix a few compiler warnings.
authorPavan Deolasee <[email protected]>
Wed, 17 Feb 2016 12:37:21 +0000 (18:07 +0530)
committerPavan Deolasee <[email protected]>
Thu, 18 Feb 2016 06:54:02 +0000 (12:24 +0530)
21 files changed:
src/backend/access/transam/gtm.c
src/backend/access/transam/transam.c
src/backend/access/transam/xact.c
src/backend/bootstrap/bootstrap.c
src/backend/optimizer/util/pgxcship.c
src/backend/pgxc/pool/execRemote.c
src/backend/pgxc/pool/pgxcnode.c
src/backend/pgxc/squeue/squeue.c
src/backend/postmaster/clustermon.c
src/backend/storage/ipc/ipci.c
src/backend/storage/ipc/procarray.c
src/backend/tcop/postgres.c
src/backend/utils/init/postinit.c
src/gtm/client/gtm_client.c
src/gtm/common/gtm_opt_handler.c
src/gtm/main/gtm_txn.c
src/include/access/gtm.h
src/include/gtm/gtm_client.h
src/include/gtm/gtm_txn.h
src/include/postgres.h
src/include/postmaster/clustermon.h

index 64f39d19ad3550f0d357f33411fade6f77524c50..210e70b1752208be4eeb71b5cfa872dc0e7d109a 100644 (file)
@@ -681,7 +681,7 @@ UnregisterGTM(GTM_PGXCNodeType type)
  * Report BARRIER
  */
 int
-ReportBarrierGTM(char *barrier_id)
+ReportBarrierGTM(const char *barrier_id)
 {
        if (!gtm_backup_barrier)
                return EINVAL;
index 71e3015d37cffa7e2cd7e48a5eb83aeb6cbf7d85..878a4b768af0f544a81ccc043b4b3c06d967cac8 100644 (file)
@@ -25,6 +25,7 @@
 #include "utils/snapmgr.h"
 
 #ifdef PGXC
+#include "storage/procarray.h"
 #include "utils/builtins.h"
 #endif
 
index 8aaa6f20bde45284ad343eb8888c8c641da52514..339c22e01f12d9d671c3156e702312e5e1eedaca 100644 (file)
@@ -2478,6 +2478,7 @@ CommitTransaction(void)
                 * durably commit.
                 */
 #ifdef XCP
+               latestXid = InvalidTransactionId;
                if (!IsConnFromDatanode())
 #endif
                        latestXid = RecordTransactionCommit();
index d2248df5408ccc079abfe641d1499249f4c42ae2..06d55d7b64e1eb19aedf75996f38561724394e70 100644 (file)
@@ -33,6 +33,7 @@
 #include "nodes/makefuncs.h"
 #include "pg_getopt.h"
 #include "postmaster/bgwriter.h"
+#include "postmaster/clustermon.h"
 #include "postmaster/startup.h"
 #include "postmaster/walwriter.h"
 #include "replication/walreceiver.h"
index 5c237eab08a223af5237fc63323d79f1802335cf..d943b63b0f5739fc07cc05a5cae49c3677e279f9 100644 (file)
@@ -1458,7 +1458,7 @@ pgxc_find_dist_equijoin_qual(Relids varnos_1,
 
        /* If no quals, no equijoin */
        if (!quals)
-               return false;
+               return NULL;
        /*
         * Make a copy of the argument bitmaps, it will be modified by
         * bms_first_member().
index 0a21135ba46c3562693912a7069bf03acb76bf61..cce9746329ee1a37a48d59d5217307929e6ec8ad 100644 (file)
@@ -1184,7 +1184,7 @@ FetchTuple(ResponseCombiner *combiner)
                for (;;)
                {
                        Datum   value = (Datum) 0;
-                       bool    isnull;
+                       bool    isnull = false;
                        int     numnodes;
                        int             i;
 
@@ -4138,6 +4138,25 @@ FinishRemotePreparedTransaction(char *prepareGID, bool commit)
        GlobalTransactionId             gxid, prepare_gxid;
        bool                                    prepared_local = false;
 
+       /*
+        * Get the list of nodes involved in this transaction.
+        *
+        * This function returns the GXID of the prepared transaction. It also
+        * returns a fresh GXID which can be used for running COMMIT PREPARED
+        * commands on the remote nodes. Both these GXIDs can then be either
+        * committed or aborted together.
+        *
+        * XXX While I understand that we get the prepared and a new GXID with a
+        * single call, it doesn't look nicer and create confusion. We should
+        * probably split them into two parts. This is used only for explicit 2PC
+        * which should not be very common in XC
+        */
+       if (GetGIDDataGTM(prepareGID, &gxid, &prepare_gxid, &nodestring) < 0)
+               ereport(ERROR,
+                               (errcode(ERRCODE_INTERNAL_ERROR),
+                                errmsg("prepared transaction with identifier \"%s\" does not exist",
+                                               prepareGID)));
+
        /*
         * Please note that with xc_maintenance_mode = on, COMMIT/ROLLBACK PREPARED will not
         * propagate to remote nodes. Only GTM status is cleaned up.
@@ -4158,24 +4177,6 @@ FinishRemotePreparedTransaction(char *prepareGID, bool commit)
                return false;
        }
 
-       /*
-        * Get the list of nodes involved in this transaction.
-        *
-        * This function returns the GXID of the prepared transaction. It also
-        * returns a fresh GXID which can be used for running COMMIT PREPARED
-        * commands on the remote nodes. Both these GXIDs can then be either
-        * committed or aborted together.
-        *
-        * XXX While I understand that we get the prepared and a new GXID with a
-        * single call, it doesn't look nicer and create confusion. We should
-        * probably split them into two parts. This is used only for explicit 2PC
-        * which should not be very common in XC
-        */
-       if (GetGIDDataGTM(prepareGID, &gxid, &prepare_gxid, &nodestring) < 0)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INTERNAL_ERROR),
-                                errmsg("prepared transaction with identifier \"%s\" does not exist",
-                                               prepareGID)));
        prepared_local = pgxc_node_remote_finish(prepareGID, commit, nodestring,
                                                                                         gxid, prepare_gxid);
 
index b10340328028cffb6b4f3829a623f87b9b82e583..f3674867206b9f75199f81e6e9054df31fa606ef 100644 (file)
@@ -525,7 +525,7 @@ retry:
        if (poll_val == 0)
        {
                /* Handle timeout */
-               elog(DEBUG1, "timeout %d while waiting for any response from %d connections", timeout_ms,conn_count);
+               elog(DEBUG1, "timeout %ld while waiting for any response from %d connections", timeout_ms,conn_count);
                for (i = 0; i < conn_count; i++)
                        connections[i]->state = DN_CONNECTION_STATE_ERROR_FATAL;
                return NO_ERROR_OCCURED;
index 5ede9d5373c3f4b014be8bec1a5148d0c6846e0e..6b96208fa97b6e06faf953a78a884c81fe326c59 100644 (file)
@@ -1469,7 +1469,6 @@ SharedQueueRelease(const char *sqname)
        {
                volatile SQueueSync    *sqsync = sq->sq_sync;
                int                                             i;
-               char                                    ntype = PGXC_NODE_DATANODE;
 
                Assert(sqsync && sqsync->queue == sq);
 
index e2dda4f7f3b130e9565efdc821bdb30b4cb05d01..d987aa1eaf30acaa0ea35452a54419a761d44157 100644 (file)
@@ -26,6 +26,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#include "access/gtm.h"
 #include "access/transam.h"
 #include "access/xact.h"
 #include "gtm/gtm_c.h"
@@ -36,7 +37,9 @@
 #include "postmaster/clustermon.h"
 #include "postmaster/fork_process.h"
 #include "postmaster/postmaster.h"
+#include "storage/ipc.h"
 #include "storage/proc.h"
+#include "storage/procarray.h"
 #include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/memutils.h"
@@ -49,7 +52,6 @@ static bool am_clustermon = false;
 
 /* Flags set by signal handlers */
 static volatile sig_atomic_t got_SIGHUP = false;
-static volatile sig_atomic_t got_SIGUSR2 = false;
 static volatile sig_atomic_t got_SIGTERM = false;
 
 /* Memory context for long-lived data */
@@ -59,7 +61,6 @@ static ClusterMonitorCtlData *ClusterMonitorCtl = NULL;
 static void cm_sighup_handler(SIGNAL_ARGS);
 static void cm_sigterm_handler(SIGNAL_ARGS);
 static void ClusterMonitorSetReportedGlobalXmin(GlobalTransactionId xmin);
-static GlobalTransactionId ClusterMonitorGetReportedGlobalXmin(void);
 static void ClusterMonitorSetReportingGlobalXmin(GlobalTransactionId xmin);
 
 /* PID of clustser monitoring process */
@@ -214,7 +215,7 @@ ClusterMonitorInit(void)
                {
                        elog(DEBUG1, "Failed (status %d) to report RecentGlobalXmin "
                                        "- reported RecentGlobalXmin %d, received "
-                                       "RecentGlobalXmin %d, " "received latestCompletedXid",
+                                       "RecentGlobalXmin %d, " "received latestCompletedXid %d",
                                        status, oldestXmin, newOldestXmin,
                                        latestCompletedXid);
                        if (status == GTM_ERRCODE_TOO_OLD_XMIN ||
@@ -415,18 +416,6 @@ ClusterMonitorSetReportedGlobalXmin(GlobalTransactionId xmin)
        SpinLockRelease(&ClusterMonitorCtl->mutex);
 }
 
-static GlobalTransactionId
-ClusterMonitorGetReportedGlobalXmin(void)
-{
-       GlobalTransactionId reported_xmin;
-
-       SpinLockAcquire(&ClusterMonitorCtl->mutex);
-       reported_xmin = ClusterMonitorCtl->reported_recent_global_xmin;
-       SpinLockRelease(&ClusterMonitorCtl->mutex);
-
-       return reported_xmin;
-}
-
 static void
 ClusterMonitorSetReportingGlobalXmin(GlobalTransactionId xmin)
 {
index 6804367fa30a7e1a0be489ffce563a187fff40f4..e3383e31a202bd0097fa195f69c6dfa716920050 100644 (file)
@@ -33,6 +33,7 @@
 #include "pgxc/nodemgr.h"
 #endif
 #include "postmaster/autovacuum.h"
+#include "postmaster/clustermon.h"
 #include "postmaster/bgworker_internals.h"
 #include "postmaster/bgwriter.h"
 #include "postmaster/postmaster.h"
index b7fc75d52dacca3366e3a56c525c2c3e57c7518c..59826501fd311d3549a1758b9d01a8e90ecded69 100644 (file)
@@ -4407,9 +4407,6 @@ ProcArrayCheckXminConsistency(TransactionId global_xmin)
 void
 SetLatestCompletedXid(TransactionId latestCompletedXid)
 {
-       int index;
-       ProcArrayStruct *arrayP = procArray;
-
        if (!TransactionIdIsValid(latestCompletedXid))
                return;
        /*
index 65d568542b1f0154d08c86a1565d245abff7766c..1c67b4e77a738646e374d1b4f4299e0dd99eb029 100644 (file)
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
-
-#ifndef HAVE_GETRUSAGE
-#include "rusagestub.h"
-#endif
 
 #include "access/parallel.h"
 #include "access/printtup.h"
index 45e8a9e793f91bffc067d4b4d5b08a2148906038..f9c2396eca3fff3a8ea79de7912fa21ba9775582 100644 (file)
@@ -45,6 +45,7 @@
 #include "pgxc/pgxc.h"
 #endif
 #include "postmaster/autovacuum.h"
+#include "postmaster/clustermon.h"
 #include "postmaster/postmaster.h"
 #include "replication/walsender.h"
 #include "storage/bufmgr.h"
index be1f6b27cd5f4ab2715d427e407de4cb38ae53a0..fadaa384e5b531f12a7853d19e0283142d4de799 100644 (file)
@@ -422,7 +422,7 @@ send_failed:
 int
 bkup_begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
                                           bool read_only,
-                                          char *global_sessionid,
+                                          const char *global_sessionid,
                                           uint32 client_id, GTM_Timestamp timestamp)
 {
        uint32 global_sessionid_len = global_sessionid ?
@@ -459,7 +459,7 @@ send_failed:
 int
 bkup_begin_transaction_gxid(GTM_Conn *conn, GlobalTransactionId gxid,
                                                        GTM_IsolationLevel isolevel, bool read_only,
-                                                       char *global_sessionid,
+                                                       const char *global_sessionid,
                                                        uint32 client_id, GTM_Timestamp timestamp)
 {
        uint32 global_sessionid_len = global_sessionid ?
@@ -495,7 +495,7 @@ send_failed:
 
 GlobalTransactionId
 begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
-               char *global_sessionid,
+               const char *global_sessionid,
                GTM_Timestamp *timestamp)
 {
        bool txn_read_only = false;
@@ -1996,7 +1996,7 @@ int
 bkup_begin_transaction_multi(GTM_Conn *conn, int txn_count,
                                                         GlobalTransactionId *gxid, GTM_IsolationLevel *isolevel,
                                                         bool *read_only,
-                                                        char *txn_global_sessionid[], 
+                                                        const char *txn_global_sessionid[], 
                                                         uint32 *client_id,
                                                         GTMProxy_ConnID *txn_connid)
 {
index 34415ba2c5bec3bd23ef22707c0d23232c79e7a7..533d38ec7ef71cc51438ac27a330f7c523cbb31c 100644 (file)
@@ -15,6 +15,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#include "postgres.h"
 #include "mb/pg_wchar.h"
 #include "gtm/path.h"
 #include "gtm/assert.h"
index bc678f9770d723751d5676d030449b9bfc0f89e4..18f01832c3e62e0301169242e81363b84ecab7f9 100644 (file)
@@ -1611,7 +1611,7 @@ ProcessBeginTransactionGetGXIDCommandMulti(Port *myport, StringInfo message)
        GTM_IsolationLevel txn_isolation_level[GTM_MAX_GLOBAL_TRANSACTIONS];
        bool txn_read_only[GTM_MAX_GLOBAL_TRANSACTIONS];
        uint32 txn_global_sessionid_len;
-       char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
+       const char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
        int txn_count, new_txn_count;
        StringInfoData buf;
        GTM_TransactionHandle txn[GTM_MAX_GLOBAL_TRANSACTIONS];
@@ -1729,7 +1729,7 @@ ProcessBkupBeginTransactionGetGXIDCommandMulti(Port *myport, StringInfo message)
        GTM_IsolationLevel txn_isolation_level[GTM_MAX_GLOBAL_TRANSACTIONS];
        bool txn_read_only[GTM_MAX_GLOBAL_TRANSACTIONS];
        uint32 txn_global_sessionid_len;
-       char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
+       const char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
        GTMProxy_ConnID txn_connid[GTM_MAX_GLOBAL_TRANSACTIONS];
        uint32 txn_client_id[GTM_MAX_GLOBAL_TRANSACTIONS];
        int ii;
@@ -1769,7 +1769,7 @@ ProcessCommitTransactionCommand(Port *myport, StringInfo message, bool is_backup
        MemoryContext oldContext;
        int status = STATUS_OK;
        int waited_xid_count;
-       GlobalTransactionId *waited_xids;
+       GlobalTransactionId *waited_xids = NULL;
 
        const char *data = pq_getmsgbytes(message, sizeof (gxid));
 
@@ -1783,7 +1783,7 @@ ProcessCommitTransactionCommand(Port *myport, StringInfo message, bool is_backup
        waited_xid_count = pq_getmsgint(message, sizeof (int));
        if (waited_xid_count > 0)
        {
-               waited_xids = pq_getmsgbytes(message,
+               waited_xids = (GlobalTransactionId *) pq_getmsgbytes(message,
                                waited_xid_count * sizeof (GlobalTransactionId));
        }
 
@@ -1870,7 +1870,7 @@ ProcessCommitPreparedTransactionCommand(Port *myport, StringInfo message, bool i
        int status[txn_count];
        int ii;
        int waited_xid_count;
-       GlobalTransactionId *waited_xids;
+       GlobalTransactionId *waited_xids = NULL;
 
        for (ii = 0; ii < txn_count; ii++)
        {
@@ -1887,7 +1887,7 @@ ProcessCommitPreparedTransactionCommand(Port *myport, StringInfo message, bool i
        waited_xid_count = pq_getmsgint(message, sizeof (int));
        if (waited_xid_count > 0)
        {
-               waited_xids = pq_getmsgbytes(message,
+               waited_xids = (GlobalTransactionId *) pq_getmsgbytes(message,
                                waited_xid_count * sizeof (GlobalTransactionId));
        }
 
index 67cea55bd4a06b33b098406bdfe5e815ea3f354a..bf7c889c66a76827d313c57f5901387204acc336 100644 (file)
@@ -61,7 +61,7 @@ extern int AlterSequenceGTM(char *seqname, GTM_Sequence increment,
 extern int DropSequenceGTM(char *name, GTM_SequenceKeyType type);
 extern int RenameSequenceGTM(char *seqname, const char *newseqname);
 /* Barrier */
-extern int ReportBarrierGTM(char *barrier_id);
+extern int ReportBarrierGTM(const char *barrier_id);
 extern int ReportGlobalXmin(GlobalTransactionId gxid,
                GlobalTransactionId *global_xmin,
                GlobalTransactionId *latest_completed_xid);
index df785e6fa2652f4a570e3a4e1f85ab51cefcf1ba..ddb092ab48e89163b704932089b57d05b69edf1c 100644 (file)
@@ -185,14 +185,14 @@ size_t get_sequence_list(GTM_Conn *, GTM_SeqInfo **);
  * Transaction Management API
  */
 GlobalTransactionId begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
-                                                 char *global_sessionid,
+                                                 const char *global_sessionid,
                                                  GTM_Timestamp *timestamp);
 int bkup_begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
-                                                  bool read_only, char *global_sessionid,
+                                                  bool read_only, const char *global_sessionid,
                                                   uint32 client_id, GTM_Timestamp timestamp);
 int bkup_begin_transaction_gxid(GTM_Conn *conn, GlobalTransactionId gxid,
                                                                GTM_IsolationLevel isolevel, bool read_only,
-                                                               char *global_sessionid,
+                                                               const char *global_sessionid,
                                                                uint32 client_id, GTM_Timestamp timestamp);
 
 GlobalTransactionId begin_transaction_autovacuum(GTM_Conn *conn, GTM_IsolationLevel isolevel);
@@ -231,7 +231,7 @@ int
 bkup_begin_transaction_multi(GTM_Conn *conn, int txn_count,
                                                         GlobalTransactionId *gxid, GTM_IsolationLevel *isolevel,
                                                         bool *read_only,
-                                                        char *txn_global_sessionid[], 
+                                                        const char *txn_global_sessionid[], 
                                                         uint32 *client_id,
                                                         GTMProxy_ConnID *txn_connid);
 int
index d746105af354e8141d3897a9d423ff2b753aa672..0a7b38b29cdb0e6df785381d2cf70201955b8c6f 100644 (file)
@@ -188,6 +188,7 @@ GTM_TransactionStates GTM_GetStatus(GTM_TransactionHandle txn);
 GTM_TransactionStates GTM_GetStatusGXID(GlobalTransactionId gxid);
 int GTM_GetAllTransactions(GTM_TransactionInfo txninfo[], uint32 txncnt);
 void GTM_RemoveAllTransInfos(uint32 client_id, int backend_id);
+uint32 GTMGetFirstClientIdentifier(void);
 uint32 GTMGetLastClientIdentifier(void);
 
 GTM_Snapshot GTM_GetSnapshotData(GTM_TransactionInfo *my_txninfo,
index c0e43643c27f355e8fd88c2850d3d393a7f7329e..142d7813441a46a4ad73e2180a137a317324f163 100644 (file)
 #include "utils/elog.h"
 #include "utils/palloc.h"
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+#ifndef HAVE_GETRUSAGE
+#include "rusagestub.h"
+#endif
+
 /* ----------------------------------------------------------------
  *                             Section 1:      variable-length datatypes (TOAST support)
  * ----------------------------------------------------------------
@@ -723,4 +732,10 @@ extern void ExceptionalCondition(const char *conditionName,
 //#define PGXC_COORD  // for PGXC coordinator compiling
 //#define PGXC_DATANODE // for PGXC data node compiling
 
+
+extern void ResetUsageCommon(struct rusage *save_r, struct timeval *save_t);
+extern void ResetUsage(void);
+extern void ShowUsageCommon(const char *title, struct rusage *save_r, struct
+               timeval *save_t);
+
 #endif   /* POSTGRES_H */
index 2cd0aefc01d58229ea848d232149ed05b66f9df2..953d6787ebbc8fbb2cbb322e3931cee7cf73a521 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef CLUSTERMON_H
 #define CLUSTERMON_H
 
+#include "gtm/gtm_c.h"
+
 typedef struct
 {
        slock_t                         mutex;
@@ -33,7 +35,10 @@ extern bool IsClusterMonitorProcess(void);
 extern int     StartClusterMonitor(void);
 GlobalTransactionId ClusterMonitorGetGlobalXmin(void);
 void ClusterMonitorSetGlobalXmin(GlobalTransactionId xmin);
-GlobalTransactionId ClusterMonitorGetReportingXmin(void);
+extern GlobalTransactionId ClusterMonitorGetReportingGlobalXmin(void);
+
+Size ClusterMonitorShmemSize(void);
+void ClusterMonitorShmemInit(void);
 
 #ifdef EXEC_BACKEND
 extern void ClusterMonitorIAm(void);