aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/xid.c')
-rw-r--r--src/backend/access/transam/xid.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/backend/access/transam/xid.c b/src/backend/access/transam/xid.c
index df5c59543c7..28171a7f33f 100644
--- a/src/backend/access/transam/xid.c
+++ b/src/backend/access/transam/xid.c
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* xid.c
- * POSTGRES transaction identifier code.
+ * POSTGRES transaction identifier type.
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xid.c,v 1.27 2000/01/26 05:56:04 momjian Exp $
+ * $Id: xid.c,v 1.28 2000/06/05 07:28:38 tgl Exp $
*
* OLD COMMENTS
* XXX WARNING
@@ -19,33 +19,42 @@
*-------------------------------------------------------------------------
*/
-
#include "postgres.h"
+
#include "access/xact.h"
+/*
+ * TransactionId is typedef'd as uint32, so...
+ */
+#define PG_GETARG_TRANSACTIONID(n) PG_GETARG_UINT32(n)
+#define PG_RETURN_TRANSACTIONID(x) PG_RETURN_UINT32(x)
+
+
extern TransactionId NullTransactionId;
extern TransactionId DisabledTransactionId;
extern TransactionId AmiTransactionId;
extern TransactionId FirstTransactionId;
/* XXX name for catalogs */
-TransactionId
-xidin(char *representation)
+Datum
+xidin(PG_FUNCTION_ARGS)
{
- return atol(representation);
+ char *representation = PG_GETARG_CSTRING(0);
+
+ PG_RETURN_TRANSACTIONID((TransactionId) atol(representation));
}
/* XXX name for catalogs */
-char *
-xidout(TransactionId transactionId)
+Datum
+xidout(PG_FUNCTION_ARGS)
{
+ TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
/* maximum 32 bit unsigned integer representation takes 10 chars */
char *representation = palloc(11);
- snprintf(representation, 11, "%u", transactionId);
-
- return representation;
+ snprintf(representation, 11, "%lu", (unsigned long) transactionId);
+ PG_RETURN_CSTRING(representation);
}
/* ----------------------------------------------------------------
@@ -57,13 +66,14 @@ xidout(TransactionId transactionId)
* xideq - returns 1, iff xid1 == xid2
* 0 else;
*/
-bool
-xideq(TransactionId xid1, TransactionId xid2)
+Datum
+xideq(PG_FUNCTION_ARGS)
{
- return (bool) (xid1 == xid2);
-}
-
+ TransactionId xid1 = PG_GETARG_TRANSACTIONID(0);
+ TransactionId xid2 = PG_GETARG_TRANSACTIONID(1);
+ PG_RETURN_BOOL(xid1 == xid2);
+}
/* ----------------------------------------------------------------
* TransactionIdAdd
@@ -73,5 +83,4 @@ void
TransactionIdAdd(TransactionId *xid, int value)
{
*xid += value;
- return;
}