1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

In pg_upgrade, add various logging improvements:

add ability to control permissions of created files
	have psql echo its queries for easier debugging
	output four separate log files, and delete them on success
	add -r/--retain option to keep log files after success
	make logs file append-only
	remove -g/-G/-l logging options
	sugggest tailing appropriate log file on failure
	enhance -v/--verbose behavior
This commit is contained in:
Bruce Momjian
2012-03-12 19:47:54 -04:00
parent b4af1c25bb
commit 717f6d6085
16 changed files with 257 additions and 234 deletions

View File

@ -165,12 +165,13 @@ issue_warnings(char *sequence_script_file_name)
if (sequence_script_file_name)
{
prep_status("Adjusting sequences");
exec_prog(true,
SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on "
exec_prog(true, true, UTILITY_LOG_FILE,
SYSTEMQUOTE "\"%s/psql\" --echo-queries "
"--set ON_ERROR_STOP=on "
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
"-f \"%s\" --dbname template1 >> \"%s\" 2>&1" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user,
sequence_script_file_name, log_opts.filename2);
sequence_script_file_name, UTILITY_LOG_FILE);
unlink(sequence_script_file_name);
check_ok();
}
@ -393,10 +394,10 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
prep_status("Creating script to delete old cluster");
snprintf(*deletion_script_file_name, MAXPGPATH, "%s/delete_old_cluster.%s",
os_info.cwd, SCRIPT_EXT);
snprintf(*deletion_script_file_name, MAXPGPATH, "delete_old_cluster.%s",
SCRIPT_EXT);
if ((script = fopen(*deletion_script_file_name, "w")) == NULL)
if ((script = fopen_priv(*deletion_script_file_name, "w")) == NULL)
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
*deletion_script_file_name, getErrorText(errno));
@ -541,8 +542,8 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
return;
}
snprintf(output_path, sizeof(output_path), "%s/contrib_isn_and_int8_pass_by_value.txt",
os_info.cwd);
snprintf(output_path, sizeof(output_path),
"contrib_isn_and_int8_pass_by_value.txt");
for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
{
@ -569,7 +570,7 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
for (rowno = 0; rowno < ntups; rowno++)
{
found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
output_path, getErrorText(errno));
if (!db_used)
@ -628,8 +629,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
prep_status("Checking for reg* system OID user data types");
snprintf(output_path, sizeof(output_path), "%s/tables_using_reg.txt",
os_info.cwd);
snprintf(output_path, sizeof(output_path), "tables_using_reg.txt");
for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
{
@ -675,7 +675,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
for (rowno = 0; rowno < ntups; rowno++)
{
found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
output_path, getErrorText(errno));
if (!db_used)