mirror of
https://github.com/postgres/postgres.git
synced 2025-12-01 12:18:01 +03:00
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.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.106 2008/01/01 19:45:55 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.107 2008/03/25 19:26:53 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -911,7 +911,6 @@ pg_cursor(PG_FUNCTION_ARGS)
|
||||
while ((hentry = hash_seq_search(&hash_seq)) != NULL)
|
||||
{
|
||||
Portal portal = hentry->portal;
|
||||
HeapTuple tuple;
|
||||
Datum values[6];
|
||||
bool nulls[6];
|
||||
|
||||
@@ -935,11 +934,9 @@ pg_cursor(PG_FUNCTION_ARGS)
|
||||
values[4] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_SCROLL);
|
||||
values[5] = TimestampTzGetDatum(portal->creation_time);
|
||||
|
||||
tuple = heap_form_tuple(tupdesc, values, nulls);
|
||||
|
||||
/* switch to appropriate context while storing the tuple */
|
||||
MemoryContextSwitchTo(per_query_ctx);
|
||||
tuplestore_puttuple(tupstore, tuple);
|
||||
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
||||
}
|
||||
|
||||
/* clean up and return the tuplestore */
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user