• Tom Lane's avatar
    Add macros to make AllocSetContextCreate() calls simpler and safer. · ea268cdc
    Tom Lane authored
    I found that half a dozen (nearly 5%) of our AllocSetContextCreate calls
    had typos in the context-sizing parameters.  While none of these led to
    especially significant problems, they did create minor inefficiencies,
    and it's now clear that expecting people to copy-and-paste those calls
    accurately is not a great idea.  Let's reduce the risk of future errors
    by introducing single macros that encapsulate the common use-cases.
    Three such macros are enough to cover all but two special-purpose contexts;
    those two calls can be left as-is, I think.
    
    While this patch doesn't in itself improve matters for third-party
    extensions, it doesn't break anything for them either, and they can
    gradually adopt the simplified notation over time.
    
    In passing, change TopMemoryContext to use the default allocation
    parameters.  Formerly it could only be extended 8K at a time.  That was
    probably reasonable when this code was written; but nowadays we create
    many more contexts than we did then, so that it's not unusual to have a
    couple hundred K in TopMemoryContext, even without considering various
    dubious code that sticks other things there.  There seems no good reason
    not to let it use growing blocks like most other contexts.
    
    Back-patch to 9.6, mostly because that's still close enough to HEAD that
    it's easy to do so, and keeping the branches in sync can be expected to
    avoid some future back-patching pain.  The bugs fixed by these changes
    don't seem to be significant enough to justify fixing them further back.
    
    Discussion: <21072.1472321324@sss.pgh.pa.us>
    ea268cdc
spgscan.c 17 KB