From 3f50ba27cf417eb57fd310c2a88f76a6ea6b966e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 27 Jun 2006 02:51:40 +0000 Subject: Create infrastructure for 'MinimalTuple' representation of in-memory tuples with less header overhead than a regular HeapTuple, per my recent proposal. Teach TupleTableSlot code how to deal with these. As proof of concept, change tuplestore.c to store MinimalTuples instead of HeapTuples. Future patches will expand the concept to other places where it is useful. --- contrib/tablefunc/tablefunc.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'contrib/tablefunc/tablefunc.c') diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index f5f751e72fe..7ab363972e5 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -934,19 +934,16 @@ get_crosstab_tuplestore(char *sql, */ if (lastrowid != NULL) { - /* - * switch to appropriate context while storing the tuple - */ - SPIcontext = MemoryContextSwitchTo(per_query_ctx); - /* rowid changed, flush the previous output row */ tuple = BuildTupleFromCStrings(attinmeta, values); + + /* switch to appropriate context while storing the tuple */ + SPIcontext = MemoryContextSwitchTo(per_query_ctx); tuplestore_puttuple(tupstore, tuple); + MemoryContextSwitchTo(SPIcontext); + for (j = 0; j < result_ncols; j++) xpfree(values[j]); - - /* now reset the context */ - MemoryContextSwitchTo(SPIcontext); } values[0] = rowid; @@ -970,16 +967,13 @@ get_crosstab_tuplestore(char *sql, lastrowid = pstrdup(rowid); } - /* switch to appropriate context while storing the tuple */ - SPIcontext = MemoryContextSwitchTo(per_query_ctx); - /* flush the last output row */ tuple = BuildTupleFromCStrings(attinmeta, values); - tuplestore_puttuple(tupstore, tuple); - /* now reset the context */ + /* switch to appropriate context while storing the tuple */ + SPIcontext = MemoryContextSwitchTo(per_query_ctx); + tuplestore_puttuple(tupstore, tuple); MemoryContextSwitchTo(SPIcontext); - } if (SPI_finish() != SPI_OK_FINISH) -- cgit v1.2.3