1010#include "pg_upgrade.h"
1111
1212
13- static void set_locale_and_encoding (Cluster whichCluster );
13+ static void set_locale_and_encoding (ClusterInfo * cluster );
1414static void check_new_db_is_empty (void );
1515static void check_locale_and_encoding (ControlData * oldctrl ,
1616ControlData * newctrl );
17- static void check_for_isn_and_int8_passing_mismatch (
18- Cluster whichCluster );
19- static void check_for_reg_data_type_usage (Cluster whichCluster );
17+ static void check_for_isn_and_int8_passing_mismatch (ClusterInfo * cluster );
18+ static void check_for_reg_data_type_usage (ClusterInfo * cluster );
2019
2120
2221void
@@ -46,14 +45,14 @@ check_old_cluster(bool live_check,
4645/* -- OLD -- */
4746
4847if (!live_check )
49- start_postmaster (CLUSTER_OLD , false);
48+ start_postmaster (& old_cluster , false);
5049
51- set_locale_and_encoding (CLUSTER_OLD );
50+ set_locale_and_encoding (& old_cluster );
5251
53- get_pg_database_relfilenode (CLUSTER_OLD );
52+ get_pg_database_relfilenode (& old_cluster );
5453
5554/* Extract a list of databases and tables from the old cluster */
56- get_db_and_rel_infos (& old_cluster . dbarr , CLUSTER_OLD );
55+ get_db_and_rel_infos (& old_cluster );
5756
5857init_tablespaces ();
5958
@@ -64,19 +63,19 @@ check_old_cluster(bool live_check,
6463 * Check for various failure cases
6564 */
6665
67- check_for_reg_data_type_usage (CLUSTER_OLD );
68- check_for_isn_and_int8_passing_mismatch (CLUSTER_OLD );
66+ check_for_reg_data_type_usage (& old_cluster );
67+ check_for_isn_and_int8_passing_mismatch (& old_cluster );
6968
7069/* old = PG 8.3 checks? */
7170if (GET_MAJOR_VERSION (old_cluster .major_version ) <=803 )
7271{
73- old_8_3_check_for_name_data_type_usage (CLUSTER_OLD );
74- old_8_3_check_for_tsquery_usage (CLUSTER_OLD );
72+ old_8_3_check_for_name_data_type_usage (& old_cluster );
73+ old_8_3_check_for_tsquery_usage (& old_cluster );
7574if (user_opts .check )
7675{
77- old_8_3_rebuild_tsvector_tables (true, CLUSTER_OLD );
78- old_8_3_invalidate_hash_gin_indexes (true, CLUSTER_OLD );
79- old_8_3_invalidate_bpchar_pattern_ops_indexes (true, CLUSTER_OLD );
76+ old_8_3_rebuild_tsvector_tables (& old_cluster , true );
77+ old_8_3_invalidate_hash_gin_indexes (& old_cluster , true );
78+ old_8_3_invalidate_bpchar_pattern_ops_indexes (& old_cluster , true );
8079}
8180else
8281
@@ -86,12 +85,12 @@ check_old_cluster(bool live_check,
8685 * end.
8786 */
8887* sequence_script_file_name =
89- old_8_3_create_sequence_script (CLUSTER_OLD );
88+ old_8_3_create_sequence_script (& old_cluster );
9089}
9190
9291/* Pre-PG 9.0 had no large object permissions */
9392if (GET_MAJOR_VERSION (old_cluster .major_version ) <=804 )
94- new_9_0_populate_pg_largeobject_metadata (true, CLUSTER_OLD );
93+ new_9_0_populate_pg_largeobject_metadata (& old_cluster , true );
9594
9695/*
9796 * While not a check option, we do this now because this is the only time
@@ -111,7 +110,7 @@ check_old_cluster(bool live_check,
111110void
112111check_new_cluster (void )
113112{
114- set_locale_and_encoding (CLUSTER_NEW );
113+ set_locale_and_encoding (& new_cluster );
115114
116115check_new_db_is_empty ();
117116
@@ -149,7 +148,7 @@ issue_warnings(char *sequence_script_file_name)
149148/* old = PG 8.3 warnings? */
150149if (GET_MAJOR_VERSION (old_cluster .major_version ) <=803 )
151150{
152- start_postmaster (CLUSTER_NEW , true);
151+ start_postmaster (& new_cluster , true);
153152
154153/* restore proper sequence values using file created from old server */
155154if (sequence_script_file_name )
@@ -165,17 +164,17 @@ issue_warnings(char *sequence_script_file_name)
165164check_ok ();
166165}
167166
168- old_8_3_rebuild_tsvector_tables (false, CLUSTER_NEW );
169- old_8_3_invalidate_hash_gin_indexes (false, CLUSTER_NEW );
170- old_8_3_invalidate_bpchar_pattern_ops_indexes (false, CLUSTER_NEW );
167+ old_8_3_rebuild_tsvector_tables (& new_cluster , false );
168+ old_8_3_invalidate_hash_gin_indexes (& new_cluster , false );
169+ old_8_3_invalidate_bpchar_pattern_ops_indexes (& new_cluster , false );
171170stop_postmaster (false, true);
172171}
173172
174173/* Create dummy large object permissions for old < PG 9.0? */
175174if (GET_MAJOR_VERSION (old_cluster .major_version ) <=804 )
176175{
177- start_postmaster (CLUSTER_NEW , true);
178- new_9_0_populate_pg_largeobject_metadata (false, CLUSTER_NEW );
176+ start_postmaster (& new_cluster , true);
177+ new_9_0_populate_pg_largeobject_metadata (& new_cluster , false );
179178stop_postmaster (false, true);
180179}
181180}
210209check_cluster_versions (void )
211210{
212211/* get old and new cluster versions */
213- old_cluster .major_version = get_major_server_version (& old_cluster . major_version_str , CLUSTER_OLD );
214- new_cluster .major_version = get_major_server_version (& new_cluster . major_version_str , CLUSTER_NEW );
212+ old_cluster .major_version = get_major_server_version (& old_cluster , & old_cluster . major_version_str );
213+ new_cluster .major_version = get_major_server_version (& new_cluster , & new_cluster . major_version_str );
215214
216215/* We allow upgrades from/to the same major version for alpha/beta upgrades */
217216
@@ -270,16 +269,15 @@ check_cluster_compatibility(bool live_check)
270269 * query the database to get the template0 locale
271270 */
272271static void
273- set_locale_and_encoding (Cluster whichCluster )
272+ set_locale_and_encoding (ClusterInfo * cluster )
274273{
275- ClusterInfo * active_cluster = ACTIVE_CLUSTER (whichCluster );
276- ControlData * ctrl = & active_cluster -> controldata ;
274+ ControlData * ctrl = & cluster -> controldata ;
277275PGconn * conn ;
278276PGresult * res ;
279277int i_encoding ;
280- int cluster_version = active_cluster -> major_version ;
278+ int cluster_version = cluster -> major_version ;
281279
282- conn = connectToServer ("template1" , whichCluster );
280+ conn = connectToServer (cluster , "template1" );
283281
284282/* for pg < 80400, we got the values from pg_controldata */
285283if (cluster_version >=80400 )
@@ -345,7 +343,7 @@ check_new_db_is_empty(void)
345343int dbnum ;
346344bool found = false;
347345
348- get_db_and_rel_infos (& new_cluster . dbarr , CLUSTER_NEW );
346+ get_db_and_rel_infos (& new_cluster );
349347
350348for (dbnum = 0 ;dbnum < new_cluster .dbarr .ndbs ;dbnum ++ )
351349{
@@ -457,9 +455,8 @@ create_script_for_old_cluster_deletion(
457455 *it must match for the old and new servers.
458456 */
459457void
460- check_for_isn_and_int8_passing_mismatch (Cluster whichCluster )
458+ check_for_isn_and_int8_passing_mismatch (ClusterInfo * cluster )
461459{
462- ClusterInfo * active_cluster = ACTIVE_CLUSTER (whichCluster );
463460int dbnum ;
464461FILE * script = NULL ;
465462bool found = false;
@@ -478,16 +475,16 @@ check_for_isn_and_int8_passing_mismatch(Cluster whichCluster)
478475snprintf (output_path ,sizeof (output_path ),"%s/contrib_isn_and_int8_pass_by_value.txt" ,
479476os_info .cwd );
480477
481- for (dbnum = 0 ;dbnum < active_cluster -> dbarr .ndbs ;dbnum ++ )
478+ for (dbnum = 0 ;dbnum < cluster -> dbarr .ndbs ;dbnum ++ )
482479{
483480PGresult * res ;
484481bool db_used = false;
485482int ntups ;
486483int rowno ;
487484int i_nspname ,
488485i_proname ;
489- DbInfo * active_db = & active_cluster -> dbarr .dbs [dbnum ];
490- PGconn * conn = connectToServer (active_db -> db_name , whichCluster );
486+ DbInfo * active_db = & cluster -> dbarr .dbs [dbnum ];
487+ PGconn * conn = connectToServer (cluster , active_db -> db_name );
491488
492489/* Find any functions coming from contrib/isn */
493490res = executeQueryOrDie (conn ,
@@ -552,9 +549,8 @@ check_for_isn_and_int8_passing_mismatch(Cluster whichCluster)
552549 *tables upgraded by pg_upgrade.
553550 */
554551void
555- check_for_reg_data_type_usage (Cluster whichCluster )
552+ check_for_reg_data_type_usage (ClusterInfo * cluster )
556553{
557- ClusterInfo * active_cluster = ACTIVE_CLUSTER (whichCluster );
558554int dbnum ;
559555FILE * script = NULL ;
560556bool found = false;
@@ -565,7 +561,7 @@ check_for_reg_data_type_usage(Cluster whichCluster)
565561snprintf (output_path ,sizeof (output_path ),"%s/tables_using_reg.txt" ,
566562os_info .cwd );
567563
568- for (dbnum = 0 ;dbnum < active_cluster -> dbarr .ndbs ;dbnum ++ )
564+ for (dbnum = 0 ;dbnum < cluster -> dbarr .ndbs ;dbnum ++ )
569565{
570566PGresult * res ;
571567bool db_used = false;
@@ -574,8 +570,8 @@ check_for_reg_data_type_usage(Cluster whichCluster)
574570int i_nspname ,
575571i_relname ,
576572i_attname ;
577- DbInfo * active_db = & active_cluster -> dbarr .dbs [dbnum ];
578- PGconn * conn = connectToServer (active_db -> db_name , whichCluster );
573+ DbInfo * active_db = & cluster -> dbarr .dbs [dbnum ];
574+ PGconn * conn = connectToServer (cluster , active_db -> db_name );
579575
580576res = executeQueryOrDie (conn ,
581577"SELECT n.nspname, c.relname, a.attname "