Closed yugo-n closed 1 year ago
It is not related to Cartesian product. This is a bug that a unique index could be created even even where there is a primary key attribute from just one of relations in FROM clause. Actually, it is intended that an index is created only if all primary keys of tables in FROM clause appear in the target list.
I misused pull_varnos_of_level but this didn't work, so I fixed it by using get_relids_in_jointree instead.
Reported by huyajun in https://www.postgresql.org/message-id/tencent_FCAF11BCA5003FD16BDDFDDA5D6A19587809%40qq.com
A unique index should not be created in the case of a Cartesian product