diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/dblink/dblink.c | 5 | ||||
-rw-r--r-- | contrib/pg_stat_statements/pg_stat_statements.c | 11 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 29 | ||||
-rw-r--r-- | contrib/xml2/xpath.c | 6 |
4 files changed, 7 insertions, 44 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 61585644f9..d3875529fd 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -8,7 +8,7 @@ * Darko Prenosil <Darko.Prenosil@finteh.hr> * Shridhar Daithankar <shridhar_daithankar@persistent.co.in> * - * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.84 2009/09/12 23:20:52 joe Exp $ + * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.85 2009/12/29 17:40:59 heikki Exp $ * Copyright (c) 2001-2009, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -1703,10 +1703,7 @@ dblink_get_notify(PG_FUNCTION_ARGS) else nulls[2] = true; - /* switch to appropriate context while storing the tuple */ - MemoryContextSwitchTo(per_query_ctx); tuplestore_putvalues(tupstore, tupdesc, values, nulls); - MemoryContextSwitchTo(oldcontext); PQfreemem(notify); PQconsumeInput(conn); diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index e2b3afa4b6..6912543023 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -14,7 +14,7 @@ * Copyright (c) 2008-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.9 2009/12/15 20:04:49 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.10 2009/12/29 17:40:59 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -783,6 +783,8 @@ pg_stat_statements(PG_FUNCTION_ARGS) rsinfo->setResult = tupstore; rsinfo->setDesc = tupdesc; + MemoryContextSwitchTo(oldcontext); + LWLockAcquire(pgss->lock, LW_SHARED); hash_seq_init(&hash_seq, pgss_hash); @@ -793,9 +795,6 @@ pg_stat_statements(PG_FUNCTION_ARGS) int i = 0; Counters tmp; - /* generate junk in short-term context */ - MemoryContextSwitchTo(oldcontext); - memset(values, 0, sizeof(values)); memset(nulls, 0, sizeof(nulls)); @@ -833,8 +832,6 @@ pg_stat_statements(PG_FUNCTION_ARGS) Assert(i == PG_STAT_STATEMENTS_COLS); - /* switch to appropriate context while storing the tuple */ - MemoryContextSwitchTo(per_query_ctx); tuplestore_putvalues(tupstore, tupdesc, values, nulls); } @@ -843,8 +840,6 @@ pg_stat_statements(PG_FUNCTION_ARGS) /* clean up and return the tuplestore */ tuplestore_donestoring(tupstore); - MemoryContextSwitchTo(oldcontext); - return (Datum) 0; } diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 48512bd934..272b1b4377 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.60 2009/06/11 14:48:52 momjian Exp $ + * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.61 2009/12/29 17:40:59 heikki Exp $ * * * tablefunc @@ -567,14 +567,9 @@ crosstab(PG_FUNCTION_ARGS) { HeapTuple tuple; - /* build the tuple */ + /* build the tuple and store it */ tuple = BuildTupleFromCStrings(attinmeta, values); - - /* switch to appropriate context while storing the tuple */ - oldcontext = MemoryContextSwitchTo(per_query_ctx); tuplestore_puttuple(tupstore, tuple); - MemoryContextSwitchTo(oldcontext); - heap_freetuple(tuple); } @@ -807,7 +802,6 @@ get_crosstab_tuplestore(char *sql, HeapTuple tuple; int ret; int proc; - MemoryContext SPIcontext; /* initialize our tuplestore (while still in query context!) */ tupstore = tuplestore_begin_heap(randomAccess, false, work_mem); @@ -907,10 +901,7 @@ get_crosstab_tuplestore(char *sql, /* 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]); @@ -943,10 +934,7 @@ get_crosstab_tuplestore(char *sql, /* flush the last 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); } if (SPI_finish() != SPI_OK_FINISH) @@ -1232,7 +1220,6 @@ build_tuplestore_recursively(char *key_fld, Tuplestorestate *tupstore) { TupleDesc tupdesc = attinmeta->tupdesc; - MemoryContext oldcontext; int ret; int proc; int serial_column; @@ -1310,15 +1297,9 @@ build_tuplestore_recursively(char *key_fld, /* construct the tuple */ tuple = BuildTupleFromCStrings(attinmeta, values); - /* switch to long lived context while storing the tuple */ - oldcontext = MemoryContextSwitchTo(per_query_ctx); - /* now store it */ tuplestore_puttuple(tupstore, tuple); - /* now reset the context */ - MemoryContextSwitchTo(oldcontext); - /* increment level */ level++; } @@ -1404,15 +1385,9 @@ build_tuplestore_recursively(char *key_fld, xpfree(current_key); xpfree(current_key_parent); - /* switch to long lived context while storing the tuple */ - oldcontext = MemoryContextSwitchTo(per_query_ctx); - /* store the tuple for later use */ tuplestore_puttuple(tupstore, tuple); - /* now reset the context */ - MemoryContextSwitchTo(oldcontext); - heap_freetuple(tuple); /* recurse using current_key_parent as the new start_with */ diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index 203e53905b..a003dd00c8 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.23 2009/06/11 14:48:53 momjian Exp $ + * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.24 2009/12/29 17:40:59 heikki Exp $ * * Parser interface for DOM-based parser (libxml) rather than * stream-based SAX-type parser @@ -821,9 +821,7 @@ xpath_table(PG_FUNCTION_ARGS) { /* not well-formed, so output all-NULL tuple */ ret_tuple = BuildTupleFromCStrings(attinmeta, values); - oldcontext = MemoryContextSwitchTo(per_query_ctx); tuplestore_puttuple(tupstore, ret_tuple); - MemoryContextSwitchTo(oldcontext); heap_freetuple(ret_tuple); } else @@ -897,9 +895,7 @@ xpath_table(PG_FUNCTION_ARGS) if (had_values) { ret_tuple = BuildTupleFromCStrings(attinmeta, values); - oldcontext = MemoryContextSwitchTo(per_query_ctx); tuplestore_puttuple(tupstore, ret_tuple); - MemoryContextSwitchTo(oldcontext); heap_freetuple(ret_tuple); } |