From de79299c78f896ea8508a11f9412df57bda88c99 Mon Sep 17 00:00:00 2001
From: Harrison Booth <harrisontbooth@gmail.com>
Date: Sat, 25 Jul 2026 16:27:15 -0500
Subject: [PATCH] Fix pg_basebackup long-path test on Windows

On Windows, the test creates a junction from the short system temporary
directory to the build-tree temporary directory.  Create the long-named
tablespace directory through the short side of that junction.  Otherwise,
mkdir can exceed Windows' legacy directory path limit and silently fail,
causing the later CREATE TABLESPACE command to report a missing directory.

Check mkdir's result so any future setup failure is reported at its source.
---
 src/bin/pg_basebackup/t/010_pg_basebackup.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index cfcfdb8b580..78b4ebab134 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -597,7 +597,8 @@ ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
 $node->safe_psql('postgres', "DROP TABLESPACE tblspc2;");
 rmtree("$tempdir/backup3");
 
-mkdir "$tempdir/$superlongname";
+mkdir "$real_sys_tempdir/$superlongname"
+  or BAIL_OUT "could not create $real_sys_tempdir/$superlongname";
 $realTsDir = "$real_sys_tempdir/$superlongname";
 $node->safe_psql('postgres',
 	"CREATE TABLESPACE tblspc3 LOCATION '$realTsDir';");
-- 
2.53.0.windows.2

