@@ -15,6 +15,7 @@ static void check_new_cluster_is_empty(void);
1515static void check_old_cluster_has_new_cluster_dbs (void );
1616static void check_locale_and_encoding (ControlData * oldctrl ,
1717ControlData * newctrl );
18+ static void check_is_super_user (ClusterInfo * cluster );
1819static void check_for_isn_and_int8_passing_mismatch (ClusterInfo * cluster );
1920static void check_for_reg_data_type_usage (ClusterInfo * cluster );
2021
@@ -63,7 +64,7 @@ check_old_cluster(bool live_check,
6364/*
6465 * Check for various failure cases
6566 */
66-
67+ check_is_super_user ( & old_cluster );
6768check_for_reg_data_type_usage (& old_cluster );
6869check_for_isn_and_int8_passing_mismatch (& old_cluster );
6970
@@ -472,6 +473,32 @@ create_script_for_old_cluster_deletion(
472473}
473474
474475
476+ /*
477+ *check_is_super_user()
478+ *
479+ *Make sure we are the super-user.
480+ */
481+ static void
482+ check_is_super_user (ClusterInfo * cluster )
483+ {
484+ PGresult * res ;
485+ PGconn * conn = connectToServer (cluster ,"template1" );
486+
487+ /* Can't use pg_authid because only superusers can view it. */
488+ res = executeQueryOrDie (conn ,
489+ "SELECT rolsuper "
490+ "FROM pg_catalog.pg_roles "
491+ "WHERE rolname = current_user" );
492+
493+ if (PQntuples (res )!= 1 || strcmp (PQgetvalue (res ,0 ,0 ),"t" )!= 0 )
494+ pg_log (PG_FATAL ,"the database user is not a superuser\n" );
495+
496+ PQclear (res );
497+
498+ PQfinish (conn );
499+ }
500+
501+
475502/*
476503 *check_for_isn_and_int8_passing_mismatch()
477504 *