Remove unnecessary smgropen() calls
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 12 Feb 2024 08:59:45 +0000 (10:59 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 12 Feb 2024 08:59:45 +0000 (10:59 +0200)
Now that RelationCreateStorage() returns the SmgrRelation (since
commit 5c1560606dc), use that.

Author: Japin Li
Discussion: https://www.postgresql.org/message-id/ME3P282MB316600FA62F6605477F26F6AB6742@ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM

src/backend/access/heap/heapam_handler.c
src/backend/commands/tablecmds.c

index d15a02b2be7fd54870b751bc21fd97fdc42e23ba..680a50bf8b161bb37576efad4b962631a6d73f0e 100644 (file)
@@ -633,8 +633,6 @@ heapam_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
 {
    SMgrRelation dstrel;
 
-   dstrel = smgropen(*newrlocator, rel->rd_backend);
-
    /*
     * Since we copy the file directly without looking at the shared buffers,
     * we'd better first flush out any pages of the source relation that are
@@ -650,7 +648,7 @@ heapam_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
     * NOTE: any conflict in relfilenumber value will be caught in
     * RelationCreateStorage().
     */
-   RelationCreateStorage(*newrlocator, rel->rd_rel->relpersistence, true);
+   dstrel = RelationCreateStorage(*newrlocator, rel->rd_rel->relpersistence, true);
 
    /* copy main fork */
    RelationCopyStorage(RelationGetSmgr(rel), dstrel, MAIN_FORKNUM,
index 9f51696740ed43689e074826ff8e1e104f7edf28..86ea3a228b65639d84163edec3effc6c97ed8932 100644 (file)
@@ -15747,8 +15747,6 @@ index_copy_data(Relation rel, RelFileLocator newrlocator)
 {
    SMgrRelation dstrel;
 
-   dstrel = smgropen(newrlocator, rel->rd_backend);
-
    /*
     * Since we copy the file directly without looking at the shared buffers,
     * we'd better first flush out any pages of the source relation that are
@@ -15764,7 +15762,7 @@ index_copy_data(Relation rel, RelFileLocator newrlocator)
     * NOTE: any conflict in relfilenumber value will be caught in
     * RelationCreateStorage().
     */
-   RelationCreateStorage(newrlocator, rel->rd_rel->relpersistence, true);
+   dstrel = RelationCreateStorage(newrlocator, rel->rd_rel->relpersistence, true);
 
    /* copy main fork */
    RelationCopyStorage(RelationGetSmgr(rel), dstrel, MAIN_FORKNUM,