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

Commit2dbdba8

Browse files
committed
Kluge solution for Alex Pilosov's report of problems with whole-tuple
function arguments in join queries: copy the tuples intoTransactionCommandContext so they don't get recycled too soon. This ishorrid, but not any worse than 7.0 or before, which also leaked suchtuples until end of query. A proper fix will require allowing tupledatums to be physically stored inside larger tuple datums, which opensup a bunch of issues that can't realistically be solved for 7.1.1.
1 parentb9be04e commit2dbdba8

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

‎src/backend/executor/execQual.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.85 2001/03/23 04:49:53 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.86 2001/04/19 04:29:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -333,21 +333,32 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
333333

334334
/*
335335
* If the attribute number is invalid, then we are supposed to return
336-
* the entire tuple, we give back a whole slot so that callers know
337-
* what the tuple looks like. XXX why copy? Couldn't we just give
338-
* back the existing slot?
336+
* the entire tuple; we give back a whole slot so that callers know
337+
* what the tuple looks like.
338+
*
339+
* XXX this is a horrid crock: since the pointer to the slot might
340+
* live longer than the current evaluation context, we are forced to
341+
* copy the tuple and slot into a long-lived context --- we use
342+
* TransactionCommandContext which should be safe enough. This
343+
* represents a serious memory leak if many such tuples are processed
344+
* in one command, however. We ought to redesign the representation
345+
* of whole-tuple datums so that this is not necessary.
346+
*
347+
* We assume it's OK to point to the existing tupleDescriptor, rather
348+
* than copy that too.
339349
*/
340350
if (attnum==InvalidAttrNumber)
341351
{
342-
TupleTableSlot*tempSlot=MakeTupleTableSlot();
343-
TupleDesctd;
352+
MemoryContextoldContext;
353+
TupleTableSlot*tempSlot;
344354
HeapTupletup;
345355

356+
oldContext=MemoryContextSwitchTo(TransactionCommandContext);
357+
tempSlot=MakeTupleTableSlot();
346358
tup=heap_copytuple(heapTuple);
347-
td=CreateTupleDescCopy(tuple_type);
348-
349-
ExecSetSlotDescriptor(tempSlot,td, true);
350359
ExecStoreTuple(tup,tempSlot,InvalidBuffer, true);
360+
ExecSetSlotDescriptor(tempSlot,tuple_type, false);
361+
MemoryContextSwitchTo(oldContext);
351362
returnPointerGetDatum(tempSlot);
352363
}
353364

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp