"--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();
}
/* 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
void
print_maps(FileNameMap *maps, int n, const char *dbName)
{
- if (log.debug)
+ if (log_opts.debug)
{
int mapnum;
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);
}
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);
break;
case 'l':
- log.filename = pg_strdup(optarg);
+ log_opts.filename = pg_strdup(optarg);
break;
case 'p':
case 'v':
pg_log(PG_REPORT, "Running in verbose mode\n");
- log.verbose = true;
+ log_opts.verbose = true;
break;
default:
}
}
- if (log.filename != NULL)
+ if (log_opts.filename != NULL)
{
/*
* We must use append mode so output generated by child processes via
* 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");
}
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();
/*
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);
"--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);
"--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 */
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();
}
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);
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);
/*
- * Log
+ * LogOpts
*/
typedef struct
{
bool debug; /* TRUE -> log more information */
FILE *debug_fd; /* debug-level log FILE */
bool verbose; /* TRUE -> be verbose in messages */
-} Log;
+} LogOpts;
/*
/*
* Global variables
*/
-extern Log log;
+extern LogOpts log_opts;
extern UserOpts user_opts;
extern ClusterInfo old_cluster,
new_cluster;
"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
"\"%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
#include <signal.h>
-Log log;
+LogOpts log_opts;
/*
* report_status()
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;
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:
{
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)