pgsql: Fix the issue that SJE mistakenly omits qual clauses

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема pgsql: Fix the issue that SJE mistakenly omits qual clauses
Дата
Msg-id E1rM5VB-0009wL-B7@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix the issue that SJE mistakenly omits qual clauses

When the SJE code handles the transfer of qual clauses from the removed
relation to the remaining one, it replaces the Vars of the removed
relation with the Vars of the remaining relation for each clause, and
then reintegrates these clauses into the appropriate restriction or join
clause lists, while attempting to avoid duplicates.

However, the code compares RestrictInfo->clause to determine if two
clauses are duplicates.  This is just flat wrong.  Two RestrictInfos
with the same clause can have different required_relids,
incompatible_relids, is_pushed_down, and so on.  This can cause qual
clauses to be mistakenly omitted, leading to wrong results.

This patch fixes it by comparing the entire RestrictInfos not just their
clauses ignoring 'rinfo_serial' field (otherwise almost all RestrictInfos will
be unique).  Making 'rinfo_serial' equal_ignore would break other code.  This
is why this commit implements our own comparison function for checking the
equality of RestrictInfos.

Reported-by: Zuming Jiang
Bug: #18261
Discussion: https://postgr.es/m/18261-2a75d748c928609b%40postgresql.org
Author: Richard Guo

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5ef34a8fc3899a306fbc907a762fee0ba3782462

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 26 ++++++++++++++++++++++++--
src/test/regress/expected/join.out        | 26 +++++++++++++++++++++++++-
src/test/regress/sql/join.sql             | 17 ++++++++++++++++-
3 files changed, 65 insertions(+), 4 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Clean up some edge cases in plpgsql's %TYPE parsing.
Следующее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Fix oversized memory allocation in Parallel Hash Join