Commit bde8c2d3 authored by Peter Eisentraut's avatar Peter Eisentraut

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: default avatarMagnus Hagander <magnus@hagander.net>
parent 1d7a6e3e
...@@ -2615,8 +2615,8 @@ The commands accepted in replication mode are: ...@@ -2615,8 +2615,8 @@ The commands accepted in replication mode are:
<term><literal>size</literal> (<type>int8</type>)</term> <term><literal>size</literal> (<type>int8</type>)</term>
<listitem> <listitem>
<para> <para>
The approximate size of the tablespace, if progress report has The approximate size of the tablespace, in kilobytes (1024 bytes),
been requested; otherwise it's null. if progress report has been requested; otherwise it's null.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -115,7 +115,7 @@ static bool made_tablespace_dirs = false; ...@@ -115,7 +115,7 @@ static bool made_tablespace_dirs = false;
static bool found_tablespace_dirs = false; static bool found_tablespace_dirs = false;
/* Progress counters */ /* Progress counters */
static uint64 totalsize; static uint64 totalsize_kb;
static uint64 totaldone; static uint64 totaldone;
static int tablespacecount; static int tablespacecount;
...@@ -722,7 +722,7 @@ progress_report(int tablespacenum, const char *filename, bool force) ...@@ -722,7 +722,7 @@ progress_report(int tablespacenum, const char *filename, bool force)
return; /* Max once per second */ return; /* Max once per second */
last_progress_report = now; 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 * 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) ...@@ -732,8 +732,8 @@ progress_report(int tablespacenum, const char *filename, bool force)
*/ */
if (percent > 100) if (percent > 100)
percent = 100; percent = 100;
if (totaldone / 1024 > totalsize) if (totaldone / 1024 > totalsize_kb)
totalsize = totaldone / 1024; totalsize_kb = totaldone / 1024;
/* /*
* Separate step to keep platform-dependent format code out of * Separate step to keep platform-dependent format code out of
...@@ -742,7 +742,7 @@ progress_report(int tablespacenum, const char *filename, bool force) ...@@ -742,7 +742,7 @@ progress_report(int tablespacenum, const char *filename, bool force)
*/ */
snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT, snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT,
totaldone / 1024); 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 #define VERBOSE_FILENAME_LENGTH 35
if (verbose) if (verbose)
...@@ -1942,11 +1942,11 @@ BaseBackup(void) ...@@ -1942,11 +1942,11 @@ BaseBackup(void)
/* /*
* Sum up the total size, for progress reporting * Sum up the total size, for progress reporting
*/ */
totalsize = totaldone = 0; totalsize_kb = totaldone = 0;
tablespacecount = PQntuples(res); tablespacecount = PQntuples(res);
for (i = 0; i < PQntuples(res); i++) 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 * Verify tablespace directories are empty. Don't bother with the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment