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: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5166~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5166
Choose a head ref
  • 4 commits
  • 18 files changed
  • 3 contributors

Commits on Mar 24, 2025

  1. Tidy up locale thread safety in ECPG library.

    Remove setlocale() and _configthreadlocal() as fallback strategy on
    systems that don't have uselocale(), where ECPG tries to control
    LC_NUMERIC formatting on input and output of floating point numbers.  It
    was probably broken on some systems (NetBSD), and the code was also
    quite messy and complicated, with obsolete configure tests (Windows).
    It was also arguably broken, or at least had unstated environmental
    requirements, if pgtypeslib code was called directly.
    
    Instead, introduce PG_C_LOCALE to refer to the "C" locale as a locale_t
    value.  It maps to the special constant LC_C_LOCALE when defined by libc
    (macOS, NetBSD), or otherwise uses a process-lifetime locale_t that is
    allocated on first use, just as ECPG previously did itself.  The new
    replacement might be more widely useful.  Then change the float parsing
    and printing code to pass that to _l() functions where appropriate.
    
    Unfortunately the portability of those functions is a bit complicated.
    First, many obvious and useful _l() functions are missing from POSIX,
    though most standard libraries define some of them anyway.  Second,
    although the thread-safe save/restore technique can be used to replace
    the missing ones, Windows and NetBSD refused to implement standard
    uselocale().  They might have a point: "wide scope" uselocale() is hard
    to combine with other code and error-prone, especially in library code.
    Luckily they have the  _l() functions we want so far anyway.  So we have
    to be prepared for both ways of doing things:
    
    1.  In ECPG, use strtod_l() for parsing, and supply a port.h replacement
    using uselocale() over a limited scope if missing.
    
    2.  Inside our own snprintf.c, use three different approaches to format
    floats.  For frontend code, call libc's snprintf_l(), or wrap libc's
    snprintf() in uselocale() if it's missing.  For backend code, snprintf.c
    can keep assuming that the global locale's LC_NUMERIC is "C" and call
    libc's snprintf() without change, for now.
    
    (It might eventually be possible to call our in-tree Ryū routines to
    display floats in snprintf.c, given the C-locale-always remit of our
    in-tree snprintf(), but this patch doesn't risk changing anything that
    complicated.)
    
    Reviewed-by: Peter Eisentraut <[email protected]>
    Reviewed-by: Tristan Partin <[email protected]>
    Discussion: https://postgr.es/m/CWZBBRR6YA8D.8EHMDRGLCKCD%40neon.tech
    macdice authored and Commitfest Bot committed Mar 24, 2025
    Configuration menu
    Copy the full SHA
    586fdb0 View commit details
    Browse the repository at this point in the history
  2. Fixup: fix compiler warnings if LC_C_LOCALE exists

    petere authored and Commitfest Bot committed Mar 24, 2025
    Configuration menu
    Copy the full SHA
    ba9377e View commit details
    Browse the repository at this point in the history
  3. Fixup: sort some lists better

    petere authored and Commitfest Bot committed Mar 24, 2025
    Configuration menu
    Copy the full SHA
    7dadc4e View commit details
    Browse the repository at this point in the history
  4. [CF 5166] v7 - Make ECPG locale usage thread-safe

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/5166
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/[email protected]
    Author(s): Thomas Munro
    Commitfest Bot committed Mar 24, 2025
    Configuration menu
    Copy the full SHA
    ec3b438 View commit details
    Browse the repository at this point in the history
Loading