Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e135743

Browse files
committed
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 0c882e5 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 0c882e5 came in. Discussion: https://postgr.es/m/575884.1620626638@sss.pgh.pa.us
1 parent d780d7c commit e135743

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/test/regress/expected/privileges.out

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2; -- duplicate
3838
NOTICE: role "regress_priv_user2" is already a member of role "regress_priv_group2"
3939
ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2;
4040
GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION;
41+
-- prepare non-leakproof function for later
42+
CREATE FUNCTION leak(integer,integer) RETURNS boolean
43+
AS 'int4lt'
44+
LANGUAGE internal IMMUTABLE STRICT; -- but deliberately not LEAKPROOF
45+
ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1;
4146
-- test owner privileges
4247
SET SESSION AUTHORIZATION regress_priv_user1;
4348
SELECT session_user, current_user;
@@ -233,9 +238,6 @@ ALTER TABLE atest12 SET (autovacuum_enabled = off);
233238
SET default_statistics_target = 10000;
234239
VACUUM ANALYZE atest12;
235240
RESET default_statistics_target;
236-
CREATE FUNCTION leak(integer,integer) RETURNS boolean
237-
AS $$begin return $1 < $2; end$$
238-
LANGUAGE plpgsql immutable;
239241
CREATE OPERATOR <<< (procedure = leak, leftarg = integer, rightarg = integer,
240242
restrict = scalarltsel);
241243
-- views with leaky operator

src/test/regress/sql/privileges.sql

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2; -- duplicate
4545
ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2;
4646
GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION;
4747

48+
-- prepare non-leakproof function for later
49+
CREATE FUNCTION leak(integer,integer) RETURNS boolean
50+
AS 'int4lt'
51+
LANGUAGE internal IMMUTABLE STRICT; -- but deliberately not LEAKPROOF
52+
ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1;
53+
4854
-- test owner privileges
4955

5056
SET SESSION AUTHORIZATION regress_priv_user1;
@@ -166,9 +172,6 @@ SET default_statistics_target = 10000;
166172
VACUUM ANALYZE atest12;
167173
RESET default_statistics_target;
168174

169-
CREATE FUNCTION leak(integer,integer) RETURNS boolean
170-
AS $$begin return $1 < $2; end$$
171-
LANGUAGE plpgsql immutable;
172175
CREATE OPERATOR <<< (procedure = leak, leftarg = integer, rightarg = integer,
173176
restrict = scalarltsel);
174177

0 commit comments

Comments
 (0)