12 #include "catalog/pg_authid_d.h"
13 #include "catalog/pg_class_d.h"
61 #define MANUAL_CHECK 1
62 #define ALL_VERSIONS -1
112 .report_filename =
"tables_using_composite.txt",
114 "SELECT t.oid FROM pg_catalog.pg_type t "
115 "LEFT JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid "
116 " WHERE typtype = 'c' AND (t.oid < 16384 OR nspname = 'information_schema')",
118 gettext_noop(
"Your installation contains system-defined composite types in user tables.\n"
119 "These type OIDs are not stable across PostgreSQL versions,\n"
120 "so this cluster cannot currently be upgraded. You can drop the\n"
121 "problem columns and restart the upgrade.\n"),
132 .status =
gettext_noop(
"Checking for incompatible \"line\" data type"),
133 .report_filename =
"tables_using_line.txt",
135 "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
137 gettext_noop(
"Your installation contains the \"line\" data type in user tables.\n"
138 "this data type changed its internal and input/output format\n"
139 "between your old and new versions so this\n"
140 "cluster cannot currently be upgraded. You can\n"
141 "drop the problem columns and restart the upgrade.\n"),
142 .threshold_version = 903
154 .status =
gettext_noop(
"Checking for reg* data types in user tables"),
155 .report_filename =
"tables_using_reg.txt",
163 "SELECT oid FROM pg_catalog.pg_type t "
164 "WHERE t.typnamespace = "
165 " (SELECT oid FROM pg_catalog.pg_namespace "
166 " WHERE nspname = 'pg_catalog') "
167 " AND t.typname IN ( "
181 gettext_noop(
"Your installation contains one of the reg* data types in user tables.\n"
182 "These data types reference system OIDs that are not preserved by\n"
183 "pg_upgrade, so this cluster cannot currently be upgraded. You can\n"
184 "drop the problem columns and restart the upgrade.\n"),
193 .status =
gettext_noop(
"Checking for incompatible \"aclitem\" data type"),
194 .report_filename =
"tables_using_aclitem.txt",
196 "SELECT 'pg_catalog.aclitem'::pg_catalog.regtype AS oid",
198 gettext_noop(
"Your installation contains the \"aclitem\" data type in user tables.\n"
199 "The internal format of \"aclitem\" changed in PostgreSQL version 16\n"
200 "so this cluster cannot currently be upgraded. You can drop the\n"
201 "problem columns and restart the upgrade.\n"),
202 .threshold_version = 1500
217 .status =
gettext_noop(
"Checking for invalid \"unknown\" user columns"),
218 .report_filename =
"tables_using_unknown.txt",
220 "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
222 gettext_noop(
"Your installation contains the \"unknown\" data type in user tables.\n"
223 "This data type is no longer allowed in tables, so this cluster\n"
224 "cannot currently be upgraded. You can drop the problem columns\n"
225 "and restart the upgrade.\n"),
226 .threshold_version = 906
239 .status =
gettext_noop(
"Checking for invalid \"sql_identifier\" user columns"),
240 .report_filename =
"tables_using_sql_identifier.txt",
242 "SELECT 'information_schema.sql_identifier'::pg_catalog.regtype AS oid",
244 gettext_noop(
"Your installation contains the \"sql_identifier\" data type in user tables.\n"
245 "The on-disk format for this data type has changed, so this\n"
246 "cluster cannot currently be upgraded. You can drop the problem\n"
247 "columns and restart the upgrade.\n"),
248 .threshold_version = 1100
255 .status =
gettext_noop(
"Checking for incompatible \"jsonb\" data type in user tables"),
256 .report_filename =
"tables_using_jsonb.txt",
258 "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
260 gettext_noop(
"Your installation contains the \"jsonb\" data type in user tables.\n"
261 "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
262 "cluster cannot currently be upgraded. You can drop the problem \n"
263 "columns and restart the upgrade.\n"),
272 .status =
gettext_noop(
"Checking for removed \"abstime\" data type in user tables"),
273 .report_filename =
"tables_using_abstime.txt",
275 "SELECT 'pg_catalog.abstime'::pg_catalog.regtype AS oid",
277 gettext_noop(
"Your installation contains the \"abstime\" data type in user tables.\n"
278 "The \"abstime\" type has been removed in PostgreSQL version 12,\n"
279 "so this cluster cannot currently be upgraded. You can drop the\n"
280 "problem columns, or change them to another data type, and restart\n"
282 .threshold_version = 1100
285 .status =
gettext_noop(
"Checking for removed \"reltime\" data type in user tables"),
286 .report_filename =
"tables_using_reltime.txt",
288 "SELECT 'pg_catalog.reltime'::pg_catalog.regtype AS oid",
290 gettext_noop(
"Your installation contains the \"reltime\" data type in user tables.\n"
291 "The \"reltime\" type has been removed in PostgreSQL version 12,\n"
292 "so this cluster cannot currently be upgraded. You can drop the\n"
293 "problem columns, or change them to another data type, and restart\n"
295 .threshold_version = 1100
298 .status =
gettext_noop(
"Checking for removed \"tinterval\" data type in user tables"),
299 .report_filename =
"tables_using_tinterval.txt",
301 "SELECT 'pg_catalog.tinterval'::pg_catalog.regtype AS oid",
303 gettext_noop(
"Your installation contains the \"tinterval\" data type in user tables.\n"
304 "The \"tinterval\" type has been removed in PostgreSQL version 12,\n"
305 "so this cluster cannot currently be upgraded. You can drop the\n"
306 "problem columns, or change them to another data type, and restart\n"
308 .threshold_version = 1100
313 NULL, NULL, NULL, NULL, 0, NULL
343 int n_data_types_usage_checks = 0;
348 while (tmp->
status != NULL)
350 n_data_types_usage_checks++;
355 results =
pg_malloc0(
sizeof(
bool) * n_data_types_usage_checks);
361 for (
int dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
366 for (
int checknum = 0; checknum < n_data_types_usage_checks; checknum++)
374 bool db_used =
false;
398 snprintf(output_path,
sizeof(output_path),
"%s/%s",
410 "WITH RECURSIVE oids AS ( "
416 " WITH x AS (SELECT oid FROM oids) "
418 " SELECT t.oid FROM pg_catalog.pg_type t, x WHERE typbasetype = x.oid AND typtype = 'd' "
421 " SELECT t.oid FROM pg_catalog.pg_type t, x WHERE typelem = x.oid AND typtype = 'b' "
424 " SELECT t.oid FROM pg_catalog.pg_type t, pg_catalog.pg_class c, pg_catalog.pg_attribute a, x "
425 " WHERE t.typtype = 'c' AND "
426 " t.oid = c.reltype AND "
427 " c.oid = a.attrelid AND "
428 " NOT a.attisdropped AND "
429 " a.atttypid = x.oid "
432 " SELECT t.oid FROM pg_catalog.pg_type t, pg_catalog.pg_range r, x "
433 " WHERE t.typtype = 'r' AND r.rngtypid = t.oid AND r.rngsubtype = x.oid"
437 "SELECT n.nspname, c.relname, a.attname "
438 "FROM pg_catalog.pg_class c, "
439 " pg_catalog.pg_namespace n, "
440 " pg_catalog.pg_attribute a "
441 "WHERE c.oid = a.attrelid AND "
442 " NOT a.attisdropped AND "
443 " a.atttypid IN (SELECT oid FROM oids) AND "
448 " c.relnamespace = n.oid AND "
450 " n.nspname !~ '^pg_temp_' AND "
451 " n.nspname !~ '^pg_toast_temp_' AND "
453 " n.nspname NOT IN ('pg_catalog', 'information_schema')",
478 if (!results[checknum])
483 _(
"A list of the problem columns is in the file:"),
486 results[checknum] =
true;
492 for (
int rowno = 0; rowno < ntups; rowno++)
494 if (script == NULL && (script =
fopen_priv(output_path,
"a")) == NULL)
495 pg_fatal(
"could not open file \"%s\": %m", output_path);
546 for (
c = result; *
c !=
'\0';
c++)
563 "Performing Consistency Checks on Old Live Server\n"
564 "------------------------------------------------");
569 "Performing Consistency Checks\n"
570 "-----------------------------");
725 "If pg_upgrade fails after this point, you must re-initdb the\n"
726 "new cluster before continuing.");
765 "Optimizer statistics are not transferred by pg_upgrade.\n"
766 "Once you start the new server, consider running:\n"
769 if (deletion_script_file_name)
771 "Running this script will delete the old cluster's data files:\n"
773 deletion_script_file_name);
776 "Could not create a script to delete the old cluster's data files\n"
777 "because user-defined tablespaces or the new cluster's data directory\n"
778 "exist in the old cluster directory. The old cluster's contents must\n"
779 "be deleted manually.");
800 pg_fatal(
"This utility can only upgrade from PostgreSQL version %s and later.",
805 pg_fatal(
"This utility can only upgrade to PostgreSQL version %s.",
814 pg_fatal(
"This utility cannot be used to downgrade to older major PostgreSQL versions.");
819 pg_fatal(
"Old cluster data and binary directories are from different major versions.");
822 pg_fatal(
"New cluster data and binary directories are from different major versions.");
837 pg_fatal(
"When checking a live server, "
838 "the old and new port numbers must be different.");
852 for (relnum = 0; relnum < rel_arr->
nrels;
856 if (strcmp(rel_arr->
rels[relnum].
nspname,
"pg_catalog") != 0)
857 pg_fatal(
"New cluster database \"%s\" is not empty: found relation \"%s.%s\"",
880 prep_status(
"Checking for new cluster tablespace directories");
890 if (
stat(new_tablespace_dir, &statbuf) == 0 || errno != ENOENT)
891 pg_fatal(
"new cluster tablespace directory already exists: \"%s\"",
911 *deletion_script_file_name =
psprintf(
"%sdelete_old_cluster.%s",
924 "\nWARNING: new data directory should not be inside the old data directory, i.e. %s", old_cluster_pgdata);
927 unlink(*deletion_script_file_name);
928 pg_free(*deletion_script_file_name);
929 *deletion_script_file_name = NULL;
948 "\nWARNING: user-defined tablespace locations should not be inside the data directory, i.e. %s", old_tablespace_dir);
951 unlink(*deletion_script_file_name);
952 pg_free(*deletion_script_file_name);
953 *deletion_script_file_name = NULL;
958 prep_status(
"Creating script to delete old cluster");
960 if ((script =
fopen_priv(*deletion_script_file_name,
"w")) == NULL)
961 pg_fatal(
"could not open file \"%s\": %m",
962 *deletion_script_file_name);
966 fprintf(script,
"#!/bin/sh\n\n");
1011 if (chmod(*deletion_script_file_name,
S_IRWXU) != 0)
1012 pg_fatal(
"could not add execute permission to file \"%s\": %m",
1013 *deletion_script_file_name);
1032 prep_status(
"Checking database user is the install user");
1036 "SELECT rolsuper, oid "
1037 "FROM pg_catalog.pg_roles "
1038 "WHERE rolname = current_user "
1039 "AND rolname !~ '^pg_'");
1048 pg_fatal(
"database user \"%s\" is not the install user",
1055 "FROM pg_catalog.pg_roles "
1056 "WHERE rolname !~ '^pg_'");
1059 pg_fatal(
"could not determine the number of users");
1067 pg_fatal(
"Only the install user can be defined in the new cluster.");
1093 FILE *script = NULL;
1096 prep_status(
"Checking database connection settings");
1098 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1100 "databases_with_datallowconn_false.txt");
1106 "SELECT datname, datallowconn "
1107 "FROM pg_catalog.pg_database");
1109 i_datname =
PQfnumber(dbres,
"datname");
1110 i_datallowconn =
PQfnumber(dbres,
"datallowconn");
1113 for (dbnum = 0; dbnum < ntups; dbnum++)
1118 if (strcmp(
datname,
"template0") == 0)
1122 pg_fatal(
"template0 must not allow connections, "
1123 "i.e. its pg_database.datallowconn must be false");
1133 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1134 pg_fatal(
"could not open file \"%s\": %m", output_path);
1149 pg_fatal(
"All non-template0 databases must allow connections, i.e. their\n"
1150 "pg_database.datallowconn must be true. Your installation contains\n"
1151 "non-template0 databases with their pg_database.datallowconn set to\n"
1152 "false. Consider allowing connection for all non-template0 databases\n"
1153 "or drop the databases which do not allow connections. A list of\n"
1154 "databases with the problem is in the file:\n"
1155 " %s", output_path);
1174 prep_status(
"Checking for prepared transactions");
1178 "FROM pg_catalog.pg_prepared_xacts");
1183 pg_fatal(
"The source cluster contains prepared transactions");
1185 pg_fatal(
"The target cluster contains prepared transactions");
1207 FILE *script = NULL;
1210 prep_status(
"Checking for contrib/isn with bigint-passing mismatch");
1220 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1222 "contrib_isn_and_int8_pass_by_value.txt");
1224 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1227 bool db_used =
false;
1237 "SELECT n.nspname, p.proname "
1238 "FROM pg_catalog.pg_proc p, "
1239 " pg_catalog.pg_namespace n "
1240 "WHERE p.pronamespace = n.oid AND "
1241 " p.probin = '$libdir/isn'");
1246 for (rowno = 0; rowno < ntups; rowno++)
1248 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1249 pg_fatal(
"could not open file \"%s\": %m", output_path);
1269 pg_fatal(
"Your installation contains \"contrib/isn\" functions which rely on the\n"
1270 "bigint data type. Your old and new clusters pass bigint values\n"
1271 "differently so this cluster cannot currently be upgraded. You can\n"
1272 "manually dump databases in the old cluster that use \"contrib/isn\"\n"
1273 "facilities, drop them, perform the upgrade, and then restore them. A\n"
1274 "list of the problem functions is in the file:\n"
1275 " %s", output_path);
1288 FILE *script = NULL;
1291 prep_status(
"Checking for user-defined postfix operators");
1293 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1298 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1301 bool db_used =
false;
1319 "SELECT o.oid AS oproid, "
1320 " n.nspname AS oprnsp, "
1322 " tn.nspname AS typnsp, "
1324 "FROM pg_catalog.pg_operator o, "
1325 " pg_catalog.pg_namespace n, "
1326 " pg_catalog.pg_type t, "
1327 " pg_catalog.pg_namespace tn "
1328 "WHERE o.oprnamespace = n.oid AND "
1329 " o.oprleft = t.oid AND "
1330 " t.typnamespace = tn.oid AND "
1331 " o.oprright = 0 AND "
1339 for (rowno = 0; rowno < ntups; rowno++)
1341 if (script == NULL &&
1342 (script =
fopen_priv(output_path,
"w")) == NULL)
1343 pg_fatal(
"could not open file \"%s\": %m", output_path);
1349 fprintf(script,
" (oid=%s) %s.%s (%s.%s, NONE)\n",
1366 pg_fatal(
"Your installation contains user-defined postfix operators, which are not\n"
1367 "supported anymore. Consider dropping the postfix operators and replacing\n"
1368 "them with prefix operators or function calls.\n"
1369 "A list of user-defined postfix operators is in the file:\n"
1370 " %s", output_path);
1386 FILE *script = NULL;
1390 prep_status(
"Checking for incompatible polymorphic functions");
1392 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1394 "incompatible_polymorphics.txt");
1400 "'array_append(anyarray,anyelement)'"
1401 ", 'array_cat(anyarray,anyarray)'"
1402 ", 'array_prepend(anyelement,anyarray)'");
1406 ", 'array_remove(anyarray,anyelement)'"
1407 ", 'array_replace(anyarray,anyelement,anyelement)'");
1411 ", 'array_position(anyarray,anyelement)'"
1412 ", 'array_position(anyarray,anyelement,integer)'"
1413 ", 'array_positions(anyarray,anyelement)'"
1414 ", 'width_bucket(anyelement,anyarray)'");
1416 for (
int dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1418 bool db_used =
false;
1433 "SELECT 'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
1434 "FROM pg_proc AS p "
1435 "JOIN pg_aggregate AS a ON a.aggfnoid=p.oid "
1436 "JOIN pg_proc AS transfn ON transfn.oid=a.aggtransfn "
1437 "WHERE p.oid >= 16384 "
1438 "AND a.aggtransfn = ANY(ARRAY[%s]::regprocedure[]) "
1439 "AND a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
1443 "SELECT 'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
1444 "FROM pg_proc AS p "
1445 "JOIN pg_aggregate AS a ON a.aggfnoid=p.oid "
1446 "JOIN pg_proc AS finalfn ON finalfn.oid=a.aggfinalfn "
1447 "WHERE p.oid >= 16384 "
1448 "AND a.aggfinalfn = ANY(ARRAY[%s]::regprocedure[]) "
1449 "AND a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
1453 "SELECT 'operator' AS objkind, op.oid::regoperator::text AS objname "
1454 "FROM pg_operator AS op "
1455 "WHERE op.oid >= 16384 "
1456 "AND oprcode = ANY(ARRAY[%s]::regprocedure[]) "
1457 "AND oprleft = ANY(ARRAY['anyarray', 'anyelement']::regtype[]);",
1458 old_polymorphics.
data,
1459 old_polymorphics.
data,
1460 old_polymorphics.
data);
1467 for (
int rowno = 0; rowno < ntups; rowno++)
1469 if (script == NULL &&
1470 (script =
fopen_priv(output_path,
"w")) == NULL)
1471 pg_fatal(
"could not open file \"%s\": %m", output_path);
1491 pg_fatal(
"Your installation contains user-defined objects that refer to internal\n"
1492 "polymorphic functions with arguments of type \"anyarray\" or \"anyelement\".\n"
1493 "These user-defined objects must be dropped before upgrading and restored\n"
1494 "afterwards, changing them to refer to the new corresponding functions with\n"
1495 "arguments of type \"anycompatiblearray\" and \"anycompatible\".\n"
1496 "A list of the problematic objects is in the file:\n"
1497 " %s", output_path);
1512 FILE *script = NULL;
1517 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1519 "tables_with_oids.txt");
1522 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1525 bool db_used =
false;
1534 "SELECT n.nspname, c.relname "
1535 "FROM pg_catalog.pg_class c, "
1536 " pg_catalog.pg_namespace n "
1537 "WHERE c.relnamespace = n.oid AND "
1539 " n.nspname NOT IN ('pg_catalog')");
1544 for (rowno = 0; rowno < ntups; rowno++)
1546 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1547 pg_fatal(
"could not open file \"%s\": %m", output_path);
1567 pg_fatal(
"Your installation contains tables declared WITH OIDS, which is not\n"
1568 "supported anymore. Consider removing the oid column using\n"
1569 " ALTER TABLE ... SET WITHOUT OIDS;\n"
1570 "A list of tables with the problem is in the file:\n"
1571 " %s", output_path);
1591 FILE *script = NULL;
1594 prep_status(
"Checking for roles starting with \"pg_\"");
1596 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1598 "pg_role_prefix.txt");
1601 "SELECT oid AS roloid, rolname "
1602 "FROM pg_catalog.pg_roles "
1603 "WHERE rolname ~ '^pg_'");
1608 for (
int rowno = 0; rowno < ntups; rowno++)
1610 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1611 pg_fatal(
"could not open file \"%s\": %m", output_path);
1612 fprintf(script,
"%s (oid=%s)\n",
1625 pg_fatal(
"Your installation contains roles starting with \"pg_\".\n"
1626 "\"pg_\" is a reserved prefix for system roles. The cluster\n"
1627 "cannot be upgraded until these roles are renamed.\n"
1628 "A list of roles starting with \"pg_\" is in the file:\n"
1629 " %s", output_path);
1642 FILE *script = NULL;
1645 prep_status(
"Checking for user-defined encoding conversions");
1647 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1649 "encoding_conversions.txt");
1652 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1655 bool db_used =
false;
1671 "SELECT c.oid as conoid, c.conname, n.nspname "
1672 "FROM pg_catalog.pg_conversion c, "
1673 " pg_catalog.pg_namespace n "
1674 "WHERE c.connamespace = n.oid AND "
1680 for (rowno = 0; rowno < ntups; rowno++)
1682 if (script == NULL &&
1683 (script =
fopen_priv(output_path,
"w")) == NULL)
1684 pg_fatal(
"could not open file \"%s\": %m", output_path);
1690 fprintf(script,
" (oid=%s) %s.%s\n",
1705 pg_fatal(
"Your installation contains user-defined encoding conversions.\n"
1706 "The conversion function parameters changed in PostgreSQL version 14\n"
1707 "so this cluster cannot currently be upgraded. You can remove the\n"
1708 "encoding conversions in the old cluster and restart the upgrade.\n"
1709 "A list of user-defined encoding conversions is in the file:\n"
1710 " %s", output_path);
1739 if (nslots_on_old == 0)
1744 prep_status(
"Checking for new cluster logical replication slots");
1747 "FROM pg_catalog.pg_replication_slots "
1748 "WHERE slot_type = 'logical' AND "
1749 "temporary IS FALSE;");
1752 pg_fatal(
"could not count the number of logical replication slots");
1757 pg_fatal(
"Expected 0 logical replication slots but found %d.",
1763 "WHERE name IN ('wal_level', 'max_replication_slots') "
1764 "ORDER BY name DESC;");
1767 pg_fatal(
"could not determine parameter settings on new cluster");
1772 pg_fatal(
"wal_level must be \"logical\", but is set to \"%s\"",
1778 pg_fatal(
"max_replication_slots (%d) must be greater than or equal to the number of "
1779 "logical replication slots (%d) on the old cluster",
1810 if (nsubs_on_old == 0)
1813 prep_status(
"Checking for new cluster configuration for subscriptions");
1818 "WHERE name = 'max_replication_slots';");
1821 pg_fatal(
"could not determine parameter settings on new cluster");
1825 pg_fatal(
"max_replication_slots (%d) must be greater than or equal to the number of "
1826 "subscriptions (%d) on the old cluster",
1845 FILE *script = NULL;
1847 prep_status(
"Checking for valid logical replication slots");
1849 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1851 "invalid_logical_slots.txt");
1857 for (
int slotnum = 0; slotnum < slot_arr->
nslots; slotnum++)
1864 if (script == NULL &&
1865 (script =
fopen_priv(output_path,
"w")) == NULL)
1866 pg_fatal(
"could not open file \"%s\": %m", output_path);
1868 fprintf(script,
"The slot \"%s\" is invalid\n",
1883 if (script == NULL &&
1884 (script =
fopen_priv(output_path,
"w")) == NULL)
1885 pg_fatal(
"could not open file \"%s\": %m", output_path);
1888 "The slot \"%s\" has not consumed the WAL yet\n",
1899 pg_fatal(
"Your installation contains logical replication slots that can't be upgraded.\n"
1900 "You can remove invalid slots and/or consume the pending WAL for other slots,\n"
1901 "and then restart the upgrade.\n"
1902 "A list of the problematic slots is in the file:\n"
1903 " %s", output_path);
1919 FILE *script = NULL;
1925 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1927 "subs_invalid.txt");
1942 "SELECT d.datname, s.subname "
1943 "FROM pg_catalog.pg_subscription s "
1944 "LEFT OUTER JOIN pg_catalog.pg_replication_origin o "
1945 " ON o.roname = 'pg_' || s.oid "
1946 "INNER JOIN pg_catalog.pg_database d "
1947 " ON d.oid = s.subdbid "
1948 "WHERE o.roname iS NULL;");
1951 for (
int i = 0;
i < ntup;
i++)
1953 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1954 pg_fatal(
"could not open file \"%s\": %m", output_path);
1955 fprintf(script,
"The replication origin is missing for database:\"%s\" subscription:\"%s\"\n",
1991 "SELECT r.srsubstate, s.subname, n.nspname, c.relname "
1992 "FROM pg_catalog.pg_subscription_rel r "
1993 "LEFT JOIN pg_catalog.pg_subscription s"
1994 " ON r.srsubid = s.oid "
1995 "LEFT JOIN pg_catalog.pg_class c"
1996 " ON r.srrelid = c.oid "
1997 "LEFT JOIN pg_catalog.pg_namespace n"
1998 " ON c.relnamespace = n.oid "
1999 "WHERE r.srsubstate NOT IN ('i', 'r') "
2000 "ORDER BY s.subname");
2003 for (
int i = 0;
i < ntup;
i++)
2005 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
2006 pg_fatal(
"could not open file \"%s\": %m", output_path);
2008 fprintf(script,
"The table sync state \"%s\" is not allowed for database:\"%s\" subscription:\"%s\" schema:\"%s\" relation:\"%s\"\n",
2024 pg_fatal(
"Your installation contains subscriptions without origin or having relations not in i (initialize) or r (ready) state.\n"
2025 "You can allow the initial sync to finish for all relations and then restart the upgrade.\n"
2026 "A list of the problematic subscriptions is in the file:\n"
2027 " %s", output_path);
void output_check_banner(bool live_check)
void check_cluster_versions(void)
static void check_for_tables_with_oids(ClusterInfo *cluster)
static void check_for_pg_role_prefix(ClusterInfo *cluster)
void check_cluster_compatibility(bool live_check)
static DataTypesUsageChecks data_types_usage_checks[]
static void check_new_cluster_logical_replication_slots(void)
static void check_old_cluster_subscription_state(void)
void check_and_dump_old_cluster(bool live_check)
void issue_warnings_and_set_wal_level(void)
static char * fix_path_separator(char *path)
static void check_for_data_types_usage(ClusterInfo *cluster, DataTypesUsageChecks *checks)
static void check_old_cluster_for_valid_slots(bool live_check)
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_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
static void check_new_cluster_is_empty(void)
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_proper_datallowconn(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 cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
void get_control_data(ClusterInfo *cluster, bool live_check)
void check_control_data(ControlData *oldctrl, ControlData *newctrl)
static void PGresult * res
void generate_old_dump(void)
void PQfinish(PGconn *conn)
int PQntuples(const PGresult *res)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
void * pg_malloc0(size_t size)
char * pg_strdup(const char *in)
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)
int count_old_cluster_subscriptions(void)
void get_db_rel_and_slot_infos(ClusterInfo *cluster, bool live_check)
int count_old_cluster_logical_slots(void)
static void check_ok(void)
Assert(fmt[strlen(fmt) - 1] !='\n')
void pfree(void *pointer)
static pid_t start_postmaster(void)
void init_tablespaces(void)
bool(* DataTypesUsageVersionCheck)(ClusterInfo *cluster)
bool jsonb_9_4_check_applicable(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
#define fopen_priv(path, mode)
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
#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)
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2
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)
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
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