aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-03-11 10:44:04 -0400
committerRobert Haas <rhaas@postgresql.org>2015-03-11 10:44:04 -0400
commite529cd4ffa605c6f14f1391af5559b3a44da0336 (patch)
treeedc9c0a16e48514e4f6570e2ecee56fff29e4ea6 /src/backend/parser/parse_expr.c
parentbbfd7edae5aa5ad5553d3c7e102f2e450d4380d4 (diff)
downloadpostgresql-e529cd4ffa605c6f14f1391af5559b3a44da0336.tar.gz
postgresql-e529cd4ffa605c6f14f1391af5559b3a44da0336.zip
Suggest to the user the column they may have meant to reference.
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
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r--src/backend/parser/parse_expr.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 7829bcbac16..130e52b26c4 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -556,7 +556,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
colname = strVal(field2);
/* Try to identify as a column of the RTE */
- node = scanRTEForColumn(pstate, rte, colname, cref->location);
+ node = scanRTEForColumn(pstate, rte, colname, cref->location,
+ 0, NULL);
if (node == NULL)
{
/* Try it as a function call on the whole row */
@@ -601,7 +602,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
colname = strVal(field3);
/* Try to identify as a column of the RTE */
- node = scanRTEForColumn(pstate, rte, colname, cref->location);
+ node = scanRTEForColumn(pstate, rte, colname, cref->location,
+ 0, NULL);
if (node == NULL)
{
/* Try it as a function call on the whole row */
@@ -659,7 +661,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
colname = strVal(field4);
/* Try to identify as a column of the RTE */
- node = scanRTEForColumn(pstate, rte, colname, cref->location);
+ node = scanRTEForColumn(pstate, rte, colname, cref->location,
+ 0, NULL);
if (node == NULL)
{
/* Try it as a function call on the whole row */