pg_upgrade_greenplum.h 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#ifndef PG_UPGRADE_GREENPLUM_H
#define PG_UPGRADE_GREENPLUM_H
/*
 *	greenplum/pg_upgrade_greenplum.h
 *
 *	Portions Copyright (c) 2019-Present, Pivotal Software Inc
 *	contrib/pg_upgrade/greenplum/pg_upgrade_greenplum.h
 */


#include "pg_upgrade.h"
B
wip  
Bhuvnesh Chaudhary 已提交
12
#include <portability/instr_time.h>
13

14

15
#define PG_OPTIONS_UTILITY_MODE " PGOPTIONS='-c gp_session_role=utility' "
16

17

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 * Enumeration for operations in the progress report
 */
typedef enum
{
	CHECK,
	SCHEMA_DUMP,
	SCHEMA_RESTORE,
	FILE_MAP,
	FILE_COPY,
	FIXUP,
	ABORT,
	DONE
} progress_type;

33 34 35 36 37 38 39
typedef enum
{
	CHECKSUM_NONE = 0,
	CHECKSUM_ADD,
	CHECKSUM_REMOVE
} checksumMode;

40 41 42 43 44 45 46
typedef enum {
	GREENPLUM_MODE_OPTION = 1,
	GREENPLUM_PROGRESS_OPTION = 2,
	GREENPLUM_ADD_CHECKSUM_OPTION = 3,
	GREENPLUM_REMOVE_CHECKSUM_OPTION = 4,
	GREENPLUM_OLD_GP_DBID = 5,
	GREENPLUM_NEW_GP_DBID = 6,
B
wip  
Bhuvnesh Chaudhary 已提交
47 48
	GREENPLUM_OLD_TABLESPACES_FILE = 7,
	GREENPLUM_TIMING = 8,
49
} greenplumOption;
50 51 52 53 54 55


#define GREENPLUM_OPTIONS \
	{"mode", required_argument, NULL, GREENPLUM_MODE_OPTION}, \
	{"progress", no_argument, NULL, GREENPLUM_PROGRESS_OPTION}, \
	{"add-checksum", no_argument, NULL, GREENPLUM_ADD_CHECKSUM_OPTION}, \
56 57 58
	{"remove-checksum", no_argument, NULL, GREENPLUM_REMOVE_CHECKSUM_OPTION}, \
	{"old-gp-dbid", required_argument, NULL, GREENPLUM_OLD_GP_DBID}, \
	{"new-gp-dbid", required_argument, NULL, GREENPLUM_NEW_GP_DBID}, \
B
wip  
Bhuvnesh Chaudhary 已提交
59 60
	{"old-tablespaces-file", required_argument, NULL, GREENPLUM_OLD_TABLESPACES_FILE}, \
	{"timing", no_argument, NULL, GREENPLUM_TIMING},
61 62 63 64 65 66 67 68 69

#define GREENPLUM_USAGE "\
      --mode=TYPE               designate node type to upgrade, \"segment\" or \"dispatcher\" (default \"segment\")\n\
      --progress                enable progress reporting\n\
      --remove-checksum         remove data checksums when creating new cluster\n\
      --add-checksum            add data checksumming to the new cluster\n\
      --old-gp-dbid             greenplum database id of the old segment\n\
      --new-gp-dbid             greenplum database id of the new segment\n\
      --old-tablespaces-file    file containing the tablespaces from an old gpdb five cluster\n\
B
wip  
Bhuvnesh Chaudhary 已提交
70
      --timing                  enable timing\n\
71 72 73 74
"

/* option_gp.c */
void initialize_greenplum_user_options(void);
75
bool process_greenplum_option(greenplumOption option, char *option_value);
76
bool is_greenplum_dispatcher_mode(void);
77 78 79
bool is_checksum_mode(checksumMode mode);
bool is_show_progress_mode(void);
void validate_greenplum_options(void);
B
wip  
Bhuvnesh Chaudhary 已提交
80
bool is_timing_on(void);
81

82
/* pg_upgrade_greenplum.c */
B
Bhuvnesh Chaudhary 已提交
83
void freeze_all_databases(void);
84 85
void reset_system_identifier(void);

B
Bhuvnesh Chaudhary 已提交
86 87
/* frozenxids_gp.c */
void update_segment_db_xids(void);
88

89 90 91
/* aotable.c */

void		restore_aosegment_tables(void);
92 93
bool        is_appendonly(char relstorage);

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

/* gpdb4_heap_convert.c */

const char *convert_gpdb4_heap_file(const char *src, const char *dst,
                                    bool has_numerics, AttInfo *atts, int natts);
void		finish_gpdb4_page_converter(void);

/* file_gp.c */

const char * rewriteHeapPageChecksum( const char *fromfile, const char *tofile,
                                      const char *schemaName, const char *relName);

/* version_gp.c */

void old_GPDB4_check_for_money_data_type_usage(void);
void old_GPDB4_check_no_free_aoseg(void);
void check_hash_partition_usage(void);
void new_gpdb5_0_invalidate_indexes(void);
Oid *get_numeric_types(PGconn *conn);
void old_GPDB5_check_for_unsupported_distribution_key_data_types(void);
114 115
void invalidate_indexes(void);
void reset_invalid_indexes(void);
116 117 118 119 120 121 122 123 124 125

/* check_gp.c */

void check_greenplum(void);

/* reporting.c */

void report_progress(ClusterInfo *cluster, progress_type op, char *fmt,...)
pg_attribute_printf(3, 4);
void close_progress(void);
B
wip  
Bhuvnesh Chaudhary 已提交
126
void duration(instr_time duration, char *res);
127

128
/* tablespace_gp.c */
129

130 131 132
void generate_old_tablespaces_file(ClusterInfo *oldCluster);
void populate_gpdb6_cluster_tablespace_suffix(ClusterInfo *cluster);
bool is_gpdb_version_with_filespaces(ClusterInfo *cluster);
133
void populate_os_info_with_file_contents(void);
134

135 136 137
/* server_gp.c */
char *greenplum_extra_pg_ctl_flags(GreenplumClusterInfo *info);

138 139 140 141 142 143
static inline bool
is_gpdb6(ClusterInfo *cluster)
{
	return GET_MAJOR_VERSION(cluster->major_version) == 904;
}

B
wip  
Bhuvnesh Chaudhary 已提交
144 145 146 147 148 149 150
static struct {
	instr_time start_time;
	instr_time end_time;
} step_timing;

void check_ok_with_timing(void);

151
#endif /* PG_UPGRADE_GREENPLUM_H */