|
4 | 4 | use Config;
|
5 | 5 | use PostgresNode;
|
6 | 6 | use TestLib;
|
7 |
| -use Test::More tests => 79; |
| 7 | +use Test::More tests => 87; |
8 | 8 |
|
9 | 9 | program_help_ok('pg_basebackup');
|
10 | 10 | program_version_ok('pg_basebackup');
|
|
66 | 66 | # positive.
|
67 | 67 | $node->safe_psql('postgres', 'SELECT 1;');
|
68 | 68 |
|
| 69 | +# Create an unlogged table to test that forks other than init are not copied. |
| 70 | +$node->safe_psql('postgres', 'CREATE UNLOGGED TABLE base_unlogged (id int)'); |
| 71 | + |
| 72 | +my $baseUnloggedPath = $node->safe_psql('postgres', |
| 73 | + q{select pg_relation_filepath('base_unlogged')}); |
| 74 | + |
| 75 | +# Make sure main and init forks exist |
| 76 | +ok(-f "$pgdata/${baseUnloggedPath}_init", 'unlogged init fork in base'); |
| 77 | +ok(-f "$pgdata/$baseUnloggedPath", 'unlogged main fork in base'); |
| 78 | + |
69 | 79 | $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backup", '-X', 'none' ],
|
70 | 80 | 'pg_basebackup runs');
|
71 | 81 | ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
|
|
96 | 106 | ok(!-f "$tempdir/backup/$filename", "$filename not copied");
|
97 | 107 | }
|
98 | 108 |
|
| 109 | +# Unlogged relation forks other than init should not be copied |
| 110 | +ok(-f "$tempdir/backup/${baseUnloggedPath}_init", |
| 111 | + 'unlogged init fork in backup'); |
| 112 | +ok(!-f "$tempdir/backup/$baseUnloggedPath", |
| 113 | + 'unlogged main fork not in backup'); |
| 114 | + |
99 | 115 | # Make sure existing backup_label was ignored.
|
100 | 116 | isnt(slurp_file("$tempdir/backup/backup_label"),
|
101 | 117 | 'DONOTCOPY', 'existing backup_label not copied');
|
|
147 | 163 | # skip on Windows.
|
148 | 164 | SKIP:
|
149 | 165 | {
|
150 |
| - skip "symlinks not supported on Windows", 11 if ($windows_os); |
| 166 | + skip "symlinks not supported on Windows", 15 if ($windows_os); |
151 | 167 |
|
152 | 168 | # Move pg_replslot out of $pgdata and create a symlink to it.
|
153 | 169 | $node->stop;
|
|
177 | 193 | my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar";
|
178 | 194 | is(scalar(@tblspc_tars), 1, 'one tablespace tar was created');
|
179 | 195 |
|
| 196 | + # Create an unlogged table to test that forks other than init are not copied. |
| 197 | + $node->safe_psql('postgres', |
| 198 | + 'CREATE UNLOGGED TABLE tblspc1_unlogged (id int) TABLESPACE tblspc1;'); |
| 199 | + |
| 200 | + my $tblspc1UnloggedPath = $node->safe_psql( |
| 201 | + 'postgres', q{select pg_relation_filepath('tblspc1_unlogged')}); |
| 202 | + |
| 203 | + # Make sure main and init forks exist |
| 204 | + ok(-f "$pgdata/${tblspc1UnloggedPath}_init", |
| 205 | + 'unlogged init fork in tablespace'); |
| 206 | + ok(-f "$pgdata/$tblspc1UnloggedPath", |
| 207 | + 'unlogged main fork in tablespace'); |
| 208 | + |
180 | 209 | $node->command_fails(
|
181 | 210 | [ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ],
|
182 | 211 | 'plain format with tablespaces fails without tablespace mapping');
|
|
195 | 224 | "tablespace symlink was updated");
|
196 | 225 | closedir $dh;
|
197 | 226 |
|
| 227 | + # Unlogged relation forks other than init should not be copied |
| 228 | + my ($tblspc1UnloggedBackupPath) = $tblspc1UnloggedPath =~ /[^\/]*\/[^\/]*\/[^\/]*$/g; |
| 229 | + |
| 230 | + ok(-f "$tempdir/tbackup/tblspc1/${tblspc1UnloggedBackupPath}_init", |
| 231 | + 'unlogged init fork in tablespace backup'); |
| 232 | + ok(!-f "$tempdir/tbackup/tblspc1/$tblspc1UnloggedBackupPath", |
| 233 | + 'unlogged main fork not in tablespace backup'); |
| 234 | + |
198 | 235 | ok( -d "$tempdir/backup1/pg_replslot",
|
199 | 236 | 'pg_replslot symlink copied as directory');
|
200 | 237 |
|
201 | 238 | mkdir "$tempdir/tbl=spc2";
|
202 | 239 | $node->safe_psql('postgres', "DROP TABLE test1;");
|
| 240 | + $node->safe_psql('postgres', "DROP TABLE tblspc1_unlogged;"); |
203 | 241 | $node->safe_psql('postgres', "DROP TABLESPACE tblspc1;");
|
204 | 242 | $node->safe_psql('postgres',
|
205 | 243 | "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';");
|
|
0 commit comments