Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
005e5c30
Commit
005e5c30
authored
Aug 16, 2011
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use less cryptic variable names
parent
2411fbda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
37 deletions
+37
-37
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_basebackup.c
+37
-37
No files found.
src/bin/pg_basebackup/pg_basebackup.c
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
(
fn
),
"%s/base.tar.gz"
,
basedir
);
ztarfile
=
gzopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
filename
),
"%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
(
fn
),
"%s/base.tar"
,
basedir
);
tarfile
=
fopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
filename
),
"%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
(
fn
),
"%s/%s.tar.gz"
,
basedir
,
PQgetvalue
(
res
,
rownum
,
0
));
ztarfile
=
gzopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
filename
),
"%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
(
fn
),
"%s/%s.tar"
,
basedir
,
PQgetvalue
(
res
,
rownum
,
0
));
tarfile
=
fopen
(
f
n
,
"wb"
);
snprintf
(
f
ilename
,
sizeof
(
filename
),
"%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
(
fn
),
"%s/%s"
,
current_path
,
copybuf
);
if
(
f
n
[
strlen
(
fn
)
-
1
]
==
'/'
)
snprintf
(
f
ilename
,
sizeof
(
filename
),
"%s/%s"
,
current_path
,
copybuf
);
if
(
f
ilename
[
strlen
(
filename
)
-
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
(
fn
)
-
1
]
=
'\0'
;
/* Remove trailing slash */
if
(
mkdir
(
f
n
,
S_IRWXU
)
!=
0
)
f
ilename
[
strlen
(
filename
)
-
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
(
fn
)
-
1
]
=
'\0'
;
/* Remove trailing slash */
if
(
symlink
(
&
copybuf
[
157
],
f
n
)
!=
0
)
f
ilename
[
strlen
(
filename
)
-
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment