mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Don't run in CacheMemoryContext longer than necessary.
This commit is contained in:
parent
72164e86a6
commit
d003213225
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.134 2000/06/28 03:31:22 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.135 2000/07/02 04:46:09 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -166,12 +166,11 @@ heap_create(char *relname,
|
|||||||
{
|
{
|
||||||
static unsigned int uniqueId = 0;
|
static unsigned int uniqueId = 0;
|
||||||
|
|
||||||
int i;
|
|
||||||
Oid relid;
|
Oid relid;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
int len;
|
|
||||||
bool nailme = false;
|
bool nailme = false;
|
||||||
int natts = tupDesc->natts;
|
int natts = tupDesc->natts;
|
||||||
|
int i;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
@ -236,13 +235,13 @@ heap_create(char *relname,
|
|||||||
* allocate a new relation descriptor.
|
* allocate a new relation descriptor.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
len = sizeof(RelationData);
|
rel = (Relation) palloc(sizeof(RelationData));
|
||||||
|
MemSet((char *) rel, 0, sizeof(RelationData));
|
||||||
rel = (Relation) palloc(len);
|
|
||||||
MemSet((char *) rel, 0, len);
|
|
||||||
rel->rd_fd = -1; /* table is not open */
|
rel->rd_fd = -1; /* table is not open */
|
||||||
rel->rd_unlinked = true; /* table is not created yet */
|
rel->rd_unlinked = true; /* table is not created yet */
|
||||||
|
|
||||||
|
RelationSetReferenceCount(rel, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a new tuple descriptor from the one passed in
|
* create a new tuple descriptor from the one passed in
|
||||||
*/
|
*/
|
||||||
@ -257,14 +256,11 @@ heap_create(char *relname,
|
|||||||
if (nailme)
|
if (nailme)
|
||||||
rel->rd_isnailed = true;
|
rel->rd_isnailed = true;
|
||||||
|
|
||||||
RelationSetReferenceCount(rel, 1);
|
|
||||||
|
|
||||||
rel->rd_rel = (Form_pg_class) palloc(sizeof *rel->rd_rel);
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize the fields of our new relation descriptor
|
* initialize the fields of our new relation descriptor
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
|
rel->rd_rel = (Form_pg_class) palloc(sizeof *rel->rd_rel);
|
||||||
MemSet((char *) rel->rd_rel, 0, sizeof *rel->rd_rel);
|
MemSet((char *) rel->rd_rel, 0, sizeof *rel->rd_rel);
|
||||||
strcpy(RelationGetPhysicalRelationName(rel), relname);
|
strcpy(RelationGetPhysicalRelationName(rel), relname);
|
||||||
rel->rd_rel->relkind = RELKIND_UNCATALOGED;
|
rel->rd_rel->relkind = RELKIND_UNCATALOGED;
|
||||||
@ -283,10 +279,14 @@ heap_create(char *relname,
|
|||||||
rel->rd_rel->reltype = relid;
|
rel->rd_rel->reltype = relid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* done building relcache entry.
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
MemoryContextSwitchTo(oldcxt);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* have the storage manager create the relation.
|
* have the storage manager create the relation.
|
||||||
*
|
|
||||||
* XXX shouldn't we switch out of CacheMemoryContext for that?
|
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -296,8 +296,6 @@ heap_create(char *relname,
|
|||||||
|
|
||||||
RelationRegisterRelation(rel);
|
RelationRegisterRelation(rel);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcxt);
|
|
||||||
|
|
||||||
return rel;
|
return rel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user