postgres.git / summary / log / commit / refs
commit 07d17a73ec9485d6fa096d29d26647459fb9cbb7
Author: Bruce Momjian <bruce@momjian.us>
Date: Tue Jun 14 18:53:35 2011 +0000
First released in: 9.2.0, 9.1.0
In pg_upgrade, check there are no prepared transactions.
contrib/pg_upgrade/check.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index fdec6e34af1..376d25a09a8 100644
--- a/contrib/pg_upgrade/check.c
+++ b/contrib/pg_upgrade/check.c
@@ -16,6 +16,7 @@ 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_prepared_transactions(ClusterInfo *cluster);
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
@@ -65,6 +66,7 @@ check_old_cluster(bool live_check,
* Check for various failure cases
*/
check_is_super_user(&old_cluster);
+ check_for_prepared_transactions(&old_cluster);
check_for_reg_data_type_usage(&old_cluster);
check_for_isn_and_int8_passing_mismatch(&old_cluster);
@@ -117,6 +119,7 @@ check_new_cluster(void)
get_db_and_rel_infos(&new_cluster);
check_new_cluster_is_empty();
+ check_for_prepared_transactions(&new_cluster);
check_old_cluster_has_new_cluster_dbs();
check_loadable_libraries();
@@ -506,6 +509,36 @@ check_is_super_user(ClusterInfo *cluster)
}
+/*
+ * check_for_prepared_transactions()
+ *
+ * Make sure there are no prepared transactions because the storage format
+ * might have changed.
+ */
+static void
+check_for_prepared_transactions(ClusterInfo *cluster)
+{
+ PGresult *res;
+ PGconn *conn = connectToServer(cluster, "template1");
+
+ prep_status("Checking for prepared transactions");
+
+ res = executeQueryOrDie(conn,
+ "SELECT * "
+ "FROM pg_catalog.pg_prepared_xact()");
+
+ if (PQntuples(res) != 0)
+ pg_log(PG_FATAL, "The %s cluster contains prepared transactions\n",
+ CLUSTER_NAME(cluster));
+
+ PQclear(res);
+
+ PQfinish(conn);
+
+ check_ok();
+}
+
+
/*
* check_for_isn_and_int8_passing_mismatch()
*
[parent: 8cfd59dd65fe]