Thread

  1. Re: [HACKERS] SELECT BUG

    Jose Soares <jose@sferacarta.com> — 1999-09-01T16:22:27Z

    You mean that "a1 " is not equal to "a1      " ?
    but PostgreSQL has a different behavior in the following example:
    
    hygea=> select code,len(code) as len_of_code,code1, len(code1) as
    len_of_code1
    from master1 where code = code1;
    
    code      |len_of_code|code1       |len_of_code1
    ----------+-----------+------------+------------
    a1        |         10|a1          |          15
    (1 row)
    
    
    in this case the test code = code1 is true even if these fields have
    different number of trailling spaces.
    
    Therefore if the above test is OK there's a bug on:
    
            select m.*, d.* from master1 m, detail1 d where m.code=d.code;
    
    
    José
    
    
    Tom Lane ha scritto:
    
    > =?iso-8859-1?Q?Jos=E9?= Soares <jose@sferacarta.com> writes:
    > > --I have the following test data into these tables:
    >
    > > hygea=> select * from master1;
    > > code
    > > -----------
    > > a
    > > a1
    > > a13
    > > (3 rows)
    >
    > > hygea=> select * from detail1;
    > > code
    > > ----------------
    > > a13
    > > a13
    > > a1
    > > (3 rows)
    >
    > > --if I try to join these two tables I have the following (nothing):
    >
    > > hygea=> select m.*, d.* from master1 m, detail1 d where m.code=d.code;
    > > code|code
    > > ----+----
    > > (0 rows)
    > > --and now trying with TRIM function... it works!
    >
    > > hygea=> select m.*, d.* from master1 m, detail1 d where
    > > trim(m.code)=trim(d.code
    > > code       |code
    > > -----------+----------------
    > > a13        |a13
    > > a13        |a13
    > > a1         |a1
    > > (3 rows)
    >
    > Looks to me like you have differing numbers of trailing spaces in the
    > entries in each table.  If so, this is not a bug.
    >
    >                         regards, tom lane