50 #define USE_BSEARCH_IF_NXIP_GREATER 30
72 #define PG_SNAPSHOT_SIZE(nxip) \
73 (offsetof(pg_snapshot, xip) + sizeof(FullTransactionId) * (nxip))
74 #define PG_SNAPSHOT_MAX_NXIP \
75 ((MaxAllocSize - offsetof(pg_snapshot, xip)) / sizeof(FullTransactionId))
103 if (extracted_xid != NULL)
104 *extracted_xid = xid;
116 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
117 errmsg(
"transaction ID %llu is in the future",
135 if (xid_epoch + 1 < now_epoch
136 || (xid_epoch + 1 == now_epoch && xid < now_epoch_next_xid)
216 #ifdef USE_BSEARCH_IF_NXIP_GREATER
231 for (
i = 0;
i < snap->
nxip;
i++)
294 const char *str_start =
str;
337 else if (*
str !=
'\0')
345 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
346 errmsg(
"invalid input syntax for type %s: \"%s\"",
347 "pg_snapshot", str_start)));
411 "possible overflow in pg_current_snapshot()");
421 for (
i = 0;
i < nxip;
i++)
474 for (
i = 0;
i < snap->
nxip;
i++)
519 for (
i = 0;
i < nxip;
i++)
546 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
547 errmsg(
"invalid external pg_snapshot data")));
569 for (
i = 0;
i < snap->
nxip;
i++)
#define FLEXIBLE_ARRAY_MEMBER
#define strtou64(str, endptr, base)
#define StaticAssertStmt(condition, errmessage)
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#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)
static const unsigned __int64 epoch
Assert(fmt[strlen(fmt) - 1] !='\n')
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
bool LWLockHeldByMe(LWLock *l)
void pfree(void *pointer)
void * MemoryContextAlloc(MemoryContext context, Size size)
static void static void status(const char *fmt,...) pg_attribute_printf(1
#define qsort(a, b, c, d)
#define SET_VARSIZE(PTR, len)
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 char *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 TransactionIdPrecedes(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)
text * cstring_to_text(const char *s)
FullTransactionId ReadNextFullTransactionId(void)
VariableCache ShmemVariableCache
FullTransactionId GetTopFullTransactionId(void)
FullTransactionId GetTopFullTransactionIdIfAny(void)
#define PG_GETARG_FULLTRANSACTIONID(X)
#define FullTransactionIdGetDatum(X)
#define PG_RETURN_FULLTRANSACTIONID(X)
static bool TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
Datum pg_snapshot_send(PG_FUNCTION_ARGS)
static pg_snapshot * parse_snapshot(const char *str)
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)
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)
static FullTransactionId widen_snapshot_xid(TransactionId xid, FullTransactionId next_fxid)
Datum pg_snapshot_xmax(PG_FUNCTION_ARGS)