Skip system attributes when applying mvdistinct stats
authorTomas Vondra
Sat, 16 Nov 2019 00:17:15 +0000 (01:17 +0100)
committerTomas Vondra
Sat, 16 Nov 2019 00:25:14 +0000 (01:25 +0100)
commit28555a53cb75d00ed0e73f63a6481b4fffcc3dea
treea851ad6114555720042979305085fac989968859
parent24897e1a1af27dc759fb41afba2a663ff9af4ef6
Skip system attributes when applying mvdistinct stats

When estimating number of distinct groups, we failed to ignore system
attributes when matching the group expressions to mvdistinct stats,
causing failures like

  ERROR: negative bitmapset member not allowed

Fix that by simply skipping anything that is not a regular attribute.
Backpatch to PostgreSQL 10, where the extended stats were introduced.

Bug: #16111
Reported-by: Tuomas Leikola
Author: Tomas Vondra
Backpatch-through: 10
Discussion: https://postgr.es/m/16111-687799584c3a7e73@postgresql.org
src/backend/utils/adt/selfuncs.c
src/test/regress/expected/stats_ext.out
src/test/regress/sql/stats_ext.sql