Skip to content

pg_upgrade from PostgreSQL 17 → 18 fails #44

Description

@said-karimov-aiven

Now that PostgreSQL 18 preserves the optimizer statistics during an upgrade with dump/restore or pg_upgrade, the upgrade fails if postgresql-unit extension installed. When upgrading a cluster from PostgreSQL 17 to 18, the process fails during the statistics–restore phase with:

pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 4602; 0 0 STATISTICS DATA foo (no owner)
pg_restore: error: could not execute query: ERROR: unit "km" is not known
Command was: SELECT * FROM pg_catalog.pg_restore_relation_stats(
'version', '170007'::integer,
'schemaname', 'public',
'relname', 'foo',
'relpages', '1'::integer,
'reltuples', '10'::real,
'relallvisible', '1'::integer
);

SELECT * FROM pg_catalog.pg_restore_attribute_stats(
'version', '170007'::integer,
'schemaname', 'public',
'relname', 'foo',
'attname', 'munit',
'inherited', 'f'::boolean,
'null_frac', '0'::real,
'avg_width', '16'::integer,
'n_distinct', '-1'::real,
'histogram_bounds', '{"3.20040000000000013 m","10 m","15 m","20 m","25.4000000000000021 m","30.4800000000000004 m","1.5 km","8.04672000000000054 km","19.3121279999999977 Mm","9.46073047258080102 Pm"}'::text,
'correlation', '0.15151516'::real
);

The failure occurs when pg_restore attempts to restore STATISTICS DATA for a table (foo in this case) containing a column of type unit. This happens despite unit_prefixes and unit_units already being "populated" in unit*.sql.in files.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions