summaryrefslogtreecommitdiff
path: root/src/include/utils
diff options
context:
space:
mode:
authorMichael P2010-08-23 08:00:01 +0000
committerPavan Deolasee2011-05-19 16:45:15 +0000
commitc15d904c93ef6364bb2d9e3213f99359d6ccb893 (patch)
tree77c663fd509ce7b8b2c470f9b0bd2d9812972160 /src/include/utils
parent8a19bf5dfd178b57f7715ca3f267972fcd5ffccc (diff)
Support for Global timestamp in Postgres-XC.
When a transaction is begun on Coordinator, a transaction sending a BEGIN message to GTM receives back a timestamp with the usual GXID. This timestamp is calculated from the clock of GTM server. With that, nodes in the cluster can adjust their own timeline with GTM by calculating a delta value based on the GTM timestamp and their local clock. Like GXID and snapshot, a timestamp is also sent down to Datanodes in case so as to keep consistent timestamp values between coordinator and datanodes. This commit supports global timestamp values for now(), statement_timestamp, transaction_timestamp,current_date, current_time, current_timestamp, localtime, local_timestamp and now(). clock_timestamp and timeofday make their calculation based on the local server clock so they get their results from the local node where it is run. Their use could lead to inconsistencies if used in a transaction involving several Datanodes.
Diffstat (limited to 'src/include/utils')
-rw-r--r--src/include/utils/timestamp.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index 2765d3927f..7c8e744915 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -23,6 +23,10 @@
#include "utils/int8.h"
#endif
+#ifdef PGXC
+#include "pgxc/pgxc.h"
+#endif
+
/*
* Timestamp represents absolute time.
*
@@ -43,6 +47,11 @@
#ifdef HAVE_INT64_TIMESTAMP
+/*
+ * PGXC note: GTM and Postgres-XC packages have to be separated.
+ * Both use use different type names for timestamp, but those types have to be the same!
+ */
+
typedef int64 Timestamp;
typedef int64 TimestampTz;
typedef int64 TimeOffset;
@@ -188,6 +197,10 @@ typedef struct
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) / 1000.0))
#endif
+#ifdef PGXC
+#define InvalidGlobalTimestamp ((TimestampTz) 0)
+#define GlobalTimestampIsValid(timestamp) ((TimestampTz) (timestamp)) != InvalidGlobalTimestamp
+#endif
/* Set at postmaster start */
extern TimestampTz PgStartTime;