Is this BUG or FEATURE?

Vladimir Litovka <pgsqll@barnet.kharkov.ua>

From: Vladimir Litovka <pgsqll@barnet.kharkov.ua>
To: PgSQL-sql <pgsql-sql@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Date: 1998-10-17T13:19:15Z
Lists: pgsql-hackers, pgsql-sql
Hello!

 There is problem - I don't know where is it.

 I'm using PostgreSQL 6.3.2 under Linux-2.0 with official patches:

  . linux_elf.patch-980421.gz
  . gram.c.patch-980428
  . configure-980430.gz
  . btree_adj-980730.gz
 
 There are two tables in my test database:

create table AAA (anum int2, aname char(16), ata int4 default 0);
insert into AAA values (0, '0');
insert into AAA values (1, '1');
-- Note: ata hasn't initialized!

create table BBB (bnum int2, bname char(16));
insert into BBB values (0, '0');
insert into BBB values (1, '1');

 Now try some queries:

test=> select * from aaa, bbb where bnum = anum;
anum|           aname|ata|bnum|           bname
----+----------------+---+----+----------------
   0|0               |  0|   0|0               
   1|1               |  0|   1|1               
(2 rows)

 It's OK, in both AAA and BBB all fields as expected.

test=> select * from aaa, bbb where bnum = ata;
NOTICE:  ExecInitMergeJoin: left and right sortop's are unequal!
anum|           aname|ata|bnum|           bname
----+----------------+---+----+----------------
   0|0               |  0|   0|0               
   1|1               |  0|   0|0               
(2 rows)

 Why bnum and bname are 0 and '0' respectively? I'm agree - ata and bnum
has different types, but why illegal comparison resets BBB's fields? In the
last query I'm expect for one row in result, where bnum == ata == 0!

 Who is wrong - I'm or PostgreSQL? And why?

---
Vladimir Litovka <doka@webest.com>