Move heaprel struct field next to index rel field.
authorPeter Geoghegan <pg@bowt.ie>
Mon, 3 Apr 2023 18:01:11 +0000 (11:01 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Mon, 3 Apr 2023 18:01:11 +0000 (11:01 -0700)
Commit 61b313e4 added a heaprel struct member to IndexVacuumInfo, but
placed it last.  Move the heaprel struct member next to the index struct
member to improve the code's readability.

Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WznG=TV6S9d3VA=y0vBHbXwnLs9_LLdiML=aNJuHeriwxg@mail.gmail.com

src/backend/access/heap/vacuumlazy.c
src/backend/catalog/index.c
src/backend/commands/analyze.c
src/backend/commands/vacuumparallel.c
src/include/access/genam.h

index 3e5d3982c7d62a66fc9e5a6e4ecb6334613c9f6e..639179aa46d9969a6a78df8c4d0b3719e225ba2c 100644 (file)
@@ -2711,13 +2711,13 @@ lazy_vacuum_one_index(Relation indrel, IndexBulkDeleteResult *istat,
    LVSavedErrInfo saved_err_info;
 
    ivinfo.index = indrel;
+   ivinfo.heaprel = vacrel->rel;
    ivinfo.analyze_only = false;
    ivinfo.report_progress = false;
    ivinfo.estimated_count = true;
    ivinfo.message_level = DEBUG2;
    ivinfo.num_heap_tuples = reltuples;
    ivinfo.strategy = vacrel->bstrategy;
-   ivinfo.heaprel = vacrel->rel;
 
    /*
     * Update error traceback information.
@@ -2760,6 +2760,7 @@ lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat,
    LVSavedErrInfo saved_err_info;
 
    ivinfo.index = indrel;
+   ivinfo.heaprel = vacrel->rel;
    ivinfo.analyze_only = false;
    ivinfo.report_progress = false;
    ivinfo.estimated_count = estimated_count;
@@ -2767,7 +2768,6 @@ lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat,
 
    ivinfo.num_heap_tuples = reltuples;
    ivinfo.strategy = vacrel->bstrategy;
-   ivinfo.heaprel = vacrel->rel;
 
    /*
     * Update error traceback information.
index ce0acf5890f513ce08845395d4469d3ec372e5bb..352e43d0e6133f9838cf8cedd7c1a5f77b0769fd 100644 (file)
@@ -3358,13 +3358,13 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
     * Scan the index and gather up all the TIDs into a tuplesort object.
     */
    ivinfo.index = indexRelation;
+   ivinfo.heaprel = heapRelation;
    ivinfo.analyze_only = false;
    ivinfo.report_progress = true;
    ivinfo.estimated_count = true;
    ivinfo.message_level = DEBUG2;
    ivinfo.num_heap_tuples = heapRelation->rd_rel->reltuples;
    ivinfo.strategy = NULL;
-   ivinfo.heaprel = heapRelation;
 
    /*
     * Encode TIDs as int8 values for the sort, rather than directly sorting
index 2b404767bb2ade5bb5e2a66fab60beadf5a08dbb..52ef462dba3fe92f8cf0c5d6f8f42db43231e487 100644 (file)
@@ -707,12 +707,12 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
            IndexVacuumInfo ivinfo;
 
            ivinfo.index = Irel[ind];
+           ivinfo.heaprel = onerel;
            ivinfo.analyze_only = true;
            ivinfo.estimated_count = true;
            ivinfo.message_level = elevel;
            ivinfo.num_heap_tuples = onerel->rd_rel->reltuples;
            ivinfo.strategy = vac_strategy;
-           ivinfo.heaprel = onerel;
 
            stats = index_vacuum_cleanup(&ivinfo, NULL);
 
index 2cdbd182b6924afba926e053fba703278eff70bb..563117a8f6eaf41127ae7e65bb6cb91fd50ef90b 100644 (file)
@@ -836,13 +836,13 @@ parallel_vacuum_process_one_index(ParallelVacuumState *pvs, Relation indrel,
        istat = &(indstats->istat);
 
    ivinfo.index = indrel;
+   ivinfo.heaprel = pvs->heaprel;
    ivinfo.analyze_only = false;
    ivinfo.report_progress = false;
    ivinfo.message_level = DEBUG2;
    ivinfo.estimated_count = pvs->shared->estimated_count;
    ivinfo.num_heap_tuples = pvs->shared->reltuples;
    ivinfo.strategy = pvs->bstrategy;
-   ivinfo.heaprel = pvs->heaprel;
 
    /* Update error traceback information */
    pvs->indname = pstrdup(RelationGetRelationName(indrel));
index a939a7353e51ede020986ad8ea314c424ee5dfb3..a30879566549a1894ea01067cc813ef3fcf0121f 100644 (file)
@@ -44,13 +44,13 @@ typedef struct IndexBuildResult
 typedef struct IndexVacuumInfo
 {
    Relation    index;          /* the index being vacuumed */
+   Relation    heaprel;        /* the heap relation the index belongs to */
    bool        analyze_only;   /* ANALYZE (without any actual vacuum) */
    bool        report_progress;    /* emit progress.h status reports */
    bool        estimated_count;    /* num_heap_tuples is an estimate */
    int         message_level;  /* ereport level for progress messages */
    double      num_heap_tuples;    /* tuples remaining in heap */
    BufferAccessStrategy strategy;  /* access strategy for reads */
-   Relation    heaprel;        /* the heap relation the index belongs to */
 } IndexVacuumInfo;
 
 /*