pg_upgrade.diff
text/x-diff
Filename: pg_upgrade.diff
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| contrib/pg_upgrade/check.c | 0 | 0 |
| contrib/pg_upgrade/pg_upgrade.c | 0 | 0 |
| contrib/pg_upgrade/pg_upgrade.h | 0 | 0 |
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
new file mode 100644
index d226f00..9f3dcda
*** a/contrib/pg_upgrade/check.c
--- b/contrib/pg_upgrade/check.c
*************** check_new_cluster(void)
*** 138,144 ****
* We don't restore our own user, so both clusters must match have
* matching install-user oids.
*/
! if (old_cluster.install_user_oid != new_cluster.install_user_oid)
pg_log(PG_FATAL,
"Old and new cluster install users have different values for pg_authid.oid.\n");
--- 138,144 ----
* We don't restore our own user, so both clusters must match have
* matching install-user oids.
*/
! if (old_cluster.install_role_oid != new_cluster.install_role_oid)
pg_log(PG_FATAL,
"Old and new cluster install users have different values for pg_authid.oid.\n");
*************** check_new_cluster(void)
*** 147,153 ****
* defined users might match users defined in the old cluster and
* generate an error during pg_dump restore.
*/
! if (new_cluster.user_count != 1)
pg_log(PG_FATAL, "Only the install user can be defined in the new cluster.\n");
check_for_prepared_transactions(&new_cluster);
--- 147,153 ----
* defined users might match users defined in the old cluster and
* generate an error during pg_dump restore.
*/
! if (new_cluster.role_count != 1)
pg_log(PG_FATAL, "Only the install user can be defined in the new cluster.\n");
check_for_prepared_transactions(&new_cluster);
*************** check_is_super_user(ClusterInfo *cluster
*** 618,624 ****
pg_log(PG_FATAL, "database user \"%s\" is not a superuser\n",
os_info.user);
! cluster->install_user_oid = atooid(PQgetvalue(res, 0, 1));
PQclear(res);
--- 618,624 ----
pg_log(PG_FATAL, "database user \"%s\" is not a superuser\n",
os_info.user);
! cluster->install_role_oid = atooid(PQgetvalue(res, 0, 1));
PQclear(res);
*************** check_is_super_user(ClusterInfo *cluster
*** 629,635 ****
if (PQntuples(res) != 1)
pg_log(PG_FATAL, "could not determine the number of users\n");
! cluster->user_count = atoi(PQgetvalue(res, 0, 0));
PQclear(res);
--- 629,635 ----
if (PQntuples(res) != 1)
pg_log(PG_FATAL, "could not determine the number of users\n");
! cluster->role_count = atoi(PQgetvalue(res, 0, 0));
PQclear(res);
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
new file mode 100644
index 528eea7..1d7f56c
*** a/contrib/pg_upgrade/pg_upgrade.h
--- b/contrib/pg_upgrade/pg_upgrade.h
*************** typedef struct
*** 230,237 ****
char major_version_str[64]; /* string PG_VERSION of cluster */
uint32 bin_version; /* version returned from pg_ctl */
Oid pg_database_oid; /* OID of pg_database relation */
! Oid install_user_oid; /* OID of connected user */
! Oid user_count; /* number of users defined in the cluster */
char *tablespace_suffix; /* directory specification */
} ClusterInfo;
--- 230,237 ----
char major_version_str[64]; /* string PG_VERSION of cluster */
uint32 bin_version; /* version returned from pg_ctl */
Oid pg_database_oid; /* OID of pg_database relation */
! Oid install_role_oid; /* OID of connected role */
! Oid role_count; /* number of roles defined in the cluster */
char *tablespace_suffix; /* directory specification */
} ClusterInfo;
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
new file mode 100644
index 2669c09..d226f00
*** a/contrib/pg_upgrade/check.c
--- b/contrib/pg_upgrade/check.c
*************** check_new_cluster(void)
*** 121,137 ****
{
set_locale_and_encoding(&new_cluster);
get_db_and_rel_infos(&new_cluster);
check_new_cluster_is_empty();
- check_for_prepared_transactions(&new_cluster);
check_loadable_libraries();
- check_locale_and_encoding(&old_cluster.controldata, &new_cluster.controldata);
-
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
check_hard_link();
}
--- 121,156 ----
{
set_locale_and_encoding(&new_cluster);
+ check_locale_and_encoding(&old_cluster.controldata, &new_cluster.controldata);
+
get_db_and_rel_infos(&new_cluster);
check_new_cluster_is_empty();
check_loadable_libraries();
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
check_hard_link();
+
+ check_is_super_user(&new_cluster);
+
+ /*
+ * We don't restore our own user, so both clusters must match have
+ * matching install-user oids.
+ */
+ if (old_cluster.install_user_oid != new_cluster.install_user_oid)
+ pg_log(PG_FATAL,
+ "Old and new cluster install users have different values for pg_authid.oid.\n");
+
+ /*
+ * We only allow the install user in the new cluster because other
+ * defined users might match users defined in the old cluster and
+ * generate an error during pg_dump restore.
+ */
+ if (new_cluster.user_count != 1)
+ pg_log(PG_FATAL, "Only the install user can be defined in the new cluster.\n");
+
+ check_for_prepared_transactions(&new_cluster);
}
*************** create_script_for_old_cluster_deletion(c
*** 579,585 ****
/*
* check_is_super_user()
*
! * Make sure we are the super-user.
*/
static void
check_is_super_user(ClusterInfo *cluster)
--- 598,604 ----
/*
* check_is_super_user()
*
! * Check we are superuser, and out user id and user count
*/
static void
check_is_super_user(ClusterInfo *cluster)
*************** check_is_super_user(ClusterInfo *cluster
*** 591,597 ****
/* 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");
--- 610,616 ----
/* Can't use pg_authid because only superusers can view it. */
res = executeQueryOrDie(conn,
! "SELECT rolsuper, oid "
"FROM pg_catalog.pg_roles "
"WHERE rolname = current_user");
*************** check_is_super_user(ClusterInfo *cluster
*** 599,604 ****
--- 618,636 ----
pg_log(PG_FATAL, "database user \"%s\" is not a superuser\n",
os_info.user);
+ cluster->install_user_oid = atooid(PQgetvalue(res, 0, 1));
+
+ PQclear(res);
+
+ res = executeQueryOrDie(conn,
+ "SELECT COUNT(*) "
+ "FROM pg_catalog.pg_roles ");
+
+ if (PQntuples(res) != 1)
+ pg_log(PG_FATAL, "could not determine the number of users\n");
+
+ cluster->user_count = atoi(PQgetvalue(res, 0, 0));
+
PQclear(res);
PQfinish(conn);
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
new file mode 100644
index 465ecdd..ba81823
*** a/contrib/pg_upgrade/pg_upgrade.c
--- b/contrib/pg_upgrade/pg_upgrade.c
***************
*** 29,35 ****
* We control all assignments of pg_enum.oid because these oids are stored
* in user tables as enum values.
*
! * We control all assignments of pg_auth.oid because these oids are stored
* in pg_largeobject_metadata.
*/
--- 29,35 ----
* We control all assignments of pg_enum.oid because these oids are stored
* in user tables as enum values.
*
! * We control all assignments of pg_authid.oid because these oids are stored
* in pg_largeobject_metadata.
*/
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
new file mode 100644
index 26aa7bb..528eea7
*** a/contrib/pg_upgrade/pg_upgrade.h
--- b/contrib/pg_upgrade/pg_upgrade.h
*************** typedef struct
*** 230,235 ****
--- 230,237 ----
char major_version_str[64]; /* string PG_VERSION of cluster */
uint32 bin_version; /* version returned from pg_ctl */
Oid pg_database_oid; /* OID of pg_database relation */
+ Oid install_user_oid; /* OID of connected user */
+ Oid user_count; /* number of users defined in the cluster */
char *tablespace_suffix; /* directory specification */
} ClusterInfo;