/*-------------------------------------------------------------------------
 *
 * pg_transactionid.h
 *	  definition of the system "transactionid" relation (pg_transactionid)
 *	  mapping between global txn id and local txn id.
 *
 * $Id: pg_transactionid.h,v 1.0 2003/09/07 17:55:22 swu Exp $
 *
 * NOTES
 *	  the genbki.sh script reads this file and generates .bki
 *	  information from the DATA() statements.
 *
 *-------------------------------------------------------------------------
 */
#ifndef _PG_TRANSACTIONID_H_
#define _PG_TRANSACTIONID_H_

/* postgres.h contains the system type definintions and the
 * CATALOG(), BOOTSTRAP and DATA() sugar words so this file
 * can be read by both genbki.sh and the C compiler.
 */

/* pg_transactionid definition.  cpp turns this into
 * typedef struct FormData_pg_transactionid.
 */
CATALOG(pg_transactionid)
{
	int4	localtxnid;		/* local txn id */
	int4	globaltxnid;	/* global txn id */
	Oid		bkndid;			/* backend pid */
	Oid		dbid;			/* database id */
    int4	firstlogid;		/* the first XLOG record id */
    int4	firstlogrecoff;	/* the first XLOG record record offset */
    int4	lastlogid;		/* the last XLOG record id */
    int4	lastlogrecoff;	/* the last XLOG record record offset */
} FormData_pg_transactionid;

/* Form_pg_transactionid corresponds to a pointer to a tuple with
 * the format of pg_transactionid relation.
 */
typedef FormData_pg_transactionid *Form_pg_transactionid;

/* compiler constants for pg_transactionid
 */
#define Natts_pg_transactionid			8
#define Anum_pg_transactionid_localtxnid	1
#define Anum_pg_transactionid_globaltxnid	2
#define Anum_pg_transactionid_bkndid		3
#define Anum_pg_transactionid_dbid		4
#define Anum_pg_transactionid_firstlogid	5
#define Anum_pg_transactionid_firstlogrecoff	6
#define Anum_pg_transactionid_lastlogid		7
#define Anum_pg_transactionid_lastlogrecoff	8


void AddNewTxn(TransactionId newLocalTxnId, TransactionId newGlobalTxnId);
void SetGlobalTxnId(TransactionId localTxnId, TransactionId globalTxnId);
TransactionId  LocalTxnidGetGlobalTxnid(TransactionId localTxnId);
/*void SetXLogRec(TransactionId localTxnId, int4 firstRec, int4 lastRec);*/

#endif   /* _PG_TRANSACTIONID_H_ */
