10
10
#include "pg_upgrade.h"
11
11
12
12
13
- static void set_locale_and_encoding (Cluster whichCluster );
13
+ static void set_locale_and_encoding (ClusterInfo * cluster );
14
14
static void check_new_db_is_empty (void );
15
15
static void check_locale_and_encoding (ControlData * oldctrl ,
16
16
ControlData * 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 );
20
19
21
20
22
21
void
@@ -46,14 +45,14 @@ check_old_cluster(bool live_check,
46
45
/* -- OLD -- */
47
46
48
47
if (!live_check )
49
- start_postmaster (CLUSTER_OLD , false);
48
+ start_postmaster (& old_cluster , false);
50
49
51
- set_locale_and_encoding (CLUSTER_OLD );
50
+ set_locale_and_encoding (& old_cluster );
52
51
53
- get_pg_database_relfilenode (CLUSTER_OLD );
52
+ get_pg_database_relfilenode (& old_cluster );
54
53
55
54
/* 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 );
57
56
58
57
init_tablespaces ();
59
58
@@ -64,19 +63,19 @@ check_old_cluster(bool live_check,
64
63
* Check for various failure cases
65
64
*/
66
65
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 );
69
68
70
69
/* old = PG 8.3 checks? */
71
70
if (GET_MAJOR_VERSION (old_cluster .major_version ) <= 803 )
72
71
{
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 );
75
74
if (user_opts .check )
76
75
{
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 );
80
79
}
81
80
else
82
81
@@ -86,12 +85,12 @@ check_old_cluster(bool live_check,
86
85
* end.
87
86
*/
88
87
* sequence_script_file_name =
89
- old_8_3_create_sequence_script (CLUSTER_OLD );
88
+ old_8_3_create_sequence_script (& old_cluster );
90
89
}
91
90
92
91
/* Pre-PG 9.0 had no large object permissions */
93
92
if (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 );
95
94
96
95
/*
97
96
* 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,
111
110
void
112
111
check_new_cluster (void )
113
112
{
114
- set_locale_and_encoding (CLUSTER_NEW );
113
+ set_locale_and_encoding (& new_cluster );
115
114
116
115
check_new_db_is_empty ();
117
116
@@ -149,7 +148,7 @@ issue_warnings(char *sequence_script_file_name)
149
148
/* old = PG 8.3 warnings? */
150
149
if (GET_MAJOR_VERSION (old_cluster .major_version ) <= 803 )
151
150
{
152
- start_postmaster (CLUSTER_NEW , true);
151
+ start_postmaster (& new_cluster , true);
153
152
154
153
/* restore proper sequence values using file created from old server */
155
154
if (sequence_script_file_name )
@@ -165,17 +164,17 @@ issue_warnings(char *sequence_script_file_name)
165
164
check_ok ();
166
165
}
167
166
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 );
171
170
stop_postmaster (false, true);
172
171
}
173
172
174
173
/* Create dummy large object permissions for old < PG 9.0? */
175
174
if (GET_MAJOR_VERSION (old_cluster .major_version ) <= 804 )
176
175
{
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 );
179
178
stop_postmaster (false, true);
180
179
}
181
180
}
210
209
check_cluster_versions (void )
211
210
{
212
211
/* 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 );
215
214
216
215
/* We allow upgrades from/to the same major version for alpha/beta upgrades */
217
216
@@ -270,16 +269,15 @@ check_cluster_compatibility(bool live_check)
270
269
* query the database to get the template0 locale
271
270
*/
272
271
static void
273
- set_locale_and_encoding (Cluster whichCluster )
272
+ set_locale_and_encoding (ClusterInfo * cluster )
274
273
{
275
- ClusterInfo * active_cluster = ACTIVE_CLUSTER (whichCluster );
276
- ControlData * ctrl = & active_cluster -> controldata ;
274
+ ControlData * ctrl = & cluster -> controldata ;
277
275
PGconn * conn ;
278
276
PGresult * res ;
279
277
int i_encoding ;
280
- int cluster_version = active_cluster -> major_version ;
278
+ int cluster_version = cluster -> major_version ;
281
279
282
- conn = connectToServer ("template1" , whichCluster );
280
+ conn = connectToServer (cluster , "template1" );
283
281
284
282
/* for pg < 80400, we got the values from pg_controldata */
285
283
if (cluster_version >= 80400 )
@@ -345,7 +343,7 @@ check_new_db_is_empty(void)
345
343
int dbnum ;
346
344
bool found = false;
347
345
348
- get_db_and_rel_infos (& new_cluster . dbarr , CLUSTER_NEW );
346
+ get_db_and_rel_infos (& new_cluster );
349
347
350
348
for (dbnum = 0 ; dbnum < new_cluster .dbarr .ndbs ; dbnum ++ )
351
349
{
@@ -457,9 +455,8 @@ create_script_for_old_cluster_deletion(
457
455
* it must match for the old and new servers.
458
456
*/
459
457
void
460
- check_for_isn_and_int8_passing_mismatch (Cluster whichCluster )
458
+ check_for_isn_and_int8_passing_mismatch (ClusterInfo * cluster )
461
459
{
462
- ClusterInfo * active_cluster = ACTIVE_CLUSTER (whichCluster );
463
460
int dbnum ;
464
461
FILE * script = NULL ;
465
462
bool found = false;
@@ -478,16 +475,16 @@ check_for_isn_and_int8_passing_mismatch(Cluster whichCluster)
478
475
snprintf (output_path , sizeof (output_path ), "%s/contrib_isn_and_int8_pass_by_value.txt" ,
479
476
os_info .cwd );
480
477
481
- for (dbnum = 0 ; dbnum < active_cluster -> dbarr .ndbs ; dbnum ++ )
478
+ for (dbnum = 0 ; dbnum < cluster -> dbarr .ndbs ; dbnum ++ )
482
479
{
483
480
PGresult * res ;
484
481
bool db_used = false;
485
482
int ntups ;
486
483
int rowno ;
487
484
int i_nspname ,
488
485
i_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 );
491
488
492
489
/* Find any functions coming from contrib/isn */
493
490
res = executeQueryOrDie (conn ,
@@ -552,9 +549,8 @@ check_for_isn_and_int8_passing_mismatch(Cluster whichCluster)
552
549
* tables upgraded by pg_upgrade.
553
550
*/
554
551
void
555
- check_for_reg_data_type_usage (Cluster whichCluster )
552
+ check_for_reg_data_type_usage (ClusterInfo * cluster )
556
553
{
557
- ClusterInfo * active_cluster = ACTIVE_CLUSTER (whichCluster );
558
554
int dbnum ;
559
555
FILE * script = NULL ;
560
556
bool found = false;
@@ -565,7 +561,7 @@ check_for_reg_data_type_usage(Cluster whichCluster)
565
561
snprintf (output_path , sizeof (output_path ), "%s/tables_using_reg.txt" ,
566
562
os_info .cwd );
567
563
568
- for (dbnum = 0 ; dbnum < active_cluster -> dbarr .ndbs ; dbnum ++ )
564
+ for (dbnum = 0 ; dbnum < cluster -> dbarr .ndbs ; dbnum ++ )
569
565
{
570
566
PGresult * res ;
571
567
bool db_used = false;
@@ -574,8 +570,8 @@ check_for_reg_data_type_usage(Cluster whichCluster)
574
570
int i_nspname ,
575
571
i_relname ,
576
572
i_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 );
579
575
580
576
res = executeQueryOrDie (conn ,
581
577
"SELECT n.nspname, c.relname, a.attname "
0 commit comments