Tuplestore should remember the memory context it's created in
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2009-12-22T11:45:50Z
Lists: pgsql-hackers
Attachments
- fix-plpgsql-srf-subxact-1.patch (text/x-diff)
With regards to this bug report: http://archives.postgresql.org/pgsql-bugs/2009-12/msg00241.php I think we should change tuplestore code so that callers of tuplestore_put* don't need to switch to the correct memory context (and resource owner, after this patch) before call. Instead, tuplestore_begin_heap() should memorize the context and resource owner used to create the tuplestore, and use that in tuplestore_put* functions. AFAICS it is always a bug to be in a different memory context in tuplestore_put* than in tuplestore_begin_heap(), so it would be more robust to not put the burden on the callers. Patch against CVS HEAD to do that and fix the reported bug attached. Now that the tuplestore_put* switches to the right memory context, we could remove that from all the callers, but this patch only does it for pl_exec.c. Thoughts? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com