Column mis-spelling hints vs case folding

Started by Tom Laneabout 11 years ago3 messageshackers
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

A newbie error that we see *constantly* is misunderstanding identifier
case-folding rules. ISTM that commit e529cd4ff missed a chance to help
with that. You do get a hint for this:

regression=# create table t1 (foo int, "Bar" int);
CREATE TABLE
regression=# select bar from t1;
ERROR: column "bar" does not exist
LINE 1: select bar from t1;
^
HINT: Perhaps you meant to reference the column "t1"."Bar".

but apparently it's just treating that as a vanilla one-mistyped-character
error, because there's no hint for this:

regression=# create table t2 (foo int, "BAR" int);
CREATE TABLE
regression=# select BAR from t2;
ERROR: column "bar" does not exist
LINE 1: select BAR from t2;
^

I think this hint might be a lot more useful if its comparison mechanism
were case-insensitive.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#1)
Re: Column mis-spelling hints vs case folding

On Sun, Apr 5, 2015 at 12:16 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

A newbie error that we see *constantly* is misunderstanding identifier
case-folding rules. ISTM that commit e529cd4ff missed a chance to help
with that. You do get a hint for this:

regression=# create table t1 (foo int, "Bar" int);
CREATE TABLE
regression=# select bar from t1;
ERROR: column "bar" does not exist
LINE 1: select bar from t1;
^
HINT: Perhaps you meant to reference the column "t1"."Bar".

but apparently it's just treating that as a vanilla one-mistyped-character
error, because there's no hint for this:

regression=# create table t2 (foo int, "BAR" int);
CREATE TABLE
regression=# select BAR from t2;
ERROR: column "bar" does not exist
LINE 1: select BAR from t2;
^

I think this hint might be a lot more useful if its comparison mechanism
were case-insensitive.

If you want to make that change, I will not object.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Bruce Momjian
bruce@momjian.us
In reply to: Robert Haas (#2)
Re: Column mis-spelling hints vs case folding

On 7 Apr 2015 09:37, "Robert Haas" <robertmhaas@gmail.com> wrote:

On Sun, Apr 5, 2015 at 12:16 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

A newbie error that we see *constantly* is misunderstanding identifier
case-folding rules.

I think this hint might be a lot more useful if its comparison mechanism
were case-insensitive.

If you want to make that change, I will not object.

If you just make out case insensitive that would be an improvement. Nobody
sane has similar columns that differ only in case.

But if the original token was not quoted and the suggested token requires
quoting IWBNI the hint directly addressed that source of confusion.

But if that gets fiddly, trying to squeeze too much in one hint then better
the generic hint then nothing at all. I don't want to kill a good simple
change with bike shedding here