From 39f5ecaf3d0e5b78e9ecc9820b049cc9f02416ba Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 28 Mar 2007 17:35:25 +0000 Subject: [PATCH] move row stamp business to its own file --- Makefile | 2 +- src/plproxy.h | 46 ++-------------------------------------------- src/rowstamp.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 45 deletions(-) create mode 100644 src/rowstamp.h diff --git a/Makefile b/Makefile index 303103a..e2f1ab8 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ gen: cd src; flex -o scanner.c scanner.l # dependencies -$(OBJS): src/plproxy.h +$(OBJS): src/plproxy.h src/rowstamp.h # utility rules diff --git a/src/plproxy.h b/src/plproxy.h index 75ef730..34f1a67 100644 --- a/src/plproxy.h +++ b/src/plproxy.h @@ -43,52 +43,10 @@ /* for standard_conforming_strings */ #include -#include - -#if PG_VERSION_NUM < 80300 - -/* - * Row version check for 8.2 - */ -typedef struct RowStamp { - TransactionId xmin; - CommandId cmin; -} RowStamp; - -static inline void plproxy_set_stamp(RowStamp *stamp, HeapTuple tup) -{ - stamp->xmin = HeapTupleHeaderGetXmin(tup->t_data); - stamp->cmin = HeapTupleHeaderGetCmin(tup->t_data); -} - -static inline bool plproxy_check_stamp(RowStamp *stamp, HeapTuple tup) -{ - return stamp->xmin == HeapTupleHeaderGetXmin(tup->t_data) - && stamp->cmin == HeapTupleHeaderGetCmin(tup->t_data); -} +#include "rowstamp.h" -#else /* ver >= 8.3 */ - -/* - * Row version check for PG >= 8.3 - */ -typedef struct RowStamp { - TransactionId xmin; - ItemPointerData tid; -} RowStamp; - -static inline void plproxy_set_stamp(RowStamp *stamp, HeapTuple tup) -{ - stamp->xmin = HeapTupleHeaderGetXmin(tup->t_data); - stamp->tid = tup->t_self; -} +#include -static inline bool plproxy_check_stamp(RowStamp *stamp, HeapTuple tup) -{ - return stamp->xmin == HeapTupleHeaderGetXmin(tup->t_data) - && ItemPointerEquals(&stamp->tid, &tup->t_self); -} -#endif /* * Maintenece period in seconds. Connnections will be freed diff --git a/src/rowstamp.h b/src/rowstamp.h new file mode 100644 index 0000000..acd51b2 --- /dev/null +++ b/src/rowstamp.h @@ -0,0 +1,50 @@ +/* + * Row version check changed in 8.3 + */ + +#if PG_VERSION_NUM < 80300 + +/* + * Row version check for 8.2 + */ +typedef struct RowStamp { + TransactionId xmin; + CommandId cmin; +} RowStamp; + +static inline void plproxy_set_stamp(RowStamp *stamp, HeapTuple tup) +{ + stamp->xmin = HeapTupleHeaderGetXmin(tup->t_data); + stamp->cmin = HeapTupleHeaderGetCmin(tup->t_data); +} + +static inline bool plproxy_check_stamp(RowStamp *stamp, HeapTuple tup) +{ + return stamp->xmin == HeapTupleHeaderGetXmin(tup->t_data) + && stamp->cmin == HeapTupleHeaderGetCmin(tup->t_data); +} + +#else /* ver >= 8.3 */ + +/* + * Row version check for PG >= 8.3 + */ +typedef struct RowStamp { + TransactionId xmin; + ItemPointerData tid; +} RowStamp; + +static inline void plproxy_set_stamp(RowStamp *stamp, HeapTuple tup) +{ + stamp->xmin = HeapTupleHeaderGetXmin(tup->t_data); + stamp->tid = tup->t_self; +} + +static inline bool plproxy_check_stamp(RowStamp *stamp, HeapTuple tup) +{ + return stamp->xmin == HeapTupleHeaderGetXmin(tup->t_data) + && ItemPointerEquals(&stamp->tid, &tup->t_self); +} + +#endif + -- 2.39.5