Re: [BUG] pg_upgrade test fails from older versions. - Mailing list pgsql-hackers

From Anton A. Melnikov
Subject Re: [BUG] pg_upgrade test fails from older versions.
Date
Msg-id 2de1593a-3281-88aa-3dad-11c3c3fadf2c@inbox.ru
Whole thread Raw
In response to Re: [BUG] pg_upgrade test fails from older versions.  (Michael Paquier <michael@paquier.xyz>)
Responses Re: [BUG] pg_upgrade test fails from older versions.  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Sorry, didn't get to see the last letter!

On 23.12.2022 11:51, Michael Paquier wrote:
> 
> FWIW, I find the use of a FOR loop with a DO block much cleaner to
> follow in this context, so something like the attached would be able
> to group the two queries and address your point on O(N^2).  Do you
> like that?
> --
> Michael

The query:

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

gives the average time of 36 ms at the same conditions.


With the best wishes!

-- 
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



pgsql-hackers by date:

Previous
From: "houzj.fnst@fujitsu.com"
Date:
Subject: RE: Perform streaming logical transactions by background workers and parallel apply
Next
From: shveta malik
Date:
Subject: Re: Force streaming every change in logical decoding