[PATCH] Fix Windows pgwin32_fopen update-mode access

From: Harrison Booth <harrisontbooth(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] Fix Windows pgwin32_fopen update-mode access
Date: 2026-10-20 15:37:00
Message-ID: CAAH-eSU8YAvbPBeMiATC14GMm7G-eRPM_phdg9+AQ0wrT6CdUw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Windows, pgwin32_fopen opens rb+/wb+ files without requesting both
read and write access. For a+ files, it requests only write access,
though + should allow reading too. The attached patch handles +
separately and adds a regression test to libpgport.

I built the frontend code against PostgreSQL commit 45fc51f on hosted
Windows x64 and ARM64 runners. On each, all 48 tests of PostgreSQL's
file-opening helper passed, as did all 48 checks using Windows' own
file-opening function and the four registered PostgreSQL test checks.
Using the PostgreSQL 18 version of the helper, 16/48 tests failed,
reproducing the bug. With the patch, all 48 passed. The checks using
Windows' own function also passed all 48 cases.

These tests check the file-opening function directly. They don't cover
a full server or older supported PostgreSQL versions. I haven't found
PostgreSQL code using the specific file modes that exposed the bug.

I added a Windows-only test_pgport module for this regression. Could
you review the patch and let me know if you’d prefer the test in an
existing module? If not, happy to move to the appropriate location.

Best,
Harrison

Attachment Content-Type Size
0001-Fix-Windows-pgwin32_fopen-update-mode-access.patch text/x-patch 10.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2026-10-20 15:57:37 Re: ILIKE '%' never matches a non-ASCII byte in single-byte C-ctype databases
Previous Message Jeff Davis 2026-10-20 15:26:03 Re: [PG19] ILIKE index scan misses rows with a libc UTF-8 collation on macOS