Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit814c8a0

Browse files
committed
Further fixes for per-tablespace options patch.
Add missing varlena header to TableSpaceOpts structure. And, perTom Lane, instead of calling tablespace_reloptions in CacheMemoryContext,call it in the caller's memory context and copy the value overafterwards, to reduce the chances of a session-lifetime memory leak.
1 parentc7f0891 commit814c8a0

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

‎src/backend/utils/cache/spccache.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.3 2010/01/06 23:00:02 tgl Exp $
15+
* $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.4 2010/01/07 03:53:08 rhaas Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -142,7 +142,6 @@ get_tablespace(Oid spcid)
142142
{
143143
Datumdatum;
144144
boolisNull;
145-
MemoryContextoctx;
146145

147146
datum=SysCacheGetAttr(TABLESPACEOID,
148147
tp,
@@ -152,10 +151,9 @@ get_tablespace(Oid spcid)
152151
opts=NULL;
153152
else
154153
{
155-
/* XXX should NOT do the parsing work in CacheMemoryContext */
156-
octx=MemoryContextSwitchTo(CacheMemoryContext);
157-
opts= (TableSpaceOpts*)tablespace_reloptions(datum, false);
158-
MemoryContextSwitchTo(octx);
154+
bytea*bytea_opts=tablespace_reloptions(datum, false);
155+
opts=MemoryContextAlloc(CacheMemoryContext,VARSIZE(bytea_opts));
156+
memcpy(opts,bytea_opts,VARSIZE(bytea_opts));
159157
}
160158
ReleaseSysCache(tp);
161159
}

‎src/include/commands/tablespace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.22 2010/01/05 21:53:59 rhaas Exp $
10+
* $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.23 2010/01/07 03:53:08 rhaas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -34,6 +34,7 @@ typedef struct xl_tblspc_drop_rec
3434

3535
typedefstructTableSpaceOpts
3636
{
37+
int32vl_len_;/* varlena header (do not touch directly!) */
3738
float8random_page_cost;
3839
float8seq_page_cost;
3940
}TableSpaceOpts;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp