Re: BUG #18730: Inequality comparison operators and SMALLINT negative immediate value

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "nat(at)makarevitch(dot)org" <nat(at)makarevitch(dot)org>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18730: Inequality comparison operators and SMALLINT negative immediate value
Date: 2024-12-03 13:48:04
Message-ID: CAKFQuwZWj6-i0R1MNYL5GhKTK1-NFOQfoBZP_t3SKeYc+uge_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Monday, December 2, 2024, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18730
> Logged by: Nat Makarevitch
> Email address: nat(at)makarevitch(dot)org
> PostgreSQL version: 17.2
> Operating system: Linux
> Description:
>
> BEWARE: there isn't any space between '=' and '-':
> select * from test_smallint where smint!=-2;
> ERROR: operator does not exist: smallint !=- integer
> LINE 1: select * from test_smallint where smint!=-2;
> ^
> HINT: No operator matches the given name and argument types. You might
> need
> to add explicit type casts.

The operator !=- is allowed per [1], since it contains !, so the parser
captures the - as per of the operator as opposed to leaving - as a break
character.

1.
https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS

> Isn't the operator "!=" theoritically "an alias, which is converted to <>
> at
> a very early stage of parsing" (as per
> https://www.postgresql.org/docs/17/functions-comparison.html )?

The != operator and !=- operators are two different operators. Only the
former is converted to <>, and not any symbol subsequence of those two
characters.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2024-12-03 14:52:32 Re: BUG #18732: Segfault in pgbench on max_connections starvation
Previous Message PostgreSQL TDBA (LDBV) 2024-12-03 12:36:25 AW: BUG #18725: "set role" requires "grant connect on database"