From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Marek Lewczuk <newsy(at)lewczuk(dot)com>, Alexander Litvinov <lan(at)ac-sw(dot)com> |
Cc: | Lista dyskusyjna pgsql-general <pgsql-general(at)postgresql(dot)org>, Lista dyskusyjna pgsql-bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: [GENERAL] CASE in where statement. BUG ?? |
Date: | 2003-12-19 09:42:34 |
Message-ID: | 200312190942.34296.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-general |
On Friday 19 December 2003 09:02, Marek Lewczuk wrote:
> Alexander Litvinov wrote:
> > This is normaol behavior.
> >
> >>I belive that I have found a bug - or maybe it was done on purpose. Have
> >>a look at this query:
> >>
> >>
> >>SELECT integer_field FROM bugtable WHERE (CASE WHEN '' <> '' THEN
> >>integer_field = '' ELSE integer_field = 0 END);
> >>Result: ERROR: invalid input syntax for integer: ""
> >
> > Here CASE have int type and you are trying to cast '' to int. Error.
>
> Well, I see that you have not run this query: In this case the query is
> trying to make integer_field = '' --> but it shouldn't, becouse "CASE
> WHEN '' <> ''" is false, so "ELSE integer_field = 0" should be used.
But until it's evaluated ''<>'' it doesn't know it is false. When building the
CASE expression, it's trying to map types to each elements and notes that ''
is not an int. Only after this stage will it actually try to evaluate the
expression.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Marek Lewczuk | 2003-12-19 09:59:43 | Re: [GENERAL] CASE in where statement. BUG ?? |
Previous Message | Marek Lewczuk | 2003-12-19 09:02:39 | Re: [GENERAL] CASE in where statement. BUG ?? |
From | Date | Subject | |
---|---|---|---|
Next Message | Marek Lewczuk | 2003-12-19 09:59:43 | Re: [GENERAL] CASE in where statement. BUG ?? |
Previous Message | Richard Huxton | 2003-12-19 09:38:33 | Re: Duplication to External Server |