48 #define USE_BSEARCH_IF_NXIP_GREATER 30
70 #define PG_SNAPSHOT_SIZE(nxip) \
71 (offsetof(pg_snapshot, xip) + sizeof(FullTransactionId) * (nxip))
72 #define PG_SNAPSHOT_MAX_NXIP \
73 ((MaxAllocSize - offsetof(pg_snapshot, xip)) / sizeof(FullTransactionId))
80 "possible overflow in pg_current_snapshot()");
110 if (extracted_xid != NULL)
111 *extracted_xid = xid;
123 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
124 errmsg(
"transaction ID %llu is in the future",
145 if (oldest_xid <= now_epoch_next_xid)
230 #ifdef USE_BSEARCH_IF_NXIP_GREATER
245 for (
i = 0;
i < snap->
nxip;
i++)
308 const char *str_start =
str;
351 else if (*
str !=
'\0')
359 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
360 errmsg(
"invalid input syntax for type %s: \"%s\"",
361 "pg_snapshot", str_start)));
427 for (
i = 0;
i < nxip;
i++)
480 for (
i = 0;
i < snap->
nxip;
i++)
525 for (
i = 0;
i < nxip;
i++)
552 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
553 errmsg(
"invalid external pg_snapshot data")));
575 for (
i = 0;
i < snap->
nxip;
i++)
695 status =
"in progress";
697 status =
"committed";
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define strtou64(str, endptr, base)
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define ereport(elevel,...)
#define PG_GETARG_VARLENA_P(n)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_CSTRING(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
bool LWLockHeldByMe(LWLock *lock)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void pfree(void *pointer)
void * MemoryContextAlloc(MemoryContext context, Size size)
#define qsort(a, b, c, d)
bool TransactionIdIsInProgress(TransactionId xid)
static size_t qunique(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
Snapshot GetActiveSnapshot(void)
StringInfo makeStringInfo(void)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
StringInfoData * StringInfo
MemoryContext multi_call_memory_ctx
TransactionId oldestClogXid
FullTransactionId xip[FLEXIBLE_ARRAY_MEMBER]
bool TransactionIdDidCommit(TransactionId transactionId)
bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
#define FullTransactionIdEquals(a, b)
#define EpochFromFullTransactionId(x)
#define U64FromFullTransactionId(x)
static FullTransactionId FullTransactionIdFromU64(uint64 value)
#define FullTransactionIdFollowsOrEquals(a, b)
#define XidFromFullTransactionId(x)
#define TransactionIdIsValid(xid)
static FullTransactionId FullTransactionIdFromEpochAndXid(uint32 epoch, TransactionId xid)
#define TransactionIdIsNormal(xid)
#define InvalidFullTransactionId
#define FullTransactionIdPrecedes(a, b)
#define FullTransactionIdIsValid(x)
void PreventCommandDuringRecovery(const char *cmdname)
#define SET_VARSIZE(PTR, len)
text * cstring_to_text(const char *s)
FullTransactionId ReadNextFullTransactionId(void)
TransamVariablesData * TransamVariables
static const unsigned __int64 epoch
FullTransactionId GetTopFullTransactionId(void)
FullTransactionId GetTopFullTransactionIdIfAny(void)
#define PG_GETARG_FULLTRANSACTIONID(X)
static Datum FullTransactionIdGetDatum(FullTransactionId X)
#define PG_RETURN_FULLTRANSACTIONID(X)
static bool TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
Datum pg_snapshot_send(PG_FUNCTION_ARGS)
Datum pg_current_xact_id_if_assigned(PG_FUNCTION_ARGS)
static StringInfo buf_init(FullTransactionId xmin, FullTransactionId xmax)
static bool is_visible_fxid(FullTransactionId value, const pg_snapshot *snap)
static int cmp_fxid(const void *aa, const void *bb)
#define USE_BSEARCH_IF_NXIP_GREATER
Datum pg_snapshot_out(PG_FUNCTION_ARGS)
#define PG_SNAPSHOT_SIZE(nxip)
#define PG_SNAPSHOT_MAX_NXIP
Datum pg_current_xact_id(PG_FUNCTION_ARGS)
Datum pg_snapshot_recv(PG_FUNCTION_ARGS)
static pg_snapshot * parse_snapshot(const char *str, Node *escontext)
Datum pg_snapshot_in(PG_FUNCTION_ARGS)
static pg_snapshot * buf_finalize(StringInfo buf)
Datum pg_xact_status(PG_FUNCTION_ARGS)
Datum pg_current_snapshot(PG_FUNCTION_ARGS)
static void buf_add_txid(StringInfo buf, FullTransactionId fxid)
Datum pg_snapshot_xmin(PG_FUNCTION_ARGS)
Datum pg_snapshot_xip(PG_FUNCTION_ARGS)
static void sort_snapshot(pg_snapshot *snap)
Datum pg_visible_in_snapshot(PG_FUNCTION_ARGS)
StaticAssertDecl(MAX_BACKENDS *2<=PG_SNAPSHOT_MAX_NXIP, "possible overflow in pg_current_snapshot()")
static FullTransactionId widen_snapshot_xid(TransactionId xid, FullTransactionId next_fxid)
Datum pg_snapshot_xmax(PG_FUNCTION_ARGS)