Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b06679e0
Commit
b06679e0
authored
May 11, 2012
by
Simon Riggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure age() returns a stable value rather than the latest value
parent
3652d72d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
src/backend/access/transam/xact.c
src/backend/access/transam/xact.c
+22
-0
src/backend/utils/adt/xid.c
src/backend/utils/adt/xid.c
+3
-5
src/include/access/xact.h
src/include/access/xact.h
+1
-0
No files found.
src/backend/access/transam/xact.c
View file @
b06679e0
...
...
@@ -391,6 +391,28 @@ GetCurrentTransactionIdIfAny(void)
}
/*
* GetStableLatestTransactionIdIfAny
*
* Get the latest XID once and then return same value for rest of transaction.
* Acts as a useful reference point for maintenance tasks.
*/
TransactionId
GetStableLatestTransactionId
(
void
)
{
static
LocalTransactionId
lxid
=
InvalidLocalTransactionId
;
static
TransactionId
stablexid
=
InvalidTransactionId
;
if
(
lxid
!=
MyProc
->
lxid
||
!
TransactionIdIsValid
(
stablexid
))
{
lxid
=
MyProc
->
lxid
;
stablexid
=
ReadNewTransactionId
();
}
return
stablexid
;
}
/*
* AssignTransactionId
*
...
...
src/backend/utils/adt/xid.c
View file @
b06679e0
...
...
@@ -19,6 +19,7 @@
#include "access/transam.h"
#include "access/xact.h"
#include "libpq/pqformat.h"
#include "storage/proc.h"
#include "utils/builtins.h"
#define PG_GETARG_TRANSACTIONID(n) DatumGetTransactionId(PG_GETARG_DATUM(n))
...
...
@@ -87,16 +88,13 @@ xideq(PG_FUNCTION_ARGS)
}
/*
* xid_age - compute age of an XID (relative to
current xact
)
* xid_age - compute age of an XID (relative to
latest stable xid
)
*/
Datum
xid_age
(
PG_FUNCTION_ARGS
)
{
TransactionId
xid
=
PG_GETARG_TRANSACTIONID
(
0
);
TransactionId
now
=
GetTopTransactionIdIfAny
();
if
(
!
TransactionIdIsValid
(
now
))
now
=
ReadNewTransactionId
();
TransactionId
now
=
GetStableLatestTransactionId
();
/* Permanent XIDs are always infinitely old */
if
(
!
TransactionIdIsNormal
(
xid
))
...
...
src/include/access/xact.h
View file @
b06679e0
...
...
@@ -209,6 +209,7 @@ extern TransactionId GetTopTransactionId(void);
extern
TransactionId
GetTopTransactionIdIfAny
(
void
);
extern
TransactionId
GetCurrentTransactionId
(
void
);
extern
TransactionId
GetCurrentTransactionIdIfAny
(
void
);
extern
TransactionId
GetStableLatestTransactionId
(
void
);
extern
SubTransactionId
GetCurrentSubTransactionId
(
void
);
extern
CommandId
GetCurrentCommandId
(
bool
used
);
extern
TimestampTz
GetCurrentTransactionStartTimestamp
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment