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