]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix new pg_upgrade query not to rely on regnamespace REL_13_STABLE github/REL_13_STABLE
authorÁlvaro Herrera <alvherre@kurilemu.de>
Fri, 4 Jul 2025 19:30:05 +0000 (21:30 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Fri, 4 Jul 2025 19:30:05 +0000 (21:30 +0200)
That was invented in 9.5, and pg_upgrade claims to support back to 9.0.
But we don't need that with a simple query change, tested by Tom Lane.

Discussion: https://postgr.es/m/202507041645.afjl5rssvrgu@alvherre.pgsql

src/bin/pg_upgrade/check.c

index 224cb6b9631df4bad1d0dc6f7f29cdcb5795f2fa..3fc96ec9005a9647a5fe4deb592099b8fb56bff9 100644 (file)
@@ -1059,12 +1059,13 @@ check_for_not_null_inheritance(ClusterInfo *cluster)
                PGconn     *conn = connectToServer(&old_cluster, active_db->db_name);
 
                res = executeQueryOrDie(conn,
-                                                               "SELECT cc.relnamespace::pg_catalog.regnamespace AS nspname, "
-                                                               "       cc.relname, ac.attname "
+                                                               "SELECT nspname, cc.relname, ac.attname "
                                                                "FROM pg_catalog.pg_inherits i, pg_catalog.pg_attribute ac, "
-                                                               "     pg_catalog.pg_attribute ap, pg_catalog.pg_class cc "
+                                                               "     pg_catalog.pg_attribute ap, pg_catalog.pg_class cc, "
+                                                               "     pg_catalog.pg_namespace nc "
                                                                "WHERE cc.oid = ac.attrelid AND i.inhrelid = ac.attrelid "
                                                                "      AND i.inhparent = ap.attrelid AND ac.attname = ap.attname "
+                                                               "      AND cc.relnamespace = nc.oid "
                                                                "      AND ap.attnum > 0 and ap.attnotnull AND NOT ac.attnotnull");
 
                ntup = PQntuples(res);