Re: [HACKERS] Bug in evaluation of AND

From: "Vadim B(dot) Mikheev" <vadim(at)sable(dot)krasnoyarsk(dot)su>
To: jeroenv(at)design(dot)nl
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Bug in evaluation of AND
Date: 1998-02-18 10:53:11
Message-ID: 34EABD97.932DAC82@sable.krasnoyarsk.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeroen van Vianen wrote:
>
> I found the following bug in sunday's snapshot (I am running Linux
> 2.1.85 and gcc 2.8.0):

Presents in 6.2.1 too...

Caused by bad execution plan:

Result (cost=0.00 size=0 width=0)
-> Seq Scan on aaa (cost=0.00 size=0 width=0)
^^^^^^^^^^^^^^^
Target list of SeqScan is empty => ExecProject returns NULL...
Optimizer should put Constant into Result' childplan target list
if it's empty. Easy to fix. Anyone ?

Vadim

>
> I created a table with one column and inserted one row:
>
> jeroenv=> create table test ( a int4 );
> CREATE
> jeroenv=> insert into test values ( 1 );
> INSERT 321708 1
>
> Some checks:
>
> jeroenv=> select a from test where (a=1);
> a
> -
> 1
> (1 row)
>
> jeroenv=> select a from test where (a=1) and true;
> a
> -
> 1
> (1 row)
>
> Now, instead of column 'a' I return the constant 1:
>
> jeroenv=> select 1 from test where (a=1);
> ?column?
> --------
> 1
> (1 row)
>
> jeroenv=> select 1 from test where (a=1) and true;
> ?column?
> --------
> (0 rows)
>
> No rows is not what I would expect.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim B. Mikheev 1998-02-18 12:29:24 new Group BY code
Previous Message Vadim B. Mikheev 1998-02-18 09:28:31 Re: [HACKERS] ecpg stuff