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 "-----------------------------");
727 "If pg_upgrade fails after this point, you must re-initdb the\n"
728 "new cluster before continuing.");
767 "Optimizer statistics are not transferred by pg_upgrade.\n"
768 "Once you start the new server, consider running:\n"
771 if (deletion_script_file_name)
773 "Running this script will delete the old cluster's data files:\n"
775 deletion_script_file_name);
778 "Could not create a script to delete the old cluster's data files\n"
779 "because user-defined tablespaces or the new cluster's data directory\n"
780 "exist in the old cluster directory. The old cluster's contents must\n"
781 "be deleted manually.");
802 pg_fatal(
"This utility can only upgrade from PostgreSQL version %s and later.",
807 pg_fatal(
"This utility can only upgrade to PostgreSQL version %s.",
816 pg_fatal(
"This utility cannot be used to downgrade to older major PostgreSQL versions.");
821 pg_fatal(
"Old cluster data and binary directories are from different major versions.");
824 pg_fatal(
"New cluster data and binary directories are from different major versions.");
839 pg_fatal(
"When checking a live server, "
840 "the old and new port numbers must be different.");
854 for (relnum = 0; relnum < rel_arr->
nrels;
858 if (strcmp(rel_arr->
rels[relnum].
nspname,
"pg_catalog") != 0)
859 pg_fatal(
"New cluster database \"%s\" is not empty: found relation \"%s.%s\"",
882 prep_status(
"Checking for new cluster tablespace directories");
892 if (
stat(new_tablespace_dir, &statbuf) == 0 || errno != ENOENT)
893 pg_fatal(
"new cluster tablespace directory already exists: \"%s\"",
913 *deletion_script_file_name =
psprintf(
"%sdelete_old_cluster.%s",
926 "\nWARNING: new data directory should not be inside the old data directory, i.e. %s", old_cluster_pgdata);
929 unlink(*deletion_script_file_name);
930 pg_free(*deletion_script_file_name);
931 *deletion_script_file_name = NULL;
950 "\nWARNING: user-defined tablespace locations should not be inside the data directory, i.e. %s", old_tablespace_dir);
953 unlink(*deletion_script_file_name);
954 pg_free(*deletion_script_file_name);
955 *deletion_script_file_name = NULL;
960 prep_status(
"Creating script to delete old cluster");
962 if ((script =
fopen_priv(*deletion_script_file_name,
"w")) == NULL)
963 pg_fatal(
"could not open file \"%s\": %m",
964 *deletion_script_file_name);
968 fprintf(script,
"#!/bin/sh\n\n");
1013 if (chmod(*deletion_script_file_name,
S_IRWXU) != 0)
1014 pg_fatal(
"could not add execute permission to file \"%s\": %m",
1015 *deletion_script_file_name);
1034 prep_status(
"Checking database user is the install user");
1038 "SELECT rolsuper, oid "
1039 "FROM pg_catalog.pg_roles "
1040 "WHERE rolname = current_user "
1041 "AND rolname !~ '^pg_'");
1050 pg_fatal(
"database user \"%s\" is not the install user",
1057 "FROM pg_catalog.pg_roles "
1058 "WHERE rolname !~ '^pg_'");
1061 pg_fatal(
"could not determine the number of users");
1069 pg_fatal(
"Only the install user can be defined in the new cluster.");
1095 FILE *script = NULL;
1098 prep_status(
"Checking database connection settings");
1100 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1102 "databases_with_datallowconn_false.txt");
1108 "SELECT datname, datallowconn "
1109 "FROM pg_catalog.pg_database");
1111 i_datname =
PQfnumber(dbres,
"datname");
1112 i_datallowconn =
PQfnumber(dbres,
"datallowconn");
1115 for (dbnum = 0; dbnum < ntups; dbnum++)
1120 if (strcmp(
datname,
"template0") == 0)
1124 pg_fatal(
"template0 must not allow connections, "
1125 "i.e. its pg_database.datallowconn must be false");
1135 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1136 pg_fatal(
"could not open file \"%s\": %m", output_path);
1151 pg_fatal(
"All non-template0 databases must allow connections, i.e. their\n"
1152 "pg_database.datallowconn must be true. Your installation contains\n"
1153 "non-template0 databases with their pg_database.datallowconn set to\n"
1154 "false. Consider allowing connection for all non-template0 databases\n"
1155 "or drop the databases which do not allow connections. A list of\n"
1156 "databases with the problem is in the file:\n"
1157 " %s", output_path);
1176 prep_status(
"Checking for prepared transactions");
1180 "FROM pg_catalog.pg_prepared_xacts");
1185 pg_fatal(
"The source cluster contains prepared transactions");
1187 pg_fatal(
"The target cluster contains prepared transactions");
1209 FILE *script = NULL;
1212 prep_status(
"Checking for contrib/isn with bigint-passing mismatch");
1222 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1224 "contrib_isn_and_int8_pass_by_value.txt");
1226 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1229 bool db_used =
false;
1239 "SELECT n.nspname, p.proname "
1240 "FROM pg_catalog.pg_proc p, "
1241 " pg_catalog.pg_namespace n "
1242 "WHERE p.pronamespace = n.oid AND "
1243 " p.probin = '$libdir/isn'");
1248 for (rowno = 0; rowno < ntups; rowno++)
1250 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1251 pg_fatal(
"could not open file \"%s\": %m", output_path);
1271 pg_fatal(
"Your installation contains \"contrib/isn\" functions which rely on the\n"
1272 "bigint data type. Your old and new clusters pass bigint values\n"
1273 "differently so this cluster cannot currently be upgraded. You can\n"
1274 "manually dump databases in the old cluster that use \"contrib/isn\"\n"
1275 "facilities, drop them, perform the upgrade, and then restore them. A\n"
1276 "list of the problem functions is in the file:\n"
1277 " %s", output_path);
1290 FILE *script = NULL;
1293 prep_status(
"Checking for user-defined postfix operators");
1295 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1300 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1303 bool db_used =
false;
1321 "SELECT o.oid AS oproid, "
1322 " n.nspname AS oprnsp, "
1324 " tn.nspname AS typnsp, "
1326 "FROM pg_catalog.pg_operator o, "
1327 " pg_catalog.pg_namespace n, "
1328 " pg_catalog.pg_type t, "
1329 " pg_catalog.pg_namespace tn "
1330 "WHERE o.oprnamespace = n.oid AND "
1331 " o.oprleft = t.oid AND "
1332 " t.typnamespace = tn.oid AND "
1333 " o.oprright = 0 AND "
1341 for (rowno = 0; rowno < ntups; rowno++)
1343 if (script == NULL &&
1344 (script =
fopen_priv(output_path,
"w")) == NULL)
1345 pg_fatal(
"could not open file \"%s\": %m", output_path);
1351 fprintf(script,
" (oid=%s) %s.%s (%s.%s, NONE)\n",
1368 pg_fatal(
"Your installation contains user-defined postfix operators, which are not\n"
1369 "supported anymore. Consider dropping the postfix operators and replacing\n"
1370 "them with prefix operators or function calls.\n"
1371 "A list of user-defined postfix operators is in the file:\n"
1372 " %s", output_path);
1388 FILE *script = NULL;
1392 prep_status(
"Checking for incompatible polymorphic functions");
1394 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1396 "incompatible_polymorphics.txt");
1402 "'array_append(anyarray,anyelement)'"
1403 ", 'array_cat(anyarray,anyarray)'"
1404 ", 'array_prepend(anyelement,anyarray)'");
1408 ", 'array_remove(anyarray,anyelement)'"
1409 ", 'array_replace(anyarray,anyelement,anyelement)'");
1413 ", 'array_position(anyarray,anyelement)'"
1414 ", 'array_position(anyarray,anyelement,integer)'"
1415 ", 'array_positions(anyarray,anyelement)'"
1416 ", 'width_bucket(anyelement,anyarray)'");
1418 for (
int dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1420 bool db_used =
false;
1435 "SELECT 'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
1436 "FROM pg_proc AS p "
1437 "JOIN pg_aggregate AS a ON a.aggfnoid=p.oid "
1438 "JOIN pg_proc AS transfn ON transfn.oid=a.aggtransfn "
1439 "WHERE p.oid >= 16384 "
1440 "AND a.aggtransfn = ANY(ARRAY[%s]::regprocedure[]) "
1441 "AND a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
1445 "SELECT 'aggregate' AS objkind, p.oid::regprocedure::text AS objname "
1446 "FROM pg_proc AS p "
1447 "JOIN pg_aggregate AS a ON a.aggfnoid=p.oid "
1448 "JOIN pg_proc AS finalfn ON finalfn.oid=a.aggfinalfn "
1449 "WHERE p.oid >= 16384 "
1450 "AND a.aggfinalfn = ANY(ARRAY[%s]::regprocedure[]) "
1451 "AND a.aggtranstype = ANY(ARRAY['anyarray', 'anyelement']::regtype[]) "
1455 "SELECT 'operator' AS objkind, op.oid::regoperator::text AS objname "
1456 "FROM pg_operator AS op "
1457 "WHERE op.oid >= 16384 "
1458 "AND oprcode = ANY(ARRAY[%s]::regprocedure[]) "
1459 "AND oprleft = ANY(ARRAY['anyarray', 'anyelement']::regtype[]);",
1460 old_polymorphics.
data,
1461 old_polymorphics.
data,
1462 old_polymorphics.
data);
1469 for (
int rowno = 0; rowno < ntups; rowno++)
1471 if (script == NULL &&
1472 (script =
fopen_priv(output_path,
"w")) == NULL)
1473 pg_fatal(
"could not open file \"%s\": %m", output_path);
1493 pg_fatal(
"Your installation contains user-defined objects that refer to internal\n"
1494 "polymorphic functions with arguments of type \"anyarray\" or \"anyelement\".\n"
1495 "These user-defined objects must be dropped before upgrading and restored\n"
1496 "afterwards, changing them to refer to the new corresponding functions with\n"
1497 "arguments of type \"anycompatiblearray\" and \"anycompatible\".\n"
1498 "A list of the problematic objects is in the file:\n"
1499 " %s", output_path);
1514 FILE *script = NULL;
1519 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1521 "tables_with_oids.txt");
1524 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1527 bool db_used =
false;
1536 "SELECT n.nspname, c.relname "
1537 "FROM pg_catalog.pg_class c, "
1538 " pg_catalog.pg_namespace n "
1539 "WHERE c.relnamespace = n.oid AND "
1541 " n.nspname NOT IN ('pg_catalog')");
1546 for (rowno = 0; rowno < ntups; rowno++)
1548 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1549 pg_fatal(
"could not open file \"%s\": %m", output_path);
1569 pg_fatal(
"Your installation contains tables declared WITH OIDS, which is not\n"
1570 "supported anymore. Consider removing the oid column using\n"
1571 " ALTER TABLE ... SET WITHOUT OIDS;\n"
1572 "A list of tables with the problem is in the file:\n"
1573 " %s", output_path);
1593 FILE *script = NULL;
1596 prep_status(
"Checking for roles starting with \"pg_\"");
1598 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1600 "pg_role_prefix.txt");
1603 "SELECT oid AS roloid, rolname "
1604 "FROM pg_catalog.pg_roles "
1605 "WHERE rolname ~ '^pg_'");
1610 for (
int rowno = 0; rowno < ntups; rowno++)
1612 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1613 pg_fatal(
"could not open file \"%s\": %m", output_path);
1614 fprintf(script,
"%s (oid=%s)\n",
1627 pg_fatal(
"Your installation contains roles starting with \"pg_\".\n"
1628 "\"pg_\" is a reserved prefix for system roles. The cluster\n"
1629 "cannot be upgraded until these roles are renamed.\n"
1630 "A list of roles starting with \"pg_\" is in the file:\n"
1631 " %s", output_path);
1644 FILE *script = NULL;
1647 prep_status(
"Checking for user-defined encoding conversions");
1649 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1651 "encoding_conversions.txt");
1654 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
1657 bool db_used =
false;
1673 "SELECT c.oid as conoid, c.conname, n.nspname "
1674 "FROM pg_catalog.pg_conversion c, "
1675 " pg_catalog.pg_namespace n "
1676 "WHERE c.connamespace = n.oid AND "
1682 for (rowno = 0; rowno < ntups; rowno++)
1684 if (script == NULL &&
1685 (script =
fopen_priv(output_path,
"w")) == NULL)
1686 pg_fatal(
"could not open file \"%s\": %m", output_path);
1692 fprintf(script,
" (oid=%s) %s.%s\n",
1707 pg_fatal(
"Your installation contains user-defined encoding conversions.\n"
1708 "The conversion function parameters changed in PostgreSQL version 14\n"
1709 "so this cluster cannot currently be upgraded. You can remove the\n"
1710 "encoding conversions in the old cluster and restart the upgrade.\n"
1711 "A list of user-defined encoding conversions is in the file:\n"
1712 " %s", output_path);
1741 if (nslots_on_old == 0)
1746 prep_status(
"Checking for new cluster logical replication slots");
1749 "FROM pg_catalog.pg_replication_slots "
1750 "WHERE slot_type = 'logical' AND "
1751 "temporary IS FALSE;");
1754 pg_fatal(
"could not count the number of logical replication slots");
1759 pg_fatal(
"Expected 0 logical replication slots but found %d.",
1765 "WHERE name IN ('wal_level', 'max_replication_slots') "
1766 "ORDER BY name DESC;");
1769 pg_fatal(
"could not determine parameter settings on new cluster");
1774 pg_fatal(
"\"wal_level\" must be \"logical\", but is set to \"%s\"",
1780 pg_fatal(
"\"max_replication_slots\" (%d) must be greater than or equal to the number of "
1781 "logical replication slots (%d) on the old cluster",
1812 prep_status(
"Checking for new cluster configuration for subscriptions");
1817 "WHERE name = 'max_replication_slots';");
1820 pg_fatal(
"could not determine parameter settings on new cluster");
1824 pg_fatal(
"\"max_replication_slots\" (%d) must be greater than or equal to the number of "
1825 "subscriptions (%d) on the old cluster",
1844 FILE *script = NULL;
1846 prep_status(
"Checking for valid logical replication slots");
1848 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1850 "invalid_logical_slots.txt");
1856 for (
int slotnum = 0; slotnum < slot_arr->
nslots; slotnum++)
1863 if (script == NULL &&
1864 (script =
fopen_priv(output_path,
"w")) == NULL)
1865 pg_fatal(
"could not open file \"%s\": %m", output_path);
1867 fprintf(script,
"The slot \"%s\" is invalid\n",
1882 if (script == NULL &&
1883 (script =
fopen_priv(output_path,
"w")) == NULL)
1884 pg_fatal(
"could not open file \"%s\": %m", output_path);
1887 "The slot \"%s\" has not consumed the WAL yet\n",
1898 pg_fatal(
"Your installation contains logical replication slots that can't be upgraded.\n"
1899 "You can remove invalid slots and/or consume the pending WAL for other slots,\n"
1900 "and then restart the upgrade.\n"
1901 "A list of the problematic slots is in the file:\n"
1902 " %s", output_path);
1918 FILE *script = NULL;
1924 snprintf(output_path,
sizeof(output_path),
"%s/%s",
1926 "subs_invalid.txt");
1941 "SELECT d.datname, s.subname "
1942 "FROM pg_catalog.pg_subscription s "
1943 "LEFT OUTER JOIN pg_catalog.pg_replication_origin o "
1944 " ON o.roname = 'pg_' || s.oid "
1945 "INNER JOIN pg_catalog.pg_database d "
1946 " ON d.oid = s.subdbid "
1947 "WHERE o.roname IS NULL;");
1950 for (
int i = 0;
i < ntup;
i++)
1952 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
1953 pg_fatal(
"could not open file \"%s\": %m", output_path);
1954 fprintf(script,
"The replication origin is missing for database:\"%s\" subscription:\"%s\"\n",
1990 "SELECT r.srsubstate, s.subname, n.nspname, c.relname "
1991 "FROM pg_catalog.pg_subscription_rel r "
1992 "LEFT JOIN pg_catalog.pg_subscription s"
1993 " ON r.srsubid = s.oid "
1994 "LEFT JOIN pg_catalog.pg_class c"
1995 " ON r.srrelid = c.oid "
1996 "LEFT JOIN pg_catalog.pg_namespace n"
1997 " ON c.relnamespace = n.oid "
1998 "WHERE r.srsubstate NOT IN ('i', 'r') "
1999 "ORDER BY s.subname");
2002 for (
int i = 0;
i < ntup;
i++)
2004 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
2005 pg_fatal(
"could not open file \"%s\": %m", output_path);
2007 fprintf(script,
"The table sync state \"%s\" is not allowed for database:\"%s\" subscription:\"%s\" schema:\"%s\" relation:\"%s\"\n",
2023 pg_fatal(
"Your installation contains subscriptions without origin or having relations not in i (initialize) or r (ready) state.\n"
2024 "You can allow the initial sync to finish for all relations and then restart the upgrade.\n"
2025 "A list of the problematic subscriptions is in the file:\n"
2026 " %s", output_path);
#define Assert(condition)
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)
void get_subscription_count(ClusterInfo *cluster)
void get_db_rel_and_slot_infos(ClusterInfo *cluster, bool live_check)
int count_old_cluster_logical_slots(void)
static void check_ok(void)
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