diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-06-27 02:51:40 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-06-27 02:51:40 +0000 |
commit | 3f50ba27cf417eb57fd310c2a88f76a6ea6b966e (patch) | |
tree | e9dec4aaac793ed8efab65488e62532057f91704 /contrib/tablefunc/tablefunc.c | |
parent | fe491fb9afd07f3cc9b8aabb17f43049b79258a9 (diff) | |
download | postgresql-3f50ba27cf417eb57fd310c2a88f76a6ea6b966e.tar.gz postgresql-3f50ba27cf417eb57fd310c2a88f76a6ea6b966e.zip |
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.
Diffstat (limited to 'contrib/tablefunc/tablefunc.c')
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 22 |
1 files changed, 8 insertions, 14 deletions
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) |