1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* tuptable.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* tuple table support stuff
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
2004-12-31 23:04:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2005-03-14 05:41:13 +01:00
|
|
|
* $PostgreSQL: pgsql/src/include/executor/tuptable.h,v 1.27 2005/03/14 04:41:13 tgl Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TUPTABLE_H
|
|
|
|
#define TUPTABLE_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/htup.h"
|
1996-10-23 09:42:13 +02:00
|
|
|
|
2005-03-14 05:41:13 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The executor stores pointers to tuples in a "tuple table"
|
|
|
|
* which is composed of TupleTableSlots. Sometimes the tuples
|
|
|
|
* are pointers to buffer pages, while others are pointers to
|
|
|
|
* palloc'ed memory; the shouldFree variable tells us whether
|
|
|
|
* we may call pfree() on a tuple. When shouldFree is true,
|
|
|
|
* the tuple is "owned" by the TupleTableSlot and should be
|
|
|
|
* freed when the slot's reference to the tuple is dropped.
|
1999-02-23 08:36:31 +01:00
|
|
|
*
|
2005-03-14 05:41:13 +01:00
|
|
|
* shouldFreeDesc is similar to shouldFree: if it's true, then the
|
|
|
|
* tupleDescriptor is "owned" by the TupleTableSlot and should be
|
|
|
|
* freed when the slot's reference to the descriptor is dropped.
|
2001-01-29 01:39:20 +01:00
|
|
|
*
|
2005-03-14 05:41:13 +01:00
|
|
|
* If buffer is not InvalidBuffer, then the slot is holding a pin
|
|
|
|
* on the indicated buffer page; drop the pin when we release the
|
|
|
|
* slot's reference to that buffer. (shouldFree should always be
|
|
|
|
* false in such a case, since presumably val is pointing at the
|
|
|
|
* buffer page.)
|
1999-02-23 08:36:31 +01:00
|
|
|
*
|
2005-03-14 05:41:13 +01:00
|
|
|
* The slot_getattr() routine allows extraction of attribute values from
|
|
|
|
* a TupleTableSlot's current tuple. It is equivalent to heap_getattr()
|
|
|
|
* except that it can optimize fetching of multiple values more efficiently.
|
|
|
|
* The cache_xxx fields of TupleTableSlot are support for slot_getattr().
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct TupleTableSlot
|
|
|
|
{
|
2005-03-14 05:41:13 +01:00
|
|
|
NodeTag type; /* vestigial ... allows IsA tests */
|
|
|
|
HeapTuple val; /* current tuple, or NULL if none */
|
|
|
|
TupleDesc ttc_tupleDescriptor; /* tuple's descriptor */
|
|
|
|
bool ttc_shouldFree; /* should pfree tuple? */
|
|
|
|
bool ttc_shouldFreeDesc; /* should pfree descriptor? */
|
|
|
|
Buffer ttc_buffer; /* tuple's buffer, or InvalidBuffer */
|
|
|
|
MemoryContext ttc_mcxt; /* slot itself is in this context */
|
|
|
|
Datum *cache_values; /* currently extracted values */
|
|
|
|
int cache_natts; /* # of valid values in cache_values */
|
|
|
|
bool cache_slow; /* saved state for slot_getattr */
|
|
|
|
long cache_off; /* saved state for slot_getattr */
|
1997-09-08 23:56:23 +02:00
|
|
|
} TupleTableSlot;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2005-03-14 05:41:13 +01:00
|
|
|
/*
|
|
|
|
* Tuple table data structure: an array of TupleTableSlots.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct TupleTableData
|
|
|
|
{
|
2005-03-14 05:41:13 +01:00
|
|
|
int size; /* size of the table (number of slots) */
|
1997-09-08 04:41:22 +02:00
|
|
|
int next; /* next available slot number */
|
2005-03-14 05:41:13 +01:00
|
|
|
TupleTableSlot array[1]; /* VARIABLE LENGTH ARRAY - must be last */
|
|
|
|
} TupleTableData; /* VARIABLE LENGTH STRUCT */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
typedef TupleTableData *TupleTable;
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2005-03-14 05:41:13 +01:00
|
|
|
|
|
|
|
/* in access/common/heaptuple.c */
|
|
|
|
extern Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* TUPTABLE_H */
|