postgresql/src
Neil Conway 3df9abd1a5 ALTER TABLE ADD COLUMN exhibits a significant memory leak when adding a
column with a default expression. In that situation, we need to rewrite
the heap relation. To evaluate the new default expression, we use
ExecEvalExpr(); however, this can allocate memory in the current memory
context, and ATRewriteTable() does not switch out of the active portal's
heap memory context. The end result is a rather large memory leak (on
the order of gigabytes for a reasonably sized table).

This patch changes ATRewriteTable() to switch to the per-tuple memory
context before beginning the per-tuple loop. It also removes an explicit
heap_freetuple() in the loop, since that is no longer needed.

In an unrelated change, I noticed the code was scanning through the
attributes of the new tuple descriptor for each tuple of the old table.
I changed this to use precomputation, which should slightly speed up
the loop.

Thanks to steve@deefs.net for reporting the leak.
2005-02-09 23:17:26 +00:00
..
backend ALTER TABLE ADD COLUMN exhibits a significant memory leak when adding a 2005-02-09 23:17:26 +00:00
bin Fix minor thinko in logic to set dump order when dumping from a pre-7.3 2005-02-03 23:38:58 +00:00
corba make sure the $Id tags are converted to $PostgreSQL as well ... 2003-11-29 22:41:33 +00:00
include Ensure that all details of the ARC algorithm are hidden within freelist.c. 2005-02-03 23:29:19 +00:00
interfaces Fixed bug in parsing of CREATE AS statement. 2005-02-09 11:26:44 +00:00
makefiles Revert -Wl, change to Makefile.osf, as the allegedly more standard 2005-01-06 20:56:50 +00:00
pl Adjust plpgsql to allow assignment to an element of an array that is 2005-02-01 19:35:14 +00:00
port Use SHGetFolderPath instead of SHGetSpecialFolderPath to find the 2005-01-26 19:24:03 +00:00
template Support Sun's compiler on SunOS4 (a/k/a Solaris 9). Per ayan@ayan.net 2004-12-29 23:47:40 +00:00
test Adjust constant-folding of CASE expressions so that the simple comparison 2005-02-02 21:49:09 +00:00
timezone Tag appropriate files for rc3 2004-12-31 22:04:05 +00:00
tools Add to release checklist: 2005-02-02 16:58:52 +00:00
tutorial Adjust src/tutorial Makefile so that it can use pgxs. This allows the 2005-01-13 18:23:22 +00:00
utils PostgreSQL extension makefile framework ("pgxs"), by Fabien Coelho, with 2004-07-30 12:26:40 +00:00
DEVELOPERS
Makefile Adjust src/tutorial Makefile so that it can use pgxs. This allows the 2005-01-13 18:23:22 +00:00
Makefile.global.in Use SHGetFolderPath instead of SHGetSpecialFolderPath to find the 2005-01-26 19:24:03 +00:00
Makefile.shlib Fix up makefile dependencies for pg_config_paths.h. 2004-11-20 21:13:06 +00:00
bcc32.mak $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
nls-global.mk More locale fixes for pg_ctl. 2004-06-01 03:32:42 +00:00
win32.mak $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00