Post-merge astyle run

This commit is contained in:
Greg Smith
2011-02-15 00:14:13 -05:00
parent 20af4ffc2c
commit f6618a01c7
2 changed files with 76 additions and 76 deletions

112
repmgr.c
View File

@@ -330,7 +330,7 @@ do_master_register(void)
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }
/* Assemble a quoted schema name /* Assemble a quoted schema name
* XXX This is not currently used due to a merge conflict, but * XXX This is not currently used due to a merge conflict, but
* probably should be */ * probably should be */
if (false) if (false)
@@ -386,9 +386,9 @@ do_master_register(void)
/* ... the tables */ /* ... the tables */
sqlquery_snprintf(sqlquery, "CREATE TABLE %s.repl_nodes ( " sqlquery_snprintf(sqlquery, "CREATE TABLE %s.repl_nodes ( "
" id integer primary key, " " id integer primary key, "
" cluster text not null, " " cluster text not null, "
" conninfo text not null)", repmgr_schema); " conninfo text not null)", repmgr_schema);
log_debug("master register: %s\n", sqlquery); log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery)) if (!PQexec(conn, sqlquery))
{ {
@@ -399,13 +399,13 @@ do_master_register(void)
} }
sqlquery_snprintf(sqlquery, "CREATE TABLE %s.repl_monitor ( " sqlquery_snprintf(sqlquery, "CREATE TABLE %s.repl_monitor ( "
" primary_node INTEGER NOT NULL, " " primary_node INTEGER NOT NULL, "
" standby_node INTEGER NOT NULL, " " standby_node INTEGER NOT NULL, "
" last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL, " " last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL, "
" last_wal_primary_location TEXT NOT NULL, " " last_wal_primary_location TEXT NOT NULL, "
" last_wal_standby_location TEXT NOT NULL, " " last_wal_standby_location TEXT NOT NULL, "
" replication_lag BIGINT NOT NULL, " " replication_lag BIGINT NOT NULL, "
" apply_lag BIGINT NOT NULL) ", repmgr_schema); " apply_lag BIGINT NOT NULL) ", repmgr_schema);
log_debug("master register: %s\n", sqlquery); log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery)) if (!PQexec(conn, sqlquery))
{ {
@@ -417,14 +417,14 @@ do_master_register(void)
/* and the view */ /* and the view */
sqlquery_snprintf(sqlquery, "CREATE VIEW %s.repl_status AS " sqlquery_snprintf(sqlquery, "CREATE VIEW %s.repl_status AS "
" WITH monitor_info AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY primary_node, standby_node " " WITH monitor_info AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY primary_node, standby_node "
" ORDER BY last_monitor_time desc) " " ORDER BY last_monitor_time desc) "
" FROM %s.repl_monitor) " " FROM %s.repl_monitor) "
" SELECT primary_node, standby_node, last_monitor_time, last_wal_primary_location, " " SELECT primary_node, standby_node, last_monitor_time, last_wal_primary_location, "
" last_wal_standby_location, pg_size_pretty(replication_lag) replication_lag, " " last_wal_standby_location, pg_size_pretty(replication_lag) replication_lag, "
" pg_size_pretty(apply_lag) apply_lag, age(now(), last_monitor_time) AS time_lag " " pg_size_pretty(apply_lag) apply_lag, age(now(), last_monitor_time) AS time_lag "
" FROM monitor_info a " " FROM monitor_info a "
" WHERE row_number = 1", repmgr_schema, repmgr_schema); " WHERE row_number = 1", repmgr_schema, repmgr_schema);
log_debug("master register: %s\n", sqlquery); log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery)) if (!PQexec(conn, sqlquery))
{ {
@@ -440,8 +440,8 @@ do_master_register(void)
int id; int id;
/* Ensure there isn't any other master already registered */ /* Ensure there isn't any other master already registered */
master_conn = getMasterConnection(conn, options.node, master_conn = getMasterConnection(conn, options.node,
options.cluster_name, &id,NULL); options.cluster_name, &id,NULL);
if (master_conn != NULL) if (master_conn != NULL)
{ {
PQfinish(master_conn); PQfinish(master_conn);
@@ -454,8 +454,8 @@ do_master_register(void)
if (runtime_options.force) if (runtime_options.force)
{ {
sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes " sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes "
" WHERE id = %d", " WHERE id = %d",
repmgr_schema, options.node); repmgr_schema, options.node);
log_debug("master register: %s\n", sqlquery); log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery)) if (!PQexec(conn, sqlquery))
@@ -468,8 +468,8 @@ do_master_register(void)
} }
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes " sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes "
"VALUES (%d, '%s', '%s')", "VALUES (%d, '%s', '%s')",
repmgr_schema, options.node, options.cluster_name, options.conninfo); repmgr_schema, options.node, options.cluster_name, options.conninfo);
log_debug("master register: %s\n", sqlquery); log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery)) if (!PQexec(conn, sqlquery))
@@ -522,7 +522,7 @@ do_standby_register(void)
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }
/* Assemble a quoted schema name /* Assemble a quoted schema name
* XXX This is not currently used due to a merge conflict, but * XXX This is not currently used due to a merge conflict, but
* probably should be */ * probably should be */
if (false) if (false)
@@ -557,8 +557,8 @@ do_standby_register(void)
PQclear(res); PQclear(res);
/* check if there is a master in this cluster */ /* check if there is a master in this cluster */
master_conn = getMasterConnection(conn, options.node, options.cluster_name, master_conn = getMasterConnection(conn, options.node, options.cluster_name,
&master_id, NULL); &master_id, NULL);
if (!master_conn) if (!master_conn)
{ {
log_err(_("A master must be defined before configuring a slave\n")); log_err(_("A master must be defined before configuring a slave\n"));
@@ -590,8 +590,8 @@ do_standby_register(void)
if (runtime_options.force) if (runtime_options.force)
{ {
sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes " sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes "
" WHERE id = %d", " WHERE id = %d",
repmgr_schema, options.node); repmgr_schema, options.node);
log_debug("standby register: %s\n", sqlquery); log_debug("standby register: %s\n", sqlquery);
if (!PQexec(master_conn, sqlquery)) if (!PQexec(master_conn, sqlquery))
@@ -605,8 +605,8 @@ do_standby_register(void)
} }
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes " sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes "
"VALUES (%d, '%s', '%s')", "VALUES (%d, '%s', '%s')",
repmgr_schema, options.node, options.cluster_name, options.conninfo); repmgr_schema, options.node, options.cluster_name, options.conninfo);
log_debug("standby register: %s\n", sqlquery); log_debug("standby register: %s\n", sqlquery);
if (!PQexec(master_conn, sqlquery)) if (!PQexec(master_conn, sqlquery))
@@ -764,11 +764,11 @@ do_standby_clone(void)
log_info(_("Succesfully connected to primary. Current installation size is %s\n"), get_cluster_size(conn)); log_info(_("Succesfully connected to primary. Current installation size is %s\n"), get_cluster_size(conn));
/* /*
* Check if the tablespace locations exists and that we can write to * Check if the tablespace locations exists and that we can write to
* them. * them.
*/ */
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"SELECT spclocation " "SELECT spclocation "
" FROM pg_tablespace " " FROM pg_tablespace "
"WHERE spcname NOT IN ('pg_default', 'pg_global')"); "WHERE spcname NOT IN ('pg_default', 'pg_global')");
@@ -844,10 +844,10 @@ do_standby_clone(void)
log_notice("Starting backup...\n"); log_notice("Starting backup...\n");
/* Get the data directory full path and the configuration files location */ /* Get the data directory full path and the configuration files location */
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"SELECT name, setting " "SELECT name, setting "
" FROM pg_settings " " FROM pg_settings "
" WHERE name IN ('data_directory', 'config_file', 'hba_file', 'ident_file')"); " WHERE name IN ('data_directory', 'config_file', 'hba_file', 'ident_file')");
log_debug("standby clone: %s\n", sqlquery); log_debug("standby clone: %s\n", sqlquery);
res = PQexec(conn, sqlquery); res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -927,8 +927,8 @@ do_standby_clone(void)
} }
log_info("standby clone: master control file '%s'\n", master_control_file); log_info("standby clone: master control file '%s'\n", master_control_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
master_control_file, local_control_file, false); master_control_file, local_control_file, false);
if (r != 0) if (r != 0)
{ {
log_warning("standby clone: failed copying master control file '%s'\n", master_control_file); log_warning("standby clone: failed copying master control file '%s'\n", master_control_file);
@@ -937,7 +937,7 @@ do_standby_clone(void)
log_info("standby clone: master data directory '%s'\n", master_data_directory); log_info("standby clone: master data directory '%s'\n", master_data_directory);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
master_data_directory, runtime_options.dest_dir, true); master_data_directory, runtime_options.dest_dir, true);
if (r != 0) if (r != 0)
{ {
log_warning("standby clone: failed copying master data directory '%s'\n", master_data_directory); log_warning("standby clone: failed copying master data directory '%s'\n", master_data_directory);
@@ -965,8 +965,8 @@ do_standby_clone(void)
{ {
strncpy(tblspc_dir, PQgetvalue(res, i, 0), MAXFILENAME); strncpy(tblspc_dir, PQgetvalue(res, i, 0), MAXFILENAME);
log_info("standby clone: master tablespace '%s'\n", tblspc_dir); log_info("standby clone: master tablespace '%s'\n", tblspc_dir);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
tblspc_dir, tblspc_dir, true); tblspc_dir, tblspc_dir, true);
if (r != 0) if (r != 0)
{ {
log_warning("standby clone: failed copying tablespace directory '%s'\n", tblspc_dir); log_warning("standby clone: failed copying tablespace directory '%s'\n", tblspc_dir);
@@ -976,7 +976,7 @@ do_standby_clone(void)
log_info("standby clone: master config file '%s'\n", master_config_file); log_info("standby clone: master config file '%s'\n", master_config_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
master_config_file, runtime_options.dest_dir, false); master_config_file, runtime_options.dest_dir, false);
if (r != 0) if (r != 0)
{ {
log_warning("standby clone: failed copying master config file '%s'\n", master_config_file); log_warning("standby clone: failed copying master config file '%s'\n", master_config_file);
@@ -993,7 +993,7 @@ do_standby_clone(void)
log_info("standby clone: master ident file '%s'\n", master_ident_file); log_info("standby clone: master ident file '%s'\n", master_ident_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
master_ident_file, runtime_options.dest_dir, false); master_ident_file, runtime_options.dest_dir, false);
if (r != 0) if (r != 0)
{ {
log_warning("standby clone: failed copying master ident file '%s'\n", master_ident_file); log_warning("standby clone: failed copying master ident file '%s'\n", master_ident_file);
@@ -1047,7 +1047,7 @@ stop_backup:
exit(ERR_BAD_RSYNC); exit(ERR_BAD_RSYNC);
log_info(_("%s requires primary to keep WAL files %s until at least %s\n"), log_info(_("%s requires primary to keep WAL files %s until at least %s\n"),
progname, first_wal_segment, last_wal_segment); progname, first_wal_segment, last_wal_segment);
/* /*
* We need to create the pg_xlog sub directory too, I'm reusing a variable * We need to create the pg_xlog sub directory too, I'm reusing a variable
@@ -1115,7 +1115,7 @@ do_standby_promote(void)
/* we also need to check if there isn't any master already */ /* we also need to check if there isn't any master already */
old_master_conn = getMasterConnection(conn, options.node, options.cluster_name, old_master_conn = getMasterConnection(conn, options.node, options.cluster_name,
&old_master_id, NULL); &old_master_id, NULL);
if (old_master_conn != NULL) if (old_master_conn != NULL)
{ {
PQfinish(old_master_conn); PQfinish(old_master_conn);
@@ -1128,7 +1128,7 @@ do_standby_promote(void)
/* Get the data directory full path and the last subdirectory */ /* Get the data directory full path and the last subdirectory */
sqlquery_snprintf(sqlquery, "SELECT setting " sqlquery_snprintf(sqlquery, "SELECT setting "
" FROM pg_settings WHERE name = 'data_directory'"); " FROM pg_settings WHERE name = 'data_directory'");
log_debug("standby promote: %s\n", sqlquery); log_debug("standby promote: %s\n", sqlquery);
res = PQexec(conn, sqlquery); res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -1214,7 +1214,7 @@ do_standby_follow(void)
/* we also need to check if there is any master in the cluster */ /* we also need to check if there is any master in the cluster */
master_conn = getMasterConnection(conn, options.node, master_conn = getMasterConnection(conn, options.node,
options.cluster_name, &master_id,(char *) &master_conninfo); options.cluster_name, &master_id,(char *) &master_conninfo);
if (master_conn == NULL) if (master_conn == NULL)
{ {
PQfinish(conn); PQfinish(conn);
@@ -1263,7 +1263,7 @@ do_standby_follow(void)
/* Get the data directory full path */ /* Get the data directory full path */
sqlquery_snprintf(sqlquery, "SELECT setting " sqlquery_snprintf(sqlquery, "SELECT setting "
" FROM pg_settings WHERE name = 'data_directory'"); " FROM pg_settings WHERE name = 'data_directory'");
log_debug("standby follow: %s\n", sqlquery); log_debug("standby follow: %s\n", sqlquery);
res = PQexec(conn, sqlquery); res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -1440,12 +1440,12 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
{ {
strcat(rsync_flags, " --exclude=pg_xlog* --exclude=pg_control --exclude=*.pid"); strcat(rsync_flags, " --exclude=pg_xlog* --exclude=pg_control --exclude=*.pid");
maxlen_snprintf(script, "rsync %s %s:%s/* %s", maxlen_snprintf(script, "rsync %s %s:%s/* %s",
rsync_flags, host_string, remote_path, local_path); rsync_flags, host_string, remote_path, local_path);
} }
else else
{ {
maxlen_snprintf(script, "rsync %s %s:%s %s/.", maxlen_snprintf(script, "rsync %s %s:%s %s/.",
rsync_flags, host_string, remote_path, local_path); rsync_flags, host_string, remote_path, local_path);
} }
log_info("rsync command line: '%s'\n", script); log_info("rsync command line: '%s'\n", script);
@@ -1561,8 +1561,8 @@ check_parameters_for_action(const int action)
if (runtime_options.config_file[0]) if (runtime_options.config_file[0])
{ {
log_notice("Only command line parameters for the connection " log_notice("Only command line parameters for the connection "
"to the master are used when issuing a STANDBY CLONE command. " "to the master are used when issuing a STANDBY CLONE command. "
"The passed configuration file is neither required nor used\n"); "The passed configuration file is neither required nor used\n");
} }
/* /*
* To clone a master into a standby we need connection parameters * To clone a master into a standby we need connection parameters
@@ -1572,7 +1572,7 @@ check_parameters_for_action(const int action)
if (runtime_options.host == NULL) if (runtime_options.host == NULL)
{ {
log_notice("You need to use connection parameters to " log_notice("You need to use connection parameters to "
"the master when issuing a STANDBY CLONE command."); "the master when issuing a STANDBY CLONE command.");
ok = false; ok = false;
} }
need_a_node = false; need_a_node = false;

View File

@@ -54,7 +54,7 @@ char repmgr_schema[MAXLEN];
/* /*
* should initialize with {0} to be ANSI complaint ? but this raises * should initialize with {0} to be ANSI complaint ? but this raises
* error with gcc -Wall * error with gcc -Wall
*/ */
t_configuration_options config = {}; t_configuration_options config = {};
@@ -178,8 +178,8 @@ main(int argc, char **argv)
else else
{ {
/* I need the id of the primary as well as a connection to it */ /* I need the id of the primary as well as a connection to it */
primaryConn = getMasterConnection(myLocalConn, local_options.node, primaryConn = getMasterConnection(myLocalConn, local_options.node,
local_options.cluster_name, &primary_options.node,NULL); local_options.cluster_name, &primary_options.node,NULL);
if (primaryConn == NULL) if (primaryConn == NULL)
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }
@@ -253,8 +253,8 @@ MonitorExecute(void)
log_err(_("We couldn't reconnect to master. Now checking if another node has been promoted.")); log_err(_("We couldn't reconnect to master. Now checking if another node has been promoted."));
for (connection_retries = 0; connection_retries < 6; connection_retries++) for (connection_retries = 0; connection_retries < 6; connection_retries++)
{ {
primaryConn = getMasterConnection(myLocalConn, local_options.node, primaryConn = getMasterConnection(myLocalConn, local_options.node,
local_options.cluster_name, &primary_options.node,NULL); local_options.cluster_name, &primary_options.node,NULL);
if (PQstatus(primaryConn) == CONNECTION_OK) if (PQstatus(primaryConn) == CONNECTION_OK)
{ {
/* Connected, we can continue the process so break the loop */ /* Connected, we can continue the process so break the loop */
@@ -334,15 +334,15 @@ MonitorExecute(void)
* Build the SQL to execute on primary * Build the SQL to execute on primary
*/ */
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"INSERT INTO %s.repl_monitor " "INSERT INTO %s.repl_monitor "
"VALUES(%d, %d, '%s'::timestamp with time zone, " "VALUES(%d, %d, '%s'::timestamp with time zone, "
" '%s', '%s', " " '%s', '%s', "
" %lld, %lld)", repmgr_schema, " %lld, %lld)", repmgr_schema,
primary_options.node, local_options.node, monitor_standby_timestamp, primary_options.node, local_options.node, monitor_standby_timestamp,
last_wal_primary_location, last_wal_primary_location,
last_wal_standby_received, last_wal_standby_received,
(lsn_primary - lsn_standby_received), (lsn_primary - lsn_standby_received),
(lsn_standby_received - lsn_standby_applied)); (lsn_standby_received - lsn_standby_applied));
/* /*
* Execute the query asynchronously, but don't check for a result. We * Execute the query asynchronously, but don't check for a result. We
@@ -360,8 +360,8 @@ checkClusterConfiguration(void)
PGresult *res; PGresult *res;
sqlquery_snprintf(sqlquery, "SELECT oid FROM pg_class " sqlquery_snprintf(sqlquery, "SELECT oid FROM pg_class "
" WHERE oid = '%s.repl_nodes'::regclass", " WHERE oid = '%s.repl_nodes'::regclass",
repmgr_schema); repmgr_schema);
res = PQexec(myLocalConn, sqlquery); res = PQexec(myLocalConn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
@@ -400,8 +400,8 @@ checkNodeConfiguration(char *conninfo)
* Check if we have my node information in repl_nodes * Check if we have my node information in repl_nodes
*/ */
sqlquery_snprintf(sqlquery, "SELECT * FROM %s.repl_nodes " sqlquery_snprintf(sqlquery, "SELECT * FROM %s.repl_nodes "
" WHERE id = %d AND cluster = '%s' ", " WHERE id = %d AND cluster = '%s' ",
repmgr_schema, local_options.node, local_options.cluster_name); repmgr_schema, local_options.node, local_options.cluster_name);
res = PQexec(myLocalConn, sqlquery); res = PQexec(myLocalConn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -423,8 +423,8 @@ checkNodeConfiguration(char *conninfo)
/* Adding the node */ /* Adding the node */
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes " sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes "
"VALUES (%d, '%s', '%s')", "VALUES (%d, '%s', '%s')",
repmgr_schema, local_options.node, local_options.cluster_name, local_options.conninfo); repmgr_schema, local_options.node, local_options.cluster_name, local_options.conninfo);
if (!PQexec(primaryConn, sqlquery)) if (!PQexec(primaryConn, sqlquery))
{ {