mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Check that the pg_upgrade user specified is a super-user.
Also report the error message when the post-pg_ctl connection fails. Per private bug report from EnterpriseDB.
This commit is contained in:
@ -15,6 +15,7 @@ static void check_new_cluster_is_empty(void);
|
||||
static void check_old_cluster_has_new_cluster_dbs(void);
|
||||
static void check_locale_and_encoding(ControlData *oldctrl,
|
||||
ControlData *newctrl);
|
||||
static void check_is_super_user(ClusterInfo *cluster);
|
||||
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
|
||||
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
|
||||
|
||||
@ -63,7 +64,7 @@ check_old_cluster(bool live_check,
|
||||
/*
|
||||
* Check for various failure cases
|
||||
*/
|
||||
|
||||
check_is_super_user(&old_cluster);
|
||||
check_for_reg_data_type_usage(&old_cluster);
|
||||
check_for_isn_and_int8_passing_mismatch(&old_cluster);
|
||||
|
||||
@ -472,6 +473,32 @@ create_script_for_old_cluster_deletion(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check_is_super_user()
|
||||
*
|
||||
* Make sure we are the super-user.
|
||||
*/
|
||||
static void
|
||||
check_is_super_user(ClusterInfo *cluster)
|
||||
{
|
||||
PGresult *res;
|
||||
PGconn *conn = connectToServer(cluster, "template1");
|
||||
|
||||
/* Can't use pg_authid because only superusers can view it. */
|
||||
res = executeQueryOrDie(conn,
|
||||
"SELECT rolsuper "
|
||||
"FROM pg_catalog.pg_roles "
|
||||
"WHERE rolname = current_user");
|
||||
|
||||
if (PQntuples(res) != 1 || strcmp(PQgetvalue(res, 0, 0), "t") != 0)
|
||||
pg_log(PG_FATAL, "the database user is not a superuser\n");
|
||||
|
||||
PQclear(res);
|
||||
|
||||
PQfinish(conn);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check_for_isn_and_int8_passing_mismatch()
|
||||
*
|
||||
|
@ -27,7 +27,7 @@ connectToServer(ClusterInfo *cluster, const char *db_name)
|
||||
|
||||
if (conn == NULL || PQstatus(conn) != CONNECTION_OK)
|
||||
{
|
||||
pg_log(PG_REPORT, "Connection to database failed: %s\n",
|
||||
pg_log(PG_REPORT, "connection to database failed: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
|
||||
if (conn)
|
||||
@ -189,6 +189,8 @@ start_postmaster(ClusterInfo *cluster)
|
||||
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
|
||||
PQstatus(conn) != CONNECTION_OK)
|
||||
{
|
||||
pg_log(PG_REPORT, "\nconnection to database failed: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
if (conn)
|
||||
PQfinish(conn);
|
||||
pg_log(PG_FATAL, "unable to connect to %s postmaster started with the command: %s\n"
|
||||
|
Reference in New Issue
Block a user