PostgreSQL Source Code  git master
pg_upgrade.c
Go to the documentation of this file.
1 /*
2  * pg_upgrade.c
3  *
4  * main source file
5  *
6  * Copyright (c) 2010-2018, PostgreSQL Global Development Group
7  * src/bin/pg_upgrade/pg_upgrade.c
8  */
9 
10 /*
11  * To simplify the upgrade process, we force certain system values to be
12  * identical between old and new clusters:
13  *
14  * We control all assignments of pg_class.oid (and relfilenode) so toast
15  * oids are the same between old and new clusters. This is important
16  * because toast oids are stored as toast pointers in user tables.
17  *
18  * While pg_class.oid and pg_class.relfilenode are initially the same
19  * in a cluster, they can diverge due to CLUSTER, REINDEX, or VACUUM
20  * FULL. In the new cluster, pg_class.oid and pg_class.relfilenode will
21  * be the same and will match the old pg_class.oid value. Because of
22  * this, old/new pg_class.relfilenode values will not match if CLUSTER,
23  * REINDEX, or VACUUM FULL have been performed in the old cluster.
24  *
25  * We control all assignments of pg_type.oid because these oids are stored
26  * in user composite type values.
27  *
28  * We control all assignments of pg_enum.oid because these oids are stored
29  * in user tables as enum values.
30  *
31  * We control all assignments of pg_authid.oid because these oids are stored
32  * in pg_largeobject_metadata.
33  */
34 
35 
36 
37 #include "postgres_fe.h"
38 
39 #include "pg_upgrade.h"
40 #include "catalog/pg_class.h"
42 #include "fe_utils/string_utils.h"
43 
44 #ifdef HAVE_LANGINFO_H
45 #include <langinfo.h>
46 #endif
47 
48 static void prepare_new_cluster(void);
49 static void prepare_new_globals(void);
50 static void create_new_objects(void);
51 static void copy_xact_xlog_xid(void);
52 static void set_frozenxids(bool minmxid_only);
53 static void setup(char *argv0, bool *live_check);
54 static void cleanup(void);
55 
59 
60 char *output_files[] = {
62 #ifdef WIN32
63  /* unique file for pg_ctl start */
65 #endif
68  NULL
69 };
70 
71 
72 int
73 main(int argc, char **argv)
74 {
75  char *analyze_script_file_name = NULL;
76  char *deletion_script_file_name = NULL;
77  bool live_check = false;
78 
79  set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_upgrade"));
80 
81  /* Ensure that all files created by pg_upgrade are non-world-readable */
82  umask(S_IRWXG | S_IRWXO);
83 
84  parseCommandLine(argc, argv);
85 
87 
88  adjust_data_dir(&old_cluster);
89  adjust_data_dir(&new_cluster);
90 
91  setup(argv[0], &live_check);
92 
93  output_check_banner(live_check);
94 
96 
97  get_sock_dir(&old_cluster, live_check);
98  get_sock_dir(&new_cluster, false);
99 
100  check_cluster_compatibility(live_check);
101 
102  check_and_dump_old_cluster(live_check);
103 
104 
105  /* -- NEW -- */
106  start_postmaster(&new_cluster, true);
107 
110 
112  "\n"
113  "Performing Upgrade\n"
114  "------------------\n");
115 
117 
118  stop_postmaster(false);
119 
120  /*
121  * Destructive Changes to New Cluster
122  */
123 
125 
126  /* New now using xids of the old system */
127 
128  /* -- NEW -- */
129  start_postmaster(&new_cluster, true);
130 
132 
134 
135  stop_postmaster(false);
136 
137  /*
138  * Most failures happen in create_new_objects(), which has completed at
139  * this point. We do this here because it is just before linking, which
140  * will link the old and new cluster data files, preventing the old
141  * cluster from being safely started once the new cluster is started.
142  */
145 
146  transfer_all_new_tablespaces(&old_cluster.dbarr, &new_cluster.dbarr,
147  old_cluster.pgdata, new_cluster.pgdata);
148 
149  /*
150  * Assuming OIDs are only used in system tables, there is no need to
151  * restore the OID counter because we have not transferred any OIDs from
152  * the old system, but we do it anyway just in case. We do it late here
153  * because there is no need to have the schema load use new oids.
154  */
155  prep_status("Setting next OID for new cluster");
156  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
157  "\"%s/pg_resetwal\" -o %u \"%s\"",
158  new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid,
159  new_cluster.pgdata);
160  check_ok();
161 
162  prep_status("Sync data directory to disk");
163  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
164  "\"%s/initdb\" --sync-only \"%s\"", new_cluster.bindir,
165  new_cluster.pgdata);
166  check_ok();
167 
168  create_script_for_cluster_analyze(&analyze_script_file_name);
169  create_script_for_old_cluster_deletion(&deletion_script_file_name);
170 
172 
174  "\n"
175  "Upgrade Complete\n"
176  "----------------\n");
177 
178  output_completion_banner(analyze_script_file_name,
179  deletion_script_file_name);
180 
181  pg_free(analyze_script_file_name);
182  pg_free(deletion_script_file_name);
183 
184  cleanup();
185 
186  return 0;
187 }
188 
189 
190 static void
191 setup(char *argv0, bool *live_check)
192 {
193  char exec_path[MAXPGPATH]; /* full path to my executable */
194 
195  /*
196  * make sure the user has a clean environment, otherwise, we may confuse
197  * libpq when we connect to one (or both) of the servers.
198  */
200 
202 
203  /* no postmasters should be running, except for a live check */
204  if (pid_lock_file_exists(old_cluster.pgdata))
205  {
206  /*
207  * If we have a postmaster.pid file, try to start the server. If it
208  * starts, the pid file was stale, so stop the server. If it doesn't
209  * start, assume the server is running. If the pid file is left over
210  * from a server crash, this also allows any committed transactions
211  * stored in the WAL to be replayed so they are not lost, because WAL
212  * files are not transferred from old to new servers.
213  */
214  if (start_postmaster(&old_cluster, false))
215  stop_postmaster(false);
216  else
217  {
218  if (!user_opts.check)
219  pg_fatal("There seems to be a postmaster servicing the old cluster.\n"
220  "Please shutdown that postmaster and try again.\n");
221  else
222  *live_check = true;
223  }
224  }
225 
226  /* same goes for the new postmaster */
227  if (pid_lock_file_exists(new_cluster.pgdata))
228  {
229  if (start_postmaster(&new_cluster, false))
230  stop_postmaster(false);
231  else
232  pg_fatal("There seems to be a postmaster servicing the new cluster.\n"
233  "Please shutdown that postmaster and try again.\n");
234  }
235 
236  /* get path to pg_upgrade executable */
237  if (find_my_exec(argv0, exec_path) < 0)
238  pg_fatal("%s: could not find own program executable\n", argv0);
239 
240  /* Trim off program name and keep just path */
241  *last_dir_separator(exec_path) = '\0';
242  canonicalize_path(exec_path);
243  os_info.exec_path = pg_strdup(exec_path);
244 }
245 
246 
247 static void
249 {
250  /*
251  * It would make more sense to freeze after loading the schema, but that
252  * would cause us to lose the frozenids restored by the load. We use
253  * --analyze so autovacuum doesn't update statistics later
254  */
255  prep_status("Analyzing all rows in the new cluster");
256  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
257  "\"%s/vacuumdb\" %s --all --analyze %s",
258  new_cluster.bindir, cluster_conn_opts(&new_cluster),
259  log_opts.verbose ? "--verbose" : "");
260  check_ok();
261 
262  /*
263  * We do freeze after analyze so pg_statistic is also frozen. template0 is
264  * not frozen here, but data rows were frozen by initdb, and we set its
265  * datfrozenxid, relfrozenxids, and relminmxid later to match the new xid
266  * counter later.
267  */
268  prep_status("Freezing all rows in the new cluster");
269  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
270  "\"%s/vacuumdb\" %s --all --freeze %s",
271  new_cluster.bindir, cluster_conn_opts(&new_cluster),
272  log_opts.verbose ? "--verbose" : "");
273  check_ok();
274 }
275 
276 
277 static void
279 {
280  /*
281  * We set autovacuum_freeze_max_age to its maximum value so autovacuum
282  * does not launch here and delete clog files, before the frozen xids are
283  * set.
284  */
285 
286  set_frozenxids(false);
287 
288  prep_status("Restoring global objects in the new cluster");
289 
290  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
291  "\"%s/psql\" " EXEC_PSQL_ARGS " %s -f \"%s\"",
292  new_cluster.bindir, cluster_conn_opts(&new_cluster),
294  check_ok();
295 }
296 
297 
298 static void
300 {
301  int dbnum;
302 
303  prep_status("Restoring database schemas in the new cluster\n");
304 
305  for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
306  {
307  char sql_file_name[MAXPGPATH],
308  log_file_name[MAXPGPATH];
309  DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
310  const char *create_opts;
311  const char *starting_db;
312 
313  pg_log(PG_STATUS, "%s", old_db->db_name);
314  snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
315  snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
316 
317  /*
318  * template1 and postgres databases will already exist in the target
319  * installation, so tell pg_restore to drop and recreate them;
320  * otherwise we would fail to propagate their database-level
321  * properties.
322  */
323  if (strcmp(old_db->db_name, "template1") == 0 ||
324  strcmp(old_db->db_name, "postgres") == 0)
325  create_opts = "--clean --create";
326  else
327  create_opts = "--create";
328 
329  /* When processing template1, we can't connect there to start with */
330  if (strcmp(old_db->db_name, "template1") == 0)
331  starting_db = "postgres";
332  else
333  starting_db = "template1";
334 
335  parallel_exec_prog(log_file_name,
336  NULL,
337  "\"%s/pg_restore\" %s %s --exit-on-error --verbose "
338  "--dbname %s \"%s\"",
339  new_cluster.bindir,
340  cluster_conn_opts(&new_cluster),
341  create_opts,
342  starting_db,
343  sql_file_name);
344  }
345 
346  /* reap all children */
347  while (reap_child(true) == true)
348  ;
349 
351  check_ok();
352 
353  /*
354  * We don't have minmxids for databases or relations in pre-9.3 clusters,
355  * so set those after we have restored the schema.
356  */
357  if (GET_MAJOR_VERSION(old_cluster.major_version) < 903)
358  set_frozenxids(true);
359 
360  /* update new_cluster info now that we have objects in the databases */
361  get_db_and_rel_infos(&new_cluster);
362 }
363 
364 /*
365  * Delete the given subdirectory contents from the new cluster
366  */
367 static void
368 remove_new_subdir(const char *subdir, bool rmtopdir)
369 {
370  char new_path[MAXPGPATH];
371 
372  prep_status("Deleting files from new %s", subdir);
373 
374  snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
375  if (!rmtree(new_path, rmtopdir))
376  pg_fatal("could not delete directory \"%s\"\n", new_path);
377 
378  check_ok();
379 }
380 
381 /*
382  * Copy the files from the old cluster into it
383  */
384 static void
385 copy_subdir_files(const char *old_subdir, const char *new_subdir)
386 {
387  char old_path[MAXPGPATH];
388  char new_path[MAXPGPATH];
389 
390  remove_new_subdir(new_subdir, true);
391 
392  snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, old_subdir);
393  snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, new_subdir);
394 
395  prep_status("Copying old %s to new server", old_subdir);
396 
397  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
398 #ifndef WIN32
399  "cp -Rf \"%s\" \"%s\"",
400 #else
401  /* flags: everything, no confirm, quiet, overwrite read-only */
402  "xcopy /e /y /q /r \"%s\" \"%s\\\"",
403 #endif
404  old_path, new_path);
405 
406  check_ok();
407 }
408 
409 static void
411 {
412  /*
413  * Copy old commit logs to new data dir. pg_clog has been renamed to
414  * pg_xact in post-10 clusters.
415  */
417  "pg_clog" : "pg_xact",
418  GET_MAJOR_VERSION(new_cluster.major_version) < 1000 ?
419  "pg_clog" : "pg_xact");
420 
421  /* set the next transaction id and epoch of the new cluster */
422  prep_status("Setting next transaction ID and epoch for new cluster");
423  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
424  "\"%s/pg_resetwal\" -f -x %u \"%s\"",
425  new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
426  new_cluster.pgdata);
427  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
428  "\"%s/pg_resetwal\" -f -e %u \"%s\"",
429  new_cluster.bindir, old_cluster.controldata.chkpnt_nxtepoch,
430  new_cluster.pgdata);
431  /* must reset commit timestamp limits also */
432  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
433  "\"%s/pg_resetwal\" -f -c %u,%u \"%s\"",
434  new_cluster.bindir,
435  old_cluster.controldata.chkpnt_nxtxid,
436  old_cluster.controldata.chkpnt_nxtxid,
437  new_cluster.pgdata);
438  check_ok();
439 
440  /*
441  * If the old server is before the MULTIXACT_FORMATCHANGE_CAT_VER change
442  * (see pg_upgrade.h) and the new server is after, then we don't copy
443  * pg_multixact files, but we need to reset pg_control so that the new
444  * server doesn't attempt to read multis older than the cutoff value.
445  */
448  {
449  copy_subdir_files("pg_multixact/offsets", "pg_multixact/offsets");
450  copy_subdir_files("pg_multixact/members", "pg_multixact/members");
451 
452  prep_status("Setting next multixact ID and offset for new cluster");
453 
454  /*
455  * we preserve all files and contents, so we must preserve both "next"
456  * counters here and the oldest multi present on system.
457  */
458  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
459  "\"%s/pg_resetwal\" -O %u -m %u,%u \"%s\"",
460  new_cluster.bindir,
461  old_cluster.controldata.chkpnt_nxtmxoff,
462  old_cluster.controldata.chkpnt_nxtmulti,
463  old_cluster.controldata.chkpnt_oldstMulti,
464  new_cluster.pgdata);
465  check_ok();
466  }
467  else if (new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
468  {
469  /*
470  * Remove offsets/0000 file created by initdb that no longer matches
471  * the new multi-xid value. "members" starts at zero so no need to
472  * remove it.
473  */
474  remove_new_subdir("pg_multixact/offsets", false);
475 
476  prep_status("Setting oldest multixact ID in new cluster");
477 
478  /*
479  * We don't preserve files in this case, but it's important that the
480  * oldest multi is set to the latest value used by the old system, so
481  * that multixact.c returns the empty set for multis that might be
482  * present on disk. We set next multi to the value following that; it
483  * might end up wrapped around (i.e. 0) if the old cluster had
484  * next=MaxMultiXactId, but multixact.c can cope with that just fine.
485  */
486  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
487  "\"%s/pg_resetwal\" -m %u,%u \"%s\"",
488  new_cluster.bindir,
489  old_cluster.controldata.chkpnt_nxtmulti + 1,
490  old_cluster.controldata.chkpnt_nxtmulti,
491  new_cluster.pgdata);
492  check_ok();
493  }
494 
495  /* now reset the wal archives in the new cluster */
496  prep_status("Resetting WAL archives");
497  exec_prog(UTILITY_LOG_FILE, NULL, true, true,
498  /* use timeline 1 to match controldata and no WAL history file */
499  "\"%s/pg_resetwal\" -l 00000001%s \"%s\"", new_cluster.bindir,
500  old_cluster.controldata.nextxlogfile + 8,
501  new_cluster.pgdata);
502  check_ok();
503 }
504 
505 
506 /*
507  * set_frozenxids()
508  *
509  * We have frozen all xids, so set datfrozenxid, relfrozenxid, and
510  * relminmxid to be the old cluster's xid counter, which we just set
511  * in the new cluster. User-table frozenxid and minmxid values will
512  * be set by pg_dump --binary-upgrade, but objects not set by the pg_dump
513  * must have proper frozen counters.
514  */
515 static
516 void
517 set_frozenxids(bool minmxid_only)
518 {
519  int dbnum;
520  PGconn *conn,
521  *conn_template1;
522  PGresult *dbres;
523  int ntups;
524  int i_datname;
525  int i_datallowconn;
526 
527  if (!minmxid_only)
528  prep_status("Setting frozenxid and minmxid counters in new cluster");
529  else
530  prep_status("Setting minmxid counter in new cluster");
531 
532  conn_template1 = connectToServer(&new_cluster, "template1");
533 
534  if (!minmxid_only)
535  /* set pg_database.datfrozenxid */
536  PQclear(executeQueryOrDie(conn_template1,
537  "UPDATE pg_catalog.pg_database "
538  "SET datfrozenxid = '%u'",
539  old_cluster.controldata.chkpnt_nxtxid));
540 
541  /* set pg_database.datminmxid */
542  PQclear(executeQueryOrDie(conn_template1,
543  "UPDATE pg_catalog.pg_database "
544  "SET datminmxid = '%u'",
545  old_cluster.controldata.chkpnt_nxtmulti));
546 
547  /* get database names */
548  dbres = executeQueryOrDie(conn_template1,
549  "SELECT datname, datallowconn "
550  "FROM pg_catalog.pg_database");
551 
552  i_datname = PQfnumber(dbres, "datname");
553  i_datallowconn = PQfnumber(dbres, "datallowconn");
554 
555  ntups = PQntuples(dbres);
556  for (dbnum = 0; dbnum < ntups; dbnum++)
557  {
558  char *datname = PQgetvalue(dbres, dbnum, i_datname);
559  char *datallowconn = PQgetvalue(dbres, dbnum, i_datallowconn);
560 
561  /*
562  * We must update databases where datallowconn = false, e.g.
563  * template0, because autovacuum increments their datfrozenxids,
564  * relfrozenxids, and relminmxid even if autovacuum is turned off, and
565  * even though all the data rows are already frozen. To enable this,
566  * we temporarily change datallowconn.
567  */
568  if (strcmp(datallowconn, "f") == 0)
569  PQclear(executeQueryOrDie(conn_template1,
570  "ALTER DATABASE %s ALLOW_CONNECTIONS = true",
571  quote_identifier(datname)));
572 
573  conn = connectToServer(&new_cluster, datname);
574 
575  if (!minmxid_only)
576  /* set pg_class.relfrozenxid */
578  "UPDATE pg_catalog.pg_class "
579  "SET relfrozenxid = '%u' "
580  /* only heap, materialized view, and TOAST are vacuumed */
581  "WHERE relkind IN ("
585  old_cluster.controldata.chkpnt_nxtxid));
586 
587  /* set pg_class.relminmxid */
589  "UPDATE pg_catalog.pg_class "
590  "SET relminmxid = '%u' "
591  /* only heap, materialized view, and TOAST are vacuumed */
592  "WHERE relkind IN ("
596  old_cluster.controldata.chkpnt_nxtmulti));
597  PQfinish(conn);
598 
599  /* Reset datallowconn flag */
600  if (strcmp(datallowconn, "f") == 0)
601  PQclear(executeQueryOrDie(conn_template1,
602  "ALTER DATABASE %s ALLOW_CONNECTIONS = false",
603  quote_identifier(datname)));
604  }
605 
606  PQclear(dbres);
607 
608  PQfinish(conn_template1);
609 
610  check_ok();
611 }
612 
613 
614 static void
615 cleanup(void)
616 {
617  fclose(log_opts.internal);
618 
619  /* Remove dump and log files? */
620  if (!log_opts.retain)
621  {
622  int dbnum;
623  char **filename;
624 
625  for (filename = output_files; *filename != NULL; filename++)
626  unlink(*filename);
627 
628  /* remove dump files */
629  unlink(GLOBALS_DUMP_FILE);
630 
631  if (old_cluster.dbarr.dbs)
632  for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
633  {
634  char sql_file_name[MAXPGPATH],
635  log_file_name[MAXPGPATH];
636  DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
637 
638  snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
639  unlink(sql_file_name);
640 
641  snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
642  unlink(log_file_name);
643  }
644  }
645 }
void transfer_all_new_tablespaces(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
Definition: relfilenode.c:30
void parallel_exec_prog(const char *log_file, const char *opt_log_file, const char *fmt,...)
Definition: parallel.c:63
static void remove_new_subdir(const char *subdir, bool rmtopdir)
Definition: pg_upgrade.c:368
void parseCommandLine(int argc, char *argv[])
Definition: option.c:38
static char * argv0
Definition: pg_ctl.c:93
uint32 major_version
Definition: pg_upgrade.h:274
static void cleanup(void)
Definition: pg_upgrade.c:615
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:10435
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3118
ControlData controldata
Definition: pg_upgrade.h:264
void check_cluster_versions(void)
Definition: check.c:233
static void prepare_new_cluster(void)
Definition: pg_upgrade.c:248
void get_sock_dir(ClusterInfo *cluster, bool live_check)
Definition: option.c:447
bool pid_lock_file_exists(const char *datadir)
Definition: exec.c:217
static void create_new_objects(void)
Definition: pg_upgrade.c:299
uint32 chkpnt_nxtoid
Definition: pg_upgrade.h:214
#define RELKIND_MATVIEW
Definition: pg_class.h:165
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2
#define GET_MAJOR_VERSION(v)
Definition: pg_upgrade.h:29
char nextxlogfile[25]
Definition: pg_upgrade.h:211
void end_progress_output(void)
Definition: util.c:44
void canonicalize_path(char *path)
Definition: path.c:254
void PQfinish(PGconn *conn)
Definition: fe-connect.c:3638
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
void pg_fatal(const char *fmt,...)
Definition: logging.c:83
void check_cluster_compatibility(bool live_check)
Definition: check.c:275
PGresult char * cluster_conn_opts(ClusterInfo *cluster)
Definition: server.c:88
LogOpts log_opts
Definition: util.c:18
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2724
static void adjust_data_dir(void)
Definition: pg_ctl.c:2059
Oid db_oid
Definition: pg_upgrade.h:186
void get_restricted_token(const char *progname)
ClusterInfo new_cluster
Definition: pg_upgrade.c:56
uint32 chkpnt_nxtmxoff
Definition: pg_upgrade.h:216
void check_pghost_envvar(void)
Definition: server.c:352
uint32 chkpnt_nxtxid
Definition: pg_upgrade.h:212
static void prepare_new_globals(void)
Definition: pg_upgrade.c:278
PGconn * conn
Definition: streamutil.c:46
uint32 chkpnt_nxtepoch
Definition: pg_upgrade.h:213
void output_check_banner(bool live_check)
Definition: check.c:61
#define MAXPGPATH
int find_my_exec(const char *argv0, char *retpath)
Definition: exec.c:119
char * output_files[]
Definition: pg_upgrade.c:60
#define S_IRWXG
Definition: win32_port.h:292
void prep_status(const char *fmt,...) pg_attribute_printf(1
ClusterInfo old_cluster
Definition: pg_upgrade.c:56
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
void pg_log(eLogType type, const char *fmt,...)
Definition: logging.c:69
static void check_ok(void)
Definition: initdb.c:2051
#define DB_DUMP_FILE_MASK
Definition: pg_upgrade.h:33
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
Definition: server.c:27
void create_script_for_old_cluster_deletion(char **deletion_script_file_name)
Definition: check.c:517
transferMode transfer_mode
Definition: pg_upgrade.h:299
uint32 chkpnt_oldstMulti
Definition: pg_upgrade.h:217
UserOpts user_opts
Definition: option.c:29
static void copy_subdir_files(const char *old_subdir, const char *new_subdir)
Definition: pg_upgrade.c:385
bool verbose
Definition: pg_upgrade.h:287
char * bindir
Definition: pg_upgrade.h:269
bool rmtree(const char *path, bool rmtopdir)
Definition: rmtree.c:36
#define CppAsString2(x)
Definition: c.h:224
uint32 cat_ver
Definition: pg_upgrade.h:210
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1043
#define RELKIND_TOASTVALUE
Definition: pg_class.h:163
uint32 chkpnt_nxtmulti
Definition: pg_upgrade.h:215
static void set_frozenxids(bool minmxid_only)
Definition: pg_upgrade.c:517
int PQfnumber(const PGresult *res, const char *field_name)
Definition: fe-exec.c:2832
static void setup(char *argv0, bool *live_check)
Definition: pg_upgrade.c:191
void stop_postmaster(bool in_atexit)
Definition: server.c:325
#define INTERNAL_LOG_FILE
Definition: pg_upgrade.h:38
char * last_dir_separator(const char *filename)
Definition: path.c:138
void PQclear(PGresult *res)
Definition: fe-exec.c:671
#define SERVER_LOG_FILE
Definition: pg_upgrade.h:36
DbInfoArr dbarr
Definition: pg_upgrade.h:265
const char * progname
Definition: pg_upgrade.h:309
void get_db_and_rel_infos(ClusterInfo *cluster)
Definition: info.c:311
void verify_directories(void)
Definition: exec.c:248
FILE * internal
Definition: pg_upgrade.h:286
int main(int argc, char **argv)
Definition: pg_upgrade.c:73
static char * exec_path
Definition: pg_ctl.c:88
bool check
Definition: pg_upgrade.h:297
void pg_free(void *ptr)
Definition: fe_memutils.c:105
#define MULTIXACT_FORMATCHANGE_CAT_VER
Definition: pg_upgrade.h:121
#define DB_DUMP_LOG_FILE_MASK
Definition: pg_upgrade.h:35
bool reap_child(bool wait_for_child)
Definition: parallel.c:289
static pgpid_t start_postmaster(void)
Definition: pg_ctl.c:443
#define SERVER_START_LOG_FILE
Definition: pg_upgrade.h:59
#define UTILITY_LOG_FILE
Definition: pg_upgrade.h:37
static char * filename
Definition: pg_dumpall.c:85
char * pgdata
Definition: pg_upgrade.h:266
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition: exec.c:550
void disable_old_cluster(void)
Definition: controldata.c:609
#define EXEC_PSQL_ARGS
Definition: pg_upgrade.h:360
OSInfo os_info
Definition: pg_upgrade.c:58
char * db_name
Definition: pg_upgrade.h:187
void output_completion_banner(char *analyze_script_file_name, char *deletion_script_file_name)
Definition: check.c:202
void create_script_for_cluster_analyze(char **analyze_script_file_name)
Definition: check.c:427
void check_new_cluster(void)
Definition: check.c:143
bool exec_prog(const char *log_file, const char *opt_log_file, bool report_error, bool exit_on_error, const char *fmt,...)
Definition: exec.c:80
#define GLOBALS_DUMP_FILE
Definition: pg_upgrade.h:32
void check_and_dump_old_cluster(bool live_check)
Definition: check.c:79
void report_clusters_compatible(void)
Definition: check.c:162
void issue_warnings_and_set_wal_level(void)
Definition: check.c:179
DbInfo * dbs
Definition: pg_upgrade.h:198
bool retain
Definition: pg_upgrade.h:288
#define RELKIND_RELATION
Definition: pg_class.h:160
#define S_IRWXO
Definition: win32_port.h:304
static void copy_xact_xlog_xid(void)
Definition: pg_upgrade.c:410
char * exec_path
Definition: pg_upgrade.h:310