PostgreSQL Source Code  git master
tuplestore.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * tuplestore.h
4  * Generalized routines for temporary tuple storage.
5  *
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  * Also, it is possible to support multiple independent read pointers.
15  *
16  * A temporary file is used to handle the data if it exceeds the
17  * space limit specified by the caller.
18  *
19  * Beginning in Postgres 8.2, what is stored is just MinimalTuples;
20  * callers cannot expect valid system columns in regurgitated tuples.
21  * Also, we have changed the API to return tuples in TupleTableSlots,
22  * so that there is a check to prevent attempted access to system columns.
23  *
24  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
25  * Portions Copyright (c) 1994, Regents of the University of California
26  *
27  * src/include/utils/tuplestore.h
28  *
29  *-------------------------------------------------------------------------
30  */
31 #ifndef TUPLESTORE_H
32 #define TUPLESTORE_H
33 
34 #include "executor/tuptable.h"
35 
36 
37 /* Tuplestorestate is an opaque type whose details are not known outside
38  * tuplestore.c.
39  */
40 typedef struct Tuplestorestate Tuplestorestate;
41 
42 /*
43  * Currently we only need to store MinimalTuples, but it would be easy
44  * to support the same behavior for IndexTuples and/or bare Datums.
45  */
46 
47 extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
48  bool interXact,
49  int maxKBytes);
50 
52 
54  TupleTableSlot *slot);
57  const Datum *values, const bool *isnull);
58 
60 
62 
64  int srcptr, int destptr);
65 
67 
68 extern void tuplestore_get_stats(Tuplestorestate *state, char **storage_type,
69  int64 *max_space);
70 
72 
73 extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
74  bool copy, TupleTableSlot *slot);
75 
76 extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
77 
79  int64 ntuples, bool forward);
80 
82 
84 
86 
88 
90 
91 #endif /* TUPLESTORE_H */
static Datum values[MAXATTR]
Definition: bootstrap.c:150
uintptr_t Datum
Definition: postgres.h:64
Definition: regguts.h:323
bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward, bool copy, TupleTableSlot *slot)
Definition: tuplestore.c:1130
void tuplestore_get_stats(Tuplestorestate *state, char **storage_type, int64 *max_space)
Definition: tuplestore.c:1533
void tuplestore_puttupleslot(Tuplestorestate *state, TupleTableSlot *slot)
Definition: tuplestore.c:742
void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
Definition: tuplestore.c:507
void tuplestore_clear(Tuplestorestate *state)
Definition: tuplestore.c:430
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
Definition: tuplestore.c:330
int64 tuplestore_tuple_count(Tuplestorestate *state)
Definition: tuplestore.c:580
void tuplestore_rescan(Tuplestorestate *state)
Definition: tuplestore.c:1285
int tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags)
Definition: tuplestore.c:395
void tuplestore_trim(Tuplestorestate *state)
Definition: tuplestore.c:1412
void tuplestore_copy_read_pointer(Tuplestorestate *state, int srcptr, int destptr)
Definition: tuplestore.c:1320
bool tuplestore_advance(Tuplestorestate *state, bool forward)
Definition: tuplestore.c:1162
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
Definition: tuplestore.c:784
bool tuplestore_in_memory(Tuplestorestate *state)
Definition: tuplestore.c:1554
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:492
void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
Definition: tuplestore.c:764
bool tuplestore_ateof(Tuplestorestate *state)
Definition: tuplestore.c:591
void tuplestore_set_eflags(Tuplestorestate *state, int eflags)
Definition: tuplestore.c:371
bool tuplestore_skiptuples(Tuplestorestate *state, int64 ntuples, bool forward)
Definition: tuplestore.c:1187