David Rowley <david.row...@2ndquadrant.com> writes: > 1) Got rid of PARTITION_ROUTING_MAXSIZE. The code using this was > useless since the int would have wrapped long before it reached > UINT_MAX. There's no shortage of other code doubling the size of an > array by multiplying it by 2 unconditionally without considering > overflowing an int. Unsure why you considered this more risky.
As long as you're re-palloc'ing the array each time, and not increasing its size more than 2X, this is perfectly safe because of the 1GB size limit on palloc requests. You'll fail because of that in the iteration where the request is between 1GB and 2GB, just before integer overflow can occur. (Yes, this is intentional.) regards, tom lane