*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: heapam.h,v 1.38 1998/10/08 18:30:22 momjian Exp $
+ * $Id: heapam.h,v 1.39 1998/11/27 19:33:31 vadim Exp $
*
*-------------------------------------------------------------------------
*/
*
* ----------------
*/
+
+extern Datum nocachegetattr(HeapTuple tup, int attnum,
+ TupleDesc att, bool *isnull);
+
#if !defined(DISABLE_COMPLEX_MACRO)
#define fastgetattr(tup, attnum, tupleDesc, isnull) \
(attnum) == 1) ? \
( \
(Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]), \
- (char *) (tup) + (tup)->t_hoff + \
+ (char *) (tup)->t_data + (tup)->t_data->t_hoff + \
( \
((attnum) != 1) ? \
(tupleDesc)->attrs[(attnum)-1]->attcacheoff \
) \
: \
( \
- att_isnull((attnum)-1, (tup)->t_bits) ? \
+ att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
( \
((isnull) ? (*(isnull) = true) : (dummyret)NULL), \
(Datum)NULL \
#else /* !defined(DISABLE_COMPLEX_MACRO) */
-extern Datum nocachegetattr(HeapTuple tup, int attnum,
- TupleDesc att, bool *isnull);
-
static Datum
fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
bool *isnull)
(attnum) == 1) ?
(
(Datum) fetchatt(&((tupleDesc)->attrs[(attnum) - 1]),
- (char *) (tup) + (tup)->t_hoff +
+ (char *) (tup)->t_data + (tup)->t_data->t_hoff +
(
((attnum) != 1) ?
(tupleDesc)->attrs[(attnum) - 1]->attcacheoff
)
:
(
- att_isnull((attnum) - 1, (tup)->t_bits) ?
+ att_isnull((attnum) - 1, (tup)->t_data->t_bits) ?
(
((isnull) ? (*(isnull) = true) : (dummyret) NULL),
(Datum) NULL
AssertMacro((tup) != NULL && \
(attnum) > FirstLowInvalidHeapAttributeNumber && \
(attnum) != 0), \
- ((attnum) > (int) (tup)->t_natts) ? \
+ ((attnum) > (int) (tup)->t_data->t_natts) ? \
( \
((isnull) ? (*(isnull) = true) : (dummyret)NULL), \
(Datum)NULL \
((isnull) ? (*(isnull) = false) : (dummyret)NULL), \
((attnum) == SelfItemPointerAttributeNumber) ? \
( \
- (Datum)((char *)(tup) + \
- heap_sysoffset[-SelfItemPointerAttributeNumber-1]) \
+ (Datum)((char *)&((tup)->t_self)) \
) \
: \
( \
(Datum)*(unsigned int *) \
- ((char *)(tup) + heap_sysoffset[-(attnum)-1]) \
+ ((char *)(tup)->t_data + heap_sysoffset[-(attnum)-1]) \
) \
) \
) \
extern void heap_rescan(HeapScanDesc scan, bool scanFromEnd, ScanKey key);
extern void heap_endscan(HeapScanDesc scan);
extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw);
-extern HeapTuple heap_fetch(Relation relation, Snapshot snapshot, ItemPointer tid, Buffer *userbuf);
+extern void heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tup, Buffer *userbuf);
extern Oid heap_insert(Relation relation, HeapTuple tup);
extern int heap_delete(Relation relation, ItemPointer tid);
extern int heap_replace(Relation relation, ItemPointer otid,
extern Datum nocachegetattr(HeapTuple tup, int attnum,
TupleDesc att, bool *isnull);
extern HeapTuple heap_copytuple(HeapTuple tuple);
+extern void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest);
extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
Datum *value, char *nulls);
extern HeapTuple heap_modifytuple(HeapTuple tuple,
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: htup.h,v 1.10 1998/09/01 04:34:14 momjian Exp $
+ * $Id: htup.h,v 1.11 1998/11/27 19:33:31 vadim Exp $
*
*-------------------------------------------------------------------------
*/
* to avoid wasting space, the attributes should be layed out in such a
* way to reduce structure padding.
*/
-typedef struct HeapTupleData
+typedef struct HeapTupleHeaderData
{
- unsigned int t_len; /* length of entire tuple */
-
Oid t_oid; /* OID of this tuple -- 4 bytes */
CommandId t_cmin; /* insert CID stamp -- 4 bytes each */
TransactionId t_xmin; /* insert XID stamp -- 4 bytes each */
TransactionId t_xmax; /* delete XID stamp */
- ItemPointerData t_ctid; /* current TID of this tuple */
+ ItemPointerData t_ctid; /* current TID of this or newer tuple */
int16 t_natts; /* number of attributes */
/* bit map of domains */
/* MORE DATA FOLLOWS AT END OF STRUCT */
-} HeapTupleData;
-
-typedef HeapTupleData *HeapTuple;
+} HeapTupleHeaderData;
+typedef HeapTupleHeaderData *HeapTupleHeader;
#define SelfItemPointerAttributeNumber (-1)
#define ObjectIdAttributeNumber (-2)
/* If you make any changes above, the order off offsets in this must change */
extern long heap_sysoffset[];
+/*
+ * This new HeapTuple for version >= 6.5 and this is why it was changed:
+ *
+ * 1. t_len moved off on-disk tuple data - ItemIdData is used to get len;
+ * 2. t_ctid above is not self tuple TID now - it may point to
+ * updated version of tuple (required by MVCC);
+ * 3. someday someone let tuple to cross block boundaries -
+ * he have to add something below...
+ */
+typedef struct HeapTupleData
+{
+ uint32 t_len; /* length of *t_data */
+ ItemPointerData t_self; /* SelfItemPointer */
+ HeapTupleHeader t_data; /* */
+} HeapTupleData;
+
+typedef HeapTupleData *HeapTuple;
+
+#define HEAPTUPLESIZE DOUBLEALIGN(sizeof(HeapTupleData))
+
+
/* ----------------
* support macros
* ----------------
*/
-#define GETSTRUCT(TUP) (((char *)(TUP)) + ((HeapTuple)(TUP))->t_hoff)
+#define GETSTRUCT(TUP) (((char *)((HeapTuple)(TUP))->t_data) + \
+ ((HeapTuple)(TUP))->t_data->t_hoff)
/*
#define HEAP_XACT_MASK 0x0F00 /* */
#define HeapTupleNoNulls(tuple) \
- (!(((HeapTuple) (tuple))->t_infomask & HEAP_HASNULL))
+ (!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
#define HeapTupleAllFixed(tuple) \
- (!(((HeapTuple) (tuple))->t_infomask & HEAP_HASVARLENA))
+ (!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASVARLENA))
#endif /* HTUP_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: relscan.h,v 1.12 1998/09/01 04:34:23 momjian Exp $
+ * $Id: relscan.h,v 1.13 1998/11/27 19:33:31 vadim Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct HeapScanDescData
{
- Relation rs_rd; /* pointer to relation descriptor */
- HeapTuple rs_ptup; /* previous tuple in scan */
- HeapTuple rs_ctup; /* current tuple in scan */
- HeapTuple rs_ntup; /* next tuple in scan */
- Buffer rs_pbuf; /* previous buffer in scan */
- Buffer rs_cbuf; /* current buffer in scan */
- Buffer rs_nbuf; /* next buffer in scan */
- ItemPointerData rs_mptid; /* marked previous tid */
- ItemPointerData rs_mctid; /* marked current tid */
- ItemPointerData rs_mntid; /* marked next tid */
- ItemPointerData rs_mcd; /* marked current delta XXX ??? */
- Snapshot rs_snapshot; /* snapshot to see */
- bool rs_atend; /* restart scan at end? */
- uint16 rs_cdelta; /* current delta in chain */
- uint16 rs_nkeys; /* number of attributes in keys */
- ScanKey rs_key; /* key descriptors */
+ Relation rs_rd; /* pointer to relation descriptor */
+ HeapTupleData rs_ptup; /* previous tuple in scan */
+ HeapTupleData rs_ctup; /* current tuple in scan */
+ HeapTupleData rs_ntup; /* next tuple in scan */
+ Buffer rs_pbuf; /* previous buffer in scan */
+ Buffer rs_cbuf; /* current buffer in scan */
+ Buffer rs_nbuf; /* next buffer in scan */
+ ItemPointerData rs_mptid; /* marked previous tid */
+ ItemPointerData rs_mctid; /* marked current tid */
+ ItemPointerData rs_mntid; /* marked next tid */
+ ItemPointerData rs_mcd; /* marked current delta XXX ??? */
+ Snapshot rs_snapshot; /* snapshot to see */
+ bool rs_atend; /* restart scan at end? */
+ uint16 rs_cdelta; /* current delta in chain */
+ uint16 rs_nkeys; /* number of attributes in keys */
+ ScanKey rs_key; /* key descriptors */
} HeapScanDescData;
typedef HeapScanDescData *HeapScanDesc;
typedef struct IndexScanDescData
{
- Relation relation; /* relation descriptor */
- void *opaque; /* am-specific slot */
+ Relation relation; /* relation descriptor */
+ void *opaque; /* am-specific slot */
ItemPointerData previousItemData; /* previous index pointer */
ItemPointerData currentItemData; /* current index pointer */
ItemPointerData nextItemData; /* next index pointer */
MarkData previousMarkData; /* marked previous pointer */
- MarkData currentMarkData;/* marked current pointer */
- MarkData nextMarkData; /* marked next pointer */
- uint8 flags; /* scan position flags */
- bool scanFromEnd; /* restart scan at end? */
- uint16 numberOfKeys; /* number of key attributes */
- ScanKey keyData; /* key descriptor */
+ MarkData currentMarkData; /* marked current pointer */
+ MarkData nextMarkData; /* marked next pointer */
+ uint8 flags; /* scan position flags */
+ bool scanFromEnd; /* restart scan at end? */
+ uint16 numberOfKeys; /* number of key attributes */
+ ScanKey keyData; /* key descriptor */
} IndexScanDescData;
typedef IndexScanDescData *IndexScanDesc;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: valid.h,v 1.15 1998/09/01 04:34:33 momjian Exp $
+ * $Id: valid.h,v 1.16 1998/11/27 19:33:32 vadim Exp $
*
*-------------------------------------------------------------------------
*/
* with joey's expensive function work.
* ----------------
*/
-#define HeapTupleSatisfies(itemId, \
+#define HeapTupleSatisfies(tuple, \
relation, \
buffer, \
disk_page, \
seeself, \
nKeys, \
- key, \
- result) \
+ key) \
do \
{ \
/* We use underscores to protect the variable passed in as parameters */ \
- HeapTuple _tuple; \
bool _res; \
\
- if (!ItemIdIsUsed(itemId)) \
- (result) = (HeapTuple) NULL; \
+ if ((key) != NULL) \
+ HeapKeyTest(tuple, RelationGetDescr(relation), \
+ (nKeys), (key), _res); \
else \
- { \
- _tuple = (HeapTuple) PageGetItem((Page) (disk_page), (itemId)); \
- \
- if ((key) != NULL) \
- HeapKeyTest(_tuple, RelationGetDescr(relation), \
- (nKeys), (key), _res); \
- else \
- _res = TRUE; \
+ _res = TRUE; \
\
- (result) = (HeapTuple) NULL; \
- if (_res) \
+ if (_res) \
+ { \
+ if ((relation)->rd_rel->relkind != RELKIND_UNCATALOGED) \
{ \
- if ((relation)->rd_rel->relkind == RELKIND_UNCATALOGED) \
- (result) = _tuple; \
- else \
- { \
- uint16 _infomask = _tuple->t_infomask; \
- \
- _res = HeapTupleSatisfiesVisibility(_tuple, (seeself)); \
- if (_tuple->t_infomask != _infomask) \
- SetBufferCommitInfoNeedsSave(buffer); \
- if (_res) \
- (result) = _tuple; \
- } \
+ uint16 _infomask = (tuple)->t_data->t_infomask; \
+ \
+ _res = HeapTupleSatisfiesVisibility((tuple), (seeself)); \
+ if ((tuple)->t_data->t_infomask != _infomask) \
+ SetBufferCommitInfoNeedsSave(buffer); \
+ if (!_res) \
+ (tuple)->t_data = NULL; \
} \
} \
+ else \
+ { \
+ (tuple)->t_data = NULL; \
+ } \
} while (0)
extern bool TupleUpdatedByCurXactAndCmd(HeapTuple t);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: executor.h,v 1.27 1998/10/14 05:10:05 momjian Exp $
+ * $Id: executor.h,v 1.28 1998/11/27 19:33:32 vadim Exp $
*
*-------------------------------------------------------------------------
*/
extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count);
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
-extern HeapTuple ExecConstraints(char *caller, Relation rel, HeapTuple tuple);
+extern void ExecConstraints(char *caller, Relation rel, HeapTuple tuple);
#ifdef QUERY_LIMIT
extern int ExecutorLimit(int limit);
extern int ExecutorGetLimit(void);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: tuptable.h,v 1.8 1998/09/01 04:36:13 momjian Exp $
+ * $Id: tuptable.h,v 1.9 1998/11/27 19:33:33 vadim Exp $
*
* NOTES
* The tuple table interface is getting pretty ugly.
*/
typedef struct TupleTableSlot
{
- NodeTag type;
- HeapTuple val;
- bool ttc_shouldFree;
- bool ttc_descIsNew;
- TupleDesc ttc_tupleDescriptor;
- Buffer ttc_buffer;
- int ttc_whichplan;
+ NodeTag type;
+ HeapTuple val;
+ bool ttc_shouldFree;
+ bool ttc_descIsNew;
+ TupleDesc ttc_tupleDescriptor;
+ Buffer ttc_buffer;
+ int ttc_whichplan;
} TupleTableSlot;
/* ----------------
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: execnodes.h,v 1.18 1998/09/01 04:36:35 momjian Exp $
+ * $Id: execnodes.h,v 1.19 1998/11/27 19:33:33 vadim Exp $
*
*-------------------------------------------------------------------------
*/
*/
typedef struct IndexScanState
{
- CommonState cstate; /* its first field is NodeTag */
- int iss_NumIndices;
- int iss_IndexPtr;
- int iss_MarkIndexPtr;
- ScanKey *iss_ScanKeys;
- int *iss_NumScanKeys;
- Pointer iss_RuntimeKeyInfo;
- RelationPtr iss_RelationDescs;
- IndexScanDescPtr iss_ScanDescs;
+ CommonState cstate; /* its first field is NodeTag */
+ int iss_NumIndices;
+ int iss_IndexPtr;
+ int iss_MarkIndexPtr;
+ ScanKey *iss_ScanKeys;
+ int *iss_NumScanKeys;
+ Pointer iss_RuntimeKeyInfo;
+ RelationPtr iss_RelationDescs;
+ IndexScanDescPtr iss_ScanDescs;
+ HeapTupleData iss_htup;
} IndexScanState;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: tqual.h,v 1.14 1998/09/01 04:39:35 momjian Exp $
+ * $Id: tqual.h,v 1.15 1998/11/27 19:33:35 vadim Exp $
*
*-------------------------------------------------------------------------
*/
*/
#define HeapTupleSatisfiesVisibility(tuple, snapshot) \
( \
- TransactionIdEquals((tuple)->t_xmax, AmiTransactionId) ? \
+ TransactionIdEquals((tuple)->t_data->t_xmax, AmiTransactionId) ? \
false \
: \
( \
(IsSnapshotSelf(snapshot) || heapisoverride()) ? \
- HeapTupleSatisfiesItself(tuple) \
+ HeapTupleSatisfiesItself((tuple)->t_data) \
: \
- HeapTupleSatisfiesNow(tuple) \
+ HeapTupleSatisfiesNow((tuple)->t_data) \
) \
)
) \
)
-extern bool HeapTupleSatisfiesItself(HeapTuple tuple);
-extern bool HeapTupleSatisfiesNow(HeapTuple tuple);
+extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
+extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple);
extern void setheapoverride(bool on);