aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2019-09-03 11:59:36 +0200
committerPeter Eisentraut <peter@eisentraut.org>2019-09-03 11:59:36 +0200
commitbde8c2d319ab3ebaf9f07e5511e1142a38bab0e0 (patch)
tree1348851347a0644295b41bd423dcb505fd4f125e
parent1d7a6e3eb45946db86d6d1776c55323740d955b0 (diff)
downloadpostgresql-bde8c2d319ab3ebaf9f07e5511e1142a38bab0e0.tar.gz
postgresql-bde8c2d319ab3ebaf9f07e5511e1142a38bab0e0.zip
Improve base backup protocol documentation
Document that the tablespace sizes are in units of kilobytes. Make the pg_basebackup source code a bit clearer about this, too. Reviewed-by: Magnus Hagander <magnus@hagander.net>
-rw-r--r--doc/src/sgml/protocol.sgml4
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c14
2 files changed, 9 insertions, 9 deletions
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index b20f1690a7e..f036d5f178b 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -2615,8 +2615,8 @@ The commands accepted in replication mode are:
<term><literal>size</literal> (<type>int8</type>)</term>
<listitem>
<para>
- The approximate size of the tablespace, if progress report has
- been requested; otherwise it's null.
+ The approximate size of the tablespace, in kilobytes (1024 bytes),
+ if progress report has been requested; otherwise it's null.
</para>
</listitem>
</varlistentry>
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 9207109ba3b..498754eb32b 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -115,7 +115,7 @@ static bool made_tablespace_dirs = false;
static bool found_tablespace_dirs = false;
/* Progress counters */
-static uint64 totalsize;
+static uint64 totalsize_kb;
static uint64 totaldone;
static int tablespacecount;
@@ -722,7 +722,7 @@ progress_report(int tablespacenum, const char *filename, bool force)
return; /* Max once per second */
last_progress_report = now;
- percent = totalsize ? (int) ((totaldone / 1024) * 100 / totalsize) : 0;
+ percent = totalsize_kb ? (int) ((totaldone / 1024) * 100 / totalsize_kb) : 0;
/*
* Avoid overflowing past 100% or the full size. This may make the total
@@ -732,8 +732,8 @@ progress_report(int tablespacenum, const char *filename, bool force)
*/
if (percent > 100)
percent = 100;
- if (totaldone / 1024 > totalsize)
- totalsize = totaldone / 1024;
+ if (totaldone / 1024 > totalsize_kb)
+ totalsize_kb = totaldone / 1024;
/*
* Separate step to keep platform-dependent format code out of
@@ -742,7 +742,7 @@ progress_report(int tablespacenum, const char *filename, bool force)
*/
snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT,
totaldone / 1024);
- snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize);
+ snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize_kb);
#define VERBOSE_FILENAME_LENGTH 35
if (verbose)
@@ -1942,11 +1942,11 @@ BaseBackup(void)
/*
* Sum up the total size, for progress reporting
*/
- totalsize = totaldone = 0;
+ totalsize_kb = totaldone = 0;
tablespacecount = PQntuples(res);
for (i = 0; i < PQntuples(res); i++)
{
- totalsize += atol(PQgetvalue(res, i, 2));
+ totalsize_kb += atol(PQgetvalue(res, i, 2));
/*
* Verify tablespace directories are empty. Don't bother with the