GrepBoard/Manuals
605 manuals ·

PostgreSQL 19 upgrade: pg_upgrade --check and breaking changes

·Tested on PostgreSQL 18.7 → 19.0 (Debian 13 container · PGDG apt) · release notes of 2026-11-19 · 2026-11·Test scope ↓·8 steps

Run pg_upgrade --check before upgrading to PostgreSQL 19, then check your 18 server for the release-note changes that hit settings, indexes and names.

PostgreSQL 19 came out on 2026-11-19. Moving from 18 takes pg_upgrade, a dump and restore, or logical replication. Run pg_upgrade --check first to find what blocks the upgrade. The sources are the release notes, "Migration to Version 19" and the pg_upgrade docs. The output comes from empty 18.7 and 19.0 clusters.

[1] The check needs the 19 binaries. The postgres:19 image was not available on 2026-11-20 (not found), so a postgres:18 container got the PGDG apt package postgresql-19.

console
$ dpkg -l 'postgresql-1[89]' | grep '^ii' | awk '{print $2, $3}'postgresql-18 18.7-1.pgdg13+2postgresql-19 19.0-1.pgdg13+1

[2] The old cluster is your current 18 data directory (an empty /tmp/old in the test). Create the new cluster separately with the 19 initdb, using options compatible with the old one. The first line sets variables for the commands below.

console
$ export O=/usr/lib/postgresql/18/bin N=/usr/lib/postgresql/19/bin$ $O/initdb -D /tmp/old -U postgres$ $N/initdb -D /tmp/new -U postgres

[3] Run the new version's pg_upgrade --check. It changes no data and needs a writable current directory. If you will upgrade with --link or similar, pass the same option to the check.

console
$ $N/pg_upgrade --check -b $O -B $N -d /tmp/old -D /tmp/new | tail -n 3Checking new cluster tablespace directories                   ok *Clusters are compatible*

[4] First blocker: btree_gist inet and cidr indexes. The notes say the default operator classes for inet and cidr moved to built-in GiST, and pg_upgrade refuses such indexes. The query finds them on a running 18 server; the check output follows.

console
$ $O/psql -h /tmp -d postgres -Atc "SELECT c.relname, o.opcname FROM pg_index i JOIN pg_class c ON c.oid = i.indexrelid JOIN pg_opclass o ON o.oid = ANY (i.indclass::oid[]) WHERE o.opcname IN ('gist_inet_ops', 'gist_cidr_ops')"hosts_addr_gist|gist_inet_ops $ $N/pg_upgrade --check -b $O -B $N -d /tmp/old -D /tmp/new | tail -n 9Checking for uses of gist_inet_ops/gist_cidr_ops              fatal …binary-upgraded.  Replace them with indexes that use the built-in GiSTinet_ops operator class.A list of indexes with the problem is in the file:    /tmp/new/pg_upgrade_output.d/20261119T231633.113/gist_inet_ops.txtFailure, exiting

[5] Second blocker: a database, role or tablespace name containing a newline or carriage return (the notes say pg_upgrade refuses these too). A check on a database with a newline in its name prints "…invalid characters (newline or carriage return)" and tells you to rename it.

[6] Settings changes the check does not catch: the notes list max_locks_per_transaction 64 → 128, JIT off by default, and io_workers removed. The 18 server (same query through $O/psql) showed io_workers|3, jit|on, max_locks_per_transaction|64. Start the new cluster and send the query to it (-h /tmp is the socket directory).

console
$ $N/pg_ctl -D /tmp/new -o "-c listen_addresses='' -c unix_socket_directories=/tmp" -l /tmp/new.log -w start$ $N/psql -h /tmp -d postgres -Atc "SELECT name, setting FROM pg_settings WHERE name IN ('jit','max_locks_per_transaction','io_workers') ORDER BY 1"jit|offmax_locks_per_transaction|128

19 has no io_workers. If postgresql.conf still sets it, 19 refuses to start with FATAL: unrecognized configuration parameter "io_workers". Four variables replace it, including io_min_workers and io_max_workers. The notes also say max_locks_per_transaction effectively needs doubling for the same capacity.

[7] Pick the other incompatibilities that apply to you (a selection).

Change in the notesWhere to look
Warning after MD5 authentication (md5_password_warnings turns it off)The query below
RADIUS authentication removedA radius method in pg_hba.conf (how to look)
standard_conforming_strings always on · MULE_INTERNAL removedOld dumps made with it off · databases with that encoding
Full text search and pg_trgm character classification changedNotes: "it is recommended to reindex all indexes which use full text search and pg_trgm after the upgrade, and to recompute any stored tsvector values". Applies to databases whose non-libc locale provider behaves differently from LC_CTYPE

Find MD5 roles with SELECT rolname FROM pg_authid WHERE rolpassword LIKE 'md5%' (superuser). For authentication errors follow password authentication failed.

[8] After the real upgrade, rebuild statistics as the docs say (only some are carried over). The 18.7 security update has its own post.

console
$ vacuumdb --all --analyze-in-stages --missing-stats-only$ vacuumdb --all --analyze-only

#postgresql#postgresql-19#pg_upgrade#major-upgrade#compatibility