pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Disable WindowAgg inverse transitions when subplans are present 6+ messages / 1 participants [nested] [flat]
* pgsql: Disable WindowAgg inverse transitions when subplans are present @ 2023-02-13 04:08 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: David Rowley @ 2023-02-13 04:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disable WindowAgg inverse transitions when subplans are present When an aggregate function is used as a WindowFunc and a tuple transitions out of the window frame, we ordinarily try to make use of the aggregate function's inverse transition function to "unaggregate" the exiting tuple. This optimization is disabled for various cases, including when the aggregate contains a volatile function. In such a case we'd be unable to ensure that the transition value was calculated to the same value during transitions and inverse transitions. Unfortunately, we did this check by calling contain_volatile_functions() which does not recursively search SubPlans for volatile functions. If the aggregate function's arguments or its FILTER clause contained a subplan with volatile functions then we'd fail to notice this. Here we fix this by just disabling the optimization when the WindowFunc contains any subplans. Volatile functions are not the only reason that a subplan may have nonrepeatable results. Bug: #17777 Reported-by: Anban Company Discussion: https://postgr.es/m/17777-860b739b6efde977%40postgresql.org Reviewed-by: Tom Lane Backpatch-through: 11 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8d2a8581b6d67cfa05c1f47fa13de9815cdf91f6 Modified Files -------------- src/backend/executor/nodeWindowAgg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Disable WindowAgg inverse transitions when subplans are present @ 2023-02-13 04:09 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: David Rowley @ 2023-02-13 04:09 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disable WindowAgg inverse transitions when subplans are present When an aggregate function is used as a WindowFunc and a tuple transitions out of the window frame, we ordinarily try to make use of the aggregate function's inverse transition function to "unaggregate" the exiting tuple. This optimization is disabled for various cases, including when the aggregate contains a volatile function. In such a case we'd be unable to ensure that the transition value was calculated to the same value during transitions and inverse transitions. Unfortunately, we did this check by calling contain_volatile_functions() which does not recursively search SubPlans for volatile functions. If the aggregate function's arguments or its FILTER clause contained a subplan with volatile functions then we'd fail to notice this. Here we fix this by just disabling the optimization when the WindowFunc contains any subplans. Volatile functions are not the only reason that a subplan may have nonrepeatable results. Bug: #17777 Reported-by: Anban Company Discussion: https://postgr.es/m/17777-860b739b6efde977%40postgresql.org Reviewed-by: Tom Lane Backpatch-through: 11 Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ac55abd33537f5ac38563826bd9423f961ac66f0 Modified Files -------------- src/backend/executor/nodeWindowAgg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Disable WindowAgg inverse transitions when subplans are present @ 2023-02-13 04:09 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: David Rowley @ 2023-02-13 04:09 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disable WindowAgg inverse transitions when subplans are present When an aggregate function is used as a WindowFunc and a tuple transitions out of the window frame, we ordinarily try to make use of the aggregate function's inverse transition function to "unaggregate" the exiting tuple. This optimization is disabled for various cases, including when the aggregate contains a volatile function. In such a case we'd be unable to ensure that the transition value was calculated to the same value during transitions and inverse transitions. Unfortunately, we did this check by calling contain_volatile_functions() which does not recursively search SubPlans for volatile functions. If the aggregate function's arguments or its FILTER clause contained a subplan with volatile functions then we'd fail to notice this. Here we fix this by just disabling the optimization when the WindowFunc contains any subplans. Volatile functions are not the only reason that a subplan may have nonrepeatable results. Bug: #17777 Reported-by: Anban Company Discussion: https://postgr.es/m/17777-860b739b6efde977%40postgresql.org Reviewed-by: Tom Lane Backpatch-through: 11 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/301eb3ee4ecd366c92bc8ecda9c42c3760e018c1 Modified Files -------------- src/backend/executor/nodeWindowAgg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Disable WindowAgg inverse transitions when subplans are present @ 2023-02-13 04:10 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: David Rowley @ 2023-02-13 04:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disable WindowAgg inverse transitions when subplans are present When an aggregate function is used as a WindowFunc and a tuple transitions out of the window frame, we ordinarily try to make use of the aggregate function's inverse transition function to "unaggregate" the exiting tuple. This optimization is disabled for various cases, including when the aggregate contains a volatile function. In such a case we'd be unable to ensure that the transition value was calculated to the same value during transitions and inverse transitions. Unfortunately, we did this check by calling contain_volatile_functions() which does not recursively search SubPlans for volatile functions. If the aggregate function's arguments or its FILTER clause contained a subplan with volatile functions then we'd fail to notice this. Here we fix this by just disabling the optimization when the WindowFunc contains any subplans. Volatile functions are not the only reason that a subplan may have nonrepeatable results. Bug: #17777 Reported-by: Anban Company Discussion: https://postgr.es/m/17777-860b739b6efde977%40postgresql.org Reviewed-by: Tom Lane Backpatch-through: 11 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4aa43ba21846ac6cc53c554565898a294ded6ad1 Modified Files -------------- src/backend/executor/nodeWindowAgg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Disable WindowAgg inverse transitions when subplans are present @ 2023-02-13 04:10 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: David Rowley @ 2023-02-13 04:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disable WindowAgg inverse transitions when subplans are present When an aggregate function is used as a WindowFunc and a tuple transitions out of the window frame, we ordinarily try to make use of the aggregate function's inverse transition function to "unaggregate" the exiting tuple. This optimization is disabled for various cases, including when the aggregate contains a volatile function. In such a case we'd be unable to ensure that the transition value was calculated to the same value during transitions and inverse transitions. Unfortunately, we did this check by calling contain_volatile_functions() which does not recursively search SubPlans for volatile functions. If the aggregate function's arguments or its FILTER clause contained a subplan with volatile functions then we'd fail to notice this. Here we fix this by just disabling the optimization when the WindowFunc contains any subplans. Volatile functions are not the only reason that a subplan may have nonrepeatable results. Bug: #17777 Reported-by: Anban Company Discussion: https://postgr.es/m/17777-860b739b6efde977%40postgresql.org Reviewed-by: Tom Lane Backpatch-through: 11 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a9fa6d79aded60564737c502115d531499deacf4 Modified Files -------------- src/backend/executor/nodeWindowAgg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Disable WindowAgg inverse transitions when subplans are present @ 2023-02-13 04:11 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: David Rowley @ 2023-02-13 04:11 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disable WindowAgg inverse transitions when subplans are present When an aggregate function is used as a WindowFunc and a tuple transitions out of the window frame, we ordinarily try to make use of the aggregate function's inverse transition function to "unaggregate" the exiting tuple. This optimization is disabled for various cases, including when the aggregate contains a volatile function. In such a case we'd be unable to ensure that the transition value was calculated to the same value during transitions and inverse transitions. Unfortunately, we did this check by calling contain_volatile_functions() which does not recursively search SubPlans for volatile functions. If the aggregate function's arguments or its FILTER clause contained a subplan with volatile functions then we'd fail to notice this. Here we fix this by just disabling the optimization when the WindowFunc contains any subplans. Volatile functions are not the only reason that a subplan may have nonrepeatable results. Bug: #17777 Reported-by: Anban Company Discussion: https://postgr.es/m/17777-860b739b6efde977%40postgresql.org Reviewed-by: Tom Lane Backpatch-through: 11 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/836c31ba508c154bc4c4ebb6270761586a6df797 Modified Files -------------- src/backend/executor/nodeWindowAgg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-02-13 04:11 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-02-13 04:08 pgsql: Disable WindowAgg inverse transitions when subplans are present David Rowley <drowley@postgresql.org> 2023-02-13 04:09 pgsql: Disable WindowAgg inverse transitions when subplans are present David Rowley <drowley@postgresql.org> 2023-02-13 04:09 pgsql: Disable WindowAgg inverse transitions when subplans are present David Rowley <drowley@postgresql.org> 2023-02-13 04:10 pgsql: Disable WindowAgg inverse transitions when subplans are present David Rowley <drowley@postgresql.org> 2023-02-13 04:10 pgsql: Disable WindowAgg inverse transitions when subplans are present David Rowley <drowley@postgresql.org> 2023-02-13 04:11 pgsql: Disable WindowAgg inverse transitions when subplans are present David Rowley <drowley@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox