MCPcopy Create free account
hub / github.com/apache/cloudberry / progress_report

Function progress_report

src/bin/pg_basebackup/pg_basebackup.c:803–892  ·  view source on GitHub ↗

* Print a progress report based on the global variables. If verbose output * is enabled, also print the current file name. * * Progress report is written at maximum once per second, unless the force * parameter is set to true. * * If finished is set to true, this is the last progress report. The cursor * is moved to the next line. */

Source from the content-addressed store, hash-verified

801 * is moved to the next line.
802 */
803static void
804progress_report(int tablespacenum, const char *filename,
805 bool force, bool finished)
806{
807 int percent;
808 char totaldone_str[32];
809 char totalsize_str[32];
810 pg_time_t now;
811
812 if (!showprogress)
813 return;
814
815 now = time(NULL);
816 if (now == last_progress_report && !force && !finished)
817 return; /* Max once per second */
818
819 last_progress_report = now;
820 percent = totalsize_kb ? (int) ((totaldone / 1024) * 100 / totalsize_kb) : 0;
821
822 /*
823 * Avoid overflowing past 100% or the full size. This may make the total
824 * size number change as we approach the end of the backup (the estimate
825 * will always be wrong if WAL is included), but that's better than having
826 * the done column be bigger than the total.
827 */
828 if (percent > 100)
829 percent = 100;
830 if (totaldone / 1024 > totalsize_kb)
831 totalsize_kb = totaldone / 1024;
832
833 /*
834 * Separate step to keep platform-dependent format code out of
835 * translatable strings. And we only test for INT64_FORMAT availability
836 * in snprintf, not fprintf.
837 */
838 snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT,
839 totaldone / 1024);
840 snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize_kb);
841
842#define VERBOSE_FILENAME_LENGTH 35
843 if (verbose)
844 {
845 if (!filename)
846
847 /*
848 * No filename given, so clear the status line (used for last
849 * call)
850 */
851 fprintf(stderr,
852 ngettext("%*s/%s kB (100%%), %d/%d tablespace %*s",
853 "%*s/%s kB (100%%), %d/%d tablespaces %*s",
854 tablespacecount),
855 (int) strlen(totalsize_str),
856 totaldone_str, totalsize_str,
857 tablespacenum, tablespacecount,
858 VERBOSE_FILENAME_LENGTH + 5, "");
859 else
860 {

Callers 5

ReceiveTarFileFunction · 0.70
ReceiveTarCopyChunkFunction · 0.70
ReceiveAndUnpackTarFileFunction · 0.70
BaseBackupFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected