Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit8f05773

Browse files
committed
Don't force materializing when copying a buffer tuple table slot.
After5408e23 it's not necessary to force materializing thetarget slot when copying from one buffer slot to another. Previouslythat was required because the HeapTupleData portion of the source slotwasn't guaranteed to stay valid long enough, but now we can simplycopy that part into the destination slot's tupdata.Author: Andres Freund
1 parent2c31825 commit8f05773

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎src/backend/executor/execTuples.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,12 @@ tts_buffer_heap_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
747747

748748
/*
749749
* If the source slot is of a different kind, or is a buffer slot that has
750-
* been materialized, make a new copy of the tuple.
750+
* been materialized / is virtual, make a new copy of the tuple. Otherwise
751+
* make a new reference to the in-buffer tuple.
751752
*/
752753
if (dstslot->tts_ops!=srcslot->tts_ops||
753-
TTS_SHOULDFREE(srcslot))
754+
TTS_SHOULDFREE(srcslot)||
755+
!bsrcslot->base.tuple)
754756
{
755757
MemoryContextoldContext;
756758

@@ -763,18 +765,19 @@ tts_buffer_heap_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
763765
}
764766
else
765767
{
766-
if (!bsrcslot->base.tuple)
767-
tts_buffer_heap_materialize(srcslot);
768+
Assert(BufferIsValid(bsrcslot->buffer));
768769

769770
tts_buffer_heap_store_tuple(dstslot,bsrcslot->base.tuple,
770771
bsrcslot->buffer, false);
771772

772773
/*
773-
* Need to materialize because the HeapTupleData portion of the tuple
774-
* might be in a foreign memory context. That's annoying, but until
775-
* that's moved into the slot, unavoidable.
774+
* The HeapTupleData portion of the source tuple might be shorter
775+
* lived than the destination slot. Therefore copy the HeapTuple into
776+
* our slot's tupdata, which is guaranteed to live long enough (but
777+
* will still point into the buffer).
776778
*/
777-
tts_buffer_heap_materialize(dstslot);
779+
memcpy(&bdstslot->base.tupdata,bdstslot->base.tuple,sizeof(HeapTupleData));
780+
bdstslot->base.tuple=&bdstslot->base.tupdata;
778781
}
779782
}
780783

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp