Remove unnecessary Windows-specific basebackup code.
authorThomas Munro <[email protected]>
Fri, 22 Jul 2022 05:37:39 +0000 (17:37 +1200)
committerThomas Munro <[email protected]>
Fri, 22 Jul 2022 05:41:47 +0000 (17:41 +1200)
Commit c6f2f016 added an explicit check for a Windows "junction point".
That turned out to be needed only because get_dirent_type() was busted
on Windows.  It's been fixed by commit 9d3444dc, so remove it.

Add a TAP-test to demonstrate that in-place tablespaces are copied by
pg_basebackup.  This exercises the codepath that would fail before
c6f2f016 on Windows, and shows that it still doesn't fail now that we're
using get_dirent_type() on both Windows and Unix.

Back-patch to 15, where in-place tablespaces arrived and caused this
problem (ie directories where previously only symlinks were expected).

Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGLzLK4PUPx0_AwXEWXOYAejU%3D7XpxnYE55Y%2Be7hB2N3FA%40mail.gmail.com

src/backend/access/transam/xlog.c
src/bin/pg_basebackup/t/010_pg_basebackup.pl

index 1da3b8eb2ea380317c744a43c5715673f5805780..15ab8d90d4b1df407f2fba5259ff26275ab7f011 100644 (file)
@@ -8302,13 +8302,8 @@ do_pg_backup_start(const char *backupidstr, bool fast, TimeLineID *starttli_p,
             * we sometimes use allow_in_place_tablespaces to create
             * directories directly under pg_tblspc, which would fail below.
             */
-#ifdef WIN32
-           if (!pgwin32_is_junction(fullpath))
-               continue;
-#else
            if (get_dirent_type(fullpath, de, false, ERROR) != PGFILETYPE_LNK)
                continue;
-#endif
 
 #if defined(HAVE_READLINK) || defined(WIN32)
            rllen = readlink(fullpath, linkpath, sizeof(linkpath));
index 87a211315f05e38705a92812f46104939e8f975d..3d1a4ddd5c0ecb153af94221268741eaa9721b09 100644 (file)
@@ -904,4 +904,21 @@ ok( pump_until(
    'background process exit message');
 $sigchld_bb->finish();
 
+# Test that we can back up an in-place tablespace
+$node->safe_psql('postgres',
+   "SET allow_in_place_tablespaces = on; CREATE TABLESPACE tblspc2 LOCATION '';");
+$node->safe_psql('postgres',
+       "CREATE TABLE test2 (a int) TABLESPACE tblspc2;"
+     . "INSERT INTO test2 VALUES (1234);");
+my $tblspc_oid = $node->safe_psql('postgres',
+   "SELECT oid FROM pg_tablespace WHERE spcname = 'tblspc2';");
+$node->backup('backup3');
+$node->safe_psql('postgres', "DROP TABLE test2;");
+$node->safe_psql('postgres', "DROP TABLESPACE tblspc2;");
+
+# check that the in-place tablespace exists in the backup
+$backupdir = $node->backup_dir . '/backup3';
+my @dst_tblspc = glob "$backupdir/pg_tblspc/$tblspc_oid/PG_*";
+is(@dst_tblspc, 1, 'tblspc directory copied');
+
 done_testing();