Use default limitOption in subquery generated for MIN/MAX index scan.

We unintentionally copied the original query's limitOption field while
building the modified subquery.  If it was LIMIT_OPTION_WITH_TIES,
that behavior would propagate through to execution, potentially
causing a "more than one row returned by a subquery used as an
expression" error.  Fix by resetting to the default LIMIT_OPTION_COUNT.
This bug dates back to the introduction of WITH TIES.

Bug: #19694
Reported-by: Chaitanya Choudhary <[email protected]>
Author: Chaitanya Choudhary <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0d5505a22c4ce25e62166e4b5d68b07c27a42408

Modified Files
--------------
src/backend/optimizer/plan/planagg.c | 1 +
1 file changed, 1 insertion(+)

Reply via email to