2000-06-19 00:44:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* tuplestore.h
|
|
|
|
* Generalized routines for temporary tuple storage.
|
|
|
|
*
|
|
|
|
* This module handles temporary storage of tuples for purposes such
|
|
|
|
* as Materialize nodes, hashjoin batch files, etc. It is essentially
|
|
|
|
* a dumbed-down version of tuplesort.c; it does no sorting of tuples
|
2003-03-09 03:19:13 +01:00
|
|
|
* but can only store and regurgitate a sequence of tuples. However,
|
|
|
|
* because no sort is required, it is allowed to start reading the sequence
|
2014-05-06 18:12:18 +02:00
|
|
|
* before it has all been written. This is particularly useful for cursors,
|
2003-03-09 03:19:13 +01:00
|
|
|
* because it allows random access within the already-scanned portion of
|
|
|
|
* a query without having to process the underlying scan to completion.
|
2008-10-01 21:51:50 +02:00
|
|
|
* Also, it is possible to support multiple independent read pointers.
|
|
|
|
*
|
2000-06-19 00:44:35 +02:00
|
|
|
* A temporary file is used to handle the data if it exceeds the
|
|
|
|
* space limit specified by the caller.
|
|
|
|
*
|
2006-06-27 04:51:40 +02:00
|
|
|
* Beginning in Postgres 8.2, what is stored is just MinimalTuples;
|
|
|
|
* callers cannot expect valid system columns in regurgitated tuples.
|
|
|
|
* Also, we have changed the API to return tuples in TupleTableSlots,
|
|
|
|
* so that there is a check to prevent attempted access to system columns.
|
|
|
|
*
|
2016-01-02 19:33:40 +01:00
|
|
|
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
|
2000-06-19 00:44:35 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/utils/tuplestore.h
|
2000-06-19 00:44:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TUPLESTORE_H
|
|
|
|
#define TUPLESTORE_H
|
|
|
|
|
2006-06-27 04:51:40 +02:00
|
|
|
#include "executor/tuptable.h"
|
|
|
|
|
2000-06-19 00:44:35 +02:00
|
|
|
|
|
|
|
/* Tuplestorestate is an opaque type whose details are not known outside
|
|
|
|
* tuplestore.c.
|
|
|
|
*/
|
|
|
|
typedef struct Tuplestorestate Tuplestorestate;
|
|
|
|
|
|
|
|
/*
|
2006-06-27 04:51:40 +02:00
|
|
|
* Currently we only need to store MinimalTuples, but it would be easy
|
2000-06-19 00:44:35 +02:00
|
|
|
* to support the same behavior for IndexTuples and/or bare Datums.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
|
2003-08-04 02:43:34 +02:00
|
|
|
bool interXact,
|
|
|
|
int maxKBytes);
|
2000-06-19 00:44:35 +02:00
|
|
|
|
2007-05-21 19:57:35 +02:00
|
|
|
extern void tuplestore_set_eflags(Tuplestorestate *state, int eflags);
|
|
|
|
|
2006-06-27 04:51:40 +02:00
|
|
|
extern void tuplestore_puttupleslot(Tuplestorestate *state,
|
2006-10-04 02:30:14 +02:00
|
|
|
TupleTableSlot *slot);
|
2006-06-27 04:51:40 +02:00
|
|
|
extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
|
2008-03-25 20:26:54 +01:00
|
|
|
extern void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc,
|
2009-06-11 16:49:15 +02:00
|
|
|
Datum *values, bool *isnull);
|
2000-06-19 00:44:35 +02:00
|
|
|
|
2003-03-09 04:34:10 +01:00
|
|
|
/* tuplestore_donestoring() used to be required, but is no longer used */
|
|
|
|
#define tuplestore_donestoring(state) ((void) 0)
|
|
|
|
|
2008-10-01 21:51:50 +02:00
|
|
|
extern int tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags);
|
|
|
|
|
|
|
|
extern void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr);
|
|
|
|
|
|
|
|
extern void tuplestore_copy_read_pointer(Tuplestorestate *state,
|
2009-06-11 16:49:15 +02:00
|
|
|
int srcptr, int destptr);
|
2008-10-01 21:51:50 +02:00
|
|
|
|
2008-12-27 18:39:00 +01:00
|
|
|
extern void tuplestore_trim(Tuplestorestate *state);
|
|
|
|
|
2008-12-28 19:54:01 +01:00
|
|
|
extern bool tuplestore_in_memory(Tuplestorestate *state);
|
|
|
|
|
2006-06-27 04:51:40 +02:00
|
|
|
extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
|
2009-03-27 19:30:21 +01:00
|
|
|
bool copy, TupleTableSlot *slot);
|
2014-04-13 19:59:17 +02:00
|
|
|
|
2006-06-27 04:51:40 +02:00
|
|
|
extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
|
2000-06-19 00:44:35 +02:00
|
|
|
|
2014-04-13 19:59:17 +02:00
|
|
|
extern bool tuplestore_skiptuples(Tuplestorestate *state,
|
|
|
|
int64 ntuples, bool forward);
|
|
|
|
|
2003-03-09 03:19:13 +01:00
|
|
|
extern bool tuplestore_ateof(Tuplestorestate *state);
|
2000-06-19 00:44:35 +02:00
|
|
|
|
|
|
|
extern void tuplestore_rescan(Tuplestorestate *state);
|
2008-10-01 21:51:50 +02:00
|
|
|
|
2008-10-04 23:56:55 +02:00
|
|
|
extern void tuplestore_clear(Tuplestorestate *state);
|
|
|
|
|
2008-10-01 21:51:50 +02:00
|
|
|
extern void tuplestore_end(Tuplestorestate *state);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* TUPLESTORE_H */
|