pgsql: Set scan direction appropriately for SubPlans (bug #15336)

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема pgsql: Set scan direction appropriately for SubPlans (bug #15336)
Дата
Msg-id E1fqgia-0000TT-Hk@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Set scan direction appropriately for SubPlans (bug #15336)

When executing a SubPlan in an expression, the EState's direction
field was left alone, resulting in an attempt to execute the subplan
backwards if it was encountered during a backwards scan of a cursor.
Also, though much less likely, it was possible to reach the execution
of an InitPlan while in backwards-scan state.

Repair by saving/restoring estate->es_direction and forcing forward
scan mode in the relevant places.

Backpatch all the way, since this has been broken since 8.3 (prior to
commit c7ff7663e, SubPlans had their own EStates rather than sharing
the parent plan's, so there was no confusion over scan direction).

Per bug #15336 reported by Vladimir Baranoff; analysis and patch by
me, review by Tom Lane.

Discussion: https://postgr.es/m/153449812167.1304.1741624125628126322@wrigleys.postgresql.org

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d2ecc27c374ad04b06fc62f365ff9445854153fd

Modified Files
--------------
src/backend/executor/nodeSubplan.c      | 26 ++++++++++++++++++++++++--
src/test/regress/expected/subselect.out | 17 +++++++++++++++++
src/test/regress/sql/subselect.sql      | 16 ++++++++++++++++
3 files changed, 57 insertions(+), 2 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix configure's snprintf test so it exposes HP-UX bug.
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: InsertPgAttributeTuple() to set attcacheoff