Skip to content

Commit d003213

Browse files
committed
Don't run in CacheMemoryContext longer than necessary.
1 parent 72164e8 commit d003213

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
static unsigned int uniqueId = 0;
168168

169-
int i;
170169
Oid relid;
171170
Relation rel;
172-
int len;
173171
bool nailme = false;
174172
int natts = tupDesc->natts;
173+
int i;
175174
MemoryContext oldcxt;
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
return rel;
302300
}
303301

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy