aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/memutils.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-02-27 18:09:42 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-02-27 18:10:04 -0500
commiteaa5808e8ec4e82ce1a87103a6b6f687666e4e4c (patch)
treebd0ea9beab48b3939190ec56c9913a5d1466d53e /src/include/utils/memutils.h
parentfbef4342a86522c98cd605891ad8c1145a61d191 (diff)
downloadpostgresql-eaa5808e8ec4e82ce1a87103a6b6f687666e4e4c.tar.gz
postgresql-eaa5808e8ec4e82ce1a87103a6b6f687666e4e4c.zip
Redefine MemoryContextReset() as deleting, not resetting, child contexts.
That is, MemoryContextReset() now means what was formerly meant by MemoryContextResetAndDeleteChildren(), and the latter is now just a macro alias for the former. If you really want the functionality that was formerly provided by MemoryContextReset(), what you have to do is MemoryContextResetChildren() plus MemoryContextResetOnly() (which is a new API to reset *only* the named context and not touch its children). The reason for this change is that near fifteen years of experience has proven that there is noplace where old-style MemoryContextReset() is actually what you want. Making that the default behavior has led to lots of context-leakage bugs, while we've not found anyplace where it's actually necessary to keep the child contexts; at least the standard regression tests do not reveal anyplace where this change breaks anything. And there are upcoming patches that will introduce additional reasons why child contexts need to be removed. We could change existing calls of MemoryContextResetAndDeleteChildren to be just MemoryContextReset, but for the moment I'll leave them alone; they're not costing anything.
Diffstat (limited to 'src/include/utils/memutils.h')
-rw-r--r--src/include/utils/memutils.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index 76ad7d443b0..dbb163a1536 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -84,6 +84,9 @@ extern PGDLLIMPORT MemoryContext CurTransactionContext;
/* This is a transient link to the active portal's memory context: */
extern PGDLLIMPORT MemoryContext PortalContext;
+/* Backwards compatibility macro */
+#define MemoryContextResetAndDeleteChildren(ctx) MemoryContextReset(ctx)
+
/*
* Memory-context-type-independent functions in mcxt.c
@@ -91,9 +94,9 @@ extern PGDLLIMPORT MemoryContext PortalContext;
extern void MemoryContextInit(void);
extern void MemoryContextReset(MemoryContext context);
extern void MemoryContextDelete(MemoryContext context);
+extern void MemoryContextResetOnly(MemoryContext context);
extern void MemoryContextResetChildren(MemoryContext context);
extern void MemoryContextDeleteChildren(MemoryContext context);
-extern void MemoryContextResetAndDeleteChildren(MemoryContext context);
extern void MemoryContextRegisterResetCallback(MemoryContext context,
MemoryContextCallback *cb);
extern void MemoryContextSetParent(MemoryContext context,