1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Fix parallel-safety code for parallel aggregation.

has_parallel_hazard() was ignoring the proparallel markings for
aggregates, which is no good.  Fix that.  There was no way to mark
an aggregate as actually being parallel-safe, either, so add a
PARALLEL option to CREATE AGGREGATE.

Patch by me, reviewed by David Rowley.
This commit is contained in:
Robert Haas
2016-04-05 16:06:15 -04:00
parent 09adc9a8c0
commit 41ea0c2376
8 changed files with 63 additions and 11 deletions

View File

@ -20,9 +20,9 @@ CREATE AGGREGATE newsum (
-- zero-argument aggregate
CREATE AGGREGATE newcnt (*) (
sfunc = int8inc, stype = int8,
initcond = '0'
initcond = '0', parallel = safe
);
-- old-style spelling of same
-- old-style spelling of same (except without parallel-safe; that's too new)
CREATE AGGREGATE oldcnt (
sfunc = int8inc, basetype = 'ANY', stype = int8,
initcond = '0'
@ -188,6 +188,14 @@ WHERE aggfnoid = 'myavg'::REGPROC;
(1 row)
DROP AGGREGATE myavg (numeric);
-- invalid: bad parallel-safety marking
CREATE AGGREGATE mysum (int)
(
stype = int,
sfunc = int4pl,
parallel = pear
);
ERROR: parameter "parallel" must be SAFE, RESTRICTED, or UNSAFE
-- invalid: nonstrict inverse with strict forward function
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$

View File

@ -23,10 +23,10 @@ CREATE AGGREGATE newsum (
-- zero-argument aggregate
CREATE AGGREGATE newcnt (*) (
sfunc = int8inc, stype = int8,
initcond = '0'
initcond = '0', parallel = safe
);
-- old-style spelling of same
-- old-style spelling of same (except without parallel-safe; that's too new)
CREATE AGGREGATE oldcnt (
sfunc = int8inc, basetype = 'ANY', stype = int8,
initcond = '0'
@ -201,6 +201,14 @@ WHERE aggfnoid = 'myavg'::REGPROC;
DROP AGGREGATE myavg (numeric);
-- invalid: bad parallel-safety marking
CREATE AGGREGATE mysum (int)
(
stype = int,
sfunc = int4pl,
parallel = pear
);
-- invalid: nonstrict inverse with strict forward function
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS