PostgreSQL Source Code  git master
info.c
Go to the documentation of this file.
1 /*
2  * info.c
3  *
4  * information support functions
5  *
6  * Copyright (c) 2010-2022, PostgreSQL Global Development Group
7  * src/bin/pg_upgrade/info.c
8  */
9 
10 #include "postgres_fe.h"
11 
12 #include "access/transam.h"
13 #include "catalog/pg_class_d.h"
14 #include "pg_upgrade.h"
15 
16 static void create_rel_filename_map(const char *old_data, const char *new_data,
17  const DbInfo *old_db, const DbInfo *new_db,
18  const RelInfo *old_rel, const RelInfo *new_rel,
19  FileNameMap *map);
20 static void report_unmatched_relation(const RelInfo *rel, const DbInfo *db,
21  bool is_new_db);
22 static void free_db_and_rel_infos(DbInfoArr *db_arr);
23 static void get_db_infos(ClusterInfo *cluster);
24 static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
25 static void free_rel_infos(RelInfoArr *rel_arr);
26 static void print_db_infos(DbInfoArr *db_arr);
27 static void print_rel_infos(RelInfoArr *rel_arr);
28 
29 
30 /*
31  * gen_db_file_maps()
32  *
33  * generates a database mapping from "old_db" to "new_db".
34  *
35  * Returns a malloc'ed array of mappings. The length of the array
36  * is returned into *nmaps.
37  */
39 gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
40  int *nmaps,
41  const char *old_pgdata, const char *new_pgdata)
42 {
44  int old_relnum,
45  new_relnum;
46  int num_maps = 0;
47  bool all_matched = true;
48 
49  /* There will certainly not be more mappings than there are old rels */
50  maps = (FileNameMap *) pg_malloc(sizeof(FileNameMap) *
51  old_db->rel_arr.nrels);
52 
53  /*
54  * Each of the RelInfo arrays should be sorted by OID. Scan through them
55  * and match them up. If we fail to match everything, we'll abort, but
56  * first print as much info as we can about mismatches.
57  */
58  old_relnum = new_relnum = 0;
59  while (old_relnum < old_db->rel_arr.nrels ||
60  new_relnum < new_db->rel_arr.nrels)
61  {
62  RelInfo *old_rel = (old_relnum < old_db->rel_arr.nrels) ?
63  &old_db->rel_arr.rels[old_relnum] : NULL;
64  RelInfo *new_rel = (new_relnum < new_db->rel_arr.nrels) ?
65  &new_db->rel_arr.rels[new_relnum] : NULL;
66 
67  /* handle running off one array before the other */
68  if (!new_rel)
69  {
70  /*
71  * old_rel is unmatched. This should never happen, because we
72  * force new rels to have TOAST tables if the old one did.
73  */
74  report_unmatched_relation(old_rel, old_db, false);
75  all_matched = false;
76  old_relnum++;
77  continue;
78  }
79  if (!old_rel)
80  {
81  /*
82  * new_rel is unmatched. This shouldn't really happen either, but
83  * if it's a TOAST table, we can ignore it and continue
84  * processing, assuming that the new server made a TOAST table
85  * that wasn't needed.
86  */
87  if (strcmp(new_rel->nspname, "pg_toast") != 0)
88  {
89  report_unmatched_relation(new_rel, new_db, true);
90  all_matched = false;
91  }
92  new_relnum++;
93  continue;
94  }
95 
96  /* check for mismatched OID */
97  if (old_rel->reloid < new_rel->reloid)
98  {
99  /* old_rel is unmatched, see comment above */
100  report_unmatched_relation(old_rel, old_db, false);
101  all_matched = false;
102  old_relnum++;
103  continue;
104  }
105  else if (old_rel->reloid > new_rel->reloid)
106  {
107  /* new_rel is unmatched, see comment above */
108  if (strcmp(new_rel->nspname, "pg_toast") != 0)
109  {
110  report_unmatched_relation(new_rel, new_db, true);
111  all_matched = false;
112  }
113  new_relnum++;
114  continue;
115  }
116 
117  /*
118  * Verify that rels of same OID have same name. The namespace name
119  * should always match, but the relname might not match for TOAST
120  * tables (and, therefore, their indexes).
121  */
122  if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
123  strcmp(old_rel->relname, new_rel->relname) != 0)
124  {
125  pg_log(PG_WARNING, "Relation names for OID %u in database \"%s\" do not match: "
126  "old name \"%s.%s\", new name \"%s.%s\"",
127  old_rel->reloid, old_db->db_name,
128  old_rel->nspname, old_rel->relname,
129  new_rel->nspname, new_rel->relname);
130  all_matched = false;
131  old_relnum++;
132  new_relnum++;
133  continue;
134  }
135 
136  /* OK, create a mapping entry */
137  create_rel_filename_map(old_pgdata, new_pgdata, old_db, new_db,
138  old_rel, new_rel, maps + num_maps);
139  num_maps++;
140  old_relnum++;
141  new_relnum++;
142  }
143 
144  if (!all_matched)
145  pg_fatal("Failed to match up old and new tables in database \"%s\"",
146  old_db->db_name);
147 
148  *nmaps = num_maps;
149  return maps;
150 }
151 
152 
153 /*
154  * create_rel_filename_map()
155  *
156  * fills a file node map structure and returns it in "map".
157  */
158 static void
159 create_rel_filename_map(const char *old_data, const char *new_data,
160  const DbInfo *old_db, const DbInfo *new_db,
161  const RelInfo *old_rel, const RelInfo *new_rel,
162  FileNameMap *map)
163 {
164  /* In case old/new tablespaces don't match, do them separately. */
165  if (strlen(old_rel->tablespace) == 0)
166  {
167  /*
168  * relation belongs to the default tablespace, hence relfiles should
169  * exist in the data directories.
170  */
171  map->old_tablespace = old_data;
172  map->old_tablespace_suffix = "/base";
173  }
174  else
175  {
176  /* relation belongs to a tablespace, so use the tablespace location */
177  map->old_tablespace = old_rel->tablespace;
179  }
180 
181  /* Do the same for new tablespaces */
182  if (strlen(new_rel->tablespace) == 0)
183  {
184  map->new_tablespace = new_data;
185  map->new_tablespace_suffix = "/base";
186  }
187  else
188  {
189  map->new_tablespace = new_rel->tablespace;
191  }
192 
193  /* DB oid and relfilenumbers are preserved between old and new cluster */
194  map->db_oid = old_db->db_oid;
195  map->relfilenumber = old_rel->relfilenumber;
196 
197  /* used only for logging and error reporting, old/new are identical */
198  map->nspname = old_rel->nspname;
199  map->relname = old_rel->relname;
200 }
201 
202 
203 /*
204  * Complain about a relation we couldn't match to the other database,
205  * identifying it as best we can.
206  */
207 static void
208 report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db)
209 {
210  Oid reloid = rel->reloid; /* we might change rel below */
211  char reldesc[1000];
212  int i;
213 
214  snprintf(reldesc, sizeof(reldesc), "\"%s.%s\"",
215  rel->nspname, rel->relname);
216  if (rel->indtable)
217  {
218  for (i = 0; i < db->rel_arr.nrels; i++)
219  {
220  const RelInfo *hrel = &db->rel_arr.rels[i];
221 
222  if (hrel->reloid == rel->indtable)
223  {
224  snprintf(reldesc + strlen(reldesc),
225  sizeof(reldesc) - strlen(reldesc),
226  _(" which is an index on \"%s.%s\""),
227  hrel->nspname, hrel->relname);
228  /* Shift attention to index's table for toast check */
229  rel = hrel;
230  break;
231  }
232  }
233  if (i >= db->rel_arr.nrels)
234  snprintf(reldesc + strlen(reldesc),
235  sizeof(reldesc) - strlen(reldesc),
236  _(" which is an index on OID %u"), rel->indtable);
237  }
238  if (rel->toastheap)
239  {
240  for (i = 0; i < db->rel_arr.nrels; i++)
241  {
242  const RelInfo *brel = &db->rel_arr.rels[i];
243 
244  if (brel->reloid == rel->toastheap)
245  {
246  snprintf(reldesc + strlen(reldesc),
247  sizeof(reldesc) - strlen(reldesc),
248  _(" which is the TOAST table for \"%s.%s\""),
249  brel->nspname, brel->relname);
250  break;
251  }
252  }
253  if (i >= db->rel_arr.nrels)
254  snprintf(reldesc + strlen(reldesc),
255  sizeof(reldesc) - strlen(reldesc),
256  _(" which is the TOAST table for OID %u"), rel->toastheap);
257  }
258 
259  if (is_new_db)
260  pg_log(PG_WARNING, "No match found in old cluster for new relation with OID %u in database \"%s\": %s",
261  reloid, db->db_name, reldesc);
262  else
263  pg_log(PG_WARNING, "No match found in new cluster for old relation with OID %u in database \"%s\": %s",
264  reloid, db->db_name, reldesc);
265 }
266 
267 /*
268  * get_db_and_rel_infos()
269  *
270  * higher level routine to generate dbinfos for the database running
271  * on the given "port". Assumes that server is already running.
272  */
273 void
275 {
276  int dbnum;
277 
278  if (cluster->dbarr.dbs != NULL)
280 
282 
283  for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
284  get_rel_infos(cluster, &cluster->dbarr.dbs[dbnum]);
285 
286  if (cluster == &old_cluster)
287  pg_log(PG_VERBOSE, "\nsource databases:");
288  else
289  pg_log(PG_VERBOSE, "\ntarget databases:");
290 
291  if (log_opts.verbose)
292  print_db_infos(&cluster->dbarr);
293 }
294 
295 
296 /*
297  * get_db_infos()
298  *
299  * Scans pg_database system catalog and populates all user
300  * databases.
301  */
302 static void
304 {
305  PGconn *conn = connectToServer(cluster, "template1");
306  PGresult *res;
307  int ntups;
308  int tupnum;
309  DbInfo *dbinfos;
310  int i_datname,
311  i_oid,
312  i_encoding,
313  i_datcollate,
314  i_datctype,
315  i_datlocprovider,
316  i_daticulocale,
317  i_spclocation;
318  char query[QUERY_ALLOC];
319 
320  snprintf(query, sizeof(query),
321  "SELECT d.oid, d.datname, d.encoding, d.datcollate, d.datctype, ");
322  if (GET_MAJOR_VERSION(cluster->major_version) < 1500)
323  snprintf(query + strlen(query), sizeof(query) - strlen(query),
324  "'c' AS datlocprovider, NULL AS daticulocale, ");
325  else
326  snprintf(query + strlen(query), sizeof(query) - strlen(query),
327  "datlocprovider, daticulocale, ");
328  snprintf(query + strlen(query), sizeof(query) - strlen(query),
329  "pg_catalog.pg_tablespace_location(t.oid) AS spclocation "
330  "FROM pg_catalog.pg_database d "
331  " LEFT OUTER JOIN pg_catalog.pg_tablespace t "
332  " ON d.dattablespace = t.oid "
333  "WHERE d.datallowconn = true "
334  "ORDER BY 1");
335 
336  res = executeQueryOrDie(conn, "%s", query);
337 
338  i_oid = PQfnumber(res, "oid");
339  i_datname = PQfnumber(res, "datname");
340  i_encoding = PQfnumber(res, "encoding");
341  i_datcollate = PQfnumber(res, "datcollate");
342  i_datctype = PQfnumber(res, "datctype");
343  i_datlocprovider = PQfnumber(res, "datlocprovider");
344  i_daticulocale = PQfnumber(res, "daticulocale");
345  i_spclocation = PQfnumber(res, "spclocation");
346 
347  ntups = PQntuples(res);
348  dbinfos = (DbInfo *) pg_malloc(sizeof(DbInfo) * ntups);
349 
350  for (tupnum = 0; tupnum < ntups; tupnum++)
351  {
352  dbinfos[tupnum].db_oid = atooid(PQgetvalue(res, tupnum, i_oid));
353  dbinfos[tupnum].db_name = pg_strdup(PQgetvalue(res, tupnum, i_datname));
354  dbinfos[tupnum].db_encoding = atoi(PQgetvalue(res, tupnum, i_encoding));
355  dbinfos[tupnum].db_collate = pg_strdup(PQgetvalue(res, tupnum, i_datcollate));
356  dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
357  dbinfos[tupnum].db_collprovider = PQgetvalue(res, tupnum, i_datlocprovider)[0];
358  if (PQgetisnull(res, tupnum, i_daticulocale))
359  dbinfos[tupnum].db_iculocale = NULL;
360  else
361  dbinfos[tupnum].db_iculocale = pg_strdup(PQgetvalue(res, tupnum, i_daticulocale));
362  snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
363  PQgetvalue(res, tupnum, i_spclocation));
364  }
365  PQclear(res);
366 
367  PQfinish(conn);
368 
369  cluster->dbarr.dbs = dbinfos;
370  cluster->dbarr.ndbs = ntups;
371 }
372 
373 
374 /*
375  * get_rel_infos()
376  *
377  * gets the relinfos for all the user tables and indexes of the database
378  * referred to by "dbinfo".
379  *
380  * Note: the resulting RelInfo array is assumed to be sorted by OID.
381  * This allows later processing to match up old and new databases efficiently.
382  */
383 static void
385 {
387  dbinfo->db_name);
388  PGresult *res;
389  RelInfo *relinfos;
390  int ntups;
391  int relnum;
392  int num_rels = 0;
393  char *nspname = NULL;
394  char *relname = NULL;
395  char *tablespace = NULL;
396  int i_spclocation,
397  i_nspname,
398  i_relname,
399  i_reloid,
400  i_indtable,
401  i_toastheap,
402  i_relfilenumber,
403  i_reltablespace;
404  char query[QUERY_ALLOC];
405  char *last_namespace = NULL,
406  *last_tablespace = NULL;
407 
408  query[0] = '\0'; /* initialize query string to empty */
409 
410  /*
411  * Create a CTE that collects OIDs of regular user tables, including
412  * matviews and sequences, but excluding toast tables and indexes. We
413  * assume that relations with OIDs >= FirstNormalObjectId belong to the
414  * user. (That's probably redundant with the namespace-name exclusions,
415  * but let's be safe.)
416  *
417  * pg_largeobject contains user data that does not appear in pg_dump
418  * output, so we have to copy that system table. It's easiest to do that
419  * by treating it as a user table.
420  */
421  snprintf(query + strlen(query), sizeof(query) - strlen(query),
422  "WITH regular_heap (reloid, indtable, toastheap) AS ( "
423  " SELECT c.oid, 0::oid, 0::oid "
424  " FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
425  " ON c.relnamespace = n.oid "
426  " WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ", "
427  CppAsString2(RELKIND_MATVIEW) ") AND "
428  /* exclude possible orphaned temp tables */
429  " ((n.nspname !~ '^pg_temp_' AND "
430  " n.nspname !~ '^pg_toast_temp_' AND "
431  " n.nspname NOT IN ('pg_catalog', 'information_schema', "
432  " 'binary_upgrade', 'pg_toast') AND "
433  " c.oid >= %u::pg_catalog.oid) OR "
434  " (n.nspname = 'pg_catalog' AND "
435  " relname IN ('pg_largeobject') ))), ",
437 
438  /*
439  * Add a CTE that collects OIDs of toast tables belonging to the tables
440  * selected by the regular_heap CTE. (We have to do this separately
441  * because the namespace-name rules above don't work for toast tables.)
442  */
443  snprintf(query + strlen(query), sizeof(query) - strlen(query),
444  " toast_heap (reloid, indtable, toastheap) AS ( "
445  " SELECT c.reltoastrelid, 0::oid, c.oid "
446  " FROM regular_heap JOIN pg_catalog.pg_class c "
447  " ON regular_heap.reloid = c.oid "
448  " WHERE c.reltoastrelid != 0), ");
449 
450  /*
451  * Add a CTE that collects OIDs of all valid indexes on the previously
452  * selected tables. We can ignore invalid indexes since pg_dump does.
453  * Testing indisready is necessary in 9.2, and harmless in earlier/later
454  * versions.
455  */
456  snprintf(query + strlen(query), sizeof(query) - strlen(query),
457  " all_index (reloid, indtable, toastheap) AS ( "
458  " SELECT indexrelid, indrelid, 0::oid "
459  " FROM pg_catalog.pg_index "
460  " WHERE indisvalid AND indisready "
461  " AND indrelid IN "
462  " (SELECT reloid FROM regular_heap "
463  " UNION ALL "
464  " SELECT reloid FROM toast_heap)) ");
465 
466  /*
467  * And now we can write the query that retrieves the data we want for each
468  * heap and index relation. Make sure result is sorted by OID.
469  */
470  snprintf(query + strlen(query), sizeof(query) - strlen(query),
471  "SELECT all_rels.*, n.nspname, c.relname, "
472  " c.relfilenode, c.reltablespace, "
473  " pg_catalog.pg_tablespace_location(t.oid) AS spclocation "
474  "FROM (SELECT * FROM regular_heap "
475  " UNION ALL "
476  " SELECT * FROM toast_heap "
477  " UNION ALL "
478  " SELECT * FROM all_index) all_rels "
479  " JOIN pg_catalog.pg_class c "
480  " ON all_rels.reloid = c.oid "
481  " JOIN pg_catalog.pg_namespace n "
482  " ON c.relnamespace = n.oid "
483  " LEFT OUTER JOIN pg_catalog.pg_tablespace t "
484  " ON c.reltablespace = t.oid "
485  "ORDER BY 1;");
486 
487  res = executeQueryOrDie(conn, "%s", query);
488 
489  ntups = PQntuples(res);
490 
491  relinfos = (RelInfo *) pg_malloc(sizeof(RelInfo) * ntups);
492 
493  i_reloid = PQfnumber(res, "reloid");
494  i_indtable = PQfnumber(res, "indtable");
495  i_toastheap = PQfnumber(res, "toastheap");
496  i_nspname = PQfnumber(res, "nspname");
497  i_relname = PQfnumber(res, "relname");
498  i_relfilenumber = PQfnumber(res, "relfilenode");
499  i_reltablespace = PQfnumber(res, "reltablespace");
500  i_spclocation = PQfnumber(res, "spclocation");
501 
502  for (relnum = 0; relnum < ntups; relnum++)
503  {
504  RelInfo *curr = &relinfos[num_rels++];
505 
506  curr->reloid = atooid(PQgetvalue(res, relnum, i_reloid));
507  curr->indtable = atooid(PQgetvalue(res, relnum, i_indtable));
508  curr->toastheap = atooid(PQgetvalue(res, relnum, i_toastheap));
509 
510  nspname = PQgetvalue(res, relnum, i_nspname);
511  curr->nsp_alloc = false;
512 
513  /*
514  * Many of the namespace and tablespace strings are identical, so we
515  * try to reuse the allocated string pointers where possible to reduce
516  * memory consumption.
517  */
518  /* Can we reuse the previous string allocation? */
519  if (last_namespace && strcmp(nspname, last_namespace) == 0)
520  curr->nspname = last_namespace;
521  else
522  {
523  last_namespace = curr->nspname = pg_strdup(nspname);
524  curr->nsp_alloc = true;
525  }
526 
527  relname = PQgetvalue(res, relnum, i_relname);
528  curr->relname = pg_strdup(relname);
529 
530  curr->relfilenumber = atooid(PQgetvalue(res, relnum, i_relfilenumber));
531  curr->tblsp_alloc = false;
532 
533  /* Is the tablespace oid non-default? */
534  if (atooid(PQgetvalue(res, relnum, i_reltablespace)) != 0)
535  {
536  /*
537  * The tablespace location might be "", meaning the cluster
538  * default location, i.e. pg_default or pg_global.
539  */
540  tablespace = PQgetvalue(res, relnum, i_spclocation);
541 
542  /* Can we reuse the previous string allocation? */
543  if (last_tablespace && strcmp(tablespace, last_tablespace) == 0)
544  curr->tablespace = last_tablespace;
545  else
546  {
547  last_tablespace = curr->tablespace = pg_strdup(tablespace);
548  curr->tblsp_alloc = true;
549  }
550  }
551  else
552  /* A zero reltablespace oid indicates the database tablespace. */
553  curr->tablespace = dbinfo->db_tablespace;
554  }
555  PQclear(res);
556 
557  PQfinish(conn);
558 
559  dbinfo->rel_arr.rels = relinfos;
560  dbinfo->rel_arr.nrels = num_rels;
561 }
562 
563 
564 static void
566 {
567  int dbnum;
568 
569  for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
570  {
571  free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
572  pg_free(db_arr->dbs[dbnum].db_name);
573  }
574  pg_free(db_arr->dbs);
575  db_arr->dbs = NULL;
576  db_arr->ndbs = 0;
577 }
578 
579 
580 static void
582 {
583  int relnum;
584 
585  for (relnum = 0; relnum < rel_arr->nrels; relnum++)
586  {
587  if (rel_arr->rels[relnum].nsp_alloc)
588  pg_free(rel_arr->rels[relnum].nspname);
589  pg_free(rel_arr->rels[relnum].relname);
590  if (rel_arr->rels[relnum].tblsp_alloc)
591  pg_free(rel_arr->rels[relnum].tablespace);
592  }
593  pg_free(rel_arr->rels);
594  rel_arr->nrels = 0;
595 }
596 
597 
598 static void
600 {
601  int dbnum;
602 
603  for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
604  {
605  pg_log(PG_VERBOSE, "Database: %s", db_arr->dbs[dbnum].db_name);
606  print_rel_infos(&db_arr->dbs[dbnum].rel_arr);
607  }
608 }
609 
610 
611 static void
613 {
614  int relnum;
615 
616  for (relnum = 0; relnum < rel_arr->nrels; relnum++)
617  pg_log(PG_VERBOSE, "relname: %s.%s: reloid: %u reltblspace: %s",
618  rel_arr->rels[relnum].nspname,
619  rel_arr->rels[relnum].relname,
620  rel_arr->rels[relnum].reloid,
621  rel_arr->rels[relnum].tablespace);
622 }
#define CppAsString2(x)
Definition: c.h:311
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
Definition: cluster.c:110
#define _(x)
Definition: elog.c:90
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4130
int PQntuples(const PGresult *res)
Definition: fe-exec.c:3310
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3705
int PQfnumber(const PGresult *res, const char *field_name)
Definition: fe-exec.c:3418
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3730
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
void pg_free(void *ptr)
Definition: fe_memutils.c:105
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
static void report_unmatched_relation(const RelInfo *rel, const DbInfo *db, bool is_new_db)
Definition: info.c:208
static void get_db_infos(ClusterInfo *cluster)
Definition: info.c:303
static void free_rel_infos(RelInfoArr *rel_arr)
Definition: info.c:581
static void print_rel_infos(RelInfoArr *rel_arr)
Definition: info.c:612
static void create_rel_filename_map(const char *old_data, const char *new_data, const DbInfo *old_db, const DbInfo *new_db, const RelInfo *old_rel, const RelInfo *new_rel, FileNameMap *map)
Definition: info.c:159
FileNameMap * gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, int *nmaps, const char *old_pgdata, const char *new_pgdata)
Definition: info.c:39
static void free_db_and_rel_infos(DbInfoArr *db_arr)
Definition: info.c:565
static void print_db_infos(DbInfoArr *db_arr)
Definition: info.c:599
void get_db_and_rel_infos(ClusterInfo *cluster)
Definition: info.c:274
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
Definition: info.c:384
int i
Definition: isn.c:73
#define pg_fatal(...)
NameData relname
Definition: pg_class.h:38
ClusterInfo new_cluster
Definition: pg_upgrade.c:63
ClusterInfo old_cluster
Definition: pg_upgrade.c:62
#define QUERY_ALLOC
Definition: pg_upgrade.h:23
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
LogOpts log_opts
Definition: util.c:17
@ PG_WARNING
Definition: pg_upgrade.h:242
@ PG_VERBOSE
Definition: pg_upgrade.h:238
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
Definition: server.c:28
#define GET_MAJOR_VERSION(v)
Definition: pg_upgrade.h:27
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2
char * tablespace
Definition: pgbench.c:225
#define snprintf
Definition: port.h:238
unsigned int Oid
Definition: postgres_ext.h:31
#define atooid(x)
Definition: postgres_ext.h:42
PGconn * conn
Definition: streamutil.c:54
const char * tablespace_suffix
Definition: pg_upgrade.h:267
DbInfo * dbs
Definition: pg_upgrade.h:188
char * db_iculocale
Definition: pg_upgrade.h:181
char db_collprovider
Definition: pg_upgrade.h:180
char * db_collate
Definition: pg_upgrade.h:178
int db_encoding
Definition: pg_upgrade.h:182
char * db_ctype
Definition: pg_upgrade.h:179
char db_tablespace[MAXPGPATH]
Definition: pg_upgrade.h:176
char * db_name
Definition: pg_upgrade.h:175
RelInfoArr rel_arr
Definition: pg_upgrade.h:183
Oid db_oid
Definition: pg_upgrade.h:174
const char * new_tablespace
Definition: pg_upgrade.h:159
const char * old_tablespace_suffix
Definition: pg_upgrade.h:160
const char * old_tablespace
Definition: pg_upgrade.h:158
RelFileNumber relfilenumber
Definition: pg_upgrade.h:163
char * relname
Definition: pg_upgrade.h:166
char * nspname
Definition: pg_upgrade.h:165
const char * new_tablespace_suffix
Definition: pg_upgrade.h:161
bool verbose
Definition: pg_upgrade.h:277
RelInfo * rels
Definition: pg_upgrade.h:149
RelFileNumber relfilenumber
Definition: pg_upgrade.h:139
Oid toastheap
Definition: pg_upgrade.h:141
bool tblsp_alloc
Definition: pg_upgrade.h:144
Oid reloid
Definition: pg_upgrade.h:138
char * nspname
Definition: pg_upgrade.h:136
char * tablespace
Definition: pg_upgrade.h:142
Oid indtable
Definition: pg_upgrade.h:140
bool nsp_alloc
Definition: pg_upgrade.h:143
char * relname
Definition: pg_upgrade.h:137
#define FirstNormalObjectId
Definition: transam.h:197
static const pg_conv_map maps[]