PostgreSQL Source Code git master
Loading...
Searching...
No Matches
regress_injection.c File Reference
#include "postgres.h"
#include "access/table.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "postmaster/autovacuum.h"
#include "storage/procarray.h"
#include "utils/rel.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 42 of file regress_injection.c.

43{
44 Relation rel = NULL;
45 TransactionId xid;
47 next_fxid;
48
49 /* could take other relkinds callee takes, but we've not yet needed it */
50 if (!PG_ARGISNULL(0))
52
53 if (rel != NULL && !rel->rd_rel->relisshared && autovacuum_start_daemon)
55 "removable_cutoff(non-shared-rel) can move backward under autovacuum=on");
56
57 /*
58 * No lock or snapshot necessarily prevents oldestXid from advancing past
59 * "xid" while this function runs. That concerns us only in that we must
60 * not ascribe "xid" to the wrong epoch. (That may never arise in
61 * isolation testing, but let's set a good example.) As a crude solution,
62 * retry until nextXid doesn't change.
63 */
64 next_fxid = ReadNextFullTransactionId();
65 do
66 {
68 next_fxid_before = next_fxid;
70 next_fxid = ReadNextFullTransactionId();
71 } while (!FullTransactionIdEquals(next_fxid, next_fxid_before));
72
73 if (rel)
75
77 xid));
78}
bool autovacuum_start_daemon
Definition autovacuum.c:117
uint32 TransactionId
Definition c.h:666
#define WARNING
Definition elog.h:36
#define elog(elevel,...)
Definition elog.h:226
#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:123
static int fb(int x)
TransactionId GetOldestNonRemovableTransactionId(Relation rel)
Definition procarray.c:1950
Form_pg_class rd_rel
Definition rel.h:111
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:443
FullTransactionId ReadNextFullTransactionId(void)
Definition varsup.c:288
#define PG_RETURN_FULLTRANSACTIONID(X)
Definition xid8.h:30

References AccessShareLock, autovacuum_start_daemon, CHECK_FOR_INTERRUPTS, elog, fb(), FullTransactionIdEquals, FullTransactionIdFromAllowableAt(), GetOldestNonRemovableTransactionId(), PG_ARGISNULL, PG_GETARG_OID, PG_RETURN_FULLTRANSACTIONID, RelationData::rd_rel, ReadNextFullTransactionId(), table_close(), table_open(), and WARNING.