Lists: | pgsql-hackers |
---|
From: | "William ZHANG" <uniware(at)zedware(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | ERROR: operator does not exist: integer !=- integer |
Date: | 2007-03-04 03:42:21 |
Message-ID: | esdf74$6rn$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Here is the steps to reproduce it in CVS HEAD:
$ uname -a
Linux os-server 2.6.9-11.19AX #1 Fri Aug 5 05:12:07 EDT 2005 i686 i686 i386
GNU/Linux
$ ./postgres --single -D $HOME/pgsql/data postgres
PostgreSQL stand-alone backend 8.3devel
backend> show server_version;
1: server_version (typeid = 25, len = -1, typmod = -1, byval =
f)
----
1: server_version = "8.3devel" (typeid = 25, len = -1, typmod = -1,
byval = f)
----
backend> select -1 != -1;
1: ?column? (typeid = 16, len = 1, typmod = -1, byval = t)
----
1: ?column? = "f" (typeid = 16, len = 1, typmod = -1, byval =
t)
----
backend> select -1 !=-1;
ERROR: operator does not exist: integer !=- integer at character 11
HINT: No operator matches the given name and argument type(s). You might
need to add explicit type casts.
STATEMENT: select -1 !=-1;
A quick hack in scan.l :
*** src/backend/parser/scan.l.old 2007-03-04 11:39:56.831289992 +0800
--- src/backend/parser/scan.l 2007-03-04 11:40:04.142178568 +0800
***************
*** 605,610 ****
--- 605,617 ----
{
int ic;
+ /* filter out operaters end
with '=' */
+ if (yytext[nchars - 2] ==
'=')
+ {
+ nchars--;
+ continue;
+ }
+
for (ic = nchars-2; ic >= 0;
ic--)
{
if
(strchr("~!(at)#^&|`?%", yytext[ic]))
Now the result is correct:
backend> select -1 !=-1;
1: ?column? (typeid = 16, len = 1, typmod = -1, byval = t)
----
1: ?column? = "f" (typeid = 16, len = 1, typmod = -1, byval =
t)
----
--
Regards,
William ZHANG
From: | Andrew - Supernews <andrew+nonews(at)supernews(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ERROR: operator does not exist: integer !=- integer |
Date: | 2007-03-04 10:59:24 |
Message-ID: | slrneul9kc.2tne.andrew+nonews@atlantis.supernews.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 2007-03-04, William ZHANG <uniware(at)zedware(dot)org> wrote:
> Here is the steps to reproduce it in CVS HEAD:
> backend> select -1 !=-1;
This arguably isn't a bug, because != is not a standard SQL operator, and
therefore !=- can legitimately be defined as a single operator by the user.
--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services
From: | Shane Ambler <pgsql(at)Sheeky(dot)Biz> |
---|---|
To: | andrew(at)supernews(dot)com |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ERROR: operator does not exist: integer !=- integer |
Date: | 2007-03-04 15:56:38 |
Message-ID: | 45EAEC36.8040901@Sheeky.Biz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Andrew - Supernews wrote:
> On 2007-03-04, William ZHANG <uniware(at)zedware(dot)org> wrote:
>> Here is the steps to reproduce it in CVS HEAD:
>> backend> select -1 !=-1;
>
> This arguably isn't a bug, because != is not a standard SQL operator, and
> therefore !=- can legitimately be defined as a single operator by the user.
>
I missed the first post and can't seem to search for it - so correct me
if I am missing something.
Isn't the problem here a missing space? != is a valid operator and -1 is
the value you are comparing to. !=-1 is not valid but != -1 is correct
and what I assume you are looking to achieve.
The negation operator goes with the int being negated and is not part of
the comparison operator != the space is needed there to separate the two.
--
Shane Ambler
pgSQL(at)Sheeky(dot)Biz
Get Sheeky @ http://Sheeky.Biz
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "William ZHANG" <uniware(at)zedware(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ERROR: operator does not exist: integer !=- integer |
Date: | 2007-03-04 18:07:44 |
Message-ID: | 22654.1173031664@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
"William ZHANG" <uniware(at)zedware(dot)org> writes:
> backend> select -1 !=-1;
> ERROR: operator does not exist: integer !=- integer at character 11
This is not a bug.
regards, tom lane
From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
---|---|
To: | Shane Ambler <pgsql(at)Sheeky(dot)Biz> |
Cc: | andrew(at)supernews(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ERROR: operator does not exist: integer !=- integer |
Date: | 2007-03-04 18:51:01 |
Message-ID: | 45EB1515.5070103@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
>
> I missed the first post and can't seem to search for it - so correct
> me if I am missing something.
>
> Isn't the problem here a missing space? != is a valid operator and -1
> is the value you are comparing to. !=-1 is not valid but != -1 is
> correct and what I assume you are looking to achieve.
>
Well yes it will work if you add a space, but technically the problem is
the query should be written like this:
1 <>-1 or 1 <> -1
Joshua D. Drake
> The negation operator goes with the int being negated and is not part
> of the comparison operator != the space is needed there to separate
> the two.
>
>
>
From: | "William ZHANG" <uniware(at)zedware(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ERROR: operator does not exist: integer !=- integer |
Date: | 2007-03-05 05:34:48 |
Message-ID: | esga5o$1nde$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
I get it. scan.l converts '!=' to '<>':
644 /* Convert "!=" operator to "<>" for
compatibility */
645 if (strcmp(yytext, "!=") == 0)
646 yylval.str = pstrdup("<>");
647 else
648 yylval.str = pstrdup(yytext);
""Joshua D. Drake"" <jd(at)commandprompt(dot)com>
>
> Well yes it will work if you add a space, but technically the problem is
> the query should be written like this:
>
> 1 <>-1 or 1 <> -1
>
> Joshua D. Drake