mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
recurse_set_operations() uses the parse tree for the group number estimation, because of the "varno 0" hack. At the same time2489d76c49made root->parse and corresponding parent_root->simple_rte_array[]->subquery distinct copies of the parse tree, whiled3d55ce571introduced self-join removal replacing relid of removed relation only in one of the copies. The present commit fixes this bug by making recurse_set_operations() call estimate_num_groups() with the copy of the parse tree processed by self-join removal. In future, we may think about maintaining just one copy of the parse tree and/or keeping removed relids as aliases. Reported-by: Zuming Jiang Bug: #18170 Discussion: https://postgr.es/m/flat/18170-f1d17bf9a0d58b24%40postgresql.org Author: Richard Guo, Alexander Korotkov Reviewed-by: Andrei Lepikhov