Skip to content

Commit faf26bf

Browse files
committed
Get rid of useless global variable in pg_upgrade.
Since the scandir() emulation was taken out of pg_upgrade, there's no longer any need for scandir_file_pattern to exist as a global variable. Replace it with a local in the one remaining function that was making use of it.
1 parent 3d6ec66 commit faf26bf

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ extern UserOpts user_opts;
283283
extern ClusterInfo old_cluster,
284284
new_cluster;
285285
extern OSInfo os_info;
286-
extern char scandir_file_pattern[];
287286

288287

289288
/* check.c */

contrib/pg_upgrade/relfilenode.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ static void transfer_relfile(pageCnvCtx *pageConverter,
2121
const char *fromfile, const char *tofile,
2222
const char *nspname, const char *relname);
2323

24-
/* used by scandir(), must be global */
25-
char scandir_file_pattern[MAXPGPATH];
2624

2725
/*
2826
* transfer_all_new_dbs()
@@ -134,6 +132,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
134132
FileNameMap *maps, int size)
135133
{
136134
char old_dir[MAXPGPATH];
135+
char file_pattern[MAXPGPATH];
137136
struct dirent **namelist = NULL;
138137
int numFiles = 0;
139138
int mapnum;
@@ -175,7 +174,8 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
175174
pg_log(PG_REPORT, OVERWRITE_MESSAGE, old_file);
176175

177176
/*
178-
* Copy/link the relation file to the new cluster
177+
* Copy/link the relation's primary file (segment 0 of main fork)
178+
* to the new cluster
179179
*/
180180
unlink(new_file);
181181
transfer_relfile(pageConverter, old_file, new_file,
@@ -187,7 +187,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
187187
/*
188188
* Copy/link any fsm and vm files, if they exist
189189
*/
190-
snprintf(scandir_file_pattern, sizeof(scandir_file_pattern), "%u_",
190+
snprintf(file_pattern, sizeof(file_pattern), "%u_",
191191
maps[mapnum].old_relfilenode);
192192

193193
for (fileno = 0; fileno < numFiles; fileno++)
@@ -199,8 +199,8 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
199199
if (vm_offset && strlen(vm_offset) == strlen("_vm"))
200200
is_vm_file = true;
201201

202-
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
203-
strlen(scandir_file_pattern)) == 0 &&
202+
if (strncmp(namelist[fileno]->d_name, file_pattern,
203+
strlen(file_pattern)) == 0 &&
204204
(!is_vm_file || !vm_crashsafe_change))
205205
{
206206
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
@@ -222,13 +222,13 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
222222
* relfilenode.3, ... 'fsm' and 'vm' files use underscores so are not
223223
* copied.
224224
*/
225-
snprintf(scandir_file_pattern, sizeof(scandir_file_pattern), "%u.",
225+
snprintf(file_pattern, sizeof(file_pattern), "%u.",
226226
maps[mapnum].old_relfilenode);
227227

228228
for (fileno = 0; fileno < numFiles; fileno++)
229229
{
230-
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
231-
strlen(scandir_file_pattern)) == 0)
230+
if (strncmp(namelist[fileno]->d_name, file_pattern,
231+
strlen(file_pattern)) == 0)
232232
{
233233
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
234234
namelist[fileno]->d_name);
@@ -242,7 +242,6 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
242242
}
243243
}
244244

245-
246245
if (numFiles > 0)
247246
{
248247
for (fileno = 0; fileno < numFiles; fileno++)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy