Rename pg_upgrade 'log' to 'log_opts', to avoid platform naming conflict.

This commit is contained in:
Bruce Momjian 2010-10-20 02:31:17 +00:00
parent 3325c9bddb
commit 691a67b922
8 changed files with 48 additions and 48 deletions

View File

@ -160,7 +160,7 @@ issue_warnings(char *sequence_script_file_name)
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user,
sequence_script_file_name, log.filename);
sequence_script_file_name, log_opts.filename);
unlink(sequence_script_file_name);
check_ok();
}

View File

@ -126,8 +126,8 @@ get_control_data(ClusterInfo *cluster, bool live_check)
/* we have the result of cmd in "output". so parse it line by line now */
while (fgets(bufin, sizeof(bufin), output))
{
if (log.debug)
fputs(bufin, log.debug_fd);
if (log_opts.debug)
fputs(bufin, log_opts.debug_fd);
#ifdef WIN32

View File

@ -192,7 +192,7 @@ map_rel_by_id(Oid oldid, Oid newid,
void
print_maps(FileNameMap *maps, int n, const char *dbName)
{
if (log.debug)
if (log_opts.debug)
{
int mapnum;
@ -277,7 +277,7 @@ get_db_and_rel_infos(DbInfoArr *db_arr, Cluster whichCluster)
get_rel_infos(&db_arr->dbs[dbnum],
&db_arr->dbs[dbnum].rel_arr, whichCluster);
if (log.debug)
if (log_opts.debug)
dbarr_print(db_arr, whichCluster);
}

View File

@ -119,11 +119,11 @@ parseCommandLine(int argc, char *argv[])
case 'g':
pg_log(PG_REPORT, "Running in debug mode\n");
log.debug = true;
log_opts.debug = true;
break;
case 'G':
if ((log.debug_fd = fopen(optarg, "w")) == NULL)
if ((log_opts.debug_fd = fopen(optarg, "w")) == NULL)
{
pg_log(PG_FATAL, "cannot open debug file\n");
exit_nicely(false);
@ -135,7 +135,7 @@ parseCommandLine(int argc, char *argv[])
break;
case 'l':
log.filename = pg_strdup(optarg);
log_opts.filename = pg_strdup(optarg);
break;
case 'p':
@ -161,7 +161,7 @@ parseCommandLine(int argc, char *argv[])
case 'v':
pg_log(PG_REPORT, "Running in verbose mode\n");
log.verbose = true;
log_opts.verbose = true;
break;
default:
@ -172,7 +172,7 @@ parseCommandLine(int argc, char *argv[])
}
}
if (log.filename != NULL)
if (log_opts.filename != NULL)
{
/*
* We must use append mode so output generated by child processes via
@ -180,20 +180,20 @@ parseCommandLine(int argc, char *argv[])
* start.
*/
/* truncate */
if ((log.fd = fopen(log.filename, "w")) == NULL)
pg_log(PG_FATAL, "Cannot write to log file %s\n", log.filename);
fclose(log.fd);
if ((log.fd = fopen(log.filename, "a")) == NULL)
pg_log(PG_FATAL, "Cannot write to log file %s\n", log.filename);
if ((log_opts.fd = fopen(log_opts.filename, "w")) == NULL)
pg_log(PG_FATAL, "Cannot write to log file %s\n", log_opts.filename);
fclose(log_opts.fd);
if ((log_opts.fd = fopen(log_opts.filename, "a")) == NULL)
pg_log(PG_FATAL, "Cannot write to log file %s\n", log_opts.filename);
}
else
log.filename = strdup(DEVNULL);
log_opts.filename = strdup(DEVNULL);
/* if no debug file name, output to the terminal */
if (log.debug && !log.debug_fd)
if (log_opts.debug && !log_opts.debug_fd)
{
log.debug_fd = fopen(DEVTTY, "w");
if (!log.debug_fd)
log_opts.debug_fd = fopen(DEVTTY, "w");
if (!log_opts.debug_fd)
pg_log(PG_FATAL, "Cannot write to terminal\n");
}

View File

@ -162,7 +162,7 @@ prepare_new_cluster(void)
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
"--all --analyze >> %s 2>&1" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, log.filename);
new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
check_ok();
/*
@ -175,7 +175,7 @@ prepare_new_cluster(void)
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
"--all --freeze >> %s 2>&1" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, log.filename);
new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
check_ok();
get_pg_database_relfilenode(CLUSTER_NEW);
@ -207,7 +207,7 @@ prepare_new_databases(void)
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
GLOBALS_DUMP_FILE, log.filename);
GLOBALS_DUMP_FILE, log_opts.filename);
check_ok();
get_db_and_rel_infos(&new_cluster.dbarr, CLUSTER_NEW);
@ -230,7 +230,7 @@ create_new_objects(void)
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
DB_DUMP_FILE, log.filename);
DB_DUMP_FILE, log_opts.filename);
check_ok();
/* regenerate now that we have db schemas */
@ -282,7 +282,7 @@ copy_clog_xlog_xid(void)
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -l %u,%u,%u \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
new_cluster.bindir, old_cluster.controldata.chkpnt_tli,
old_cluster.controldata.logid, old_cluster.controldata.nxtlogseg,
new_cluster.pgdata, log.filename);
new_cluster.pgdata, log_opts.filename);
check_ok();
}
@ -384,7 +384,7 @@ cleanup(void)
dbarr_free(&old_cluster.dbarr);
dbarr_free(&new_cluster.dbarr);
pg_free(log.filename);
pg_free(log_opts.filename);
pg_free(os_info.user);
pg_free(old_cluster.major_version_str);
pg_free(new_cluster.major_version_str);
@ -397,14 +397,14 @@ cleanup(void)
pg_free(old_cluster.tablespace_suffix);
pg_free(new_cluster.tablespace_suffix);
if (log.fd != NULL)
if (log_opts.fd != NULL)
{
fclose(log.fd);
log.fd = NULL;
fclose(log_opts.fd);
log_opts.fd = NULL;
}
if (log.debug_fd)
fclose(log.debug_fd);
if (log_opts.debug_fd)
fclose(log_opts.debug_fd);
snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, ALL_DUMP_FILE);
unlink(filename);

View File

@ -197,7 +197,7 @@ typedef struct
/*
* Log
* LogOpts
*/
typedef struct
{
@ -206,7 +206,7 @@ typedef struct
bool debug; /* TRUE -> log more information */
FILE *debug_fd; /* debug-level log FILE */
bool verbose; /* TRUE -> be verbose in messages */
} Log;
} LogOpts;
/*
@ -241,7 +241,7 @@ typedef struct
/*
* Global variables
*/
extern Log log;
extern LogOpts log_opts;
extern UserOpts user_opts;
extern ClusterInfo old_cluster,
new_cluster;

View File

@ -185,7 +185,7 @@ start_postmaster(Cluster whichCluster, bool quiet)
"start >> \"%s\" 2>&1" SYSTEMQUOTE,
bindir,
#ifndef WIN32
log.filename, datadir, port, log.filename);
log_opts.filename, datadir, port, log_opts.filename);
#else
DEVNULL, datadir, port, DEVNULL);
#endif
@ -229,7 +229,7 @@ stop_postmaster(bool fast, bool quiet)
"\"%s\" 2>&1" SYSTEMQUOTE,
bindir,
#ifndef WIN32
log.filename, datadir, fast ? "-m fast" : "", log.filename);
log_opts.filename, datadir, fast ? "-m fast" : "", log_opts.filename);
#else
DEVNULL, datadir, fast ? "-m fast" : "", DEVNULL);
#endif

View File

@ -12,7 +12,7 @@
#include <signal.h>
Log log;
LogOpts log_opts;
/*
* report_status()
@ -75,19 +75,19 @@ pg_log(eLogType type, char *fmt,...)
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);
if (log.fd != NULL)
if (log_opts.fd != NULL)
{
fwrite(message, strlen(message), 1, log.fd);
fwrite(message, strlen(message), 1, log_opts.fd);
/* if we are using OVERWRITE_MESSAGE, add newline */
if (strchr(message, '\r') != NULL)
fwrite("\n", 1, 1, log.fd);
fflush(log.fd);
fwrite("\n", 1, 1, log_opts.fd);
fflush(log_opts.fd);
}
switch (type)
{
case PG_INFO:
if (log.verbose)
if (log_opts.verbose)
printf("%s", _(message));
break;
@ -103,8 +103,8 @@ pg_log(eLogType type, char *fmt,...)
break;
case PG_DEBUG:
if (log.debug)
fprintf(log.debug_fd, "%s\n", _(message));
if (log_opts.debug)
fprintf(log_opts.debug_fd, "%s\n", _(message));
break;
default:
@ -189,13 +189,13 @@ exit_nicely(bool need_cleanup)
{
stop_postmaster(true, true);
pg_free(log.filename);
pg_free(log_opts.filename);
if (log.fd)
fclose(log.fd);
if (log_opts.fd)
fclose(log_opts.fd);
if (log.debug_fd)
fclose(log.debug_fd);
if (log_opts.debug_fd)
fclose(log_opts.debug_fd);
/* terminate any running instance of postmaster */
if (os_info.postmasterPID != 0)