summaryrefslogtreecommitdiff
path: root/src/backend/utils/sort
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2008-03-25 19:26:54 +0000
committerNeil Conway <neilc@samurai.com>2008-03-25 19:26:54 +0000
commit1d812a98b47da94ad274dcac682c5d2c014aae16 (patch)
tree6d4b51db76796e3dd7a59e7b18432bf179fe89ad /src/backend/utils/sort
parent76cf067ae40d5f8c4bf95954726e0067131da84b (diff)
downloadpostgresql-1d812a98b47da94ad274dcac682c5d2c014aae16.tar.gz
Add a new tuplestore API function, tuplestore_putvalues(). This is
identical to tuplestore_puttuple(), except it operates on arrays of Datums + nulls rather than a fully-formed HeapTuple. In several places that use the tuplestore API, this means we can avoid creating a HeapTuple altogether, saving a copy.
Diffstat (limited to 'src/backend/utils/sort')
-rw-r--r--src/backend/utils/sort/tuplestore.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c
index d6c192993e..da8de84d68 100644
--- a/src/backend/utils/sort/tuplestore.c
+++ b/src/backend/utils/sort/tuplestore.c
@@ -38,7 +38,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.37 2008/03/10 20:06:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.38 2008/03/25 19:26:53 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -366,8 +366,6 @@ tuplestore_puttupleslot(Tuplestorestate *state,
/*
* "Standard" case to copy from a HeapTuple. This is actually now somewhat
* deprecated, but not worth getting rid of in view of the number of callers.
- * (Consider adding something that takes a tupdesc+values/nulls arrays so
- * that we can use heap_form_minimal_tuple() and avoid a copy step.)
*/
void
tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
@@ -380,6 +378,22 @@ tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
tuplestore_puttuple_common(state, (void *) tuple);
}
+/*
+ * Similar to tuplestore_puttuple(), but start from the values + nulls
+ * array. This avoids requiring that the caller construct a HeapTuple,
+ * saving a copy.
+ */
+void
+tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc,
+ Datum *values, bool *isnull)
+{
+ MinimalTuple tuple;
+
+ tuple = heap_form_minimal_tuple(tdesc, values, isnull);
+
+ tuplestore_puttuple_common(state, (void *) tuple);
+}
+
static void
tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
{