12#include "catalog/pg_authid_d.h"
13#include "catalog/pg_class_d.h"
60#define ALL_VERSIONS -1
110 .report_filename =
"tables_using_composite.txt",
112 "SELECT t.oid FROM pg_catalog.pg_type t "
113 "LEFT JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid "
114 " WHERE typtype = 'c' AND (t.oid < 16384 OR nspname = 'information_schema')",
116 gettext_noop(
"Your installation contains system-defined composite types in user tables.\n"
117 "These type OIDs are not stable across PostgreSQL versions,\n"
118 "so this cluster cannot currently be upgraded. You can drop the\n"
119 "problem columns and restart the upgrade.\n"),
130 .status =
gettext_noop(
"Checking for incompatible \"line\" data type"),
131 .report_filename =
"tables_using_line.txt",
133 "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
135 gettext_noop(
"Your installation contains the \"line\" data type in user tables.\n"
136 "This data type changed its internal and input/output format\n"
137 "between your old and new versions so this\n"
138 "cluster cannot currently be upgraded. You can\n"
139 "drop the problem columns and restart the upgrade.\n"),
140 .threshold_version = 903
152 .status =
gettext_noop(
"Checking for reg* data types in user tables"),
153 .report_filename =
"tables_using_reg.txt",
161 "SELECT oid FROM pg_catalog.pg_type t "
162 "WHERE t.typnamespace = "
163 " (SELECT oid FROM pg_catalog.pg_namespace "
164 " WHERE nspname = 'pg_catalog') "
165 " AND t.typname IN ( "
179 gettext_noop(
"Your installation contains one of the reg* data types in user tables.\n"
180 "These data types reference system OIDs that are not preserved by\n"
181 "pg_upgrade, so this cluster cannot currently be upgraded. You can\n"
182 "drop the problem columns and restart the upgrade.\n"),
191 .status =
gettext_noop(
"Checking for incompatible \"aclitem\" data type"),
192 .report_filename =
"tables_using_aclitem.txt",
194 "SELECT 'pg_catalog.aclitem'::pg_catalog.regtype AS oid",
196 gettext_noop(
"Your installation contains the \"aclitem\" data type in user tables.\n"
197 "The internal format of \"aclitem\" changed in PostgreSQL version 16\n"
198 "so this cluster cannot currently be upgraded. You can drop the\n"
199 "problem columns and restart the upgrade.\n"),
200 .threshold_version = 1500
215 .status =
gettext_noop(
"Checking for invalid \"unknown\" user columns"),
216 .report_filename =
"tables_using_unknown.txt",
218 "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
220 gettext_noop(
"Your installation contains the \"unknown\" data type in user tables.\n"
221 "This data type is no longer allowed in tables, so this cluster\n"
222 "cannot currently be upgraded. You can drop the problem columns\n"
223 "and restart the upgrade.\n"),
224 .threshold_version = 906
237 .status =
gettext_noop(
"Checking for invalid \"sql_identifier\" user columns"),
238 .report_filename =
"tables_using_sql_identifier.txt",
240 "SELECT 'information_schema.sql_identifier'::pg_catalog.regtype AS oid",
242 gettext_noop(
"Your installation contains the \"sql_identifier\" data type in user tables.\n"
243 "The on-disk format for this data type has changed, so this\n"
244 "cluster cannot currently be upgraded. You can drop the problem\n"
245 "columns and restart the upgrade.\n"),
246 .threshold_version = 1100
253 .status =
gettext_noop(
"Checking for incompatible \"jsonb\" data type in user tables"),
254 .report_filename =
"tables_using_jsonb.txt",
256 "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
258 gettext_noop(
"Your installation contains the \"jsonb\" data type in user tables.\n"
259 "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
260 "cluster cannot currently be upgraded. You can drop the problem \n"
261 "columns and restart the upgrade.\n"),
270 .status =
gettext_noop(
"Checking for removed \"abstime\" data type in user tables"),
271 .report_filename =
"tables_using_abstime.txt",
273 "SELECT 'pg_catalog.abstime'::pg_catalog.regtype AS oid",
275 gettext_noop(
"Your installation contains the \"abstime\" data type in user tables.\n"
276 "The \"abstime\" type has been removed in PostgreSQL version 12,\n"
277 "so this cluster cannot currently be upgraded. You can drop the\n"
278 "problem columns, or change them to another data type, and restart\n"
280 .threshold_version = 1100
283 .status =
gettext_noop(
"Checking for removed \"reltime\" data type in user tables"),
284 .report_filename =
"tables_using_reltime.txt",
286 "SELECT 'pg_catalog.reltime'::pg_catalog.regtype AS oid",
288 gettext_noop(
"Your installation contains the \"reltime\" data type in user tables.\n"
289 "The \"reltime\" type has been removed in PostgreSQL version 12,\n"
290 "so this cluster cannot currently be upgraded. You can drop the\n"
291 "problem columns, or change them to another data type, and restart\n"
293 .threshold_version = 1100
296 .status =
gettext_noop(
"Checking for removed \"tinterval\" data type in user tables"),
297 .report_filename =
"tables_using_tinterval.txt",
299 "SELECT 'pg_catalog.tinterval'::pg_catalog.regtype AS oid",
301 gettext_noop(
"Your installation contains the \"tinterval\" data type in user tables.\n"
302 "The \"tinterval\" type has been removed in PostgreSQL version 12,\n"
303 "so this cluster cannot currently be upgraded. You can drop the\n"
304 "problem columns, or change them to another data type, and restart\n"
306 .threshold_version = 1100
311 NULL, NULL, NULL, NULL, 0, NULL
334 return psprintf(
"WITH RECURSIVE oids AS ( "
340 " WITH x AS (SELECT oid FROM oids) "
342 " SELECT t.oid FROM pg_catalog.pg_type t, x WHERE typbasetype = x.oid AND typtype = 'd' "
345 " SELECT t.oid FROM pg_catalog.pg_type t, x WHERE typelem = x.oid AND typtype = 'b' "
348 " SELECT t.oid FROM pg_catalog.pg_type t, pg_catalog.pg_class c, pg_catalog.pg_attribute a, x "
349 " WHERE t.typtype = 'c' AND "
350 " t.oid = c.reltype AND "
351 " c.oid = a.attrelid AND "
352 " NOT a.attisdropped AND "
353 " a.atttypid = x.oid "
356 " SELECT t.oid FROM pg_catalog.pg_type t, pg_catalog.pg_range r, x "
357 " WHERE t.typtype = 'r' AND r.rngtypid = t.oid AND r.rngsubtype = x.oid"
361 "SELECT n.nspname, c.relname, a.attname "
362 "FROM pg_catalog.pg_class c, "
363 " pg_catalog.pg_namespace n, "
364 " pg_catalog.pg_attribute a "
365 "WHERE c.oid = a.attrelid AND "
366 " NOT a.attisdropped AND "
367 " a.atttypid IN (SELECT oid FROM oids) AND "
372 " c.relnamespace = n.oid AND "
374 " n.nspname !~ '^pg_temp_' AND "
375 " n.nspname !~ '^pg_toast_temp_' AND "
377 " n.nspname NOT IN ('pg_catalog', 'information_schema')",
402 snprintf(output_path,
sizeof(output_path),
"%s/%s",
404 state->check->report_filename);
410 if (*
state->report == NULL)
421 _(
state->check->report_text),
422 _(
"A list of the problem columns is in the file:"),
425 state->result =
true;
427 if ((script =
fopen_priv(output_path,
"a")) == NULL)
428 pg_fatal(
"could not open file \"%s\": %m", output_path);
432 for (
int rowno = 0; rowno < ntups; rowno++)
465 int n_data_types_usage_checks = 0;
467 char **queries = NULL;
473 while (tmp->
status != NULL)
475 n_data_types_usage_checks++;
480 queries =
pg_malloc0(
sizeof(
char *) * n_data_types_usage_checks);
483 for (
int i = 0;
i < n_data_types_usage_checks;
i++)
528 for (
int i = 0;
i < n_data_types_usage_checks;
i++)
573 "Performing Consistency Checks on Old Live Server\n"
574 "------------------------------------------------");
579 "Performing Consistency Checks\n"
580 "-----------------------------");
742 "If pg_upgrade fails after this point, you must re-initdb the\n"
743 "new cluster before continuing.");
782 "Optimizer statistics are not transferred by pg_upgrade.\n"
783 "Once you start the new server, consider running:\n"
786 if (deletion_script_file_name)
788 "Running this script will delete the old cluster's data files:\n"
790 deletion_script_file_name);
793 "Could not create a script to delete the old cluster's data files\n"
794 "because user-defined tablespaces or the new cluster's data directory\n"
795 "exist in the old cluster directory. The old cluster's contents must\n"
796 "be deleted manually.");
817 pg_fatal(
"This utility can only upgrade from PostgreSQL version %s and later.",
822 pg_fatal(
"This utility can only upgrade to PostgreSQL version %s.",
831 pg_fatal(
"This utility cannot be used to downgrade to older major PostgreSQL versions.");
836 pg_fatal(
"Old cluster data and binary directories are from different major versions.");
839 pg_fatal(
"New cluster data and binary directories are from different major versions.");
854 pg_fatal(
"When checking a live server, "
855 "the old and new port numbers must be different.");
869 for (relnum = 0; relnum < rel_arr->
nrels;
873 if (strcmp(rel_arr->
rels[relnum].
nspname,
"pg_catalog") != 0)
874 pg_fatal(
"New cluster database \"%s\" is not empty: found relation \"%s.%s\"",
897 prep_status(
"Checking for new cluster tablespace directories");
907 if (
stat(new_tablespace_dir, &statbuf) == 0 || errno != ENOENT)
908 pg_fatal(
"new cluster tablespace directory already exists: \"%s\"",
928 *deletion_script_file_name =
psprintf(
"%sdelete_old_cluster.%s",
941 "\nWARNING: new data directory should not be inside the old data directory, i.e. %s", old_cluster_pgdata);
944 unlink(*deletion_script_file_name);
945 pg_free(*deletion_script_file_name);
946 *deletion_script_file_name = NULL;
965 "\nWARNING: user-defined tablespace locations should not be inside the data directory, i.e. %s", old_tablespace_dir);
968 unlink(*deletion_script_file_name);
969 pg_free(*deletion_script_file_name);
970 *deletion_script_file_name = NULL;
975 prep_status(
"Creating script to delete old cluster");
977 if ((script =
fopen_priv(*deletion_script_file_name,
"w")) == NULL)
978 pg_fatal(
"could not open file \"%s\": %m",
979 *deletion_script_file_name);
983 fprintf(script,
"#!/bin/sh\n\n");
1028 if (chmod(*deletion_script_file_name,
S_IRWXU) != 0)
1029 pg_fatal(
"could not add execute permission to file \"%s\": %m",
1030 *deletion_script_file_name);
1049 prep_status(
"Checking database user is the install user");
1053 "SELECT rolsuper, oid "
1054 "FROM pg_catalog.pg_roles "
1055 "WHERE rolname = current_user "
1056 "AND rolname !~ '^pg_'");
1065 pg_fatal(
"database user \"%s\" is not the install user",
1072 "FROM pg_catalog.pg_roles "
1073 "WHERE rolname !~ '^pg_'");
1076 pg_fatal(
"could not determine the number of users");
1084 pg_fatal(
"Only the install user can be defined in the new cluster.");
1111 FILE *script = NULL;
1114 prep_status(
"Checking database connection settings");
1116 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1118 "databases_cannot_connect_to.txt");
1124 "SELECT datname, datallowconn, datconnlimit "
1125 "FROM pg_catalog.pg_database");
1127 i_datname =
PQfnumber(dbres,
"datname");
1128 i_datallowconn =
PQfnumber(dbres,
"datallowconn");
1129 i_datconnlimit =
PQfnumber(dbres,
"datconnlimit");
1132 for (dbnum = 0; dbnum < ntups; dbnum++)
1138 if (strcmp(
datname,
"template0") == 0)
1142 pg_fatal(
"template0 must not allow connections, "
1143 "i.e. its pg_database.datallowconn must be false");
1154 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1155 pg_fatal(
"could not open file \"%s\": %m", output_path);
1170 pg_fatal(
"All non-template0 databases must allow connections, i.e. their\n"
1171 "pg_database.datallowconn must be true and pg_database.datconnlimit\n"
1172 "must not be -2. Your installation contains non-template0 databases\n"
1173 "which cannot be connected to. Consider allowing connection for all\n"
1174 "non-template0 databases or drop the databases which do not allow\n"
1175 "connections. A list of databases with the problem is in the file:\n"
1176 " %s", output_path);
1195 prep_status(
"Checking for prepared transactions");
1199 "FROM pg_catalog.pg_prepared_xacts");
1204 pg_fatal(
"The source cluster contains prepared transactions");
1206 pg_fatal(
"The target cluster contains prepared transactions");
1236 if (report->
file == NULL &&
1238 pg_fatal(
"could not open file \"%s\": %m", report->
path);
1242 for (
int rowno = 0; rowno < ntups; rowno++)
1260 const char *query =
"SELECT n.nspname, p.proname "
1261 "FROM pg_catalog.pg_proc p, "
1262 " pg_catalog.pg_namespace n "
1263 "WHERE p.pronamespace = n.oid AND "
1264 " p.probin = '$libdir/isn'";
1266 prep_status(
"Checking for contrib/isn with bigint-passing mismatch");
1279 "contrib_isn_and_int8_pass_by_value.txt");
1289 fclose(report.
file);
1291 pg_fatal(
"Your installation contains \"contrib/isn\" functions which rely on the\n"
1292 "bigint data type. Your old and new clusters pass bigint values\n"
1293 "differently so this cluster cannot currently be upgraded. You can\n"
1294 "manually dump databases in the old cluster that use \"contrib/isn\"\n"
1295 "facilities, drop them, perform the upgrade, and then restore them. A\n"
1296 "list of the problem functions is in the file:\n"
1297 " %s", report.
path);
1325 if (report->
file == NULL &&
1327 pg_fatal(
"could not open file \"%s\": %m", report->
path);
1331 for (
int rowno = 0; rowno < ntups; rowno++)
1332 fprintf(report->
file,
" (oid=%s) %s.%s (%s.%s, NONE)\n",
1356 query =
"SELECT o.oid AS oproid, "
1357 " n.nspname AS oprnsp, "
1359 " tn.nspname AS typnsp, "
1361 "FROM pg_catalog.pg_operator o, "
1362 " pg_catalog.pg_namespace n, "
1363 " pg_catalog.pg_type t, "
1364 " pg_catalog.pg_namespace tn "
1365 "WHERE o.oprnamespace = n.oid AND "
1366 " o.oprleft = t.oid AND "
1367 " t.typnamespace = tn.oid AND "
1368 " o.oprright = 0 AND "
1371 prep_status(
"Checking for user-defined postfix operators");
1385 fclose(report.
file);
1387 pg_fatal(
"Your installation contains user-defined postfix operators, which are not\n"
1388 "supported anymore. Consider dropping the postfix operators and replacing\n"
1389 "them with prefix operators or function calls.\n"
1390 "A list of user-defined postfix operators is in the file:\n"
1391 " %s", report.
path);
1416 if (report->
file == NULL &&
1418 pg_fatal(
"could not open file \"%s\": %m", report->
path);
1422 for (
int rowno = 0; rowno < ntups; rowno++)
1442 prep_status(
"Checking for incompatible polymorphic functions");
1447 "incompatible_polymorphics.txt");
1453 "'array_append(anyarray,anyelement)'"
1454 ", 'array_cat(anyarray,anyarray)'"
1455 ", 'array_prepend(anyelement,anyarray)'");
1459 ", 'array_remove(anyarray,anyelement)'"
1460 ", 'array_replace(anyarray,anyelement,anyelement)'");
1464 ", 'array_position(anyarray,anyelement)'"
1465 ", 'array_position(anyarray,anyelement,integer)'"
1466 ", 'array_positions(anyarray,anyelement)'"
1467 ", 'width_bucket(anyelement,anyarray)'");
1477 query =
psprintf(
"SELECT 'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
1478 "FROM pg_proc AS p "
1479 "JOIN pg_aggregate AS a ON a.aggfnoid=p.oid "
1480 "JOIN pg_proc AS transfn ON transfn.oid=a.aggtransfn "
1481 "WHERE p.oid >= 16384 "
1482 "AND a.aggtransfn = ANY(ARRAY[%s]::regprocedure[]) "
1483 "AND a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
1487 "SELECT 'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
1488 "FROM pg_proc AS p "
1489 "JOIN pg_aggregate AS a ON a.aggfnoid=p.oid "
1490 "JOIN pg_proc AS finalfn ON finalfn.oid=a.aggfinalfn "
1491 "WHERE p.oid >= 16384 "
1492 "AND a.aggfinalfn = ANY(ARRAY[%s]::regprocedure[]) "
1493 "AND a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
1497 "SELECT 'operator' AS objkind, op.oid::regoperator::text AS objname "
1498 "FROM pg_operator AS op "
1499 "WHERE op.oid >= 16384 "
1500 "AND oprcode = ANY(ARRAY[%s]::regprocedure[]) "
1501 "AND oprleft = ANY(ARRAY['anyarray', 'anyelement']::regtype[])",
1502 old_polymorphics.
data,
1503 old_polymorphics.
data,
1504 old_polymorphics.
data);
1513 fclose(report.
file);
1515 pg_fatal(
"Your installation contains user-defined objects that refer to internal\n"
1516 "polymorphic functions with arguments of type \"anyarray\" or \"anyelement\".\n"
1517 "These user-defined objects must be dropped before upgrading and restored\n"
1518 "afterwards, changing them to refer to the new corresponding functions with\n"
1519 "arguments of type \"anycompatiblearray\" and \"anycompatible\".\n"
1520 "A list of the problematic objects is in the file:\n"
1521 " %s", report.
path);
1548 if (report->
file == NULL &&
1550 pg_fatal(
"could not open file \"%s\": %m", report->
path);
1554 for (
int rowno = 0; rowno < ntups; rowno++)
1568 const char *query =
"SELECT n.nspname, c.relname "
1569 "FROM pg_catalog.pg_class c, "
1570 " pg_catalog.pg_namespace n "
1571 "WHERE c.relnamespace = n.oid AND "
1573 " n.nspname NOT IN ('pg_catalog')";
1580 "tables_with_oids.txt");
1589 fclose(report.
file);
1591 pg_fatal(
"Your installation contains tables declared WITH OIDS, which is not\n"
1592 "supported anymore. Consider removing the oid column using\n"
1593 " ALTER TABLE ... SET WITHOUT OIDS;\n"
1594 "A list of tables with the problem is in the file:\n"
1595 " %s", report.
path);
1615 FILE *script = NULL;
1618 prep_status(
"Checking for roles starting with \"pg_\"");
1620 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1622 "pg_role_prefix.txt");
1625 "SELECT oid AS roloid, rolname "
1626 "FROM pg_catalog.pg_roles "
1627 "WHERE rolname ~ '^pg_'");
1632 for (
int rowno = 0; rowno < ntups; rowno++)
1634 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1635 pg_fatal(
"could not open file \"%s\": %m", output_path);
1636 fprintf(script,
"%s (oid=%s)\n",
1649 pg_fatal(
"Your installation contains roles starting with \"pg_\".\n"
1650 "\"pg_\" is a reserved prefix for system roles. The cluster\n"
1651 "cannot be upgraded until these roles are renamed.\n"
1652 "A list of roles starting with \"pg_\" is in the file:\n"
1653 " %s", output_path);
1680 if (report->
file == NULL &&
1682 pg_fatal(
"could not open file \"%s\": %m", report->
path);
1686 for (
int rowno = 0; rowno < ntups; rowno++)
1703 prep_status(
"Checking for user-defined encoding conversions");
1708 "encoding_conversions.txt");
1716 query =
"SELECT c.oid as conoid, c.conname, n.nspname "
1717 "FROM pg_catalog.pg_conversion c, "
1718 " pg_catalog.pg_namespace n "
1719 "WHERE c.connamespace = n.oid AND "
1730 fclose(report.
file);
1732 pg_fatal(
"Your installation contains user-defined encoding conversions.\n"
1733 "The conversion function parameters changed in PostgreSQL version 14\n"
1734 "so this cluster cannot currently be upgraded. You can remove the\n"
1735 "encoding conversions in the old cluster and restart the upgrade.\n"
1736 "A list of user-defined encoding conversions is in the file:\n"
1737 " %s", report.
path);
1766 if (nslots_on_old == 0)
1771 prep_status(
"Checking for new cluster logical replication slots");
1774 "FROM pg_catalog.pg_replication_slots "
1775 "WHERE slot_type = 'logical' AND "
1776 "temporary IS FALSE;");
1779 pg_fatal(
"could not count the number of logical replication slots");
1784 pg_fatal(
"expected 0 logical replication slots but found %d",
1790 "WHERE name IN ('wal_level', 'max_replication_slots') "
1791 "ORDER BY name DESC;");
1794 pg_fatal(
"could not determine parameter settings on new cluster");
1799 pg_fatal(
"\"wal_level\" must be \"logical\" but is set to \"%s\"",
1805 pg_fatal(
"\"max_replication_slots\" (%d) must be greater than or equal to the number of "
1806 "logical replication slots (%d) on the old cluster",
1837 prep_status(
"Checking for new cluster configuration for subscriptions");
1842 "WHERE name = 'max_replication_slots';");
1845 pg_fatal(
"could not determine parameter settings on new cluster");
1849 pg_fatal(
"\"max_replication_slots\" (%d) must be greater than or equal to the number of "
1850 "subscriptions (%d) on the old cluster",
1869 FILE *script = NULL;
1871 prep_status(
"Checking for valid logical replication slots");
1873 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1875 "invalid_logical_slots.txt");
1881 for (
int slotnum = 0; slotnum < slot_arr->
nslots; slotnum++)
1888 if (script == NULL &&
1889 (script =
fopen_priv(output_path,
"w")) == NULL)
1890 pg_fatal(
"could not open file \"%s\": %m", output_path);
1892 fprintf(script,
"The slot \"%s\" is invalid\n",
1907 if (script == NULL &&
1908 (script =
fopen_priv(output_path,
"w")) == NULL)
1909 pg_fatal(
"could not open file \"%s\": %m", output_path);
1912 "The slot \"%s\" has not consumed the WAL yet\n",
1923 pg_fatal(
"Your installation contains logical replication slots that cannot be upgraded.\n"
1924 "You can remove invalid slots and/or consume the pending WAL for other slots,\n"
1925 "and then restart the upgrade.\n"
1926 "A list of the problematic slots is in the file:\n"
1927 " %s", output_path);
1953 if (report->
file == NULL &&
1955 pg_fatal(
"could not open file \"%s\": %m", report->
path);
1957 for (
int i = 0;
i < ntups;
i++)
1958 fprintf(report->
file,
"The table sync state \"%s\" is not allowed for database:\"%s\" subscription:\"%s\" schema:\"%s\" relation:\"%s\"\n",
1988 "subs_invalid.txt");
1996 "SELECT d.datname, s.subname "
1997 "FROM pg_catalog.pg_subscription s "
1998 "LEFT OUTER JOIN pg_catalog.pg_replication_origin o "
1999 " ON o.roname = 'pg_' || s.oid "
2000 "INNER JOIN pg_catalog.pg_database d "
2001 " ON d.oid = s.subdbid "
2002 "WHERE o.roname IS NULL;");
2004 for (
int i = 0;
i < ntup;
i++)
2006 if (report.
file == NULL &&
2008 pg_fatal(
"could not open file \"%s\": %m", report.
path);
2009 fprintf(report.
file,
"The replication origin is missing for database:\"%s\" subscription:\"%s\"\n",
2044 query =
"SELECT r.srsubstate, s.subname, n.nspname, c.relname "
2045 "FROM pg_catalog.pg_subscription_rel r "
2046 "LEFT JOIN pg_catalog.pg_subscription s"
2047 " ON r.srsubid = s.oid "
2048 "LEFT JOIN pg_catalog.pg_class c"
2049 " ON r.srrelid = c.oid "
2050 "LEFT JOIN pg_catalog.pg_namespace n"
2051 " ON c.relnamespace = n.oid "
2052 "WHERE r.srsubstate NOT IN ('i', 'r') "
2053 "ORDER BY s.subname";
2063 fclose(report.
file);
2065 pg_fatal(
"Your installation contains subscriptions without origin or having relations not in i (initialize) or r (ready) state.\n"
2066 "You can allow the initial sync to finish for all relations and then restart the upgrade.\n"
2067 "A list of the problematic subscriptions is in the file:\n"
2068 " %s", report.
path);
#define AssertVariableIsOfType(varname, typename)
#define Assert(condition)
void check_cluster_versions(void)
static void check_for_tables_with_oids(ClusterInfo *cluster)
static void check_for_pg_role_prefix(ClusterInfo *cluster)
static void process_old_sub_state_check(DbInfo *dbinfo, PGresult *res, void *arg)
static void check_for_data_types_usage(ClusterInfo *cluster)
static char * data_type_check_query(int checknum)
static void process_incompat_polymorphics(DbInfo *dbinfo, PGresult *res, void *arg)
static DataTypesUsageChecks data_types_usage_checks[]
static void process_with_oids_check(DbInfo *dbinfo, PGresult *res, void *arg)
static void check_new_cluster_logical_replication_slots(void)
static void check_old_cluster_subscription_state(void)
void issue_warnings_and_set_wal_level(void)
void check_cluster_compatibility(void)
void check_new_cluster(void)
void report_clusters_compatible(void)
static void check_is_install_user(ClusterInfo *cluster)
static void check_new_cluster_subscription_configuration(void)
void create_script_for_old_cluster_deletion(char **deletion_script_file_name)
static void check_for_connection_status(ClusterInfo *cluster)
static void process_user_defined_encoding_conversions(DbInfo *dbinfo, PGresult *res, void *arg)
static void process_data_type_check(DbInfo *dbinfo, PGresult *res, void *arg)
void check_and_dump_old_cluster(void)
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
static char * fix_path_separator(char *path)
static void check_new_cluster_is_empty(void)
static void check_old_cluster_for_valid_slots(void)
static void process_isn_and_int8_passing_mismatch(DbInfo *dbinfo, PGresult *res, void *arg)
static void check_for_user_defined_postfix_ops(ClusterInfo *cluster)
void output_completion_banner(char *deletion_script_file_name)
static void check_for_prepared_transactions(ClusterInfo *cluster)
static void check_for_new_tablespace_dir(void)
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster)
static void check_for_incompatible_polymorphics(ClusterInfo *cluster)
void output_check_banner(void)
static void process_user_defined_postfix_ops(DbInfo *dbinfo, PGresult *res, void *arg)
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
void get_control_data(ClusterInfo *cluster)
void check_control_data(ControlData *oldctrl, ControlData *newctrl)
#define fprintf(file, fmt, msg)
static void PGresult * res
void generate_old_dump(void)
void PQfinish(PGconn *conn)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQntuples(const PGresult *res)
int PQfnumber(const PGresult *res, const char *field_name)
char * pg_strdup(const char *in)
void * pg_malloc0(size_t size)
void check_file_clone(void)
void check_hard_link(void)
void check_copy_file_range(void)
void check_loadable_libraries(void)
void get_loadable_libraries(void)
void get_subscription_count(ClusterInfo *cluster)
int count_old_cluster_logical_slots(void)
void get_db_rel_and_slot_infos(ClusterInfo *cluster)
static void check_ok(void)
void pfree(void *pointer)
static struct LogicalRepInfo * dbinfo
static pid_t start_postmaster(void)
UpgradeTask * upgrade_task_create(void)
void init_tablespaces(void)
bool(* DataTypesUsageVersionCheck)(ClusterInfo *cluster)
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
bool jsonb_9_4_check_applicable(ClusterInfo *cluster)
void upgrade_task_run(const UpgradeTask *task, const ClusterInfo *cluster)
void cleanup_output_dirs(void)
void report_extension_updates(ClusterInfo *cluster)
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
@ TRANSFER_MODE_COPY_FILE_RANGE
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2
void upgrade_task_free(UpgradeTask *task)
#define fopen_priv(path, mode)
void(* UpgradeTaskProcessCB)(DbInfo *dbinfo, PGresult *res, void *arg)
#define GET_MAJOR_VERSION(v)
void stop_postmaster(bool in_atexit)
void prep_status(const char *fmt,...) pg_attribute_printf(1
void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
void upgrade_task_add_step(UpgradeTask *task, const char *query, UpgradeTaskProcessCB process_cb, bool free_result, void *arg)
bool path_is_prefix_of_path(const char *path1, const char *path2)
void canonicalize_path(char *path)
size_t strlcpy(char *dst, const char *src, size_t siz)
PQExpBuffer createPQExpBuffer(void)
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void destroyPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
char * psprintf(const char *fmt,...)
int max_replication_slots
void appendShellString(PQExpBuffer buf, const char *str)
const char * tablespace_suffix
bool float8_pass_by_value
DataTypesUsageVersionCheck version_hook
const char * report_filename
LogicalSlotInfoArr slot_arr
transferMode transfer_mode
DataTypesUsageChecks * check