Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
Post-merge astyle run
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Smith authored and Greg Smith committed Feb 15, 2011
1 parent 20af4ff commit f6618a0
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 76 deletions.
112 changes: 56 additions & 56 deletions repmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ do_master_register(void)
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
* probably should be */
if (false)
Expand Down Expand Up @@ -386,9 +386,9 @@ do_master_register(void)

/* ... the tables */
sqlquery_snprintf(sqlquery, "CREATE TABLE %s.repl_nodes ( "
" id integer primary key, "
" cluster text not null, "
" conninfo text not null)", repmgr_schema);
" id integer primary key, "
" cluster text not null, "
" conninfo text not null)", repmgr_schema);
log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery))
{
Expand All @@ -399,13 +399,13 @@ do_master_register(void)
}

sqlquery_snprintf(sqlquery, "CREATE TABLE %s.repl_monitor ( "
" primary_node INTEGER NOT NULL, "
" standby_node INTEGER NOT NULL, "
" last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL, "
" last_wal_primary_location TEXT NOT NULL, "
" last_wal_standby_location TEXT NOT NULL, "
" replication_lag BIGINT NOT NULL, "
" apply_lag BIGINT NOT NULL) ", repmgr_schema);
" primary_node INTEGER NOT NULL, "
" standby_node INTEGER NOT NULL, "
" last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL, "
" last_wal_primary_location TEXT NOT NULL, "
" last_wal_standby_location TEXT NOT NULL, "
" replication_lag BIGINT NOT NULL, "
" apply_lag BIGINT NOT NULL) ", repmgr_schema);
log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery))
{
Expand All @@ -417,14 +417,14 @@ do_master_register(void)

/* and the view */
sqlquery_snprintf(sqlquery, "CREATE VIEW %s.repl_status AS "
" WITH monitor_info AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY primary_node, standby_node "
" ORDER BY last_monitor_time desc) "
" FROM %s.repl_monitor) "
" SELECT primary_node, standby_node, last_monitor_time, last_wal_primary_location, "
" 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 "
" FROM monitor_info a "
" WHERE row_number = 1", repmgr_schema, repmgr_schema);
" WITH monitor_info AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY primary_node, standby_node "
" ORDER BY last_monitor_time desc) "
" FROM %s.repl_monitor) "
" SELECT primary_node, standby_node, last_monitor_time, last_wal_primary_location, "
" 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 "
" FROM monitor_info a "
" WHERE row_number = 1", repmgr_schema, repmgr_schema);
log_debug("master register: %s\n", sqlquery);
if (!PQexec(conn, sqlquery))
{
Expand All @@ -440,8 +440,8 @@ do_master_register(void)
int id;

/* Ensure there isn't any other master already registered */
master_conn = getMasterConnection(conn, options.node,
options.cluster_name, &id,NULL);
master_conn = getMasterConnection(conn, options.node,
options.cluster_name, &id,NULL);
if (master_conn != NULL)
{
PQfinish(master_conn);
Expand All @@ -454,8 +454,8 @@ do_master_register(void)
if (runtime_options.force)
{
sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes "
" WHERE id = %d",
repmgr_schema, options.node);
" WHERE id = %d",
repmgr_schema, options.node);
log_debug("master register: %s\n", sqlquery);

if (!PQexec(conn, sqlquery))
Expand All @@ -468,8 +468,8 @@ do_master_register(void)
}

sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes "
"VALUES (%d, '%s', '%s')",
repmgr_schema, options.node, options.cluster_name, options.conninfo);
"VALUES (%d, '%s', '%s')",
repmgr_schema, options.node, options.cluster_name, options.conninfo);
log_debug("master register: %s\n", sqlquery);

if (!PQexec(conn, sqlquery))
Expand Down Expand Up @@ -522,7 +522,7 @@ do_standby_register(void)
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
* probably should be */
if (false)
Expand Down Expand Up @@ -557,8 +557,8 @@ do_standby_register(void)
PQclear(res);

/* check if there is a master in this cluster */
master_conn = getMasterConnection(conn, options.node, options.cluster_name,
&master_id, NULL);
master_conn = getMasterConnection(conn, options.node, options.cluster_name,
&master_id, NULL);
if (!master_conn)
{
log_err(_("A master must be defined before configuring a slave\n"));
Expand Down Expand Up @@ -590,8 +590,8 @@ do_standby_register(void)
if (runtime_options.force)
{
sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes "
" WHERE id = %d",
repmgr_schema, options.node);
" WHERE id = %d",
repmgr_schema, options.node);
log_debug("standby register: %s\n", sqlquery);

if (!PQexec(master_conn, sqlquery))
Expand All @@ -605,8 +605,8 @@ do_standby_register(void)
}

sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes "
"VALUES (%d, '%s', '%s')",
repmgr_schema, options.node, options.cluster_name, options.conninfo);
"VALUES (%d, '%s', '%s')",
repmgr_schema, options.node, options.cluster_name, options.conninfo);
log_debug("standby register: %s\n", sqlquery);

if (!PQexec(master_conn, sqlquery))
Expand Down Expand Up @@ -764,11 +764,11 @@ do_standby_clone(void)

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.
*/
sqlquery_snprintf(sqlquery,
sqlquery_snprintf(sqlquery,
"SELECT spclocation "
" FROM pg_tablespace "
"WHERE spcname NOT IN ('pg_default', 'pg_global')");
Expand Down Expand Up @@ -844,10 +844,10 @@ do_standby_clone(void)
log_notice("Starting backup...\n");

/* Get the data directory full path and the configuration files location */
sqlquery_snprintf(sqlquery,
"SELECT name, setting "
" FROM pg_settings "
" WHERE name IN ('data_directory', 'config_file', 'hba_file', 'ident_file')");
sqlquery_snprintf(sqlquery,
"SELECT name, setting "
" FROM pg_settings "
" WHERE name IN ('data_directory', 'config_file', 'hba_file', 'ident_file')");
log_debug("standby clone: %s\n", sqlquery);
res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
Expand Down Expand Up @@ -927,8 +927,8 @@ do_standby_clone(void)
}

log_info("standby clone: master control file '%s'\n", master_control_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
master_control_file, local_control_file, false);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
master_control_file, local_control_file, false);
if (r != 0)
{
log_warning("standby clone: failed copying master control file '%s'\n", master_control_file);
Expand All @@ -937,7 +937,7 @@ do_standby_clone(void)

log_info("standby clone: master data directory '%s'\n", master_data_directory);
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)
{
log_warning("standby clone: failed copying master data directory '%s'\n", master_data_directory);
Expand Down Expand Up @@ -965,8 +965,8 @@ do_standby_clone(void)
{
strncpy(tblspc_dir, PQgetvalue(res, i, 0), MAXFILENAME);
log_info("standby clone: master tablespace '%s'\n", tblspc_dir);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
tblspc_dir, tblspc_dir, true);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
tblspc_dir, tblspc_dir, true);
if (r != 0)
{
log_warning("standby clone: failed copying tablespace directory '%s'\n", tblspc_dir);
Expand All @@ -976,7 +976,7 @@ do_standby_clone(void)

log_info("standby clone: master config file '%s'\n", master_config_file);
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)
{
log_warning("standby clone: failed copying master config file '%s'\n", master_config_file);
Expand All @@ -993,7 +993,7 @@ do_standby_clone(void)

log_info("standby clone: master ident file '%s'\n", master_ident_file);
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)
{
log_warning("standby clone: failed copying master ident file '%s'\n", master_ident_file);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ do_standby_clone(void)
exit(ERR_BAD_RSYNC);

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
Expand Down Expand Up @@ -1115,7 +1115,7 @@ do_standby_promote(void)

/* we also need to check if there isn't any master already */
old_master_conn = getMasterConnection(conn, options.node, options.cluster_name,
&old_master_id, NULL);
&old_master_id, NULL);
if (old_master_conn != NULL)
{
PQfinish(old_master_conn);
Expand All @@ -1128,7 +1128,7 @@ do_standby_promote(void)

/* Get the data directory full path and the last subdirectory */
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);
res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
Expand Down Expand Up @@ -1214,7 +1214,7 @@ do_standby_follow(void)

/* we also need to check if there is any master in the cluster */
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)
{
PQfinish(conn);
Expand Down Expand Up @@ -1263,7 +1263,7 @@ do_standby_follow(void)

/* Get the data directory full path */
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);
res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
Expand Down Expand Up @@ -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");
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
{
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);
Expand Down Expand Up @@ -1561,8 +1561,8 @@ check_parameters_for_action(const int action)
if (runtime_options.config_file[0])
{
log_notice("Only command line parameters for the connection "
"to the master are used when issuing a STANDBY CLONE command. "
"The passed configuration file is neither required nor used\n");
"to the master are used when issuing a STANDBY CLONE command. "
"The passed configuration file is neither required nor used\n");
}
/*
* To clone a master into a standby we need connection parameters
Expand All @@ -1572,7 +1572,7 @@ check_parameters_for_action(const int action)
if (runtime_options.host == NULL)
{
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;
}
need_a_node = false;
Expand Down
40 changes: 20 additions & 20 deletions repmgrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ char repmgr_schema[MAXLEN];

/*
* should initialize with {0} to be ANSI complaint ? but this raises
* error with gcc -Wall
* error with gcc -Wall
*/
t_configuration_options config = {};

Expand Down Expand Up @@ -178,8 +178,8 @@ main(int argc, char **argv)
else
{
/* I need the id of the primary as well as a connection to it */
primaryConn = getMasterConnection(myLocalConn, local_options.node,
local_options.cluster_name, &primary_options.node,NULL);
primaryConn = getMasterConnection(myLocalConn, local_options.node,
local_options.cluster_name, &primary_options.node,NULL);
if (primaryConn == NULL)
exit(ERR_BAD_CONFIG);
}
Expand Down Expand Up @@ -253,8 +253,8 @@ MonitorExecute(void)
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++)
{
primaryConn = getMasterConnection(myLocalConn, local_options.node,
local_options.cluster_name, &primary_options.node,NULL);
primaryConn = getMasterConnection(myLocalConn, local_options.node,
local_options.cluster_name, &primary_options.node,NULL);
if (PQstatus(primaryConn) == CONNECTION_OK)
{
/* Connected, we can continue the process so break the loop */
Expand Down Expand Up @@ -334,15 +334,15 @@ MonitorExecute(void)
* Build the SQL to execute on primary
*/
sqlquery_snprintf(sqlquery,
"INSERT INTO %s.repl_monitor "
"VALUES(%d, %d, '%s'::timestamp with time zone, "
" '%s', '%s', "
" %lld, %lld)", repmgr_schema,
primary_options.node, local_options.node, monitor_standby_timestamp,
last_wal_primary_location,
last_wal_standby_received,
(lsn_primary - lsn_standby_received),
(lsn_standby_received - lsn_standby_applied));
"INSERT INTO %s.repl_monitor "
"VALUES(%d, %d, '%s'::timestamp with time zone, "
" '%s', '%s', "
" %lld, %lld)", repmgr_schema,
primary_options.node, local_options.node, monitor_standby_timestamp,
last_wal_primary_location,
last_wal_standby_received,
(lsn_primary - lsn_standby_received),
(lsn_standby_received - lsn_standby_applied));

/*
* Execute the query asynchronously, but don't check for a result. We
Expand All @@ -360,8 +360,8 @@ checkClusterConfiguration(void)
PGresult *res;

sqlquery_snprintf(sqlquery, "SELECT oid FROM pg_class "
" WHERE oid = '%s.repl_nodes'::regclass",
repmgr_schema);
" WHERE oid = '%s.repl_nodes'::regclass",
repmgr_schema);
res = PQexec(myLocalConn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
Expand Down Expand Up @@ -400,8 +400,8 @@ checkNodeConfiguration(char *conninfo)
* Check if we have my node information in repl_nodes
*/
sqlquery_snprintf(sqlquery, "SELECT * FROM %s.repl_nodes "
" WHERE id = %d AND cluster = '%s' ",
repmgr_schema, local_options.node, local_options.cluster_name);
" WHERE id = %d AND cluster = '%s' ",
repmgr_schema, local_options.node, local_options.cluster_name);

res = PQexec(myLocalConn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
Expand All @@ -423,8 +423,8 @@ checkNodeConfiguration(char *conninfo)

/* Adding the node */
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes "
"VALUES (%d, '%s', '%s')",
repmgr_schema, local_options.node, local_options.cluster_name, local_options.conninfo);
"VALUES (%d, '%s', '%s')",
repmgr_schema, local_options.node, local_options.cluster_name, local_options.conninfo);

if (!PQexec(primaryConn, sqlquery))
{
Expand Down

0 comments on commit f6618a0

Please sign in to comment.