model-writtenrun 8375 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jeremy Smith reported that PL/pgSQL RETURN QUERY could not use parallel plans even when the equivalent standalone query did, and supplied a temporary-table workaround #1.
- Tom Lane traced the restriction to RETURN QUERY's internal cursor and proposed sending executor results directly into a spillable tuplestore through new SPI DestReceiver interfaces, preserving bounded memory use while enabling parallel execution #2.
- Hamid Akhtar reported successful regression and feature testing of the first patch #4, after which Tom raised the possibility of including the improvement in PostgreSQL 13 #5.
- Tom's revised patch retained the execution design, converted PL/pgSQL's legacy parameter handling to ParamListInfo, and added SPI documentation; he deferred converting other consumers and deprecating old SPI interfaces as separate work #6.
- Tom committed the revised patch with documentation and comment refinements as 2f48ede080, crediting Hamid's review and explaining that the change was too invasive to back-patch.
- After the commit, Robert Haas explained why parallel execution cannot safely yield control through cursors and welcomed the improvement #7.
- Following PostgreSQL 14's release, Marc Bachmann reported that RETURN QUERY INSERT RETURNING now failed with a SELECT-only error #8, and Tom identified this as an unintended consequence of the refactoring #9.
- Tom fixed the regression in a0558cfa39 by moving tuple-return validation into SPI for both static and dynamic RETURN QUERY, adding regression tests, and back-patching to PostgreSQL 14; he announced the fix #10, and Marc acknowledged it in the thread's final message #11.