summaryrefslogtreecommitdiff
path: root/src/backend/access/transam
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2006-04-25 00:25:22 +0000
committerBruce Momjian <bruce@momjian.us>2006-04-25 00:25:22 +0000
commite6004f01518bb7c9c2c1fdf7e5fa4fa4a3e572f3 (patch)
treede46c5948ecbb3ef7e833d0c349ddb449ba94926 /src/backend/access/transam
parentf04080d73b64ea24f7c12ffda43ee605cb2e4a8c (diff)
downloadpostgresql-e6004f01518bb7c9c2c1fdf7e5fa4fa4a3e572f3.tar.gz
Add statement_timestamp(), clock_timestamp(), and
transaction_timestamp() (just like now()). Also update statement_timeout() to mention it is statement arrival time that is measured. Catalog version updated.
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r--src/backend/access/transam/xact.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 0bbe2c0d49..b59cea044b 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.219 2006/03/29 21:17:37 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.220 2006/04/25 00:25:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,6 +172,7 @@ static CommandId currentCommandId;
* keep it inside the TransactionState stack.
*/
static TimestampTz xactStartTimestamp;
+static TimestampTz stmtStartTimestamp;
/*
* GID to be used for preparing the current transaction. This is also
@@ -428,6 +429,24 @@ GetCurrentTransactionStartTimestamp(void)
}
/*
+ * GetCurrentStatementStartTimestamp
+ */
+TimestampTz
+GetCurrentStatementStartTimestamp(void)
+{
+ return stmtStartTimestamp;
+}
+
+/*
+ * SetCurrentStatementStartTimestamp
+ */
+void
+SetCurrentStatementStartTimestamp(void)
+{
+ stmtStartTimestamp = GetCurrentTimestamp();
+}
+
+/*
* GetCurrentTransactionNestLevel
*
* Note: this will return zero when not inside any transaction, one when
@@ -1367,9 +1386,9 @@ StartTransaction(void)
XactLockTableInsert(s->transactionId);
/*
- * set now()
+ * now() and statement_timestamp() should be the same time
*/
- xactStartTimestamp = GetCurrentTimestamp();
+ xactStartTimestamp = stmtStartTimestamp;
/*
* initialize current transaction state fields