Re: [HACKERS] SELECT BUG

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: José Soares <jose(at)sferacarta(dot)com>
Cc: hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] SELECT BUG
Date: 1999-09-02 13:19:37
Message-ID: 8828.936278377@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?iso-8859-1?Q?Jos=E9?= Soares <jose(at)sferacarta(dot)com> writes:
> You mean that "a1 " is not equal to "a1 " ?

I don't think they're equal ... do you? That is what trim()
is for, after all.

> 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;

What is this "len" function? I don't find one in the standard
distribution. I suspect you have some locally developed function
that returns the attrmod of the column --- which is the maximum
length of a varchar, but is not the same as the *actual* length
of the value.

> in this case the test code = code1 is true even if these fields have
> different number of trailling spaces.

I see no such behavior:

regression=> create table z2 (code varchar(10), code1 varchar(15));
CREATE
regression=> select code,len(code) from z2;
ERROR: No such function 'len' with the specified attributes
regression=> insert into z2 values ('a1', 'a1');
INSERT 282452 1
regression=> insert into z2 values ('a1 ', 'a1 ');
INSERT 282453 1
regression=> select *,length(code),length(code1) from z2 ;
code|code1 |length|length
----+---------+------+------
a1 |a1 | 2| 2
a1 |a1 | 4| 9
(2 rows)
regression=> select *,length(code),length(code1) from z2 where code = code1;
code|code1|length|length
----+-----+------+------
a1 |a1 | 2| 2
(1 row)

Can you provide a reproducible example?

regards, tom lane

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-09-02 13:27:17 Re: [HACKERS] md.c is feeling much better now, thank you
Previous Message Christian Denning 1999-09-02 13:08:28 Re: Linux/Postgres 6.5 problems using jdbc w/jdk1.2