Suggest to the user the column they may have meant to reference

Enterprise / PostgreSQL - Robert Haas [postgresql.org] - 11 March 2015 09:44 UTC

Error messages informing the user that no such column exists can sometimes provoke a perplexed response. This often happens due to a subtle typo in the column name or, perhaps less likely, in the alias name. To speed discovery of what the real issue is in such cases, we'll now search the range table for approximate matches. If there are one or two such matches that are good enough to think that they might be what the user intended to type, and better than all other approximate matches, we'll issue a hint suggesting that the user might have intended to reference those columns.

Peter Geoghegan and Robert Haas

e529cd4 Suggest to the user the column they may have meant to reference.
src/backend/parser/parse_expr.c | 9 +-
src/backend/parser/parse_func.c | 2 +-
src/backend/parser/parse_relation.c | 266 +++++++++++++++++++++++++----
src/backend/utils/adt/levenshtein.c | 9 +
src/include/parser/parse_relation.h | 21 ++-
src/test/regress/expected/alter_table.out | 3 +
src/test/regress/expected/join.out | 38 +++++
src/test/regress/sql/join.sql | 24 +++
8 files changed, 334 insertions(+), 38 deletions(-)

Upstream: git.postgresql.org


  • Share