示例#1
0
文件: xidhelper.c 项目: 50wu/gpdb
Datum
spoof_next_xid(PG_FUNCTION_ARGS)
{
	TransactionId desiredXid = PG_GETARG_UINT32(0);
	TransactionId oldXid = ShmemVariableCache->nextXid;
	ShmemVariableCache->nextXid = desiredXid;

	/*
	 * If we're raising the xid, the intent is presumably to cross some
	 * threshold and make assertions about expected behavior.
	 * On the other hand, lowering the xid is meant to be a tear down of
	 * a completed test case. Because of this distinction, only when
	 * we're raising the xid, do we take extra precaution to zero out
	 * the new pg_clog/pg_subtrans/pg_distributedlog files. (We don't
	 * want to zero out existing files...)
	 */
	if (TransactionIdFollows(desiredXid, oldXid))
	{
		/*
		 * The nature of xid arithmetic is such that we only bother zeroing out
		 * new pages of transaction files when we've crossed page boundaries.
		 * So, here we fool the following routines into zeroing out the desired
		 * pages of transaction metadata by lowering the input xid to the first
		 * of its corresponding page.
		 */
#define CLOG_XACTS_PER_BYTE 4
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
		ExtendCLOG(desiredXid - TransactionIdToPgIndex(desiredXid));
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(SubTransData))
#define TransactionIdToEntry(xid) ((xid) % (uint32) SUBTRANS_XACTS_PER_PAGE)
		ExtendSUBTRANS(desiredXid - TransactionIdToEntry(desiredXid));
#undef TransactionIdToEntry
#define ENTRIES_PER_PAGE (BLCKSZ / sizeof(DistributedLogEntry))
#define TransactionIdToEntry(localXid) ((localXid) % (TransactionId) ENTRIES_PER_PAGE)
		DistributedLog_Extend(desiredXid - TransactionIdToEntry(desiredXid));
	}

	PG_RETURN_XID(oldXid);
}
Datum
gp_distributed_xid(PG_FUNCTION_ARGS __attribute__((unused)) )
{
	PG_RETURN_XID(InvalidDistributedTransactionId);

}
示例#3
0
文件: xidhelper.c 项目: 50wu/gpdb
Datum
get_wrap_limit(PG_FUNCTION_ARGS)
{
	PG_RETURN_XID(ShmemVariableCache->xidWrapLimit);
}
示例#4
0
文件: xidhelper.c 项目: 50wu/gpdb
Datum
get_vac_limit(PG_FUNCTION_ARGS)
{
	PG_RETURN_XID(ShmemVariableCache->xidVacLimit);
}
示例#5
0
文件: xidhelper.c 项目: 50wu/gpdb
Datum
get_next_xid(PG_FUNCTION_ARGS)
{
	PG_RETURN_XID(ShmemVariableCache->nextXid);
}
示例#6
0
文件: xidhelper.c 项目: 50wu/gpdb
Datum
get_oldest_xid(PG_FUNCTION_ARGS)
{
	PG_RETURN_XID(ShmemVariableCache->oldestXid);
}