mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 16:16:29 +00:00
repmgr master register: support --dry-run
This commit is contained in:
@@ -67,6 +67,18 @@ do_master_register(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In --dry-run mode we can't proceed any further as the following code
|
||||||
|
* attempts to query the repmgr metadata, which won't exist until
|
||||||
|
* the extension is installed
|
||||||
|
*/
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
PQfinish(conn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Ensure there isn't another registered node which is master */
|
/* Ensure there isn't another registered node which is master */
|
||||||
master_conn = get_master_connection(conn, ¤t_master_id, NULL);
|
master_conn = get_master_connection(conn, ¤t_master_id, NULL);
|
||||||
|
|
||||||
@@ -134,6 +146,7 @@ do_master_register(void)
|
|||||||
config_file_options.upstream_node_id);
|
config_file_options.upstream_node_id);
|
||||||
log_detail(_("the value set for \"upstream_node_id\" will be ignored"));
|
log_detail(_("the value set for \"upstream_node_id\" will be ignored"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set type to "master", active to "true" and unset upstream_node_id*/
|
/* set type to "master", active to "true" and unset upstream_node_id*/
|
||||||
node_info.type = MASTER;
|
node_info.type = MASTER;
|
||||||
node_info.upstream_node_id = NO_UPSTREAM_NODE;
|
node_info.upstream_node_id = NO_UPSTREAM_NODE;
|
||||||
|
|||||||
@@ -1263,7 +1263,7 @@ create_repmgr_extension(PGconn *conn)
|
|||||||
switch(extension_status)
|
switch(extension_status)
|
||||||
{
|
{
|
||||||
case REPMGR_UNKNOWN:
|
case REPMGR_UNKNOWN:
|
||||||
log_error(_("unable to determine status of repmgr extension"));
|
log_error(_("unable to determine status of \"repmgr\" extension"));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case REPMGR_UNAVAILABLE:
|
case REPMGR_UNAVAILABLE:
|
||||||
@@ -1276,9 +1276,15 @@ create_repmgr_extension(PGconn *conn)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case REPMGR_AVAILABLE:
|
case REPMGR_AVAILABLE:
|
||||||
log_notice(_("attempting to install extension \"repmgr\""));
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_notice(_("would now attempt to install extension \"repmgr\""));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_notice(_("attempting to install extension \"repmgr\""));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3. Attempt to get a superuser connection */
|
/* 3. Attempt to get a superuser connection */
|
||||||
@@ -1287,6 +1293,9 @@ create_repmgr_extension(PGconn *conn)
|
|||||||
|
|
||||||
get_superuser_connection(&conn, &superuser_conn, &schema_create_conn);
|
get_superuser_connection(&conn, &superuser_conn, &schema_create_conn);
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
return true;
|
||||||
|
|
||||||
/* 4. Create extension */
|
/* 4. Create extension */
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user