summaryrefslogtreecommitdiff
path: root/contrib/pg_upgrade/check.c
diff options
context:
space:
mode:
authorCédric Villemain2011-05-13 20:55:39 +0000
committerCédric Villemain2011-05-13 20:55:39 +0000
commite0c3b474d5436c7874aef36988f2646bdb890249 (patch)
tree49c41d2b8abbd9bae4096643d840859f3a02a08c /contrib/pg_upgrade/check.c
parent40cefa392974c73ec20deb3c15fb5111ed7fad17 (diff)
parent9bb6d9795253bb521f81c626fea49a704a369ca9 (diff)
Merge branch 'master' into analyze_cacheanalyze_cache
Diffstat (limited to 'contrib/pg_upgrade/check.c')
-rw-r--r--contrib/pg_upgrade/check.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index a9436ce5b2..ebdc34e188 100644
--- a/contrib/pg_upgrade/check.c
+++ b/contrib/pg_upgrade/check.c
@@ -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);
@@ -253,7 +254,7 @@ check_cluster_compatibility(bool live_check)
if ((lib_test = fopen(libfile, "r")) == NULL)
pg_log(PG_FATAL,
- "\npg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile);
+ "pg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile);
else
fclose(lib_test);
@@ -473,6 +474,37 @@ 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");
+
+ prep_status("Checking database user is a superuser");
+
+ /* 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, "database user \"%s\" is not a superuser\n",
+ os_info.user);
+
+ PQclear(res);
+
+ PQfinish(conn);
+
+ check_ok();
+}
+
+
+/*
* check_for_isn_and_int8_passing_mismatch()
*
* /contrib/isn relies on data type int8, and in 8.4 int8 can now be passed