Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a40a5d9

Browse files
committed
Remove extra copying of TupleDescs for heap_create_with_catalog
Some callers were creating copies of tuple descriptors to pass to that function, stating in code comments that it was necessary because it modified the passed descriptor. Code inspection reveals this not to be true, and indeed not all callers are passing copies in the first place. So remove the extra ones and the misleading comments about this behavior as well.
1 parent bddc35a commit a40a5d9

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/backend/commands/cluster.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid,
591591
Oid
592592
make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
593593
{
594-
TupleDesc OldHeapDesc,
595-
tupdesc;
594+
TupleDesc OldHeapDesc;
596595
char NewHeapName[NAMEDATALEN];
597596
Oid OIDNewHeap;
598597
Oid toastid;
@@ -605,13 +604,11 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
605604
OldHeapDesc = RelationGetDescr(OldHeap);
606605

607606
/*
608-
* Need to make a copy of the tuple descriptor, since
609-
* heap_create_with_catalog modifies it. Note that the NewHeap will not
607+
* Note that the NewHeap will not
610608
* receive any of the defaults or constraints associated with the OldHeap;
611609
* we don't need 'em, and there's no reason to spend cycles inserting them
612610
* into the catalogs only to delete them.
613611
*/
614-
tupdesc = CreateTupleDescCopy(OldHeapDesc);
615612

616613
/*
617614
* But we do want to use reloptions of the old heap for new heap.
@@ -645,7 +642,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
645642
InvalidOid,
646643
InvalidOid,
647644
OldHeap->rd_rel->relowner,
648-
tupdesc,
645+
OldHeapDesc,
649646
NIL,
650647
OldHeap->rd_rel->relkind,
651648
OldHeap->rd_rel->relpersistence,

src/backend/executor/execMain.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,6 @@ OpenIntoRel(QueryDesc *queryDesc)
23942394
Oid tablespaceId;
23952395
Datum reloptions;
23962396
Oid intoRelationId;
2397-
TupleDesc tupdesc;
23982397
DR_intorel *myState;
23992398
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
24002399

@@ -2467,9 +2466,6 @@ OpenIntoRel(QueryDesc *queryDesc)
24672466
false);
24682467
(void) heap_reloptions(RELKIND_RELATION, reloptions, true);
24692468

2470-
/* Copy the tupdesc because heap_create_with_catalog modifies it */
2471-
tupdesc = CreateTupleDescCopy(queryDesc->tupDesc);
2472-
24732469
/* Now we can actually create the new relation */
24742470
intoRelationId = heap_create_with_catalog(intoName,
24752471
namespaceId,
@@ -2478,7 +2474,7 @@ OpenIntoRel(QueryDesc *queryDesc)
24782474
InvalidOid,
24792475
InvalidOid,
24802476
GetUserId(),
2481-
tupdesc,
2477+
queryDesc->tupDesc,
24822478
NIL,
24832479
RELKIND_RELATION,
24842480
into->rel->relpersistence,
@@ -2492,8 +2488,6 @@ OpenIntoRel(QueryDesc *queryDesc)
24922488
allowSystemTableMods);
24932489
Assert(intoRelationId != InvalidOid);
24942490

2495-
FreeTupleDesc(tupdesc);
2496-
24972491
/*
24982492
* Advance command counter so that the newly-created relation's catalog
24992493
* tuples will be visible to heap_open.

0 commit comments

Comments
 (0)