Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: arons/postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 81a61fd
Choose a base ref
...
head repository: postgres/postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4fbe015
Choose a head ref
  • 17 commits
  • 24 files changed
  • 6 contributors

Commits on Sep 9, 2025

  1. test_slru: Fix LWLock tranche allocation in EXEC_BACKEND builds.

    Currently, test_slru's shmem_startup_hook unconditionally generates
    new LWLock tranche IDs.  This is fine on non-EXEC_BACKEND builds,
    where only the postmaster executes this hook, but on EXEC_BACKEND
    builds, every backend executes it, too.  To fix, only generate the
    tranche IDs in the postmaster process by checking the
    IsUnderPostmaster variable.
    
    This is arguably a bug fix and could be back-patched, but since the
    damage is limited to some extra unused tranche IDs in a test
    module, I'm not going to bother.
    
    Reported-by: Sami Imseih <samimseih@gmail.com>
    Reviewed-by: Sami Imseih <samimseih@gmail.com>
    Discussion: https://postgr.es/m/CAA5RZ0vaAuonaf12CeDddQJu5xKL%2B6xVyS%2B_q1%2BcH%3D33JXV82w%40mail.gmail.com
    nathan-bossart committed Sep 9, 2025
    Configuration menu
    Copy the full SHA
    530cfa8 View commit details
    Browse the repository at this point in the history
  2. Fix documentation for shmem_startup_hook.

    This section claims that each backend executes the
    shmem_startup_hook shortly after attaching to shared memory, which
    is true for EXEC_BACKEND builds, but not for others.  This commit
    adds this important detail.
    
    Oversight in commit 964152c.
    
    Reported-by: Sami Imseih <samimseih@gmail.com>
    Reviewed-by: Sami Imseih <samimseih@gmail.com>
    Discussion: https://postgr.es/m/CAA5RZ0vEGT1eigGbVt604LkXP6mUPMwPMxQoRCbFny44w%2B9EUQ%40mail.gmail.com
    Backpatch-through: 17
    nathan-bossart committed Sep 9, 2025
    Configuration menu
    Copy the full SHA
    d96c854 View commit details
    Browse the repository at this point in the history
  3. Fix leak with SMgrRelations in startup process

    The startup process does not process shared invalidation messages, only
    sending them, and never calls AtEOXact_SMgr() which clean up any
    unpinned SMgrRelations.  Hence, it is never able to free SMgrRelations
    on a periodic basis, bloating its hashtable over time.
    
    Like the checkpointer and the bgwriter, this commit takes a conservative
    approach by freeing periodically SMgrRelations when replaying a
    checkpoint record, either online or shutdown, so as the startup process
    has a way to perform a periodic cleanup.
    
    Issue caused by 21d9c3e, so backpatch down to v17.
    
    Author: Jingtang Zhang <mrdrivingduck@gmail.com>
    Reviewed-by: Yuhang Qiu <iamqyh@gmail.com>
    Discussion: https://postgr.es/m/28C687D4-F335-417E-B06C-6612A0BD5A10@gmail.com
    Backpatch-through: 17
    michaelpq committed Sep 9, 2025
    Configuration menu
    Copy the full SHA
    8c8f7b1 View commit details
    Browse the repository at this point in the history

Commits on Sep 10, 2025

  1. Replace callers of dynahash.h's my_log() by equivalent in pg_bitutils.h

    All the calls replaced by this commit use 4-byte integers for their
    variables used in input of my_log2().  Hence, the limit against
    too-large inputs does not really apply.  Thresholds are also applied, as
    of:
    - In nodeAgg.c, the number of partitions is limited by
    HASHAGG_MAX_PARTITIONS.
    - In nodeHash.c, ExecChooseHashTableSize() caps its maximum number of
    buckets based on HashJoinTuple and palloc() allocation limit.
    - In worker.c, the number of subxacts tracked by ApplySubXactData uses
    uint32, making pg_ceil_log2_64() safe to use directly.
    
    Several approaches have been discussed, like an integration with
    thresholds in pg_bitutils.h, but it was found confusing.  This uses
    Dean's idea, which gives a simpler result than what I came up with to be
    able to remove dynahash.h.  dynahash.h will be removed in a follow-up
    commit, removing some duplication with the ceil log2 routines.
    
    Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
    Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
    Discussion: https://postgr.es/m/CAEZATCUJPQD_7sC-wErak2CQGNa6bj2hY-mr8wsBki=kX7f2_A@mail.gmail.com
    michaelpq committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    b118726 View commit details
    Browse the repository at this point in the history
  2. Remove dynahash.h

    All the callers of my_log2() are now limited inside dynahash.c, so let's
    remove this header.  The same capability is provided by pg_bitutils.h
    already.
    
    Discussion: https://postgr.es/m/CAEZATCUJPQD_7sC-wErak2CQGNa6bj2hY-mr8wsBki=kX7f2_A@mail.gmail.com
    michaelpq committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    e6da68a View commit details
    Browse the repository at this point in the history
  3. Fix CREATE TABLE LIKE with not-valid check constraint

    In CREATE TABLE ... LIKE, any check constraints copied from the source
    table should be set to valid if they are ENFORCED (the default).
    
    Bug introduced in commit ca87c41.
    
    Author: jian he <jian.universality@gmail.com>
    Discussion: https://www.postgresql.org/message-id/CACJufxH%3D%2Bod8Wy0P4L3_GpapNwLUP3oAes5UFRJ7yTxrM_M5kg%40mail.gmail.com
    petere committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    33eec80 View commit details
    Browse the repository at this point in the history
  4. meson: Build numeric.c with -ftree-vectorize.

    autoconf builds have compiled this file with -ftree-vectorize since
    commit 8870917, but meson builds seem to have missed the memo.
    
    Reviewed-by: Jeff Davis <pgsql@j-davis.com>
    Discussion: https://postgr.es/m/aL85CeasM51-0D1h%40nathan
    Backpatch-through: 16
    nathan-bossart committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    9016fa7 View commit details
    Browse the repository at this point in the history
  5. Fix memory leakage in nodeSubplan.c.

    If the hash functions used for hashing tuples leaked any memory,
    we failed to clean that up, resulting in query-lifespan memory
    leakage in queries using hashed subplans.  One way that could
    happen is if the values being hashed require de-toasting, since
    most of our hash functions don't trouble to clean up de-toasted
    inputs.
    
    Prior to commit bf6c614, this leakage was largely masked
    because TupleHashTableMatch would reset hashtable->tempcxt
    (via execTuplesMatch).  But it doesn't do that anymore, and
    that's not really the right place for this anyway: doing it
    there could reset the tempcxt many times per hash lookup,
    or not at all.  Instead put reset calls into ExecHashSubPlan
    and buildSubPlanHash.  Along the way to that, rearrange
    ExecHashSubPlan so that there's just one place to call
    MemoryContextReset instead of several.
    
    This amounts to accepting the de-facto API spec that the caller
    of the TupleHashTable routines is responsible for resetting the
    tempcxt adequately often.  Although the other callers seem to
    get this right, it was not documented anywhere, so add a comment
    about it.
    
    Bug: #19040
    Reported-by: Haiyang Li <mohen.lhy@alibaba-inc.com>
    Author: Haiyang Li <mohen.lhy@alibaba-inc.com>
    Reviewed-by: Fei Changhong <feichanghong@qq.com>
    Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://postgr.es/m/19040-c9b6073ef814f48c@postgresql.org
    Backpatch-through: 13
    tglsfdc committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    abdeacd View commit details
    Browse the repository at this point in the history
  6. Eliminate duplicative hashtempcxt in nodeSubplan.c.

    Instead of building a separate memory context that's used just
    for running hash functions, make the hash functions run in the
    per-tuple context of the node's innerecontext.  This saves a
    little space at runtime, and it avoids needing to reset two
    contexts instead of one inside buildSubPlanHash's main loop.
    
    This largely reverts commit 133924e.  That's safe to do now
    because bf6c614 decoupled the evaluation context used by
    TupleHashTableMatch from that used for hash function evaluation,
    so that there's no longer a risk of resetting the innerecontext
    too soon.
    
    Per discussion of bug #19040, although this is not directly
    a fix for that.
    
    Author: Tom Lane <tgl@sss.pgh.pa.us>
    Reviewed-by: Haiyang Li <mohen.lhy@alibaba-inc.com>
    Reviewed-by: Fei Changhong <feichanghong@qq.com>
    Discussion: https://postgr.es/m/19040-c9b6073ef814f48c@postgresql.org
    tglsfdc committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    bdc6cfc View commit details
    Browse the repository at this point in the history
  7. Avoid faulty alignment of Datums in build_sorted_items().

    If sizeof(Pointer) is 4 then sizeof(SortItem) will be 12, so that
    if data->numrows is odd then we placed the values array at a location
    that's not a multiple of 8.  That was fine when sizeof(Datum) was also
    4, but in the wake of commit 2a600a9 it makes some alignment-picky
    machines unhappy.  (You need a 32-bit machine that nonetheless expects
    8-byte alignment of 8-byte quantities, which is an odd-seeming
    combination but it does exist outside the Intel universe.)
    
    To fix, MAXALIGN the space allocated to the SortItem array.
    In passing, let's make the "len" variable be Size not int,
    just for paranoia's sake.
    
    This code was arguably not too safe even before 2a600a9, but at
    present I don't see a strong argument for back-patching.
    
    Reported-by: Tomas Vondra <tomas@vondra.me>
    Author: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://postgr.es/m/87036018-8d70-40ad-a0ac-192b07bd7b04@vondra.me
    tglsfdc committed Sep 10, 2025
    Configuration menu
    Copy the full SHA
    09036dc View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2025

  1. Fix incorrect file reference in guc.h

    GucSource_Names was documented as being in guc.c, but since 0a20ff5
    it is located in guc_tables.c.  The reference to the location of
    GucSource_Names is important, as GucSource needs to be kept in sync with
    GucSource_Names.
    
    Author: David G. Johnston <david.g.johnston@gmail.com>
    Discussion: https://postgr.es/m/CAKFQuwYPgAHWPYjPzK7iXzhSZ6MKR8w20_Nz7ZXpOvx=kZbs7A@mail.gmail.com
    Backpatch-through: 16
    michaelpq committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    c88ce73 View commit details
    Browse the repository at this point in the history
  2. Fix description of WAL record blocks in hash_xlog.h

    hash_xlog.h included descriptions for the blocks used in WAL records
    that were was not completely consistent with how the records are
    generated, with one block missing for SQUEEZE_PAGE, and inconsistent
    descriptions used for block 0 in VACUUM_ONE_PAGE and MOVE_PAGE_CONTENTS.
    
    This information was incorrect since c11453c, cross-checking the
    logic for the record generation.
    
    Author: Kirill Reshke <reshkekirill@gmail.com>
    Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
    Discussion: https://postgr.es/m/CALdSSPj1j=a1d1hVA3oabRFz0hSU3KKrYtZPijw4UPUM7LY9zw@mail.gmail.com
    Backpatch-through: 13
    michaelpq committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    26eadf4 View commit details
    Browse the repository at this point in the history
  3. doc: Improve description of new random(min, max) functions.

    Mention that the new variants of random(min, max) are affected by
    setseed(), like the original functions.
    
    Reported-by: Marcos Pegoraro <marcos@f10.com.br>
    Discussion: https://postgr.es/m/CAB-JLwb1=drA3Le6uZXDBi_tCpeS1qm6XQU7dKwac_x91Z4qDg@mail.gmail.com
    deanrasheed committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    9c24111 View commit details
    Browse the repository at this point in the history
  4. doc: Fix indentation in func-datetime.sgml.

    Incorrect indentation introduced by commit faf071b.
    deanrasheed committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    2bbbb2e View commit details
    Browse the repository at this point in the history
  5. Fix intermittent test failure introduced in 6456c6e.

    The test assumes that a backend will execute COMMIT PREPARED on the
    publisher and hit the injection point commit-after-delay-checkpoint within
    the commit critical section. This should cause the apply worker on the
    subscriber to wait for the transaction to complete.
    
    However, the test does not guarantee that the injection point is actually
    triggered, creating a race condition where the apply worker may proceed
    prematurely during COMMIT PREPARED.
    
    This commit resolves the issue by explicitly waiting for the injection
    point to be hit before continuing with the test, ensuring consistent and
    reliable behavior.
    
    Author: Zhijie Hou <houzj.fnst@fujitsu.com>
    Reviewed-by: shveta malik <shveta.malik@gmail.com>
    Discussion: https://postgr.es/m/TY4PR01MB1690751D1CA8C128B0770EC6F9409A@TY4PR01MB16907.jpnprd01.prod.outlook.com
    Amit Kapila committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    01d7936 View commit details
    Browse the repository at this point in the history
  6. Remove stray semicolon at global scope

    The Sun Studio compiler complains about an empty declaration here.
    
    Note for future historians:  This does not mean that this compiler is
    still of current interest for anyone using PostgreSQL.  But we can let
    this small fix be its parting gift.
    
    Reviewed-by: Andres Freund <andres@anarazel.de>
    Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org
    petere committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    368c38d View commit details
    Browse the repository at this point in the history
  7. Remove checks for no longer supported GCC versions

    Since commit f5e0186 (Raise C requirement to C11), we effectively
    require at least GCC version 4.7, so checks for older versions can be
    removed.
    
    Reviewed-by: Andres Freund <andres@anarazel.de>
    Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org
    petere committed Sep 11, 2025
    Configuration menu
    Copy the full SHA
    4fbe015 View commit details
    Browse the repository at this point in the history
Loading