1 /*-------------------------------------------------------------------------
4 * Generalized routines for temporary tuple storage.
6 * This module handles temporary storage of tuples for purposes such
7 * as Materialize nodes, hashjoin batch files, etc. It is essentially
8 * a dumbed-down version of tuplesort.c; it does no sorting of tuples
9 * but can only store and regurgitate a sequence of tuples. However,
10 * because no sort is required, it is allowed to start reading the sequence
11 * before it has all been written. This is particularly useful for cursors,
12 * because it allows random access within the already-scanned portion of
13 * a query without having to process the underlying scan to completion.
14 * A temporary file is used to handle the data if it exceeds the
15 * space limit specified by the caller.
17 * Beginning in Postgres 8.2, what is stored is just MinimalTuples;
18 * callers cannot expect valid system columns in regurgitated tuples.
19 * Also, we have changed the API to return tuples in TupleTableSlots,
20 * so that there is a check to prevent attempted access to system columns.
22 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
23 * Portions Copyright (c) 1994, Regents of the University of California
25 * $PostgreSQL: pgsql/src/include/utils/tuplestore.h,v 1.18 2006/06/27 02:51:40 tgl Exp $
27 *-------------------------------------------------------------------------
32 #include "executor/tuptable.h"
35 /* Tuplestorestate is an opaque type whose details are not known outside
38 typedef struct Tuplestorestate Tuplestorestate;
41 * Currently we only need to store MinimalTuples, but it would be easy
42 * to support the same behavior for IndexTuples and/or bare Datums.
45 extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
49 extern void tuplestore_puttupleslot(Tuplestorestate *state,
50 TupleTableSlot *slot);
51 extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
53 /* tuplestore_donestoring() used to be required, but is no longer used */
54 #define tuplestore_donestoring(state) ((void) 0)
56 /* backwards scan is only allowed if randomAccess was specified 'true' */
57 extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
58 TupleTableSlot *slot);
59 extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
61 extern void tuplestore_end(Tuplestorestate *state);
63 extern bool tuplestore_ateof(Tuplestorestate *state);
65 extern void tuplestore_rescan(Tuplestorestate *state);
66 extern void tuplestore_markpos(Tuplestorestate *state);
67 extern void tuplestore_restorepos(Tuplestorestate *state);
69 #endif /* TUPLESTORE_H */