mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-26 16:17:19 +02:00
Fix STRICT check for strict aggregates with NULL ORDER BY columns.
I (Andres) broke this unintentionally in69c3936a14
, by checking strictness for all input expressions computed for an aggregate, rather than just the input for the aggregate transition function. Reported-By: Ondřej Bouda Bisected-By: Tom Lane Diagnosed-By: Andrew Gierth Discussion: https://postgr.es/m/2a505161-2727-2473-7c46-591ed108ac52@email.cz Backpatch: 11-, like69c3936a14
This commit is contained in:
parent
bf4a9562e8
commit
fd59b29c87
@ -3028,7 +3028,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
|||||||
scratch.opcode = EEOP_AGG_STRICT_INPUT_CHECK;
|
scratch.opcode = EEOP_AGG_STRICT_INPUT_CHECK;
|
||||||
scratch.d.agg_strict_input_check.nulls = strictnulls;
|
scratch.d.agg_strict_input_check.nulls = strictnulls;
|
||||||
scratch.d.agg_strict_input_check.jumpnull = -1; /* adjust later */
|
scratch.d.agg_strict_input_check.jumpnull = -1; /* adjust later */
|
||||||
scratch.d.agg_strict_input_check.nargs = numInputs;
|
scratch.d.agg_strict_input_check.nargs = pertrans->numTransInputs;
|
||||||
ExprEvalPushStep(state, &scratch);
|
ExprEvalPushStep(state, &scratch);
|
||||||
adjust_bailout = lappend_int(adjust_bailout,
|
adjust_bailout = lappend_int(adjust_bailout,
|
||||||
state->steps_len - 1);
|
state->steps_len - 1);
|
||||||
|
@ -2101,3 +2101,18 @@ SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),
|
|||||||
1
|
1
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
-- Ensure that the STRICT checks for aggregates does not take NULLness
|
||||||
|
-- of ORDER BY columns into account. See bug report around
|
||||||
|
-- 2a505161-2727-2473-7c46-591ed108ac52@email.cz
|
||||||
|
SELECT min(x ORDER BY y) FROM (VALUES(1, NULL)) AS d(x,y);
|
||||||
|
min
|
||||||
|
-----
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT min(x ORDER BY y) FROM (VALUES(1, 2)) AS d(x,y);
|
||||||
|
min
|
||||||
|
-----
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
@ -928,3 +928,10 @@ ROLLBACK;
|
|||||||
|
|
||||||
-- test coverage for dense_rank
|
-- test coverage for dense_rank
|
||||||
SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),(3)) v(x) GROUP BY (x) ORDER BY 1;
|
SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),(3)) v(x) GROUP BY (x) ORDER BY 1;
|
||||||
|
|
||||||
|
|
||||||
|
-- Ensure that the STRICT checks for aggregates does not take NULLness
|
||||||
|
-- of ORDER BY columns into account. See bug report around
|
||||||
|
-- 2a505161-2727-2473-7c46-591ed108ac52@email.cz
|
||||||
|
SELECT min(x ORDER BY y) FROM (VALUES(1, NULL)) AS d(x,y);
|
||||||
|
SELECT min(x ORDER BY y) FROM (VALUES(1, 2)) AS d(x,y);
|
||||||
|
Loading…
Reference in New Issue
Block a user