postgresql/src/backend/commands
Tom Lane 407b50f2d4 Store GUC data in a memory context, instead of using malloc().
The only real argument for using malloc directly was that we needed
the ability to not throw error on OOM; but mcxt.c grew that feature
awhile ago.

Keeping the data in a memory context improves accountability and
debuggability --- for example, without this it's almost impossible
to detect memory leaks in the GUC code with anything less costly
than valgrind.  Moreover, the next patch in this series will add a
hash table for GUC lookup, and it'd be pretty silly to be using
palloc-dependent hash facilities alongside malloc'd storage of the
underlying data.

This is a bit invasive though, in particular causing an API break
for GUC check hooks that want to modify the GUC's value or use an
"extra" data structure.  They must now use guc_malloc() and
guc_free() instead of malloc() and free().  Failure to change
affected code will result in assertion failures or worse; but
thanks to recent effort in the mcxt infrastructure, it shouldn't
be too hard to diagnose such oversights (at least in assert-enabled
builds).

One note is that this changes ParseLongOption() to return short-lived
palloc'd not malloc'd data.  There wasn't any caller for which the
previous definition was better.

Discussion: https://postgr.es/m/2982579.1662416866@sss.pgh.pa.us
2022-10-14 12:10:48 -04:00
..
Makefile Move parallel vacuum code to vacuumparallel.c. 2021-12-23 11:42:52 +05:30
aggregatecmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
alter.c Ensure that pg_auth_members.grantor is always valid. 2022-08-18 13:13:02 -04:00
amcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
analyze.c Cleanup useless assignments and checks 2022-10-04 13:16:23 +09:00
async.c Revert the addition of GetMaxBackends() and related stuff. 2022-04-12 14:45:23 -04:00
cluster.c Split up guc.c for better build speed and ease of maintenance. 2022-09-13 11:11:45 -04:00
collationcmds.c Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
comment.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
conversioncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copy.c Add support for COPY TO callback functions 2022-10-11 11:45:52 +09:00
copyfrom.c Allow batch insertion during COPY into a foreign table. 2022-10-13 18:45:00 +09:00
copyfromparse.c Fix typo in comment. 2022-08-26 16:55:00 +09:00
copyto.c Add support for COPY TO callback functions 2022-10-11 11:45:52 +09:00
createas.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
dbcommands.c Message style improvements 2022-09-24 18:41:25 -04:00
define.c Improve two comments related to a boolean DefElem's value 2022-07-11 11:07:33 +09:00
discard.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dropcmds.c Use list_copy_head() instead of list_truncate(list_copy(...), ...) 2022-07-13 15:03:47 +12:00
event_trigger.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
explain.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
extension.c Fix missed corner cases for grantable permissions on GUCs. 2022-07-19 17:21:55 -04:00
foreigncmds.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
functioncmds.c More -Wshadow=compatible-local warning fixes 2022-08-26 02:35:40 +12:00
indexcmds.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
lockcmds.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
matview.c Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
meson.build meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
opclasscmds.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
operatorcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
policy.c Add construct_array_builtin, deconstruct_array_builtin 2022-07-01 11:23:15 +02:00
portalcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
prepare.c Assorted examples of expanded type-safer palloc/pg_malloc API 2022-09-12 08:45:03 +02:00
proclang.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
publicationcmds.c Rename shadowed local variables 2022-10-05 21:01:41 +13:00
schemacmds.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
seclabel.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
sequence.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
statscmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
subscriptioncmds.c Improve the WARNING message for CREATE SUBSCRIPTION. 2022-10-13 06:09:43 +05:30
tablecmds.c Fix self-referencing foreign keys with partitioned tables 2022-10-07 19:37:48 +02:00
tablespace.c Store GUC data in a memory context, instead of using malloc(). 2022-10-14 12:10:48 -04:00
trigger.c Rename shadowed local variables 2022-10-05 21:01:41 +13:00
tsearchcmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
typecmds.c Avoid using list_length() to test for empty list. 2022-08-17 11:12:35 -04:00
user.c Change some errdetail() to errdetail_internal() 2022-09-28 17:14:53 +02:00
vacuum.c Derive freeze cutoff from nextXID, not OldestXmin. 2022-08-31 11:37:35 -07:00
vacuumparallel.c Use logical operator && instead of & in vacuumparallel.c. 2022-08-22 08:53:58 +05:30
variable.c Store GUC data in a memory context, instead of using malloc(). 2022-10-14 12:10:48 -04:00
view.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00