Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
ba98239d
Commit
ba98239d
authored
13 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Simplify pg_upgrade's handling when returning directory listings.
Backpatch to 9.2.
parent
a4a7eb37
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/pg_upgrade/file.c
+8
-17
8 additions, 17 deletions
contrib/pg_upgrade/file.c
contrib/pg_upgrade/pg_upgrade.h
+1
-1
1 addition, 1 deletion
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/relfilenode.c
+8
-8
8 additions, 8 deletions
contrib/pg_upgrade/relfilenode.c
with
17 additions
and
26 deletions
contrib/pg_upgrade/file.c
+
8
−
17
View file @
ba98239d
...
...
@@ -225,23 +225,21 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
* load_directory()
*
* Read all the file names in the specified directory, and return them as
* an array of "
struct dirent
" pointers. The array address is returned in
* an array of "
char *
" pointers. The array address is returned in
* *namelist, and the function result is the count of file names.
*
* To free the result data, free each
namelist
array member, then free the
* To free the result data, free each
(char *)
array member, then free the
* namelist array itself.
*/
int
load_directory
(
const
char
*
dirname
,
struct
dirent
***
namelist
)
load_directory
(
const
char
*
dirname
,
char
***
namelist
)
{
DIR
*
dirdesc
;
struct
dirent
*
direntry
;
int
count
=
0
;
int
allocsize
=
64
;
size_t
entrysize
;
int
allocsize
=
64
;
/* initial array size */
*
namelist
=
(
struct
dirent
**
)
pg_malloc
(
allocsize
*
sizeof
(
struct
dirent
*
));
*
namelist
=
(
char
**
)
pg_malloc
(
allocsize
*
sizeof
(
char
*
));
if
((
dirdesc
=
opendir
(
dirname
))
==
NULL
)
pg_log
(
PG_FATAL
,
"could not open directory
\"
%s
\"
: %s
\n
"
,
...
...
@@ -252,18 +250,11 @@ load_directory(const char *dirname, struct dirent *** namelist)
if
(
count
>=
allocsize
)
{
allocsize
*=
2
;
*
namelist
=
(
struct
dirent
**
)
pg_realloc
(
*
namelist
,
allocsize
*
sizeof
(
struct
dirent
*
));
*
namelist
=
(
char
**
)
pg_realloc
(
*
namelist
,
allocsize
*
sizeof
(
char
*
));
}
entrysize
=
offsetof
(
struct
dirent
,
d_name
)
+
strlen
(
direntry
->
d_name
)
+
1
;
(
*
namelist
)[
count
]
=
(
struct
dirent
*
)
pg_malloc
(
entrysize
);
memcpy
((
*
namelist
)[
count
],
direntry
,
entrysize
);
count
++
;
(
*
namelist
)[
count
++
]
=
pg_strdup
(
direntry
->
d_name
);
}
#ifdef WIN32
...
...
This diff is collapsed.
Click to expand it.
contrib/pg_upgrade/pg_upgrade.h
+
1
−
1
View file @
ba98239d
...
...
@@ -357,7 +357,7 @@ const char *setupPageConverter(pageCnvCtx **result);
typedef
void
*
pageCnvCtx
;
#endif
int
load_directory
(
const
char
*
dirname
,
struct
dirent
***
namelist
);
int
load_directory
(
const
char
*
dirname
,
char
***
namelist
);
const
char
*
copyAndUpdateFile
(
pageCnvCtx
*
pageConverter
,
const
char
*
src
,
const
char
*
dst
,
bool
force
);
const
char
*
linkAndUpdateFile
(
pageCnvCtx
*
pageConverter
,
const
char
*
src
,
...
...
This diff is collapsed.
Click to expand it.
contrib/pg_upgrade/relfilenode.c
+
8
−
8
View file @
ba98239d
...
...
@@ -133,7 +133,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
{
char
old_dir
[
MAXPGPATH
];
char
file_pattern
[
MAXPGPATH
];
struct
dirent
**
namelist
=
NULL
;
char
**
namelist
=
NULL
;
int
numFiles
=
0
;
int
mapnum
;
int
fileno
;
...
...
@@ -192,21 +192,21 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
for
(
fileno
=
0
;
fileno
<
numFiles
;
fileno
++
)
{
char
*
vm_offset
=
strstr
(
namelist
[
fileno
]
->
d_name
,
"_vm"
);
char
*
vm_offset
=
strstr
(
namelist
[
fileno
],
"_vm"
);
bool
is_vm_file
=
false
;
/* Is a visibility map file? (name ends with _vm) */
if
(
vm_offset
&&
strlen
(
vm_offset
)
==
strlen
(
"_vm"
))
is_vm_file
=
true
;
if
(
strncmp
(
namelist
[
fileno
]
->
d_name
,
file_pattern
,
if
(
strncmp
(
namelist
[
fileno
],
file_pattern
,
strlen
(
file_pattern
))
==
0
&&
(
!
is_vm_file
||
!
vm_crashsafe_change
))
{
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%s"
,
maps
[
mapnum
].
old_dir
,
namelist
[
fileno
]
->
d_name
);
namelist
[
fileno
]);
snprintf
(
new_file
,
sizeof
(
new_file
),
"%s/%u%s"
,
maps
[
mapnum
].
new_dir
,
maps
[
mapnum
].
new_relfilenode
,
strchr
(
namelist
[
fileno
]
->
d_name
,
'_'
));
maps
[
mapnum
].
new_relfilenode
,
strchr
(
namelist
[
fileno
],
'_'
));
unlink
(
new_file
);
transfer_relfile
(
pageConverter
,
old_file
,
new_file
,
...
...
@@ -227,13 +227,13 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
for
(
fileno
=
0
;
fileno
<
numFiles
;
fileno
++
)
{
if
(
strncmp
(
namelist
[
fileno
]
->
d_name
,
file_pattern
,
if
(
strncmp
(
namelist
[
fileno
],
file_pattern
,
strlen
(
file_pattern
))
==
0
)
{
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%s"
,
maps
[
mapnum
].
old_dir
,
namelist
[
fileno
]
->
d_name
);
namelist
[
fileno
]);
snprintf
(
new_file
,
sizeof
(
new_file
),
"%s/%u%s"
,
maps
[
mapnum
].
new_dir
,
maps
[
mapnum
].
new_relfilenode
,
strchr
(
namelist
[
fileno
]
->
d_name
,
'.'
));
maps
[
mapnum
].
new_relfilenode
,
strchr
(
namelist
[
fileno
],
'.'
));
unlink
(
new_file
);
transfer_relfile
(
pageConverter
,
old_file
,
new_file
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment