mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	pg_basebackup: Fix progress messages when writing to a file
The progress messages print out \r to keep overwriting the same line on the screen. But this does not yield useful results when writing the output to a file. So in that case, print out \n instead. Author: Martín Marqués <martin@2ndquadrant.com> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
This commit is contained in:
		@@ -811,7 +811,10 @@ progress_report(int tablespacenum, const char *filename, bool force)
 | 
				
			|||||||
				totaldone_str, totalsize_str, percent,
 | 
									totaldone_str, totalsize_str, percent,
 | 
				
			||||||
				tablespacenum, tablespacecount);
 | 
									tablespacenum, tablespacecount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (isatty(fileno(stderr)))
 | 
				
			||||||
		fprintf(stderr, "\r");
 | 
							fprintf(stderr, "\r");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							fprintf(stderr, "\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int32
 | 
					static int32
 | 
				
			||||||
@@ -1796,7 +1799,13 @@ BaseBackup(void)
 | 
				
			|||||||
				progname);
 | 
									progname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (showprogress && !verbose)
 | 
						if (showprogress && !verbose)
 | 
				
			||||||
		fprintf(stderr, "waiting for checkpoint\r");
 | 
						{
 | 
				
			||||||
 | 
							fprintf(stderr, "waiting for checkpoint");
 | 
				
			||||||
 | 
							if (isatty(fileno(stderr)))
 | 
				
			||||||
 | 
								fprintf(stderr, "\r");
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								fprintf(stderr, "\n");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	basebkp =
 | 
						basebkp =
 | 
				
			||||||
		psprintf("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s",
 | 
							psprintf("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s",
 | 
				
			||||||
@@ -1929,6 +1938,7 @@ BaseBackup(void)
 | 
				
			|||||||
	if (showprogress)
 | 
						if (showprogress)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		progress_report(PQntuples(res), NULL, true);
 | 
							progress_report(PQntuples(res), NULL, true);
 | 
				
			||||||
 | 
							if (isatty(fileno(stderr)))
 | 
				
			||||||
			fprintf(stderr, "\n");	/* Need to move to next line */
 | 
								fprintf(stderr, "\n");	/* Need to move to next line */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user