On 06/11/15 16:54, Tom Lane wrote:
Tomas Vondra <tomas.von...@2ndquadrant.com> writes:
Interestingly, the hash code checks for INT_MAX overflows on a number of
places, but does not check for this ...

Yeah, and at least at one time there were checks to prevent the hash
table request from exceeding MaxAllocSize. Did those get removed by
somebody?

I think the problem is in this piece of code:

  if ((hashtable->nbatch == 1) &&
      (hashtable->nbuckets_optimal <= INT_MAX / 2) &&
       /* overflow protection */
      (ntuples >= (hashtable->nbuckets_optimal * NTUP_PER_BUCKET)))
      {
          hashtable->nbuckets_optimal *= 2;
          hashtable->log2_nbuckets_optimal += 1;
      }

ISTM it does not check against the max_pointers (that's only done in ExecChooseHashTableSize).



--
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to