Fix some incorrectness in upgrade_adapt.sql on query for WITH OIDS
authorMichael Paquier <michael@paquier.xyz>
Fri, 23 Dec 2022 02:26:49 +0000 (11:26 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 23 Dec 2022 02:26:49 +0000 (11:26 +0900)
The query used to disable WITH OIDS in all the relations making use of
it was checking for materialized views, but this is not a supported
operation.  On the contrary, this needs to be done on foreign tables.

While on it, use quote_ident() in the ALTER TABLE strings built on the
relation name.

Author: Anton A. Melnikov, Michael Paquier
Discussion: https://postgr.es/m/49f389ba-95ce-8a9b-09ae-f60650c0e7c7@inbox.ru
Backpatch-through: 12

src/bin/pg_upgrade/upgrade_adapt.sql

index 27c4c7fd011a665ecef9b29c297becc3995775fb..d0580e428230a60dcd3a340af35b59def211d2e9 100644 (file)
@@ -72,10 +72,10 @@ DO $stmt$
     FROM pg_class
     WHERE relname !~ '^pg_'
       AND relhasoids
-      AND relkind in ('r','m')
+      AND relkind in ('r', 'f')
     ORDER BY 1
   LOOP
-    execute 'ALTER TABLE ' || rec || ' SET WITHOUT OIDS';
+    EXECUTE 'ALTER TABLE ' || quote_ident(rec) || ' SET WITHOUT OIDS';
   END LOOP;
   END; $stmt$;
 \endif