]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Make more use of binaryheap_empty() and binaryheap_size().
authorNathan Bossart <nathan@postgresql.org>
Tue, 1 Jul 2025 19:19:07 +0000 (14:19 -0500)
committerNathan Bossart <nathan@postgresql.org>
Tue, 1 Jul 2025 19:19:07 +0000 (14:19 -0500)
A few places were accessing bh_size directly instead of via these
handy macros.

Author: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CAJ7c6TPQMVL%2B028T4zuw9ZqL5Du9JavOLhBQLkJeK0RznYx_6w%40mail.gmail.com

src/backend/postmaster/pgarch.c
src/backend/replication/logical/reorderbuffer.c

index 7e622ae4bd2a705762671eacd9b8b714edb28d7c..78e39e5f866a744b0d4b744eb33c735b9b3bd8c7 100644 (file)
@@ -718,15 +718,15 @@ pgarch_readyXlog(char *xlog)
                /*
                 * Store the file in our max-heap if it has a high enough priority.
                 */
-               if (arch_files->arch_heap->bh_size < NUM_FILES_PER_DIRECTORY_SCAN)
+               if (binaryheap_size(arch_files->arch_heap) < NUM_FILES_PER_DIRECTORY_SCAN)
                {
                        /* If the heap isn't full yet, quickly add it. */
-                       arch_file = arch_files->arch_filenames[arch_files->arch_heap->bh_size];
+                       arch_file = arch_files->arch_filenames[binaryheap_size(arch_files->arch_heap)];
                        strcpy(arch_file, basename);
                        binaryheap_add_unordered(arch_files->arch_heap, CStringGetDatum(arch_file));
 
                        /* If we just filled the heap, make it a valid one. */
-                       if (arch_files->arch_heap->bh_size == NUM_FILES_PER_DIRECTORY_SCAN)
+                       if (binaryheap_size(arch_files->arch_heap) == NUM_FILES_PER_DIRECTORY_SCAN)
                                binaryheap_build(arch_files->arch_heap);
                }
                else if (ready_file_comparator(binaryheap_first(arch_files->arch_heap),
@@ -744,21 +744,21 @@ pgarch_readyXlog(char *xlog)
        FreeDir(rldir);
 
        /* If no files were found, simply return. */
-       if (arch_files->arch_heap->bh_size == 0)
+       if (binaryheap_empty(arch_files->arch_heap))
                return false;
 
        /*
         * If we didn't fill the heap, we didn't make it a valid one.  Do that
         * now.
         */
-       if (arch_files->arch_heap->bh_size < NUM_FILES_PER_DIRECTORY_SCAN)
+       if (binaryheap_size(arch_files->arch_heap) < NUM_FILES_PER_DIRECTORY_SCAN)
                binaryheap_build(arch_files->arch_heap);
 
        /*
         * Fill arch_files array with the files to archive in ascending order of
         * priority.
         */
-       arch_files->arch_files_size = arch_files->arch_heap->bh_size;
+       arch_files->arch_files_size = binaryheap_size(arch_files->arch_heap);
        for (int i = 0; i < arch_files->arch_files_size; i++)
                arch_files->arch_files[i] = DatumGetCString(binaryheap_remove_first(arch_files->arch_heap));
 
index c4299c76fb16bcd45f5b8b0ee8337357a7540e66..7b4e8629553b8681e6707e8785b94b1781dcca54 100644 (file)
@@ -1415,7 +1415,7 @@ ReorderBufferIterTXNNext(ReorderBuffer *rb, ReorderBufferIterTXNState *state)
        int32           off;
 
        /* nothing there anymore */
-       if (state->heap->bh_size == 0)
+       if (binaryheap_empty(state->heap))
                return NULL;
 
        off = DatumGetInt32(binaryheap_first(state->heap));