Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 07d17a7

Browse files
committed
In pg_upgrade, check there are no prepared transactions.
1 parent 8cfd59d commit 07d17a7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

contrib/pg_upgrade/check.c

+33
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static void check_old_cluster_has_new_cluster_dbs(void);
1616
static void check_locale_and_encoding(ControlData *oldctrl,
1717
ControlData *newctrl);
1818
static void check_is_super_user(ClusterInfo *cluster);
19+
static void check_for_prepared_transactions(ClusterInfo *cluster);
1920
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
2021
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
2122

@@ -65,6 +66,7 @@ check_old_cluster(bool live_check,
6566
* Check for various failure cases
6667
*/
6768
check_is_super_user(&old_cluster);
69+
check_for_prepared_transactions(&old_cluster);
6870
check_for_reg_data_type_usage(&old_cluster);
6971
check_for_isn_and_int8_passing_mismatch(&old_cluster);
7072

@@ -117,6 +119,7 @@ check_new_cluster(void)
117119
get_db_and_rel_infos(&new_cluster);
118120

119121
check_new_cluster_is_empty();
122+
check_for_prepared_transactions(&new_cluster);
120123
check_old_cluster_has_new_cluster_dbs();
121124

122125
check_loadable_libraries();
@@ -506,6 +509,36 @@ check_is_super_user(ClusterInfo *cluster)
506509
}
507510

508511

512+
/*
513+
* check_for_prepared_transactions()
514+
*
515+
* Make sure there are no prepared transactions because the storage format
516+
* might have changed.
517+
*/
518+
static void
519+
check_for_prepared_transactions(ClusterInfo *cluster)
520+
{
521+
PGresult *res;
522+
PGconn *conn = connectToServer(cluster, "template1");
523+
524+
prep_status("Checking for prepared transactions");
525+
526+
res = executeQueryOrDie(conn,
527+
"SELECT * "
528+
"FROM pg_catalog.pg_prepared_xact()");
529+
530+
if (PQntuples(res) != 0)
531+
pg_log(PG_FATAL, "The %s cluster contains prepared transactions\n",
532+
CLUSTER_NAME(cluster));
533+
534+
PQclear(res);
535+
536+
PQfinish(conn);
537+
538+
check_ok();
539+
}
540+
541+
509542
/*
510543
* check_for_isn_and_int8_passing_mismatch()
511544
*

0 commit comments

Comments
 (0)