]> granicus.if.org Git - postgresql/commit
Make the overflow guards in ExecChooseHashTableSize be more protective.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 30 Oct 2009 20:58:51 +0000 (20:58 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 30 Oct 2009 20:58:51 +0000 (20:58 +0000)
commit3f5a4828f9b04811d25ded71ed452e9b97e1df75
tree266e283d8fc67bdc9db0d06915ea398d27f1de3e
parent4b53f16be9599b4d3f1f067d5070eefd8ab2ce85
Make the overflow guards in ExecChooseHashTableSize be more protective.
The original coding ensured nbuckets and nbatch didn't exceed INT_MAX,
which while not insane on its own terms did nothing to protect subsequent
code like "palloc(nbatch * sizeof(BufFile *))".  Since enormous join size
estimates might well be planner error rather than reality, it seems best
to constrain the initial sizes to be not more than work_mem/sizeof(pointer),
thus ensuring the allocated arrays don't exceed work_mem.  We will allow
nbatch to get bigger than that during subsequent ExecHashIncreaseNumBatches
calls, but we should still guard against integer overflow in those palloc
requests.  Per bug #5145 from Bernt Marius Johnsen.

Although the given test case only seems to fail back to 8.2, previous
releases have variants of this issue, so patch all supported branches.
src/backend/executor/nodeHash.c