PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
regress_injection.c File Reference
#include "postgres.h"
#include "access/table.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "storage/procarray.h"
#include "utils/xid8.h"
Include dependency graph for regress_injection.c:

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (removable_cutoff)
 
Datum removable_cutoff (PG_FUNCTION_ARGS)
 

Function Documentation

◆ PG_FUNCTION_INFO_V1()

PG_FUNCTION_INFO_V1 ( removable_cutoff  )

◆ removable_cutoff()

Datum removable_cutoff ( PG_FUNCTION_ARGS  )

Definition at line 39 of file regress_injection.c.

40{
41 Relation rel = NULL;
42 TransactionId xid;
43 FullTransactionId next_fxid_before,
44 next_fxid;
45
46 /* could take other relkinds callee takes, but we've not yet needed it */
47 if (!PG_ARGISNULL(0))
49
50 /*
51 * No lock or snapshot necessarily prevents oldestXid from advancing past
52 * "xid" while this function runs. That concerns us only in that we must
53 * not ascribe "xid" to the wrong epoch. (That may never arise in
54 * isolation testing, but let's set a good example.) As a crude solution,
55 * retry until nextXid doesn't change.
56 */
57 next_fxid = ReadNextFullTransactionId();
58 do
59 {
61 next_fxid_before = next_fxid;
63 next_fxid = ReadNextFullTransactionId();
64 } while (!FullTransactionIdEquals(next_fxid, next_fxid_before));
65
66 if (rel)
68
70 xid));
71}
uint32 TransactionId
Definition: c.h:623
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define PG_ARGISNULL(n)
Definition: fmgr.h:209
#define AccessShareLock
Definition: lockdefs.h:36
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
TransactionId GetOldestNonRemovableTransactionId(Relation rel)
Definition: procarray.c:2005
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40
#define FullTransactionIdEquals(a, b)
Definition: transam.h:50
static FullTransactionId FullTransactionIdFromAllowableAt(FullTransactionId nextFullXid, TransactionId xid)
Definition: transam.h:381
FullTransactionId ReadNextFullTransactionId(void)
Definition: varsup.c:288
#define PG_RETURN_FULLTRANSACTIONID(X)
Definition: xid8.h:30

References AccessShareLock, CHECK_FOR_INTERRUPTS, FullTransactionIdEquals, FullTransactionIdFromAllowableAt(), GetOldestNonRemovableTransactionId(), PG_ARGISNULL, PG_GETARG_OID, PG_RETURN_FULLTRANSACTIONID, ReadNextFullTransactionId(), table_close(), and table_open().