From 834d9284b4fee413c74de3a143a072eb21c05772 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 11 May 2021 20:59:45 -0400 Subject: [PATCH] Reduce runtime of privileges.sql test under CLOBBER_CACHE_ALWAYS. Several queries in the privileges regression test cause the planner to apply the plpgsql function "leak()" to every element of the histogram for atest12.b. Since commit 0c882e52a increased the size of that histogram to 10000 entries, the test invokes that function over 100000 times, which takes an absolutely unreasonable amount of time in clobber-cache-always mode. However, there's no real reason why that has to be a plpgsql function: for the purposes of this test, all that matters is that it not be marked leakproof. So we can replace the plpgsql implementation with a direct call of int4lt, which has the same behavior and is orders of magnitude faster. This is expected to cut several hours off the buildfarm cycle time for CCA animals. It has some positive impact in normal builds too, though that's probably lost in the noise. Back-patch to v13 where 0c882e52a came in. Discussion: https://postgr.es/m/575884.1620626638@sss.pgh.pa.us --- src/test/regress/expected/privileges.out | 8 +++++--- src/test/regress/sql/privileges.sql | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out index 4ddd723377..0fab32f560 100644 --- a/src/test/regress/expected/privileges.out +++ b/src/test/regress/expected/privileges.out @@ -33,6 +33,11 @@ ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2; -- duplicate NOTICE: role "regress_priv_user2" is already a member of role "regress_priv_group2" ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2; GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION; +-- prepare non-leakproof function for later +CREATE FUNCTION leak(integer,integer) RETURNS boolean + AS 'int4lt' + LANGUAGE internal IMMUTABLE STRICT; -- but deliberately not LEAKPROOF +ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1; -- test owner privileges SET SESSION AUTHORIZATION regress_priv_user1; SELECT session_user, current_user; @@ -196,9 +201,6 @@ ALTER TABLE atest12 SET (autovacuum_enabled = off); SET default_statistics_target = 10000; VACUUM ANALYZE atest12; RESET default_statistics_target; -CREATE FUNCTION leak(integer,integer) RETURNS boolean - AS $$begin return $1 < $2; end$$ - LANGUAGE plpgsql immutable; CREATE OPERATOR <<< (procedure = leak, leftarg = integer, rightarg = integer, restrict = scalarltsel); -- views with leaky operator diff --git a/src/test/regress/sql/privileges.sql b/src/test/regress/sql/privileges.sql index 80581757a2..5fdb58c798 100644 --- a/src/test/regress/sql/privileges.sql +++ b/src/test/regress/sql/privileges.sql @@ -39,6 +39,12 @@ ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2; -- duplicate ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2; GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION; +-- prepare non-leakproof function for later +CREATE FUNCTION leak(integer,integer) RETURNS boolean + AS 'int4lt' + LANGUAGE internal IMMUTABLE STRICT; -- but deliberately not LEAKPROOF +ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1; + -- test owner privileges SET SESSION AUTHORIZATION regress_priv_user1; @@ -142,9 +148,6 @@ SET default_statistics_target = 10000; VACUUM ANALYZE atest12; RESET default_statistics_target; -CREATE FUNCTION leak(integer,integer) RETURNS boolean - AS $$begin return $1 < $2; end$$ - LANGUAGE plpgsql immutable; CREATE OPERATOR <<< (procedure = leak, leftarg = integer, rightarg = integer, restrict = scalarltsel);