diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-10-25 19:13:37 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-10-25 19:13:37 +0000 |
commit | dd7444cfe2c73a31e45e7ee93bf1555e7920177c (patch) | |
tree | 830411db19b5bb54f1002d2e8f3e9b9034c451d9 /src | |
parent | 9ddfe034c7d7ee9c4a7dcae1ba37e5e4e5ac2488 (diff) | |
download | postgresql-dd7444cfe2c73a31e45e7ee93bf1555e7920177c.tar.gz postgresql-dd7444cfe2c73a31e45e7ee93bf1555e7920177c.zip |
Fix memory management for new variables -- they must actually survive
transaction end, in case we decide to do a vacuum analyze (which is done in two
xacts).
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/postmaster/autovacuum.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index d77a4d96133..82c31d918cd 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -55,7 +55,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.64 2007/10/25 14:45:55 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.65 2007/10/25 19:13:37 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -2099,11 +2099,9 @@ next_worker: /* * Save the relation name for a possible error message, to avoid a - * catalog lookup in case of an error. We do it in - * TopTransactionContext so that they go away automatically in the next - * iteration. + * catalog lookup in case of an error. Note: they must live in a + * long-lived memory context. */ - MemoryContextSwitchTo(TopTransactionContext); datname = get_database_name(MyDatabaseId); nspname = get_namespace_name(get_rel_namespace(tab->at_relid)); relname = get_rel_name(tab->at_relid); @@ -2116,6 +2114,7 @@ next_worker: PG_TRY(); { /* have at it */ + MemoryContextSwitchTo(TopTransactionContext); autovacuum_do_vac_analyze(tab->at_relid, tab->at_dovacuum, tab->at_doanalyze, @@ -2152,6 +2151,9 @@ next_worker: /* be tidy */ pfree(tab); + pfree(datname); + pfree(nspname); + pfree(relname); /* remove my info from shared memory */ LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE); |