]> granicus.if.org Git - postgresql/commit
Check for tables with sql_identifier during pg_upgrade
authorTomas Vondra <tomas.vondra@postgresql.org>
Mon, 14 Oct 2019 20:31:56 +0000 (22:31 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Mon, 14 Oct 2019 21:40:58 +0000 (23:40 +0200)
commiteaf900e842ab0c8a03f23a2eda6a872eb9fce1c7
tree94d7dc0cca7980a0ff5e0abafa3f1adcc78741d2
parent9fd9af97fb7b19a5cf5488358d8535faa0949da4
Check for tables with sql_identifier during pg_upgrade

Commit 7c15cef86d changed sql_identifier data type to be based on name
instead of varchar.  Unfortunately, this breaks on-disk format for this
data type.  Luckily, that should be a very rare problem, as this data
type is used only in information_schema views, so this only affects user
objects (tables, materialized views and indexes).  One way to end in
such situation is to do CTAS with a query on those system views.

There are two options to deal with this - we can either abort pg_upgrade
if there are user objects with sql_identifier columns in pg_upgrade, or
we could replace the sql_identifier type with varchar.  Considering how
rare the issue is expected to be, and the complexity of replacing the
data type (e.g. in matviews), we've decided to go with the simple check.

The query is somewhat complex - the sql_identifier data type may be used
indirectly - through a domain, a composite type or both, possibly in
multiple levels.  Detecting this requires a recursive CTE.

Backpatch to 12, where the sql_identifier definition changed.

Reported-by: Hans Buschmann
Author: Tomas Vondra
Reviewed-by: Tom Lane
Backpatch-to: 12
Discussion: https://postgr.es/m/16045-673e8fa6b5ace196%40postgresql.org
src/bin/pg_upgrade/check.c
src/bin/pg_upgrade/pg_upgrade.h
src/bin/pg_upgrade/version.c