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

Commitd003213

Browse files
committed
Don't run in CacheMemoryContext longer than necessary.
1 parent72164e8 commitd003213

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

‎src/backend/catalog/heap.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.134 2000/06/28 03:31:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.135 2000/07/02 04:46:09 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -166,12 +166,11 @@ heap_create(char *relname,
166166
{
167167
staticunsignedintuniqueId=0;
168168

169-
inti;
170169
Oidrelid;
171170
Relationrel;
172-
intlen;
173171
boolnailme= false;
174172
intnatts=tupDesc->natts;
173+
inti;
175174
MemoryContextoldcxt;
176175

177176
/* ----------------
@@ -236,13 +235,13 @@ heap_create(char *relname,
236235
*allocate a new relation descriptor.
237236
* ----------------
238237
*/
239-
len=sizeof(RelationData);
240-
241-
rel= (Relation)palloc(len);
242-
MemSet((char*)rel,0,len);
238+
rel= (Relation)palloc(sizeof(RelationData));
239+
MemSet((char*)rel,0,sizeof(RelationData));
243240
rel->rd_fd=-1;/* table is not open */
244241
rel->rd_unlinked= true;/* table is not created yet */
245242

243+
RelationSetReferenceCount(rel,1);
244+
246245
/*
247246
* create a new tuple descriptor from the one passed in
248247
*/
@@ -257,14 +256,11 @@ heap_create(char *relname,
257256
if (nailme)
258257
rel->rd_isnailed= true;
259258

260-
RelationSetReferenceCount(rel,1);
261-
262-
rel->rd_rel= (Form_pg_class)palloc(sizeof*rel->rd_rel);
263-
264259
/* ----------------
265260
*initialize the fields of our new relation descriptor
266261
* ----------------
267262
*/
263+
rel->rd_rel= (Form_pg_class)palloc(sizeof*rel->rd_rel);
268264
MemSet((char*)rel->rd_rel,0,sizeof*rel->rd_rel);
269265
strcpy(RelationGetPhysicalRelationName(rel),relname);
270266
rel->rd_rel->relkind=RELKIND_UNCATALOGED;
@@ -283,10 +279,14 @@ heap_create(char *relname,
283279
rel->rd_rel->reltype=relid;
284280
}
285281

282+
/* ----------------
283+
*done building relcache entry.
284+
* ----------------
285+
*/
286+
MemoryContextSwitchTo(oldcxt);
287+
286288
/* ----------------
287289
*have the storage manager create the relation.
288-
*
289-
* XXX shouldn't we switch out of CacheMemoryContext for that?
290290
* ----------------
291291
*/
292292

@@ -296,8 +296,6 @@ heap_create(char *relname,
296296

297297
RelationRegisterRelation(rel);
298298

299-
MemoryContextSwitchTo(oldcxt);
300-
301299
returnrel;
302300
}
303301

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp