Re: Regarding select distinct ...query

Поиск
Список
Период
Сортировка
От Ian Harding
Тема Re: Regarding select distinct ...query
Дата
Msg-id se00a5af.023@mail.tpchd.org
обсуждение исходный текст
Ответ на Regarding select distinct ...query  ("Prachi Jain" <prachijain3@rediffmail.com>)
Список pgsql-general
What's a non-standard cast?  select distinct cast('foo' as varchar) should work just about everywhere...  Explicit
castsare never a bad idea afaics... 

Ian Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
iharding@tpchd.org
(253) 798-3549

>>> Greg Stark <gsstark@mit.edu> 12/18/02 04:12PM >>>

Tom Lane <tgl@sss.pgh.pa.us> writes:

> Greg Stark <gsstark@mit.edu> writes:
> > I ran into precisely the same issue here yesterday. This works perfectly fine
> > in Oracle, does the standard really leave "select distinct 'foo'" undefined?
>
> The standard has no notion of datatype extensibility, so it's got no
> problem with legislating that anything between single quotes is of type
> CHAR(n).  If we followed the spec closely on this point, you'd probably
> need an explicit cast for *every* literal you wanted to be of a datatype
> other than numeric (no quotes) or string (with quotes).

Well, if that what the spec says then I would imagine you should at least
follow it in the absence of other information. I don't see what's "dangerous"
about the assumption that valid standard SQL code should be interpreted as
such.

In the current situation we have a perfectly fine standard SQL query that runs
fine on other databases but fails on postgres. And the only way to "fix" it
for postgres is to add a non-standard cast to it that won't work on the other
databases.

I'm kind of surprised actually that it doesn't work the other way around. It
seems like the standard datatypes ought to be the default for all constants
and the kludges should only be necessary to automatically cast strings and
numbers to other datatypes for programmer convenience.

--
greg


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly


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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Batch Insert Performance
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Regarding select distinct ...query