mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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.
This commit is contained in:
10
src/backend/utils/cache/spccache.c
vendored
10
src/backend/utils/cache/spccache.c
vendored
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
Datum datum;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
MemoryContext octx;
|
|
||||||
|
|
||||||
datum = SysCacheGetAttr(TABLESPACEOID,
|
datum = SysCacheGetAttr(TABLESPACEOID,
|
||||||
tp,
|
tp,
|
||||||
@ -152,10 +151,9 @@ get_tablespace(Oid spcid)
|
|||||||
opts = NULL;
|
opts = NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* XXX should NOT do the parsing work in CacheMemoryContext */
|
bytea *bytea_opts = tablespace_reloptions(datum, false);
|
||||||
octx = MemoryContextSwitchTo(CacheMemoryContext);
|
opts = MemoryContextAlloc(CacheMemoryContext, VARSIZE(bytea_opts));
|
||||||
opts = (TableSpaceOpts *) tablespace_reloptions(datum, false);
|
memcpy(opts, bytea_opts, VARSIZE(bytea_opts));
|
||||||
MemoryContextSwitchTo(octx);
|
|
||||||
}
|
}
|
||||||
ReleaseSysCache(tp);
|
ReleaseSysCache(tp);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.22 2010/01/05 21:53:59 rhaas Exp $
|
* $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.23 2010/01/07 03:53:08 rhaas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -34,6 +34,7 @@ typedef struct xl_tblspc_drop_rec
|
|||||||
|
|
||||||
typedef struct TableSpaceOpts
|
typedef struct TableSpaceOpts
|
||||||
{
|
{
|
||||||
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
float8 random_page_cost;
|
float8 random_page_cost;
|
||||||
float8 seq_page_cost;
|
float8 seq_page_cost;
|
||||||
} TableSpaceOpts;
|
} TableSpaceOpts;
|
||||||
|
Reference in New Issue
Block a user