You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Store GUC data in a memory context, instead of using malloc().
The only real argument for using malloc directly was that we neededthe ability to not throw error on OOM; but mcxt.c grew that featureawhile ago.Keeping the data in a memory context improves accountability anddebuggability --- for example, without this it's almost impossibleto detect memory leaks in the GUC code with anything less costlythan valgrind. Moreover, the next patch in this series will add ahash table for GUC lookup, and it'd be pretty silly to be usingpalloc-dependent hash facilities alongside malloc'd storage of theunderlying data.This is a bit invasive though, in particular causing an API breakfor GUC check hooks that want to modify the GUC's value or use an"extra" data structure. They must now use guc_malloc() andguc_free() instead of malloc() and free(). Failure to changeaffected code will result in assertion failures or worse; butthanks to recent effort in the mcxt infrastructure, it shouldn'tbe too hard to diagnose such oversights (at least in assert-enabledbuilds).One note is that this changes ParseLongOption() to return short-livedpalloc'd not malloc'd data. There wasn't any caller for which theprevious definition was better.Discussion:https://postgr.es/m/2982579.1662416866@sss.pgh.pa.us