1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* itup.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* POSTGRES index tuple definitions.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
1999-07-16 19:07:40 +02:00
|
|
|
* $Id: itup.h,v 1.20 1999/07/16 17:07:27 momjian Exp $
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef ITUP_H
|
|
|
|
#define ITUP_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/ibit.h"
|
|
|
|
#include "access/tupdesc.h"
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "access/tupmacs.h"
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "storage/itemptr.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define MaxIndexAttributeNumber 7
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct IndexTupleData
|
|
|
|
{
|
|
|
|
ItemPointerData t_tid; /* reference TID to base tuple */
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* t_info is layed out in the following fashion:
|
|
|
|
*
|
|
|
|
* 15th (leftmost) bit: "has nulls" bit 14th bit: "has varlenas" bit 13th
|
|
|
|
* bit: "has rules" bit - (removed ay 11/94) bits 12-0 bit: size of
|
|
|
|
* tuple.
|
|
|
|
*/
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
unsigned short t_info; /* various info about tuple */
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* please make sure sizeof(IndexTupleData) is MAXALIGN'ed. See
|
|
|
|
* IndexInfoFindDataOffset() for the reason.
|
|
|
|
*/
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-08 23:56:23 +02:00
|
|
|
} IndexTupleData; /* MORE DATA FOLLOWS AT END OF STRUCT */
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef IndexTupleData *IndexTuple;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct InsertIndexResultData
|
|
|
|
{
|
|
|
|
ItemPointerData pointerData;
|
1997-09-08 23:56:23 +02:00
|
|
|
} InsertIndexResultData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
typedef InsertIndexResultData *InsertIndexResult;
|
|
|
|
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct RetrieveIndexResultData
|
|
|
|
{
|
|
|
|
ItemPointerData index_iptr;
|
|
|
|
ItemPointerData heap_iptr;
|
1997-09-08 23:56:23 +02:00
|
|
|
} RetrieveIndexResultData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef RetrieveIndexResultData *RetrieveIndexResult;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*-----------------
|
|
|
|
* PredInfo -
|
1997-09-07 07:04:48 +02:00
|
|
|
* used for partial indices
|
1996-08-27 23:50:29 +02:00
|
|
|
*-----------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct PredInfo
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Node *pred;
|
|
|
|
Node *oldPred;
|
1997-09-08 23:56:23 +02:00
|
|
|
} PredInfo;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* externs
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define INDEX_SIZE_MASK 0x1FFF
|
|
|
|
#define INDEX_NULL_MASK 0x8000
|
1997-09-07 07:04:48 +02:00
|
|
|
#define INDEX_VAR_MASK 0x4000
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define IndexTupleSize(itup) (((IndexTuple) (itup))->t_info & 0x1FFF)
|
|
|
|
#define IndexTupleDSize(itup) ((itup).t_info & 0x1FFF)
|
1996-08-27 23:50:29 +02:00
|
|
|
#define IndexTupleNoNulls(itup) (!(((IndexTuple) (itup))->t_info & 0x8000))
|
|
|
|
#define IndexTupleAllFixed(itup) (!(((IndexTuple) (itup))->t_info & 0x4000))
|
|
|
|
|
|
|
|
#define IndexTupleHasMinHeader(itup) (IndexTupleNoNulls(itup))
|
|
|
|
|
1998-01-31 05:39:26 +01:00
|
|
|
/*
|
|
|
|
* Takes an infomask as argument (primarily because this needs to be usable
|
|
|
|
* at index_formtuple time so enough space is allocated).
|
|
|
|
*
|
|
|
|
* Change me if adding an attribute to IndexTuples!!!!!!!!!!!
|
|
|
|
*/
|
|
|
|
#define IndexInfoFindDataOffset(t_info) \
|
|
|
|
( \
|
|
|
|
(!((unsigned short)(t_info) & INDEX_NULL_MASK)) ? \
|
|
|
|
( \
|
|
|
|
(Size)sizeof(IndexTupleData) \
|
|
|
|
) \
|
|
|
|
: \
|
|
|
|
( \
|
|
|
|
(Size)DOUBLEALIGN(sizeof(IndexTupleData) + sizeof(IndexAttributeBitMapData)) \
|
|
|
|
) \
|
|
|
|
)
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1998-01-31 05:39:26 +01:00
|
|
|
/* ----------------
|
|
|
|
* index_getattr
|
|
|
|
*
|
|
|
|
* This gets called many times, so we macro the cacheable and NULL
|
|
|
|
* lookups, and call noncachegetattr() for the rest.
|
|
|
|
*
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
#define index_getattr(tup, attnum, tupleDesc, isnull) \
|
|
|
|
( \
|
1998-06-15 20:40:05 +02:00
|
|
|
AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
|
|
|
|
*(isnull) = false, \
|
|
|
|
IndexTupleNoNulls(tup) ? \
|
1998-01-31 05:39:26 +01:00
|
|
|
( \
|
1998-06-15 20:40:05 +02:00
|
|
|
((tupleDesc)->attrs[(attnum)-1]->attcacheoff != -1 || \
|
|
|
|
(attnum) == 1) ? \
|
1998-01-31 05:39:26 +01:00
|
|
|
( \
|
1998-06-15 20:40:05 +02:00
|
|
|
(Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]), \
|
|
|
|
(char *) (tup) + \
|
1998-01-31 05:39:26 +01:00
|
|
|
( \
|
1998-06-15 20:40:05 +02:00
|
|
|
IndexTupleHasMinHeader(tup) ? \
|
|
|
|
sizeof (*(tup)) \
|
|
|
|
: \
|
|
|
|
IndexInfoFindDataOffset((tup)->t_info) \
|
|
|
|
) + \
|
|
|
|
( \
|
|
|
|
((attnum) != 1) ? \
|
|
|
|
(tupleDesc)->attrs[(attnum)-1]->attcacheoff \
|
|
|
|
: \
|
|
|
|
0 \
|
1998-01-31 05:39:26 +01:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
: \
|
1998-06-15 20:40:05 +02:00
|
|
|
nocache_index_getattr((tup), (attnum), (tupleDesc), (isnull)) \
|
1998-01-31 05:39:26 +01:00
|
|
|
) \
|
|
|
|
: \
|
|
|
|
( \
|
1998-06-15 20:40:05 +02:00
|
|
|
(att_isnull((attnum)-1, (char *)(tup) + sizeof(*(tup)))) ? \
|
|
|
|
( \
|
|
|
|
*(isnull) = true, \
|
|
|
|
(Datum)NULL \
|
|
|
|
) \
|
|
|
|
: \
|
|
|
|
( \
|
|
|
|
nocache_index_getattr((tup), (attnum), (tupleDesc), (isnull)) \
|
|
|
|
) \
|
1998-01-31 05:39:26 +01:00
|
|
|
) \
|
|
|
|
)
|
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* indextuple.h */
|
1998-09-01 06:40:42 +02:00
|
|
|
extern IndexTuple index_formtuple(TupleDesc tupleDescriptor,
|
1998-09-01 05:29:17 +02:00
|
|
|
Datum *value, char *null);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Datum nocache_index_getattr(IndexTuple tup, int attnum,
|
1998-02-26 05:46:47 +01:00
|
|
|
TupleDesc tupleDesc, bool *isnull);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern RetrieveIndexResult FormRetrieveIndexResult(ItemPointer indexItemPointer,
|
1997-09-07 07:04:48 +02:00
|
|
|
ItemPointer heapItemPointer);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void CopyIndexTuple(IndexTuple source, IndexTuple *target);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* ITUP_H */
|