summaryrefslogtreecommitdiff
path: root/src/include/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-06-18 22:44:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-06-18 22:44:35 +0000
commit1ee26b776475155ad1fb00fa3ed0a93659ffadad (patch)
tree1f2c7a59a1fdf3fe3eb62cf5044c5c6c21f77d12 /src/include/utils
parent2c0edb3c8677831d836fc44eb58ebecb73f747af (diff)
downloadpostgresql-1ee26b776475155ad1fb00fa3ed0a93659ffadad.tar.gz
Reimplement nodeMaterial to use a temporary BufFile (or even memory, if the
materialized tupleset is small enough) instead of a temporary relation. This was something I was thinking of doing anyway for performance, and Jan says he needs it for TOAST because he doesn't want to cope with toasting noname relations. With this change, the 'noname table' support in heap.c is dead code, and I have accordingly removed it. Also clean up 'noname' plan handling in planner --- nonames are either sort or materialize plans, and it seems less confusing to handle them separately under those names.
Diffstat (limited to 'src/include/utils')
-rw-r--r--src/include/utils/rel.h3
-rw-r--r--src/include/utils/tuplestore.h60
2 files changed, 61 insertions, 2 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 2a585c0e7e..901020611a 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rel.h,v 1.37 2000/06/17 21:49:02 tgl Exp $
+ * $Id: rel.h,v 1.38 2000/06/18 22:44:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -90,7 +90,6 @@ typedef struct RelationData
uint16 rd_refcnt; /* reference count */
bool rd_myxactonly; /* rel uses the local buffer mgr */
bool rd_isnailed; /* rel is nailed in cache */
- bool rd_isnoname; /* rel has no name */
bool rd_unlinked; /* rel already unlinked or not created yet */
bool rd_indexfound; /* true if rd_indexlist is valid */
Form_pg_am rd_am; /* AM tuple */
diff --git a/src/include/utils/tuplestore.h b/src/include/utils/tuplestore.h
new file mode 100644
index 0000000000..702d3b73c9
--- /dev/null
+++ b/src/include/utils/tuplestore.h
@@ -0,0 +1,60 @@
+/*-------------------------------------------------------------------------
+ *
+ * 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
+ * but can only store a sequence of tuples and regurgitate it later.
+ * A temporary file is used to handle the data if it exceeds the
+ * space limit specified by the caller.
+ *
+ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: tuplestore.h,v 1.1 2000/06/18 22:44:35 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TUPLESTORE_H
+#define TUPLESTORE_H
+
+#include "access/htup.h"
+
+/* Tuplestorestate is an opaque type whose details are not known outside
+ * tuplestore.c.
+ */
+typedef struct Tuplestorestate Tuplestorestate;
+
+/*
+ * Currently we only need to store HeapTuples, but it would be easy
+ * to support the same behavior for IndexTuples and/or bare Datums.
+ */
+
+extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
+ int maxKBytes);
+
+extern void tuplestore_puttuple(Tuplestorestate *state, void *tuple);
+
+extern void tuplestore_donestoring(Tuplestorestate *state);
+
+extern void *tuplestore_gettuple(Tuplestorestate *state, bool forward,
+ bool *should_free);
+
+#define tuplestore_getheaptuple(state, forward, should_free) \
+ ((HeapTuple) tuplestore_gettuple(state, forward, should_free))
+
+extern void tuplestore_end(Tuplestorestate *state);
+
+/*
+ * These routines may only be called if randomAccess was specified 'true'.
+ * Likewise, backwards scan in gettuple/getdatum is only allowed if
+ * randomAccess was specified.
+ */
+
+extern void tuplestore_rescan(Tuplestorestate *state);
+extern void tuplestore_markpos(Tuplestorestate *state);
+extern void tuplestore_restorepos(Tuplestorestate *state);
+
+#endif /* TUPLESTORE_H */