pgsql: Give a better error for duplicate entries in VACUUM/ANALYZE colu

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Give a better error for duplicate entries in VACUUM/ANALYZE colu
Date: 2017-09-21 22:13:56
Message-ID: E1dv9jI-0006oZ-Gf@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/122289a66b92799885917953907d5b3f3f9e6ac2

Modified Files
--------------
src/backend/commands/analyze.c | 13 ++++++++++++-
src/test/regress/expected/vacuum.out | 5 +++++
src/test/regress/sql/vacuum.sql | 4 ++++
3 files changed, 21 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2017-09-21 23:11:44 pgsql: Provide a test for variable existence in psql
Previous Message Tom Lane 2017-09-21 18:58:09 Re: [COMMITTERS] pgsql: Fix bool/int type confusion