node action: don't attempt to issue a CHECKPOINT as non-superuser

Raise a warning instead.
This commit is contained in:
Ian Barwick
2020-03-24 16:36:50 +09:00
parent b09631b3bc
commit 304c1391cc

View File

@@ -2026,26 +2026,43 @@ do_node_service(void)
if ((action == ACTION_STOP || action == ACTION_RESTART) && runtime_options.checkpoint == true) if ((action == ACTION_STOP || action == ACTION_RESTART) && runtime_options.checkpoint == true)
{ {
if (runtime_options.dry_run == true) PGconn *conn = NULL;
if (strlen(config_file_options.conninfo))
conn = establish_db_connection(config_file_options.conninfo, true);
else
conn = establish_db_connection_by_params(&source_conninfo, true);
if (is_superuser_connection(conn, NULL) == false)
{ {
log_info(_("a CHECKPOINT would be issued here")); if (runtime_options.dry_run == true)
{
log_warning(_("a CHECKPOINT would be issued here but no superuser connection is available"));
}
else
{
log_warning(_("a superuser connection is required to issue a CHECKPOINT"));
}
log_hint(_("provide a superuser with -S/--superuser"));
} }
else else
{ {
PGconn *conn = NULL; if (runtime_options.dry_run == true)
{
if (strlen(config_file_options.conninfo)) log_info(_("a CHECKPOINT would be issued here"));
conn = establish_db_connection(config_file_options.conninfo, true); }
else else
conn = establish_db_connection_by_params(&source_conninfo, true); {
log_notice(_("issuing CHECKPOINT")); log_notice(_("issuing CHECKPOINT"));
/* check superuser conn! */ checkpoint(conn);
checkpoint(conn);
PQfinish(conn); }
} }
PQfinish(conn);
} }
get_server_action(action, command, data_dir); get_server_action(action, command, data_dir);