1996-08-27 21:59:28 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* tqual.h
|
2002-01-16 15:29:02 -05:00
|
|
|
* POSTGRES "time" qualification definitions, ie, tuple visibility rules.
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
1998-07-27 15:38:40 -04:00
|
|
|
* Should be moved/renamed... - vadim 07/28/98
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
2003-08-03 22:40:20 -04:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
2003-10-01 17:30:53 -04:00
|
|
|
* $Id: tqual.h,v 1.48 2003/10/01 21:30:53 tgl Exp $
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1997-09-07 01:04:48 -04:00
|
|
|
#ifndef TQUAL_H
|
1996-08-27 21:59:28 -04:00
|
|
|
#define TQUAL_H
|
|
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "access/htup.h"
|
|
|
|
|
#include "access/xact.h"
|
1996-08-27 21:59:28 -04:00
|
|
|
|
2000-01-17 18:57:48 -05:00
|
|
|
|
1998-07-27 15:38:40 -04:00
|
|
|
typedef struct SnapshotData
|
|
|
|
|
{
|
2000-04-12 13:17:23 -04:00
|
|
|
TransactionId xmin; /* XID < xmin are visible to me */
|
|
|
|
|
TransactionId xmax; /* XID >= xmax are invisible to me */
|
2001-07-12 00:11:13 -04:00
|
|
|
uint32 xcnt; /* # of xact ids in xip[] */
|
|
|
|
|
TransactionId *xip; /* array of xact IDs in progress */
|
|
|
|
|
/* note: all ids in xip[] satisfy xmin <= xip[i] < xmax */
|
2002-05-21 18:05:55 -04:00
|
|
|
CommandId curcid; /* in my xact, CID < curcid are visible */
|
2000-04-12 13:17:23 -04:00
|
|
|
ItemPointerData tid; /* required for Dirty snapshot -:( */
|
1999-05-25 18:43:53 -04:00
|
|
|
} SnapshotData;
|
1998-07-27 15:38:40 -04:00
|
|
|
|
1998-09-01 00:40:42 -04:00
|
|
|
typedef SnapshotData *Snapshot;
|
1998-07-27 15:38:40 -04:00
|
|
|
|
1998-09-01 00:40:42 -04:00
|
|
|
#define SnapshotNow ((Snapshot) 0x0)
|
|
|
|
|
#define SnapshotSelf ((Snapshot) 0x1)
|
1999-09-29 12:06:40 -04:00
|
|
|
#define SnapshotAny ((Snapshot) 0x2)
|
2002-01-16 15:29:02 -05:00
|
|
|
#define SnapshotToast ((Snapshot) 0x3)
|
1998-12-16 06:53:55 -05:00
|
|
|
|
2001-07-12 00:11:13 -04:00
|
|
|
extern DLLIMPORT Snapshot SnapshotDirty;
|
|
|
|
|
extern DLLIMPORT Snapshot QuerySnapshot;
|
2001-06-18 17:38:02 -04:00
|
|
|
extern DLLIMPORT Snapshot SerializableSnapshot;
|
1998-12-15 07:47:01 -05:00
|
|
|
|
2003-02-23 18:20:52 -05:00
|
|
|
extern TransactionId RecentXmin;
|
2002-05-24 14:57:57 -04:00
|
|
|
extern TransactionId RecentGlobalXmin;
|
|
|
|
|
|
1996-08-27 21:59:28 -04:00
|
|
|
|
1998-04-24 10:43:33 -04:00
|
|
|
/*
|
1999-05-25 12:15:34 -04:00
|
|
|
* HeapTupleSatisfiesVisibility
|
2002-01-16 15:29:02 -05:00
|
|
|
* True iff heap tuple satisfies a time qual.
|
1998-04-24 10:43:33 -04:00
|
|
|
*
|
2000-01-17 18:57:48 -05:00
|
|
|
* Notes:
|
1998-04-24 10:43:33 -04:00
|
|
|
* Assumes heap tuple is valid.
|
2002-01-16 15:29:02 -05:00
|
|
|
* Beware of multiple evaluations of snapshot argument.
|
1998-04-24 10:43:33 -04:00
|
|
|
*/
|
1998-07-27 15:38:40 -04:00
|
|
|
#define HeapTupleSatisfiesVisibility(tuple, snapshot) \
|
2003-09-25 14:58:36 -04:00
|
|
|
((snapshot) == SnapshotNow ? \
|
2002-01-16 15:29:02 -05:00
|
|
|
HeapTupleSatisfiesNow((tuple)->t_data) \
|
|
|
|
|
: \
|
2003-09-25 14:58:36 -04:00
|
|
|
((snapshot) == SnapshotSelf ? \
|
2002-01-16 15:29:02 -05:00
|
|
|
HeapTupleSatisfiesItself((tuple)->t_data) \
|
1998-04-24 10:43:33 -04:00
|
|
|
: \
|
2003-09-25 14:58:36 -04:00
|
|
|
((snapshot) == SnapshotAny ? \
|
1999-09-29 12:06:40 -04:00
|
|
|
true \
|
1998-04-24 10:43:33 -04:00
|
|
|
: \
|
2003-09-25 14:58:36 -04:00
|
|
|
((snapshot) == SnapshotToast ? \
|
2002-01-16 15:29:02 -05:00
|
|
|
HeapTupleSatisfiesToast((tuple)->t_data) \
|
1998-12-15 07:47:01 -05:00
|
|
|
: \
|
2003-09-25 14:58:36 -04:00
|
|
|
((snapshot) == SnapshotDirty ? \
|
2002-01-16 15:29:02 -05:00
|
|
|
HeapTupleSatisfiesDirty((tuple)->t_data) \
|
1998-12-16 06:53:55 -05:00
|
|
|
: \
|
2002-01-16 15:29:02 -05:00
|
|
|
HeapTupleSatisfiesSnapshot((tuple)->t_data, snapshot) \
|
|
|
|
|
) \
|
1998-12-15 07:47:01 -05:00
|
|
|
) \
|
1999-09-29 12:06:40 -04:00
|
|
|
) \
|
1998-04-24 10:43:33 -04:00
|
|
|
) \
|
|
|
|
|
)
|
1996-08-27 21:59:28 -04:00
|
|
|
|
2001-07-12 00:11:13 -04:00
|
|
|
/* Result codes for HeapTupleSatisfiesUpdate */
|
1999-05-25 12:15:34 -04:00
|
|
|
#define HeapTupleMayBeUpdated 0
|
|
|
|
|
#define HeapTupleInvisible 1
|
1998-12-15 07:47:01 -05:00
|
|
|
#define HeapTupleSelfUpdated 2
|
|
|
|
|
#define HeapTupleUpdated 3
|
|
|
|
|
#define HeapTupleBeingUpdated 4
|
1998-04-24 10:43:33 -04:00
|
|
|
|
2001-07-12 00:11:13 -04:00
|
|
|
/* Result codes for HeapTupleSatisfiesVacuum */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2001-10-28 01:26:15 -05:00
|
|
|
HEAPTUPLE_DEAD, /* tuple is dead and deletable */
|
|
|
|
|
HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
|
|
|
|
|
HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
|
2002-09-04 16:31:48 -04:00
|
|
|
HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in
|
|
|
|
|
* progress */
|
2001-10-28 01:26:15 -05:00
|
|
|
HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */
|
2001-07-12 00:11:13 -04:00
|
|
|
} HTSV_Result;
|
|
|
|
|
|
1999-05-25 12:15:34 -04:00
|
|
|
extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
|
|
|
|
|
extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple);
|
|
|
|
|
extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple);
|
2002-01-16 15:29:02 -05:00
|
|
|
extern bool HeapTupleSatisfiesToast(HeapTupleHeader tuple);
|
2000-01-17 18:57:48 -05:00
|
|
|
extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple,
|
2000-04-12 13:17:23 -04:00
|
|
|
Snapshot snapshot);
|
2003-10-01 17:30:53 -04:00
|
|
|
extern int HeapTupleSatisfiesUpdate(HeapTupleHeader tuple,
|
2002-09-04 16:31:48 -04:00
|
|
|
CommandId curcid);
|
2001-07-12 00:11:13 -04:00
|
|
|
extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
|
2001-10-25 01:50:21 -04:00
|
|
|
TransactionId OldestXmin);
|
1996-08-27 21:59:28 -04:00
|
|
|
|
2003-06-11 21:42:21 -04:00
|
|
|
extern Snapshot GetSnapshotData(Snapshot snapshot, bool serializable);
|
1999-05-25 12:15:34 -04:00
|
|
|
extern void SetQuerySnapshot(void);
|
2002-05-21 18:59:01 -04:00
|
|
|
extern Snapshot CopyQuerySnapshot(void);
|
2003-10-01 17:30:53 -04:00
|
|
|
extern Snapshot CopyCurrentSnapshot(void);
|
1999-05-25 12:15:34 -04:00
|
|
|
extern void FreeXactSnapshot(void);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* TQUAL_H */
|