Subject | Re: Memory overflow executing a SQL statement |
---|---|
Author | kokok_kokok |
Post date | 2005-07-22T08:03:39Z |
--- In firebird-support@yahoogroups.com, "kokok_kokok"
<kokok_kokok@y...> wrote:
select 0, color, count(*) from product group by 1,2
crashes Firebird, but if I cast it
select cast(0 as integer), color, count(*) from product group by 1,2
then it works fine.
<kokok_kokok@y...> wrote:
> --- In firebird-support@yahoogroups.com, "Adam" <s3057043@y...> wrote:Definitely it is a bug of FB, I have found:
> > > If I stop the Firebird Engine before the crash, I get the following
> > > dataset result:
> > >
> > > COLUMN0, COLUMN1, SUM
> > > 0, <null>, <null>
> > > 0, <null>, <null>
> > > 0, <null>, <null>
> > > ....
> > >
> > >
> > > Hundreds of similar rows.
> > >
> > > Is it a bug of Firebird?
> > >
> > > Thank you
> >
> > No it is a bug in your logic that assumes that NULL = NULL
> >
> > NULL does not equal NULL
> > Therefore, every (0, NULL) combination would be considered unique.
> >
> > In fact I am not sure why
> >
> > select NULL, sum(*)
> > from customers
> > group by 1
> >
> > would work (although it does, logically it shouldn't). Perhaps that
> > is a bug.
> >
> > Read this NULL guide for more info.
> > http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_firebird_null
> >
> > By the way it is possible to use first 1 syntax to stop it going to
> > infinity, but still I would be looking for some other way of the
> > wizard handling this.
> >
> > Hope that helps a little.
> > Adam
>
>
> Yes, I understand that A = B it's impossible to know if they are equal
> if A and B are NULL, but "GROUP" groups the NULL values as 1 item
> because all are unknonw.
>
> For example:
>
> select color, count(*) from product group by 1
>
> it returns someting like:
>
> <null>, 102
> black, 23
> white, 14
>
>
> Note that all <null> are grouped in 1 item. It is right.
>
> Now, if I do:
>
> select 0, color, count(*) from product group by 1,2
>
> the FB crashes and it is not ok, the result must be the same that the
> first case plus a 0 column.
select 0, color, count(*) from product group by 1,2
crashes Firebird, but if I cast it
select cast(0 as integer), color, count(*) from product group by 1,2
then it works fine.