1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Add binary I/O routines for a bunch more datatypes. Still a few to go,

but that was enough tedium for one day.  Along the way, move the few
support routines for types xid and cid into a more logical place.
This commit is contained in:
Tom Lane
2003-05-12 23:08:52 +00:00
parent b02832719c
commit 30f609484d
25 changed files with 1133 additions and 216 deletions

View File

@ -4,7 +4,7 @@
# Makefile for access/transam
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/access/transam/Makefile,v 1.15 2001/08/25 18:52:41 tgl Exp $
# $Header: /cvsroot/pgsql/src/backend/access/transam/Makefile,v 1.16 2003/05/12 23:08:50 tgl Exp $
#
#-------------------------------------------------------------------------
@ -12,7 +12,7 @@ subdir = src/backend/access/transam
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = clog.o transam.o varsup.o xact.o xid.o xlog.o xlogutils.o rmgr.o
OBJS = clog.o transam.o varsup.o xact.o xlog.o xlogutils.o rmgr.o
all: SUBSYS.o

View File

@ -1,72 +0,0 @@
/*-------------------------------------------------------------------------
*
* xid.c
* POSTGRES transaction identifier datatype.
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: xid.c,v 1.35 2002/06/20 20:29:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <limits.h>
#include "access/xact.h"
#define PG_GETARG_TRANSACTIONID(n) DatumGetTransactionId(PG_GETARG_DATUM(n))
#define PG_RETURN_TRANSACTIONID(x) return TransactionIdGetDatum(x)
Datum
xidin(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
PG_RETURN_TRANSACTIONID((TransactionId) strtoul(str, NULL, 0));
}
Datum
xidout(PG_FUNCTION_ARGS)
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
/* maximum 32 bit unsigned integer representation takes 10 chars */
char *str = palloc(11);
snprintf(str, 11, "%lu", (unsigned long) transactionId);
PG_RETURN_CSTRING(str);
}
/*
* xideq - are two xids equal?
*/
Datum
xideq(PG_FUNCTION_ARGS)
{
TransactionId xid1 = PG_GETARG_TRANSACTIONID(0);
TransactionId xid2 = PG_GETARG_TRANSACTIONID(1);
PG_RETURN_BOOL(TransactionIdEquals(xid1, xid2));
}
/*
* xid_age - compute age of an XID (relative to current xact)
*/
Datum
xid_age(PG_FUNCTION_ARGS)
{
TransactionId xid = PG_GETARG_TRANSACTIONID(0);
TransactionId now = GetCurrentTransactionId();
/* Permanent XIDs are always infinitely old */
if (!TransactionIdIsNormal(xid))
PG_RETURN_INT32(INT_MAX);
PG_RETURN_INT32((int32) (now - xid));
}