Commit a40a5d94 authored by Alvaro Herrera's avatar Alvaro Herrera

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.
parent bddc35ac
...@@ -591,8 +591,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid, ...@@ -591,8 +591,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid,
Oid Oid
make_new_heap(Oid OIDOldHeap, Oid NewTableSpace) make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
{ {
TupleDesc OldHeapDesc, TupleDesc OldHeapDesc;
tupdesc;
char NewHeapName[NAMEDATALEN]; char NewHeapName[NAMEDATALEN];
Oid OIDNewHeap; Oid OIDNewHeap;
Oid toastid; Oid toastid;
...@@ -605,13 +604,11 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace) ...@@ -605,13 +604,11 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
OldHeapDesc = RelationGetDescr(OldHeap); OldHeapDesc = RelationGetDescr(OldHeap);
/* /*
* Need to make a copy of the tuple descriptor, since * Note that the NewHeap will not
* heap_create_with_catalog modifies it. Note that the NewHeap will not
* receive any of the defaults or constraints associated with the OldHeap; * receive any of the defaults or constraints associated with the OldHeap;
* we don't need 'em, and there's no reason to spend cycles inserting them * we don't need 'em, and there's no reason to spend cycles inserting them
* into the catalogs only to delete them. * into the catalogs only to delete them.
*/ */
tupdesc = CreateTupleDescCopy(OldHeapDesc);
/* /*
* But we do want to use reloptions of the old heap for new heap. * 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) ...@@ -645,7 +642,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
InvalidOid, InvalidOid,
InvalidOid, InvalidOid,
OldHeap->rd_rel->relowner, OldHeap->rd_rel->relowner,
tupdesc, OldHeapDesc,
NIL, NIL,
OldHeap->rd_rel->relkind, OldHeap->rd_rel->relkind,
OldHeap->rd_rel->relpersistence, OldHeap->rd_rel->relpersistence,
......
...@@ -2394,7 +2394,6 @@ OpenIntoRel(QueryDesc *queryDesc) ...@@ -2394,7 +2394,6 @@ OpenIntoRel(QueryDesc *queryDesc)
Oid tablespaceId; Oid tablespaceId;
Datum reloptions; Datum reloptions;
Oid intoRelationId; Oid intoRelationId;
TupleDesc tupdesc;
DR_intorel *myState; DR_intorel *myState;
static char *validnsps[] = HEAP_RELOPT_NAMESPACES; static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
...@@ -2467,9 +2466,6 @@ OpenIntoRel(QueryDesc *queryDesc) ...@@ -2467,9 +2466,6 @@ OpenIntoRel(QueryDesc *queryDesc)
false); false);
(void) heap_reloptions(RELKIND_RELATION, reloptions, true); (void) heap_reloptions(RELKIND_RELATION, reloptions, true);
/* Copy the tupdesc because heap_create_with_catalog modifies it */
tupdesc = CreateTupleDescCopy(queryDesc->tupDesc);
/* Now we can actually create the new relation */ /* Now we can actually create the new relation */
intoRelationId = heap_create_with_catalog(intoName, intoRelationId = heap_create_with_catalog(intoName,
namespaceId, namespaceId,
...@@ -2478,7 +2474,7 @@ OpenIntoRel(QueryDesc *queryDesc) ...@@ -2478,7 +2474,7 @@ OpenIntoRel(QueryDesc *queryDesc)
InvalidOid, InvalidOid,
InvalidOid, InvalidOid,
GetUserId(), GetUserId(),
tupdesc, queryDesc->tupDesc,
NIL, NIL,
RELKIND_RELATION, RELKIND_RELATION,
into->rel->relpersistence, into->rel->relpersistence,
...@@ -2492,8 +2488,6 @@ OpenIntoRel(QueryDesc *queryDesc) ...@@ -2492,8 +2488,6 @@ OpenIntoRel(QueryDesc *queryDesc)
allowSystemTableMods); allowSystemTableMods);
Assert(intoRelationId != InvalidOid); Assert(intoRelationId != InvalidOid);
FreeTupleDesc(tupdesc);
/* /*
* Advance command counter so that the newly-created relation's catalog * Advance command counter so that the newly-created relation's catalog
* tuples will be visible to heap_open. * tuples will be visible to heap_open.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment