PostgreSQL Source Code: src/bin/pg_upgrade/version.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

11

14

15

16

17

18

19

20bool

22{

23

26 return true;

27

28 return false;

29}

30

31

32

33

34

35

36void

38{

39 int dbnum;

40 FILE *script = NULL;

41 bool found = false;

42 char *output_path = "reindex_hash.sql";

43

45

46 for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)

47 {

49 bool db_used = false;

50 int ntups;

51 int rowno;

52 int i_nspname,

53 i_relname;

56

57

59 "SELECT n.nspname, c.relname "

60 "FROM pg_catalog.pg_class c, "

61 " pg_catalog.pg_index i, "

62 " pg_catalog.pg_am a, "

63 " pg_catalog.pg_namespace n "

64 "WHERE i.indexrelid = c.oid AND "

65 " c.relam = a.oid AND "

66 " c.relnamespace = n.oid AND "

67 " a.amname = 'hash'"

68 );

69

71 i_nspname = PQfnumber(res, "nspname");

72 i_relname = PQfnumber(res, "relname");

73 for (rowno = 0; rowno < ntups; rowno++)

74 {

75 found = true;

76 if (!check_mode)

77 {

78 if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)

79 pg_fatal("could not open file \"%s\": %m", output_path);

80 if (!db_used)

81 {

83

86 fputs(connectbuf.data, script);

88 db_used = true;

89 }

90 fprintf(script, "REINDEX INDEX %s.%s;\n",

93 }

94 }

95

97

98 if (!check_mode && db_used)

99 {

100

102 "UPDATE pg_catalog.pg_index i "

103 "SET indisvalid = false "

104 "FROM pg_catalog.pg_class c, "

105 " pg_catalog.pg_am a, "

106 " pg_catalog.pg_namespace n "

107 "WHERE i.indexrelid = c.oid AND "

108 " c.relam = a.oid AND "

109 " c.relnamespace = n.oid AND "

110 " a.amname = 'hash'"));

111 }

112

114 }

115

116 if (script)

117 fclose(script);

118

119 if (found)

120 {

122 if (check_mode)

124 "Your installation contains hash indexes. These indexes have different\n"

125 "internal formats between your old and new clusters, so they must be\n"

126 "reindexed with the REINDEX command. After upgrading, you will be given\n"

127 "REINDEX instructions.");

128 else

130 "Your installation contains hash indexes. These indexes have different\n"

131 "internal formats between your old and new clusters, so they must be\n"

132 "reindexed with the REINDEX command. The file\n"

133 " %s\n"

134 "when executed by psql by the database superuser will recreate all invalid\n"

135 "indexes; until then, none of these indexes will be used.",

136 output_path);

137 }

138 else

140}

141

142

143

144

145

146

147static void

149{

151 int i_name = PQfnumber(res, "name");

154

156

157 if (ntups == 0)

158 return;

159

160 if (report->file == NULL &&

162 pg_fatal("could not open file \"%s\": %m", report->path);

163

166 fputs(connectbuf.data, report->file);

168

169 for (int rowno = 0; rowno < ntups; rowno++)

170 fprintf(report->file, "ALTER EXTENSION %s UPDATE;\n",

172}

173

174

175

176

177

178void

180{

183 const char *query = "SELECT name "

184 "FROM pg_available_extensions "

185 "WHERE installed_version != default_version";

186

187 prep_status("Checking for extension updates");

188

189 report.file = NULL;

190 strcpy(report.path, "update_extensions.sql");

191

193 true, &report);

194

197

198 if (report.file)

199 {

200 fclose(report.file);

203 "Your installation contains extensions that should be updated\n"

204 "with the ALTER EXTENSION command. The file\n"

205 " %s\n"

206 "when executed by psql by the database superuser will update\n"

207 "these extensions.",

208 report.path);

209 }

210 else

212}

bool jsonb_9_4_check_applicable(ClusterInfo *cluster)

void report_extension_updates(ClusterInfo *cluster)

static void process_extension_updates(DbInfo *dbinfo, PGresult *res, void *arg)

void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)

#define AssertVariableIsOfType(varname, typename)

void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)

#define fprintf(file, fmt, msg)

void PQfinish(PGconn *conn)

char * PQgetvalue(const PGresult *res, int tup_num, int field_num)

void PQclear(PGresult *res)

int PQntuples(const PGresult *res)

int PQfnumber(const PGresult *res, const char *field_name)

static void check_ok(void)

UpgradeTask * upgrade_task_create(void)

PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)

void upgrade_task_run(const UpgradeTask *task, const ClusterInfo *cluster)

void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2

PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2

void upgrade_task_free(UpgradeTask *task)

#define fopen_priv(path, mode)

void(* UpgradeTaskProcessCB)(DbInfo *dbinfo, PGresult *res, void *arg)

#define GET_MAJOR_VERSION(v)

void prep_status(const char *fmt,...) pg_attribute_printf(1

void report_status(eLogType type, const char *fmt,...) pg_attribute_printf(2

void upgrade_task_add_step(UpgradeTask *task, const char *query, UpgradeTaskProcessCB process_cb, bool free_result, void *arg)

#define JSONB_FORMAT_CHANGE_CAT_VER

void initPQExpBuffer(PQExpBuffer str)

void termPQExpBuffer(PQExpBuffer str)

const char * quote_identifier(const char *ident)

void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname)