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()");
106 if (extracted_xid != NULL)
107 *extracted_xid = xid;
119 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
120 errmsg(
"transaction ID %" PRIu64
" is in the future",
193#ifdef USE_BSEARCH_IF_NXIP_GREATER
201 return (res) ?
false :
true;
208 for (
i = 0;
i < snap->
nxip;
i++)
271 const char *str_start =
str;
314 else if (*
str !=
'\0')
322 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
323 errmsg(
"invalid input syntax for type %s: \"%s\"",
324 "pg_snapshot", str_start)));
395 for (
i = 0;
i < nxip;
i++)
449 for (
i = 0;
i < snap->
nxip;
i++)
494 for (
i = 0;
i < nxip;
i++)
521 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
522 errmsg(
"invalid external pg_snapshot data")));
544 for (
i = 0;
i < snap->
nxip;
i++)
664 status =
"in progress";
666 status =
"committed";
#define FLEXIBLE_ARRAY_MEMBER
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)
Assert(PointerIsAligned(start, uint64))
bool LWLockHeldByMe(LWLock *lock)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void * MemoryContextAlloc(MemoryContext context, Size size)
void pfree(void *pointer)
#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)
#define FullTransactionIdEquals(a, b)
static FullTransactionId FullTransactionIdFromAllowableAt(FullTransactionId nextFullXid, TransactionId xid)
#define U64FromFullTransactionId(x)
static FullTransactionId FullTransactionIdFromU64(uint64 value)
#define FullTransactionIdFollowsOrEquals(a, b)
#define XidFromFullTransactionId(x)
#define TransactionIdIsValid(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
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)
static pg_snapshot * buf_finalize(StringInfo buf)
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)
static pg_snapshot * parse_snapshot(const char *str, Node *escontext)
Datum pg_snapshot_recv(PG_FUNCTION_ARGS)
Datum pg_snapshot_in(PG_FUNCTION_ARGS)
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()")
Datum pg_snapshot_xmax(PG_FUNCTION_ARGS)