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