From 50f90c0b0c1f28cad0f3508bbfb929d37bb7bf76 Mon Sep 17 00:00:00 2001
From: Harrison Booth <harrisontbooth@gmail.com>
Date: Mon, 12 Oct 2026 15:54:31 -0500
Subject: [PATCH v3] Fix pg_basebackup long-path test on Windows

Create the long tablespace directory through the short side of the Windows
junction. Check mkdir and report its underlying error instead of failing
later with a misleading CREATE TABLESPACE error.
---
 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 2442131e179..23a757b1c86 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';");
