• Andres Freund's avatar
    Plug leak in BuildTupleHashTable by creating ExprContext in correct context. · 5567d12c
    Andres Freund authored
    In bf6c614a I added a expr context to evaluate the grouping
    expression. Unfortunately the code I added initialized them while in
    the calling context, rather the table context.  Additionally, I used
    CreateExprContext() rather than CreateStandaloneExprContext(), which
    creates the econtext in the estate's query context.
    
    Fix that by using CreateStandaloneExprContext when in the table's
    tablecxt. As we rely on the memory being freed by a memory context
    reset that means that the econtext's shutdown callbacks aren't being
    called, but that seems ok as the expressions are tightly controlled
    due to ExecBuildGroupingEqual().
    
    Bug: #15592
    Reported-By: Dmitry Marakasov
    Author: Andres Freund
    Discussion: https://postgr.es/m/20190114222838.h6r3fuyxjxkykf6t@alap3.anarazel.de
    Backpatch: 11, where I broke this in bf6c614a
    5567d12c
execGrouping.c 13.3 KB