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);
/*
* 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);
}
+/*
+ * 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()
*
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)
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
PQstatus(conn) != CONNECTION_OK)
{
- if (conn)
+ 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"
"Perhaps pg_hba.conf was not set to \"trust\".\n",