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

Commit5f21f52

Browse files
committed
Mark immutable functions in information schema as parallel safe
Also add opr_sanity check that all preloaded immutable functions areparallel safe. (Per discussion, this does not necessarily have to betrue for all possible such functions, but deviations would be unlikelyenough that maintaining such a test is reasonable.)Reported-by: David Rowley <david.rowley@2ndquadrant.com>Reviewed-by: Robert Haas <robertmhaas@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
1 parent4be613f commit5f21f52

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

‎src/backend/catalog/information_schema.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ SET search_path TO information_schema;
4242
/* Expand any 1-D array into a set with integers 1..N*/
4343
CREATEFUNCTION_pg_expandarray(IN anyarray, OUT x anyelement, OUT nint)
4444
RETURNS SETOF RECORD
45-
LANGUAGE sql STRICT IMMUTABLE
45+
LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
4646
AS'select $1[s], s - pg_catalog.array_lower($1,1) + 1
4747
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
4848
pg_catalog.array_upper($1,1),
4949
1) as g(s)';
5050

5151
CREATEFUNCTION_pg_keysequal(smallint[],smallint[]) RETURNSboolean
52-
LANGUAGE sql IMMUTABLE-- intentionally not STRICT, to allow inlining
52+
LANGUAGE sql IMMUTABLEPARALLEL SAFE-- intentionally not STRICT, to allow inlining
5353
AS'select $1 operator(pg_catalog.<@) $2 and $2 operator(pg_catalog.<@) $1';
5454

5555
/* Given an index's OID and an underlying-table column number, return the
@@ -66,13 +66,15 @@ $$;
6666
CREATEFUNCTION_pg_truetypid(pg_attribute, pg_type) RETURNSoid
6767
LANGUAGE sql
6868
IMMUTABLE
69+
PARALLEL SAFE
6970
RETURNSNULLONNULL INPUT
7071
AS
7172
$$SELECT CASE WHEN $2.typtype='d' THEN $2.typbasetype ELSE $1.atttypid END$$;
7273

7374
CREATEFUNCTION_pg_truetypmod(pg_attribute, pg_type) RETURNS int4
7475
LANGUAGE sql
7576
IMMUTABLE
77+
PARALLEL SAFE
7678
RETURNSNULLONNULL INPUT
7779
AS
7880
$$SELECT CASE WHEN $2.typtype='d' THEN $2.typtypmod ELSE $1.atttypmod END$$;
@@ -82,6 +84,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
8284
CREATEFUNCTION_pg_char_max_length(typidoid, typmod int4) RETURNSinteger
8385
LANGUAGE sql
8486
IMMUTABLE
87+
PARALLEL SAFE
8588
RETURNSNULLONNULL INPUT
8689
AS
8790
$$SELECT
@@ -97,6 +100,7 @@ $$SELECT
97100
CREATEFUNCTION_pg_char_octet_length(typidoid, typmod int4) RETURNSinteger
98101
LANGUAGE sql
99102
IMMUTABLE
103+
PARALLEL SAFE
100104
RETURNSNULLONNULL INPUT
101105
AS
102106
$$SELECT
@@ -112,6 +116,7 @@ $$SELECT
112116
CREATEFUNCTION_pg_numeric_precision(typidoid, typmod int4) RETURNSinteger
113117
LANGUAGE sql
114118
IMMUTABLE
119+
PARALLEL SAFE
115120
RETURNSNULLONNULL INPUT
116121
AS
117122
$$SELECT
@@ -132,6 +137,7 @@ $$SELECT
132137
CREATEFUNCTION_pg_numeric_precision_radix(typidoid, typmod int4) RETURNSinteger
133138
LANGUAGE sql
134139
IMMUTABLE
140+
PARALLEL SAFE
135141
RETURNSNULLONNULL INPUT
136142
AS
137143
$$SELECT
@@ -143,6 +149,7 @@ $$SELECT
143149
CREATEFUNCTION_pg_numeric_scale(typidoid, typmod int4) RETURNSinteger
144150
LANGUAGE sql
145151
IMMUTABLE
152+
PARALLEL SAFE
146153
RETURNSNULLONNULL INPUT
147154
AS
148155
$$SELECT
@@ -158,6 +165,7 @@ $$SELECT
158165
CREATEFUNCTION_pg_datetime_precision(typidoid, typmod int4) RETURNSinteger
159166
LANGUAGE sql
160167
IMMUTABLE
168+
PARALLEL SAFE
161169
RETURNSNULLONNULL INPUT
162170
AS
163171
$$SELECT
@@ -173,6 +181,7 @@ $$SELECT
173181
CREATEFUNCTION_pg_interval_type(typidoid, mod int4) RETURNStext
174182
LANGUAGE sql
175183
IMMUTABLE
184+
PARALLEL SAFE
176185
RETURNSNULLONNULL INPUT
177186
AS
178187
$$SELECT

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201704061
56+
#defineCATALOG_VERSION_NO201704062
5757

5858
#endif

‎src/test/regress/expected/opr_sanity.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,14 @@ order by 1;
733733
lowrite | 955
734734
(13 rows)
735735

736+
-- Check that all immutable functions are marked parallel safe
737+
SELECT p1.oid, p1.proname
738+
FROM pg_proc AS p1
739+
WHERE provolatile = 'i' AND proparallel = 'u';
740+
oid | proname
741+
-----+---------
742+
(0 rows)
743+
736744
-- **************** pg_cast ****************
737745
-- Catch bogus values in pg_cast columns (other than cases detected by
738746
-- oidjoins test).

‎src/test/regress/sql/opr_sanity.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ and pronamespace = (select oid from pg_catalog.pg_namespace
381381
where nspname='pg_catalog')
382382
order by1;
383383

384+
-- Check that all immutable functions are marked parallel safe
385+
SELECTp1.oid,p1.proname
386+
FROM pg_procAS p1
387+
WHERE provolatile='i'AND proparallel='u';
388+
384389

385390
-- **************** pg_cast ****************
386391

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp