• Robert Haas's avatar
    Fix handling of sortKeys field in Tuplesortstate. · 2720e96a
    Robert Haas authored
    Commit 5cefbf5a introduced an
    assumption that this field would always be non-NULL when doing a merge
    pass, but that's not true.  Without this fix, you can crash the server
    by building a hash index that is sufficiently large relative to
    maintenance_work_mem, or by triggering a large datum sort.
    
    Commit 5ea86e6e changed the comments
    for that field to say that it would be set in all cases except for the
    hash index case, but that wasn't (and still isn't) true.
    
    The datum-sort failure was spotted by Tomas Vondra; initial analysis
    of that failure was by Peter Geoghegan.  The remaining issues were
    spotted by me during review of the surrounding code, and the patch is
    all my fault.
    2720e96a
tuplesort.c 114 KB