Re: A small bug in gram.y

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Gokulakannan Somasundaram <gokul007(at)gmail(dot)com>
Cc: pgsql-hackers list <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A small bug in gram.y
Date: 2009-11-03 07:49:17
Message-ID: 4AEFE07D.7080009@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gokulakannan Somasundaram wrote:
> Hmmm.... no-one else feels this as a bug????
>
> The logic is that a function call is made for "similar" and the position
> where SIMILAR occurs is at the third position, but it has been coded that it
> is at fifth position.

The function call is constructed for the similar_escape function, to
construct a regular expression equivalent to the right operand of the
SIMILAR TO. So setting the error location to the right operand seems OK
to me.

However, I note that for the "a_expr SIMILAR TO a_expr" rule we're doing
what you expected and the error location points to SIMILAR. I think we
should change that to behave like NOT SIMILAR TO.

Here's an example that exercises those paths:

postgres=# SELECT 'aa' NOT SIMILAR TO 123;
ERROR: function pg_catalog.similar_escape(integer, unknown) does not exist
LINE 1: SELECT 'aa' NOT SIMILAR TO 123;
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
postgres=# SELECT 'aa' SIMILAR TO 123;
ERROR: function pg_catalog.similar_escape(integer, unknown) does not exist
LINE 1: SELECT 'aa' SIMILAR TO 123;
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
postgres=#

I think the former error location is better.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2009-11-03 10:36:47 Re: Segfault in PL/Python
Previous Message Gokulakannan Somasundaram 2009-11-03 06:21:37 Re: A small bug in gram.y