Re: [BUG] pg_upgrade test fails from older versions.

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: "Anton A(dot) Melnikov" <aamelnikov(at)inbox(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [BUG] pg_upgrade test fails from older versions.
Date: 2022-12-23 03:27:24
Message-ID: 20221223032724.GQ1153@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 23, 2022 at 11:42:39AM +0900, Michael Paquier wrote:
> Hmm. 0001 does a direct check on aclitem as data type used in an
> attribute,

> For now, I have fixed the most pressing part for tables to match with
> the buildfarm

+DO $$
+ DECLARE
+ rec text;
+ col text;
+ BEGIN
+ FOR rec in
+ SELECT oid::regclass::text
+ FROM pg_class
+ WHERE relname !~ '^pg_'
+ AND relkind IN ('r')
+ ORDER BY 1
+ LOOP
+ FOR col in SELECT attname FROM pg_attribute
+ WHERE attrelid::regclass::text = rec
+ AND atttypid = 'aclitem'::regtype
+ LOOP
+ EXECUTE 'ALTER TABLE ' || quote_ident(rec) || ' ALTER COLUMN ' ||
+ quote_ident(col) || ' SET DATA TYPE text';
+ END LOOP;
+ END LOOP;
+ END; $$;

This will do a seq scan around pg_attribute for each relation (currently
~600)...

Here, that takes a few seconds in a debug build, and I guess it'll be
more painful when running under valgrind/discard_caches/antiquated
hardware/etc.

This would do a single seqscan:
SELECT format('ALTER TABLE %I ALTER COLUMN %I TYPE TEXT', attrelid::regclass, attname) FROM pg_attribute WHERE atttypid='aclitem'::regtype; -- AND ...
\gexec

--
Justin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2022-12-23 03:29:56 Re: Avoid lost result of recursion (src/backend/optimizer/util/inherit.c)
Previous Message Amit Langote 2022-12-23 03:22:08 Re: Avoid lost result of recursion (src/backend/optimizer/util/inherit.c)