Re: I need a SQL...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: I need a SQL...
Дата
Msg-id 26747.1063290361@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: I need a SQL...  (Bjørn T Johansen <btj@havleik.no>)
Ответы Re: I need a SQL...  (Bjørn T Johansen <btj@havleik.no>)
Список pgsql-general
=?ISO-8859-1?Q?Bj=F8rn?= T Johansen <btj@havleik.no> writes:
> Yes, I am sure, I just use copy-and-paste and I have double checked....
> I am running on 7.3.4 but that shouldn't make any difference?

It'll probably work better if you quote the zero.  Unquoted, you get
some weird textual comparison.  Compare:

regression=# explain select * from time_tbl where f1-f1 >= 0;
                       QUERY PLAN
--------------------------------------------------------
 Seq Scan on time_tbl  (cost=0.00..1.14 rows=3 width=8)
   Filter: (((f1 - f1))::text >= '0'::text)
(2 rows)

regression=# explain select * from time_tbl where f1-f1 >= '0';
                       QUERY PLAN
--------------------------------------------------------
 Seq Scan on time_tbl  (cost=0.00..1.12 rows=3 width=8)
   Filter: ((f1 - f1) >= '00:00'::interval)
(2 rows)

In "C" locale, the textual comparison accidentally manages to give
the desired answers, but in other locales it would not.

(Just another example of why implicit coercions to text are evil.)

            regards, tom lane

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

Предыдущее
От: "Mattias Kregert"
Дата:
Сообщение: Re: I need a SQL...
Следующее
От: Bjørn T Johansen
Дата:
Сообщение: Re: I need a SQL...