Give a better error for duplicate entries in VACUUM/ANALYZE column list.
authorTom Lane
Thu, 21 Sep 2017 22:13:11 +0000 (18:13 -0400)
committerTom Lane
Thu, 21 Sep 2017 22:13:11 +0000 (18:13 -0400)
commitb572b435ca67a2c032187d376baa271f9049b7cf
tree2ca521ed45fa68cf5801ba8696d1f92ee97d5bfc
parente5b8b771e7a98e3620679cd9873ad2507ab87fb5
Give a better error for duplicate entries in VACUUM/ANALYZE column list.

Previously, the code didn't think about this case and would just try to
analyze such a column twice.  That would fail at the point of inserting
the second version of the pg_statistic row, with obscure error messsages
like "duplicate key value violates unique constraint" or "tuple already
updated by self", depending on context and PG version.  We could allow
the case by ignoring duplicate column specifications, but it seems better
to reject it explicitly.

The bogus error messages seem like arguably a bug, so back-patch to
all supported versions.

Nathan Bossart, per a report from Michael Paquier, and whacked
around a bit by me.

Discussion: https://postgr.es/m/E061A8E3-5E3D-494D-94F0-E8A9B312BBFC@amazon.com
src/backend/commands/analyze.c
src/test/regress/expected/vacuum.out
src/test/regress/sql/vacuum.sql