Re: A small bug in gram.y - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: A small bug in gram.y
Date
Msg-id 4AEFE07D.7080009@enterprisedb.com
Whole thread Raw
In response to Re: A small bug in gram.y  (Gokulakannan Somasundaram <gokul007@gmail.com>)
Responses Re: A small bug in gram.y
Re: A small bug in gram.y
List 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


pgsql-hackers by date:

Previous
From: Gokulakannan Somasundaram
Date:
Subject: Re: A small bug in gram.y
Next
From: Peter Eisentraut
Date:
Subject: Re: Segfault in PL/Python