Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 04bcf9e

Browse filesBrowse files
committed
Adjust tuplestore.c not to allocate BufFiles in generation context
590b045 made it so tuplestore.c would store tuples inside a generation.c memory context. After fixing a bug report in 97651b0, it seems that it's probably best not to allocate BufFile related allocations in that context. Let's keep it just for tuple data. This adjusts the code to switch to the Tuplestorestate.context's parent, which is the MemoryContext that tuplestore_begin_common() was called in. It does not seem worth adding a new field in Tuplestorestate to store this when we can access it by looking at the Tuplestorestate's context's parent. Discussion: https://postgr.es/m/CAApHDvqFt_CdJtSr+E9YLZb7jZAyRCy3hjQ+ktM+dcOFVq-xkg@mail.gmail.com
1 parent 97651b0 commit 04bcf9e
Copy full SHA for 04bcf9e

File tree

Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed

‎src/backend/utils/sort/tuplestore.c

Copy file name to clipboardExpand all lines: src/backend/utils/sort/tuplestore.c
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
799799
TSReadPointer *readptr;
800800
int i;
801801
ResourceOwner oldowner;
802+
MemoryContext oldcxt;
802803

803804
state->tuples++;
804805

@@ -850,8 +851,17 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
850851
oldowner = CurrentResourceOwner;
851852
CurrentResourceOwner = state->resowner;
852853

854+
/*
855+
* We switch out of the state->context as this is a generation
856+
* context, which isn't ideal for allocations relating to the
857+
* BufFile.
858+
*/
859+
oldcxt = MemoryContextSwitchTo(state->context->parent);
860+
853861
state->myfile = BufFileCreateTemp(state->interXact);
854862

863+
MemoryContextSwitchTo(oldcxt);
864+
855865
CurrentResourceOwner = oldowner;
856866

857867
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.