Re: Wrong unsafe-flag test in check_output_expressions()
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-02T20:59:17Z
Lists: pgsql-hackers
On Mon, 1 Jun 2026 at 20:27, Richard Guo <guofenglinux@gmail.com> wrote:
>
> I happened to notice $subject when working on a bug-fix near-by.
>
> /* If subquery uses window functions, check point 4 */
> if (subquery->hasWindowFuncs &&
> (safetyInfo->unsafeFlags[tle->resno] &
> UNSAFE_NOTIN_DISTINCTON_CLAUSE) == 0 &&
> !targetIsInAllPartitionLists(tle, subquery))
> {
> /* not present in all PARTITION BY clauses, so mark it unsafe */
> safetyInfo->unsafeFlags[tle->resno] |= UNSAFE_NOTIN_PARTITIONBY_CLAUSE;
> continue;
> }
Yes, that's not intentional. Your proposed fix looks correct. Are you
happy to go ahead with pushing and backpatching that?
Wondering, did you spot that with eyes or tool assist?
David
Commits
-
Fix wrong unsafe-flag test in check_output_expressions()
- 919471ead95f 15 (unreleased) landed
- ad1cb0d08df7 16 (unreleased) landed
- c3f1db2b8822 17 (unreleased) landed
- cc0819e78ae3 18 (unreleased) landed
- ee2fa291c8b2 19 (unreleased) landed