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
005e5c30
Commit
005e5c30
authored
13 years ago
by
Peter Eisentraut
Browse files
Options
Downloads
Patches
Plain Diff
Use less cryptic variable names
parent
2411fbda
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/pg_basebackup/pg_basebackup.c
+37
-37
37 additions, 37 deletions
src/bin/pg_basebackup/pg_basebackup.c
with
37 additions
and
37 deletions
src/bin/pg_basebackup/pg_basebackup.c
+
37
−
37
View file @
005e5c30
...
...
@@ -59,7 +59,7 @@ static char *xstrdup(const char *s);
static
void
*
xmalloc0
(
int
size
);
static
void
usage
(
void
);
static
void
verify_dir_is_empty_or_create
(
char
*
dirname
);
static
void
progress_report
(
int
tablespacenum
,
c
har
*
fn
);
static
void
progress_report
(
int
tablespacenum
,
c
onst
char
*
filename
);
static
PGconn
*
GetConnection
(
void
);
static
void
ReceiveTarFile
(
PGconn
*
conn
,
PGresult
*
res
,
int
rownum
);
...
...
@@ -201,7 +201,7 @@ verify_dir_is_empty_or_create(char *dirname)
* is enabled, also print the current file name.
*/
static
void
progress_report
(
int
tablespacenum
,
c
har
*
fn
)
progress_report
(
int
tablespacenum
,
c
onst
char
*
filename
)
{
int
percent
=
(
int
)
((
totaldone
/
1024
)
*
100
/
totalsize
);
...
...
@@ -210,7 +210,7 @@ progress_report(int tablespacenum, char *fn)
if
(
verbose
)
{
if
(
!
f
n
)
if
(
!
f
ilename
)
/*
* No filename given, so clear the status line (used for last
...
...
@@ -225,7 +225,7 @@ progress_report(int tablespacenum, char *fn)
INT64_FORMAT
"/"
INT64_FORMAT
" kB (%d%%) %d/%d tablespaces (%-30.30s)
\r
"
,
totaldone
/
1024
,
totalsize
,
percent
,
tablespacenum
,
tablespacecount
,
f
n
);
tablespacenum
,
tablespacecount
,
f
ilename
);
}
else
fprintf
(
stderr
,
INT64_FORMAT
"/"
INT64_FORMAT
" kB (%d%%) %d/%d tablespaces
\r
"
,
...
...
@@ -248,7 +248,7 @@ progress_report(int tablespacenum, char *fn)
static
void
ReceiveTarFile
(
PGconn
*
conn
,
PGresult
*
res
,
int
rownum
)
{
char
f
n
[
MAXPGPATH
];
char
f
ilename
[
MAXPGPATH
];
char
*
copybuf
=
NULL
;
FILE
*
tarfile
=
NULL
;
...
...
@@ -283,8 +283,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
#ifdef HAVE_LIBZ
if
(
compresslevel
!=
0
)
{
snprintf
(
f
n
,
sizeof
(
f
n
),
"%s/base.tar.gz"
,
basedir
);
ztarfile
=
gzopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
f
ilename
),
"%s/base.tar.gz"
,
basedir
);
ztarfile
=
gzopen
(
f
ilename
,
"wb"
);
if
(
gzsetparams
(
ztarfile
,
compresslevel
,
Z_DEFAULT_STRATEGY
)
!=
Z_OK
)
{
fprintf
(
stderr
,
_
(
"%s: could not set compression level %d: %s
\n
"
),
...
...
@@ -295,8 +295,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
else
#endif
{
snprintf
(
f
n
,
sizeof
(
f
n
),
"%s/base.tar"
,
basedir
);
tarfile
=
fopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
f
ilename
),
"%s/base.tar"
,
basedir
);
tarfile
=
fopen
(
f
ilename
,
"wb"
);
}
}
else
...
...
@@ -307,8 +307,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
#ifdef HAVE_LIBZ
if
(
compresslevel
!=
0
)
{
snprintf
(
f
n
,
sizeof
(
f
n
),
"%s/%s.tar.gz"
,
basedir
,
PQgetvalue
(
res
,
rownum
,
0
));
ztarfile
=
gzopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
f
ilename
),
"%s/%s.tar.gz"
,
basedir
,
PQgetvalue
(
res
,
rownum
,
0
));
ztarfile
=
gzopen
(
f
ilename
,
"wb"
);
if
(
gzsetparams
(
ztarfile
,
compresslevel
,
Z_DEFAULT_STRATEGY
)
!=
Z_OK
)
{
fprintf
(
stderr
,
_
(
"%s: could not set compression level %d: %s
\n
"
),
...
...
@@ -319,8 +319,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
else
#endif
{
snprintf
(
f
n
,
sizeof
(
f
n
),
"%s/%s.tar"
,
basedir
,
PQgetvalue
(
res
,
rownum
,
0
));
tarfile
=
fopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
f
ilename
),
"%s/%s.tar"
,
basedir
,
PQgetvalue
(
res
,
rownum
,
0
));
tarfile
=
fopen
(
f
ilename
,
"wb"
);
}
}
...
...
@@ -331,7 +331,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
{
/* Compression is in use */
fprintf
(
stderr
,
_
(
"%s: could not create compressed file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
get_gz_error
(
ztarfile
));
progname
,
f
ilename
,
get_gz_error
(
ztarfile
));
disconnect_and_exit
(
1
);
}
}
...
...
@@ -342,7 +342,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
if
(
!
tarfile
)
{
fprintf
(
stderr
,
_
(
"%s: could not create file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
}
...
...
@@ -386,7 +386,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
if
(
gzwrite
(
ztarfile
,
zerobuf
,
sizeof
(
zerobuf
))
!=
sizeof
(
zerobuf
))
{
fprintf
(
stderr
,
_
(
"%s: could not write to compressed file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
get_gz_error
(
ztarfile
));
progname
,
f
ilename
,
get_gz_error
(
ztarfile
));
}
}
else
...
...
@@ -395,7 +395,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
if
(
fwrite
(
zerobuf
,
sizeof
(
zerobuf
),
1
,
tarfile
)
!=
1
)
{
fprintf
(
stderr
,
_
(
"%s: could not write to file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
}
...
...
@@ -432,7 +432,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
if
(
gzwrite
(
ztarfile
,
copybuf
,
r
)
!=
r
)
{
fprintf
(
stderr
,
_
(
"%s: could not write to compressed file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
get_gz_error
(
ztarfile
));
progname
,
f
ilename
,
get_gz_error
(
ztarfile
));
}
}
else
...
...
@@ -441,13 +441,13 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
if
(
fwrite
(
copybuf
,
r
,
1
,
tarfile
)
!=
1
)
{
fprintf
(
stderr
,
_
(
"%s: could not write to file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
}
totaldone
+=
r
;
if
(
showprogress
)
progress_report
(
rownum
,
f
n
);
progress_report
(
rownum
,
f
ilename
);
}
/* while (1) */
if
(
copybuf
!=
NULL
)
...
...
@@ -468,7 +468,7 @@ static void
ReceiveAndUnpackTarFile
(
PGconn
*
conn
,
PGresult
*
res
,
int
rownum
)
{
char
current_path
[
MAXPGPATH
];
char
f
n
[
MAXPGPATH
];
char
f
ilename
[
MAXPGPATH
];
int
current_len_left
;
int
current_padding
=
0
;
char
*
copybuf
=
NULL
;
...
...
@@ -563,8 +563,8 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
/*
* First part of header is zero terminated filename
*/
snprintf
(
f
n
,
sizeof
(
f
n
),
"%s/%s"
,
current_path
,
copybuf
);
if
(
f
n
[
strlen
(
f
n
)
-
1
]
==
'/'
)
snprintf
(
f
ilename
,
sizeof
(
f
ilename
),
"%s/%s"
,
current_path
,
copybuf
);
if
(
f
ilename
[
strlen
(
f
ilename
)
-
1
]
==
'/'
)
{
/*
* Ends in a slash means directory or symlink to directory
...
...
@@ -574,18 +574,18 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
/*
* Directory
*/
f
n
[
strlen
(
f
n
)
-
1
]
=
'\0'
;
/* Remove trailing slash */
if
(
mkdir
(
f
n
,
S_IRWXU
)
!=
0
)
f
ilename
[
strlen
(
f
ilename
)
-
1
]
=
'\0'
;
/* Remove trailing slash */
if
(
mkdir
(
f
ilename
,
S_IRWXU
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"%s: could not create directory
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
#ifndef WIN32
if
(
chmod
(
f
n
,
(
mode_t
)
filemode
))
if
(
chmod
(
f
ilename
,
(
mode_t
)
filemode
))
fprintf
(
stderr
,
_
(
"%s: could not set permissions on directory
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
#endif
}
else
if
(
copybuf
[
156
]
==
'2'
)
...
...
@@ -593,12 +593,12 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
/*
* Symbolic link
*/
f
n
[
strlen
(
f
n
)
-
1
]
=
'\0'
;
/* Remove trailing slash */
if
(
symlink
(
&
copybuf
[
157
],
f
n
)
!=
0
)
f
ilename
[
strlen
(
f
ilename
)
-
1
]
=
'\0'
;
/* Remove trailing slash */
if
(
symlink
(
&
copybuf
[
157
],
f
ilename
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"%s: could not create symbolic link from
\"
%s
\"
to
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
&
copybuf
[
157
],
strerror
(
errno
));
progname
,
f
ilename
,
&
copybuf
[
157
],
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
}
...
...
@@ -614,18 +614,18 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
/*
* regular file
*/
file
=
fopen
(
f
n
,
"wb"
);
file
=
fopen
(
f
ilename
,
"wb"
);
if
(
!
file
)
{
fprintf
(
stderr
,
_
(
"%s: could not create file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
#ifndef WIN32
if
(
chmod
(
f
n
,
(
mode_t
)
filemode
))
if
(
chmod
(
f
ilename
,
(
mode_t
)
filemode
))
fprintf
(
stderr
,
_
(
"%s: could not set permissions on file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
#endif
if
(
current_len_left
==
0
)
...
...
@@ -658,12 +658,12 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
if
(
fwrite
(
copybuf
,
r
,
1
,
file
)
!=
1
)
{
fprintf
(
stderr
,
_
(
"%s: could not write to file
\"
%s
\"
: %s
\n
"
),
progname
,
f
n
,
strerror
(
errno
));
progname
,
f
ilename
,
strerror
(
errno
));
disconnect_and_exit
(
1
);
}
totaldone
+=
r
;
if
(
showprogress
)
progress_report
(
rownum
,
f
n
);
progress_report
(
rownum
,
f
ilename
);
current_len_left
-=
r
;
if
(
current_len_left
==
0
&&
current_padding
==
0
)
...
...
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