Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3c0cc4

Browse files
committed
Switch query fixing aclitems in ~15 from O(N^2) to O(N) in upgrade_adapt.sql
f4f2f2b was doing a sequential scan of pg_class before checking if arelation had attributes dependent on aclitem as data typewhen buildingthe set of ALTER TABLE queries, but it would be costly on a regressiondatabase.While on it, make the query style more consistent with the rest.Reported-by: Justin PryzbyDiscussion:https://postgr.es/m/20221223032724.GQ1153@telsasoft.com
1 parent442e25d commitd3c0cc4

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

‎src/bin/pg_upgrade/upgrade_adapt.sql

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,21 @@ DROP OPERATOR public.#@%# (pg_catalog.int8, NONE);
9595
-- The internal format of "aclitem" has changed in 16, so replace it with
9696
-- text type in tables.
9797
\if :oldpgversion_le15
98-
DO $$
98+
DO $stmt$
9999
DECLARE
100-
rectext;
101-
coltext;
100+
rec record;
102101
BEGIN
103102
FOR recin
104-
SELECToid::regclass::text
105-
FROM pg_class
106-
WHERE relname !~'^pg_'
107-
AND relkindIN ('r')
103+
SELECToid::regclass::textas rel, attnameas col
104+
FROM pg_class c, pg_attribute a
105+
WHEREc.relname !~'^pg_'
106+
ANDc.relkindIN ('r')
107+
ANDa.attrelid=c.oid
108+
ANDa.atttypid='aclitem'::regtype
108109
ORDER BY1
109110
LOOP
110-
FOR colinSELECT attnameFROM pg_attribute
111-
WHERE attrelid::regclass::text= rec
112-
AND atttypid='aclitem'::regtype
113-
LOOP
114-
EXECUTE'ALTER TABLE'|| quote_ident(rec)||' ALTER COLUMN'||
115-
quote_ident(col)||' SET DATA TYPE text';
116-
END LOOP;
111+
EXECUTE'ALTER TABLE'|| quote_ident(rec.rel)||' ALTER COLUMN'||
112+
quote_ident(rec.col)||' SET DATA TYPE text';
117113
END LOOP;
118-
END; $$;
114+
END; $stmt$;
119115
\endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp