[PATCH v1] Fix pg_basebackup long-path test on Windows

Started by Harrison Booth4 months ago4 messageshackers
Jump to latest
#1Harrison Booth
harrisontbooth@gmail.com

PostgreSQL's pg_basebackup TAP test creates a junction from the short
system temporary directory to the build-tree temporary directory on
Windows. It then creates $superlongname through the build-tree side.

On my build, that target path was 253 characters. Perl's mkdir failed
at Windows' default 248-character directory path limit, but the result
was unchecked. The test then failed later with a misleading
CREATE TABLESPACE "directory does not exist" error.

The attached patch creates the directory through the short side of the
junction and checks the result of mkdir.

I tested current master 38afc3dcb25 with Meson 1.11.2 and MSVC 19.44 on
Windows 11 ARM64:

- Native ARM64: the unpatched isolated test failed; the patched test
passed all 149 subtests.
- x64 cross-build with needs_exe_wrapper=false: the unpatched test
failed; the patched test passed all 149 subtests.

The 2023 discussion below addressed a related pg_basebackup long-file
test. I did not find an existing proposal for this unchecked
long-directory creation.

/messages/by-id/666ac55b-3400-fb2c-2cea-0281bf36a53c@dunslane.net

Best,
Harrison

Attachments:

t253208_1
0001-Fix-pg_basebackup-long-path-test-on-Windows.patchapplication/octet-stream; name=0001-Fix-pg_basebackup-long-path-test-on-Windows.patchDownload+2-2
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Harrison Booth (#1)
Re: [PATCH v1] Fix pg_basebackup long-path test on Windows

On 26 Jul 2026, at 02:02, Harrison Booth <harrisontbooth@gmail.com> wrote:

On my build, that target path was 253 characters. Perl's mkdir failed
at Windows' default 248-character directory path limit, but the result
was unchecked. The test then failed later with a misleading
CREATE TABLESPACE "directory does not exist" error.

-mkdir "$tempdir/$superlongname";
+mkdir "$real_sys_tempdir/$superlongname"
+  or BAIL_OUT "could not create $real_sys_tempdir/$superlongname";

Shouldn't this include $! to give a hint to the user what the error might be?

--
Daniel Gustafsson

#3Harrison Booth
harrisontbooth@gmail.com
In reply to: Daniel Gustafsson (#2)
Re: [PATCH v1] Fix pg_basebackup long-path test on Windows

Daniel,

Thanks for catching. Attached is v2, which adds `$!` to the `BAIL_OUT`
message so a failed directory creation reports the underlying Windows
error.

This does not change the test logic. The v1 results were 149/149
subtests passing on native ARM64 and the x64 cross-build with
`needs_exe_wrapper=false`.

Best,
Harrison

Attachments:

t253208_3
v2-0001-Fix-pg_basebackup-long-path-test-on-Windows.patchtext/x-diff; charset=US-ASCII; name=v2-0001-Fix-pg_basebackup-long-path-test-on-Windows.patchDownload+2-2
#4Harrison Booth
harrisontbooth@gmail.com
In reply to: Harrison Booth (#3)
Re: [PATCH v3] Fix pg_basebackup long-path test on Windows

Attached is v3 rebased on master at 8e82d6610e7. It retains the $!
detail you requested in v2 and creates the directory through the short
side of the Windows junction. There are no further test-logic changes.

Full ARM64 and x64 builds passed. The refreshed pg_basebackup suite
passed all 151 subtests on both native ARM64 and x64 under ARM64
emulation. Both runs emitted directory-cleanup warnings but passed all
assertions.

Could you take another look when you have a chance?

A separate GitHub-hosted Windows x64 build and all nine test groups
passed with all three patches applied. The pg_basebackup suite passed
all 152 subtests on the GitHub Windows x64 runner.

Best,
Harrison

Attachments:

t253208_4
v3-0001-Fix-pg_basebackup-long-path-test-on-Windows.patchtext/x-diff; charset=utf-8; name=v3-0001-Fix-pg_basebackup-long-path-test-on-Windows.patchDownload+2-1