PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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"
41 #include "fe_utils/string_utils.h"
42 
43 #ifdef HAVE_LANGINFO_H
44 #include <langinfo.h>
45 #endif
46 
47 static void prepare_new_cluster(void);
48 static void prepare_new_databases(void);
49 static void create_new_objects(void);
50 static void copy_clog_xlog_xid(void);
51 static void set_frozenxids(bool minmxid_only);
52 static void setup(char *argv0, bool *live_check);
53 static void cleanup(void);
54 
58 
59 char *output_files[] = {
61 #ifdef WIN32
62  /* unique file for pg_ctl start */
64 #endif
67  NULL
68 };
69 
70 
71 int
72 main(int argc, char **argv)
73 {
74  char *analyze_script_file_name = NULL;
75  char *deletion_script_file_name = NULL;
76  bool live_check = false;
77 
78  set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_upgrade"));
79  parseCommandLine(argc, argv);
80 
82 
83  adjust_data_dir(&old_cluster);
84  adjust_data_dir(&new_cluster);
85 
86  setup(argv[0], &live_check);
87 
88  output_check_banner(live_check);
89 
91 
92  get_sock_dir(&old_cluster, live_check);
93  get_sock_dir(&new_cluster, false);
94 
95  check_cluster_compatibility(live_check);
96 
97  check_and_dump_old_cluster(live_check);
98 
99 
100  /* -- NEW -- */
101  start_postmaster(&new_cluster, true);
102 
105 
106  pg_log(PG_REPORT, "\nPerforming Upgrade\n");
107  pg_log(PG_REPORT, "------------------\n");
108 
110 
111  stop_postmaster(false);
112 
113  /*
114  * Destructive Changes to New Cluster
115  */
116 
118 
119  /* New now using xids of the old system */
120 
121  /* -- NEW -- */
122  start_postmaster(&new_cluster, true);
123 
125 
127 
128  stop_postmaster(false);
129 
130  /*
131  * Most failures happen in create_new_objects(), which has completed at
132  * this point. We do this here because it is just before linking, which
133  * will link the old and new cluster data files, preventing the old
134  * cluster from being safely started once the new cluster is started.
135  */
138 
139  transfer_all_new_tablespaces(&old_cluster.dbarr, &new_cluster.dbarr,
140  old_cluster.pgdata, new_cluster.pgdata);
141 
142  /*
143  * Assuming OIDs are only used in system tables, there is no need to
144  * restore the OID counter because we have not transferred any OIDs from
145  * the old system, but we do it anyway just in case. We do it late here
146  * because there is no need to have the schema load use new oids.
147  */
148  prep_status("Setting next OID for new cluster");
150  "\"%s/pg_resetwal\" -o %u \"%s\"",
151  new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid,
152  new_cluster.pgdata);
153  check_ok();
154 
155  prep_status("Sync data directory to disk");
157  "\"%s/initdb\" --sync-only \"%s\"", new_cluster.bindir,
158  new_cluster.pgdata);
159  check_ok();
160 
161  create_script_for_cluster_analyze(&analyze_script_file_name);
162  create_script_for_old_cluster_deletion(&deletion_script_file_name);
163 
164  issue_warnings();
165 
166  pg_log(PG_REPORT, "\nUpgrade Complete\n");
167  pg_log(PG_REPORT, "----------------\n");
168 
169  output_completion_banner(analyze_script_file_name,
170  deletion_script_file_name);
171 
172  pg_free(analyze_script_file_name);
173  pg_free(deletion_script_file_name);
174 
175  cleanup();
176 
177  return 0;
178 }
179 
180 
181 static void
182 setup(char *argv0, bool *live_check)
183 {
184  char exec_path[MAXPGPATH]; /* full path to my executable */
185 
186  /*
187  * make sure the user has a clean environment, otherwise, we may confuse
188  * libpq when we connect to one (or both) of the servers.
189  */
191 
193 
194  /* no postmasters should be running, except for a live check */
195  if (pid_lock_file_exists(old_cluster.pgdata))
196  {
197  /*
198  * If we have a postmaster.pid file, try to start the server. If it
199  * starts, the pid file was stale, so stop the server. If it doesn't
200  * start, assume the server is running. If the pid file is left over
201  * from a server crash, this also allows any committed transactions
202  * stored in the WAL to be replayed so they are not lost, because WAL
203  * files are not transferred from old to new servers.
204  */
205  if (start_postmaster(&old_cluster, false))
206  stop_postmaster(false);
207  else
208  {
209  if (!user_opts.check)
210  pg_fatal("There seems to be a postmaster servicing the old cluster.\n"
211  "Please shutdown that postmaster and try again.\n");
212  else
213  *live_check = true;
214  }
215  }
216 
217  /* same goes for the new postmaster */
218  if (pid_lock_file_exists(new_cluster.pgdata))
219  {
220  if (start_postmaster(&new_cluster, false))
221  stop_postmaster(false);
222  else
223  pg_fatal("There seems to be a postmaster servicing the new cluster.\n"
224  "Please shutdown that postmaster and try again.\n");
225  }
226 
227  /* get path to pg_upgrade executable */
228  if (find_my_exec(argv0, exec_path) < 0)
229  pg_fatal("%s: could not find own program executable\n", argv0);
230 
231  /* Trim off program name and keep just path */
232  *last_dir_separator(exec_path) = '\0';
233  canonicalize_path(exec_path);
234  os_info.exec_path = pg_strdup(exec_path);
235 }
236 
237 
238 static void
240 {
241  /*
242  * It would make more sense to freeze after loading the schema, but that
243  * would cause us to lose the frozenids restored by the load. We use
244  * --analyze so autovacuum doesn't update statistics later
245  */
246  prep_status("Analyzing all rows in the new cluster");
248  "\"%s/vacuumdb\" %s --all --analyze %s",
249  new_cluster.bindir, cluster_conn_opts(&new_cluster),
250  log_opts.verbose ? "--verbose" : "");
251  check_ok();
252 
253  /*
254  * We do freeze after analyze so pg_statistic is also frozen. template0 is
255  * not frozen here, but data rows were frozen by initdb, and we set its
256  * datfrozenxid, relfrozenxids, and relminmxid later to match the new xid
257  * counter later.
258  */
259  prep_status("Freezing all rows on the new cluster");
261  "\"%s/vacuumdb\" %s --all --freeze %s",
262  new_cluster.bindir, cluster_conn_opts(&new_cluster),
263  log_opts.verbose ? "--verbose" : "");
264  check_ok();
265 }
266 
267 
268 static void
270 {
271  /*
272  * We set autovacuum_freeze_max_age to its maximum value so autovacuum
273  * does not launch here and delete clog files, before the frozen xids are
274  * set.
275  */
276 
277  set_frozenxids(false);
278 
279  prep_status("Restoring global objects in the new cluster");
280 
281  /*
282  * We have to create the databases first so we can install support
283  * functions in all the other databases. Ideally we could create the
284  * support functions in template1 but pg_dumpall creates database using
285  * the template0 template.
286  */
288  "\"%s/psql\" " EXEC_PSQL_ARGS " %s -f \"%s\"",
289  new_cluster.bindir, cluster_conn_opts(&new_cluster),
291  check_ok();
292 
293  /* we load this to get a current list of databases */
294  get_db_and_rel_infos(&new_cluster);
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];
311  escaped_connstr;
312 
313  initPQExpBuffer(&connstr);
314  appendPQExpBuffer(&connstr, "dbname=");
315  appendConnStrVal(&connstr, old_db->db_name);
316  initPQExpBuffer(&escaped_connstr);
317  appendShellString(&escaped_connstr, connstr.data);
318  termPQExpBuffer(&connstr);
319 
320  pg_log(PG_STATUS, "%s", old_db->db_name);
321  snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
322  snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
323 
324  /*
325  * pg_dump only produces its output at the end, so there is little
326  * parallelism if using the pipe.
327  */
328  parallel_exec_prog(log_file_name,
329  NULL,
330  "\"%s/pg_restore\" %s --exit-on-error --verbose --dbname %s \"%s\"",
331  new_cluster.bindir,
332  cluster_conn_opts(&new_cluster),
333  escaped_connstr.data,
334  sql_file_name);
335 
336  termPQExpBuffer(&escaped_connstr);
337  }
338 
339  /* reap all children */
340  while (reap_child(true) == true)
341  ;
342 
344  check_ok();
345 
346  /*
347  * We don't have minmxids for databases or relations in pre-9.3 clusters,
348  * so set those after we have restored the schema.
349  */
350  if (GET_MAJOR_VERSION(old_cluster.major_version) < 903)
351  set_frozenxids(true);
352 
353  /* regenerate now that we have objects in the databases */
354  get_db_and_rel_infos(&new_cluster);
355 }
356 
357 /*
358  * Delete the given subdirectory contents from the new cluster
359  */
360 static void
361 remove_new_subdir(char *subdir, bool rmtopdir)
362 {
363  char new_path[MAXPGPATH];
364 
365  prep_status("Deleting files from new %s", subdir);
366 
367  snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
368  if (!rmtree(new_path, rmtopdir))
369  pg_fatal("could not delete directory \"%s\"\n", new_path);
370 
371  check_ok();
372 }
373 
374 /*
375  * Copy the files from the old cluster into it
376  */
377 static void
378 copy_subdir_files(char *subdir)
379 {
380  char old_path[MAXPGPATH];
381  char new_path[MAXPGPATH];
382 
383  remove_new_subdir(subdir, true);
384 
385  snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, subdir);
386  snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
387 
388  prep_status("Copying old %s to new server", subdir);
389 
391 #ifndef WIN32
392  "cp -Rf \"%s\" \"%s\"",
393 #else
394  /* flags: everything, no confirm, quiet, overwrite read-only */
395  "xcopy /e /y /q /r \"%s\" \"%s\\\"",
396 #endif
397  old_path, new_path);
398 
399  check_ok();
400 }
401 
402 static void
404 {
405  /* copy old commit logs to new data dir */
406  copy_subdir_files("pg_clog");
407 
408  /* set the next transaction id and epoch of the new cluster */
409  prep_status("Setting next transaction ID and epoch for new cluster");
411  "\"%s/pg_resetwal\" -f -x %u \"%s\"",
412  new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
413  new_cluster.pgdata);
415  "\"%s/pg_resetwal\" -f -e %u \"%s\"",
416  new_cluster.bindir, old_cluster.controldata.chkpnt_nxtepoch,
417  new_cluster.pgdata);
418  /* must reset commit timestamp limits also */
420  "\"%s/pg_resetwal\" -f -c %u,%u \"%s\"",
421  new_cluster.bindir,
422  old_cluster.controldata.chkpnt_nxtxid,
423  old_cluster.controldata.chkpnt_nxtxid,
424  new_cluster.pgdata);
425  check_ok();
426 
427  /*
428  * If the old server is before the MULTIXACT_FORMATCHANGE_CAT_VER change
429  * (see pg_upgrade.h) and the new server is after, then we don't copy
430  * pg_multixact files, but we need to reset pg_control so that the new
431  * server doesn't attempt to read multis older than the cutoff value.
432  */
435  {
436  copy_subdir_files("pg_multixact/offsets");
437  copy_subdir_files("pg_multixact/members");
438 
439  prep_status("Setting next multixact ID and offset for new cluster");
440 
441  /*
442  * we preserve all files and contents, so we must preserve both "next"
443  * counters here and the oldest multi present on system.
444  */
446  "\"%s/pg_resetwal\" -O %u -m %u,%u \"%s\"",
447  new_cluster.bindir,
448  old_cluster.controldata.chkpnt_nxtmxoff,
449  old_cluster.controldata.chkpnt_nxtmulti,
450  old_cluster.controldata.chkpnt_oldstMulti,
451  new_cluster.pgdata);
452  check_ok();
453  }
454  else if (new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
455  {
456  /*
457  * Remove offsets/0000 file created by initdb that no longer matches
458  * the new multi-xid value. "members" starts at zero so no need to
459  * remove it.
460  */
461  remove_new_subdir("pg_multixact/offsets", false);
462 
463  prep_status("Setting oldest multixact ID on new cluster");
464 
465  /*
466  * We don't preserve files in this case, but it's important that the
467  * oldest multi is set to the latest value used by the old system, so
468  * that multixact.c returns the empty set for multis that might be
469  * present on disk. We set next multi to the value following that; it
470  * might end up wrapped around (i.e. 0) if the old cluster had
471  * next=MaxMultiXactId, but multixact.c can cope with that just fine.
472  */
474  "\"%s/pg_resetwal\" -m %u,%u \"%s\"",
475  new_cluster.bindir,
476  old_cluster.controldata.chkpnt_nxtmulti + 1,
477  old_cluster.controldata.chkpnt_nxtmulti,
478  new_cluster.pgdata);
479  check_ok();
480  }
481 
482  /* now reset the wal archives in the new cluster */
483  prep_status("Resetting WAL archives");
485  /* use timeline 1 to match controldata and no WAL history file */
486  "\"%s/pg_resetwal\" -l 00000001%s \"%s\"", new_cluster.bindir,
487  old_cluster.controldata.nextxlogfile + 8,
488  new_cluster.pgdata);
489  check_ok();
490 }
491 
492 
493 /*
494  * set_frozenxids()
495  *
496  * We have frozen all xids, so set datfrozenxid, relfrozenxid, and
497  * relminmxid to be the old cluster's xid counter, which we just set
498  * in the new cluster. User-table frozenxid and minmxid values will
499  * be set by pg_dump --binary-upgrade, but objects not set by the pg_dump
500  * must have proper frozen counters.
501  */
502 static
503 void
504 set_frozenxids(bool minmxid_only)
505 {
506  int dbnum;
507  PGconn *conn,
508  *conn_template1;
509  PGresult *dbres;
510  int ntups;
511  int i_datname;
512  int i_datallowconn;
513 
514  if (!minmxid_only)
515  prep_status("Setting frozenxid and minmxid counters in new cluster");
516  else
517  prep_status("Setting minmxid counter in new cluster");
518 
519  conn_template1 = connectToServer(&new_cluster, "template1");
520 
521  if (!minmxid_only)
522  /* set pg_database.datfrozenxid */
523  PQclear(executeQueryOrDie(conn_template1,
524  "UPDATE pg_catalog.pg_database "
525  "SET datfrozenxid = '%u'",
526  old_cluster.controldata.chkpnt_nxtxid));
527 
528  /* set pg_database.datminmxid */
529  PQclear(executeQueryOrDie(conn_template1,
530  "UPDATE pg_catalog.pg_database "
531  "SET datminmxid = '%u'",
532  old_cluster.controldata.chkpnt_nxtmulti));
533 
534  /* get database names */
535  dbres = executeQueryOrDie(conn_template1,
536  "SELECT datname, datallowconn "
537  "FROM pg_catalog.pg_database");
538 
539  i_datname = PQfnumber(dbres, "datname");
540  i_datallowconn = PQfnumber(dbres, "datallowconn");
541 
542  ntups = PQntuples(dbres);
543  for (dbnum = 0; dbnum < ntups; dbnum++)
544  {
545  char *datname = PQgetvalue(dbres, dbnum, i_datname);
546  char *datallowconn = PQgetvalue(dbres, dbnum, i_datallowconn);
547 
548  /*
549  * We must update databases where datallowconn = false, e.g.
550  * template0, because autovacuum increments their datfrozenxids,
551  * relfrozenxids, and relminmxid even if autovacuum is turned off, and
552  * even though all the data rows are already frozen. To enable this,
553  * we temporarily change datallowconn.
554  */
555  if (strcmp(datallowconn, "f") == 0)
556  PQclear(executeQueryOrDie(conn_template1,
557  "ALTER DATABASE %s ALLOW_CONNECTIONS = true",
558  quote_identifier(datname)));
559 
560  conn = connectToServer(&new_cluster, datname);
561 
562  if (!minmxid_only)
563  /* set pg_class.relfrozenxid */
565  "UPDATE pg_catalog.pg_class "
566  "SET relfrozenxid = '%u' "
567  /* only heap, materialized view, and TOAST are vacuumed */
568  "WHERE relkind IN ('r', 'm', 't')",
569  old_cluster.controldata.chkpnt_nxtxid));
570 
571  /* set pg_class.relminmxid */
573  "UPDATE pg_catalog.pg_class "
574  "SET relminmxid = '%u' "
575  /* only heap, materialized view, and TOAST are vacuumed */
576  "WHERE relkind IN ('r', 'm', 't')",
577  old_cluster.controldata.chkpnt_nxtmulti));
578  PQfinish(conn);
579 
580  /* Reset datallowconn flag */
581  if (strcmp(datallowconn, "f") == 0)
582  PQclear(executeQueryOrDie(conn_template1,
583  "ALTER DATABASE %s ALLOW_CONNECTIONS = false",
584  quote_identifier(datname)));
585  }
586 
587  PQclear(dbres);
588 
589  PQfinish(conn_template1);
590 
591  check_ok();
592 }
593 
594 
595 static void
596 cleanup(void)
597 {
598  fclose(log_opts.internal);
599 
600  /* Remove dump and log files? */
601  if (!log_opts.retain)
602  {
603  int dbnum;
604  char **filename;
605 
606  for (filename = output_files; *filename != NULL; filename++)
607  unlink(*filename);
608 
609  /* remove dump files */
611 
612  if (old_cluster.dbarr.dbs)
613  for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
614  {
615  char sql_file_name[MAXPGPATH],
616  log_file_name[MAXPGPATH];
617  DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
618 
619  snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
620  unlink(sql_file_name);
621 
622  snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
623  unlink(log_file_name);
624  }
625  }
626 }
static void copy_clog_xlog_xid(void)
Definition: pg_upgrade.c:403
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:66
void parseCommandLine(int argc, char *argv[])
Definition: option.c:39
static char * argv0
Definition: pg_ctl.c:92
uint32 major_version
Definition: pg_upgrade.h:274
static void cleanup(void)
Definition: pg_upgrade.c:596
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:9968
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3067
ControlData controldata
Definition: pg_upgrade.h:264
void check_cluster_versions(void)
Definition: check.c:214
static void prepare_new_cluster(void)
Definition: pg_upgrade.c:239
void get_sock_dir(ClusterInfo *cluster, bool live_check)
Definition: option.c:446
void termPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:128
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
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 appendConnStrVal(PQExpBuffer buf, const char *str)
Definition: string_utils.c:536
void canonicalize_path(char *path)
Definition: path.c:254
void PQfinish(PGconn *conn)
Definition: fe-connect.c:3517
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:256
PGresult char * cluster_conn_opts(ClusterInfo *cluster)
Definition: server.c:88
LogOpts log_opts
Definition: util.c:18
void issue_warnings(void)
Definition: check.c:170
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2673
static void adjust_data_dir(void)
Definition: pg_ctl.c:2087
Oid db_oid
Definition: pg_upgrade.h:186
static void copy_subdir_files(char *subdir)
Definition: pg_upgrade.c:378
void stop_postmaster(bool fast)
Definition: server.c:308
void get_restricted_token(const char *progname)
ClusterInfo new_cluster
Definition: pg_upgrade.c:55
uint32 chkpnt_nxtmxoff
Definition: pg_upgrade.h:216
void check_pghost_envvar(void)
Definition: server.c:335
uint32 chkpnt_nxtxid
Definition: pg_upgrade.h:212
PGconn * conn
Definition: streamutil.c:45
uint32 chkpnt_nxtepoch
Definition: pg_upgrade.h:213
void output_check_banner(bool live_check)
Definition: check.c:61
#define MAXPGPATH
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
Definition: pqexpbuffer.c:262
int find_my_exec(const char *argv0, char *retpath)
Definition: exec.c:119
char * output_files[]
Definition: pg_upgrade.c:59
void prep_status(const char *fmt,...) pg_attribute_printf(1
ClusterInfo old_cluster
Definition: pg_upgrade.c:55
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:1988
static void remove_new_subdir(char *subdir, bool rmtopdir)
Definition: pg_upgrade.c:361
int unlink(const char *filename)
#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:504
transferMode transfer_mode
Definition: pg_upgrade.h:299
uint32 chkpnt_oldstMulti
Definition: pg_upgrade.h:217
UserOpts user_opts
Definition: option.c:30
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
uint32 cat_ver
Definition: pg_upgrade.h:210
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1012
uint32 chkpnt_nxtmulti
Definition: pg_upgrade.h:215
static void prepare_new_databases(void)
Definition: pg_upgrade.c:269
static void set_frozenxids(bool minmxid_only)
Definition: pg_upgrade.c:504
int PQfnumber(const PGresult *res, const char *field_name)
Definition: fe-exec.c:2781
static void setup(char *argv0, bool *live_check)
Definition: pg_upgrade.c:182
#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:650
void appendShellString(PQExpBuffer buf, const char *str)
Definition: string_utils.c:430
#define SERVER_LOG_FILE
Definition: pg_upgrade.h:36
DbInfoArr dbarr
Definition: pg_upgrade.h:265
const char * progname
Definition: pg_upgrade.h:309
#define NULL
Definition: c.h:226
void get_db_and_rel_infos(ClusterInfo *cluster)
Definition: info.c:310
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:72
static char * exec_path
Definition: pg_ctl.c:87
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:122
#define DB_DUMP_LOG_FILE_MASK
Definition: pg_upgrade.h:35
bool reap_child(bool wait_for_child)
Definition: parallel.c:293
static pgpid_t start_postmaster(void)
Definition: pg_ctl.c:431
#define SERVER_START_LOG_FILE
Definition: pg_upgrade.h:59
#define UTILITY_LOG_FILE
Definition: pg_upgrade.h:37
bool exec_prog(const char *log_file, const char *opt_log_file, bool throw_error, const char *fmt,...)
Definition: exec.c:78
static char * filename
Definition: pg_dumpall.c:84
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:606
#define EXEC_PSQL_ARGS
Definition: pg_upgrade.h:360
OSInfo os_info
Definition: pg_upgrade.c:57
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:183
void create_script_for_cluster_analyze(char **analyze_script_file_name)
Definition: check.c:414
void check_new_cluster(void)
Definition: check.c:134
#define GLOBALS_DUMP_FILE
Definition: pg_upgrade.h:32
void check_and_dump_old_cluster(bool live_check)
Definition: check.c:77
void report_clusters_compatible(void)
Definition: check.c:153
DbInfo * dbs
Definition: pg_upgrade.h:198
bool retain
Definition: pg_upgrade.h:288
void initPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:89
char * exec_path
Definition: pg_upgrade.h:310
static char * connstr
Definition: pg_dumpall.c:67