diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-01-07 03:53:08 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-01-07 03:53:08 +0000 |
commit | 814c8a03bacf9e30c2c7b4e652986b68a292ac30 (patch) | |
tree | 77d8fd67ced2db54c4fcee3e3d5233174e077a54 /src/backend | |
parent | c7f08913ba98931753f7acef39fc2d83a18f7b6e (diff) | |
download | postgresql-814c8a03bacf9e30c2c7b4e652986b68a292ac30.tar.gz postgresql-814c8a03bacf9e30c2c7b4e652986b68a292ac30.zip |
Further fixes for per-tablespace options patch.
Add missing varlena header to TableSpaceOpts structure. And, per
Tom Lane, instead of calling tablespace_reloptions in CacheMemoryContext,
call it in the caller's memory context and copy the value over
afterwards, to reduce the chances of a session-lifetime memory leak.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/utils/cache/spccache.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/utils/cache/spccache.c b/src/backend/utils/cache/spccache.c index 16526159bc8..6f28da32032 100644 --- a/src/backend/utils/cache/spccache.c +++ b/src/backend/utils/cache/spccache.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.3 2010/01/06 23:00:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.4 2010/01/07 03:53:08 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -142,7 +142,6 @@ get_tablespace(Oid spcid) { Datum datum; bool isNull; - MemoryContext octx; datum = SysCacheGetAttr(TABLESPACEOID, tp, @@ -152,10 +151,9 @@ get_tablespace(Oid spcid) opts = NULL; else { - /* XXX should NOT do the parsing work in CacheMemoryContext */ - octx = MemoryContextSwitchTo(CacheMemoryContext); - opts = (TableSpaceOpts *) tablespace_reloptions(datum, false); - MemoryContextSwitchTo(octx); + bytea *bytea_opts = tablespace_reloptions(datum, false); + opts = MemoryContextAlloc(CacheMemoryContext, VARSIZE(bytea_opts)); + memcpy(opts, bytea_opts, VARSIZE(bytea_opts)); } ReleaseSysCache(tp); } |