Header And Logo

PostgreSQL
| The world's most advanced open source database.

tuplestore.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * tuplestore.h
00004  *    Generalized routines for temporary tuple storage.
00005  *
00006  * This module handles temporary storage of tuples for purposes such
00007  * as Materialize nodes, hashjoin batch files, etc.  It is essentially
00008  * a dumbed-down version of tuplesort.c; it does no sorting of tuples
00009  * but can only store and regurgitate a sequence of tuples.  However,
00010  * because no sort is required, it is allowed to start reading the sequence
00011  * before it has all been written.  This is particularly useful for cursors,
00012  * because it allows random access within the already-scanned portion of
00013  * a query without having to process the underlying scan to completion.
00014  * Also, it is possible to support multiple independent read pointers.
00015  *
00016  * A temporary file is used to handle the data if it exceeds the
00017  * space limit specified by the caller.
00018  *
00019  * Beginning in Postgres 8.2, what is stored is just MinimalTuples;
00020  * callers cannot expect valid system columns in regurgitated tuples.
00021  * Also, we have changed the API to return tuples in TupleTableSlots,
00022  * so that there is a check to prevent attempted access to system columns.
00023  *
00024  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00025  * Portions Copyright (c) 1994, Regents of the University of California
00026  *
00027  * src/include/utils/tuplestore.h
00028  *
00029  *-------------------------------------------------------------------------
00030  */
00031 #ifndef TUPLESTORE_H
00032 #define TUPLESTORE_H
00033 
00034 #include "executor/tuptable.h"
00035 
00036 
00037 /* Tuplestorestate is an opaque type whose details are not known outside
00038  * tuplestore.c.
00039  */
00040 typedef struct Tuplestorestate Tuplestorestate;
00041 
00042 /*
00043  * Currently we only need to store MinimalTuples, but it would be easy
00044  * to support the same behavior for IndexTuples and/or bare Datums.
00045  */
00046 
00047 extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
00048                       bool interXact,
00049                       int maxKBytes);
00050 
00051 extern void tuplestore_set_eflags(Tuplestorestate *state, int eflags);
00052 
00053 extern void tuplestore_puttupleslot(Tuplestorestate *state,
00054                         TupleTableSlot *slot);
00055 extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
00056 extern void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc,
00057                      Datum *values, bool *isnull);
00058 
00059 /* tuplestore_donestoring() used to be required, but is no longer used */
00060 #define tuplestore_donestoring(state)   ((void) 0)
00061 
00062 extern int  tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags);
00063 
00064 extern void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr);
00065 
00066 extern void tuplestore_copy_read_pointer(Tuplestorestate *state,
00067                              int srcptr, int destptr);
00068 
00069 extern void tuplestore_trim(Tuplestorestate *state);
00070 
00071 extern bool tuplestore_in_memory(Tuplestorestate *state);
00072 
00073 extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
00074                         bool copy, TupleTableSlot *slot);
00075 extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
00076 
00077 extern bool tuplestore_ateof(Tuplestorestate *state);
00078 
00079 extern void tuplestore_rescan(Tuplestorestate *state);
00080 
00081 extern void tuplestore_clear(Tuplestorestate *state);
00082 
00083 extern void tuplestore_end(Tuplestorestate *state);
00084 
00085 #endif   /* TUPLESTORE_H */