Re: [HACKERS] SELECT BUG

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] SELECT BUG
Дата
Msg-id 8828.936278377@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] SELECT BUG  (José Soares <jose@sferacarta.com>)
Список pgsql-hackers
José Soares <jose@sferacarta.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [HACKERS] Commercial question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] md.c is feeling much better now, thank you